|  |  |  | 
|---|
|  |  |  | import { | 
|---|
|  |  |  | List, | 
|---|
|  |  |  | DatagridConfigurable, | 
|---|
|  |  |  | SearchInput, | 
|---|
|  |  |  | TopToolbar, | 
|---|
|  |  |  | Button, | 
|---|
|  |  |  | SelectColumnsButton, | 
|---|
|  |  |  | EditButton, | 
|---|
|  |  |  | FilterButton, | 
|---|
|  |  |  | CreateButton, | 
|---|
|  |  |  | ExportButton, | 
|---|
|  |  |  | BulkDeleteButton, | 
|---|
|  |  |  | WrapperField, | 
|---|
|  |  |  | useRecordContext, | 
|---|
|  |  |  | useTranslate, | 
|---|
|  |  |  | useNotify, | 
|---|
|  |  |  | useListContext, | 
|---|
|  |  |  | FunctionField, | 
|---|
|  |  |  | TextField, | 
|---|
|  |  |  | NumberField, | 
|---|
|  |  |  | DateField, | 
|---|
|  |  |  | BooleanField, | 
|---|
|  |  |  | ReferenceField, | 
|---|
|  |  |  | TextInput, | 
|---|
|  |  |  | DateTimeInput, | 
|---|
|  |  |  | DateInput, | 
|---|
|  |  |  | SelectInput, | 
|---|
|  |  |  | NumberInput, | 
|---|
|  |  |  | ReferenceInput, | 
|---|
|  |  |  | ReferenceArrayInput, | 
|---|
|  |  |  | AutocompleteInput, | 
|---|
|  |  |  | DeleteButton, | 
|---|
|  |  |  | SimpleForm, | 
|---|
|  |  |  | required, | 
|---|
|  |  |  | Form, | 
|---|
|  |  |  | useRefresh, | 
|---|
|  |  |  | 
|---|
|  |  |  | import CloseSharpIcon from '@mui/icons-material/CloseSharp'; | 
|---|
|  |  |  | import ConfirmButton from '../../components/ConfirmButton'; | 
|---|
|  |  |  | import { Delete, Edit, Add } from '@mui/icons-material'; | 
|---|
|  |  |  | import OutStockSiteDialog from "./OutStockSiteDialog"; | 
|---|
|  |  |  | import CheckOrderSiteDialog from "./CheckOrderSiteDialog"; | 
|---|
|  |  |  | import { map } from "lodash"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|---|
|  |  |  | '& .css-1vooibu-MuiSvgIcon-root': { | 
|---|
|  |  |  | 
|---|
|  |  |  | setRows(fetchRows) | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | const mas = fetchRows.filter(item => selectedMatnr.includes(item.matnrCode)); | 
|---|
|  |  |  | setRows(mas) | 
|---|
|  |  |  | let ids = mas.map(item => item.matnrCode); | 
|---|
|  |  |  | getLocs(ids) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, [selectedMatnr]) | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const getLocs = async (ids) => { | 
|---|
|  |  |  | const { data: { code, data, msg } } = await request.post('/check/locs/' + ids); | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | console.log('----->'); | 
|---|
|  |  |  | console.log(data); | 
|---|
|  |  |  | setRows(data) | 
|---|
|  |  |  | const matnrs = selectedMatnr.filter(item => data.some(bigData => bigData.matnrCode === item)); | 
|---|
|  |  |  | // setSelectedMatnr(matnrs) | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | notify(msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const ComfirmButton = () => { | 
|---|
|  |  |  | const { selectedIds, data } = useListContext(); | 
|---|
|  |  |  | const { selectedIds, data, onUnselectItems } = useListContext(); | 
|---|
|  |  |  | const handleRowClick = () => { | 
|---|
|  |  |  | const ids = data.filter(item => selectedIds.includes(item.id)).map(item => item.id); | 
|---|
|  |  |  | const ids = data.filter(item => selectedIds.includes(item.id)); | 
|---|
|  |  |  | setRowSelectedIds(ids); | 
|---|
|  |  |  | const mas = data.filter(item => selectedIds.includes(item.id)).map(item => item.matnrCode); | 
|---|
|  |  |  | //设置库位信息筛选条件 | 
|---|
|  |  |  | setSelectedMatnr(mas); | 
|---|
|  |  |  | onUnselectItems() | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Button label="toolbar.confirm" size="medium" onClick={handleRowClick} /> | 
|---|
|  |  |  | record.exceStatus != 3 ? <><Button label="toolbar.confirm" size="medium" onClick={handleRowClick} /></> : <></> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | if (formData.waveId == null && formData.waveId == undefined) { | 
|---|
|  |  |  | return | 
|---|
|  |  |  | } | 
|---|
|  |  |  | const { data: { code, data, msg } } = await request.post('/outStock/order/getOutTaskItems', { ...formData }); | 
|---|
|  |  |  | const { data: { code, data, msg } } = await request.post('/check/order/items', { ...formData }); | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | // setRows(data) | 
|---|
|  |  |  | setFetchRows(data) | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | notify(msg); | 
|---|
|  |  |  | 
|---|
|  |  |  | </ReferenceInput> | 
|---|
|  |  |  | </Form> | 
|---|
|  |  |  | <List | 
|---|
|  |  |  | resource="outStockItem" | 
|---|
|  |  |  | storeKey='outStockItem' | 
|---|
|  |  |  | resource="checkItem" | 
|---|
|  |  |  | storeKey='checkItem' | 
|---|
|  |  |  | sx={{ | 
|---|
|  |  |  | flexGrow: 1, | 
|---|
|  |  |  | transition: (theme) => | 
|---|
|  |  |  | 
|---|
|  |  |  | duration: theme.transitions.duration.enteringScreen, | 
|---|
|  |  |  | }), | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | title={"menu.outStockItem"} | 
|---|
|  |  |  | title={"menu.checkItem"} | 
|---|
|  |  |  | empty={false} | 
|---|
|  |  |  | filter={{ asnId: record?.id, deleted: 0 }} | 
|---|
|  |  |  | filter={{ orderId: record?.id, deleted: 0 }} | 
|---|
|  |  |  | sort={{ field: "create_time", order: "desc" }} | 
|---|
|  |  |  | actions={false} | 
|---|
|  |  |  | pagination={false} | 
|---|
|  |  |  | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <StyledDatagrid | 
|---|
|  |  |  | storeKey={"outStockPublic"} | 
|---|
|  |  |  | preferenceKey='outStockItem' | 
|---|
|  |  |  | preferenceKey='checkItem' | 
|---|
|  |  |  | bulkActionButtons={<> | 
|---|
|  |  |  | <ComfirmButton /> | 
|---|
|  |  |  | </>} | 
|---|
|  |  |  | omit={['id', 'splrName', 'qty', 'poCode',]} | 
|---|
|  |  |  | omit={['id', 'splrName', 'qty',]} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <NumberField source="id" /> | 
|---|
|  |  |  | <TextField source="asnCode" label="table.field.outStockItem.asnCode" /> | 
|---|
|  |  |  | <TextField source="poCode" label="table.field.outStockItem.poCode" /> | 
|---|
|  |  |  | <TextField source="matnrCode" label="table.field.outStockItem.matnrCode" /> | 
|---|
|  |  |  | <TextField source="maktx" label="table.field.outStockItem.maktx" /> | 
|---|
|  |  |  | <NumberField source="anfme" label="table.field.outStockItem.anfme" /> | 
|---|
|  |  |  | <NumberField source="workQty" label="table.field.outStockItem.workQty" /> | 
|---|
|  |  |  | <NumberField source="qty" label="table.field.outStockItem.qty" /> | 
|---|
|  |  |  | <TextField source="stockUnit" label="table.field.outStockItem.stockUnit" /> | 
|---|
|  |  |  | <TextField source="splrName" label="table.field.outStockItem.splrName" /> | 
|---|
|  |  |  | <TextField source="orderCode" label="table.field.checkOrderItem.orderCode" /> | 
|---|
|  |  |  | <TextField source="matnrCode" label="table.field.checkOrderItem.matnrCode" /> | 
|---|
|  |  |  | <TextField source="maktx" label="table.field.checkOrderItem.maktx" /> | 
|---|
|  |  |  | <NumberField source="anfme" label="table.field.checkOrderItem.anfme" /> | 
|---|
|  |  |  | <NumberField source="workQty" label="table.field.checkOrderItem.workQty" /> | 
|---|
|  |  |  | <NumberField source="qty" label="table.field.checkOrderItem.qty" /> | 
|---|
|  |  |  | <TextField source="stockUnit" label="table.field.checkOrderItem.stockUnit" /> | 
|---|
|  |  |  | <TextField source="splrName" label="table.field.checkOrderItem.splrName" /> | 
|---|
|  |  |  | </StyledDatagrid> | 
|---|
|  |  |  | </List> | 
|---|
|  |  |  | </Card> | 
|---|
|  |  |  | 
|---|
|  |  |  | </Box> | 
|---|
|  |  |  | <Box sx={{ textAlign: 'center' }}> | 
|---|
|  |  |  | <CloseButton setOpen={setOpen} /> | 
|---|
|  |  |  | <SubmitButton selectedIds={selectedIds} setSelectedIds={setSelectedIds} gridRef={gridRef} record={record} /> | 
|---|
|  |  |  | <SubmitButton selectedIds={selectedIds} setOpen={setOpen} setSelectedIds={setSelectedIds} selectedMatnr={selectedMatnr} rowSelectedIds={rowSelectedIds} gridRef={gridRef} record={record} /> | 
|---|
|  |  |  | </Box> | 
|---|
|  |  |  | </Card> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | <Grid> | 
|---|
|  |  |  | <OutStockSiteDialog | 
|---|
|  |  |  | <CheckOrderSiteDialog | 
|---|
|  |  |  | selectedValue={selectedValue} | 
|---|
|  |  |  | open={dialog} | 
|---|
|  |  |  | onClose={handleClose} | 
|---|
|  |  |  | 
|---|
|  |  |  | }, [selectedIds]) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const baseColumns = [ | 
|---|
|  |  |  | // { field: 'id', headerName: 'ID', width: 40 }, | 
|---|
|  |  |  | { field: 'locCode', headerName: '库位', width: 110 }, | 
|---|
|  |  |  | { field: 'barcode', headerName: '容器', width: 120 }, | 
|---|
|  |  |  | { field: 'matnrCode', headerName: '物料编码', width: 120 }, | 
|---|
|  |  |  | { field: 'batch', headerName: '批次', width: 90 }, | 
|---|
|  |  |  | { field: 'unit', headerName: '单位', width: 60 }, | 
|---|
|  |  |  | { field: 'outQty', headerName: '出库数量', width: 110, }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | field: 'anfme', headerName: '库存数量', width: 110, | 
|---|
|  |  |  | renderCell: (params) => ( | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //提交按钮 | 
|---|
|  |  |  | const SubmitButton = ({ selectedIds, setSelectedIds, gridRef, record }) => { | 
|---|
|  |  |  | const SubmitButton = ({ selectedIds, setSelectedIds, rowSelectedIds, gridRef, record, setOpen, selectedMatnr }) => { | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  | const translate = useTranslate(); | 
|---|
|  |  |  | const redirect = useRedirect(); | 
|---|
|  |  |  | const submit = async () => { | 
|---|
|  |  |  | const items = gridRef.current?.getSortedRows(); | 
|---|
|  |  |  | const { data: { code, data, msg } } = await request.post('/outStock/generate/tasks', { items, outId: record?.id }); | 
|---|
|  |  |  | let selctRecord = items.filter(item => selectedIds.includes(item?.id)); | 
|---|
|  |  |  | if (selctRecord == undefined || selctRecord.length < 1) { | 
|---|
|  |  |  | notify(translate('common.msg.locEmpty'), { type: 'error' }); | 
|---|
|  |  |  | return | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //过滤,将库位添加至盘点单明细中 | 
|---|
|  |  |  | const records = rowSelectedIds.map(map => { | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | ...map, | 
|---|
|  |  |  | items: selctRecord.filter(item => item.matnrCode == map.matnrCode) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | let params = records.filter(record => record?.items.length > 0); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const { data: { code, data, msg } } = await request.post('/check/generate/tasks', params); | 
|---|
|  |  |  | if (code == 200) { | 
|---|
|  |  |  | refresh(); | 
|---|
|  |  |  | redirect("/task") | 
|---|
|  |  |  | setOpen(false) | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | notify(msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <ConfirmButton | 
|---|
|  |  |  | label="toolbar.allComfirm" | 
|---|
|  |  |  | label="toolbar.confirmSelect" | 
|---|
|  |  |  | variant="contained" | 
|---|
|  |  |  | size="medium" | 
|---|
|  |  |  | onConfirm={submit} | 
|---|