From 1e42773a05285543be5f18b352a8b5884c02273c Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期三, 11 六月 2025 17:16:14 +0800
Subject: [PATCH] 库口修改问题修复 下发执行单据明细添加多选显示功能 库存信息删除按钮显示问题修复 库存信息删除分页信息

---
 rsf-admin/src/page/orders/outStock/OutStockPublic.jsx |  178 ++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 134 insertions(+), 44 deletions(-)

diff --git a/rsf-admin/src/page/orders/outStock/OutStockPublic.jsx b/rsf-admin/src/page/orders/outStock/OutStockPublic.jsx
index b3570fe..e63b5a2 100644
--- a/rsf-admin/src/page/orders/outStock/OutStockPublic.jsx
+++ b/rsf-admin/src/page/orders/outStock/OutStockPublic.jsx
@@ -1,4 +1,4 @@
-import { Box, Card, Grid, LinearProgress, Select, MenuItem, ListItemText, Tooltip, IconButton } from "@mui/material";
+import { Box, Card, Grid, LinearProgress, Select, MenuItem, ListItemText } from "@mui/material";
 import React, { useState, useRef, useEffect, useMemo } from "react";
 import {
     List,
@@ -38,7 +38,7 @@
     useRefresh,
     useRedirect,
 } from 'react-admin';
-import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE, DEFAULT_ITEM_PAGE_SIZE } from '@/config/setting';
+import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE, DEFAULT_ITEM_PAGE_SIZE, DEFAULT_TYPE } from '@/config/setting';
 import { styled } from '@mui/material/styles';
 import { DataGrid, useGridApiContext, GridActionsCellItem, useGridApiRef } from '@mui/x-data-grid';
 import request from '@/utils/request';
@@ -46,6 +46,7 @@
 import CloseSharpIcon from '@mui/icons-material/CloseSharp';
 import ConfirmButton from '../../components/ConfirmButton';
 import { Delete, Edit, Add } from '@mui/icons-material';
+import OutStockSiteDialog from "./OutStockSiteDialog";
 
 const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
     '& .css-1vooibu-MuiSvgIcon-root': {
@@ -56,30 +57,54 @@
     },
     '& .column-maktx': {
         width: 200
+    },
+    '& .RaBulkActionsToolbar-toolbar': {
+        display: 'none'
     }
-}));
 
+}));
 
 const OutStockPublic = (props) => {
     const { record, open, setOpen } = props;
     const notify = useNotify();
     const gridRef = useGridApiRef();
-    const [rows, setRows] = useState({});
+    const [rows, setRows] = useState([]);
     const translate = useTranslate();
-    const [selectedIds, setSelectedIds] = React.useState([]);
+    const [selectedIds, setSelectedIds] = useState([]);
     const [formData, setFormData] = useState({
-        orderId: record?.id
+        orderId: record?.id,
+        waveId: DEFAULT_TYPE
     });
+    const [dialog, setDialog] = useState(false);
+    const [selectedValue, setSelectedValue] = useState({});
+
+    const handleClickOpen = () => {
+        setDialog(true);
+    };
+
+    const handleClose = (value) => {
+        setDialog(false);
+        setSelectedValue(value);
+        const newRows = rows.map(item => {
+            return selectedIds.includes(item?.id) ? {
+                ...item,
+                siteNo: value?.site
+            } : item
+        })
+        setRows(newRows);
+    };
+
     useEffect(() => {
-        getWaveRule()
-    }, [formData, open])
+        if (open) {
+            getWaveRule()
+        }
+    }, [open, formData])
 
     const getWaveRule = async () => {
         if (formData.waveId == null && formData.waveId == undefined) {
             return
         }
         const { data: { code, data, msg } } = await request.post('/outStock/order/getOutTaskItems', { ...formData });
-
         if (code === 200) {
             setRows(data)
         } else {
@@ -109,6 +134,7 @@
                                     <AutocompleteInput
                                         label="table.field.waveRule.type"
                                         onChange={(e) => handleChange(e, 'waveId')}
+                                        defaultValue={15}
                                         value={formData.type}
                                         validate={required()}
                                     />
@@ -136,7 +162,7 @@
                                 />
                                 <StyledDatagrid
                                     preferenceKey='outStockItem'
-                                    bulkActionButtons={false}
+                                    bulkActionButtons={<></>}
                                     rowClick={false}
                                     omit={['id', 'splrName', 'qty', 'poCode', 'workQty']}
                                 >
@@ -157,30 +183,61 @@
                     <Grid item xl={6.3} gap={2}>
                         <Card>
                             <Box sx={{ height: 500, width: '100%' }}>
-                                <PreviewTable rows={rows} gridRef={gridRef} setRows={setRows} record={record}/>
+                                <PreviewTable
+                                    rows={rows}
+                                    gridRef={gridRef}
+                                    setRows={setRows}
+                                    record={record}
+                                    formData={formData}
+                                    selectedIds={selectedIds}
+                                    setDialog={setDialog}
+                                    setSelectedIds={setSelectedIds}
+                                />
                             </Box>
                             <Box sx={{ textAlign: 'center' }}>
                                 <CloseButton setOpen={setOpen} />
-                                <SubmitButton selectedIds={selectedIds} setSelectedIds={setSelectedIds} gridRef={gridRef} record={record}/>
+                                <SubmitButton selectedIds={selectedIds} setSelectedIds={setSelectedIds} gridRef={gridRef} record={record} />
                             </Box>
                         </Card>
                     </Grid>
+                </Grid>
+                <Grid>
+                    <OutStockSiteDialog
+                        selectedValue={selectedValue}
+                        open={dialog}
+                        onClose={handleClose}
+                    />
                 </Grid>
             </Box>
         </>
     );
 }
 
-const PreviewTable = ({ rows, gridRef, setRows, record }) => {
+const PreviewTable = ({ rows, gridRef, setRows, record, selectedIds, setSelectedIds, setDialog, formData }) => {
     gridRef.current = useGridApiRef();
+    const translate = useTranslate();
 
-    const columns = [
-        { field: 'id', headerName: 'ID', width: 40 },
+    useEffect(() => {
+        if (selectedIds.length > 0) {
+            console.log(selectedIds);
+        }
+    }, [selectedIds])
+
+
+    const baseColumns = [
+        // { field: 'id', headerName: 'ID', width: 40 },
         { field: 'locCode', headerName: '搴撲綅', width: 110 },
         { field: 'barcode', headerName: '瀹瑰櫒', width: 120 },
+        { field: 'matnrCode', headerName: '鐗╂枡缂栫爜', width: 120 },
         { field: 'batch', headerName: '鎵规', width: 90 },
-        { field: 'unit', headerName: '鍗曚綅', width: 90 },
-        { field: 'outQty', headerName: '鏈鍑哄簱鏁伴噺', width: 110 },
+        { field: 'unit', headerName: '鍗曚綅', width: 60 },
+        { field: 'outQty', headerName: '鍑哄簱鏁伴噺', width: 110, },
+        {
+            field: 'anfme', headerName: '搴撳瓨鏁伴噺', width: 110,
+            renderCell: (params) => (
+                <OutStockAnfme value={params.value} />
+            )
+        },
         {
             field: 'siteNo',
             headerName: '鍑哄簱鍙�',
@@ -194,31 +251,48 @@
                 <OutStockSite {...params} />
             ),
         },
-        {
-            field: 'actions',
-            type: 'actions',
-            headerName: '鎿嶄綔',
-            with: 120,
-            getActions: (params) => [
-                <GridActionsCellItem
-                    icon={<Delete />}
-                    label="Delete"
-                    onClick={() => handleDelete(params.row, rows, setRows)}
-                />,
-            ]
-        },
     ]
+
+    const optAction = {
+        field: 'actions',
+        type: 'actions',
+        headerName: translate('common.field.opt'),
+        with: 120,
+        getActions: (params) => [
+            <GridActionsCellItem
+                icon={<Delete />}
+                label="Delete"
+                onClick={() => handleDelete(params.row, rows, setRows)}
+            />,
+        ]
+    }
+
+    const columns = (formData.waveId == 15 || formData.waveId == 16) ? [...baseColumns] : [...baseColumns, optAction];
 
     /**
      * 鍒犻櫎浜嬩欢
      * @param {*} params 
      */
     const handleDelete = (params, rows, setRows) => {
-        const outRows = rows.filter(row => { 
-             return row.id !== params.id 
+        const outRows = rows.filter(row => {
+            return row.id !== params.id
         })
         setRows(outRows)
     }
+
+    const OutStockAnfme = React.memo(function OutStockAnfme(props) {
+        const { value } = props;
+        return (
+            value > 0 ?
+                <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
+                    <span>{value}</span>
+                </Box>
+                :
+                <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
+                    <span style={{ color: 'red' }}>{translate('common.edit.title.insuffInventory')}</span>
+                </Box>
+        );
+    });
 
     const OutStockSiteNo = React.memo(function OutStockSiteNo(props) {
         const { value } = props;
@@ -226,13 +300,32 @@
             return null;
         }
         return (
-            <Box
-                sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}
-            >
+            <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
                 <span>{value}</span>
             </Box>
         );
     });
+
+    const CustomToolBar = () => {
+        const selectSiteNo = () => {
+            setDialog(true)
+        }
+        return (
+            <Box sx={{
+                p: 1,
+                display: 'flex',
+                justifyContent: 'flex-end',
+                borderTop: '1px solid rgba(224, 224, 224, 1)'
+            }}>
+                <Button
+                    onClick={selectSiteNo}
+                    variant="outlined"
+                    label="toolbar.modiftySite"
+                    size="medium"
+                    sx={{ mr: 1 }} />
+            </Box>
+        );
+    }
 
     const OutStockSite = (params) => {
         const { id, field, siteNo, row: { staNos } } = params;
@@ -288,16 +381,12 @@
         <DataGrid
             rows={rows}
             columns={columns}
+            slots={{ toolbar: CustomToolBar }}
             apiRef={gridRef}
-            initialState={{
-                pagination: {
-                    paginationModel: {
-                        pageSize: 15,
-                    },
-                },
-            }}
             checkboxSelection
-            pageSizeOptions={[15, 25, 35, 45]}
+            disableRowSelectionOnClick
+            hideFooterPagination={true}  // 闅愯棌鍒嗛〉鎺т欢
+            hideFooter={false}
             onRowSelectionModelChange={(ids) => {
                 setSelectedIds(ids)
             }}
@@ -305,13 +394,14 @@
     )
 }
 
+
+
 //鎻愪氦鎸夐挳
 const SubmitButton = ({ selectedIds, setSelectedIds, gridRef, record }) => {
     const notify = useNotify();
     const refresh = useRefresh();
     const redirect = useRedirect();
     const submit = async () => {
-        console.log(record);
         const items = gridRef.current?.getSortedRows();
         const { data: { code, data, msg } } = await request.post('/outStock/generate/tasks', { items, outId: record?.id });
         if (code == 200) {

--
Gitblit v1.9.1