|
|
|
@ -29,10 +29,30 @@ 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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//编辑章节 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;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加章节
|
|
|
|
@ -42,8 +62,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 +161,7 @@ export default () => {
|
|
|
|
|
{
|
|
|
|
|
title: '标签',
|
|
|
|
|
valueType: 'select',
|
|
|
|
|
dataIndex: 'tags',
|
|
|
|
|
dataIndex: 'tag_ids',
|
|
|
|
|
sorter: false,
|
|
|
|
|
hideInTable: true,
|
|
|
|
|
hideInForm: false,
|
|
|
|
@ -148,15 +169,21 @@ export default () => {
|
|
|
|
|
fieldProps: {
|
|
|
|
|
mode: "multiple"
|
|
|
|
|
},
|
|
|
|
|
formItemProps: {
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '请填选择标签',
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
renderText: (val: string) => `${val}`,
|
|
|
|
|
request: async () => {
|
|
|
|
|
const { data: Items } = await queryTagList({});
|
|
|
|
|
console.log('queryTagList...')
|
|
|
|
|
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'
|
|
|
|
@ -180,17 +207,31 @@ 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<TableListItem | undefined>) => [
|
|
|
|
|
<div>
|
|
|
|
|
{
|
|
|
|
|
record.course_names.length!==0?record.course_names.map((i,index)=>{
|
|
|
|
|
if(index+1===record.course_names.length){
|
|
|
|
|
return i
|
|
|
|
|
}else {
|
|
|
|
|
return i+','
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}):'--'
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
// 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()});
|
|
|
|
|
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'
|
|
|
|
@ -236,7 +277,6 @@ export default () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const params = useParams();
|
|
|
|
|
console.log('params', params);
|
|
|
|
|
|
|
|
|
|
const {data:subjectInfo} = useRequest(() => {
|
|
|
|
|
return getSubjectInfo({subject_id: params?.id});
|
|
|
|
@ -272,7 +312,6 @@ export default () => {
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
// console.log('error', error)
|
|
|
|
|
hide();
|
|
|
|
|
message.error('删除失败,请重试');
|
|
|
|
|
return false;
|
|
|
|
@ -280,8 +319,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 +348,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 +365,6 @@ export default () => {
|
|
|
|
|
formMapRef={formMapRef}
|
|
|
|
|
formRef={formRef}
|
|
|
|
|
onFinish={async (values) => {
|
|
|
|
|
console.log('values::', values)
|
|
|
|
|
message.success('提交成功');
|
|
|
|
|
}}
|
|
|
|
|
formProps={{
|
|
|
|
@ -361,7 +394,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 +438,6 @@ export default () => {
|
|
|
|
|
listType: 'picture-card',
|
|
|
|
|
maxCount: 1,
|
|
|
|
|
beforeUpload: (file) => {
|
|
|
|
|
console.log('file', file)
|
|
|
|
|
// 获取文件名
|
|
|
|
|
SetUploadFileName(file?.name);
|
|
|
|
|
// 获取最后一个.的位置
|
|
|
|
@ -505,6 +536,21 @@ 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((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,
|
|
|
|
|
data: data?.list,
|
|
|
|
@ -535,8 +581,8 @@ export default () => {
|
|
|
|
|
wrapperCol={{ span: 12 }}
|
|
|
|
|
onFinish={async (values: any) => {
|
|
|
|
|
// 表单处理
|
|
|
|
|
console.log('columns:', columns);
|
|
|
|
|
console.log('values:', values);
|
|
|
|
|
// console.log('columns:', columns);
|
|
|
|
|
// console.log('values:新建', values);
|
|
|
|
|
const success = await handleAddChapter({
|
|
|
|
|
...values,
|
|
|
|
|
subject_id: params?.id || 0,
|
|
|
|
@ -571,7 +617,6 @@ export default () => {
|
|
|
|
|
}}
|
|
|
|
|
footer={null}
|
|
|
|
|
>
|
|
|
|
|
{console.log('currentRow',currentRow)}
|
|
|
|
|
{currentRow?.chapter_id && (
|
|
|
|
|
<BetaSchemaForm<DataItem>
|
|
|
|
|
layout="horizontal"
|
|
|
|
@ -579,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) => (
|
|
|
|
@ -618,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;
|
|
|
|
|