import React, { useEffect, useRef, useReducer } from "react";
import { Button, Tooltip, Row, Divider } from "antd";
import AutoTable from "@/components/AutoTable";
import getPrem from "@/utils/getPrem"; //权限判断fn
import { useRequest } from "umi";
import defaultFields from "./fields";
import { doFetch } from "@/utils/doFetch";
import DrawInitForm from "@/components/DrawInitForm";
import Details from "@/components/Details";
import { workingProcedureDetail } from "@/utils/detailTotalCard";
import Coltext from "@/components/Coltext";
const initState = {
vs: false,
fields: {},
iftype: {},
curitem: {},
detail: {
dataSource: {},
totalCard: [],
},
visible: false,
},
otherBasic = {
processLineName: "工艺路线",
collectionSiteName: "采集站点",
};
function reducer(state, action) {
let { type } = action,
newState = {};
switch (type) {
case "add":
newState = {
...state,
vs: true,
iftype: {
title: "新增工序",
val: type,
},
fields: { ...action.fields },
};
break;
case "edit":
newState = {
...state,
vs: true,
iftype: {
title: "编辑工序",
val: type,
},
fields: { ...action.fields },
curitem: action.curitem,
};
break;
case "see":
newState = {
...state,
detail: {
dataSource: action.dataSource,
totalCard: [...workingProcedureDetail],
},
visible: true,
};
break;
case "close":
newState = {
vs: false,
fields: {},
iftype: {},
curitem: {},
detail: {
dataSource: {},
totalCard: [],
},
visible: false,
};
break;
}
return newState;
}
const Process = (props) => {
let actionRef = useRef(),
ChildRef = null;
function reload() {
actionRef?.current?.reload();
ChildRef?.onRefresh();
}
const { run, loading } = useRequest(doFetch, {
manual: true,
formatResult: (res) => res,
onSuccess: (result, params) => {
if (result.code == "0000") {
reload();
dispatch({ type: "close" });
}
},
}),
[state, dispatch] = useReducer(reducer, initState),
{ vs, fields, iftype, curitem, detail, visible } = state,
columns = [
{
title: "工序编号",
dataIndex: "workingProcedureCode",
key: "workingProcedureCode",
},
{
title: "工序名称",
dataIndex: "workingProcedureName",
key: "workingProcedureName",
render: (_, row) => {
return (