From 16845ea7cd44511661766c28b1b17a8e5bdce2a9 Mon Sep 17 00:00:00 2001 From: verou <857149855@qq.com> Date: 星期一, 17 三月 2025 18:41:49 +0800 Subject: [PATCH] feat:库位初始化 --- rsf-admin/src/page/basicInfo/loc/InitModal.jsx | 234 ++++++++++++++++++++++++++ rsf-admin/src/page/components/BatchButton.jsx | 15 rsf-admin/src/page/warehouseAreas/WarehouseAreasList.jsx | 10 rsf-admin/src/page/components/BatchModal.jsx | 65 +++++++ rsf-admin/src/i18n/zh.js | 12 + rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx | 35 +++ rsf-admin/src/i18n/en.js | 10 + rsf-admin/src/page/warehouseAreasItem/WarehouseAreasItemList.jsx | 4 rsf-admin/src/page/basicInfo/loc/InitButton.jsx | 74 ++++++++ rsf-admin/src/page/basicInfo/loc/LocList.jsx | 34 +++ 10 files changed, 474 insertions(+), 19 deletions(-) diff --git a/rsf-admin/src/i18n/en.js b/rsf-admin/src/i18n/en.js index 1beaebd..602630c 100644 --- a/rsf-admin/src/i18n/en.js +++ b/rsf-admin/src/i18n/en.js @@ -144,6 +144,13 @@ fields: 'Extend Fields', fieldsItem: 'Extend Fields Items', warehouseAreasItem: 'WarehouseAreasItem', + endBay: "endBay", + endLev: "endLev", + endRow: "endRow", + locType: "locType", + startBay: "startBay", + startLev: "startLev", + startRow: "startRow", }, table: { field: { @@ -600,6 +607,9 @@ inspection: "Inspection", creatcode: "creatcode", print: "print", + enable: 'enable', + unenable: 'unenable', + locInit: 'loc init' }, }; diff --git a/rsf-admin/src/i18n/zh.js b/rsf-admin/src/i18n/zh.js index 31ca842..889ea39 100644 --- a/rsf-admin/src/i18n/zh.js +++ b/rsf-admin/src/i18n/zh.js @@ -327,7 +327,7 @@ warehouseId: "浠撳簱", areaId: "搴撳尯", code: "缂栫爜", - type: "绫诲瀷", + type: "搴撲綅绫诲瀷", name: "鍚嶇О", flagLogic: "铏氭嫙搴撲綅", fucAtrrs: "鍔熻兘灞炴��", @@ -345,6 +345,13 @@ maxPack: "鏈�澶у寘瑁呮暟", flagLabelMange: "鏍囩绠$悊", locAttrs: "灞炴��", + endBay: "缁堟鍒�", + endLev: "缁堟灞�", + endRow: "缁堟鎺�", + locType: "瀹界獎绫诲瀷", + startBay: "璧峰鍒�", + startLev: "璧峰灞�", + startRow: "璧峰鎺�", }, container: { @@ -602,6 +609,9 @@ inspection: "鎶ユ", creatcode: "鐢熸垚鏉$爜", print: "鎵撳嵃", + enable: '鍚敤', + unenable: '绂佺敤', + locInit: '聽搴撲綅鍒濆鍖�' }, }; diff --git a/rsf-admin/src/page/basicInfo/loc/InitButton.jsx b/rsf-admin/src/page/basicInfo/loc/InitButton.jsx new file mode 100644 index 0000000..e3dd2e3 --- /dev/null +++ b/rsf-admin/src/page/basicInfo/loc/InitButton.jsx @@ -0,0 +1,74 @@ +import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; +import { useNavigate } from 'react-router-dom'; +import { + List, + DatagridConfigurable, + SearchInput, + TopToolbar, + SelectColumnsButton, + EditButton, + FilterButton, + CreateButton, + ExportButton, + BulkDeleteButton, + WrapperField, + useRecordContext, + useTranslate, + useNotify, + useListContext, + FunctionField, + TextField, + NumberField, + DateField, + BooleanField, + ReferenceField, + TextInput, + DateTimeInput, + DateInput, + SelectInput, + NumberInput, + ReferenceInput, + ReferenceArrayInput, + AutocompleteInput, + DeleteButton, + useRefresh, + Button +} from 'react-admin'; +import { Box, Typography, Card, Stack } from '@mui/material'; +import { styled } from '@mui/material/styles'; +import InitModal from "./InitModal"; +import LocPanel from "./LocPanel"; +import EmptyData from "../../components/EmptyData"; +import MyCreateButton from "../../components/MyCreateButton"; +import MyExportButton from '../../components/MyExportButton'; +import BatchButton from '../../components/BatchButton'; +import PageDrawer from "../../components/PageDrawer"; +import MyField from "../../components/MyField"; +import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; +import * as Common from '@/utils/common'; +import DashboardIcon from '@mui/icons-material/Dashboard'; +import request from '@/utils/request'; +import CabinIcon from '@mui/icons-material/Cabin'; + +const InitButton = () => { + const record = useRecordContext(); + const notify = useNotify(); + const refresh = useRefresh(); + + const [createDialog, setCreateDialog] = useState(false); + // console.log(record) + + return (<> + <Button onClick={() => setCreateDialog(true)} label={"toolbar.locInit"}> + <CabinIcon /> + </Button> + <InitModal + open={createDialog} + setOpen={setCreateDialog} + /> + </> + + ) +} + +export default InitButton; \ No newline at end of file diff --git a/rsf-admin/src/page/basicInfo/loc/InitModal.jsx b/rsf-admin/src/page/basicInfo/loc/InitModal.jsx new file mode 100644 index 0000000..ef64347 --- /dev/null +++ b/rsf-admin/src/page/basicInfo/loc/InitModal.jsx @@ -0,0 +1,234 @@ +import React, { useState, useRef, useEffect, useMemo } from "react"; +import { + CreateBase, + useTranslate, + TextInput, + NumberInput, + BooleanInput, + DateInput, + SaveButton, + SelectInput, + ReferenceInput, + ReferenceArrayInput, + AutocompleteInput, + Toolbar, + required, + useDataProvider, + useNotify, + Form, + useCreateController, + useListContext, + useRefresh, +} from 'react-admin'; +import { + Dialog, + DialogActions, + DialogContent, + DialogTitle, + Grid, + TextField, + Box, + Button, + Paper, + TableContainer, + Table, + TableHead, + TableBody, + TableRow, + TableCell, + Tooltip, + IconButton, + styled + + +} from '@mui/material'; +import DialogCloseButton from "../../components/DialogCloseButton"; +import { useForm, Controller, useWatch, FormProvider, useFormContext } from "react-hook-form"; +import SaveIcon from '@mui/icons-material/Save'; +import request from '@/utils/request'; +import { Add, Edit, Delete } from '@mui/icons-material'; +import _ from 'lodash'; +import { DataGrid } from '@mui/x-data-grid'; + + + + +const InitModal = ({ open, setOpen }) => { + const refresh = useRefresh(); + const translate = useTranslate(); + + + const notify = useNotify(); + + const [formData, setFormData] = useState({ + "areaId": "", + "endBay": "", + "endLev": "", + "endRow": "", + "locType": "", + "startBay": "", + "startLev": "", + "startRow": "", + "type": "" + }); + + const handleClose = (event, reason) => { + if (reason !== "backdropClick") { + setOpen(false); + } + }; + + const handleReset = (e) => { + e.preventDefault(); + }; + + const handleChange = (e) => { + const { name, value } = e.target; + setFormData((prevData) => ({ + ...prevData, + [name]: value + })); + }; + + const handleSubmit = async () => { + const res = await request.post(`/loc/init`, formData); + if (res?.data?.code === 200) { + setOpen(false); + refresh(); + } else { + notify(res.data.msg); + } + } + + + return ( + <Dialog open={open} maxWidth="md" fullWidth> + <DialogCloseButton onClose={handleClose} /> + <DialogTitle>{translate('toolbar.locInit')}</DialogTitle> + <DialogContent sx={{ mt: 2 }}> + <Box component="form" sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}> + <Grid container spacing={2}> + <Grid item xs={4}> + <TextField + label={translate("table.field.loc.areaId")} + name="wkType" + value={formData.areaId} + onChange={handleChange} + variant="outlined" + size="small" + validate={required()} + /> + </Grid> + + <Grid item xs={4}> + <TextField + label={translate("table.field.loc.locType")} + name="wkType" + value={formData.locType} + onChange={handleChange} + variant="outlined" + size="small" + validate={required()} + /> + </Grid> + + <Grid item xs={4}> + <TextField + label={translate("table.field.loc.type")} + name="wkType" + value={formData.type} + onChange={handleChange} + variant="outlined" + size="small" + validate={required()} + /> + </Grid> + + <Grid item xs={4}> + <TextField + label={translate("table.field.loc.startBay")} + name="type" + value={formData.startBay} + onChange={handleChange} + variant="outlined" + size="small" + validate={required()} + /> + </Grid> + + <Grid item xs={4}> + <TextField + label={translate("table.field.loc.startLev")} + name="wkType" + value={formData.startLev} + onChange={handleChange} + variant="outlined" + size="small" + validate={required()} + /> + </Grid> + + <Grid item xs={4}> + <TextField + label={translate("table.field.loc.startRow")} + name="wkType" + value={formData.startRow} + onChange={handleChange} + variant="outlined" + size="small" + validate={required()} + /> + </Grid> + + <Grid item xs={4}> + <TextField + label={translate("table.field.loc.endBay")} + name="wkType" + value={formData.endBay} + onChange={handleChange} + variant="outlined" + size="small" + validate={required()} + /> + </Grid> + + <Grid item xs={4}> + <TextField + label={translate("table.field.loc.endLev")} + name="wkType" + value={formData.endLev} + onChange={handleChange} + variant="outlined" + size="small" + validate={required()} + /> + </Grid> + + <Grid item xs={4}> + <TextField + label={translate("table.field.loc.endRow")} + name="wkType" + value={formData.endRow} + onChange={handleChange} + variant="outlined" + size="small" + validate={required()} + /> + </Grid> + + + </Grid> + </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 />}> + 纭 + </Button> + </Box> + </DialogActions> + </Dialog> + ); +} + +export default InitModal; \ No newline at end of file diff --git a/rsf-admin/src/page/basicInfo/loc/LocList.jsx b/rsf-admin/src/page/basicInfo/loc/LocList.jsx index 5ef83f5..fbbecc9 100644 --- a/rsf-admin/src/page/basicInfo/loc/LocList.jsx +++ b/rsf-admin/src/page/basicInfo/loc/LocList.jsx @@ -31,6 +31,8 @@ ReferenceArrayInput, AutocompleteInput, DeleteButton, + useRefresh, + Button } from 'react-admin'; import { Box, Typography, Card, Stack } from '@mui/material'; import { styled } from '@mui/material/styles'; @@ -39,10 +41,13 @@ import EmptyData from "../../components/EmptyData"; import MyCreateButton from "../../components/MyCreateButton"; import MyExportButton from '../../components/MyExportButton'; +import InitButton from './InitButton'; import PageDrawer from "../../components/PageDrawer"; import MyField from "../../components/MyField"; import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; import * as Common from '@/utils/common'; +import DashboardIcon from '@mui/icons-material/Dashboard'; +import request from '@/utils/request'; const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ '& .css-1vooibu-MuiSvgIcon-root': { @@ -98,6 +103,7 @@ const [createDialog, setCreateDialog] = useState(false); const [drawerVal, setDrawerVal] = useState(false); + return ( <Box display="flex"> <List @@ -116,6 +122,7 @@ actions={( <TopToolbar> <FilterButton /> + <InitButton /> <MyCreateButton onClick={() => { setCreateDialog(true) }} /> <SelectColumnsButton preferenceKey='loc' /> <MyExportButton /> @@ -165,6 +172,7 @@ <WrapperField cellClassName="opt" label="common.field.opt"> <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> {/* <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> */} + <EnableButton /> </WrapperField> </StyledDatagrid> </List> @@ -183,3 +191,29 @@ } export default LocList; + +const EnableButton = () => { + const record = useRecordContext(); + const notify = useNotify(); + const refresh = useRefresh(); + const enable = async () => { + const res = await request.post('/loc/update', { + ...record, + status: +!record.status + }); + if (res?.data?.code === 200) { + refresh() + } else { + notify(res.data.msg); + } + } + return ( + record.status === 1 ? + (<Button onClick={enable} label={"toolbar.unenable"}> + <DashboardIcon /> + </Button>) : (<Button onClick={enable} label={"toolbar.enable"}> + <DashboardIcon /> + </Button>) + + ) +} diff --git a/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx b/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx index 937a8e4..901038b 100644 --- a/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx +++ b/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx @@ -31,6 +31,8 @@ ReferenceArrayInput, AutocompleteInput, DeleteButton, + useRefresh, + Button } from 'react-admin'; import { Box, Typography, Card, Stack, LinearProgress, Tooltip } from '@mui/material'; @@ -47,6 +49,8 @@ import ImportButton from "../../components/ImportButton"; import MatListAside from './MatnrListAside'; import { display, height } from "@mui/system"; +import DashboardIcon from '@mui/icons-material/Dashboard'; +import request from '@/utils/request'; const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ '& .css-1vooibu-MuiSvgIcon-root': { @@ -165,7 +169,7 @@ omit={['id', 'shipperId', 'platCode', 'spec', 'model', 'weight', 'color', 'size', 'describle' , 'nromNum', 'unit', 'purchaseUnit', 'stockUnit', 'stockLeval', 'isLabelMange', 'safeQty' , 'minQty', 'maxQty', 'stagn', 'valid', 'validWarn', 'flagCheck', 'updateTime', 'updateBy' - , 'createTime', 'createBy', 'memo']} + , 'createTime', 'createBy', 'memo', 'rglarId', 'groupId', 'stockLevel', 'isLabelMange']} > <NumberField source="id" /> @@ -214,6 +218,7 @@ <WrapperField cellClassName="opt" label="common.field.opt"> <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> {/* <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> */} + <EnableButton /> </WrapperField> </StyledDatagrid> </Box> @@ -275,4 +280,30 @@ MatnrList.Context = React.createContext() -export default MatnrList; \ No newline at end of file +export default MatnrList; + +const EnableButton = () => { + const record = useRecordContext(); + const notify = useNotify(); + const refresh = useRefresh(); + const enable = async () => { + const res = await request.post('/loc/update', { + ...record, + status: +!record.status + }); + if (res?.data?.code === 200) { + refresh() + } else { + notify(res.data.msg); + } + } + return ( + record.status === 1 ? + (<Button onClick={enable} label={"toolbar.unenable"}> + <DashboardIcon /> + </Button>) : (<Button onClick={enable} label={"toolbar.enable"}> + <DashboardIcon /> + </Button>) + + ) +} \ No newline at end of file diff --git a/rsf-admin/src/page/components/BatchButton.jsx b/rsf-admin/src/page/components/BatchButton.jsx index 147ec9e..5a46f8d 100644 --- a/rsf-admin/src/page/components/BatchButton.jsx +++ b/rsf-admin/src/page/components/BatchButton.jsx @@ -1,11 +1,12 @@ -import UploadIcon from '@mui/icons-material/Upload'; +import EditIcon from '@mui/icons-material/Edit'; import { useState } from 'react'; -import { Button } from 'react-admin'; -import ImportModal from './ImportModal'; +import { Button, useListContext } from 'react-admin'; +import BatchModal from './BatchModal'; const ImportButton = (props) => { const [modalOpen, setModalOpen] = useState(false); - + const { selectedIds } = useListContext(); + console.log(selectedIds) const handleOpenModal = () => { setModalOpen(true); }; @@ -17,12 +18,12 @@ return ( <> <Button - startIcon={<UploadIcon />} - label="common.action.import.title" + startIcon={<EditIcon />} + label="common.action.batch" onClick={handleOpenModal} /> - <ImportModal open={modalOpen} onClose={handleCloseModal} {...props} /> + <BatchModal open={modalOpen} onClose={handleCloseModal} {...props} /> </> ); }; diff --git a/rsf-admin/src/page/components/BatchModal.jsx b/rsf-admin/src/page/components/BatchModal.jsx new file mode 100644 index 0000000..e2107c7 --- /dev/null +++ b/rsf-admin/src/page/components/BatchModal.jsx @@ -0,0 +1,65 @@ +import { useEffect, useState, createContext, useContext } from 'react'; +import { Box, CircularProgress, Stack, Typography } from '@mui/material'; +import Alert from '@mui/material/Alert'; +import Dialog from '@mui/material/Dialog'; +import DialogActions from '@mui/material/DialogActions'; +import DialogContent from '@mui/material/DialogContent'; +import DialogTitle from '@mui/material/DialogTitle'; +import MuiLink from '@mui/material/Link'; +import { + Button, + FileField, + FileInput, + Form, + Toolbar, + useRefresh, + useTranslate, + useNotify +} from 'react-admin'; +import { Link } from 'react-router-dom'; +import DialogCloseButton from './DialogCloseButton'; +import { usePapaParse } from './usePapaParse'; +import MatnrList from '../basicInfo/matnr/MatnrList'; +import request from '@/utils/request' +import SaveIcon from '@mui/icons-material/Save'; + +const ImportModal = ({ open, onClose, importTemp, useCodeImport, onceBatch = 10, value, parmas = {} }) => { + const refresh = useRefresh(); + const translate = useTranslate(); + + + const notify = useNotify(); + + + + const handleClose = () => { + onClose(); + }; + + const handleReset = (e) => { + e.preventDefault(); + }; + + const handleSubmit = () => { + }; + + + return ( + <Dialog open={open} maxWidth="md" fullWidth> + <DialogCloseButton onClose={handleClose} /> + <DialogTitle>{translate('common.action.batch')}</DialogTitle> + <DialogContent> + <div>1</div> + </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 />}> + 纭 + </Button> + </Box> + </DialogActions> + </Dialog> + ); +} + +export default ImportModal; \ No newline at end of file diff --git a/rsf-admin/src/page/warehouseAreas/WarehouseAreasList.jsx b/rsf-admin/src/page/warehouseAreas/WarehouseAreasList.jsx index f8a68f3..8a95d66 100644 --- a/rsf-admin/src/page/warehouseAreas/WarehouseAreasList.jsx +++ b/rsf-admin/src/page/warehouseAreas/WarehouseAreasList.jsx @@ -60,8 +60,6 @@ const filters = [ <SearchInput source="condition" alwaysOn />, - <DateInput label='common.time.after' source="timeStart" alwaysOn />, - <DateInput label='common.time.before' source="timeEnd" alwaysOn />, <TextInput source="uuid" label="table.field.warehouseAreas.uuid" />, <TextInput source="name" label="table.field.warehouseAreas.name" />, @@ -73,19 +71,19 @@ <SelectInput source="flagMinus" label="table.field.warehouseAreas.flagMinus" choices={[ { id: 0, name: '鍚�' }, - { id: 1, name: '鏄�' }, + { id: 1, name: '鏄�' }, ]} />, <SelectInput source="flagLabelMange" label="table.field.warehouseAreas.flagLabelMange" choices={[ { id: 0, name: ' 鍚�' }, - { id: 1, name: ' 鏄�' }, + { id: 1, name: ' 鏄�' }, ]} />, <SelectInput source="flagMix" label="table.field.warehouseAreas.flagMix" choices={[ { id: 0, name: '鍚�' }, - { id: 1, name: '鏄�' }, + { id: 1, name: '鏄�' }, ]} />, @@ -116,7 +114,7 @@ theme.transitions.create(['all'], { duration: theme.transitions.duration.enteringScreen, }), - marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, + marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, }} title={"menu.warehouseAreas"} empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} diff --git a/rsf-admin/src/page/warehouseAreasItem/WarehouseAreasItemList.jsx b/rsf-admin/src/page/warehouseAreasItem/WarehouseAreasItemList.jsx index 65fc752..9b03b48 100644 --- a/rsf-admin/src/page/warehouseAreasItem/WarehouseAreasItemList.jsx +++ b/rsf-admin/src/page/warehouseAreasItem/WarehouseAreasItemList.jsx @@ -60,8 +60,6 @@ const filters = [ <SearchInput source="condition" alwaysOn />, - <DateInput label='common.time.after' source="timeStart" alwaysOn />, - <DateInput label='common.time.before' source="timeEnd" alwaysOn />, <NumberInput source="areaId" label="table.field.warehouseAreasItem.areaId" />, <TextInput source="areaName" label="table.field.warehouseAreasItem.areaName" />, @@ -109,7 +107,7 @@ theme.transitions.create(['all'], { duration: theme.transitions.duration.enteringScreen, }), - marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, + marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, }} title={"menu.warehouseAreasItem"} empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} -- Gitblit v1.9.1