diff --git a/src/compenents/tree-department/index.tsx b/src/compenents/tree-department/index.tsx index 0681622..4bd1e45 100644 --- a/src/compenents/tree-department/index.tsx +++ b/src/compenents/tree-department/index.tsx @@ -9,24 +9,32 @@ interface Option { } interface PropInterface { + text: string; onUpdate: (keys: any) => void; } export const TreeDepartment = (props: PropInterface) => { const [treeData, setTreeData] = useState([]); const [loading, setLoading] = useState(true); + const [selectKey, setSelectKey] = useState([]); useEffect(() => { setLoading(true); department.departmentList().then((res: any) => { const departments = res.data.departments; - const new_arr: Option[] = [ - { - key: "", - title: "全部", - children: checkArr(departments, 0), - }, - ]; - setTreeData(new_arr); + + if (JSON.stringify(departments) !== "{}") { + const new_arr: Option[] = checkArr(departments, 0); + setTreeData(new_arr); + } else { + const new_arr: Option[] = [ + { + key: "", + title: "全部", + children: [], + }, + ]; + setTreeData(new_arr); + } setLoading(false); }); }, []); @@ -53,7 +61,22 @@ export const TreeDepartment = (props: PropInterface) => { const onSelect = (selectedKeys: any, info: any) => { props.onUpdate(selectedKeys); + setSelectKey(selectedKeys); }; - return ; + return ( +
+
onSelect([], "")} + > + 全部{props.text} +
+ +
+ ); }; diff --git a/src/pages/course/index.tsx b/src/pages/course/index.tsx index fafc95b..2e800b3 100644 --- a/src/pages/course/index.tsx +++ b/src/pages/course/index.tsx @@ -3,21 +3,25 @@ import { Button, Row, Col, - Popconfirm, + Modal, Image, Table, Typography, Input, message, Space, + Tabs, } from "antd"; import { course } from "../../api"; import styles from "./index.module.less"; -import { PlusOutlined, ReloadOutlined } from "@ant-design/icons"; +import { PlusOutlined, ExclamationCircleFilled } from "@ant-design/icons"; import type { ColumnsType } from "antd/es/table"; import { dateFormat } from "../../utils/index"; import { Link, useNavigate } from "react-router-dom"; import { TreeDepartment, TreeCategory, PerButton } from "../../compenents"; +import type { TabsProps } from "antd"; + +const { confirm } = Modal; interface DataType { id: React.Key; @@ -40,28 +44,47 @@ export const CoursePage = () => { const [title, setTitle] = useState(""); const [dep_ids, setDepIds] = useState([]); - const columns: ColumnsType = [ + const items: TabsProps["items"] = [ { - title: "ID", - key: "id", - dataIndex: "id", - }, - { - title: "封面", - dataIndex: "thumb", - render: (thumb: string) => ( - + key: "1", + label: `分类`, + children: ( +
+ setCategoryIds(keys)} + /> +
), }, { - title: "课程标题", - dataIndex: "title", - render: (text: string) => {text}, + key: "2", + label: `部门`, + children: ( +
+ setDepIds(keys)} + /> +
+ ), }, + ]; + + const columns: ColumnsType = [ { - title: "时间", - dataIndex: "created_at", - render: (text: string) => {dateFormat(text)}, + title: "课程名称", + render: (_, record: any) => ( +
+ + {record.title} +
+ ), }, { title: "是否显示", @@ -72,6 +95,11 @@ export const CoursePage = () => { ), }, + { + title: "创建时间", + dataIndex: "created_at", + render: (text: string) => {dateFormat(text)}, + }, { title: "操作", key: "action", @@ -81,43 +109,49 @@ export const CoursePage = () => { navigate(`/course/update/${record.id}`)} disabled={null} /> - removeItem(record.id)} - okText="确定" - cancelText="取消" - > - null} - disabled={null} - /> - +
+ removeItem(record.id)} + disabled={null} + />
), }, ]; - // 删除图片 + // 删除课程 const removeItem = (id: number) => { if (id === 0) { return; } - course.destroyCourse(id).then(() => { - message.success("删除成功"); - resetList(); + confirm({ + title: "操作确认", + icon: , + content: "确认删除此课程?", + okText: "确认", + okType: "danger", + cancelText: "取消", + onOk() { + course.destroyCourse(id).then(() => { + message.success("删除成功"); + resetList(); + }); + }, + onCancel() { + console.log("Cancel"); + }, }); }; @@ -165,65 +199,27 @@ export const CoursePage = () => { setSize(pageSize); }; + const onChange = (key: string) => { + console.log(key); + }; + return ( <>
-
-
- 资源分类: -
- setCategoryIds(keys)} - /> -
-
-
- 部门: -
- setDepIds(keys)} /> -
+
-
-
-
- 课程名称: - { - setTitle(e.target.value); - }} - style={{ width: 160 }} - placeholder="请输入课程名称" - /> -
-
- - -
-
-
-
+
+
后端课程
} p="course" @@ -233,14 +229,31 @@ export const CoursePage = () => {
- +
+ 课程名称: + { + setTitle(e.target.value); + }} + style={{ width: 160 }} + placeholder="请输入名称关键字" + /> +
+
+ + +
diff --git a/src/pages/member/index.tsx b/src/pages/member/index.tsx index 926f5c8..7d719ef 100644 --- a/src/pages/member/index.tsx +++ b/src/pages/member/index.tsx @@ -90,6 +90,7 @@ export const MemberPage: React.FC = () => { onClick={() => navigate(`/member/update/${record.id}`)} disabled={null} /> +
{
- setDepIds(keys)} /> + setDepIds(keys)} + />