From c44442e9f84c95d88a8eb7d4dd8579780d078cdd Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期五, 11 四月 2025 13:05:14 +0800 Subject: [PATCH] #修改 字典编码规则优化 --- rsf-admin/src/page/system/dicts/dictType/DictDataEdit.jsx | 163 ++++++++++++++ rsf-admin/src/page/system/dicts/dictType/DictDataCreate.jsx | 160 ++++++++++++++ rsf-admin/src/page/system/serialRule/SerialRuleItemEdit.jsx | 158 ++++++++++++++ rsf-admin/src/page/system/dicts/dictType/DictDataList.jsx | 173 +++++++++++++++ rsf-admin/src/i18n/en.js | 3 5 files changed, 657 insertions(+), 0 deletions(-) diff --git a/rsf-admin/src/i18n/en.js b/rsf-admin/src/i18n/en.js index daf2177..c18734e 100644 --- a/rsf-admin/src/i18n/en.js +++ b/rsf-admin/src/i18n/en.js @@ -9,6 +9,9 @@ fail: "Fail", dataError: "Submit data was error, Please check", }, + button: { + edit: "Edit", + }, field: { id: 'ID', uuid: 'uuid', diff --git a/rsf-admin/src/page/system/dicts/dictType/DictDataCreate.jsx b/rsf-admin/src/page/system/dicts/dictType/DictDataCreate.jsx new file mode 100644 index 0000000..058996b --- /dev/null +++ b/rsf-admin/src/page/system/dicts/dictType/DictDataCreate.jsx @@ -0,0 +1,160 @@ +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, +} from 'react-admin'; +import { + Dialog, + DialogActions, + DialogContent, + DialogTitle, + Stack, + Grid, + Box, +} from '@mui/material'; +import DialogCloseButton from "../../../components/DialogCloseButton"; +import StatusSelectInput from "../../../components/StatusSelectInput"; +import MemoInput from "../../../components/MemoInput"; + +const DictDataCreate = (props) => { + const { open, setOpen, record } = props; + const translate = useTranslate(); + const notify = useNotify(); + + const handleClose = (event, reason) => { + if (reason !== "backdropClick") { + setOpen(false); + } + }; + + const handleSuccess = async (data) => { + setOpen(false); + notify('common.response.success'); + }; + + const handleError = async (error) => { + notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } }); + }; + + return ( + <> + <CreateBase + resource="dictData" + record={{}} + transform={(data) => { + return data; + }} + mutationOptions={{ onSuccess: handleSuccess, onError: handleError }} + > + <Dialog + open={open} + onClose={handleClose} + aria-labelledby="form-dialog-title" + fullWidth + disableRestoreFocus + maxWidth="md" // 'xs' | 'sm' | 'md' | 'lg' | 'xl' + > + <Form> + <DialogTitle id="form-dialog-title" sx={{ + position: 'sticky', + top: 0, + backgroundColor: 'background.paper', + zIndex: 1000 + }} + > + {translate('create.title')} + <Box sx={{ position: 'absolute', top: 8, right: 8, zIndex: 1001 }}> + <DialogCloseButton onClose={handleClose} /> + </Box> + </DialogTitle> + <DialogContent sx={{ mt: 2 }}> + <Grid container rowSpacing={2} columnSpacing={2}> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.dictData.dictTypeId" + source="dictTypeId" + defaultValue={record?.id} + parse={v => v} + readOnly + validate={required()} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.dictData.dictTypeCode" + source="dictTypeCode" + parse={v => v} + readOnly + defaultValue={record?.code} + validate={required()} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.dictData.value" + source="value" + parse={v => v} + validate={required()} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.dictData.label" + validate={required()} + autoFocus + source="label" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.dictData.sort" + source="sort" + /> + </Grid> + {/* <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.dictData.color" + source="color" + parse={v => v} + /> + </Grid> */} + + <Grid item xs={6} display="flex" gap={1}> + <StatusSelectInput /> + </Grid> + <Grid item xs={12} display="flex" gap={1}> + <Stack direction="column" spacing={1} width={'100%'}> + <MemoInput /> + </Stack> + </Grid> + </Grid> + </DialogContent> + <DialogActions sx={{ position: 'sticky', bottom: 0, backgroundColor: 'background.paper', zIndex: 1000 }}> + <Toolbar sx={{ width: '100%', justifyContent: 'space-between' }} > + <SaveButton /> + </Toolbar> + </DialogActions> + </Form> + </Dialog> + </CreateBase> + </> + ) +} + +export default DictDataCreate; diff --git a/rsf-admin/src/page/system/dicts/dictType/DictDataEdit.jsx b/rsf-admin/src/page/system/dicts/dictType/DictDataEdit.jsx new file mode 100644 index 0000000..c80fbfc --- /dev/null +++ b/rsf-admin/src/page/system/dicts/dictType/DictDataEdit.jsx @@ -0,0 +1,163 @@ +import React, { useState, useRef, useEffect, useMemo } from "react"; +import { + Edit, + SimpleForm, + Form, + FormDataConsumer, + useTranslate, + TextInput, + NumberInput, + BooleanInput, + DateInput, + SelectInput, + ReferenceInput, + ReferenceArrayInput, + AutocompleteInput, + SaveButton, + Toolbar, + Labeled, + NumberField, + required, + useRecordContext, + DeleteButton, + useNotify, + useRedirect, + useEditContext, + EditBase, +} from 'react-admin'; +import { useWatch, useFormContext } from "react-hook-form"; +import { Stack, Grid, Box, Typography, Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material'; +import { EDIT_MODE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting'; +import DialogCloseButton from "../../../components/DialogCloseButton"; +import EditBaseAside from "../../../components/EditBaseAside"; +import MemoInput from "../../../components/MemoInput"; +import StatusSelectInput from "../../../components/StatusSelectInput"; + +const EditToolbar = () => { + const form = useFormContext(); + const { record, isPending } = useEditContext(); + const redirect = useRedirect(); + return ( + <Toolbar sx={{ justifyContent: 'end' }}> + <SaveButton type="button" mutationOptions={{ + onSuccess: () => { + redirect('/dictType/' + record?.dictTypeId) + } + }} /> + <DeleteButton mutationMode="optimistic" /> + </Toolbar> + ) +} + +const DictDataEdit = (props) => { + const { open, setOpen, record } = props; + const translate = useTranslate(); + const handleClose = (event, reason) => { + if (reason !== "backdropClick") { + setOpen(false); + } + }; + return ( + <> + <Edit + id={record?.id} + resource="dictData" + mutationMode={EDIT_MODE} + > + <Dialog + open={open} + onClose={handleClose} + aria-labelledby="form-dialog-title" + fullWidth + disableRestoreFocus + maxWidth="md" + > + <Form> + <DialogTitle id="form-dialog-title" sx={{ + position: 'sticky', + top: 0, + backgroundColor: 'background.paper', + zIndex: 1000 + }} + > + {translate('update.title')} + <Box sx={{ position: 'absolute', top: 8, right: 8, zIndex: 1001 }}> + <DialogCloseButton onClose={handleClose} /> + </Box> + </DialogTitle> + <DialogContent sx={{ mt: 2 }}> + <Grid container width={{ xs: '100%', xl: '80%' }} rowSpacing={3} columnSpacing={3}> + <Grid item xs={12} md={8}> + <Typography variant="h6" gutterBottom> + {translate('common.edit.title.main')} + </Typography> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.dictData.dictTypeId" + source="dictTypeId" + readOnly + defaultValue={record?.id} + parse={v => v} + validate={required()} + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.dictData.dictTypeCode" + source="dictTypeCode" + defaultValue={record?.code} + readOnly + parse={v => v} + validate={required()} + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.dictData.value" + source="value" + parse={v => v} + validate={required()} + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.dictData.label" + source="label" + validate={required()} + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <NumberInput + label="table.field.dictData.sort" + source="sort" + /> + </Stack> + </Grid> + <Grid item xs={12} md={4}> + <Typography variant="h6" gutterBottom> + {translate('common.edit.title.common')} + </Typography> + <StatusSelectInput /> + <Box mt="2em" /> + <MemoInput /> + </Grid> + </Grid> + </DialogContent> + <DialogActions sx={{ position: 'sticky', bottom: 0, backgroundColor: 'background.paper', zIndex: 1000 }}> + <Toolbar sx={{ width: '100%', justifyContent: 'end' }} > + <SaveButton type="button" mutationOptions={{ + onSuccess: () => { + setOpen(false) + } + }} /> + </Toolbar> + </DialogActions> + </Form> + </Dialog> + </Edit > + </> + ) +} + +export default DictDataEdit; diff --git a/rsf-admin/src/page/system/dicts/dictType/DictDataList.jsx b/rsf-admin/src/page/system/dicts/dictType/DictDataList.jsx new file mode 100644 index 0000000..c039b96 --- /dev/null +++ b/rsf-admin/src/page/system/dicts/dictType/DictDataList.jsx @@ -0,0 +1,173 @@ +import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; +import { useNavigate, useLocation } 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, + useGetRecordId, + useGetPathForRecord, + useGetOne, + Button, +} from 'react-admin'; +import { Box, Typography, Card, Stack } from '@mui/material'; +import { styled } from '@mui/material/styles'; +import DictDataCreate from "./DictDataCreate"; +import EmptyData from "../../../components/EmptyData"; +import MyCreateButton from "../../../components/MyCreateButton"; +import MyExportButton from '../../../components/MyExportButton'; +import PageDrawer from "../../../components/PageDrawer"; +import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; +import DictDataEdit from "./DictDataEdit"; +import { use } from "react"; + + +const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ + '& .css-1vooibu-MuiSvgIcon-root': { + height: '.9em' + }, + '& .RaDatagrid-row': { + cursor: 'auto' + }, + '& .column-name': { + }, + '& .opt': { + width: 200 + }, +})); + +const filters = [ + <SearchInput source="condition" alwaysOn />, + <TextInput source="dictTypeId" label="table.field.dictData.dictTypeId" />, + <TextInput source="dictTypeCode" label="table.field.dictData.dictTypeCode" />, + <TextInput source="value" label="table.field.dictData.value" />, + <TextInput source="label" label="table.field.dictData.label" />, + <NumberInput source="sort" label="table.field.dictData.sort" />, + // <TextInput source="color" label="table.field.dictData.color" />, + <TextInput label="common.field.memo" source="memo" />, + <SelectInput + label="common.field.status" + source="status" + choices={[ + { id: '1', name: 'common.enums.statusTrue' }, + { id: '0', name: 'common.enums.statusFalse' }, + ]} + resettable + />, +] + +const DictDataList = () => { + const translate = useTranslate(); + const [createDialog, setCreateDialog] = useState(false); + const [editDialog, setEditDialog] = useState(false); + const [drawerVal, setDrawerVal] = useState(false); + const [select, setSelect] = useState({}); + const dictId = useGetRecordId(); + const { data: dicts, isPending, error } = useGetOne('dictType', { id: dictId }); + + return ( + <> + <Box display="flex" > + <List + resource="dictData" + sx={{ + flexGrow: 1, + transition: (theme) => + theme.transitions.create(['all'], { + duration: theme.transitions.duration.enteringScreen, + }), + marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, + }} + title={"menu.dictData"} + empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} + filters={filters} + filter={{ dictTypeId: dictId }} + sort={{ field: "create_time", order: "desc" }} + actions={( + <TopToolbar> + <FilterButton /> + <MyCreateButton onClick={() => { setCreateDialog(true) }} /> + <SelectColumnsButton preferenceKey='dictData' /> + <MyExportButton /> + </TopToolbar> + )} + perPage={DEFAULT_PAGE_SIZE} + > + <StyledDatagrid + bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} + rowClick={(id, resource ,record)=> { + setSelect(record) + setEditDialog(true) + }} + omit={['id', 'createTime', 'createBy', 'memo']} + > + <NumberField source="id" /> + <TextField source="dictTypeId" label="table.field.dictData.dictTypeId" /> + <TextField source="dictTypeCode" label="table.field.dictData.dictTypeCode" /> + <TextField source="value" label="table.field.dictData.value" /> + <TextField source="label" label="table.field.dictData.label" /> + <NumberField source="sort" label="table.field.dictData.sort" /> + <TextField source="updateBy$" label="common.field.updateBy" /> + <DateField source="updateTime" label="common.field.updateTime" showTime /> + <TextField source="createBy$" label="common.field.createBy" /> + <DateField source="createTime" label="common.field.createTime" showTime /> + <BooleanField source="statusBool" label="common.field.status" sortable={false} /> + <TextField source="memo" label="common.field.memo" sortable={false} /> + <WrapperField cellClassName="opt" label="common.field.opt"> + {/* <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} type="button" redirect={"/dictType/" + dictId} onClick={()=> { + setEditDialog(true) + }} /> */} + <Button onClick={()=>{setEditDialog(true)}}>缂栬緫</Button> + <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode='pessimistic' redirect={"/dictType/" + dictId} /> + </WrapperField> + </StyledDatagrid> + </List> + <DictDataEdit + open={editDialog} + record={select} + setOpen={setEditDialog} + /> + <DictDataCreate + open={createDialog} + record={dicts} + setOpen={setCreateDialog} + /> + <PageDrawer + title='DictData Detail' + drawerVal={drawerVal} + setDrawerVal={setDrawerVal} + > + </PageDrawer> + </Box> + </> + + ) +} + +export default DictDataList; diff --git a/rsf-admin/src/page/system/serialRule/SerialRuleItemEdit.jsx b/rsf-admin/src/page/system/serialRule/SerialRuleItemEdit.jsx new file mode 100644 index 0000000..ca3b86c --- /dev/null +++ b/rsf-admin/src/page/system/serialRule/SerialRuleItemEdit.jsx @@ -0,0 +1,158 @@ +import React, { useState, useRef, useEffect, useMemo } from "react"; +import { + Edit, + Form, + SimpleForm, + FormDataConsumer, + useTranslate, + TextInput, + NumberInput, + BooleanInput, + DateInput, + SelectInput, + ReferenceInput, + ReferenceArrayInput, + AutocompleteInput, + SaveButton, + Toolbar, + Labeled, + NumberField, + required, + useRecordContext, + DeleteButton, +} from 'react-admin'; +import { useWatch, useFormContext } from "react-hook-form"; +import { Stack, Grid, Box, Typography, Dialog, DialogContent, DialogTitle, DialogActions } from '@mui/material'; +import * as Common from '@/utils/common'; +import { EDIT_MODE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting'; +import EditBaseAside from "../../components/EditBaseAside"; +import DialogCloseButton from "../../components/DialogCloseButton"; +import CustomerTopToolBar from "../../components/EditTopToolBar"; +import MemoInput from "../../components/MemoInput"; +import StatusSelectInput from "../../components/StatusSelectInput"; + +const FormToolbar = () => { + const { getValues } = useFormContext(); + + return ( + <Toolbar sx={{ justifyContent: 'space-between' }}> + <SaveButton /> + <DeleteButton mutationMode="optimistic" /> + </Toolbar> + ) +} + +const SerialRuleItemEdit = (props) => { + const { open, setOpen, record } = props; + const translate = useTranslate(); + const handleClose = (event, reason) => { + if (reason !== "backdropClick") { + setOpen(false); + } + }; + return ( + <Edit + id={record.id} + redirect="list" + resource="serialRuleItem" + mutationMode={EDIT_MODE} + > + <Dialog + open={open} + onClose={handleClose} + aria-labelledby="form-dialog-title" + fullWidth + disableRestoreFocus + maxWidth="md" + > + <Form + shouldUnregister + warnWhenUnsavedChanges + toolbar={<FormToolbar />} + mode="onTouched" + defaultValues={{}} + > + <DialogTitle id="form-dialog-title" sx={{ + position: 'sticky', + top: 0, + backgroundColor: 'background.paper', + zIndex: 1000 + }} + > + {translate('update.title')} + <Box sx={{ position: 'absolute', top: 8, right: 8, zIndex: 1001 }}> + <DialogCloseButton onClose={handleClose} /> + </Box> + </DialogTitle> + <DialogContent> + <Grid container width={{ xs: '100%', xl: '80%' }} rowSpacing={3} columnSpacing={3}> + <Grid item xs={12} md={8}> + <Typography variant="h6" gutterBottom> + {translate('common.edit.title.main')} + </Typography> + <Stack direction='row' gap={2}> + <NumberInput + label="table.field.serialRuleItem.ruleId" + source="ruleId" + readOnly + autoFocus + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.serialRuleItem.wkType" + source="wkType$" + readOnly + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.serialRuleItem.feildValue" + source="feildValue" + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <NumberInput + label="table.field.serialRuleItem.len" + source="len" + /> + </Stack> + <Stack direction='row' gap={2}> + <NumberInput + label="table.field.serialRuleItem.lenStr" + source="lenStr" + validate={required()} + /> + </Stack> + <Stack direction='row' gap={2}> + <NumberInput + label="table.field.serialRuleItem.sort" + source="sort" + validate={required()} + /> + </Stack> + + </Grid> + <Grid item xs={12} md={4}> + <Typography variant="h6" gutterBottom> + {translate('common.edit.title.common')} + </Typography> + <StatusSelectInput /> + <Box mt="2em" /> + <MemoInput /> + </Grid> + </Grid> + </DialogContent> + <DialogActions> + + </DialogActions> + </Form> + + </Dialog> + </Edit > + ) +} + +export default SerialRuleItemEdit; -- Gitblit v1.9.1