| | |
| | | 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, |
| | |
| | | })); |
| | | |
| | | 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([]); |
| | |
| | | <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 /> |
| | | <CompleteButton /> |
| | | <PublicButton setDrawerVal={setDrawerVal} drawerVal={drawerVal} setSelect={setSelect} /> |
| | | </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} /> |
| | |
| | | ) |
| | | } |
| | | |
| | | /** 出库单执行状态: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) => { |