|
@@ -0,0 +1,63 @@
|
|
|
+import {deleteSoftWare} from '@apis';
|
|
|
+import {useTableDeleteEvent, useTableModalEvent} from '@hooks';
|
|
|
+import {SoftwareBindData} from '@models';
|
|
|
+import {
|
|
|
+ DOUBLE_BTN_WIDTH,
|
|
|
+ MATERIAL_CODE_COL_WIDTH,
|
|
|
+ MATERIAL_NAME_COL_WIDTH,
|
|
|
+} from '@utils';
|
|
|
+import {Button} from 'antd';
|
|
|
+import {ColumnsType} from 'antd/es/table';
|
|
|
+
|
|
|
+const tableColumns: ColumnsType<SoftwareBindData> = [
|
|
|
+ {title: '物料编号', width: MATERIAL_CODE_COL_WIDTH, dataIndex: 'equipmentCode'},
|
|
|
+ {title: '物料名称', width: MATERIAL_NAME_COL_WIDTH, dataIndex: 'equipmentName'},
|
|
|
+ {title: '软件类物料编号', width: MATERIAL_CODE_COL_WIDTH, dataIndex: 'softwareCode'},
|
|
|
+ {title: '软件类物料名称', width: MATERIAL_NAME_COL_WIDTH, dataIndex: 'softwareName'},
|
|
|
+];
|
|
|
+
|
|
|
+export function useColumns(onFetch: () => void) {
|
|
|
+ const [
|
|
|
+ {visible, editId: editData},
|
|
|
+ {onClose, onAdd, onEdit},
|
|
|
+ ] = useTableModalEvent({id: '', code: '', softwareCode: ''});
|
|
|
+ const [deleteId, onDelete] = useTableDeleteEvent(
|
|
|
+ deleteSoftWare,
|
|
|
+ onFetch,
|
|
|
+ {label: '软件类绑定'},
|
|
|
+ );
|
|
|
+
|
|
|
+ const columns: ColumnsType<SoftwareBindData> = [
|
|
|
+ ...tableColumns, {
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'id',
|
|
|
+ key: 'id',
|
|
|
+ fixed: 'right',
|
|
|
+ width: DOUBLE_BTN_WIDTH,
|
|
|
+ render(_, {id, equipmentName, equipmentCode, softwareCode}) {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <Button
|
|
|
+ type='text'
|
|
|
+ className='ant-text-btn-color-primary'
|
|
|
+ disabled={deleteId === id}
|
|
|
+ onClick={onEdit({id, code: equipmentCode, softwareCode})}
|
|
|
+ >
|
|
|
+ 修改
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ type='text'
|
|
|
+ danger
|
|
|
+ loading={deleteId === id}
|
|
|
+ onClick={onDelete(id, equipmentName)}
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </Button>
|
|
|
+ </>
|
|
|
+ );
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+ return [{columns, visible, editData}, {onClose, onAdd}] as const;
|
|
|
+}
|