import React, { useState, useMemo, useRef, useEffect } from 'react';
import DrawerPro from '@/components/DrawerPro';
import AutoTable from '@/components/AutoTable';
import PremButton from '@/components/PremButton';
import getcolumns from './columns';
import { doFetch, exportFetch } from '@/utils/doFetch';
import { useRequest, useAsyncEffect } from "ahooks";
import styles from "./index.less";
import TreeRender from '@/components/TreeRender';
import { Divider, Tabs, message } from "antd";
import Leaseresume from "./Leaseresume";
import Operatinghistory from "./Operatinghistory";
import Resume from "./Resume";
import Basemsg from "./Basemsg";
import setAllCanvas from "@/utils/drawimage"//导出二维码
const Ledger = () => {
let actionRef = useRef();
const [drawer, setdrawer] = useState({
open: false,
}),
[defaultmsg, cds] = useState({
supplier: {},
factory: {}
}),
[extraparams, setextraparams] = useState({}),
[searchParams, csp] = useState({});
const { run, loading, runAsync } = useRequest(doFetch, {
manual: true,
onSuccess: (res, params) => {
if (res?.code == "0000") {
actionRef?.current?.reload();
setdrawer((s) => ({
...s,
open: false,
}));
}
},
});
const columns = useMemo(() => {
let defcolumn = getcolumns(setdrawer)?.columns ?? [];
return defcolumn.concat({
title: '操作',
valueType: 'option',
width: 190,
render: (text, row, _, action) => getExtra(text, row, _, action),
colProps: {
fixed: 'right'
}
});
}, []);
const pathconfig = useMemo(() => {
let pathconf = getcolumns(setdrawer)?.pathconfig ?? {};
return pathconf;
}, []);
useAsyncEffect(async () => {
let res = await doFetch({ url: "/lease/umEquipmentSupplier/queryByDefault", params: {} }),
res2 = await doFetch({ url: "/auth/sysFactory/queryByDefault", params: {} });
cds({
supplier: res?.data?.data ?? {},
factory: res2?.data?.data ?? {}
});
}, [])
const onselecteTree = (selectedKeys, e, alldata) => {
let params = {};
if (selectedKeys.length) {
switch (e.node.type) {
case 1:
params = { factoryId: e.node.key }
break;
case 2:
params = { shopId: e.node.key }
break;
case 3:
params = { sectionId: e.node.key }
break;
case 4:
params = { productionLineId: e.node.key }
break;
default:
params = {};
}
} else {
params = {}
}
setextraparams(params);
};
const getExtra = (text, row, _, action) => {
//0: 报废 1: 预占 2: 租赁 3: 销售 4: 闲置 5:待复检 6: 未绑定 7: 绑定
let ifsd = row.status == 0,
ifsa = row.status == 1,
ifsb = row.status == 2,
ifsg = row.status == 3,
ifs = row.status == 4,
ifsc = row.status == 5,
ifse = row.status == 6,
ifsf = row.status == 7,
devicetype1 = row.equipmentType == 1,
devicetype2 = row.equipmentType == 2,
intelligentUnit = row.ledgerEquipment;
return [
(ifsd || (devicetype1 && ifs) || (devicetype2 && ifse)) &&
请确认是一同报废或
释放出关联智能单元?,
okText: '释放',
cancelText: '一同报废',
onConfirm: async () => {
runAsync({ url: "/lease/umLeaseLedger/scrapSubmit", params: { flag: 2, id: row.id } });
},
onCancel: async () => {
runAsync({ url: "/lease/umLeaseLedger/scrapSubmit", params: { flag: 1, id: row.id } });
},
}}
btn={{
size: 'small',
type: 'danger',
}}
>
报废