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 { sectionDetail } from "@/utils/detailTotalCard";
import Coltext from "@/components/Coltext";
const initState = {
vs: false,
fields: {},
iftype: {},
curitem: {},
detail: {
dataSource: {},
totalCard: [],
},
visible: false,
},
otherBasic = {
workingProcedureName: "工序",
stationName: "工位",
groupName: "班组",
};
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: [...sectionDetail],
},
visible: true,
};
break;
case "close":
newState = {
vs: false,
fields: {},
iftype: {},
curitem: {},
detail: {
dataSource: {},
totalCard: [],
},
visible: false,
};
break;
}
return newState;
}
const Section = (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: "sectionCode",
key: "sectionCode",
},
{
title: "工段名称",
dataIndex: "sectionName",
key: "sectionName",
render: (_, row) => {
return (