diff --git a/src/api/courseware/index.js b/src/api/courseware/index.js index 2297818..507b0bd 100644 --- a/src/api/courseware/index.js +++ b/src/api/courseware/index.js @@ -95,6 +95,12 @@ export const courseModify = declareRequest( "Post > @/safetyEval/courseManagement/modify", ); +/** 修改课程状态(启用/禁用) */ +export const courseModifyStatus = declareRequest( + "courseLoading", + "Post > @/safetyEval/courseManagement/modifyStatus", +); + /** 分页查询班级 */ export const classPage = declareRequest( "classLoading", diff --git a/src/pages/Container/EduTraining/CourseManage/List/index.js b/src/pages/Container/EduTraining/CourseManage/List/index.js index 531097c..40b27fb 100644 --- a/src/pages/Container/EduTraining/CourseManage/List/index.js +++ b/src/pages/Container/EduTraining/CourseManage/List/index.js @@ -1,5 +1,5 @@ import { useEffect } from "react"; -import { Badge, Button, Form, Table, message } from "antd"; +import { Badge, Button, Form, Modal, Table, message } from "antd"; import { PlusOutlined } from "@ant-design/icons"; import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout"; import TableAction from "@cqsjjb/jjb-react-admin-component/TableAction"; @@ -33,6 +33,27 @@ function CourseManagePage(props) { handleSearch(); }, []); + /** 启用/禁用 */ + const onToggleStatus = (record) => { + const enabled = record.status === 1; + Modal.confirm({ + title: "提示", + content: enabled ? "是否确认禁用该课程?" : "是否确认启用该课程?", + okText: "是", + cancelText: "否", + onOk: async () => { + const res = await props.courseModifyStatus({ + id: record.id, + status: enabled ? 0 : 1, + }); + if (res?.success !== false) { + message.success("操作成功"); + handleSearch(); + } + }, + }); + }; + const columns = [ { title: "序号", @@ -85,10 +106,17 @@ function CourseManagePage(props) { }, { title: "操作", - width: 180, + width: 220, fixed: "right", render: (_, record) => ( +