From 4e201e075237976d674204e36a1c2cc367999263 Mon Sep 17 00:00:00 2001 From: Administrator <123456> Date: Tue, 1 Mar 2022 08:53:19 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=B8=BB=E9=A2=98=E8=AE=BE=E7=BD=AE-?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E7=AB=A0=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/pages/course/subject/step/index.tsx | 79 +++++++++++++------ 1 file changed, 55 insertions(+), 24 deletions(-) diff --git a/admin/src/pages/course/subject/step/index.tsx b/admin/src/pages/course/subject/step/index.tsx index 08655ae..9ad6433 100644 --- a/admin/src/pages/course/subject/step/index.tsx +++ b/admin/src/pages/course/subject/step/index.tsx @@ -29,6 +29,7 @@ import { v4 as uuidv4 } from 'uuid'; import {DataItem} from "@antv/data-set/lib/transform/tag-cloud"; import {removeTrain} from "@/pages/training/option/service"; import {listMyLearningChapterCourse} from "../../../../../../web/src/pages/course/list/service"; +import course from "../../../../../../web/mock/course"; const { confirm } = Modal; @@ -42,8 +43,9 @@ const { confirm } = Modal; const handleAddChapter = async (fields: TableListItem) => { const hide = message.loading('正在添加'); try { - const {course_ids} = fields - const {code, msg} = await saveChapter({ ...fields, course_ids: course_ids.toString()}); + const {course_ids} = fields; + const {tag_ids} = fields; + const {code, msg} = await saveChapter({ ...fields, course_ids: course_ids.toString(),tag_ids: tag_ids.toString()}); if(code === 2000){ hide(); message.success('添加成功'); @@ -140,7 +142,7 @@ export default () => { { title: '标签', valueType: 'select', - dataIndex: 'tags', + dataIndex: 'tag_ids', sorter: false, hideInTable: true, hideInForm: false, @@ -148,10 +150,18 @@ export default () => { fieldProps: { mode: "multiple" }, + formItemProps: { + rules: [ + { + required: true, + message: '请填选择标签', + }, + ] + }, renderText: (val: string) => `${val}`, request: async () => { const { data: Items } = await queryTagList({}); - console.log('queryTagList...') + console.log('queryTagList..Items标签.',Items) const tags = [] for (let i = 0; i < Items.length; i++) { tags.push({ label: Items[i].tag_name, value: Items[i].tag_id }) @@ -180,12 +190,29 @@ export default () => { }, ] }, - renderText: (val: string) => `${val}`, - dependencies: ['tags'], - request: async (params) => { - const {tags} = params; - const { data: Items } = await queryCourseListByTag({tag_ids: tags?.toString()}); - console.log('queryCourseListByTag...') + render: (_dom: any, record: React.SetStateAction) => [ +
+ {console.log('record.course_names',record.course_names)} + { + record.course_names.length!==0?record.course_names.map((i,index)=>{ + if(index+1===record.course_names.length){ + return i + }else { + return i+',' + } + + }):'--' + } +
+ ], + + // renderText: (val: string) => `${val}`, + dependencies: ['tag_ids'], + request: async (arr) => { + console.log('arr',arr) + const {tags} = arr; + const { data: Items } = await queryCourseListByTag({tag_ids:arr?.tag_ids?.toString()}); + console.log('queryCourseListByTag...Items课程列表',Items) const courses = [] for (let i = 0; i < Items?.length; i++) { courses.push({ label: Items[i]?.course_name, value: Items[i]?.course_id }) @@ -236,7 +263,6 @@ export default () => { const params = useParams(); - console.log('params', params); const {data:subjectInfo} = useRequest(() => { return getSubjectInfo({subject_id: params?.id}); @@ -272,7 +298,6 @@ export default () => { } return true; } catch (error) { - // console.log('error', error) hide(); message.error('删除失败,请重试'); return false; @@ -280,8 +305,6 @@ export default () => { }; useEffect(() => { - console.log('getSubjectInfo', subjectInfo); - console.log('url', subjectInfo?.attachment_json?.url); // 编辑场景下需要使用formMapRef循环设置formData formMapRef.current.forEach((formInstanceRef) => { let fieldsValue; @@ -311,14 +334,11 @@ export default () => { /** 获取列数据初始值 */ const getInitialValues = (cols: any[], vals: any) => { - console.log('getInitialValues-columns', columns); - console.log('getInitialValues-values', vals); const initialValues: any[] = []; cols.forEach((column: { dataIndex: string }) => { const key: any = column?.dataIndex || ''; initialValues.push({ ...column, initialValue: key ? vals[key] : '' }); }); - console.log('initialValues::', initialValues); return initialValues || []; }; @@ -331,7 +351,6 @@ export default () => { formMapRef={formMapRef} formRef={formRef} onFinish={async (values) => { - console.log('values::', values) message.success('提交成功'); }} formProps={{ @@ -361,7 +380,6 @@ export default () => { }}*/ onFinish={async (value: any) => { - console.log(value, "vvvvv"); const url = value?.upload[0]?.url?.replace('/dsideal_yy/html/','') || value?.upload[0]?.response?.url; const { data } = await saveSubject({ @@ -406,7 +424,6 @@ export default () => { listType: 'picture-card', maxCount: 1, beforeUpload: (file) => { - console.log('file', file) // 获取文件名 SetUploadFileName(file?.name); // 获取最后一个.的位置 @@ -505,6 +522,15 @@ export default () => { page_number: value?.current || 1, page_size: value?.pageSize, }); + if(data.list.length!==0){ + data.list.forEach((i)=>{ + i.course_ids=parseInt(i.course_ids.split(',')) + i.course_names=i.course_names.split(',') + i.tag_ids=parseInt(i.tag_ids.split(',')) + i.tag_names=i.tag_names.split(',') + }) + console.log('data.list.',data.list) + } return { current: data?.page_number, data: data?.list, @@ -536,7 +562,12 @@ export default () => { onFinish={async (values: any) => { // 表单处理 console.log('columns:', columns); - console.log('values:', values); + console.log('values:新建', values); + // values['tag_ids']=values.tags; + values.tag_ids=values.tag_names.toString(); + values.course_ids=values.course_names.toString(); + delete values.course_names; + delete values.tag_names; const success = await handleAddChapter({ ...values, subject_id: params?.id || 0, @@ -571,7 +602,7 @@ export default () => { }} footer={null} > - {console.log('currentRow',currentRow)} + {/*{console.log('currentRow',currentRow)}*/} {currentRow?.chapter_id && ( layout="horizontal" @@ -579,7 +610,7 @@ export default () => { labelCol={{ span: 8 }} wrapperCol={{ span: 12 }} onFinish={async (values) => { - console.log('values', values) + console.log('values编辑', values) console.log('currentRow', currentRow) //const url = values?.upload[0]?.url?.replace('/dsideal_yy/html/','') || values?.upload[0]?.response?.url; //console.log('url', url) @@ -589,7 +620,7 @@ export default () => { // course_id: currentRow?.course_id, // attachment_json: `{"img":"", "name": "${values.attachment_json?.name}", "url": "${values.attachment_json?.url}", "size": "${values.attachment_json?.size}"}` // }); - handleUpdateModalVisible(false); // 隐藏编辑窗口 + // handleUpdateModalVisible(false); // 隐藏编辑窗口 actionRef.current?.reloadAndRest?.(); console.log(values); }} From 2fa20315213fa3c7022490c9bc70f1710ea16f93 Mon Sep 17 00:00:00 2001 From: Administrator <123456> Date: Tue, 1 Mar 2022 10:01:57 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=B8=BB=E9=A2=98=E8=AE=BE=E7=BD=AE-?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E7=AB=A0=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/pages/course/subject/step/index.tsx | 76 +++++++++++-------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/admin/src/pages/course/subject/step/index.tsx b/admin/src/pages/course/subject/step/index.tsx index 9ad6433..8963745 100644 --- a/admin/src/pages/course/subject/step/index.tsx +++ b/admin/src/pages/course/subject/step/index.tsx @@ -34,6 +34,25 @@ import course from "../../../../../../web/mock/course"; const { confirm } = Modal; +//编辑章节 handleUpdateChapter + +const handleUpdateChapter = async (fields: TableListItem) => { + try { + const {course_ids} = fields; + const {tag_ids} = fields; + const {code, msg} = await saveChapter({ ...fields, course_ids: course_ids.toString(),tag_ids: tag_ids.toString()}); + if(code === 2000){ + message.success('编辑成功'); + return true; + }else{ + message.warn(msg); + return false; + } + } catch (error) { + message.error('编辑失败请重试!'); + return false; + } +}; /** * 添加章节 @@ -161,12 +180,10 @@ export default () => { renderText: (val: string) => `${val}`, request: async () => { const { data: Items } = await queryTagList({}); - console.log('queryTagList..Items标签.',Items) const tags = [] for (let i = 0; i < Items.length; i++) { tags.push({ label: Items[i].tag_name, value: Items[i].tag_id }) } - console.log(tags, 'tags:::'); return tags; }, align:'center' @@ -192,7 +209,6 @@ export default () => { }, render: (_dom: any, record: React.SetStateAction) => [
- {console.log('record.course_names',record.course_names)} { record.course_names.length!==0?record.course_names.map((i,index)=>{ if(index+1===record.course_names.length){ @@ -209,15 +225,13 @@ export default () => { // renderText: (val: string) => `${val}`, dependencies: ['tag_ids'], request: async (arr) => { - console.log('arr',arr) - const {tags} = arr; + // console.log('arr',arr) + // const {tags} = arr; const { data: Items } = await queryCourseListByTag({tag_ids:arr?.tag_ids?.toString()}); - console.log('queryCourseListByTag...Items课程列表',Items) const courses = [] for (let i = 0; i < Items?.length; i++) { courses.push({ label: Items[i]?.course_name, value: Items[i]?.course_id }) } - console.log(courses, 'courses:::'); return courses; }, align:'center' @@ -524,12 +538,18 @@ export default () => { }); if(data.list.length!==0){ data.list.forEach((i)=>{ - i.course_ids=parseInt(i.course_ids.split(',')) + i.course_ids=i.course_ids.split(',') i.course_names=i.course_names.split(',') - i.tag_ids=parseInt(i.tag_ids.split(',')) + i.tag_ids=i.tag_ids.split(',') i.tag_names=i.tag_names.split(',') }) - console.log('data.list.',data.list) + + } + if(data.list.length!==0){ + data.list.forEach((item)=>{ + item.tag_ids=item.tag_ids.map(i => i * 1); + item.course_ids=item.course_ids.map(a => a * 1); + }) } return { current: data?.page_number, @@ -561,13 +581,8 @@ export default () => { wrapperCol={{ span: 12 }} onFinish={async (values: any) => { // 表单处理 - console.log('columns:', columns); - console.log('values:新建', values); - // values['tag_ids']=values.tags; - values.tag_ids=values.tag_names.toString(); - values.course_ids=values.course_names.toString(); - delete values.course_names; - delete values.tag_names; + // console.log('columns:', columns); + // console.log('values:新建', values); const success = await handleAddChapter({ ...values, subject_id: params?.id || 0, @@ -602,7 +617,6 @@ export default () => { }} footer={null} > - {/*{console.log('currentRow',currentRow)}*/} {currentRow?.chapter_id && ( layout="horizontal" @@ -610,19 +624,17 @@ export default () => { labelCol={{ span: 8 }} wrapperCol={{ span: 12 }} onFinish={async (values) => { - console.log('values编辑', values) - console.log('currentRow', currentRow) - //const url = values?.upload[0]?.url?.replace('/dsideal_yy/html/','') || values?.upload[0]?.response?.url; - //console.log('url', url) - // await handleUpdate({ - // ...values, - // attachment_filesize: attachment_json?.size || 0, // Bit 字节 - // course_id: currentRow?.course_id, - // attachment_json: `{"img":"", "name": "${values.attachment_json?.name}", "url": "${values.attachment_json?.url}", "size": "${values.attachment_json?.size}"}` - // }); - // handleUpdateModalVisible(false); // 隐藏编辑窗口 - actionRef.current?.reloadAndRest?.(); - console.log(values); + // console.log('values编辑', values) + // console.log('currentRow', currentRow) + const success = await handleUpdateChapter({ + ...values, + subject_id: params?.id || 0, + chapter_id:currentRow.chapter_id + }); + if(success){ + handleUpdateModalVisible(false); + actionRef.current?.reloadAndRest?.(); + } }} submitter={{ render: (props, doms) => ( @@ -649,9 +661,7 @@ export default () => { description: false, }} onFinish={async (values) => { - console.log('subject_id:', subjectIntro?.subject_id); await commitSubject({subject_id: subjectIntro?.subject_id}); - console.log(formRef.current?.getFieldsValue()); // 跳转到指定路由 history.push('/course/subject'); return true; From e7c56a9a0af148dfd8c1c3b15268f4252324b289 Mon Sep 17 00:00:00 2001 From: Administrator <123456> Date: Tue, 1 Mar 2022 15:15:24 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E8=80=83=E8=AF=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=BF=AE=E6=94=B9=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=8A=A5=E5=90=8D=E5=85=A5=E5=8F=A3=EF=BC=8C=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=AD=A6=E4=B9=A0=E8=B7=B3=E8=BD=AC=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/config/config.ts | 1 + web/src/pages/course/list/index.tsx | 4 ++-- web/src/pages/dashboard/workplace/index.tsx | 19 ++++++++++--------- web/src/pages/registration/index.tsx | 16 +++++++++++++--- web/src/pages/registration/success/index.tsx | 4 +++- 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/web/config/config.ts b/web/config/config.ts index b8c7bde..6ad87b9 100644 --- a/web/config/config.ts +++ b/web/config/config.ts @@ -75,6 +75,7 @@ export default defineConfig({ { name: '考试报名', icon: 'dashboard', + hideInMenu: true, path: '/registration', routes: [ { diff --git a/web/src/pages/course/list/index.tsx b/web/src/pages/course/list/index.tsx index b8c48d6..6f3b105 100644 --- a/web/src/pages/course/list/index.tsx +++ b/web/src/pages/course/list/index.tsx @@ -95,7 +95,7 @@ const CardList = () => { onClick={() => { if (last_data) { const info = last_data.chapter_id + ',' + last_data.course_id + ',' + subject_data.subject_id; - window.open('/#/course/detail/' + info) + window.open(location.pathname+'#/course/detail/' + info) } }} @@ -156,7 +156,7 @@ const CardList = () => {
diff --git a/web/src/pages/dashboard/workplace/index.tsx b/web/src/pages/dashboard/workplace/index.tsx index 3606ca5..64570ec 100644 --- a/web/src/pages/dashboard/workplace/index.tsx +++ b/web/src/pages/dashboard/workplace/index.tsx @@ -82,17 +82,17 @@ const examinationColumns = [ render: (_, record, index, action) => { // return record?.status === 0 ? : switch (record.status_type) { - case 0: - return "待报名" + case 0://待报名 + return break; - case 1: - return "报名中" + case 1://报名中 + return //判断 break; - case 2: - return "待考试" + case 2://待考试 + return break; - case 3: - return + case 3://考试中 + return break; case 4: return "考试完成" @@ -100,6 +100,7 @@ const examinationColumns = [ default: break; } + }, }, ]; @@ -253,7 +254,7 @@ const Workplace: FC = () => { //responsive xField="learning_date" yField="learning_minutes" - //seriesField="type" + //seriesField="type" legend={{ position: 'top-center', }} diff --git a/web/src/pages/registration/index.tsx b/web/src/pages/registration/index.tsx index 6abf292..f758655 100644 --- a/web/src/pages/registration/index.tsx +++ b/web/src/pages/registration/index.tsx @@ -1,5 +1,5 @@ import React, { useRef,useState } from 'react'; -import { history,useRequest } from 'umi'; +import {history, useParams, useRequest} from 'umi'; import Base64 from 'base64-js'; import { ProFormInstance, ProFormRadio } from '@ant-design/pro-form'; import ProForm, { @@ -32,6 +32,8 @@ const waitTime = (time: number = 100) => { export default () => { + const params = useParams(); + console.log('params',params) const formRef = useRef(); const [baseInfo, setBaseInfo] = useState({}); const [testInfo, setTestInfo] = useState({}); @@ -123,7 +125,9 @@ export default () => { label="出生年月" fieldProps={{ format: 'YYYY-MM', + }} + rules={[{ required: true, message: '请选择出生年月' }]} /> @@ -219,12 +223,18 @@ export default () => { //actionRef={actionRef} request={async (value) => { const data = await queryExaminationRule({ - examination_id: 2 + examination_id: params.examination_id }); setTestInfo(data.bean); const dom=data.bean.examination_start_time+'-'+data.bean.examination_end_time; + if(data){ + data.bean.sum_score=data.bean.sum_score===null?'--':data.bean.sum_score + data.bean.pass_score=data.bean.pass_score===null?'--':data.bean.pass_score + } + return Promise.resolve({ + success: true, data: { id: data?.bean.id, object:data?.bean.examination_name, @@ -269,7 +279,7 @@ export default () => { district_id:backInfo?.district_id, district_name:backInfo?.district_name, education:baseInfo?.qualifications, - examination_id:2, + examination_id:params.examination_id, gender:baseInfo?.sex, id_code:baseInfo?.idCard, identity_id:backInfo?.identity_id, diff --git a/web/src/pages/registration/success/index.tsx b/web/src/pages/registration/success/index.tsx index f74828b..5a762c2 100644 --- a/web/src/pages/registration/success/index.tsx +++ b/web/src/pages/registration/success/index.tsx @@ -9,7 +9,9 @@ const { Step } = Steps; const extra = ( - + );