import dayjs from 'dayjs'; function getcolumns(setdrawer) { const disabledDateOfDay = (current) => { // Can not select days before today and today return current && current < dayjs().endOf('day'); }; const disabledDateOfMonth = (current) => { // Can not select days before today and today return current && current < dayjs().startOf('month'); }; const columns_day = [ { title: '设备编号', dataIndex: 'equipmentNo', key: 'equipmentNo', editable: false, }, { title: '设备名称', dataIndex: 'equipmentName', key: 'equipmentName', editable: false, }, { title: '工厂名称', dataIndex: 'factoryName', key: 'factoryId', hideInForm: true, valueType: 'select', fieldProps: { placeholder: '请选择', showSearch: true, }, options: { path: '/auth/sysFactory/getAllFactorySelection', params: {}, }, editable: false, }, { title: '车间名称', dataIndex: 'shopName', key: 'shopId', hideInForm: true, valueType: 'select', fieldProps: { placeholder: '请选择', showSearch: true, }, options: { path: '/auth/sysShop/getAllShopSelection', params: {}, }, editable: false, }, { title: '下次保养日期', dataIndex: 'nextMaintainDate', formItemProps: { rules: [ { required: true, message: '此项为必填项', }, ], }, fieldProps: { disabledDate: disabledDateOfDay, }, valueType: 'date', hideInSearch: true, }, ]; const columns_month = [ { title: '设备编号', dataIndex: 'equipmentNo', key: 'equipmentNo', editable: false, }, { title: '设备名称', dataIndex: 'equipmentName', key: 'equipmentName', editable: false, }, { title: '工厂名称', dataIndex: 'factoryName', key: 'factoryId', hideInForm: true, valueType: 'select', fieldProps: { placeholder: '请选择', showSearch: true, }, options: { path: '/auth/sysFactory/getAllFactorySelection', params: {}, }, editable: false, }, { title: '车间名称', dataIndex: 'shopName', key: 'shopId', hideInForm: true, valueType: 'select', fieldProps: { placeholder: '请选择', showSearch: true, }, options: { path: '/auth/sysShop/getAllShopSelection', params: {}, }, editable: false, }, { title: '下次保养日期', dataIndex: 'nextMaintainDate', formItemProps: { rules: [ { required: true, message: '此项为必填项', }, ], }, fieldProps: { disabledDate: disabledDateOfMonth, }, valueType: 'dateMonth', hideInSearch: true, }, ]; return [ { tab: '未完成', key: '1', columns: [ { title: '保养计划号', dataIndex: 'maintainNo', key: 'maintainNo', hideInForm: true, render: (text, row, _, action) => { return ( { setdrawer((s) => ({ ...s, open: true, val: 'detail', title: '详细信息', item: row, })); }} > {row?.maintainNo} ); }, }, { title: '设备编号', dataIndex: 'equipmentNo', key: 'equipmentNo', hideInForm: true, }, { title: '设备名称', dataIndex: 'equipmentName', key: 'equipmentName', hideInForm: true, }, { title: '工厂名称', dataIndex: 'factoryName', key: 'factoryId', valueType: 'select', fieldProps: { showSearch: true, }, mode: 'radio', options: { path: '/auth/sysFactory/getAllFactorySelection', params: {}, }, hideInForm: true, }, { title: '车间名称', dataIndex: 'shopName', key: 'shopId', fieldProps: { showSearch: true, }, valueType: 'select', mode: 'radio', options: { path: '/auth/sysShop/getAllShopSelection', params: {}, }, hideInForm: true, }, { title: '保养类型', dataIndex: 'maintainTypeName', key: 'maintainType', valueType: 'select', mode: 'radio', options: [ { label: '自主保养', value: '1', }, { label: '专业保养', value: '2', }, ], formItemProps: { rules: [ { required: true, message: '此项为必填项', }, ], }, }, { title: '保养频次', dataIndex: 'maintainFrequencyName', key: 'maintainFrequency', formItemProps: { rules: [ { required: true, message: '此项为必填项', }, ], }, valueType: 'select', mode: 'radio', options: [ { label: '周', value: '0', }, { label: '月度', value: '1', }, { label: '季度', value: '2', }, { label: '半年', value: '3', }, { label: '年度', value: '4', }, ], }, { title: '计划类型', dataIndex: 'isCycle', key: 'isCycle', valueType: 'select', mode: 'radio', options: [ { label: '单次', value: '1', }, { label: '周期', value: '2', }, ], hideInForm: false, formItemProps: { rules: [ { required: true, message: '此项为必填项', }, ], }, render: (_, row) => { return row?.isCycle == 1 ? '单次' : '周期'; }, }, { title: '下次保养日期', dataIndex: 'nextMaintainDate', key: 'nextMaintainDateList', valueType: 'dateRange', hideInForm: true, }, { title: '状态', dataIndex: 'maintainStatusName', key: 'maintainStatus', hideInForm: true, valueType: 'select', fieldProps: { dropdownMatchSelectWidth: 100, }, mode: 'radio', options: [ { label: '未开始', value: '1', }, { label: '执行中', value: '2', }, ], }, { title: '选择设备', dataIndex: 'paramList', key: 'paramList', formItemProps: { rules: [ { required: true, message: '此项为必填项', }, ], }, hideInSearch: true, hideInTable: true, hideInForm: { maintainFrequency: { reverse: ['0'], }, }, valueType: 'formSelectList', colProps: { span: 24, }, path: '/asset/equipment/list/user/shop', columns: columns_day, hideInDescriptions: true, }, { title: '选择设备', dataIndex: 'paramList', key: 'paramList', hideInForm: { maintainFrequency: ['0'], }, formItemProps: { rules: [ { required: true, message: '此项为必填项', }, ], }, hideInSearch: true, hideInTable: true, valueType: 'formSelectList', colProps: { span: 24, }, path: '/asset/equipment/list/user/shop', columns: columns_month, hideInDescriptions: true, }, ], pathconfig: { enableadd: true, enableedit: true, enabledelete: true, enabledetail: true, add: '/maintain/umMaintainPlan/save', edit: '/maintain/umMaintainPlan/save', list: '/maintain/umMaintainPlan/queryList', delete: '/maintain/umMaintainPlan/deleteById', detail: '/maintain/umMaintainPlan/queryById', }, }, { tab: '已完成', key: '2', columns: [ { title: '保养计划号', dataIndex: 'maintainNo', key: 'maintainNo', hideInForm: true, render: (text, row, _, action) => { return ( { setdrawer((s) => ({ ...s, open: true, val: 'detail', title: '详细信息', item: row, })); }} > {row?.maintainNo} ); }, }, { title: '设备编号', dataIndex: 'equipmentNo', key: 'equipmentNo', hideInForm: true, }, { title: '设备名称', dataIndex: 'equipmentName', key: 'equipmentName', hideInForm: true, }, { title: '工厂名称', dataIndex: 'factoryName', key: 'factoryId', valueType: 'select', mode: 'radio', options: { path: '/auth/sysFactory/getAllFactorySelection', params: {}, }, hideInForm: true, }, { title: '车间名称', dataIndex: 'shopName', key: 'shopId', valueType: 'select', mode: 'radio', options: { path: '/auth/sysShop/getAllShopSelection', params: {}, }, hideInForm: true, }, { title: '保养类型', dataIndex: 'maintainTypeName', key: 'maintainType', valueType: 'select', mode: 'radio', options: [ { label: '自主保养', value: '1', }, { label: '专业保养', value: '2', }, ], formItemProps: { rules: [ { required: true, message: '此项为必填项', }, ], }, }, { title: '保养频次', dataIndex: 'maintainFrequencyName', key: 'maintainFrequency', formItemProps: { rules: [ { required: true, message: '此项为必填项', }, ], }, valueType: 'select', mode: 'radio', options: [ { label: '周', value: '0', }, { label: '月度', value: '1', }, { label: '季度', value: '2', }, { label: '半年', value: '3', }, { label: '年度', value: '4', }, ], }, { title: '计划类型', dataIndex: 'isCycle', key: 'isCycle', valueType: 'select', mode: 'radio', options: [ { label: '单次', value: '1', }, { label: '周期', value: '2', }, ], hideInForm: false, formItemProps: { rules: [ { required: true, message: '此项为必填项', }, ], }, render: (_, row) => { return row?.isCycle == 1 ? '单次' : '周期'; }, }, { title: '关单日期', dataIndex: 'customsTime', key: 'customsTimeList', valueType: 'dateRange', hideInForm: true, }, { title: '状态', dataIndex: 'maintainStatusName', key: 'maintainStatus', hideInForm: true, valueType: 'input', mode: 'radio', hideInSearch: true, }, ], pathconfig: { enableadd: true, enableedit: true, enabledelete: true, enabledetail: true, add: '/maintain/umMaintainPlan/save', edit: '/maintain/umMaintainPlan/save', list: '/maintain/umMaintainPlanHis/queryList', delete: '/maintain/umMaintainPlan/deleteById', detail: '/maintain/umMaintainPlanHis/queryById', }, }, ]; } export default getcolumns;