diff --git a/src/index.less b/src/index.less index fc3177b..2f8e947 100644 --- a/src/index.less +++ b/src/index.less @@ -81,6 +81,10 @@ code { margin-left: 15px; } +.ml-42 { + margin-left: 42px; +} + .ml-120 { margin-left: 120px; } diff --git a/src/pages/course/compenents/hour-update.module.less b/src/pages/course/compenents/hour-update.module.less index 1c6f80b..e2a53db 100644 --- a/src/pages/course/compenents/hour-update.module.less +++ b/src/pages/course/compenents/hour-update.module.less @@ -1,13 +1,13 @@ .top-content { width: 502px; - height: 80px; + height: auto; background: rgba(255, 77, 79, 0.1); border-radius: 6px; display: flex; flex-direction: column; justify-content: center; box-sizing: border-box; - padding: 16px; + padding: 8px 16px; margin: 0 auto; p { font-size: 14px; diff --git a/src/pages/course/compenents/hour-update.tsx b/src/pages/course/compenents/hour-update.tsx index 7602371..96533ba 100644 --- a/src/pages/course/compenents/hour-update.tsx +++ b/src/pages/course/compenents/hour-update.tsx @@ -158,24 +158,37 @@ export const CourseHourUpdate: React.FC = ({ const delHour = (hid: number) => { const data = [...treeData]; - const index = data.findIndex((i: any) => i.rid === hid); - let delId = data[index].id; - if (index >= 0) { - data.splice(index, 1); - } - if (data.length > 0) { - setTreeData(data); - const keys = data.map((item: any) => item.rid); - setHours(keys); - } else { - setTreeData([]); - setHours([]); - } - if (delId) { - courseHour.destroyCourseHour(id, delId).then((res: any) => { - console.log("ok"); - }); - } + confirm({ + title: "操作确认", + icon: , + content: "确认删除此课时?", + centered: true, + okText: "确认", + cancelText: "取消", + onOk() { + const index = data.findIndex((i: any) => i.rid === hid); + let delId = data[index].id; + if (index >= 0) { + data.splice(index, 1); + } + if (data.length > 0) { + setTreeData(data); + const keys = data.map((item: any) => item.rid); + setHours(keys); + } else { + setTreeData([]); + setHours([]); + } + if (delId) { + courseHour.destroyCourseHour(id, delId).then((res: any) => { + console.log("ok"); + }); + } + }, + onCancel() { + console.log("Cancel"); + }, + }); }; const transHour = (arr: any) => { @@ -270,27 +283,40 @@ export const CourseHourUpdate: React.FC = ({ const delChapterHour = (index: number, hid: number) => { const keys = [...chapterHours]; const data = [...chapters]; - const current = data[index].hours.findIndex((i: any) => i.rid === hid); - let delId = data[index].hours.map((item: any) => item.id); - if (current >= 0) { - data[index].hours.splice(current, 1); - } - if (data[index].hours.length > 0) { - setChapters(data); - keys[index] = data[index].hours.map((item: any) => item.rid); - setChapterHours(keys); - } else { - keys[index] = []; - data[index].hours = []; - setChapters(data); - setChapterHours(keys); - } + confirm({ + title: "操作确认", + icon: , + content: "确认删除此课时?", + centered: true, + okText: "确认", + cancelText: "取消", + onOk() { + const current = data[index].hours.findIndex((i: any) => i.rid === hid); + let delId = data[index].hours.map((item: any) => item.id); + if (current >= 0) { + data[index].hours.splice(current, 1); + } + if (data[index].hours.length > 0) { + setChapters(data); + keys[index] = data[index].hours.map((item: any) => item.rid); + setChapterHours(keys); + } else { + keys[index] = []; + data[index].hours = []; + setChapters(data); + setChapterHours(keys); + } - if (delId) { - courseHour.destroyCourseHour(id, delId).then((res: any) => { - console.log("ok"); - }); - } + if (delId) { + courseHour.destroyCourseHour(id, delId).then((res: any) => { + console.log("ok"); + }); + } + }, + onCancel() { + console.log("Cancel"); + }, + }); }; const transChapterHour = (index: number, arr: any) => { @@ -359,7 +385,7 @@ export const CourseHourUpdate: React.FC = ({ {chapterType === 0 && (
-
+