/* 设备台账 * @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
{it?.name}
))}
); }, }, ], 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
{it?.name}
))}
); }, }, ], 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 = ( { setDrawer((s) => ({ ...s, visible: true, type: 'editChildEquipment', item: { id: row.id, }, val: 'only', title: '编辑子设备', })); }} > 编辑子设备 ), key: '0', }, { label: ( { let res = await doFetch({ url: '/asset/equipmentLog/getAllResumeType', params: { equipmentId: row?.id }, }); await setresumeTab(res?.data?.dataList); await setDrawer((s) => ({ ...s, visible: true, type: 'resume', item: { id: row.id, reformDate: formatDate(new Date()), scrapDate: formatDate(new Date()), transferDate: formatDate(new Date()), borrowDate: formatDate(new Date()), realReturnDate: formatDate(new Date()), }, val: 'only', title: '履历登记', })); }} > 履历登记 ), key: '1', }, // { // label: 关联备件(暂缓), // key: '2', // }, // { // label: 寿命件台账(暂缓), // key: '3', // }, ]} /> ); return ( containderef.current} > ); }; //设备详情 const Detail = () => { // 基础信息 const BaseInfo = () => { const columns1 = [ { title: '设备编号', dataIndex: 'equipmentNo', key: 'equipmentNo', }, { title: '设备名称', dataIndex: 'equipmentName', key: 'equipmentName', }, { title: '位置号', dataIndex: 'positionNo', key: 'positionNo', }, { title: '设备类型', dataIndex: 'equipmentTypeName', key: 'equipmentTypeId', }, { title: '设备型号', dataIndex: 'equipmentModelName', key: 'equipmentModelName', }, { title: '状态', dataIndex: 'statusName', key: 'statusName', span: 2, }, ]; const columns2 = [ { title: '公司名称', dataIndex: 'organizationName', key: 'organizationId', }, { title: '部门名称', dataIndex: 'departmentName', key: 'departmentId', }, { title: '工厂名称', dataIndex: 'factoryName', key: 'factoryId', }, { title: '车间名称', dataIndex: 'shopName', key: 'shopId', }, { title: '工段名称', dataIndex: 'sectionName', key: 'sectionId', }, { title: '产线名称', dataIndex: 'productLineName', key: 'productLineName', }, ]; const columns3 = [ { title: '供应商', dataIndex: 'supplierName', key: 'supplierId', }, { title: '设备原值', dataIndex: 'equipmentWorth', key: 'equipmentWorth', }, { title: '安装投产日期', dataIndex: 'productDate', key: 'productDate', }, { title: '图片', dataIndex: 'pictureUrl', key: 'pictureUrl', render: (text, row) => , }, { title: '二维码', dataIndex: 'qrCodeUrl', key: 'qrCodeUrl', render: (text, row) => , }, ]; const [newfieldscolumns, setnewfieldscolumns] = useState([]); const selectValueType = (type, options) => { switch (type) { case 1: return { valueType: 'input', }; case 2: return { valueType: 'select', options, }; case 3: return { valueType: 'radio', options, }; case 4: return { valueType: 'select', options, }; default: break; } }; const [request, setrequest] = useState(); useEffect(() => { const fn = async () => { let res = await doFetch({ url: '/base/paFormField/queryList', params: { formId: '2', }, }); if (res?.data?.dataList) { let column = []; res?.data?.dataList?.forEach?.((el) => { column.push({ ...selectValueType(el.fieldChar, el.valueList), title: el.fieldName, dataIndex: el.id, key: el.id, }); }); setnewfieldscolumns(column); } }, fn2 = async () => { const res = await doFetch({ url: urlParams.detail, params: { id: drawer?.item?.id }, }); let obj = {}; res?.data?.data['equipmentCharList']?.forEach?.((it) => { obj[it?.fieldId] = it?.fieldRealValue; }); console.log('drawerpro:', { ...(res?.data?.data ?? {}), ...obj, }); setrequest( { ...(res?.data?.data ?? {}), ...obj, } ?? {}, ); }; fn(); fn2(); }, []); return ( <>

扩展字段

); }; // 相关设备 const Correlation = () => { return ( <> ); }; //履历查询 const Curritae = () => { return ( <> { const { data } = await doFetch({ url: urlParams.detail, params: { id: drawer?.item?.id }, }); return { success: true, data: data?.data, }; }} columns={[ { title: '设备编号', dataIndex: 'equipmentNo', key: 'equipmentNo', }, { title: '设备名称', dataIndex: 'equipmentName', key: 'equipmentName', }, { title: '位置号', dataIndex: 'positionNo', key: 'positionNo', }, { title: '公司名称', dataIndex: 'organizationName', key: 'organizationId', }, { title: '部门名称', dataIndex: 'departmentName', key: 'departmentId', }, { title: '工厂名称', dataIndex: 'factoryName', key: 'factoryId', }, { title: '车间名称', dataIndex: 'shopName', key: 'shopId', }, { title: '工段名称', dataIndex: 'sectionName', key: 'sectionId', }, { title: '产线名称', dataIndex: 'productLineName', key: 'productLineName', }, ]} /> { return ( { setCurrDrawer((s) => ({ ...s, visible: true, item: row, val: 'only', title: `${row.logTypeName}详情`, })); }} > {row.relateNo} ); }, }, ]} path={urlParams_resume.list} params={{ equipmentId: drawer?.item?.id }} resizeable={false} /> ); }; return ( <> , }, { label: '相关设备', key: 2, children: , }, { label: '履历查询', key: 3, children: , }, ]} /> ); }; // 子设备 const EditChildEquipment = () => { const [selectArr, setSelectArr] = useState([]); useEffect(() => { const fun = async () => { const result = await doFetch({ url: '/asset/equipment/children/selected/queryList', params: { id: drawer?.item?.id }, }); // //console.log(result); if (!result?.data?.dataList.length == 0) { setSelectArr(result?.data?.dataList.map((it) => it.id)); } }; fun(); }, []); const columns = [ { title: '设备编号', dataIndex: 'equipmentNo', key: 'equipmentNo', search: false, width: 120, formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '设备名称', dataIndex: 'equipmentName', width: 120, key: 'equipmentName', formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '公司名称', dataIndex: 'organizationName', width: 120, key: 'organizationId', fieldProps: { placeholder: '请选择', showSearch: true, }, valueType: 'select', options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} }, formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '部门名称', width: 120, valueType: 'treeSelect', dataIndex: 'departmentName', fieldProps: { placeholder: '请选择', showSearch: true, }, key: 'departmentId', options: { path: '/auth/sysDepartment/query/children/tree', linkParams: { organizationId: 'parentId', }, }, }, { title: '工厂名称', dataIndex: 'factoryName', key: 'factoryId', width: 120, fieldProps: { placeholder: '请选择', showSearch: true, }, valueType: 'select', options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} }, formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '车间名称', dataIndex: 'shopName', width: 120, fieldProps: { placeholder: '请选择', showSearch: true, }, valueType: 'select', options: { path: '/auth/sysShop/getShopSelectionByFactory', linkParams: { factoryId: '', }, }, search: false, key: 'shopId', formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '车间名称', dataIndex: 'shopName', width: 120, valueType: 'select', fieldProps: { placeholder: '请选择', showSearch: true, }, options: { path: '/auth/sysShop/getAllShopSelection', params: {}, }, key: 'shopId', hideInForm: true, hideInTable: true, }, { title: '工段名称', width: 120, dataIndex: 'sectionName', key: 'sectionId', fieldProps: { placeholder: '请选择', showSearch: true, }, valueType: 'select', options: { path: '/auth/sysSection/getAllSectionSelectionByShop', linkParams: { shopId: '', }, }, search: false, }, { title: '工段名称', width: 120, dataIndex: 'sectionName', key: 'sectionId', fieldProps: { placeholder: '请选择', showSearch: true, }, valueType: 'select', options: { path: '/auth/sysSection/getAllSectionSelection', params: {}, }, hideInForm: true, hideInTable: true, }, { title: '产线名称', width: 120, dataIndex: 'productLineName', valueType: 'select', key: 'productLineName', fieldProps: { placeholder: '请选择', showSearch: true, }, options: { path: '/auth/sysProductionLine/getAllProductLineSelectionByShop', linkParams: { shopId: '', }, }, search: false, }, { title: '产线名称', width: 120, dataIndex: 'productLineName', valueType: 'select', fieldProps: { placeholder: '请选择', showSearch: true, }, key: 'productLineId', options: { path: '/auth/sysProductionLine/getAllProductLineSelection', params: {}, }, hideInForm: true, hideInTable: true, }, ]; return ( <> { const { data } = await doFetch({ url: urlParams.detail, params: { id: drawer.item.id }, }); return { success: true, data: data.data, }; }} columns={[ { title: '设备编号', dataIndex: 'equipmentNo', key: 'equipmentNo', }, { title: '设备名称', dataIndex: 'equipmentName', key: 'equipmentName', }, { title: '位置号', dataIndex: 'positionNo', key: 'positionNo', }, { title: '公司名称', dataIndex: 'organizationName', key: 'organizationId', }, { title: '部门名称', dataIndex: 'departmentName', key: 'departmentId', }, { title: '工厂名称', dataIndex: 'factoryName', key: 'factoryId', }, { title: '车间名称', dataIndex: 'shopName', key: 'shopId', }, { title: '工段名称', dataIndex: 'sectionName', key: 'sectionId', }, { title: '产线名称', dataIndex: 'productLineName', key: 'productLineName', }, ]} /> { //console.log('selectedRowKeys changed: ', record, selected, selectedRows); setSelectArr(() => { return selectedRows.map((it) => it.id); }); }, onSelectAll: (selected, selectedRows, changeRows) => { //console.log(selected, selectedRows, changeRows); if (selected) { let arr = selectArr.concat(changeRows.map((it) => it.id)); setSelectArr(arr); } else { setSelectArr([]); } }, onSelectNone: () => { //console.log(11); setSelectArr([]); }, }} /> ); }; // 履历登记 const Resume = () => { const [selectArr, setSelectArr] = useState([]); const [activeTab, setactiveTab] = useState(1); useEffect(() => { const fun = async () => { const result = await doFetch({ url: '/asset/equipment/children/selected/queryList', params: { id: drawer?.item?.id }, }); // //console.log(result); if (!result?.data?.dataList.length == 0) { setSelectArr(result?.data?.dataList.map((it) => it.id)); } }; fun(); let dis = resumeTab?.filter((it) => it?.disabled); if (dis?.length > 0 && dis[0].key == 1) { setactiveTab( menulist?.filter((it) => !dis?.map((item) => item.key).includes(it?.key))[0]?.key, ); } else { setactiveTab(1); } }, []); const menulist = useMemo(() => { console.log(activeTab); const fields = { 1: [ { title: '改造日期', dataIndex: 'reformDate', key: 'reformDate', valueType: 'date', fieldProps: { disabledDate: disabledDateOfDay, }, 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: '上传文件(上限为5个)', key: 'urlIds', valueType: 'UploadDragger', // colProps: { span: 24 }, fieldProps: { maxCount: 5, name: 'file', }, formItemProps: { rules: [ { required: false, message: '此项为必填项', }, ], }, }, ], 2: [ { title: '报废日期', dataIndex: 'scrapDate', key: 'scrapDate', fieldProps: { disabledDate: disabledDateOfDay, }, valueType: 'date', formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '报废原因', dataIndex: 'scrapReason', key: 'scrapReason', valueType: 'textarea', formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '上传文件(上限为5个)', key: 'urlIds', valueType: 'UploadDragger', formItemProps: { rules: [ { required: false, message: '此项为必填项', }, ], }, fieldProps: { name: 'file', maxCount: 5, }, }, ], 3: [ { title: '调入公司', dataIndex: 'organizationName', key: 'toOrganizationId', valueType: 'select', options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} }, formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '调入部门', valueType: 'treeSelect', dataIndex: 'departmentName', key: 'toDepartmentId', options: { path: '/auth/sysDepartment/query/children/tree', linkParams: { toOrganizationId: 'parentId', }, }, }, { title: '调入工厂', dataIndex: 'factoryName', key: 'toFactoryId', valueType: 'select', options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} }, formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '调入车间', dataIndex: 'shopName', valueType: 'select', options: { path: '/auth/sysShop/getShopSelectionByFactory', linkParams: { toFactoryId: 'factoryId', }, }, key: 'toShopId', formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '调入工段', dataIndex: 'sectionName', key: 'toSectionId', valueType: 'select', options: { path: '/auth/sysSection/getAllSectionSelectionByShop', linkParams: { toShopId: 'shopId', }, }, }, { title: '调入产线', dataIndex: 'productionLines', 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', fieldProps: { disabledDate: disabledDateOfDay, }, formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '调拨原因', dataIndex: 'transferReason', key: 'transferReason', valueType: 'textarea', formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, ], 4: [ { title: '借用公司', dataIndex: 'organizationName', key: 'toOrganizationId', valueType: 'select', options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} }, formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '借用部门', valueType: 'treeSelect', dataIndex: 'departmentName', key: 'toDepartmentId', options: { path: '/auth/sysDepartment/query/children/tree', linkParams: { toOrganizationId: 'parentId', }, }, }, { title: '借用工厂', dataIndex: 'factoryName', key: 'toFactoryId', valueType: 'select', options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} }, formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '借用车间', dataIndex: 'shopName', valueType: 'select', options: { path: '/auth/sysShop/getShopSelectionByFactory', linkParams: { toFactoryId: 'factoryId', }, }, key: 'toShopId', formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '借用工段', dataIndex: 'sectionName', key: 'toSectionId', valueType: 'select', options: { path: '/auth/sysSection/getAllSectionSelectionByShop', linkParams: { toShopId: 'shopId', }, }, }, { title: '借用产线', dataIndex: 'productionLines', valueType: 'select', key: 'toProductLineId', options: { path: '/auth/sysProductionLine/getAllProductLineSelectionByShop', linkParams: { toShopId: 'shopId', }, }, }, { title: '借用位置号', dataIndex: 'toPositionNo', valueType: 'input', key: 'toPositionNo', }, { title: '借用日期', dataIndex: 'borrowDate', key: 'borrowDate', fieldProps: { disabledDate: disabledDateOfDay, }, 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: 'returnOrganizationId', key: 'returnOrganizationId', valueType: 'select', options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} }, formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '接收部门', valueType: 'treeSelect', dataIndex: 'returnDepartmentId', key: 'returnDepartmentId', options: { path: '/auth/sysDepartment/query/children/tree', linkParams: { returnOrganizationId: 'parentId', }, }, }, { title: '接收工厂', dataIndex: 'returnFactoryId', key: 'returnFactoryId', valueType: 'select', options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} }, formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '接收车间', dataIndex: 'returnShopId', valueType: 'select', options: { path: '/auth/sysShop/getShopSelectionByFactory', linkParams: { returnFactoryId: 'factoryId', }, }, key: 'returnShopId', formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '接收工段', dataIndex: 'returnSectionId', key: 'returnSectionId', valueType: 'select', options: { path: '/auth/sysSection/getAllSectionSelectionByShop', linkParams: { returnShopId: 'shopId', }, }, }, { title: '接收产线', dataIndex: 'returnProductLineId', 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', fieldProps: { disabledDate: disabledDateOfDay, }, formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, }, { title: '备注', dataIndex: 'remark', key: 'remark', valueType: 'textarea', formItemProps: { rules: [{ required: false, message: '此项为必填项' }] }, }, ], }; let arr = [ { label: '改造', key: 1, children: activeTab == 1 && ( { //console.log(vals); let res = await doFetch({ url: urlParams_resume.save, params: { ...vals, type: '1', equipmentId: drawer?.item?.id }, }); if (res.code === '0000') { message.success('登记成功!'); await setDrawer((s) => ({ ...s, visible: false, item: null, })); actionRef.current.reload(); } }} /> ), }, // remember to pass the key prop { label: '报废', key: 2, children: activeTab == 2 && ( { let res = await doFetch({ url: urlParams_resume.save, params: { ...vals, type: '2', equipmentId: drawer?.item?.id }, }); if (res.code === '0000') { message.success('登记成功!'); await setDrawer((s) => ({ ...s, visible: false, item: null, })); actionRef.current.reload(); } }} /> ), }, { label: '调拨', key: 3, children: activeTab == 3 && ( { //console.log(vals); let res = await doFetch({ url: urlParams_resume.save, params: { ...vals, type: '3', equipmentId: drawer?.item?.id }, }); if (res.code === '0000') { message.success('登记成功!'); await setDrawer((s) => ({ ...s, visible: false, item: null, })); actionRef.current.reload(); } }} /> ), }, { label: '借用', key: 4, children: activeTab == 4 && ( { //console.log(vals); let res = await doFetch({ url: urlParams_resume.save, params: { ...vals, type: '4', equipmentId: drawer?.item?.id }, }); if (res.code === '0000') { message.success('登记成功!'); await setDrawer((s) => ({ ...s, visible: false, item: null, })); actionRef.current.reload(); } }} /> ), }, { label: '归还', key: 5, children: activeTab == 5 && ( { //console.log(vals); let res = await doFetch({ url: urlParams_resume.save, params: { ...vals, type: '5', equipmentId: drawer?.item?.id }, }); if (res.code === '0000') { message.success('登记成功!'); await setDrawer((s) => ({ ...s, visible: false, item: null, })); actionRef.current.reload(); } }} /> ), }, ]; let dis = resumeTab?.filter((it) => it?.disabled); arr.forEach((item) => { dis?.forEach((it) => { if (item?.key == it?.key) { let string = item.label; item.disabled = true; item.label = ( {string} ); } }); }); return arr; }, [activeTab]); return ( <> { const { data } = await doFetch({ url: urlParams.detail, params: { id: drawer?.item?.id }, }); return { success: true, data: data?.data, }; }} columns={[ { title: '设备编号', dataIndex: 'equipmentNo', key: 'equipmentNo', }, { title: '设备名称', dataIndex: 'equipmentName', key: 'equipmentName', }, { title: '位置号', dataIndex: 'positionNo', key: 'positionNo', }, { title: '公司名称', dataIndex: 'organizationName', key: 'organizationId', }, { title: '部门名称', dataIndex: 'departmentName', key: 'departmentId', }, { title: '工厂名称', dataIndex: 'factoryName', key: 'factoryId', }, { title: '车间名称', dataIndex: 'shopName', key: 'shopId', }, { title: '工段名称', dataIndex: 'sectionName', key: 'sectionId', }, { title: '产线名称', dataIndex: 'productLineName', key: 'productLineName', }, { title: '供应商', dataIndex: 'supplierName', key: 'supplierId', }, { title: '安装投产日期', dataIndex: 'productDate', key: 'productDate', }, ]} /> ); }; const columns = useMemo(() => { let defcolumn = getcolumns(setDrawer); defcolumn[1].render = (text, row) => { return ( { setDrawer((s) => ({ ...s, visible: true, type: 'detail', item: row, val: 'only', title: row.equipmentName + '的详细信息', })); }} > {row.equipmentName} ); }; return defcolumn.concat({ title: '操作', valueType: 'option', fixed: 'right', width: 200, render: (text, row, _, action) => [ edit(text, row, _, action), remove(text, row, _, action), more(text, row, _, action), ], }); }, []); const onselecteTree = async (selectedKeys, e, alldata) => { let params = { treeNodeType: e.node.type, treeNodeKey: e.node.key, }; setextraparams(params); }; const selectMoreDrawerType = (type) => { switch (type) { case 'editChildEquipment': return ; case 'resume': return ; case 'detail': return ; case 'add': return ( { let equipmentCharReqList = []; for (let i in vals) { if (!isNaN(Number(i))) { equipmentCharReqList.push({ fieldId: i, fieldRealValue: vals[i], }); delete vals[i]; } } let params = { ...vals, id: drawer?.title == '编辑' ? drawer?.item?.id : '', equipmentCharReqList, }; //console.log(params, '!!!!'); let res = await doFetch({ url: urlParams.save, params, }); if (res.code === '0000') { if (drawer?.title == '编辑') { message.success('编辑成功!'); } else { message.success('新增成功!'); } setDrawer((s) => ({ ...s, visible: false, })); actionRef.current.reload(); } }} /> ); case 'edit': return ( { let equipmentCharReqList = []; for (let i in vals) { if (!isNaN(Number(i))) { equipmentCharReqList.push({ fieldId: i, fieldRealValue: vals[i], }); delete vals[i]; } } let params = { ...vals, id: drawer?.title == '编辑' ? drawer?.item?.id : '', equipmentCharReqList, }; let res = await doFetch({ url: urlParams.save, params, }); if (res.code === '0000') { if (drawer?.title == '编辑') { message.success('编辑成功!'); } else { message.success('新增成功!'); } setDrawer((s) => ({ ...s, visible: false, })); actionRef.current.reload(); } }} /> ); default: return null; } }; const containderef = useRef(); return (

设备台账

设备台账} columns={columns} path={urlParams.list} actionRef={actionRef} pageextra={'add'} resizeable={false} addconfig={{ // access: 'sysDepartment_save', btn: { disabled: false, type: 'primary', onClick: () => { setDrawer((s) => ({ ...s, visible: true, item: null, title: '新增', val: 'only', type: 'add', // onFinish: async (vals) => { // //console.log(vals); // let params = { // ...vals, // }; // let res = await doFetch({ // url: urlParams.save, // params, // }); // if (res.code === '0000') { // message.success('新增成功!'); // setDrawer((s) => ({ // ...s, // visible: false, // })); // actionRef.current.reload(); // } // }, })); }, }, }} x={1500} extraparams={extraparams} /> { setDrawer((s) => ({ ...s, visible: false, })); }} {...drawer} colProps={{ span: 8, }} > {drawer?.visible && selectMoreDrawerType(drawer?.type)} { await setactiveTab(3); await setCurrDrawer((s) => ({ ...s, visible: false, item: null, })); }} {...currDrawer} colProps={{ span: 8, }} > { const { data } = await doFetch({ url: urlParams.detail, params: { id: drawer?.item?.id }, }); return { success: true, data: data?.data, }; }} columns={[ { title: '设备编号', dataIndex: 'equipmentNo', key: 'equipmentNo', }, { title: '设备名称', dataIndex: 'equipmentName', key: 'equipmentName', }, { title: '位置号', dataIndex: 'positionNo', key: 'positionNo', }, { title: '公司名称', dataIndex: 'organizationName', key: 'organizationId', }, { title: '部门名称', dataIndex: 'departmentName', key: 'departmentId', }, { title: '工厂名称', dataIndex: 'factoryName', key: 'factoryId', }, { title: '车间名称', dataIndex: 'shopName', key: 'shopId', }, { title: '工段名称', dataIndex: 'sectionName', key: 'sectionId', }, { title: '产线名称', dataIndex: 'productLineName', key: 'productLineName', }, ]} /> { const { data } = await doFetch({ url: urlParams_resume.detail, params: { id: currDrawer?.item?.id }, }); return { success: true, data: data?.data?.resume, }; }} columns={currfields[currDrawer?.item?.logType]} />
); } export default Model;