|
|
|
@ -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="点击提交将设置为发布状态。"
|
|
|
|
|