import React, { useState, useEffect } from "react"; import { PageHeaderWrapper } from "@ant-design/pro-layout"; import { Card, Table, Popconfirm, Switch, message, Button, Input, Select, } from "antd"; import { PlusOutlined } from "@ant-design/icons"; import usePagination from "@/hooks/usePagination"; import { ListVO, getConfigListApi, taskEnableApi, taskDeleteApi, taskDisableApi, } from "./api"; import { TodoTypeEnum } from "./entity"; import moment from "moment"; import { debounce } from "lodash"; import CreateModal from "./components/CreateModal"; import { getAllRoleCodeApi } from "@/common/api"; import { systemListApi } from "@/pages/admin/Privilege/api"; import { getWorkTypeListApi, WorkTypeListVO, } from "@/pages/backlog/WorkTypeConfig/api"; const Column = Table.Column; const Search = Input.Search; export default function TaskConfig() { const { list, loading, paginationConfig, setList, setParams, setLoading } = usePagination(getConfigListApi, {}, {}); const [switchLoading, setSwitchLoading] = useState(false); const [modalData, setModalData] = useState<{ visible: boolean; row: ListVO }>( { visible: false, row: {} } ); /** * 查询系统列表 */ const { list: syslist } = usePagination(systemListApi, { current: 1, pageSize: 100, }); /** * 查询工作类型列表 */ const { list: workTyoeList } = usePagination( getWorkTypeListApi, { pageSize: 1000 } ); useEffect(() => { getAllRoleCodeApi() .then((res) => {}) .catch((e) => { message.error(`获取角色列表失败:${e.message}`); }); }, []); function triggerModal(row: ListVO = {}) { setModalData({ visible: !modalData.visible, row }); } const _onChange = debounce((val: string) => { setParams({ keywords: val.trim(), current: 1 }, true); }, 500); // 禁用或启用待办 const handleChangeStatus = (record: ListVO) => { const API = record.status ? taskDisableApi : taskEnableApi; record.id && API(record.id) .then((res) => { setSwitchLoading(false); message.success(record.status ? "禁用成功" : "启用成功"); const tempList = list.map((item: ListVO) => { if (item.id == record.id) { return { ...item, status: record.status == 0 ? 1 : 0 }; } return item; }); setList(tempList); }) .catch((e) => { setSwitchLoading(false); message.error(e.message); }); }; // 删除待办 const handleDelete = (record: any) => { taskDeleteApi(record.id) .then((res) => { message.success("删除成功!"); setLoading(true); }) .catch((e) => { setSwitchLoading(false); message.error(e.message); }); }; //根据系统名称搜索 const _onChangeSys = (value: any) => { setParams({ ...value, current: 1 }, true); }; return (
_onChange(e.target.value)} style={{ maxWidth: 260, marginRight: 15 }} />
TodoTypeEnum[t]} /> (String(text) === "true" ? "是" : "否")} /> (String(text) === "true" ? "是" : "否")} /> {text || "--"}} /> {text || "--"}} /> moment(text).format("YYYY-MM-DD")} /> ( handleChangeStatus(row)} onCancel={() => setSwitchLoading(false)} > setSwitchLoading(true)} /> )} /> ( <> handleDelete(row)} > )} />
setLoading(true)} item={modalData.row} systemList={syslist || []} workTyoeList={workTyoeList || []} />
); }