From b5e8045d5f5b5401b696db12f62fdbcc86dc5c5d Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期四, 10 四月 2025 11:40:02 +0800
Subject: [PATCH] Merge branch 'devlop' of http://47.97.1.152:5880/r/wms-master into devlop

---
 rsf-admin/src/page/asnOrder/AsnOrderList.jsx |  211 ++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 169 insertions(+), 42 deletions(-)

diff --git a/rsf-admin/src/page/asnOrder/AsnOrderList.jsx b/rsf-admin/src/page/asnOrder/AsnOrderList.jsx
index 8c1c2d1..561522a 100644
--- a/rsf-admin/src/page/asnOrder/AsnOrderList.jsx
+++ b/rsf-admin/src/page/asnOrder/AsnOrderList.jsx
@@ -15,6 +15,7 @@
   useRecordContext,
   useTranslate,
   useNotify,
+  useRefresh,
   useListContext,
   FunctionField,
   TextField,
@@ -40,6 +41,8 @@
 import EmptyData from "../components/EmptyData";
 import MyCreateButton from "../components/MyCreateButton";
 import MyExportButton from '../components/MyExportButton';
+import BillStatusField from '../components/BillStatusField';
+import ConfirmButton from '../components/ConfirmButton';
 import PageDrawer from "../components/PageDrawer";
 import MyField from "../components/MyField";
 import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
@@ -47,7 +50,10 @@
 import ConstructionIcon from "@mui/icons-material/Construction";
 import FileDownloadIcon from '@mui/icons-material/FileDownload';
 import EditIcon from '@mui/icons-material/Edit';
-
+import TaskIcon from '@mui/icons-material/Task';
+import CloseIcon from '@mui/icons-material/Close';
+import request from '@/utils/request';
+import DictionarySelect from "../components/DictionarySelect";
 
 const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
   '& .css-1vooibu-MuiSvgIcon-root': {
@@ -59,13 +65,15 @@
   '& .column-name': {
   },
   '& .opt': {
-    width: 200
+    width: 320
+  },
+  '& .status': {
+    width: 100
   },
 }));
 
 const filters = [
   <SearchInput source="condition" alwaysOn />,
-
   <TextInput source="code" label="table.field.asnOrder.code" />,
   <TextInput source="poCode" label="table.field.asnOrder.poCode" />,
   <NumberInput source="poId" label="table.field.asnOrder.poId" />,
@@ -83,15 +91,12 @@
   />,
 
   <TextInput label="common.field.memo" source="memo" />,
-  <SelectInput
-    label="common.field.status"
-    source="status"
-    choices={[
-      { id: '1', name: 'common.enums.statusTrue' },
-      { id: '0', name: 'common.enums.statusFalse' },
-    ]}
-    resettable
+  <DictionarySelect
+    label='common.field.status'
+    name="exceStatus"
+    dictTypeCode="sys_asn_exce_status"
   />,
+
 ]
 
 const AsnOrderList = () => {
@@ -99,15 +104,13 @@
 
   const [createDialog, setCreateDialog] = useState(false);
   const [drawerVal, setDrawerVal] = useState(false);
+  const [modalType, setmodalType] = useState(0);
+  const billReload = useRef();
 
   const navigate = useNavigate();
   const assign = (record) => {
     navigate(`/asnOrderItem?asnId=${record.id}`);
   };
-
-  const inspection = () => { };
-  const print = () => { };
-
 
   return (
     <Box display="flex">
@@ -121,17 +124,14 @@
           marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0,
         }}
         title={"menu.asnOrder"}
-        empty={<EmptyData onClick={() => { setCreateDialog(true) }} />}
+        empty={<EmptyData onClick={() => { setCreateDialog(true); setmodalType(0) }} />}
         filters={filters}
         sort={{ field: "create_time", order: "desc" }}
         actions={(
           <TopToolbar>
 
-            <Button onClick={inspection} label={"toolbar.inspection"}>
-              <ConstructionIcon />
-            </Button>
             <FilterButton />
-            <MyCreateButton onClick={() => { setCreateDialog(true) }} />
+            <MyCreateButton onClick={() => { setCreateDialog(true); setmodalType(0) }} />
             <SelectColumnsButton preferenceKey='asnOrder' />
 
             <MyExportButton />
@@ -141,25 +141,18 @@
       >
         <StyledDatagrid
           preferenceKey='asnOrder'
-          bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />}
-          rowClick={(id, resource, record) => false}
-          expand={() => <AsnOrderPanel />}
+          bulkActionButtons={<> <InspectionsButton /><BulkDeleteButton mutationMode={OPERATE_MODE} /></>}
+          rowClick={() => false}
+          expand={<AsnOrderPanel billReload={billReload} />}
           expandSingle={true}
-          omit={['id', 'createTime', 'createBy', 'memo']}
+          omit={['id', 'createTime', 'createBy', 'memo', 'poId']}
         >
           <NumberField source="id" />
-          <MyField
-            source="code"
-            label="table.field.asnOrder.code"
-            onClick={(event, record, val) => {
-              event.stopPropagation();
-              assign(record);
-            }}
-          />
+          <TextField source="code" label="table.field.asnOrder.code" />
           <TextField source="poCode" label="table.field.asnOrder.poCode" />
           <NumberField source="poId" label="table.field.asnOrder.poId" />
-          <TextField source="type" label="table.field.asnOrder.type" />
-          <TextField source="wkType" label="table.field.asnOrder.wkType" />
+          <TextField source="type$" label="table.field.asnOrder.type" />
+          <TextField source="wkType$" label="table.field.asnOrder.wkType" />
           <NumberField source="anfme" label="table.field.asnOrder.anfme" />
           <NumberField source="qty" label="table.field.asnOrder.qty" />
           <TextField source="logisNo" label="table.field.asnOrder.logisNo" />
@@ -174,28 +167,34 @@
             <TextField source="nickname" />
           </ReferenceField>
           <DateField source="createTime" label="common.field.createTime" showTime />
-          <BooleanField source="statusBool" label="common.field.status" sortable={false} />
+          <BillStatusField cellClassName="status" source="exceStatus" label="common.field.status" />
           <TextField source="memo" label="common.field.memo" sortable={false} />
-          <WrapperField cellClassName="opt" label="common.field.opt">
-            <Button label="toolbar.print" onClick={print}>
+          <WrapperField cellClassName="opt" label="common.field.opt" width={300} >
+            {/* <Button label="toolbar.print" onClick={print}>
               <FileDownloadIcon />
-            </Button>
+            </Button> */}
             {/* <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> */}
-            <Button
+            <MyButton setCreateDialog={setCreateDialog} setmodalType={setmodalType} />
+            {/* <Button
               color="primary"
               startIcon={<EditIcon />}
-              onClick={() => { setCreateDialog(true) }}
+              onClick={(event, record) => handleEditClick(record)}
               sx={{ ml: 1 }}
               label={'ra.action.edit'}
             >
-            </Button>
-            <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} />
+            </Button> */}
+            <InspectionButton />
+            <CompleteButton />
+            {/* <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> */}
+            <CloseButton />
           </WrapperField>
         </StyledDatagrid>
       </List>
       <AsnOrderModal
         open={createDialog}
         setOpen={setCreateDialog}
+        asnId={modalType}
+        billReload={billReload}
       />
       <PageDrawer
         title='AsnOrder Detail'
@@ -207,3 +206,131 @@
   )
 }
 export default AsnOrderList;
+
+const MyButton = ({ setCreateDialog, setmodalType }) => {
+  const record = useRecordContext();
+  const handleEditClick = () => {
+    const id = record.id;
+    setmodalType(id);
+    setCreateDialog(true);
+
+  };
+  return (
+    <Button
+      color="primary"
+      startIcon={<EditIcon />}
+      onClick={() => handleEditClick()}
+      sx={{ ml: 1 }}
+      label={'ra.action.edit'}
+    >
+    </Button>
+  )
+}
+
+const InspectionButton = () => {
+  const record = useRecordContext();
+  const notify = useNotify();
+  const refresh = useRefresh();
+  const inspection = () => {
+    requestInspect([record])
+  };
+
+  const requestInspect = async (rows) => {
+    const { data: { code, data, msg } } = await request.post(`/asnOrder/inspect`, rows);
+
+    if (code === 200) {
+      notify(msg);
+      refresh()
+    } else {
+      notify(msg);
+    }
+  }
+
+
+  return (
+    <Button onClick={inspection} label={"toolbar.inspection"}>
+      <ConstructionIcon />
+    </Button>
+  )
+}
+
+const InspectionsButton = () => {
+  const { selectedIds, onUnselectItems, data } = useListContext();
+  const notify = useNotify();
+  const refresh = useRefresh();
+  const inspection = () => {
+    if (selectedIds.length === 0) {
+      notify('璇烽�夋嫨閫氱煡鍗�');
+      return;
+    } else {
+      const rows = data.filter((item) => selectedIds.includes(item.id))
+      requestInspect(rows)
+    }
+  };
+
+  const requestInspect = async (rows) => {
+    const { data: { code, data, msg } } = await request.post(`/asnOrder/inspect`, rows);
+
+    if (code === 200) {
+      notify(msg);
+      refresh()
+    } else {
+      notify(msg);
+    }
+  }
+
+
+  return (
+    <Button onClick={inspection} label={"toolbar.inspection"}>
+      <ConstructionIcon />
+    </Button>
+  )
+}
+
+const CompleteButton = () => {
+  const record = useRecordContext();
+  const notify = useNotify();
+  const refresh = useRefresh();
+  const requestComplete = async () => {
+    const { data: { code, data, msg } } = await request.post(`/asnOrder/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="success">
+      <TaskIcon />
+    </Button> : <ConfirmButton label={"toolbar.complete"} color="success" data={'褰撳墠鏀惰揣鏁伴噺灏忎簬璁″垝鏁伴噺锛屾槸鍚︾‘璁ゅ畬鎴�'} startIcon={<TaskIcon />} onConfirm={requestComplete} />)
+
+  )
+
+
+}
+
+const CloseButton = () => {
+  const record = useRecordContext();
+  const notify = useNotify();
+  const refresh = useRefresh();
+  const requestClose = async () => {
+    const { data: { code, data, msg } } = await request.post(`/asnOrder/close/${record.id}`);
+
+    if (code === 200) {
+      notify(msg);
+      refresh()
+    } else {
+      notify(msg);
+    }
+  }
+
+  return (
+    (<Button onClick={requestClose} label={"toolbar.close"} color="error">
+      <CloseIcon />
+    </Button>)
+  )
+}

--
Gitblit v1.9.1