|  |  | 
 |  |  |     CreateBase, | 
 |  |  |     TopToolbar, | 
 |  |  |     FilterButton, | 
 |  |  |     ReferenceField, | 
 |  |  |     SearchInput, | 
 |  |  |     List, | 
 |  |  |     Create, | 
 |  |  |     useGetOne, | 
 |  |  |     useRecordContext, | 
 |  |  | } from 'react-admin'; | 
 |  |  | import { | 
 |  |  |     Dialog, | 
 |  |  | 
 |  |  | import request from '@/utils/request'; | 
 |  |  | import _, { set } from 'lodash'; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
 |  |  |     '& .css-1vooibu-MuiSvgIcon-root': { | 
 |  |  |         height: '.9em' | 
 |  |  |     }, | 
 |  |  |     '& .RaDatagrid-row': { | 
 |  |  |         cursor: 'auto' | 
 |  |  |     }, | 
 |  |  |     '& .column-name': { | 
 |  |  |     }, | 
 |  |  |     '& .opt': { | 
 |  |  |         width: 200 | 
 |  |  |     }, | 
 |  |  | })); | 
 |  |  |  | 
 |  |  |  | 
 |  |  | const LocReviseCreate = (props) => { | 
 |  |  |     const { open, setOpen, orderId } = props; | 
 |  |  |     const tableRef = useRef(); | 
 |  |  | 
 |  |  |     const refresh = useRefresh(); | 
 |  |  |     const translate = useTranslate(); | 
 |  |  |     const [tabelData, setTableData] = useState([]); | 
 |  |  |     const [locRevise, setLocRevise] = useState(); | 
 |  |  |     const [disabled, setDisabled] = useState(false); | 
 |  |  |     const [isVisible, setIsVisible] = useState("block"); | 
 |  |  |     const [isVisible, setIsVisible] = useState("none"); | 
 |  |  |     const [selectedRows, setSelectedRows] = useState([]); | 
 |  |  |     const [createDialog, setCreateDialog] = useState(false); | 
 |  |  |     const [formData, setFormData] = useState({ type: '0', orgAreaId: null, tarAreaId: null, exceTime: null, code: null }); | 
 |  |  |     const dicts = JSON.parse(localStorage.getItem('sys_dicts'))?.filter(dict => (dict.dictTypeCode == 'sys_stock_revise_type')) || []; | 
 |  |  |  | 
 |  |  |     const setFinally = () => { | 
 |  |  |         const rows = tableRef.current.state.editRows; | 
 |  |  |         for (const key in rows) { | 
 |  |  |             const find = tabelData.find(item => item.matnrId === +key); | 
 |  |  |             find.anfme = rows[key].anfme.value; | 
 |  |  |         } | 
 |  |  |         setTableData([...tabelData]); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     const FormToolbar = () => { | 
 |  |  |         return ( | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     const mutationOptions = { | 
 |  |  |         onSuccess: (data) => { | 
 |  |  |         onSuccess: (id) => { | 
 |  |  |             setIsVisible("block") | 
 |  |  |             setDisabled(true) | 
 |  |  |             setLocRevise(id) | 
 |  |  |             refresh() | 
 |  |  |         }, | 
 |  |  |     }; | 
 |  |  |  | 
 |  |  |     const handleChange = (value, name) => { | 
 |  |  |         setFormData((prevData) => ({ | 
 |  |  |             ...prevData, | 
 |  |  |             [name]: value | 
 |  |  |         })); | 
 |  |  |     }; | 
 |  |  |  | 
 |  |  |     return ( | 
 |  |  |         <> | 
 |  |  |             <Box sx={{ padding: 1 }}> | 
 |  |  |                 <Create resource="locRevise" | 
 |  |  |                 <Create | 
 |  |  |                     resource="locRevise" | 
 |  |  |                     title={false} | 
 |  |  |                     mutationOptions={mutationOptions} > | 
 |  |  |                     // mutationOptions={mutationOptions} | 
 |  |  |                      > | 
 |  |  |                     <SimpleForm toolbar={<FormToolbar />}> | 
 |  |  |                         <Grid container spacing={2} sx={{ | 
 |  |  |                             '& .MuiToolbar-root-RaToolbar-root.RaToolbar-defaultToolbar': { | 
 |  |  | 
 |  |  |                                 </Stack> | 
 |  |  |                             </Box> | 
 |  |  |                             <Box sx={{ mt: 2 }}> | 
 |  |  |                                 <TransferTableView | 
 |  |  |                                     tabelData={tabelData} | 
 |  |  |                                     setTableData={setTableData} | 
 |  |  |                                     orderId={orderId} | 
 |  |  |                                     selectedRows={selectedRows} | 
 |  |  |                                     setSelectedRows={setSelectedRows} | 
 |  |  |                                     tableRef={tableRef}> | 
 |  |  |                                 </TransferTableView> | 
 |  |  |                                 <List | 
 |  |  |                                     sx={{ | 
 |  |  |                                         flexGrow: 1, | 
 |  |  |                                         transition: (theme) => | 
 |  |  |                                             theme.transitions.create(['all'], { | 
 |  |  |                                                 duration: theme.transitions.duration.enteringScreen, | 
 |  |  |                                             }), | 
 |  |  |                                     }} | 
 |  |  |                                     resource="reviseLog" | 
 |  |  |                                     title={"menu.reviseLog"} | 
 |  |  |                                     empty={false} | 
 |  |  |                                     filters={false} | 
 |  |  |                                     sort={{ field: "create_time", order: "desc" }} | 
 |  |  |                                     actions={false} | 
 |  |  |                                     perPage={DEFAULT_PAGE_SIZE} | 
 |  |  |                                 > | 
 |  |  |                                     <StyledDatagrid | 
 |  |  |                                         preferenceKey='reviseLog' | 
 |  |  |                                         bulkActionButtons={false} | 
 |  |  |                                         rowClick={(id, resource, record) => false} | 
 |  |  |                                         expand={false} | 
 |  |  |                                         expandSingle={true} | 
 |  |  |                                         omit={['id', 'reviseId', 'createTime', 'createBy', 'memo']} | 
 |  |  |                                     > | 
 |  |  |                                         <NumberField source="id" /> | 
 |  |  |                                         <NumberField source="reviseId" label="table.field.reviseLog.reviseId" /> | 
 |  |  |                                         <TextField source="reviseCode" label="table.field.reviseLog.reviseCode" /> | 
 |  |  |                                         <NumberField source="warehouseId" label="table.field.loc.warehouseId" /> | 
 |  |  |                                         <NumberField source="areaId" label="table.field.loc.areaId" /> | 
 |  |  |                                         <NumberField source="type" label="table.field.loc.type" /> | 
 |  |  |                                         <TextField source="barcode" label="table.field.loc.barcode" /> | 
 |  |  |                                         <TextField source="useStatus" label="table.field.loc.useStatus" /> | 
 |  |  |                                         <NumberField source="channel" label="table.field.loc.channel" /> | 
 |  |  |                                         <NumberField source="row" label="table.field.loc.row" /> | 
 |  |  |                                         <NumberField source="col" label="table.field.loc.col" /> | 
 |  |  |                                         <NumberField source="lev" label="table.field.loc.lev" /> | 
 |  |  |                                         <TextField source="updateBy$" label="common.field.updateBy" /> | 
 |  |  |                                         <DateField source="updateTime" label="common.field.updateTime" showTime /> | 
 |  |  |                                         <TextField source="createBy$" label="common.field.createBy" /> | 
 |  |  |                                         <DateField source="createTime" label="common.field.createTime" showTime /> | 
 |  |  |                                         <BooleanField source="statusBool" label="common.field.status" sortable={false} /> | 
 |  |  |                                         <TextField source="memo" label="common.field.memo" sortable={false} /> | 
 |  |  |                                         <WrapperField cellClassName="opt" label="common.field.opt"> | 
 |  |  |                                             <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> | 
 |  |  |                                             <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> | 
 |  |  |                                         </WrapperField> | 
 |  |  |                                     </StyledDatagrid> | 
 |  |  |                                 </List> | 
 |  |  |                             </Box> | 
 |  |  |                         </Box> | 
 |  |  |                     </Card> | 
 |  |  | 
 |  |  |                 <SelectLocsRevise | 
 |  |  |                     data={tabelData} | 
 |  |  |                     queryForm={formData} | 
 |  |  |                     locRevise={locRevise} | 
 |  |  |                     open={createDialog} | 
 |  |  |                     setOpen={setCreateDialog} | 
 |  |  |                     selectedRows={selectedRows} | 
 |  |  | 
 |  |  |     const notify = useNotify(); | 
 |  |  |     const [columns, setColumns] = useState([ | 
 |  |  |         { | 
 |  |  |             field: 'maktx', | 
 |  |  |             headerName: translate('table.field.outStockItem.maktx'), | 
 |  |  |             width: 250, | 
 |  |  |             field: 'code', | 
 |  |  |             headerName: translate('table.field.locItem.locCode'), | 
 |  |  |             width: 100, | 
 |  |  |             editable: false, | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'matnrCode', | 
 |  |  |             headerName: translate('table.field.outStockItem.matnrCode'), | 
 |  |  |             field: 'areaId', | 
 |  |  |             headerName: translate('table.field.loc.areaId'), | 
 |  |  |             width: 130, | 
 |  |  |             editable: false, | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'anfme', | 
 |  |  |             headerName: translate('table.field.outStockItem.anfme'), | 
 |  |  |             field: 'type', | 
 |  |  |             headerName: translate('table.field.loc.type'), | 
 |  |  |             type: 'number', | 
 |  |  |             minWidth: 100, | 
 |  |  |             flex: 1, | 
 |  |  | 
 |  |  |             valueFormatter: (val) => val < 0 ? 0 : val, | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'splrCode', | 
 |  |  |             headerName: translate('table.field.outStockItem.splrCode'), | 
 |  |  |             field: 'warehouseId', | 
 |  |  |             headerName: translate('table.field.loc.warehouseId'), | 
 |  |  |             minWidth: 100, | 
 |  |  |             flex: 1, | 
 |  |  |             editable: true, | 
 |  |  | 
 |  |  |             ), | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'splrName', | 
 |  |  |             headerName: translate('table.field.outStockItem.splrName') + "*", | 
 |  |  |             field: 'useStatus', | 
 |  |  |             headerName: translate('table.field.loc.useStatus') + "*", | 
 |  |  |             minWidth: 100, | 
 |  |  |             flex: 1, | 
 |  |  |             editable: true, | 
 |  |  | 
 |  |  |             ), | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'batch', | 
 |  |  |             headerName: translate('table.field.outStockItem.splrBatch'), | 
 |  |  |             field: 'channel', | 
 |  |  |             headerName: translate('table.field.loc.channel'), | 
 |  |  |             minWidth: 100, | 
 |  |  |             flex: 1, | 
 |  |  |             editable: true, | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'stockUnit', | 
 |  |  |             headerName: translate('table.field.outStockItem.stockUnit'), | 
 |  |  |             field: 'row', | 
 |  |  |             headerName: translate('table.field.loc.row'), | 
 |  |  |             minWidth: 100, | 
 |  |  |             flex: 1, | 
 |  |  |             editable: true, | 
 |  |  |             editable: false, | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'col', | 
 |  |  |             headerName: translate('table.field.loc.col'), | 
 |  |  |             minWidth: 100, | 
 |  |  |             flex: 1, | 
 |  |  |             editable: false, | 
 |  |  |         }, | 
 |  |  |         { | 
 |  |  |             field: 'lev', | 
 |  |  |             headerName: translate('table.field.loc.lev'), | 
 |  |  |             minWidth: 100, | 
 |  |  |             flex: 1, | 
 |  |  |             editable: false, | 
 |  |  |         }, | 
 |  |  |     ]) | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  |     let cdata = useRef([]); | 
 |  |  |  | 
 |  |  |     useEffect(() => { | 
 |  |  |         if (extendColumns == undefined || extendColumns.length < 1) { | 
 |  |  |             getDynamicFields(); | 
 |  |  |         } | 
 |  |  |     }, []); | 
 |  |  |     // useEffect(() => { | 
 |  |  |     //     if (extendColumns == undefined || extendColumns.length < 1) { | 
 |  |  |     //         getDynamicFields(); | 
 |  |  |     //     } | 
 |  |  |     // }, []); | 
 |  |  |  | 
 |  |  |     useEffect(() => { | 
 |  |  |         cdata.current = tabelData | 
 |  |  |     }, [tabelData]); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     const getDynamicFields = async () => { | 
 |  |  |         const { | 
 |  |  |             data: { code, data, msg }, | 
 |  |  |         } = await request.get("/fields/enable/list"); | 
 |  |  |         if (code === 200) { | 
 |  |  |             const cols = data.map(el => ({ | 
 |  |  |                 field: el.fields, | 
 |  |  |                 headerName: el.fieldsAlise, | 
 |  |  |                 minWidth: 100, | 
 |  |  |                 flex: 1, | 
 |  |  |                 editable: false | 
 |  |  |             })) | 
 |  |  |             setColumns([...columns, ...cols, action]) | 
 |  |  |             setExtendColumns(cols); | 
 |  |  |         } else { | 
 |  |  |             notify(msg); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     // const getDynamicFields = async () => { | 
 |  |  |     //     const { | 
 |  |  |     //         data: { code, data, msg }, | 
 |  |  |     //     } = await request.get("/fields/enable/list"); | 
 |  |  |     //     if (code === 200) { | 
 |  |  |     //         const cols = data.map(el => ({ | 
 |  |  |     //             field: el.fields, | 
 |  |  |     //             headerName: el.fieldsAlise, | 
 |  |  |     //             minWidth: 100, | 
 |  |  |     //             flex: 1, | 
 |  |  |     //             editable: false | 
 |  |  |     //         })) | 
 |  |  |     //         setColumns([...columns, ...cols, action]) | 
 |  |  |     //         setExtendColumns(cols); | 
 |  |  |     //     } else { | 
 |  |  |     //         notify(msg); | 
 |  |  |     //     } | 
 |  |  |     // } | 
 |  |  |  | 
 |  |  |     const handleDelete = (row) => { | 
 |  |  |         const newData = _.filter(cdata.current, (item) => item.matnrId !== row.matnrId); | 
 |  |  |         setTableData(newData); | 
 |  |  |     }; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     const processRowUpdate = (newRow, oldRow) => { | 
 |  |  |         const rows = tabelData.map((r) => | 
 |  |  |             r.matnrId === newRow.matnrId ? { ...newRow } : r | 
 |  |  |         ) | 
 |  |  |         setTableData(rows) | 
 |  |  |         return newRow; | 
 |  |  |     }; | 
 |  |  |  | 
 |  |  |     const handleSelectionChange = (ids) => { | 
 |  |  | 
 |  |  |     }; | 
 |  |  |  | 
 |  |  |     tableRef.current = useGridApiRef(); | 
 |  |  |  | 
 |  |  |     const tableIds = tabelData.map(map => map.id); | 
 |  |  |     // setSelectedRows(tableIds); | 
 |  |  |     // // console.log(selectedRows); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     return ( | 
 |  |  |         <Box> |