From b11d506d64188be9843f13fcf2dd6bb3df45acfd Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期三, 11 六月 2025 09:51:00 +0800
Subject: [PATCH] #
---
rsf-admin/src/page/orders/outStock/OutStockPublic.jsx | 333 +++++++++++++++++++++++++++++++++----------------------
1 files changed, 201 insertions(+), 132 deletions(-)
diff --git a/rsf-admin/src/page/orders/outStock/OutStockPublic.jsx b/rsf-admin/src/page/orders/outStock/OutStockPublic.jsx
index b3b7062..5ba82cb 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,
@@ -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': {
@@ -70,9 +71,31 @@
const [formData, setFormData] = useState({
orderId: record?.id
});
+ const [dialog, setDialog] = useState(false);
+ const [selectedValue, setSelectedValue] = useState({});
+
+ const handleClickOpen = () => {
+ setDialog(true);
+ };
+
+ const handleClose = (value) => {
+ setDialog(false);
+ setSelectedValue(value);
+ console.log(rows);
+ console.log(value);
+ const newRows = rows.map(item => {
+ return {
+ ...item,
+ siteNo: value?.site
+ }
+ })
+ setRows(newRows);
+ };
+
useEffect(() => {
getWaveRule()
}, [formData, open])
+
const getWaveRule = async () => {
if (formData.waveId == null && formData.waveId == undefined) {
@@ -94,7 +117,6 @@
}));
};
- gridRef.current = useGridApiRef();
return (
<>
@@ -158,45 +180,203 @@
<Grid item xl={6.3} gap={2}>
<Card>
<Box sx={{ height: 500, width: '100%' }}>
- <DataGrid
+ <PreviewTable
rows={rows}
- columns={columns}
- apiRef={gridRef}
- initialState={{
- pagination: {
- paginationModel: {
- pageSize: 15,
- },
- },
- }}
- checkboxSelection
- pageSizeOptions={[15, 25, 35, 45]}
- onRowSelectionModelChange={(ids) => {
- setSelectedIds(ids)
- }}
+ gridRef={gridRef}
+ setRows={setRows}
+ record={record}
+ selectedIds={selectedIds}
+ setDialog={setDialog}
+ setSelectedIds={setSelectedIds}
/>
</Box>
<Box sx={{ textAlign: 'center' }}>
<CloseButton setOpen={setOpen} />
- <SubmitButton selectedIds={selectedIds} setSelectedIds={setSelectedIds} gridRef={gridRef} />
+ <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, selectedIds, setSelectedIds, setDialog }) => {
+ gridRef.current = useGridApiRef();
+
+ const columns = [
+ { field: 'id', headerName: 'ID', width: 40 },
+ { field: 'locCode', headerName: '搴撲綅', width: 110 },
+ { field: 'barcode', headerName: '瀹瑰櫒', width: 120 },
+ { field: 'batch', headerName: '鎵规', width: 90 },
+ { field: 'unit', headerName: '鍗曚綅', width: 90 },
+ { field: 'outQty', headerName: '鏈鍑哄簱鏁伴噺', width: 110 },
+ {
+ field: 'siteNo',
+ headerName: '鍑哄簱鍙�',
+ width: 90,
+ type: 'singleSelect',
+ editable: true,
+ renderCell: (params) => (
+ <OutStockSiteNo value={params.value} />
+ ),
+ renderEditCell: (params) => (
+ <OutStockSite {...params} />
+ ),
+ },
+ {
+ field: 'actions',
+ type: 'actions',
+ headerName: '鎿嶄綔',
+ with: 120,
+ getActions: (params) => [
+ <GridActionsCellItem
+ icon={<Delete />}
+ label="Delete"
+ onClick={() => handleDelete(params.row, rows, setRows)}
+ />,
+ ]
+ },
+ ]
+
+ /**
+ * 鍒犻櫎浜嬩欢
+ * @param {*} params
+ */
+ const handleDelete = (params, rows, setRows) => {
+ const outRows = rows.filter(row => {
+ return row.id !== params.id
+ })
+ setRows(outRows)
+ }
+
+ const OutStockSiteNo = React.memo(function OutStockSiteNo(props) {
+ const { value } = props;
+ if (!value) {
+ return null;
+ }
+ return (
+ <Box
+ sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}
+ >
+ <span>{value}</span>
+ </Box>
+ );
+ });
+
+ const CustomToolBar = () => {
+ const selectSiteNo = () => {
+ setDialog(true)
+ }
+
+ return (
+ selectedIds.length > 0 ? <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;
+ const apiRef = useGridApiContext();
+ const handleChange = async (event) => {
+ await apiRef.current.setEditCellValue(
+ { id, field, value: event.target.value },
+ event,
+ );
+ apiRef.current.stopCellEditMode({ id, field });
+ };
+
+ const handleClose = (event, reason) => {
+ if (reason === 'backdropClick') {
+ apiRef.current.stopCellEditMode({ id, field });
+ }
+ };
+
+ return (
+ <Select
+ value={siteNo}
+ onChange={handleChange}
+ MenuProps={{
+ onClose: handleClose,
+ }}
+ sx={{
+ height: '100%',
+ '& .MuiSelect-select': {
+ display: 'flex',
+ alignItems: 'center',
+ pl: 1,
+ },
+ }}
+ autoFocus
+ fullWidth
+ open
+ >
+ {staNos.map((option) => {
+ return (
+ <MenuItem
+ key={option}
+ value={option.staNo}
+ >
+ <ListItemText sx={{ overflow: 'hidden' }} primary={option.staNo} />
+ </MenuItem>
+ );
+ })}
+ </Select >
+ )
+ }
+
+ return (
+ <DataGrid
+ rows={rows}
+ columns={columns}
+ slots={{ toolbar: CustomToolBar }}
+ apiRef={gridRef}
+ initialState={{
+ pagination: {
+ paginationModel: {
+ pageSize: 15,
+ },
+ },
+ }}
+ checkboxSelection
+ pageSizeOptions={[15, 25, 35, 45]}
+ onRowSelectionModelChange={(ids) => {
+ setSelectedIds(ids)
+ }}
+ />
+ )
+}
+
+
//鎻愪氦鎸夐挳
-const SubmitButton = ({ selectedIds, setSelectedIds, gridRef }) => {
+const SubmitButton = ({ selectedIds, setSelectedIds, gridRef, record }) => {
const notify = useNotify();
const refresh = useRefresh();
- const redirect = useRedirect();
+ 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 });
+ const { data: { code, data, msg } } = await request.post('/outStock/generate/tasks', { items, outId: record?.id });
if (code == 200) {
refresh();
redirect("/task")
@@ -230,117 +410,6 @@
sx={{ margin: '3.5em' }} />
)
}
-
-const columns = [
- { field: 'id', headerName: 'ID', width: 40 },
- { field: 'locCode', headerName: '搴撲綅', width: 110 },
- { field: 'barcode', headerName: '瀹瑰櫒', width: 120 },
- { field: 'batch', headerName: '鎵规', width: 90 },
- { field: 'unit', headerName: '鍗曚綅', width: 90 },
- { field: 'outQty', headerName: '鏈鍑哄簱鏁伴噺', width: 110 },
- {
- field: 'siteNo',
- headerName: '鍑哄簱鍙�',
- width: 90,
- type: 'singleSelect',
- editable: true,
- renderCell: (params) => (
- <OutStockSiteNo value={params.value} />
- ),
- renderEditCell: (params) => (
- <OutStockSite {...params} />
- ),
- },
- {
- field: 'actions',
- type: 'actions',
- headerName: '鎿嶄綔',
- with: 120,
- getActions: (params) => [
- <GridActionsCellItem
- icon={<Delete />}
- label="Delete"
- onClick={() => handleDelete(params.row.id)}
- />,
- ]
- },
-]
-
-/**
- * 鍒犻櫎浜嬩欢
- * @param {*} params
- */
-const handleDelete = (params) => {
- console.log(params);
-
-}
-
-
-const OutStockSiteNo = React.memo(function OutStockSiteNo(props) {
- const { value } = props;
- if (!value) {
- return null;
- }
- return (
- <Box
- sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}
- >
- <span>{value}</span>
- </Box>
- );
-});
-
-
-const OutStockSite = (params) => {
- const { id, field, siteNo, row: { staNos } } = params;
- const apiRef = useGridApiContext();
- const handleChange = async (event) => {
- await apiRef.current.setEditCellValue(
- { id, field, value: event.target.value },
- event,
- );
- apiRef.current.stopCellEditMode({ id, field });
- };
-
- const handleClose = (event, reason) => {
- if (reason === 'backdropClick') {
- apiRef.current.stopCellEditMode({ id, field });
- }
- };
-
- return (
- <Select
- value={siteNo}
- onChange={handleChange}
- MenuProps={{
- onClose: handleClose,
- }}
- sx={{
- height: '100%',
- '& .MuiSelect-select': {
- display: 'flex',
- alignItems: 'center',
- pl: 1,
- },
- }}
- autoFocus
- fullWidth
- open
- >
- {staNos.map((option) => {
- return (
- <MenuItem
- key={option}
- value={option.staNo}
- >
- <ListItemText sx={{ overflow: 'hidden' }} primary={option.staNo} />
- </MenuItem>
- );
- })}
- </Select >
- )
-}
-
export default OutStockPublic;
--
Gitblit v1.9.1