/* 设备台账
* @Author: Li Hanlin
* @Date: 2022-11-10 09:39:56
* @Last Modified by: Li Hanlin
* @Last Modified time: 2023-02-16 17:23:15
*/
import * as React from 'react';
import { 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 } from '@/utils/doFetch';
import {
message,
Dropdown,
Menu,
Layout,
Button,
Image,
Space,
Divider,
Tabs,
Tooltip,
} from 'antd';
import TreeRender from '@/components/TreeRender';
import { ProDescriptions } from '@ant-design/pro-components';
import InitForm from '@/components/InitForm';
import ExtendField from '@/components/ExtendField';
import dayjs from 'dayjs';
const { Sider, Content } = Layout;
function Model(props) {
const disabledDateOfDay = (current) => {
// Can not select days before today and today
return current && current > dayjs().endOf('day');
};
const [activeTab, setactiveTab] = useState(1);
let actionRef = useRef(),
formRef = useRef(),
[drawer, setDrawer] = useState({
visible: false,
}),
[extraparams, setextraparams] = useState({}),
[currDrawer, setCurrDrawer] = useState({
visible: false,
}),
[resumeTab, setresumeTab] = useState(null),
currfields = {
1: [
{
title: '操作人',
dataIndex: 'updateUserName',
key: 'updateUserName',
},
{
title: '操作时间',
dataIndex: 'updateTime',
key: 'updateTime',
},
{
title: '改造日期',
dataIndex: 'reformDate',
key: 'reformDate',
valueType: 'date',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '改造承包商',
dataIndex: 'supplierId',
key: 'supplierId',
valueType: 'select',
options: {
path: '/asset/equipmentSupplier/query/selection',
params: {},
},
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
],
},
},
{
title: '改造内容',
dataIndex: 'reformContent',
key: 'reformContent',
valueType: 'textarea',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '上传文件',
key: 'urlIds',
valueType: 'uploadDragger',
// column: { xs: 1, sm: 2, md: 3 },
span: '3',
fieldProps: {
maxCount: 5,
},
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
],
},
render: (text, row) => {
return (
{row?.urlIds.map((it) => (
// eslint-disable-next-line react/jsx-key
))}
);
},
},
],
2: [
{
title: '操作人',
dataIndex: 'updateUserName',
key: 'updateUserName',
},
{
title: '操作时间',
dataIndex: 'updateTime',
key: 'updateTime',
},
{
title: '报废日期',
dataIndex: 'scrapDate',
key: 'scrapDate',
valueType: 'date',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '报废原因',
dataIndex: 'scrapReason',
key: 'scrapReason',
valueType: 'textarea',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '上传文件',
key: 'urlIds',
valueType: 'uploadDragger',
span: '3',
formItemProps: {
rules: [
{
required: false,
message: '此项为必填项',
},
],
},
fieldProps: {
maxCount: 5,
},
render: (text, row) => {
return (
{row?.urlIds.map((it) => (
// eslint-disable-next-line react/jsx-key
))}
);
},
},
],
3: [
{
title: '操作人',
dataIndex: 'updateUserName',
key: 'updateUserName',
},
{
title: '操作时间',
dataIndex: 'updateTime',
key: 'updateTime',
},
{
title: '调入公司',
dataIndex: 'toOrganizationName',
key: 'toOrganizationId',
valueType: 'select',
options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '调入部门',
valueType: 'treeSelect',
dataIndex: 'toDepartmentName',
key: 'toDepartmentId',
options: {
path: '/auth/sysDepartment/query/children/tree',
linkParams: {
toOrganizationId: 'parentId',
},
},
},
{
title: '调入工厂',
dataIndex: 'toFactoryName',
key: 'toFactoryId',
valueType: 'select',
options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '调入车间',
dataIndex: 'toShopName',
valueType: 'select',
options: {
path: '/auth/sysShop/getShopSelectionByFactory',
linkParams: {
toFactoryId: 'factoryId',
},
},
key: 'toShopId',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '调入工段',
dataIndex: 'toSectionName',
key: 'toSectionId',
valueType: 'select',
options: {
path: '/auth/sysSection/getAllSectionSelectionByShop',
linkParams: {
toShopId: 'shopId',
},
},
},
{
title: '调入产线',
dataIndex: 'toProductLineName',
valueType: 'select',
key: 'toProductLineId',
options: {
path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
linkParams: {
toShopId: 'shopId',
},
},
},
{
title: '调入位置号',
dataIndex: 'toPositionNo',
valueType: 'input',
key: 'toPositionNo',
},
{
title: '调拨日期',
dataIndex: 'transferDate',
key: 'transferDate',
valueType: 'date',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '调拨原因',
dataIndex: 'transferReason',
key: 'transferReason',
valueType: 'textarea',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
],
4: [
{
title: '操作人',
dataIndex: 'updateUserName',
key: 'updateUserName',
},
{
title: '操作时间',
dataIndex: 'updateTime',
key: 'updateTime',
},
{
title: '借用公司',
dataIndex: 'toOrganizationName',
key: 'toOrganizationName',
},
{
title: '借用部门',
valueType: 'treeSelect',
dataIndex: 'toDepartmentName',
key: 'toDepartmentName',
},
{
title: '借用工厂',
dataIndex: 'toFactoryName',
key: 'toFactoryName',
},
{
title: '借用车间',
dataIndex: 'toShopName',
valueType: 'select',
key: 'toShopName',
},
{
title: '借用工段',
dataIndex: 'toSectionName',
key: 'toSectionName',
},
{
title: '借用产线',
dataIndex: 'toProductLineName',
key: 'toProductLineName',
},
{
title: '借用位置号',
dataIndex: 'toPositionNo',
valueType: 'input',
key: 'toPositionNo',
},
{
title: '借用日期',
dataIndex: 'borrowDate',
key: 'borrowDate',
valueType: 'date',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '预计归还日期',
dataIndex: 'planReturnDate',
key: 'planReturnDate',
valueType: 'date',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '借用原因',
dataIndex: 'borrowReason',
key: 'borrowReason',
valueType: 'textarea',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
],
5: [
{
title: '操作人',
dataIndex: 'updateUserName',
key: 'updateUserName',
},
{
title: '操作时间',
dataIndex: 'updateTime',
key: 'updateTime',
},
{
title: '接收公司',
dataIndex: 'returnOrganizationName',
key: 'returnOrganizationName',
valueType: 'select',
options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '接收部门',
valueType: 'treeSelect',
dataIndex: 'returnDepartmentName',
key: 'returnDepartmentName',
options: {
path: '/auth/sysDepartment/query/children/tree',
linkParams: {
returnOrganizationId: 'parentId',
},
},
},
{
title: '接收工厂',
dataIndex: 'returnFactoryName',
key: 'returnFactoryName',
valueType: 'select',
options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '接收车间',
dataIndex: 'returnShopName',
valueType: 'select',
options: {
path: '/auth/sysShop/getShopSelectionByFactory',
linkParams: {
returnFactoryId: 'factoryId',
},
},
key: 'returnShopId',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '接收工段',
dataIndex: 'returnSectionName',
key: 'returnSectionId',
valueType: 'select',
options: {
path: '/auth/sysSection/getAllSectionSelectionByShop',
linkParams: {
returnShopId: 'shopId',
},
},
},
{
title: '接收产线',
dataIndex: 'returnProductLineName',
valueType: 'select',
key: 'returnProductLineId',
options: {
path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
linkParams: {
returnShopId: 'shopId',
},
},
},
{
title: '接收位置号',
dataIndex: 'returnPositionNo',
valueType: 'input',
key: 'returnPositionNo',
},
{
title: '实际归还日期',
dataIndex: 'realReturnDate',
key: 'realReturnDate',
valueType: 'date',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '备注',
dataIndex: 'remark',
key: 'remark',
valueType: 'textarea',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
],
},
urlParams = {
save: '/asset/equipment/save',
remove: '/asset/equipment/deleteById',
list: '/asset/equipment/queryList',
detail: '/asset/equipment/detail',
},
urlParams_childEquipment = {
list: '/asset/equipment/children/queryList',
checked: '/asset/equipment/children/selected/queryList',
save: '/asset/equipmentChildren/save',
},
urlParams_resume = {
save: '/asset/equipmentLog/save',
list: '/asset/equipmentLog/queryEquipmentLogPage',
detail: '/asset/equipmentLog/query/resumeDetail',
},
urlParams_correlation = {
zsb: '/asset/equipment/detail/children/page',
fsb: '/asset/equipment/detail/parent/page',
};
function formatDate(date) {
var myyear = date.getFullYear();
var mymonth = date.getMonth() + 1;
var myweekday = date.getDate();
if (mymonth < 10) {
mymonth = '0' + mymonth;
}
if (myweekday < 10) {
myweekday = '0' + myweekday;
}
return myyear + '-' + mymonth + '-' + myweekday; //想要什么格式都可以随便自己拼
}
const edit = (text, row, _, action) => {
return (
{
setDrawer((s) => ({
...s,
visible: true,
title: '编辑',
val: 'only',
type: 'edit',
item: row,
}));
},
}}
>
编辑
);
};
const remove = (text, row, _, action) => {
return (
{
let res = await doFetch({ url: urlParams.remove, params: { id: row.id } });
if (res.code === '0000') {
message.success('删除成功!');
setDrawer((s) => ({
...s,
visible: false,
}));
actionRef.current.reload();
}
},
}}
btn={{
size: 'small',
type: 'danger',
}}
>
删除
);
};
const more = (text, row, _, action) => {
const menu = (