import React, { useState, useEffect, useMemo, useRef } from "react"; import AutoTable from "@/components/AutoTable"; import PremButton from "@/components/PremButton"; import useKeepAlive from "@/components/useKeepAlive"; import getcolumns from "./columns"; import { useRequest } from "ahooks"; import { doFetch } from "@/utils/doFetch"; function Taskmanage() { let actionRef = useRef(); const [tabKey, setTabKey] = useState("1"); const { runAsync } = useRequest(doFetch, { manual: true, onSuccess: (res, params) => { if (res.code == "0000") { actionRef?.current?.reload(); } }, }); const tabList = useMemo(() => { return getcolumns(); }, [tabKey]); const columns = useMemo(() => { let defcolumn = getcolumns().filter((it) => it.key == tabKey)[0]?.columns ?? []; return tabKey === "2" ? defcolumn : defcolumn.concat({ title: "操作", valueType: "option", width: 80, render: (text, row, _, action) => rightExtra(text, row, _, action), }); }, [tabKey]); const pathconfig = useMemo(() => { let defpath = getcolumns().filter((it) => it.key == tabKey)[0]?.pathconfig ?? {}; return defpath; }, [tabKey]); const rightExtra = (text, row, _, action) => { return [ (row.documentStatus == 0 || row.documentStatus == 1) && ( { await runAsync({ url: "/ta_wms_workmanship/pmTaskManagement/taskColse", params: { id: row.id }, }); actionRef?.current?.reload(); }, }} btn={{ size: "small", danger: true, }} > 关单 ), (row.documentStatus === 2 || row.documentStatus === 1) && ( { await runAsync({ url: "/ta_wms_workmanship/pmTaskManagement/taskManualFinish", params: { ticketNo: row.taskNo, status: 0 }, }); actionRef?.current?.reload(); }, }} btn={{ size: "small", danger: true, }} > 手工完成 ), ]; }; return (
{ setTabKey(key); }} />
); } export default useKeepAlive(Taskmanage);