|
|
|
@ -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<TableListItem | undefined>) => [
|
|
|
|
|
<div>
|
|
|
|
|
{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 && (
|
|
|
|
|
<BetaSchemaForm<DataItem>
|
|
|
|
|
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;
|
|
|
|
|