From 53eb9e72f7fff791c2d1f7a768441035b57ca7b1 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期二, 25 三月 2025 11:23:55 +0800 Subject: [PATCH] Merge branch 'front' into devlop --- rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupEdit.jsx | 41 +++++++- rsf-admin/src/page/components/TreeSelectInput.jsx | 3 rsf-admin/src/i18n/zh.js | 2 rsf-admin/src/page/basicInfo/matnr/BatchGropuModal.jsx | 153 ++++++++++++++++++++++++++++++ rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx | 33 +++++ rsf-admin/src/i18n/en.js | 2 rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupCreate.jsx | 4 rsf-admin/src/page/system/role/AssignPermissions.jsx | 23 ++- rsf-admin/src/layout/index.jsx | 1 rsf-admin/src/page/basicInfo/matnr/MatnrEdit.jsx | 1 rsf-admin/src/page/basicInfo/locAreaMat/LocAreaMatPanel.jsx | 2 11 files changed, 242 insertions(+), 23 deletions(-) diff --git a/rsf-admin/src/i18n/en.js b/rsf-admin/src/i18n/en.js index fe02573..dfb832c 100644 --- a/rsf-admin/src/i18n/en.js +++ b/rsf-admin/src/i18n/en.js @@ -292,6 +292,7 @@ name: "name", code: "code", parentId: "parentId", + parCode: "parCode", }, warehouse: { name: "name", @@ -644,6 +645,7 @@ subzone: 'subzone', bindmatnr: 'bind matnr', bindloc: 'bind loc', + batchMatnrGropu: 'batchMatnrGropu', }, }; diff --git a/rsf-admin/src/i18n/zh.js b/rsf-admin/src/i18n/zh.js index 7044fee..a1976a7 100644 --- a/rsf-admin/src/i18n/zh.js +++ b/rsf-admin/src/i18n/zh.js @@ -286,6 +286,7 @@ name: "鍚嶇О", code: "缂栫爜", parentId: "涓婄骇鏍囪瘑", + parCode: "涓婄骇缂栫爜", }, warehouse: { name: "浠撳簱鍚嶇О", @@ -646,6 +647,7 @@ subzone: '缁戝畾鍒嗗尯', bindmatnr: '缁戝畾鐗╂枡', bindloc: '缁戝畾搴撲綅', + batchMatnrGropu: '鎵归噺鐗╂枡鍒嗙粍', }, }; diff --git a/rsf-admin/src/layout/index.jsx b/rsf-admin/src/layout/index.jsx index 40f6657..9d105ce 100644 --- a/rsf-admin/src/layout/index.jsx +++ b/rsf-admin/src/layout/index.jsx @@ -6,6 +6,7 @@ <RALayout appBar={AppBar} menu={MyMenu} + sx={{ '& .RaLayout-content': { position: 'absolute', left: '200px', overflowY: 'auto', width: 'calc(100% - 200px)', height: 'calc(100% - 50px)' } }} > {children} <CheckForApplicationUpdate /> diff --git a/rsf-admin/src/page/basicInfo/locAreaMat/LocAreaMatPanel.jsx b/rsf-admin/src/page/basicInfo/locAreaMat/LocAreaMatPanel.jsx index 18268bf..7620e16 100644 --- a/rsf-admin/src/page/basicInfo/locAreaMat/LocAreaMatPanel.jsx +++ b/rsf-admin/src/page/basicInfo/locAreaMat/LocAreaMatPanel.jsx @@ -352,7 +352,7 @@ typeId: selectedItems } - const res = await request.post(`/locAreaMatRela/locType/remove/`, parmas); + const res = await request.post(`/locAreaMatRela/locType/remove`, parmas); if (res?.data?.code === 200) { reload() notify(res.data.msg); diff --git a/rsf-admin/src/page/basicInfo/matnr/BatchGropuModal.jsx b/rsf-admin/src/page/basicInfo/matnr/BatchGropuModal.jsx new file mode 100644 index 0000000..135c251 --- /dev/null +++ b/rsf-admin/src/page/basicInfo/matnr/BatchGropuModal.jsx @@ -0,0 +1,153 @@ +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 DictionarySelect from "../../components/DictionarySelect"; +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'; +import StatusSelectInput from "../../components/StatusSelectInput"; +import TreeSelectInput from "@/page/components/TreeSelectInput"; + +const InitModal = ({ open, setOpen }) => { + const refresh = useRefresh(); + const translate = useTranslate(); + + + const notify = useNotify(); + + const [formData, setFormData] = useState({ + 'groupId': null + }); + + const { selectedIds, onUnselectItems } = useListContext(); + + const handleClose = (event, reason) => { + if (reason !== "backdropClick") { + setOpen(false); + reset() + refresh(); + onUnselectItems() + } + }; + + const reset = () => { + setFormData({ + 'groupId': null + }) + } + + const handleReset = (e) => { + e.preventDefault(); + }; + + const handleChange = (value, name) => { + setFormData((prevData) => ({ + ...prevData, + [name]: ['locType', 'type'].includes(name) ? value : +value + })); + }; + + const removeEmptyKeys = (obj) => { + return _.pickBy(obj, (value) => { + if (_.isObject(value)) { + const newObj = removeEmptyKeys(value); + return !_.isEmpty(newObj); + } + return !_.isNil(value) && (_.isNumber(value) ? value !== 0 : !_.isEmpty(value)); + }); + } + + const handleSubmit = async () => { + const parmas = { + ids: selectedIds, + ...removeEmptyKeys(formData) + } + + const res = await request.post(`/matnr/group/bind`, parmas); + if (res?.data?.code === 200) { + handleClose() + + } else { + notify(res.data.msg); + } + } + + return ( + <Dialog open={open} maxWidth="md" fullWidth> + <Form onSubmit={handleSubmit}> + <DialogCloseButton onClose={handleClose} /> + <DialogTitle>{translate('toolbar.batchMatnrGropu')}</DialogTitle> + <DialogContent sx={{ mt: 2 }}> + <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}> + <Grid container spacing={2}> + <Grid item xs={4}> + <TreeSelectInput + label="table.field.locAreaMatRela.groupId" + resource={'matnrGroup'} + source="groupId" + value={formData.groupId} + onChange={(e) => handleChange(+e.target.value, 'groupId')} + /> + </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 type="submit" variant="contained" startIcon={<SaveIcon />}> + {translate('toolbar.confirm')} + </Button> + </Box> + </DialogActions> + </Form> + </Dialog> + ); +} + +export default InitModal; \ No newline at end of file diff --git a/rsf-admin/src/page/basicInfo/matnr/MatnrEdit.jsx b/rsf-admin/src/page/basicInfo/matnr/MatnrEdit.jsx index 2264d6e..def6d1a 100644 --- a/rsf-admin/src/page/basicInfo/matnr/MatnrEdit.jsx +++ b/rsf-admin/src/page/basicInfo/matnr/MatnrEdit.jsx @@ -100,7 +100,6 @@ redirect="list" mutationMode={EDIT_MODE} actions={<CustomerTopToolBar />} - aside={<EditBaseAside />} title={"menu.matnr"} > <SimpleForm diff --git a/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx b/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx index 5dc0c6c..9bf7cfc 100644 --- a/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx +++ b/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx @@ -54,6 +54,7 @@ import PrintIcon from '@mui/icons-material/Print'; import request from '@/utils/request'; import BatchModal from './BatchModal'; +import BatchGropuModal from './BatchGropuModal'; import PrintModal from './PrintModal'; import LinkIcon from '@mui/icons-material/Link'; import BindModal from './BindModal'; @@ -86,10 +87,11 @@ overflow: 'hidden', textOverflow: 'ellipsis', display: 'block', - width: '300px', + width: '200px', }, '& .RaDatagrid-table': { - width: '100%' + width: '100%', + position: 'relative', } })); @@ -207,7 +209,7 @@ <TextField key="memo" source="memo" label="common.field.memo" sortable={false} />, ] const fields = data.map(el => <TextField key={el.fields} source={`extendFields.[${el.fields}]`} label={el.fieldsAlise} />) - const opt = <WrapperField key="opt" cellClassName="opt" label="common.field.opt"> + const opt = <WrapperField key="opt" cellClassName="fixed" className="fixed" label="common.field.opt"> <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> <EnableButton /> </WrapperField> @@ -239,6 +241,7 @@ <StyledDatagrid preferenceKey='matnr' bulkActionButtons={<> + <BatchGroupButton /> <BatchButton /> <BindButton /> <PrintButton /> @@ -360,6 +363,29 @@ ) } +const BatchGroupButton = () => { + const record = useRecordContext(); + const notify = useNotify(); + const refresh = useRefresh(); + + + const [createDialog, setCreateDialog] = useState(false); + + return ( + <> + <Button onClick={() => setCreateDialog(true)} label={"toolbar.batchMatnrGropu"}> + <EditIcon /> + </Button> + + <BatchGropuModal + open={createDialog} + setOpen={setCreateDialog} + /> + </> + + ) +} + const PrintButton = () => { const record = useRecordContext(); const { resource, selectedIds } = useListContext(); @@ -380,7 +406,6 @@ rows={selectedIds} /> </> - ) } diff --git a/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupCreate.jsx b/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupCreate.jsx index 6e2a958..4c9aa78 100644 --- a/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupCreate.jsx +++ b/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupCreate.jsx @@ -93,14 +93,14 @@ validate={required()} /> </Grid> - {/* <Grid item xs={6} display="flex" gap={1}> + <Grid item xs={6} display="flex" gap={1}> <TextInput label="table.field.matnrGroup.code" source="code" parse={v => v} validate={required()} /> - </Grid> */} + </Grid> <Grid item xs={6} display="flex" gap={1}> <NumberInput label="table.field.matnrGroup.parentId" diff --git a/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupEdit.jsx b/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupEdit.jsx index ad0a7d7..b2d9744 100644 --- a/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupEdit.jsx +++ b/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupEdit.jsx @@ -31,29 +31,59 @@ Stack, Grid, Box, + TextField } from '@mui/material'; import DialogCloseButton from "@/page/components/DialogCloseButton"; import TreeSelectInput from "@/page/components/TreeSelectInput"; -import { useWatch, useFormContext } from "react-hook-form"; +import { useWatch, useFormContext, useFieldArray } from "react-hook-form"; import * as Common from '@/utils/common'; import { EDIT_MODE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting'; import EditBaseAside from "@/page/components/EditBaseAside"; import CustomerTopToolBar from "@/page/components/EditTopToolBar"; import MemoInput from "@/page/components/MemoInput"; import StatusSelectInput from "@/page/components/StatusSelectInput"; - +import request from '@/utils/request'; const EditContent = ({ editRecord }) => { const { resource } = useCreateContext(); + const translate = useTranslate(); + + const { update } = useFieldArray({ name: "parCode" }) + + const pChange = (val) => { + if (val > 0) { + http(val) + } + } + + + + const http = async (val) => { + const res = await request.post(`/matnrGroup/page`, { id: val }); + const code = res.data.data.records[0].code || '' + // setpCode(code) + editRecord.parCode = code; + update(code) + } return ( <Grid container rowSpacing={2} columnSpacing={2}> <Grid item xs={6} display="flex" gap={1}> <TreeSelectInput label="table.field.matnrGroup.parentId" validate={[required()]} - value={editRecord?.parentId} isTranslate resource={resource} + onChange={(e) => pChange(e.target.value)} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.matnrGroup.parCode" + validate={[required()]} + source="parCode" + value={editRecord?.parCode} + parse={v => v} + disabled /> </Grid> <Grid item xs={6} display="flex" gap={1}> @@ -64,13 +94,14 @@ validate={required()} /> </Grid> - {/* <Grid item xs={6} display="flex" gap={1}> + <Grid item xs={6} display="flex" gap={1}> <TextInput label="table.field.matnrGroup.code" source="code" parse={v => v} + disabled={!!editRecord} /> - </Grid> */} + </Grid> </Grid> ) } diff --git a/rsf-admin/src/page/components/TreeSelectInput.jsx b/rsf-admin/src/page/components/TreeSelectInput.jsx index 8243ce1..569451a 100644 --- a/rsf-admin/src/page/components/TreeSelectInput.jsx +++ b/rsf-admin/src/page/components/TreeSelectInput.jsx @@ -5,7 +5,7 @@ import * as Common from '@/utils/common'; import { useFormContext } from 'react-hook-form'; -const TreeSelectInput = ({ resource, label, source = 'parentId', value, isTranslate = false, ...rest }) => { +const TreeSelectInput = ({ resource, onChange, label, source = 'parentId', value, isTranslate = false, ...rest }) => { const translate = useTranslate(); const { setValue } = useFormContext(); const [filter, setFilter] = React.useState(""); @@ -38,6 +38,7 @@ shouldValidate: true, shouldDirty: true, }); + onChange(event) }; return ( diff --git a/rsf-admin/src/page/system/role/AssignPermissions.jsx b/rsf-admin/src/page/system/role/AssignPermissions.jsx index 134163b..a70bc66 100644 --- a/rsf-admin/src/page/system/role/AssignPermissions.jsx +++ b/rsf-admin/src/page/system/role/AssignPermissions.jsx @@ -2,6 +2,7 @@ import { useTranslate, useNotify, + TextInput } from 'react-admin'; import { Box, Button, Card, Stack, CardContent, Skeleton } from '@mui/material'; import { SimpleTreeView, TreeItem, RichTreeView, useTreeViewApiRef } from '@mui/x-tree-view'; @@ -36,7 +37,7 @@ }) } const http = async () => { - const res = await request.post('/menu' + '/tree', {}); + const res = await request.post('/menu' + '/tree', { condition: '' }); if (res?.data?.code === 200) { const transformData = transformTree(res.data.data); setTreeData(transformData); @@ -191,9 +192,20 @@ </Button> </Box> <Box sx={{ + display: 'flex', + justifyContent: 'flex-start' + }}> + + <Button startIcon={<SaveIcon />} variant="contained" onClick={handleSave}> + {translate('ra.action.save')} + </Button> + </Box> + + <Box sx={{ height: 480, minWidth: 290, overflow: 'auto', + marginTop: '10px', padding: 1, borderBottom: '1px solid background.paper', borderRadius: '4px', @@ -223,14 +235,7 @@ </Box> </Box> - <Box sx={{ - display: 'flex', - justifyContent: 'flex-start' - }}> - <Button startIcon={<SaveIcon />} variant="contained" onClick={handleSave}> - {translate('ra.action.save')} - </Button> - </Box> + </CardContent> </Card> </> -- Gitblit v1.9.1