From ca23f2be97249ab82494983ee34636dcc28c8a19 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期三, 02 四月 2025 10:13:52 +0800
Subject: [PATCH] 报检提示优化

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

diff --git a/rsf-admin/src/page/asnOrder/AsnOrderList.jsx b/rsf-admin/src/page/asnOrder/AsnOrderList.jsx
index 095bde5..f0a45e4 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,
@@ -47,7 +48,7 @@
 import ConstructionIcon from "@mui/icons-material/Construction";
 import FileDownloadIcon from '@mui/icons-material/FileDownload';
 import EditIcon from '@mui/icons-material/Edit';
-
+import request from '@/utils/request';
 
 
 const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
@@ -107,36 +108,6 @@
     navigate(`/asnOrderItem?asnId=${record.id}`);
   };
 
-
-  const inspection = () => { };
-
-  const print = () => {
-    const imageUrls = ['https://www.baidu.com/img/flexible/logo/pc/result@2.png',]
-    const iframe = document.createElement('iframe');
-    iframe.style.display = 'none';
-    document.body.appendChild(iframe);
-
-    const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
-    iframeDoc.open();
-    iframeDoc.write('<html><head><title>Print Images</title></head><body>');
-
-    // 灏嗗浘鐗囨彃鍏ュ埌 iframe 涓�
-    imageUrls.forEach((imageUrl) => {
-      iframeDoc.write(`<img src="${imageUrl}" style="margin: 10px;">`);
-    });
-
-    iframeDoc.write('</body></html>');
-    iframeDoc.close();
-
-    // 绛夊緟鍥剧墖鍔犺浇瀹屾垚鍚庤Е鍙戞墦鍗�
-    iframe.contentWindow.onload = () => {
-      iframe.contentWindow.print();
-      // 鎵撳嵃瀹屾垚鍚庣Щ闄� iframe
-      document.body.removeChild(iframe);
-    };
-  };
-
-
   return (
     <Box display="flex">
       <List
@@ -155,9 +126,6 @@
         actions={(
           <TopToolbar>
 
-            <Button onClick={inspection} label={"toolbar.inspection"}>
-              <ConstructionIcon />
-            </Button>
             <FilterButton />
             <MyCreateButton onClick={() => { setCreateDialog(true); setmodalType(0) }} />
             <SelectColumnsButton preferenceKey='asnOrder' />
@@ -169,18 +137,18 @@
       >
         <StyledDatagrid
           preferenceKey='asnOrder'
-          bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />}
-          rowClick={(id, resource, record) => false}
-          expand={(e) => <AsnOrderPanel key={Math.floor(Math.random() * 100)} />}
+          bulkActionButtons={<> <InspectionsButton /><BulkDeleteButton mutationMode={OPERATE_MODE} /></>}
+          rowClick={() => false}
+          expand={<AsnOrderPanel />}
           expandSingle={true}
-          omit={['id', 'createTime', 'createBy', 'memo']}
+          omit={['id', 'createTime', 'createBy', 'memo', 'poId']}
         >
           <NumberField source="id" />
           <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" />
@@ -198,9 +166,9 @@
           <BooleanField source="statusBool" label="common.field.status" sortable={false} />
           <TextField source="memo" label="common.field.memo" sortable={false} />
           <WrapperField cellClassName="opt" label="common.field.opt" >
-            <Button label="toolbar.print" onClick={print}>
+            {/* <Button label="toolbar.print" onClick={print}>
               <FileDownloadIcon />
-            </Button>
+            </Button> */}
             {/* <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> */}
             <MyButton setCreateDialog={setCreateDialog} setmodalType={setmodalType} />
             {/* <Button
@@ -211,6 +179,7 @@
               label={'ra.action.edit'}
             >
             </Button> */}
+            <InspectionButton />
             <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} />
           </WrapperField>
         </StyledDatagrid>
@@ -250,3 +219,63 @@
     </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>
+  )
+}

--
Gitblit v1.9.1