From 07878f88d842096f499c391d4446ca4538f209b5 Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 17 Feb 2025 17:42:49 +0800 Subject: [PATCH] up --- config/routes.ts | 12 +++++------ src/pages/TrainingClasses/add.tsx | 35 +++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/config/routes.ts b/config/routes.ts index 7de1d02..2eb64a9 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -170,18 +170,18 @@ export default [ path: '/training-classes', icon: 'book', routes: [ - { - name: '课程类型管理', - path: 'category', - access: 'trainingClassesCategoryQuery', - component: './TrainingClasses/category', - }, { name: '课程维护', path: 'list', access: 'trainingClassesQuery', component: './TrainingClasses', }, + { + name: '课程类型管理', + path: 'category', + access: 'trainingClassesCategoryQuery', + component: './TrainingClasses/category', + }, { name: '新增课程', path: 'add', diff --git a/src/pages/TrainingClasses/add.tsx b/src/pages/TrainingClasses/add.tsx index d023317..45e59d2 100644 --- a/src/pages/TrainingClasses/add.tsx +++ b/src/pages/TrainingClasses/add.tsx @@ -11,30 +11,40 @@ import { import { PageContainer } from '@ant-design/pro-layout'; import { Button, Col, message, Row } from 'antd'; import Upload, { RcFile } from 'antd/es/upload'; -import React, { useRef } from 'react'; +import React, { useRef, useState } from 'react'; +import { history } from '@umijs/max'; import { getClassesTypeListForAdminUsingPost } from '@/services/pop-b2b2c/pbcTrainingClassesTypeController'; -import { addOrUpdateClassUsingPost } from '@/services/pop-b2b2c/pbcTrainingClassesController'; +import { addOrUpdateClassUsingPost, classDetailForAdminUsingGet } from '@/services/pop-b2b2c/pbcTrainingClassesController'; const Detail: React.FC = () => { const formRef = useRef(); + const [info, setInfo] = useState() const onSave = () => { formRef.current?.submit() } + const getInfo = (id: number) => { + classDetailForAdminUsingGet({ pbcId: id }).then((res) => { + if (res.retcode && res.data) { + setInfo(res.data); + } + }); + }; + const onSubmit = async (values: any) => { let pbcImages = "" - if (values.pbcImages && values.pbcImages.length > 0) { - if ( - values.pbcImages[0].response && - values.pbcImages[0].response.retcode - ) { - pbcImages = values.pbcImages[0].response.data; - } - } + if (values.pbcImages && values.pbcImages.length > 0) { + if ( + values.pbcImages[0].response && + values.pbcImages[0].response.retcode + ) { + pbcImages = values.pbcImages[0].response.data; + } + } const params: API.PbcTrainingClasses_ = { ...values, @@ -43,9 +53,12 @@ const Detail: React.FC = () => { pbcTrainingEndDatetime: values.pbcTrainingStartDatetime[1] } const msg = await addOrUpdateClassUsingPost(params) - if (msg.retcode) { + if (msg.retcode && msg.data) { message.success("创建成功!") history.back(); + if (msg.data.pbcId) { + getInfo(msg.data.pbcId) + } return true } else { message.error(msg.retmsg)