| | |
| | | import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; |
| | | import React, { useState, useRef, useEffect, useLayoutEffect, useMemo, useCallback } from "react"; |
| | | import { useLocation, useNavigate } from 'react-router-dom'; |
| | | import { useTabDialogState, getDialogStatePath } from '@/context/TabDialogStateContext'; |
| | | import { |
| | | List, |
| | | DatagridConfigurable, |
| | |
| | | import PublicIcon from '@mui/icons-material/Public'; |
| | | import SelectMatnrModal from "./SelectMatnrModal"; |
| | | import EditIcon from '@mui/icons-material/Edit'; |
| | | import TaskIcon from '@mui/icons-material/Task'; |
| | | import OutOrderPreview from "./OutOrderPreview"; |
| | | import AddIcon from '@mui/icons-material/Add'; |
| | | import OutStockPublic from "./OutStockPublic"; |
| | |
| | | }, |
| | | })); |
| | | |
| | | const filters = [ |
| | | <SearchInput source="condition" alwaysOn />, |
| | | <TextInput source="code" label="table.field.outStock.code" alwaysOn />, |
| | | <TextInput source="poCode" label="table.field.outStock.poCode" />, |
| | | <NumberInput source="poId" label="table.field.outStock.poId" />, |
| | | <ReferenceInput source="type" reference="dictData" filter={{ dictTypeCode: 'sys_order_type', group: '2' }} label="table.field.outStock.type" alwaysOn> |
| | | <AutocompleteInput label="table.field.outStock.type" optionValue="value" /> |
| | | </ReferenceInput>, |
| | | <ReferenceInput source="wkType" reference="dictData" filter={{ dictTypeCode: 'sys_business_type', group: '2' }} label="table.field.outStock.wkType" alwaysOn> |
| | | <AutocompleteInput label="table.field.outStock.wkType" optionValue="value" /> |
| | | </ReferenceInput>, |
| | | <NumberInput source="anfme" label="table.field.outStock.anfme" />, |
| | | <NumberInput source="qty" label="table.field.outStock.qty" />, |
| | | <TextInput source="logisNo" label="table.field.outStock.logisNo" />, |
| | | <DateInput source="arrTime" label="table.field.outStock.arrTime" />, |
| | | <SelectInput source="rleStatus" label="table.field.outStock.rleStatus" |
| | | choices={[ |
| | | { id: 0, name: ' 正常' }, |
| | | { id: 1, name: ' 已释放' }, |
| | | ]} |
| | | />, |
| | | |
| | | <TextInput label="common.field.memo" source="memo" />, |
| | | <DictionarySelect |
| | | label='table.field.outStock.exceStatus' |
| | | name="exceStatus" |
| | | dictTypeCode="sys_asn_exce_status" |
| | | alwaysOn |
| | | />, |
| | | ] |
| | | |
| | | const OutOrderList = (props) => { |
| | | const location = useLocation(); |
| | | const tabDialogState = useTabDialogState(); |
| | | |
| | | const dicts = JSON.parse(localStorage.getItem('sys_dicts'))?.filter(dict => (dict.dictTypeCode == 'sys_business_type')) || []; |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | const [createDialog, setCreateDialogInner] = useState(false); |
| | | const [manualDialog, setManualDialog] = useState(false); |
| | | |
| | | const pathKey = getDialogStatePath( |
| | | location.pathname === '/' && typeof window !== 'undefined' && window.location?.hash |
| | | ? (window.location.hash.replace(/^#/, '') || '/') |
| | | : location.pathname |
| | | ); |
| | | |
| | | const setCreateDialog = useCallback((open) => { |
| | | setCreateDialogInner(open); |
| | | if (tabDialogState) { |
| | | const current = tabDialogState.getDialogState(pathKey) || {}; |
| | | tabDialogState.setDialogState(pathKey, { ...current, createDialogOpen: open }); |
| | | } |
| | | }, [pathKey, tabDialogState]); |
| | | |
| | | const saveCreateDialogForm = useCallback((formData) => { |
| | | if (tabDialogState) { |
| | | const current = tabDialogState.getDialogState(pathKey) || {}; |
| | | tabDialogState.setDialogState(pathKey, { ...current, createDialogOpen: true, createDialogForm: formData }); |
| | | } |
| | | }, [pathKey, tabDialogState]); |
| | | |
| | | const savedCreateFormData = tabDialogState?.getDialogState(pathKey)?.createDialogForm; |
| | | |
| | | useLayoutEffect(() => { |
| | | if (tabDialogState) { |
| | | const saved = tabDialogState.getDialogState(pathKey); |
| | | if (saved?.createDialogOpen) { |
| | | setCreateDialogInner(true); |
| | | } |
| | | } |
| | | }, [pathKey, tabDialogState]); |
| | | const [drawerVal, setDrawerVal] = useState(false); |
| | | const [waveRule, setWaveRule] = useState(false); |
| | | const [selectIds, setSelectIds] = useState([]); |
| | |
| | | const [modalType, setmodalType] = useState(0); |
| | | const [select, setSelect] = useState(0); |
| | | const translate = useTranslate(); |
| | | |
| | | const filters = [ |
| | | <SearchInput source="condition" alwaysOn placeholder={translate('ra.action.search')} />, |
| | | <TextInput source="code" label="table.field.outStock.code" alwaysOn />, |
| | | <TextInput source="poCode" label="table.field.outStock.poCode" />, |
| | | <NumberInput source="poId" label="table.field.outStock.poId" />, |
| | | <ReferenceInput source="type" reference="dictData" filter={{ dictTypeCode: 'sys_order_type', group: '2' }} label="table.field.outStock.type" alwaysOn> |
| | | <AutocompleteInput label="table.field.outStock.type" optionValue="value" /> |
| | | </ReferenceInput>, |
| | | <ReferenceInput source="wkType" reference="dictData" filter={{ dictTypeCode: 'sys_business_type', group: '2' }} label="table.field.outStock.wkType" alwaysOn> |
| | | <AutocompleteInput label="table.field.outStock.wkType" optionValue="value" /> |
| | | </ReferenceInput>, |
| | | <NumberInput source="anfme" label="table.field.outStock.anfme" />, |
| | | <NumberInput source="qty" label="table.field.outStock.qty" />, |
| | | <TextInput source="logisNo" label="table.field.outStock.logisNo" />, |
| | | <DateInput source="arrTime" label="table.field.outStock.arrTime" />, |
| | | <SelectInput source="rleStatus" label="table.field.outStock.rleStatus" |
| | | choices={[ |
| | | { id: 0, name: ' 正常' }, |
| | | { id: 1, name: ' 已释放' }, |
| | | ]} |
| | | />, |
| | | |
| | | <TextInput label="common.field.memo" source="memo" />, |
| | | <DictionarySelect |
| | | label='table.field.outStock.exceStatus' |
| | | name="exceStatus" |
| | | dictTypeCode="sys_asn_exce_status" |
| | | alwaysOn |
| | | />, |
| | | ]; |
| | | const refresh = useRefresh(); |
| | | const notify = useNotify(); |
| | | const billReload = useRef(); |
| | |
| | | <BillStatusField cellClassName="status" source="exceStatus" label="table.field.outStock.exceStatus" /> |
| | | <TextField source="memo" label="common.field.memo" sortable={false} /> |
| | | <WrapperField cellClassName="opt" label="common.field.opt" > |
| | | <MyButton setCreateDialog={setManualDialog} setmodalType={setmodalType} /> |
| | | <EditButton label="toolbar.detail" icon={(<DetailsIcon />)}></EditButton> |
| | | <OutOrderRowActions |
| | | setCreateDialog={setManualDialog} |
| | | setmodalType={setmodalType} |
| | | setDrawerVal={setDrawerVal} |
| | | drawerVal={drawerVal} |
| | | setSelect={setSelect} |
| | | /> |
| | | <CancelButton /> |
| | | <PublicButton setDrawerVal={setDrawerVal} drawerVal={drawerVal} setSelect={setSelect} /> |
| | | <CompleteButton /> |
| | | </WrapperField> |
| | | </StyledDatagrid> |
| | | </List> |
| | |
| | | setOpen={setCreateDialog} |
| | | preview={preview} |
| | | setPreview={setPreview} |
| | | initialFormData={savedCreateFormData} |
| | | saveFormData={saveCreateDialogForm} |
| | | /> |
| | | <OutStockWaveDialog open={waveRule} setOpen={setWaveRule} onClose={closeDialog} /> |
| | | <OutOrderPreview open={preview} setOpen={setPreview} /> |
| | |
| | | ); |
| | | } |
| | | |
| | | //完成单据 |
| | | const CompleteButton = () => { |
| | | const record = useRecordContext(); |
| | | const notify = useNotify(); |
| | | const refresh = useRefresh(); |
| | | const requestComplete = async () => { |
| | | const { data: { code, data, msg } } = await request.get(`/outStock/complete/${record.id}`); |
| | | if (code === 200) { |
| | | notify(msg); |
| | | refresh() |
| | | } else { |
| | | notify(msg); |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | // record.exceStatus === 1 && (record.anfme === record.qty ? <Button onClick={requestComplete} label={"toolbar.complete"} color="secondary"> |
| | | // <TaskIcon /> |
| | | // </Button> : ) |
| | | record.exceStatus != 15 ? <ConfirmButton label={"toolbar.complete"} color="secondary" startIcon={<TaskIcon />} onConfirm={requestComplete} /> : <></> |
| | | ) |
| | | } |
| | | |
| | | /** 出库单执行状态:10=初始化(仅此状态显示编辑/详情) */ |
| | | const OUT_STOCK_EXCE_STATUS_INIT = 10; |
| | | |
| | | const OutOrderRowActions = ({ setCreateDialog, setmodalType, setDrawerVal, drawerVal, setSelect }) => { |
| | | const record = useRecordContext(); |
| | | const isInit = record?.exceStatus === OUT_STOCK_EXCE_STATUS_INIT || record?.exceStatus === '10'; |
| | | return ( |
| | | <> |
| | | {isInit && ( |
| | | <> |
| | | <MyButton setCreateDialog={setCreateDialog} setmodalType={setmodalType} /> |
| | | <EditButton label="toolbar.detail" icon={(<DetailsIcon />)} /> |
| | | </> |
| | | )} |
| | | <PublicButton setDrawerVal={setDrawerVal} drawerVal={drawerVal} setSelect={setSelect} /> |
| | | </> |
| | | ); |
| | | }; |
| | | |
| | | const MyButton = ({ setCreateDialog, setmodalType }) => { |
| | | const record = useRecordContext(); |
| | | const handleEditClick = (btn) => { |