From c55a86895cabc3e91c2e7aa4eab099a7287e0ae6 Mon Sep 17 00:00:00 2001
From: cl <1442464845@qq.com>
Date: 星期二, 21 四月 2026 14:54:16 +0800
Subject: [PATCH] 站点优化

---
 rsf-admin/src/page/orders/outStock/OutOrderList.jsx |   84 +++++++++++++++++++++++++++++++++++------
 1 files changed, 71 insertions(+), 13 deletions(-)

diff --git a/rsf-admin/src/page/orders/outStock/OutOrderList.jsx b/rsf-admin/src/page/orders/outStock/OutOrderList.jsx
index 8934fe5..26f90e3 100644
--- a/rsf-admin/src/page/orders/outStock/OutOrderList.jsx
+++ b/rsf-admin/src/page/orders/outStock/OutOrderList.jsx
@@ -1,5 +1,6 @@
-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,
@@ -48,7 +49,7 @@
 import MyCreateButton from "../../components/MyCreateButton";
 import PageEditDrawer from "../../components/PageEditDrawer";
 import ConfirmButton from '../../components/ConfirmButton';
-import ImportButton from "../../components/ImportButton";
+// import ImportButton from "../../components/ImportButton";
 import DetailsIcon from '@mui/icons-material/Details';
 import OutStockWaveDialog from "./OutStockWaveDialog";
 import AddTaskIcon from '@mui/icons-material/AddTask';
@@ -83,10 +84,44 @@
 }));
 
 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([]);
@@ -160,10 +195,10 @@
         actions={(
           <TopToolbar>
             <FilterButton />
-            <CreateByOrderButton setCreateDialog={setCreateDialog} />
+            {/* <CreateByOrderButton setCreateDialog={setCreateDialog} /> 閫氳繃鍗曟嵁鍒涘缓鏆備笉浣跨敤 */}
             <MyCreateButton onClick={() => { setManualDialog(true); setmodalType(0) }} />
             <SelectColumnsButton preferenceKey='outStock' />
-            <ImportButton value={'outStockItem'} />
+            {/* <ImportButton value={'outStockItem'} /> 瀵煎叆鎸夐挳鎸夐渶姹傞殣钘� */}
           </TopToolbar>
         )}
         perPage={DEFAULT_PAGE_SIZE}
@@ -181,9 +216,9 @@
           <TextField source="poCode" label="table.field.outStock.poCode" />
           <TextField source="type$" label="table.field.outStock.type" />
           <TextField cellClassName="wkType" source="wkType$" label="table.field.outStock.wkType" />
-          <NumberField source="anfme" label="table.field.outStock.anfme" />
-          <NumberField source="workQty" label="table.field.outStock.workQty" />
-          <NumberField source="qty" label="table.field.outStock.qty" />
+          <NumberField source="anfme" label="table.field.outStock.anfme" options={{ minimumFractionDigits: 2, maximumFractionDigits: 2 }} />
+          <NumberField source="workQty" label="table.field.outStock.workQty" options={{ minimumFractionDigits: 2, maximumFractionDigits: 2 }} />
+          <NumberField source="qty" label="table.field.outStock.qty" options={{ minimumFractionDigits: 2, maximumFractionDigits: 2 }} />
           <TextField source="logisNo" label="table.field.outStock.logisNo" />
           <TextField source="rleStatus$" label="table.field.outStock.rleStatus" sortable={false} />
           <TextField source="updateBy$" label="common.field.updateBy" />
@@ -193,11 +228,15 @@
           <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>
@@ -216,6 +255,8 @@
         setOpen={setCreateDialog}
         preview={preview}
         setPreview={setPreview}
+        initialFormData={savedCreateFormData}
+        saveFormData={saveCreateDialogForm}
       />
       <OutStockWaveDialog open={waveRule} setOpen={setWaveRule} onClose={closeDialog} />
       <OutOrderPreview open={preview} setOpen={setPreview} />
@@ -276,6 +317,21 @@
   )
 }
 
+/** 鍑哄簱鍗曟墽琛岀姸鎬侊細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) => {
@@ -329,7 +385,7 @@
   )
 }
 
-//涓嬪彂鎵ц
+//涓嬪彂鎵ц锛堝凡瀹屾垚 exceStatus=15 涓嶆樉绀猴級
 const PublicButton = ({ setDrawerVal, setSelect }) => {
   const record = useRecordContext();
   const refresh = useRefresh();
@@ -339,7 +395,9 @@
     refresh();
   }
 
+  const canDispatch = record?.exceStatus != 15 && Number(record?.workQty) < Number(record?.anfme);
+
   return (
-    record.workQty < record.anfme ? <Button label={"toolbar.publicWorking"} startIcon={<AddTaskIcon />} onClick={taskEvent} size={"small"} /> : <></>
+    canDispatch ? <Button label={"toolbar.publicWorking"} startIcon={<AddTaskIcon />} onClick={taskEvent} size={"small"} /> : <></>
   )
 }

--
Gitblit v1.9.1