master
xialiang 3 years ago
parent a45b26d862
commit 9c6af9d23e

@ -39,7 +39,7 @@ const chapterColumns: ProColumns<TableListItem>[] = [
hideInTable: false,
hideInForm: false,
hideInSearch: true,
renderText: (val: string) => (<div dangerouslySetInnerHTML={{__html: val}} />),
renderText: (val: string) => (<div dangerouslySetInnerHTML={{ __html: val }} />),
},
{
title: '课程',
@ -54,8 +54,8 @@ const chapterColumns: ProColumns<TableListItem>[] = [
},
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<TableListItem>[] = [
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 = () => {
</a>,
<a
key="remove"
onClick={ () => {
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([]);
@ -444,7 +444,7 @@ const TableList: React.FC = () => {
<ProDescriptions.Item dataIndex="id" hideInDescriptions />
<ProDescriptions.Item dataIndex="subject_name" label="主题名称" valueType="text">{currentRow?.subject_name}</ProDescriptions.Item>
<ProDescriptions.Item dataIndex="subject_describe" label="主题介绍" valueType="text">
<div dangerouslySetInnerHTML={{__html: currentRow?.subject_describe}} />
<div dangerouslySetInnerHTML={{ __html: currentRow?.subject_describe }} />
</ProDescriptions.Item>
</ProDescriptions>

@ -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<string>();
const [subjectIntro, setSubjectIntro] = useState({});
const [subjectId, setSubjectId] = useState({});
const [currentRow, setCurrentRow] = useState<TableListItem>();
const formMapRef = useRef<React.MutableRefObject<ProFormInstance<any> | 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) => (<div dangerouslySetInnerHTML={{__html: val}} />),
renderText: (val: string) => (<div dangerouslySetInnerHTML={{ __html: val }} />),
renderFormItem: (item, { defaultRender, ...rest }, form) => (
<ProFormRichEdit
name="chapter_describe"
@ -156,7 +157,7 @@ export default () => {
/>
),
align:'center'
align: 'center'
},
{
title: '标签',
@ -186,7 +187,7 @@ export default () => {
}
return tags;
},
align:'center'
align: 'center'
},
{
title: '课程',
@ -210,14 +211,14 @@ export default () => {
render: (_dom: any, record: React.SetStateAction<TableListItem | undefined>) => [
<div>
{
record.course_names.length!==0?record.course_names.map((i,index)=>{
if(index+1===record.course_names.length){
record.course_names.length !== 0 ? record.course_names.map((i, index) => {
if (index + 1 === record.course_names.length) {
return i
}else {
return i+''
} else {
return i + ''
}
}):'--'
}) : '--'
}
</div>
],
@ -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<TableListItem | undefined>) => [
<a
key="update"
style={{marginRight:'1rem'}}
style={{ marginRight: '1rem' }}
onClick={() => {
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 () => {
<ProDescriptions.Item dataIndex="subject_id" hideInDescriptions />
<ProDescriptions.Item dataIndex="subject_name" label="主题名称" valueType="text">{subjectIntro?.subject_name}</ProDescriptions.Item>
<ProDescriptions.Item dataIndex="subject_describe" label="主题介绍" valueType="text">
<div dangerouslySetInnerHTML={{__html: subjectIntro?.subject_describe}} />
<div dangerouslySetInnerHTML={{ __html: subjectIntro?.subject_describe }} />
</ProDescriptions.Item>
</ProDescriptions>
@ -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;
@ -698,7 +704,7 @@ export default () => {
status="success"
title={
<div className={styles.title}>
<span style={{color: '#1890ff'}}>{subjectIntro?.subject_name} </span>/
<span style={{ color: '#1890ff' }}>{subjectIntro?.subject_name} </span>/
</div>
}
subTitle="点击提交将设置为发布状态。"

@ -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}
</Button>,

@ -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,

@ -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)}
/>
)}

@ -217,7 +217,7 @@ const RegistrationList: React.FC = () => {
title: '考试时间',
dataIndex: 'examination_time',
valueType: 'dateTimeRange',
sorter: true,
sorter: false,
hideInTable: false,
hideInForm: true,
hideInSearch: false,

@ -271,7 +271,7 @@ const TableList: React.FC = () => {
valueType: 'text',
hideInForm: true,
hideInSearch: true,
renderText: (val: string) => `${val}`,
renderText: (val: string) => `${val}`,
},
{
title: '操作',

@ -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(
<div style={{ padding: '12px 14px', fontSize: '12px', width: '180px', height: '68px',lineHeight:'20px' }}>
console.log('title', title);
console.log('items', items);
return (
<div style={{ padding: '12px 14px', fontSize: '12px', width: '180px', height: '68px', lineHeight: '20px' }}>
<div>{title}</div>
<div>{items[0]?items[0].data.learning_minutes:''}</div>
<div>{items[0] ? items[0].data.learning_minutes : ''}</div>
</div>
@ -278,7 +279,7 @@ const Workplace: FC = () => {
</div>
</Card>
{
JSON.stringify(lastLearningList)!=='{}'?
JSON.stringify(lastLearningList) !== '{}' ?
<Card
bodyStyle={{ padding: 15 }}
bordered={false}
@ -301,7 +302,7 @@ const Workplace: FC = () => {
bordered={false}
className={styles.studyCard}
title="当前学习"
><div style={{minHeight:'5rem',textAlign:'right',paddingTop:'1rem',fontSize:'15px'}}></div></Card>
><div style={{ minHeight: '5rem', textAlign: 'right', paddingTop: '1rem', fontSize: '15px' }}></div></Card>
}
</Col>
<Col xl={14} lg={14} md={14} sm={14} xs={14}>

@ -41,7 +41,7 @@ const SubjectList = () => {
<List.Item key={item?.subject_id}>
<Card
title={<a>{item?.subject_name}</a>}
hoverable
hoverable={false}
className={styles.card}
actions={[]}
// extra={<><span style={{ padding: 10 }}>开始学习时间:{item?.learning_start_time}</span><span style={{ padding: 10 }}>距离结束时间:{item?.distance_end_time}</span><span style={{ padding: 10 }}>考核学时:{item?.total_course_hours}小时</span></>}
@ -53,7 +53,7 @@ const SubjectList = () => {
<>
<Card.Grid hoverable={false} style={{ width: '50%', padding: 0 }}>
<Paragraph className={styles.item} ellipsis={{ rows: 4 }}>
<div dangerouslySetInnerHTML={{__html:item.subject_describe}}/>
<div dangerouslySetInnerHTML={{ __html: item.subject_describe }} />
</Paragraph>
</Card.Grid>
{/*<Card.Grid hoverable={false} style={{ width: '30%', textAlign: 'center' }}><Progress type="circle" percent={item?.subject_learning_progress * 100} /></Card.Grid>*/}

Loading…
Cancel
Save