From ff55ac0e6b5fbc8be995ede3972972e380fb87b4 Mon Sep 17 00:00:00 2001
From: verou <857149855@qq.com>
Date: 星期二, 01 四月 2025 09:56:55 +0800
Subject: [PATCH] feat:质检合格

---
 rsf-admin/src/page/qlyInspect/InspectModal.jsx   |  259 +++++++++++++++++++++++++++++++++++++++++++++++++++
 rsf-admin/src/page/qlyInspect/QlyInspectList.jsx |   30 ++---
 rsf-admin/src/i18n/zh.js                         |    1 
 3 files changed, 273 insertions(+), 17 deletions(-)

diff --git a/rsf-admin/src/i18n/zh.js b/rsf-admin/src/i18n/zh.js
index a7d404f..ceb6029 100644
--- a/rsf-admin/src/i18n/zh.js
+++ b/rsf-admin/src/i18n/zh.js
@@ -439,6 +439,7 @@
                 splrBatch: "渚涘簲鍟嗘壒娆�",
                 stockBatch: "搴撳瓨鎵规",
                 isptResult: '璐ㄦ缁撹',
+                isptStatus: '璐ㄦ鐘舵��',
                 rcptQty: "鏀惰揣鏁伴噺",
                 dlyQty: "閫佽揣鏁伴噺",
                 disQty: "涓嶅悎鏁伴噺",
diff --git a/rsf-admin/src/page/qlyInspect/InspectModal.jsx b/rsf-admin/src/page/qlyInspect/InspectModal.jsx
new file mode 100644
index 0000000..f977507
--- /dev/null
+++ b/rsf-admin/src/page/qlyInspect/InspectModal.jsx
@@ -0,0 +1,259 @@
+import React, { useState, useEffect, useCallback, useRef } from "react";
+import {
+    Dialog,
+    DialogActions,
+    DialogContent,
+    DialogTitle,
+    Stack,
+    Grid,
+    TextField,
+    Box,
+    Button,
+    Paper,
+    styled,
+    RadioGroup,
+    Radio,
+    FormControlLabel,
+} from '@mui/material';
+import DialogCloseButton from "../components/DialogCloseButton";
+import ConfirmButton from "../components/ConfirmButton";
+import { useTranslate, useNotify, useRefresh } from 'react-admin';
+import request from '@/utils/request';
+import { DataGrid, useGridApiRef } from '@mui/x-data-grid';
+import SaveIcon from '@mui/icons-material/Save';
+import TreeSelectInput from "@/page/components/TreeSelectInput";
+import { set, throttle } from 'lodash';
+
+const InspectModal = (props) => {
+    const { open, setOpen, ispectId } = props;
+
+    const translate = useTranslate();
+    const notify = useNotify();
+    const refresh = useRefresh();
+
+    const handleClose = (event, reason) => {
+        if (reason !== "backdropClick") {
+            setOpen(false);
+        }
+    };
+
+    const [formData, setFormData] = useState({
+        code: ''
+    });
+
+    const [tableData, setTableData] = useState([]);
+    const [selectedRows, setSelectedRows] = useState([]);
+
+    const handleChange = (e) => {
+        const { name, value } = e.target;
+        setFormData((prevData) => ({
+            ...prevData,
+            [name]: value
+        }));
+    };
+
+    const reset = () => {
+        setFormData({
+            code: ''
+        })
+    }
+
+    const handleSubmit = async () => {
+        const data = tableData.filter(el => el.safeQty == 0)
+        console.log(data);
+        if (data.length) {
+            // const { data: { code, data, msg } } = await request.post(`/qlyInspect/selected`, { ids: selectedRows });
+
+            // if (code === 200) {
+            //     notify(msg);
+            //     refresh()
+            // } else {
+            //     notify(msg);
+            // }
+        }
+
+        setOpen(false);
+        reset();
+    };
+
+    useEffect(() => {
+        getData();
+    }, [open]);
+
+
+    const getData = async () => {
+        const res = await request.post(`/qlyIsptItem/page`, { ispectId, isptStatus: '0' });
+        if (res?.data?.code === 200) {
+            const data = res.data.data.records.map(item => {
+                return {
+                    ...item,
+                    isptResult: ''
+                }
+            })
+            setTableData(data);
+        } else {
+            notify(res.data.msg);
+        }
+    };
+
+
+
+    const handleSearch = () => {
+        getData()
+    };
+
+    const batchQualified = () => {
+        if (selectedRows.length) {
+            console.log(selectedRows);
+
+        }
+        getData()
+    }
+
+    const batchUnQualified = () => {
+        console.log(selectedRows);
+        getData()
+    }
+
+    return (
+        <Dialog
+            open={open}
+            onClose={handleClose}
+            aria-labelledby="form-dialog-title"
+            fullWidth
+            disableRestoreFocus
+            maxWidth="lg"
+        >
+            <DialogTitle id="form-dialog-title" sx={{
+                position: 'sticky',
+                top: 0,
+                backgroundColor: 'background.paper',
+                zIndex: 1000
+            }}>
+                鎵ц璐ㄦ
+                <Box sx={{ position: 'absolute', top: 8, right: 8, zIndex: 1001 }}>
+                    <DialogCloseButton onClose={handleClose} />
+                </Box>
+            </DialogTitle>
+            <DialogContent sx={{ mt: 2 }}>
+                {/* <Box component="form" onSubmit={handleSubmit} sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}>
+                    <Grid container spacing={2}>
+                        <Grid item md={4}>
+                            <TextField
+                                label={translate('table.field.asnOrder.code')}
+                                name="code"
+                                value={formData.code}
+                                onChange={handleChange}
+                                size="small"
+                            />
+                        </Grid>
+                    </Grid>
+                </Box> */}
+                <Box sx={{ mt: 2 }}>
+                    {/* <Stack direction="row" spacing={2}>
+                        <Button variant="contained" onClick={handleSearch}>鎼滅储</Button>
+                    </Stack> */}
+
+                    <Stack direction="row" spacing={2}>
+                        <Button variant="contained" onClick={batchQualified}>鎵归噺鍚堟牸</Button>
+                        <Button variant="contained" color="error" onClick={batchUnQualified}>鎵归噺涓嶅悎鏍�</Button>
+                    </Stack>
+                </Box>
+                <Box sx={{ mt: 2, height: 400, width: '100%' }}>
+                    <InspectModalTable
+                        tableData={tableData}
+                        setTableData={setTableData}
+                        selectedRows={selectedRows}
+                        setSelectedRows={setSelectedRows}
+                    />
+                </Box>
+            </DialogContent>
+            <DialogActions sx={{ position: 'sticky', bottom: 0, backgroundColor: 'background.paper', zIndex: 1000 }}>
+                <Box sx={{ width: '100%', display: 'flex', justifyContent: 'space-between' }}>
+                    <Button onClick={handleSubmit} variant="contained" startIcon={<SaveIcon />}>
+                        {translate('toolbar.confirm')}
+                    </Button>
+                </Box>
+            </DialogActions>
+        </Dialog>
+    );
+};
+
+export default InspectModal;
+
+const InspectModalTable = ({ tableData, setTableData, selectedRows, setSelectedRows }) => {
+    const translate = useTranslate();
+    const notify = useNotify();
+    const apiRef = useGridApiRef();
+
+    const handleSelectionChange = (ids) => {
+        setSelectedRows(ids)
+
+    };
+
+
+
+    const [columns, setColumns] = useState([
+        // { field: 'id', headerName: 'ID', width: 100 },
+        { field: 'maktx', headerName: translate('table.field.qlyIsptItem.maktx'), width: 200 },
+        { field: 'matnrCode', headerName: translate('table.field.qlyIsptItem.matnrCode') },
+        { field: 'splrName', headerName: translate('table.field.qlyIsptItem.splrName') },
+        { field: 'splrBatch', headerName: translate('table.field.qlyIsptItem.splrBatch') },
+        { field: 'stockBatch', headerName: translate('table.field.qlyIsptItem.stockBatch') },
+        { field: 'rcptQty', headerName: translate('table.field.qlyIsptItem.rcptQty') },
+        {
+            field: 'safeQty', headerName: translate('table.field.qlyIsptItem.safeQty'), editable: true, type: 'number',
+            renderHeader: () => (
+                <strong>
+                    {translate('table.field.qlyIsptItem.safeQty')}
+                    <span style={{ color: '#d32f2f' }}>
+                        *
+                    </span>
+                </strong>
+            ),
+        },
+        {
+            field: 'isptResult', headerName: translate('table.field.qlyIsptItem.isptResult'), width: 150, type: 'singleSelect',
+            editable: true, valueOptions: [{ value: '1', label: '鍚堟牸' }, { value: '2', label: '涓嶅悎鏍�' }, { value: '3', label: '寰呭畾' }, { value: '4', label: '闄嶇骇浣跨敤' }],
+        },
+
+
+    ])
+
+    const processRowUpdate = (newRow, oldRow) => {
+        setTableData((prevData) =>
+            prevData.map((r) =>
+                r.id === newRow.id ? { ...newRow } : r
+            )
+        );
+
+        return newRow;
+    };
+
+
+    return (
+        <div style={{ height: 400, width: '100%' }}>
+            <DataGrid
+                size="small"
+                rows={tableData}
+                columns={columns}
+                checkboxSelection
+                onRowSelectionModelChange={handleSelectionChange}
+                selectionModel={selectedRows}
+                apiRef={apiRef}
+                processRowUpdate={processRowUpdate}
+                editMode="row"
+                disableColumnMenu={true}
+                disableColumnSorting
+                disableMultipleColumnsSorting
+                disableRowSelectionOnClick
+                getRowId={(row) => row.id}
+                sx={{
+                    '& .MuiDataGrid-cell input': {
+                        border: '1px solid #ccc'
+                    },
+                }}
+            />
+        </div>
+    );
+};
\ No newline at end of file
diff --git a/rsf-admin/src/page/qlyInspect/QlyInspectList.jsx b/rsf-admin/src/page/qlyInspect/QlyInspectList.jsx
index 124d53c..33f00db 100644
--- a/rsf-admin/src/page/qlyInspect/QlyInspectList.jsx
+++ b/rsf-admin/src/page/qlyInspect/QlyInspectList.jsx
@@ -51,6 +51,7 @@
 import AddIcon from '@mui/icons-material/Add';
 import request from '@/utils/request';
 import AsnSelModal from "./AsnSelModal";
+import InspectModal from "./InspectModal";
 
 const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
     '& .css-1vooibu-MuiSvgIcon-root': {
@@ -178,26 +179,21 @@
     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);
-    //   }
-    // }
+    const [createDialog, setCreateDialog] = useState(false);
 
 
     return (
-        <Button onClick={inspection} label={"toolbar.quality"}>
-            <ConstructionIcon />
-        </Button>
+        <>
+            <Button onClick={() => setCreateDialog(true)} label={"toolbar.quality"}>
+                <ConstructionIcon />
+            </Button>
+
+            <InspectModal
+                open={createDialog}
+                setOpen={setCreateDialog}
+                ispectId={record.id}
+            />
+        </>
     )
 }
 

--
Gitblit v1.9.1