From 9c6af9d23ebb567495c7d7c41d3ae3fde059cc92 Mon Sep 17 00:00:00 2001 From: xialiang <1818147@qq.com> Date: Thu, 17 Mar 2022 09:56:44 +0800 Subject: [PATCH] 0317 --- admin/src/pages/course/subject/index.tsx | 114 ++++++------ admin/src/pages/course/subject/step/index.tsx | 170 +++++++++--------- .../pages/examination/certificate/index.tsx | 2 +- .../pages/examination/certificate/person.tsx | 15 +- admin/src/pages/examination/option/index.tsx | 10 +- .../pages/examination/registration/index.tsx | 2 +- admin/src/pages/training/option/index.tsx | 2 +- web/src/pages/dashboard/workplace/index.tsx | 69 +++---- .../mockExamination/chapterExamination.tsx | 6 +- 9 files changed, 199 insertions(+), 191 deletions(-) diff --git a/admin/src/pages/course/subject/index.tsx b/admin/src/pages/course/subject/index.tsx index 5e1df6e..7c08457 100644 --- a/admin/src/pages/course/subject/index.tsx +++ b/admin/src/pages/course/subject/index.tsx @@ -39,7 +39,7 @@ const chapterColumns: ProColumns[] = [ hideInTable: false, hideInForm: false, hideInSearch: true, - renderText: (val: string) => (
), + renderText: (val: string) => (
), }, { title: '课程', @@ -54,8 +54,8 @@ const chapterColumns: ProColumns[] = [ }, renderText: (val: string) => `${val}`, request: async (params) => { - const {tags} = params; - const { data: Items } = await queryCourseListByTag({tag_ids: tags?.toString()}); + const { tags } = params; + const { data: Items } = await queryCourseListByTag({ tag_ids: tags?.toString() }); console.log('queryCourseListByTag...') const courses = [] for (let i = 0; i < Items?.length; i++) { @@ -74,7 +74,7 @@ const chapterColumns: ProColumns[] = [ hideInTable: false, hideInForm: true, hideInSearch: true, - renderText: (val: string) => `${val}`, + renderText: (val: string) => `${val}学时`, }, ]; @@ -130,13 +130,13 @@ const handleRemove = async (selectedRows: TableListItem[]) => { if (!selectedRows) return true; try { - const {code, msg} = await removeSubject({ + const { code, msg } = await removeSubject({ key: selectedRows.map((row) => row.key), }); hide(); - if(code === 2000 ){ + if (code === 2000) { message.success('删除成功,即将刷新'); - }else{ + } else { message.warning(msg); } return true; @@ -220,7 +220,7 @@ const TableList: React.FC = () => { hideInSearch: true, width: 200, render: (dom, entity) => { - if(entity.b_use === 0){ + if (entity.b_use === 0) { return '待发布' } @@ -287,7 +287,7 @@ const TableList: React.FC = () => { , { + onClick={() => { showConfirm(record) }}> @@ -296,10 +296,10 @@ const TableList: React.FC = () => { ], }, ]; - const showConfirm=async (record)=>{ + const showConfirm = async (record) => { confirm({ title: '确认删除主题吗?', - centered:true, + centered: true, onOk() { handleRemove([{ key: record?.subject_id }]); // 调用批量删除函数(如果接口不支持批量需要在service中处理) setSelectedRows([]); @@ -426,53 +426,53 @@ const TableList: React.FC = () => { > {currentRow?.subject_id && ( <> - { - console.log('step2 主题信息') - return Promise.resolve({ - success: true, - data: { id: '这是一段文本', object: '', date: '2020-07-30 08:00', duration: '', grade: 100, through: '>60', learn: '>20 min', times: 2 }, - }); - }}*/ - extra={false} - > - - {currentRow?.subject_name} - -
- - + { + console.log('step2 主题信息') + return Promise.resolve({ + success: true, + data: { id: '这是一段文本', object: '', date: '2020-07-30 08:00', duration: '', grade: 100, through: '>60', learn: '>20 min', times: 2 }, + }); + }}*/ + extra={false} + > + + {currentRow?.subject_name} + +
+ + - - headerTitle={false} - actionRef={actionChapterRef} - rowKey="chapter_id" - options={false} - search={false} - toolBarRender={false} - request={async (value) => { - const { data } = await queryListChapterBySubject({ - subject_id: currentRow?.subject_id, - page_number: value?.current || 1, - page_size: value?.pageSize, - }); - return { - current: data?.page_number, - data: data?.list, - pageSize: data?.page_size, - success: true, - total: data?.total_row || 0, - }; - }} - // dataSource={list} - columns={chapterColumns} - rowSelection={false} - /> + + headerTitle={false} + actionRef={actionChapterRef} + rowKey="chapter_id" + options={false} + search={false} + toolBarRender={false} + request={async (value) => { + const { data } = await queryListChapterBySubject({ + subject_id: currentRow?.subject_id, + page_number: value?.current || 1, + page_size: value?.pageSize, + }); + return { + current: data?.page_number, + data: data?.list, + pageSize: data?.page_size, + success: true, + total: data?.total_row || 0, + }; + }} + // dataSource={list} + columns={chapterColumns} + rowSelection={false} + /> )} diff --git a/admin/src/pages/course/subject/step/index.tsx b/admin/src/pages/course/subject/step/index.tsx index 74996f6..ffbcdaf 100644 --- a/admin/src/pages/course/subject/step/index.tsx +++ b/admin/src/pages/course/subject/step/index.tsx @@ -23,12 +23,12 @@ import ProFormRichEdit from '../components/ProFormRichEdit'; import type { ActionType, ProColumns } from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table'; import type { TableListItem, TableListPagination } from '../../option/data'; -import {queryCourseList, queryCourseListByTag, queryTagList, removeCourse, saveSubject} from '../../option/service'; -import { commitSubject, getSubjectInfo, queryListChapterBySubject, saveChapter,deleteChapter } from '../service'; +import { queryCourseList, queryCourseListByTag, queryTagList, removeCourse, saveSubject } from '../../option/service'; +import { commitSubject, getSubjectInfo, queryListChapterBySubject, saveChapter, deleteChapter } from '../service'; 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 type { 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; @@ -38,13 +38,13 @@ const { confirm } = Modal; 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){ + 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{ + } else { message.warn(msg); return false; } @@ -62,14 +62,14 @@ const handleUpdateChapter = async (fields: TableListItem) => { const handleAddChapter = async (fields: TableListItem) => { const hide = message.loading('正在添加'); 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){ + 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('添加成功'); return true; - }else{ + } else { hide(); message.warn(msg); return false; @@ -96,6 +96,7 @@ export default () => { const [uploadFileExt, SetUploadFileExt] = useState(); const [subjectIntro, setSubjectIntro] = useState({}); + const [subjectId, setSubjectId] = useState({}); const [currentRow, setCurrentRow] = useState(); const formMapRef = useRef | undefined>[]>([]); @@ -106,7 +107,7 @@ export default () => { key: 'index', valueType: 'indexBorder', width: 48, - align:'center' + align: 'center' }, { title: '章节名称', @@ -124,7 +125,7 @@ export default () => { }, ] }, - align:'center' + align: 'center' }, { title: '简介', @@ -142,7 +143,7 @@ export default () => { }, ] }, - renderText: (val: string) => (
), + renderText: (val: string) => (
), renderFormItem: (item, { defaultRender, ...rest }, form) => ( { placeholder="请输入介绍" // rules={[{ required: true }]} value="" - // disabled + // disabled /> ), - align:'center' + align: 'center' }, { title: '标签', @@ -186,7 +187,7 @@ export default () => { } return tags; }, - align:'center' + align: 'center' }, { title: '课程', @@ -208,18 +209,18 @@ export default () => { ] }, render: (_dom: any, record: React.SetStateAction) => [ -
- { - record.course_names.length!==0?record.course_names.map((i,index)=>{ - if(index+1===record.course_names.length){ - return i - }else { - return i+',' - } - - }):'--' - } -
+
+ { + 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}`, @@ -227,14 +228,14 @@ export default () => { request: async (arr) => { // console.log('arr',arr) // const {tags} = arr; - const { data: Items } = await queryCourseListByTag({tag_ids:arr?.tag_ids?.toString()}); + const { data: Items } = await queryCourseListByTag({ tag_ids: arr?.tag_ids?.toString() }); const courses = [] for (let i = 0; i < Items?.length; i++) { courses.push({ label: Items[i]?.course_name, value: Items[i]?.course_id }) } return courses; }, - align:'center' + align: 'center' }, { title: '学时', @@ -245,7 +246,7 @@ export default () => { hideInForm: true, hideInSearch: true, renderText: (val: string) => `${val}`, - align:'center' + align: 'center' }, { @@ -253,11 +254,11 @@ export default () => { dataIndex: 'option', valueType: 'option', width: 200, - align:'center', + align: 'center', render: (_dom: any, record: React.SetStateAction) => [
{ setCurrentRow(record); handleUpdateModalVisible(true); @@ -275,18 +276,17 @@ export default () => { }, ]; - const params = useParams(); - const {data:subjectInfo} = useRequest(() => { - return getSubjectInfo({subject_id: params?.id}); + const { data: subjectInfo } = useRequest(() => { + return getSubjectInfo({ subject_id: params?.id }); }); - const showConfirm=async (record)=>{ + const showConfirm = async (record) => { confirm({ title: '确认删除章节吗?', - centered:true, + centered: true, onOk() { handleRemove([record]); setSelectedRows([]); @@ -301,13 +301,13 @@ export default () => { const hide = message.loading('正在删除'); if (!selectedRows) return true; try { - const {code, msg} = await deleteChapter({ + const { code, msg } = await deleteChapter({ key: selectedRows, }); hide(); - if(code === 2000 ){ + if (code === 2000) { message.success('删除成功,即将刷新'); - }else{ + } else { message.warning(msg); } return true; @@ -318,18 +318,22 @@ export default () => { } }; + useEffect(() => { + setSubjectId(params?.id) + + }, []) useEffect(() => { // 编辑场景下需要使用formMapRef循环设置formData formMapRef.current.forEach((formInstanceRef) => { let fieldsValue; const subjectValue = { - subject_name:subjectInfo?.subject_name, - subject_describe:subjectInfo?.subject_describe, + subject_name: subjectInfo?.subject_name, + subject_describe: subjectInfo?.subject_describe, } - if(params?.id && subjectInfo?.attachment_json?.url){ + if (params?.id && subjectInfo?.attachment_json?.url) { fieldsValue = { ...subjectValue, - upload:[ + upload: [ { name: subjectInfo?.attachment_json?.name, status: 'done', @@ -337,7 +341,7 @@ export default () => { } ] } - }else{ + } else { // 无附件 fieldsValue = subjectValue; } @@ -393,19 +397,21 @@ export default () => { }}*/ onFinish={async (value: any) => { + console.log(subjectId, 'subjectId') - const url = value?.upload[0]?.url?.replace('/dsideal_yy/html/','') || value?.upload[0]?.response?.url; + const url = value?.upload[0]?.url?.replace('/dsideal_yy/html/', '') || value?.upload[0]?.response?.url; const info = await saveSubject({ ...value, - subject_id: params?.id, + subject_id: subjectId, attachment_json: `{ "url": "${url}"}` }); - if(info.code!==2000){ + if (info.code !== 2000) { message.warning(info.msg); return false; - }else { - setSubjectIntro({subject_id:info?.data.subject_id, subject_name: value?.subject_name, subject_describe:value?.subject_describe}); + } else { + setSubjectId(info?.data.subject_id) + setSubjectIntro({ subject_id: info?.data.subject_id, subject_name: value?.subject_name, subject_describe: value?.subject_describe }); return true; } @@ -439,7 +445,7 @@ export default () => { label="主题图片" max={2} fieldProps={{ - accept:'.jpg,.jpeg,.git,.png', + accept: '.jpg,.jpeg,.git,.png', name: 'file', listType: 'picture-card', maxCount: 1, @@ -530,7 +536,7 @@ export default () => { {subjectIntro?.subject_name} -
+
@@ -559,19 +565,19 @@ export default () => { page_number: value?.current || 1, page_size: value?.pageSize, }); - if(data.list.length!==0){ - data.list.forEach((i)=>{ - i.course_ids=i.course_ids.split(',') - i.course_names=i.course_names.split(',') - i.tag_ids=i.tag_ids.split(',') - i.tag_names=i.tag_names.split(',') + if (data.list.length !== 0) { + data.list.forEach((i) => { + i.course_ids = i.course_ids.split(',') + i.course_names = i.course_names.split(',') + i.tag_ids = i.tag_ids.split(',') + i.tag_names = i.tag_names.split(',') }) } - 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); + 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 { @@ -610,7 +616,7 @@ export default () => { ...values, subject_id: params?.id || 0, }); - if(success){ + if (success) { handleCreateModalVisible(false); actionRef.current?.reloadAndRest?.(); } @@ -652,9 +658,9 @@ export default () => { const success = await handleUpdateChapter({ ...values, subject_id: params?.id || 0, - chapter_id:currentRow.chapter_id + chapter_id: currentRow.chapter_id }); - if(success){ + if (success) { handleUpdateModalVisible(false); actionRef.current?.reloadAndRest?.(); } @@ -684,7 +690,7 @@ export default () => { description: false, }} onFinish={async (values) => { - await commitSubject({subject_id: subjectIntro?.subject_id}); + await commitSubject({ subject_id: subjectIntro?.subject_id }); // 跳转到指定路由 history.push('/course/subject'); return true; @@ -693,17 +699,17 @@ export default () => { - - 主题 {subjectIntro?.subject_name} 创建/修改成功 -
- } - subTitle="点击提交将设置为发布状态。" + + 主题 {subjectIntro?.subject_name} 创建/修改成功 +
+ } + subTitle="点击提交将设置为发布状态。" //extra={actions} - /> + /> diff --git a/admin/src/pages/examination/certificate/index.tsx b/admin/src/pages/examination/certificate/index.tsx index 832ff9c..258dda6 100644 --- a/admin/src/pages/examination/certificate/index.tsx +++ b/admin/src/pages/examination/certificate/index.tsx @@ -219,7 +219,7 @@ const CourseList: React.FC = () => { history.push('/examination/certificate/person/' + record.examination_id + "/" + record.accreditation_status + "/" + encodeURIComponent(record.examination_name)) }} - disabled={record.status_type === 4 ? false : true} + // disabled={record.status_type === 4 ? false : true} > 查看名单{record.status_type} , diff --git a/admin/src/pages/examination/certificate/person.tsx b/admin/src/pages/examination/certificate/person.tsx index ab64d1c..cd13ef6 100644 --- a/admin/src/pages/examination/certificate/person.tsx +++ b/admin/src/pages/examination/certificate/person.tsx @@ -158,7 +158,7 @@ const CourseList: React.FC = () => { }, { title: '考试时间', - valueType: 'dateTimeRange', + valueType: 'dateRange', dataIndex: 'examination_time', sorter: false, hideInTable: false, @@ -182,10 +182,11 @@ const CourseList: React.FC = () => { { title: '姓名或学校', dataIndex: 'bureau_name', - sorter: true, + sorter: false, valueType: 'text', hideInForm: true, hideInSearch: false, + hideInTable: true, }, @@ -231,11 +232,12 @@ const CourseList: React.FC = () => { request={async (value) => { console.log(value, 'form value') - const { create_time } = value; - if (create_time) { - value.start_time = create_time[0] - value.end_time = create_time[1] + const { examination_time } = value; + if (examination_time) { + value.start_date = examination_time[0] + value.end_date = examination_time[1] } + delete value.examination_time const _data = await getExaminationPersonApplyList({ ...value, examination_id: params.id, @@ -244,7 +246,6 @@ const CourseList: React.FC = () => { page_number: value.current, page_size: value.pageSize, is_pass: 1 }); - return { current: _data?.pageNumber, data: _data?.table_List, diff --git a/admin/src/pages/examination/option/index.tsx b/admin/src/pages/examination/option/index.tsx index c3ec467..73d24bc 100644 --- a/admin/src/pages/examination/option/index.tsx +++ b/admin/src/pages/examination/option/index.tsx @@ -183,7 +183,7 @@ const ExaminationList: React.FC = () => { rules: [ { required: true, - message: '此项为必填项', + message: '请选择关联主题', } ] }, @@ -210,7 +210,7 @@ const ExaminationList: React.FC = () => { rules: [ { required: true, - message: '此项为必填项', + message: '请选择关联考试规则', }, ] }, @@ -219,13 +219,14 @@ const ExaminationList: React.FC = () => { { title: '在线学习时长(分钟)', dataIndex: 'learning_time', - valueType: 'text', + valueType: 'digit', hideInForm: false, hideInSearch: true, hideInTable: true, renderText: (val: string) => `${val}`, fieldProps: { - maxLength: 3 + maxLength: 3, + min: 1 }, formItemProps: { rules: [ @@ -626,7 +627,6 @@ const ExaminationList: React.FC = () => { ), }} // action = '' - title="编辑" columns={getInitialValues(columns, currentRow)} /> )} diff --git a/admin/src/pages/examination/registration/index.tsx b/admin/src/pages/examination/registration/index.tsx index 9223898..a6b8c42 100644 --- a/admin/src/pages/examination/registration/index.tsx +++ b/admin/src/pages/examination/registration/index.tsx @@ -217,7 +217,7 @@ const RegistrationList: React.FC = () => { title: '考试时间', dataIndex: 'examination_time', valueType: 'dateTimeRange', - sorter: true, + sorter: false, hideInTable: false, hideInForm: true, hideInSearch: false, diff --git a/admin/src/pages/training/option/index.tsx b/admin/src/pages/training/option/index.tsx index d9e145a..9c30a99 100644 --- a/admin/src/pages/training/option/index.tsx +++ b/admin/src/pages/training/option/index.tsx @@ -271,7 +271,7 @@ const TableList: React.FC = () => { valueType: 'text', hideInForm: true, hideInSearch: true, - renderText: (val: string) => `${val}小时`, + renderText: (val: string) => `${val}学时`, }, { title: '操作', diff --git a/web/src/pages/dashboard/workplace/index.tsx b/web/src/pages/dashboard/workplace/index.tsx index 4c9f021..a884ef8 100644 --- a/web/src/pages/dashboard/workplace/index.tsx +++ b/web/src/pages/dashboard/workplace/index.tsx @@ -1,6 +1,6 @@ import type { FC } from 'react'; import { useEffect } from 'react'; -import { Avatar, Card, Col, List, Skeleton, Row, Statistic, Descriptions, Progress, Table, Button ,Image} from 'antd'; +import { Avatar, Card, Col, List, Skeleton, Row, Statistic, Descriptions, Progress, Table, Button, Image } from 'antd'; import { Line, Radar } from '@ant-design/charts'; import { Link, history, useRequest } from 'umi'; import { PageContainer } from '@ant-design/pro-layout'; @@ -126,7 +126,7 @@ const certificateColumns = [ dataIndex: 'is_pass', key: 'statusExam', render: (dom, entity) => { - return entity.is_pass = 1 ? "已通过" : "未通过" + return entity.is_pass = 1 ? "通过" : "未通过" } }, { @@ -192,7 +192,8 @@ const Workplace: FC = () => { () => getExaminationList( { person_id: cookie.load('person_id'), - b_use:1 + b_use: 1, + page_size: 999 }), { formatResult: (result) => { return result.table_List; @@ -262,12 +263,12 @@ const Workplace: FC = () => { point={{ size: 5 }} tooltip={{ customContent: (title: any, items: any): any => { - console.log('title',title); - console.log('items',items); - return( -
+ console.log('title', title); + console.log('items', items); + return ( +
{title}
-
学习时长:{items[0]?items[0].data.learning_minutes:''}
+
学习时长:{items[0] ? items[0].data.learning_minutes : ''}
@@ -277,32 +278,32 @@ const Workplace: FC = () => { />
- { - JSON.stringify(lastLearningList)!=='{}'? - } - cover={} - > - - {lastLearningList?.lecture_teacher} - {lastLearningList?.chapter_name} - {lastLearningList?.subject_name} - {lastLearningList?.total_course_minutes}分钟 - - - - :
暂无数据
- } + { + JSON.stringify(lastLearningList) !== '{}' ? + } + cover={} + > + + {lastLearningList?.lecture_teacher} + {lastLearningList?.chapter_name} + {lastLearningList?.subject_name} + {lastLearningList?.total_course_minutes}分钟 + + + + :
暂无数据
+ } { {item?.subject_name}
} - hoverable + hoverable={false} className={styles.card} actions={[]} - // extra={<>开始学习时间:{item?.learning_start_time}距离结束时间:{item?.distance_end_time}考核学时:{item?.total_course_hours}小时} + // extra={<>开始学习时间:{item?.learning_start_time}距离结束时间:{item?.distance_end_time}考核学时:{item?.total_course_hours}小时} > } @@ -53,7 +53,7 @@ const SubjectList = () => { <> -
+
{/**/}