diff --git a/config/authRoutes.js b/config/authRoutes.js index 540a9fede8749aa17ff596223918e0945ec63f8d..8bd327df564b20e0ad8cd80a7b4ba1cc8e779311 100644 --- a/config/authRoutes.js +++ b/config/authRoutes.js @@ -200,6 +200,12 @@ export default [ "path": "/spare/setting", "icon": "", "component": "./spare/setting" + }, + { + "name": "备件领用", + "path": "/spare/requisition", + "icon": "", + "component": "./spare/requisition" } ] } diff --git a/config/proxy.js b/config/proxy.js index 3e1892dc56d107d862f5e3b84636bfda0a6a6a4f..e46e6914ae9f5452614f8ae9bed89435ab1525e1 100644 --- a/config/proxy.js +++ b/config/proxy.js @@ -13,7 +13,7 @@ export default { dev: { [defaultSetting.proxypath]: { // è¦ä»£ç†çš„åœ°å€ - target: 'http://192.168.40.64:28001', //jfå“¥ + target: 'http://192.168.40.64:28000', //jfå“¥ // target: 'http://192.168.40.203:8000', //djå“¥ changeOrigin: true, }, diff --git a/src/components/AutoTable/mtable.jsx b/src/components/AutoTable/mtable.jsx index b7aaa1e86c6257595dd1e4790d75e6b73a509ec0..d5c8bf36e519de41f7b440a95b7d3a0026a62983 100644 --- a/src/components/AutoTable/mtable.jsx +++ b/src/components/AutoTable/mtable.jsx @@ -403,13 +403,17 @@ const Mtable = (props) => { } : {} } - pagination={{ - showTotal: (total, range) => <span>å…±{total}æ¡</span>, - showQuickJumper: true, - showSizeChanger: true, - pageSizeOptions: [5, 10, 15, 30, 50, 100, 200], - defaultPageSize: pageSize || 15, - }} + pagination={ + pagination + ? { + showTotal: (total, range) => <span>å…±{total}æ¡</span>, + showQuickJumper: true, + showSizeChanger: true, + pageSizeOptions: [5, 10, 15, 30, 50, 100, 200], + defaultPageSize: pageSize || 15, + } + : false + } search={{ filterType: 'light', //è½»é‡æ¨¡å¼ }} diff --git a/src/components/DrawerPro/index.jsx b/src/components/DrawerPro/index.jsx index 63c75be61720f729b0884db97b637ac7f03e86c6..553e395211ae426cc6834a698fe114a9b19141eb 100644 --- a/src/components/DrawerPro/index.jsx +++ b/src/components/DrawerPro/index.jsx @@ -26,12 +26,19 @@ function DrawerPro(props) { destroyOnClose={true} {...props} > - {props.val == 'only' && props.children} - {props.val == 'only' ? null : props.val == 'detail' ? ( + {props.val == 'only' ? ( + props.children + ) : props.val == 'detail' ? ( <DetailPro {...detailprops} /> + ) : props.val == 'detailaddon' ? ( + <div> + <DetailPro {...detailprops} /> + {props?.children} + </div> ) : ( <InitForm {...newProps} /> )} + {pushSettingFlag ? ( <a id="pushSettingBtn" diff --git a/src/components/InitForm/index.jsx b/src/components/InitForm/index.jsx index 5b2e659fbd5e6e7da7888bebfd9e0c7e0a7d1243..b2665abb1742643161ab9dbad855ed1fe180c8bb 100644 --- a/src/components/InitForm/index.jsx +++ b/src/components/InitForm/index.jsx @@ -102,13 +102,14 @@ function InitForm(props) { //console.log(changedValues, allValues); }, val, + style = {}, } = props; let proformRef = useRef(); proformRef = formRef ?? proformRef; return ( <ProForm - style={{ overflow: 'hidden' }} + style={{ overflow: 'hidden', ...style }} formRef={proformRef} onFinish={onFinish} formKey={formKey ?? parseInt(Math.random() * 1000000)} diff --git a/src/pages/spare/edgestore/columns.js b/src/pages/spare/edgestore/columns.js index 02a28f6977e7343f1fcd2f94161f9506d49e7b15..cf9acac970d2bbfa67ac98197152d3cb25214d43 100644 --- a/src/pages/spare/edgestore/columns.js +++ b/src/pages/spare/edgestore/columns.js @@ -1,60 +1,62 @@ function getcolumns(setdrawer) { - return { - "pathconfig": { - "enableadd": false, - "enableedit": false, - "enabledelete": false, - "enabledetail": false, - "add": "", - "edit": "", - "list": "/repair/umRepairOrder/queryRepairOrderList", - "delete": "", - "detail": "" - }, + return { "columns": [ { - "title": "ç»´ä¿®å•å·", - "dataIndex": "repairOrderNo", - "key": "repairOrderNo" + "title": "线边库åç§°", + "dataIndex": "stockName", + "key": "stockName" }, { - "title": "设备编å·", - "dataIndex": "equipmentNo", - "key": "equipmentNo" + "title": "备件料å·", + "dataIndex": "sparePartNo", + "key": "sparePartNo" }, { - "title": "设备åç§°", - "dataIndex": "equipmentName", - "key": "equipmentName" + "title": "备件åç§°", + "dataIndex": "sparePartName", + "key": "sparePartName" }, { - "title": "æ•…éšœæè¿°", - "dataIndex": "faultDescription", - "key": "faultDescription" + "title": "供应商编å·", + "dataIndex": "supplierNo", + "key": "supplierNo" }, { - "title": "报修人员", - "dataIndex": "repairUserName", - "key": "repairUserName" + "title": "供应商åç§°", + "dataIndex": "supplierName", + "key": "supplierName" }, { - "title": "报修时间", - "dataIndex": "repairTime", - "key": "repairTimeList", - "valueType": "dateTimeRange" + "title": "æŒæœ‰æ•°é‡", + "dataIndex": "actualStock", + "key": "actualStock", + "hideInSearch": true }, { - "title": "报修å•å·", - "dataIndex": "repairNo", - "key": "repairNo" + "title": "å¯ç”¨æ•°é‡", + "dataIndex": "usedStock", + "key": "usedStock", + "hideInSearch": true }, { - "title": "å·¥å•状æ€", - "dataIndex": "statusName", - "key": "statusName" + "title": "库å˜å•ä½", + "dataIndex": "unit", + "key": "unit", + "hideInSearch": true } - ] + ], + "pathconfig": { + "enableadd": false, + "enableedit": false, + "enabledelete": false, + "enabledetail": false, + "add": "", + "edit": "", + "list": "/sparepart/lineStock/queryList", + "delete": "", + "detail": "" + } }; - -} -export default getcolumns; \ No newline at end of file + } + export default getcolumns; + \ No newline at end of file diff --git a/src/pages/spare/edgestore/index.jsx b/src/pages/spare/edgestore/index.jsx index a93fc4ce6963960fc09a68d013bf4799cb495672..ad718a7802253b8858d94b07366efa96d8d865d8 100644 --- a/src/pages/spare/edgestore/index.jsx +++ b/src/pages/spare/edgestore/index.jsx @@ -1,166 +1,156 @@ import * as React from 'react'; - import { useState, useMemo, useRef } from 'react'; - import DrawerPro from '@/components/DrawerPro'; - import AutoTable from '@/components/AutoTable'; - import PremButton from '@/components/PremButton'; - import getcolumns from './columns'; - import { useRequest } from 'ahooks'; - import { doFetch } from '@/utils/doFetch'; +import { useState, useMemo, useRef } from 'react'; +import DrawerPro from '@/components/DrawerPro'; +import AutoTable from '@/components/AutoTable'; +import PremButton from '@/components/PremButton'; +import getcolumns from './columns'; +import { useRequest } from 'ahooks'; +import { doFetch } from '@/utils/doFetch'; - function Edgestore(props) { - const actionRef = useRef(), - formRef = useRef(); - const [drawer, setdrawer] = useState({ - open: false, - }); - const pathconfig = useMemo(() => { - let pathconf = getcolumns(setdrawer)?.pathconfig ?? {}; - return pathconf; - }, []); - const { run, loading } = useRequest(doFetch, { - manual: true, - onSuccess: (res, params) => { - if (res?.code == '0000') { - actionRef?.current?.reload(); - setdrawer((s) => ({ - ...s, - open: false, - })); - } - }, - }); +function Edgestore(props) { + const actionRef = useRef(), + formRef = useRef(); + const [drawer, setdrawer] = useState({ + open: false, + }); + const pathconfig = useMemo(() => { + let pathconf = getcolumns(setdrawer)?.pathconfig ?? {}; + return pathconf; + }, []); + const { run, loading } = useRequest(doFetch, { + manual: true, + onSuccess: (res, params) => { + if (res?.code == '0000') { + actionRef?.current?.reload(); + setdrawer((s) => ({ + ...s, + open: false, + })); + } + }, + }); - const detail = (text, row, _, action) => { - return ( - <PremButton - btn={{ - size: 'small', - type: 'link', - onClick: () => { - setdrawer((s) => ({ - ...s, - open: true, - item: row, - title: '详情', - val: 'detail', - title: '详细信æ¯', - })); - }, - }} - > - 详情 - </PremButton> - ); - }; + const detail = (text, row, _, action) => { + return ( + <PremButton + btn={{ + size: 'small', + type: 'link', + onClick: () => { + setdrawer((s) => ({ + ...s, + open: true, + item: row, + title: '详情', + val: 'detail', + title: '详细信æ¯', + })); + }, + }} + > + 详情 + </PremButton> + ); + }; - const edit = (text, row, _, action) => { - return ( - <PremButton - btn={{ - size: 'small', + const edit = (text, row, _, action) => { + return ( + <PremButton + btn={{ + size: 'small', + onClick: () => { + setdrawer((s) => ({ + ...s, + open: true, + item: row, + title: '编辑', + val: 'edit', + })); + }, + }} + > + 编辑 + </PremButton> + ); + }; + + const remove = (text, row, _, action) => { + return ( + <PremButton + pop={{ + title: '是å¦åˆ 除?', + okText: '确认', + cancelText: 'å–æ¶ˆ', + onConfirm: () => { + run({ url: pathconfig?.delete || '/delete', params: { id: row?.id } }); + }, + }} + btn={{ + size: 'small', + type: 'danger', + }} + > + åˆ é™¤ + </PremButton> + ); + }; + + const columns = useMemo(() => { + let defcolumn = getcolumns(setdrawer)?.columns; + return defcolumn; + }, []); + + return ( + <div style={{ position: 'relative' }}> + <AutoTable + pagetitle=" 线边库å˜" + columns={columns} + actionRef={actionRef} + path={pathconfig?.list || '/ngic-auth/sysUser/query/page'} + pageextra={pathconfig?.enableadd ? 'add' : null} + resizeable={false} + addconfig={{ + // access: 'sysDepartment_save', + btn: { + disabled: false, onClick: () => { setdrawer((s) => ({ ...s, open: true, - item: row, - title: '编辑', - val: 'edit', + item: null, + title: '新增', + val: 'add', })); }, - }} - > - 编辑 - </PremButton> - ); - }; + }, + }} + /> - const remove = (text, row, _, action) => { - return ( - <PremButton - pop={{ - title: '是å¦åˆ 除?', - okText: '确认', - cancelText: 'å–æ¶ˆ', - onConfirm: () => { - run({ url: pathconfig?.delete || '/delete', params: { id: row?.id } }); - }, - }} - btn={{ - size: 'small', - type: 'danger', - }} - > - åˆ é™¤ - </PremButton> - ); - }; - - const columns = useMemo(() => { - let defcolumn = getcolumns(setdrawer)?.columns; - return defcolumn.concat({ - title: 'æ“作', - valueType: 'option', - width: 150, - render: (text, row, _, action) => [ - pathconfig?.enabledetail && detail(text, row, _, action), - pathconfig?.enableedit && edit(text, row, _, action), - pathconfig?.enabledelete && remove(text, row, _, action), - ], - }); - }, []); - - return ( - <div style={{ position: 'relative' }}> - <AutoTable - pagetitle=" 线边库å˜" - columns={columns} - actionRef={actionRef} - path={pathconfig?.list || '/ngic-auth/sysUser/query/page'} - pageextra={pathconfig?.enableadd ? 'add' : null} - resizeable={true} - addconfig={{ - // access: 'sysDepartment_save', - btn: { - disabled: false, - onClick: () => { - setdrawer((s) => ({ - ...s, - open: true, - item: null, - title: '新增', - val: 'add', - })); - }, - }, - }} - /> - - <DrawerPro - fields={columns} - params={{ id: drawer?.item?.id }} - formRef={formRef} - placement="right" - detailpath={pathconfig?.detail || null} - detailData={drawer?.item} - defaultFormValue={drawer?.item} - onClose={() => { - setdrawer((s) => ({ - ...s, - open: false, - })); - }} - {...drawer} - onFinish={(vals) => { - if (drawer?.val == 'add') { - run({ url: pathconfig?.add || '/add', params: { ...vals } }); - } else if (drawer?.val == 'edit') { - run({ url: pathconfig?.edit || '/edit', params: { ...vals, id: drawer?.item?.id } }); - } - }} - /> - </div> - ); - } + <DrawerPro + fields={columns} + params={{ id: drawer?.item?.id }} + formRef={formRef} + placement="right" + detailpath={pathconfig?.detail || null} + detailData={drawer?.item} + defaultFormValue={drawer?.item} + onClose={() => { + setdrawer((s) => ({ + ...s, + open: false, + })); + }} + {...drawer} + onFinish={(vals) => { + if (drawer?.val == 'add') { + run({ url: pathconfig?.add || '/add', params: { ...vals } }); + } else if (drawer?.val == 'edit') { + run({ url: pathconfig?.edit || '/edit', params: { ...vals, id: drawer?.item?.id } }); + } + }} + /> + </div> + ); +} - export default Edgestore; - \ No newline at end of file +export default Edgestore; diff --git a/src/pages/spare/outstore/columns.js b/src/pages/spare/outstore/columns.js index 8d91f5c2b99fc9f174b2f4abb27bdf7abcb6f076..5c8ee2a3726c72784fa57b4efe9db4dff057f0e6 100644 --- a/src/pages/spare/outstore/columns.js +++ b/src/pages/spare/outstore/columns.js @@ -1,5 +1,29 @@ import AutoTable from '@/components/AutoTable/mtable'; +function ExtraTable({ dataSource }) { + return ( + <div style={{ padding: '4px 4px 4px 36px' }}> + <AutoTable + dataSource={dataSource} + pagination={false} + resizeable={false} + columns={[ + { title: '供应商编å·', dataIndex: 'supplierNo', key: 'supplierNo', width: 200 }, + { title: '供应商åç§°', dataIndex: 'supplierName', key: 'supplierName', width: 200 }, + { + title: 'åº“å˜æ•°é‡', + dataIndex: 'actualStock', + key: 'actualStock', + hideInSearch: true, + width: 200, + }, + { title: '下架数é‡', dataIndex: 'operateNum', key: 'operateNum', hideInSearch: true }, + ]} + /> + </div> + ); +} + function getcolumns(setdrawer) { const columns = [ { @@ -7,12 +31,14 @@ function getcolumns(setdrawer) { dataIndex: 'sparePartNo', key: 'sparePartNo', editable: false, + width: 235, }, { title: '备件åç§°', dataIndex: 'sparePartName', key: 'sparePartName', editable: false, + width: 200, }, { title: 'å¯ç”¨åº“å˜', @@ -20,6 +46,7 @@ function getcolumns(setdrawer) { key: 'usedStock', editable: false, hideInSearch: true, + width: 200, }, { title: '出库数é‡', @@ -30,6 +57,7 @@ function getcolumns(setdrawer) { fieldProps: { precision: 3, }, + width: 200, }, { title: '库å˜å•ä½', @@ -167,6 +195,7 @@ function getcolumns(setdrawer) { path: '/sparepart/spareStock/queryByOperate', hideInSearch: true, hideInTable: true, + rowName: 'sparePartName', render: (text, row) => { return ( <AutoTable @@ -175,6 +204,12 @@ function getcolumns(setdrawer) { hideInSearch: true, }))} dataSource={row?.taskSpareList} + resizeable={false} + expandable={{ + expandedRowRender: (record) => ( + <ExtraTable dataSource={record?.taskSpareSupplierList ?? []} /> + ), + }} /> ); }, @@ -330,6 +365,7 @@ function getcolumns(setdrawer) { path: '/sparepart/spareStock/queryByOperate', hideInSearch: true, hideInTable: true, + rowName: 'sparePartName', render: (text, row) => { return ( <AutoTable @@ -337,7 +373,13 @@ function getcolumns(setdrawer) { ...it, hideInSearch: true, }))} + resizeable={false} dataSource={row?.taskSpareList} + expandable={{ + expandedRowRender: (record) => ( + <ExtraTable dataSource={record?.taskSpareSupplierList ?? []} /> + ), + }} /> ); }, diff --git a/src/pages/spare/requisition/columns.js b/src/pages/spare/requisition/columns.js new file mode 100644 index 0000000000000000000000000000000000000000..bf97c0f9222b7ff04ec5bf33c9a703ba93020645 --- /dev/null +++ b/src/pages/spare/requisition/columns.js @@ -0,0 +1,450 @@ +import AutoTable from '@/components/AutoTable/mtable'; + +function getcolumns(type) { + const columns = [ + { + title: '备件料å·', + dataIndex: 'sparePartNo', + key: 'sparePartNo', + editable: false, + }, + { + title: '备件åç§°', + dataIndex: 'sparePartName', + key: 'sparePartName', + editable: false, + }, + { + title: 'å¯ç”¨åº“å˜', + dataIndex: 'usedStock', + key: 'usedStock', + editable: false, + hideInSearch: true, + }, + { + title: '申请数é‡', + dataIndex: 'operateNum', + key: 'operateNum', + hideInSearch: true, + valueType: 'digit', + fieldProps: { + precision: 3, + }, + formItemProps: { + rules: [ + { + required: true, + message: 'æ¤é¡¹ä¸ºå¿…填项', + }, + ], + }, + }, + { + title: '库å˜å•ä½', + dataIndex: 'unit', + editable: false, + hideInSearch: true, + }, + ]; + return [ + { + tab: '未完æˆ', + key: '1', + columns: [ + { + title: '领用å•å·', + dataIndex: 'taskNo', + key: 'taskNo', + }, + { + title: 'ç”³è¯·åŽŸå› ', + dataIndex: 'applyReasonName', + key: 'applyReason', + valueType: 'select', + options: [ + { + label: '备库领用', + value: 1, + }, + { + label: '维修领用', + value: 2, + }, + { + label: 'ä¿å…»é¢†ç”¨', + value: 3, + }, + { + label: '点检领用', + value: 4, + }, + ], + }, + { + title: '入库仓库', + dataIndex: 'inWarehouseName', + key: 'inWarehouseId', + valueType: 'select', + options: { + path: '/auth/sysShop/getUserShopSelection', + params: {}, + }, + hideInForm: type == 1, + }, + { + title: '出库仓库', + dataIndex: 'outWarehouseName', + key: 'outWarehouseName', + hideInForm: true, + }, + { + title: '备件ç§ç±»', + dataIndex: 'spareTypeNum', + key: 'spareTypeNum', + hideInForm: true, + hideInSearch: true, + }, + { + title: '相关å•å·', + dataIndex: 'relationNo', + key: 'relationNo', + }, + { + title: '创建时间', + dataIndex: 'createTime', + key: 'createTimeList', + hideInForm: true, + valueType: 'dateRange', + render: (text, row) => { + return <span>{row?.createTime}</span>; + }, + hideInForm: true, + }, + { + title: '出库å•å·', + dataIndex: 'outWarehouseTaskNo', + key: 'outWarehouseTaskNo', + hideInForm: true, + }, + { + dataIndex: 'remark', + valueType: 'textarea', + title: '备注', + key: 'remark', + colProps: { + span: 24, + }, + hideInTable: true, + hideInSearch: true, + }, + { + title: '状æ€', + dataIndex: 'statusName', + key: 'status', + hideInForm: true, + valueType: 'select', + options: [ + { + label: '待审批', + value: 1, + }, + { + label: '出库ä¸', + value: 2, + }, + ], + }, + { + title: '备件信æ¯', + dataIndex: 'details', + key: 'details', + valueType: 'split', + }, + { + title: '备件', + dataIndex: 'detailsList', + key: 'detailsList', + valueType: 'formSelectList', + colProps: { + span: 24, + }, + columns, + span: 12, + path: '/sparepart/spareStock/queryByOperate', + hideInSearch: true, + hideInTable: true, + rowName: 'sparePartName', + render: (text, row) => { + return ( + <AutoTable + columns={columns?.map((it) => ({ + ...it, + hideInSearch: true, + }))} + dataSource={row?.detailsList} + /> + ); + }, + }, + { + title: '审批信æ¯', + dataIndex: 'cdetails', + key: 'cdetails', + valueType: 'split', + hideInForm: true, + }, + { + title: '审批人', + dataIndex: 'approvalUserName', + key: 'approvalUserName', + hideInTable: true, + hideInForm: true, + hideInSearch: true, + }, + { + title: '审批时间', + dataIndex: 'approvalTime', + key: 'approvalTime', + hideInSearch: true, + hideInTable: true, + hideInForm: true, + }, + { + title: '审批结果', + dataIndex: 'approvalResultName', + key: 'approvalResultName', + hideInSearch: true, + hideInTable: true, + hideInForm: true, + }, + { + title: '审批备注', + dataIndex: 'approvalRemark', + key: 'approvalRemark', + hideInSearch: true, + hideInTable: true, + hideInForm: true, + }, + ], + pathconfig: { + enableadd: true, + enableedit: true, + enabledelete: true, + enabledetail: true, + add: '/sparepart/spareApplyTask/save', + edit: '', + list: '/sparepart/spareApplyTask/queryNoComplete', + delete: '/sparepart/spareApplyTask/deleteById', + detail: '/sparepart/spareApplyTask/queryDetails', + }, + }, + { + tab: '已完æˆ', + key: '2', + columns: [ + { + title: '领用å•å·', + dataIndex: 'taskNo', + key: 'taskNo', + }, + { + title: 'ç”³è¯·åŽŸå› ', + dataIndex: 'applyReasonName', + key: 'applyReason', + valueType: 'select', + options: [ + { + label: '备库领用', + value: 1, + }, + { + label: '维修领用', + value: 2, + }, + { + label: 'ä¿å…»é¢†ç”¨', + value: 3, + }, + { + label: '点检领用', + value: 4, + }, + ], + }, + { + title: '入库仓库', + dataIndex: 'inWarehouseName', + key: 'inWarehouseId', + valueType: 'select', + options: { + path: '/auth/sysShop/getUserShopSelection', + params: {}, + }, + hideInForm: type == 1, + }, + { + title: '出库仓库', + dataIndex: 'outWarehouseName', + key: 'outWarehouseName', + hideInForm: true, + }, + { + title: '备件ç§ç±»', + dataIndex: 'spareTypeNum', + key: 'spareTypeNum', + hideInForm: true, + hideInSearch: true, + }, + { + title: '相关å•å·', + dataIndex: 'relationNo', + key: 'relationNo', + }, + { + title: '创建时间', + dataIndex: 'createTime', + key: 'createTimeList', + hideInForm: true, + valueType: 'dateRange', + render: (text, row) => { + return <span>{row?.createTime}</span>; + }, + hideInForm: true, + }, + { + title: 'å®Œæˆæ—¶é—´', + dataIndex: 'completeTime', + key: 'completeTimeList', + hideInForm: true, + valueType: 'dateRange', + render: (text, row) => { + return <span>{row?.completeTime}</span>; + }, + hideInForm: true, + }, + { + title: '出库å•å·', + dataIndex: 'outWarehouseTaskNo', + key: 'outWarehouseTaskNo', + hideInForm: true, + }, + { + dataIndex: 'remark', + valueType: 'textarea', + title: '备注', + key: 'remark', + colProps: { + span: 24, + }, + hideInTable: true, + hideInSearch: true, + }, + { + title: '状æ€', + dataIndex: 'statusName', + key: 'status', + hideInForm: true, + valueType: 'select', + options: [ + { + label: '已驳回', + value: 3, + }, + { + label: '处ç†å¤±è´¥ ', + value: 4, + }, + { + label: '已完æˆ', + value: 5, + }, + ], + }, + { + title: '备件信æ¯', + dataIndex: 'details', + key: 'details', + valueType: 'split', + hideInForm: true, + }, + { + title: '备件', + dataIndex: 'detailsList', + key: 'detailsList', + valueType: 'formSelectList', + colProps: { + span: 24, + }, + columns, + span: 12, + path: '/sparepart/spareStock/queryByOperate', + hideInSearch: true, + hideInTable: true, + rowName: 'sparePartName', + render: (text, row) => { + return ( + <AutoTable + columns={columns?.map((it) => ({ + ...it, + hideInSearch: true, + }))} + dataSource={row?.detailsList} + /> + ); + }, + }, + + { + title: '审批信æ¯', + dataIndex: 'cdetails', + key: 'cdetails', + valueType: 'split', + }, + { + title: '审批人', + dataIndex: 'approvalUserName', + key: 'approvalUserName', + hideInTable: true, + hideInForm: true, + hideInSearch: true, + }, + { + title: '审批时间', + dataIndex: 'approvalTime', + key: 'approvalTime', + hideInSearch: true, + hideInTable: true, + hideInForm: true, + }, + { + title: '审批结果', + dataIndex: 'approvalResultName', + key: 'approvalResultName', + hideInSearch: true, + hideInTable: true, + hideInForm: true, + }, + { + title: '审批备注', + dataIndex: 'approvalRemark', + key: 'approvalRemark', + hideInSearch: true, + hideInTable: true, + hideInForm: true, + }, + ], + pathconfig: { + enableadd: true, + enableedit: false, + enabledelete: false, + enabledetail: true, + add: '/sparepart/spareApplyTask/save', + edit: '', + list: '/sparepart/spareApplyTask/queryYesComplete', + delete: '', + detail: '/sparepart/spareApplyTask/queryDetails', + }, + }, + ]; +} +export default getcolumns; diff --git a/src/pages/spare/requisition/index.jsx b/src/pages/spare/requisition/index.jsx new file mode 100644 index 0000000000000000000000000000000000000000..aab2f23d7ada7854837761b104b4285f32ed2ccb --- /dev/null +++ b/src/pages/spare/requisition/index.jsx @@ -0,0 +1,228 @@ +import * as React from 'react'; +import { useState, useMemo, useRef } from 'react'; +import DrawerPro from '@/components/DrawerPro'; +import AutoTable from '@/components/AutoTable'; +import PremButton from '@/components/PremButton'; +import getcolumns from './columns'; +import { useRequest } from 'ahooks'; +import { doFetch } from '@/utils/doFetch'; +import InitForm from '@/components/InitForm'; +import { message, Divider } from 'antd'; + +function Requisition(props) { + const actionRef = useRef(), + formRef = useRef(); + const [drawer, setdrawer] = useState({ + open: false, + }), + [activeTabKey, setactiveTabKey] = useState('1'); + + const { run, loading } = useRequest(doFetch, { + manual: true, + onSuccess: (res, params) => { + if (res?.code == '0000') { + message.success('æ“作æˆåŠŸ'); + actionRef?.current?.reload(); + setdrawer((s) => ({ + ...s, + open: false, + })); + } + }, + }); + + const detail = (text, row, _, action) => { + return ( + <PremButton + btn={{ + size: 'small', + type: 'link', + onClick: () => { + setdrawer((s) => ({ + ...s, + open: true, + item: row, + title: '详情', + val: 'detail', + title: '详细信æ¯', + })); + }, + }} + > + 详情 + </PremButton> + ); + }; + + const edit = (text, row, _, action) => { + return ( + <PremButton + btn={{ + size: 'small', + disabled: row.status == 2, + onClick: () => { + setdrawer((s) => ({ + ...s, + open: true, + item: row, + title: '审批', + val: 'detailaddon', + addon: ( + <> + <InitForm + style={{ background: '#f0f0f0', padding: 12, borderTop: '#1890ff solid 1px' }} + fields={[ + { + title: '审批结果', + dataIndex: 'approvalResult', + key: 'approvalResult', + formItemProps: { rules: [{ required: true, message: 'æ¤é¡¹ä¸ºå¿…填项' }] }, + valueType: 'radio', + options: [ + { label: '通过', value: '1' }, + { label: 'ä¸é€šè¿‡', value: '2' }, + ], + }, + { + title: '审批备注', + dataIndex: 'approvalRemark', + key: 'approvalRemark', + valueType: 'textarea', + colProps: { span: 24 }, + }, + ]} + onFinish={(vals) => { + run({ + url: '/sparepart/spareApplyTask/approval', + params: { ...vals, id: row?.id }, + }); + }} + /> + </> + ), + })); + }, + }} + > + 审批 + </PremButton> + ); + }; + + const remove = (text, row, _, action) => { + return ( + <PremButton + pop={{ + title: '是å¦åˆ 除?', + okText: '确认', + cancelText: 'å–æ¶ˆ', + onConfirm: () => { + run({ url: pathconfig?.delete || '/delete', params: { id: row?.id } }); + }, + }} + btn={{ + size: 'small', + type: 'danger', + }} + > + åˆ é™¤ + </PremButton> + ); + }; + + const columns = useMemo(() => { + let defcolumn = getcolumns(drawer?.type).filter((it) => it.key == activeTabKey)[0]?.columns; + let defpath = + getcolumns(drawer?.type).filter((it) => it.key == activeTabKey)[0]?.pathconfig ?? {}; + return defcolumn.concat({ + title: 'æ“作', + valueType: 'option', + width: 150, + render: (text, row, _, action) => [ + defpath?.enabledetail && detail(text, row, _, action), + defpath?.enableedit && edit(text, row, _, action), + defpath?.enabledelete && remove(text, row, _, action), + ], + }); + }, [activeTabKey, drawer?.type]); + + const pathconfig = useMemo(() => { + let defpath = getcolumns(setdrawer).filter((it) => it.key == activeTabKey)[0]?.pathconfig ?? {}; + return defpath; + }, [activeTabKey]); + + return ( + <div style={{ position: 'relative' }}> + <AutoTable + pagetitle="备件领用" + columns={columns} + path={pathconfig?.list || '/ngic-auth/sysUser/query/page'} + actionRef={actionRef} + pageextra={pathconfig?.enableadd ? 'add' : null} + resizeable={false} + addconfig={{ + // access: 'sysDepartment_save', + btn: { + disabled: false, + onClick: async () => { + let res = await doFetch({ + url: '/base/pmBaseBusinessData/querySpareStockType', + params: {}, + }); + let type = res?.data?.data?.type; + setdrawer((s) => ({ + ...s, + open: true, + item: null, + title: '新增', + val: 'add', + type, + })); + }, + }, + }} + tabList={getcolumns()} + activeTabKey={activeTabKey} + onTabChange={(key) => { + setactiveTabKey(key); + }} + /> + + <DrawerPro + fields={columns} + detailpath={pathconfig?.detail || null} + defaultFormValue={drawer?.item} + params={{ id: drawer?.item?.id }} + formRef={formRef} + placement="right" + onClose={() => { + setdrawer((s) => ({ + ...s, + open: false, + })); + }} + {...drawer} + onFinish={(vals) => { + const detailsList = vals?.detailsList?.map?.((it, i) => { + return { + spareStockId: it?.id, + operateNum: it?.operateNum, + }; + }); + if (drawer?.val == 'add') { + run({ url: pathconfig?.add || '/add', params: { ...vals, detailsList } }); + } else if (drawer?.val == 'edit') { + run({ + url: pathconfig?.edit || '/edit', + params: { ...vals, id: drawer?.item?.id, detailsList }, + }); + } + }} + > + {drawer?.addon} + </DrawerPro> + </div> + ); +} + +export default Requisition;