From 2b152fc6bf1e6a7ab799f8ad882a19ec763bc1a6 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期五, 13 九月 2024 13:11:19 +0800 Subject: [PATCH] # --- zy-acs-flow/src/page/staType/StaTypeEdit.jsx | 97 +++++++++ zy-acs-flow/src/page/staType/StaTypePanel.jsx | 63 ++++++ zy-acs-framework/src/main/resources/templates/react-admin/Sql.txt | 6 zy-acs-flow/src/i18n/en.js | 5 zy-acs-manager/src/main/java/com/zy/acs/manager/common/CodeBuilder.java | 4 zy-acs-flow/src/page/ResourceContent.js | 3 zy-acs-flow/src/page/staType/StaTypeCreate.jsx | 125 ++++++++++++ zy-acs-flow/src/i18n/zh.js | 5 zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/StaTypeController.java | 111 +++++++++++ zy-acs-flow/src/page/staType/index.jsx | 18 + zy-acs-flow/src/page/staType/StaTypeList.jsx | 146 ++++++++++++++ 11 files changed, 578 insertions(+), 5 deletions(-) diff --git a/zy-acs-flow/src/i18n/en.js b/zy-acs-flow/src/i18n/en.js index f1ec13e..1c8e170 100644 --- a/zy-acs-flow/src/i18n/en.js +++ b/zy-acs-flow/src/i18n/en.js @@ -91,6 +91,7 @@ equipment: 'Equipment', zone: 'Zone', staSts: 'Station Status', + staType: 'Station Type', }, table: { field: { @@ -200,6 +201,10 @@ uuid: "uuid", name: "name", }, + staType: { + uuid: "uuid", + name: "name", + }, } } }; diff --git a/zy-acs-flow/src/i18n/zh.js b/zy-acs-flow/src/i18n/zh.js index 428ff51..0ed3cbe 100644 --- a/zy-acs-flow/src/i18n/zh.js +++ b/zy-acs-flow/src/i18n/zh.js @@ -91,6 +91,7 @@ equipment: '璁惧绠$悊', zone: '搴撳尯绠$悊', staSts: '绔欑偣鐘舵��', + staType: '绔欑偣绫诲瀷', }, table: { field: { @@ -199,6 +200,10 @@ uuid: "缂栧彿", name: "鍚嶇О", }, + staType: { + uuid: "缂栧彿", + name: "鍚嶇О", + }, } } }; diff --git a/zy-acs-flow/src/page/ResourceContent.js b/zy-acs-flow/src/page/ResourceContent.js index 76d400e..a3d35d9 100644 --- a/zy-acs-flow/src/page/ResourceContent.js +++ b/zy-acs-flow/src/page/ResourceContent.js @@ -15,6 +15,7 @@ import operationRecord from './operationRecord'; import zone from './zone'; import staSts from './staSts'; +import staType from './staType'; const ResourceContent = (node) => { switch (node.component) { @@ -40,6 +41,8 @@ return zone; case 'staSts': return staSts; + case 'staType': + return staType; default: return { list: ListGuesser, diff --git a/zy-acs-flow/src/page/staType/StaTypeCreate.jsx b/zy-acs-flow/src/page/staType/StaTypeCreate.jsx new file mode 100644 index 0000000..fb6a788 --- /dev/null +++ b/zy-acs-flow/src/page/staType/StaTypeCreate.jsx @@ -0,0 +1,125 @@ +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 StaTypeCreate = (props) => { + const { open, setOpen } = 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 (data) => { + notify('common.response.fail'); + }; + + return ( + <> + <CreateBase + 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> + <Grid container rowSpacing={2} columnSpacing={2}> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.staType.uuid" + source="uuid" + parse={v => v} + autoFocus + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.staType.name" + source="name" + 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 StaTypeCreate; diff --git a/zy-acs-flow/src/page/staType/StaTypeEdit.jsx b/zy-acs-flow/src/page/staType/StaTypeEdit.jsx new file mode 100644 index 0000000..9293cb3 --- /dev/null +++ b/zy-acs-flow/src/page/staType/StaTypeEdit.jsx @@ -0,0 +1,97 @@ +import React, { useState, useRef, useEffect, useMemo } from "react"; +import { + Edit, + 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 } from '@mui/material'; +import * as Common from '@/utils/common'; +import { EDIT_MODE } from '@/config/setting'; +import EditBaseAside from "../components/EditBaseAside"; +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 StaTypeEdit = () => { + const translate = useTranslate(); + + return ( + <Edit + redirect="list" + mutationMode={EDIT_MODE} + actions={<CustomerTopToolBar />} + aside={<EditBaseAside />} + > + <SimpleForm + shouldUnregister + warnWhenUnsavedChanges + toolbar={<FormToolbar />} + mode="onTouched" + defaultValues={{}} + // validate={(values) => { }} + > + <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.staType.uuid" + source="uuid" + parse={v => v} + autoFocus + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.staType.name" + source="name" + parse={v => v} + /> + </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> + </SimpleForm> + </Edit > + ) +} + +export default StaTypeEdit; diff --git a/zy-acs-flow/src/page/staType/StaTypeList.jsx b/zy-acs-flow/src/page/staType/StaTypeList.jsx new file mode 100644 index 0000000..5e82b40 --- /dev/null +++ b/zy-acs-flow/src/page/staType/StaTypeList.jsx @@ -0,0 +1,146 @@ +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, + useListContext, + useCreatePath, + TextField, + NumberField, + DateField, + BooleanField, + ReferenceField, + TextInput, + DateTimeInput, + DateInput, + SelectInput, + NumberInput, + ReferenceInput, + ReferenceArrayInput, + AutocompleteInput, + DeleteButton, +} from 'react-admin'; +import { Box, Typography, Card, Stack } from '@mui/material'; +import { styled } from '@mui/material/styles'; +import StaTypeCreate from "./StaTypeCreate"; +import StaTypePanel from "./StaTypePanel"; +import EmptyData from "../components/EmptyData"; +import MyCreateButton from "../components/MyCreateButton"; +import MyExportButton from '../components/MyExportButton'; +import PageDrawer from "../components/PageDrawer"; +import MyField from "../components/MyField"; +import { PAGE_DRAWER_WIDTH, OPERATE_MODE } from '@/config/setting'; +import * as Common from '@/utils/common'; + +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 />, + <DateInput label='common.time.after' source="timeStart" alwaysOn />, + <DateInput label='common.time.before' source="timeEnd" alwaysOn />, + + <TextInput source="uuid" label="table.field.staType.uuid" />, + <TextInput source="name" label="table.field.staType.name" />, + + <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' }, + ]} + />, +] + +const StaTypeList = () => { + const translate = useTranslate(); + + const [createDialog, setCreateDialog] = useState(false); + const [drawerVal, setDrawerVal] = useState(false); + + return ( + <Box display="flex"> + <List + sx={{ + flexGrow: 1, + transition: (theme) => + theme.transitions.create(['all'], { + duration: theme.transitions.duration.enteringScreen, + }), + marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, + }} + title={"menu.staType"} + empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} + filters={filters} + sort={{ field: "create_time", order: "desc" }} + actions={( + <TopToolbar> + <FilterButton /> + <MyCreateButton onClick={() => { setCreateDialog(true) }} /> + <SelectColumnsButton preferenceKey='staType' /> + <MyExportButton /> + </TopToolbar> + )} + perPage={25} + > + <StyledDatagrid + preferenceKey='staType' + bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} + rowClick={(id, resource, record) => false} + expand={() => <StaTypePanel />} + expandSingle={true} + omit={['id', 'createTime', 'memo']} + > + <NumberField source="id" /> + <TextField source="uuid" label="table.field.staType.uuid" /> + <TextField source="name" label="table.field.staType.name" /> + + <DateField source="updateTime" label="common.field.updateTime" showTime /> + <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' }} /> + <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> + </WrapperField> + </StyledDatagrid> + </List> + <StaTypeCreate + open={createDialog} + setOpen={setCreateDialog} + /> + <PageDrawer + title='StaType Detail' + drawerVal={drawerVal} + setDrawerVal={setDrawerVal} + > + </PageDrawer> + </Box> + ) +} + +export default StaTypeList; diff --git a/zy-acs-flow/src/page/staType/StaTypePanel.jsx b/zy-acs-flow/src/page/staType/StaTypePanel.jsx new file mode 100644 index 0000000..8d865e0 --- /dev/null +++ b/zy-acs-flow/src/page/staType/StaTypePanel.jsx @@ -0,0 +1,63 @@ +import React, { useState, useRef, useEffect, useMemo } from "react"; +import { Box, Card, CardContent, Grid, Typography, Tooltip } from '@mui/material'; +import { + useTranslate, + useRecordContext, +} from 'react-admin'; +import PanelTypography from "../components/PanelTypography"; +import * as Common from '@/utils/common' + +const StaTypePanel = () => { + const record = useRecordContext(); + if (!record) return null; + const translate = useTranslate(); + return ( + <> + <Card sx={{ width: { xs: 300, sm: 500, md: 600, lg: 800 }, margin: 'auto' }}> + <CardContent> + <Grid container spacing={2}> + <Grid item xs={12} sx={{ display: 'flex', justifyContent: 'space-between' }}> + <Typography variant="h6" gutterBottom align="left" sx={{ + maxWidth: { xs: '100px', sm: '180px', md: '260px', lg: '360px' }, + whiteSpace: 'nowrap', + overflow: 'hidden', + textOverflow: 'ellipsis', + }}> + {Common.camelToPascalWithSpaces(translate('table.field.staType.name'))}: {record.name} + </Typography> + {/* inherit, primary, secondary, textPrimary, textSecondary, error */} + <Typography variant="h6" gutterBottom align="right" > + ID: {record.id} + </Typography> + </Grid> + </Grid> + <Grid container spacing={2}> + <Grid item xs={12} container alignContent="flex-end"> + <Typography variant="caption" color="textSecondary" sx={{ wordWrap: 'break-word', wordBreak: 'break-all' }}> + {Common.camelToPascalWithSpaces(translate('common.field.memo'))}:{record.memo} + </Typography> + </Grid> + </Grid> + <Box height={20}> </Box> + <Grid container spacing={2}> + <Grid item xs={6}> + <PanelTypography + title="table.field.staType.uuid" + property={record.uuid} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.staType.name" + property={record.name} + /> + </Grid> + + </Grid> + </CardContent> + </Card > + </> + ); +}; + +export default StaTypePanel; diff --git a/zy-acs-flow/src/page/staType/index.jsx b/zy-acs-flow/src/page/staType/index.jsx new file mode 100644 index 0000000..cd4277b --- /dev/null +++ b/zy-acs-flow/src/page/staType/index.jsx @@ -0,0 +1,18 @@ +import React, { useState, useRef, useEffect, useMemo } from "react"; +import { + ListGuesser, + EditGuesser, + ShowGuesser, +} from "react-admin"; + +import StaTypeList from "./StaTypeList"; +import StaTypeEdit from "./StaTypeEdit"; + +export default { + list: StaTypeList, + edit: StaTypeEdit, + show: ShowGuesser, + recordRepresentation: (record) => { + return `${record.name}` + } +}; diff --git a/zy-acs-framework/src/main/resources/templates/react-admin/Sql.txt b/zy-acs-framework/src/main/resources/templates/react-admin/Sql.txt index 9954776..f251079 100644 --- a/zy-acs-framework/src/main/resources/templates/react-admin/Sql.txt +++ b/zy-acs-framework/src/main/resources/templates/react-admin/Sql.txt @@ -7,12 +7,12 @@ insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `tenant_id`, `status`) values ( 'Update @{TABLEDESC}', '', '1', '@{ITEMNAME}:@{SIMPLEENTITYNAME}:update', '2', '1', '1'); insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `tenant_id`, `status`) values ( 'Delete @{TABLEDESC}', '', '1', '@{ITEMNAME}:@{SIMPLEENTITYNAME}:remove', '3', '1', '1'); --- locale field -@{SIMPLEENTITYNAME}: @{REACTLOCALECONTENT} - -- locale menu name @{SIMPLEENTITYNAME}: '@{ENTITYNAME}', +-- locale field +@{SIMPLEENTITYNAME}: @{REACTLOCALECONTENT} + -- ResourceContent import @{SIMPLEENTITYNAME} from './@{SIMPLEENTITYNAME}'; diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/common/CodeBuilder.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/common/CodeBuilder.java index acbcccc..c3e7e14 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/common/CodeBuilder.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/common/CodeBuilder.java @@ -22,8 +22,8 @@ // generator.username="sa"; // generator.password="Zoneyung@zy56$"; - generator.table="man_sta_sts"; - generator.tableDesc="StaSts"; + generator.table="man_sta_type"; + generator.tableDesc="StaType"; generator.packagePath="com.zy.acs.manager.manager"; generator.build(); diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/StaTypeController.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/StaTypeController.java new file mode 100644 index 0000000..3f6cd02 --- /dev/null +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/StaTypeController.java @@ -0,0 +1,111 @@ +package com.zy.acs.manager.manager.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zy.acs.framework.common.Cools; +import com.zy.acs.framework.common.R; +import com.zy.acs.manager.common.utils.ExcelUtil; +import com.zy.acs.manager.common.annotation.OperationLog; +import com.zy.acs.manager.common.domain.BaseParam; +import com.zy.acs.manager.common.domain.KeyValVo; +import com.zy.acs.manager.common.domain.PageParam; +import com.zy.acs.manager.manager.entity.StaType; +import com.zy.acs.manager.manager.service.StaTypeService; +import com.zy.acs.manager.system.controller.BaseController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.*; + +@RestController +@RequestMapping("/api") +public class StaTypeController extends BaseController { + + @Autowired + private StaTypeService staTypeService; + + @PreAuthorize("hasAuthority('manager:staType:list')") + @PostMapping("/staType/page") + public R page(@RequestBody Map<String, Object> map) { + BaseParam baseParam = buildParam(map, BaseParam.class); + PageParam<StaType, BaseParam> pageParam = new PageParam<>(baseParam, StaType.class); + return R.ok().add(staTypeService.page(pageParam, pageParam.buildWrapper(true))); + } + + @PreAuthorize("hasAuthority('manager:staType:list')") + @PostMapping("/staType/list") + public R list(@RequestBody Map<String, Object> map) { + return R.ok().add(staTypeService.list()); + } + + @PreAuthorize("hasAuthority('system:staType:list')") + @PostMapping({"/staType/many/{ids}", "/staTypes/many/{ids}"}) + public R many(@PathVariable Long[] ids) { + return R.ok().add(staTypeService.listByIds(Arrays.asList(ids))); + } + + @PreAuthorize("hasAuthority('manager:staType:list')") + @GetMapping("/staType/{id}") + public R get(@PathVariable("id") Long id) { + return R.ok().add(staTypeService.getById(id)); + } + + @PreAuthorize("hasAuthority('manager:staType:save')") + @OperationLog("Create StaType") + @PostMapping("/staType/save") + public R save(@RequestBody StaType staType) { + staType.setCreateBy(getLoginUserId()); + staType.setCreateTime(new Date()); + staType.setUpdateBy(getLoginUserId()); + staType.setUpdateTime(new Date()); + if (!staTypeService.save(staType)) { + return R.error("Save Fail"); + } + return R.ok("Save Success").add(staType); + } + + @PreAuthorize("hasAuthority('manager:staType:update')") + @OperationLog("Update StaType") + @PostMapping("/staType/update") + public R update(@RequestBody StaType staType) { + staType.setUpdateBy(getLoginUserId()); + staType.setUpdateTime(new Date()); + if (!staTypeService.updateById(staType)) { + return R.error("Update Fail"); + } + return R.ok("Update Success").add(staType); + } + + @PreAuthorize("hasAuthority('manager:staType:remove')") + @OperationLog("Delete StaType") + @PostMapping("/staType/remove/{ids}") + public R remove(@PathVariable Long[] ids) { + if (!staTypeService.removeByIds(Arrays.asList(ids))) { + return R.error("Delete Fail"); + } + return R.ok("Delete Success").add(ids); + } + + @PreAuthorize("hasAuthority('manager:staType:list')") + @PostMapping("/staType/query") + public R query(@RequestParam(required = false) String condition) { + List<KeyValVo> vos = new ArrayList<>(); + LambdaQueryWrapper<StaType> wrapper = new LambdaQueryWrapper<>(); + if (!Cools.isEmpty(condition)) { + wrapper.like(StaType::getName, condition); + } + staTypeService.page(new Page<>(1, 30), wrapper).getRecords().forEach( + item -> vos.add(new KeyValVo(item.getId(), item.getName())) + ); + return R.ok().add(vos); + } + + @PreAuthorize("hasAuthority('manager:staType:list')") + @PostMapping("/staType/export") + public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { + ExcelUtil.build(ExcelUtil.create(staTypeService.list(), StaType.class), response); + } + +} -- Gitblit v1.9.1