fix:input disabled不能更新bug
| | |
| | | size="small" |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={4}> |
| | | <TextField |
| | | label={translate('table.field.matnr.groupId')} |
| | | name="groupId" |
| | | value={formData.groupId} |
| | | onChange={handleChange} |
| | | variant="outlined" |
| | | size="small" |
| | | /> |
| | | </Grid> |
| | | </Grid> |
| | | </Box> |
| | | <Box sx={{ mt: 2 }}> |
| | |
| | | DeleteButton, |
| | | useRefresh, |
| | | Button, |
| | | useList |
| | | useList, |
| | | } from 'react-admin'; |
| | | import { Box, Typography, Card, Stack } from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | |
| | | const filters = [ |
| | | <SearchInput source="condition" alwaysOn />, |
| | | |
| | | <TextInput source="warehouseId$" label="table.field.loc.warehouseId" />, |
| | | <TextInput source="areaId$" label="table.field.loc.areaId" />, |
| | | <ReferenceInput |
| | | source="warehouseId" |
| | | label="table.field.loc.warehouseId" |
| | | reference="warehouse" |
| | | alwaysOn |
| | | > |
| | | <AutocompleteInput |
| | | label="table.field.loc.warehouseId" |
| | | optionText="name" |
| | | filterToQuery={(val) => ({ name: val })} |
| | | /> |
| | | </ReferenceInput>, |
| | | <ReferenceInput |
| | | source="areaId" |
| | | label="table.field.loc.areaId" |
| | | reference="warehouseAreas" |
| | | alwaysOn |
| | | > |
| | | <AutocompleteInput |
| | | label="table.field.loc.areaId" |
| | | optionText="name" |
| | | filterToQuery={(val) => ({ name: val })} |
| | | /> |
| | | </ReferenceInput>, |
| | | <TextInput source="code" label="table.field.loc.code" />, |
| | | <TextInput source="type" label="table.field.loc.type" />, |
| | | <TextInput source="name" label="table.field.loc.name" />, |
| | |
| | | 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; |
| | | editRecord && (editRecord.parCode = code); |
| | | update(code) |
| | | } |
| | | return ( |
| | |
| | | source="parCode" |
| | | value={editRecord?.parCode} |
| | | parse={v => v} |
| | | disabled |
| | | readOnly |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | |
| | | label="table.field.matnrGroup.code" |
| | | source="code" |
| | | parse={v => v} |
| | | disabled={!!editRecord} |
| | | readOnly={!!editRecord} |
| | | /> |
| | | </Grid> |
| | | </Grid> |
| | |
| | | const onSubmit = (data) => { |
| | | const _params = { ...data }; |
| | | if (editRecord) { |
| | | debugger |
| | | if (_params.parentId === editRecord.id) { |
| | | notify('common.response.dataError', { type: 'error' }); |
| | | return; |
| | |
| | | useNotify, |
| | | TextInput |
| | | } from 'react-admin'; |
| | | import { Box, Button, Card, Stack, CardContent, Skeleton } from '@mui/material'; |
| | | import { Box, Button, Card, Stack, CardContent, Skeleton, TextField } from '@mui/material'; |
| | | import { SimpleTreeView, TreeItem, RichTreeView, useTreeViewApiRef } from '@mui/x-tree-view'; |
| | | import SaveIcon from '@mui/icons-material/Save'; |
| | | import request from '@/utils/request' |
| | |
| | | const [treeData, setTreeData] = useState([]); |
| | | const [selectedItems, setSelectedItems] = useState([]); |
| | | const [expandedItems, setExpandedItems] = useState([]); |
| | | const [parmas, setParmas] = useState({ condition: '' }); |
| | | const toggledItemRef = useRef({}); |
| | | const apiRef = useTreeViewApiRef(); |
| | | |
| | | useEffect(() => { |
| | | reload() |
| | | }, [role, originMenuIds]) |
| | | |
| | | const reload = () => { |
| | | setSelectedItems(originMenuIds.map(item => item + "")); |
| | | |
| | | const transformTree = (treeData) => { |
| | |
| | | }) |
| | | } |
| | | const http = async () => { |
| | | const res = await request.post('/menu' + '/tree', { condition: '' }); |
| | | const res = await request.post('/menu/tree', parmas); |
| | | if (res?.data?.code === 200) { |
| | | const transformData = transformTree(res.data.data); |
| | | setTreeData(transformData); |
| | |
| | | setTimeout(() => { |
| | | http(); |
| | | }, 200); |
| | | }, [role, originMenuIds]) |
| | | } |
| | | |
| | | |
| | | const getAllItemItemIds = () => { |
| | |
| | | }) |
| | | } |
| | | |
| | | const search = (e) => { |
| | | const value = e.target.value; |
| | | setParmas({ |
| | | ...parmas, |
| | | condition: value |
| | | }) |
| | | reload() |
| | | |
| | | } |
| | | |
| | | return ( |
| | | <> |
| | | <Card sx={{ |
| | |
| | | </Box> |
| | | <Box sx={{ |
| | | display: 'flex', |
| | | justifyContent: 'flex-start' |
| | | justifyContent: 'space-between', |
| | | alignItems: 'center' |
| | | }}> |
| | | |
| | | <Button startIcon={<SaveIcon />} variant="contained" onClick={handleSave}> |
| | | <TextField sx={{ width: '200px' }} label="搜索菜单" variant="outlined" value={parmas.condition} onChange={(e) => search(e)} /> |
| | | <Button startIcon={<SaveIcon />} size="small" variant="contained" onClick={handleSave} sx={{ height: '40px' }}> |
| | | {translate('ra.action.save')} |
| | | </Button> |
| | | </Box> |
New file |
| | |
| | | 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'; |
| | | import StatusSelectInput from "../components/StatusSelectInput"; |
| | | |
| | | const InitModal = ({ open, setOpen }) => { |
| | | const refresh = useRefresh(); |
| | | const translate = useTranslate(); |
| | | |
| | | |
| | | const notify = useNotify(); |
| | | |
| | | const [formData, setFormData] = useState({ |
| | | 'status': null |
| | | }); |
| | | |
| | | const { selectedIds, onUnselectItems } = useListContext(); |
| | | |
| | | const handleClose = (event, reason) => { |
| | | if (reason !== "backdropClick") { |
| | | setOpen(false); |
| | | reset() |
| | | refresh(); |
| | | onUnselectItems() |
| | | } |
| | | }; |
| | | |
| | | const reset = () => { |
| | | setFormData({ |
| | | 'status': null |
| | | }) |
| | | } |
| | | |
| | | const handleReset = (e) => { |
| | | e.preventDefault(); |
| | | }; |
| | | |
| | | const handleChange = (value, name) => { |
| | | setFormData((prevData) => ({ |
| | | ...prevData, |
| | | [name]: 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 = { |
| | | id: selectedIds, |
| | | matnr: removeEmptyKeys(formData) |
| | | } |
| | | |
| | | const res = await request.post(`/matnr/modify`, 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.batch')}</DialogTitle> |
| | | <DialogContent sx={{ mt: 2 }}> |
| | | <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}> |
| | | <Grid container spacing={2}> |
| | | <Grid item xs={4}> |
| | | <StatusSelectInput |
| | | onChange={(e) => handleChange(e.target.value, 'status')} |
| | | defaultValue={''} |
| | | require={false} |
| | | /> |
| | | </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; |
| | |
| | | ReferenceArrayInput, |
| | | AutocompleteInput, |
| | | DeleteButton, |
| | | useRefresh, |
| | | Button |
| | | } from 'react-admin'; |
| | | import { Box, Typography, Card, Stack } from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | |
| | | import MyCreateButton from "../components/MyCreateButton"; |
| | | import MyExportButton from '../components/MyExportButton'; |
| | | import PageDrawer from "../components/PageDrawer"; |
| | | import MyField from "../components/MyField"; |
| | | import BatchModal from "./BatchModal"; |
| | | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; |
| | | import * as Common from '@/utils/common'; |
| | | import EditIcon from '@mui/icons-material/Edit'; |
| | | |
| | | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ |
| | | '& .css-1vooibu-MuiSvgIcon-root': { |
| | |
| | | > |
| | | <StyledDatagrid |
| | | preferenceKey='warehouseAreas' |
| | | bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} |
| | | bulkActionButtons={ |
| | | <> |
| | | <BatchButton /> |
| | | <BulkDeleteButton mutationMode={OPERATE_MODE} /> |
| | | </> |
| | | } |
| | | rowClick={(id, resource, record) => false} |
| | | omit={['id', 'createTime', 'createBy', 'memo']} |
| | | > |
| | |
| | | } |
| | | |
| | | export default WarehouseAreasList; |
| | | |
| | | |
| | | const BatchButton = () => { |
| | | const record = useRecordContext(); |
| | | const notify = useNotify(); |
| | | const refresh = useRefresh(); |
| | | |
| | | |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | |
| | | return ( |
| | | <> |
| | | <Button onClick={() => setCreateDialog(true)} label={"toolbar.batch"}> |
| | | <EditIcon /> |
| | | </Button> |
| | | |
| | | <BatchModal |
| | | open={createDialog} |
| | | setOpen={setCreateDialog} |
| | | /> |
| | | </> |
| | | |
| | | ) |
| | | } |