| | |
| | | # VITE_BASE_IP=192.168.4.24 |
| | | VITE_BASE_IP=47.76.147.249 |
| | | VITE_BASE_IP=192.168.4.24 |
| | | # VITE_BASE_IP=47.76.147.249 |
| | | VITE_BASE_PORT=8080 |
| | |
| | | maxPack: "MaxPack", |
| | | flagLabelMange: "FlagLabelMange", |
| | | locAttrs: "LocAttrs", |
| | | useStatus: 'useStatus' |
| | | }, |
| | | container: { |
| | | code: "Code", |
| | |
| | | startBay: "起始列", |
| | | startLev: "起始层", |
| | | startRow: "起始排", |
| | | useStatus: '库位状态' |
| | | }, |
| | | |
| | | container: { |
| | |
| | | import { Add, Edit, Delete } from '@mui/icons-material'; |
| | | import _ from 'lodash'; |
| | | import { DataGrid } from '@mui/x-data-grid'; |
| | | import DictionarySelect from "../components/DictionarySelect"; |
| | | |
| | | const AsnOrderModal = (props) => { |
| | | const { open, setOpen, asnId } = props; |
| | |
| | | |
| | | const [tabelData, setTableData] = useState([]); |
| | | |
| | | const handleChange = (e) => { |
| | | const { name, value } = e.target; |
| | | |
| | | const handleChange = (value, name) => { |
| | | setFormData((prevData) => ({ |
| | | ...prevData, |
| | | [name]: value |
| | |
| | | </Box> |
| | | </DialogTitle> |
| | | <DialogContent sx={{ mt: 2 }}> |
| | | <Box component="form" sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}> |
| | | <form> |
| | | <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}> |
| | | <Form> |
| | | <Grid container spacing={2}> |
| | | <Grid item xs={4}> |
| | | <TextField |
| | | label={translate('table.field.asnOrder.type')} |
| | | <DictionarySelect |
| | | label={translate("table.field.asnOrder.type")} |
| | | name="type" |
| | | value={formData.type} |
| | | onChange={handleChange} |
| | | onBlur={requestSetHead} |
| | | variant="outlined" |
| | | onChange={(e) => handleChange(+e.target.value, 'type')} |
| | | size="small" |
| | | required |
| | | dictTypeCode="sys_bill_type" |
| | | /> |
| | | |
| | | </Grid> |
| | | |
| | | {/* <Grid item xs={4}> |
| | |
| | | /> |
| | | </Grid> */} |
| | | </Grid> |
| | | </form> |
| | | </Form> |
| | | </Box> |
| | | |
| | | <Box sx={{ mt: 2 }}> |
| | |
| | | import { Add, Edit, Delete } from '@mui/icons-material'; |
| | | import _ from 'lodash'; |
| | | import { DataGrid } from '@mui/x-data-grid'; |
| | | |
| | | import StatusSelectInput from "../../components/StatusSelectInput"; |
| | | |
| | | |
| | | |
| | |
| | | const notify = useNotify(); |
| | | |
| | | const [formData, setFormData] = useState({ |
| | | "areaId": undefined, |
| | | "locType": "", |
| | | "type": "" |
| | | "areaId": null, |
| | | "type": null, |
| | | 'status': null |
| | | }); |
| | | |
| | | const { selectedIds } = useListContext(); |
| | | |
| | | const handleClose = (event, reason) => { |
| | | if (reason !== "backdropClick") { |
| | | setOpen(false); |
| | | reset() |
| | | refresh(); |
| | | } |
| | | }; |
| | | |
| | | const reset = () => { |
| | | setFormData({ |
| | | "areaId": null, |
| | | "type": null, |
| | | 'status': null |
| | | }) |
| | | } |
| | | |
| | | const handleReset = (e) => { |
| | | e.preventDefault(); |
| | |
| | | const handleChange = (value, name) => { |
| | | setFormData((prevData) => ({ |
| | | ...prevData, |
| | | [name]: ['locType', 'type'].includes(name) ? value : +value |
| | | [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 res = await request.post(`/loc/init`, formData); |
| | | const parmas = { |
| | | id: selectedIds, |
| | | loc: removeEmptyKeys(formData) |
| | | } |
| | | |
| | | const res = await request.post(`/loc/modify`, parmas); |
| | | if (res?.data?.code === 200) { |
| | | setOpen(false); |
| | | refresh(); |
| | | handleClose() |
| | | |
| | | } else { |
| | | notify(res.data.msg); |
| | | } |
| | | } |
| | | |
| | | |
| | | return ( |
| | | <Dialog open={open} maxWidth="md" fullWidth> |
| | |
| | | optionText="name" |
| | | onChange={(value) => handleChange(value, 'areaId')} |
| | | value={formData.areaId} |
| | | validate={[required()]} |
| | | filterToQuery={(val) => ({ name: val })} |
| | | /> |
| | | </ReferenceInput> |
| | |
| | | |
| | | <Grid item xs={4}> |
| | | <DictionarySelect |
| | | label={translate("table.field.loc.locType")} |
| | | name="locType" |
| | | value={formData.locType} |
| | | onChange={(e) => handleChange(e.target.value, 'locType')} |
| | | size="small" |
| | | validate={[required()]} |
| | | dictTypeCode="sys_width_type" |
| | | /> |
| | | </Grid> |
| | | |
| | | <Grid item xs={4}> |
| | | <DictionarySelect |
| | | label={translate("table.field.loc.type")} |
| | | name="type" |
| | | value={formData.type} |
| | | onChange={(e) => handleChange(e.target.value, 'type')} |
| | | onChange={(e) => handleChange(+e.target.value, 'type')} |
| | | size="small" |
| | | validate={[required()]} |
| | | dictTypeCode="sys_loc_type" |
| | | /> |
| | | </Grid> |
| | | |
| | | <Grid item xs={4}> |
| | | <StatusSelectInput |
| | | onChange={(e) => handleChange(e.target.value, 'status')} |
| | | defaultValue={''} |
| | | require={false} |
| | | /> |
| | | </Grid> |
| | | |
| | | </Grid> |
| | | |
| | |
| | | const handleChange = (value, name) => { |
| | | setFormData((prevData) => ({ |
| | | ...prevData, |
| | | [name]: ['locType', 'type'].includes(name) ? value : +value |
| | | [name]: value |
| | | })); |
| | | }; |
| | | |
| | |
| | | label={translate("table.field.loc.startBay")} |
| | | name="startBay" |
| | | value={formData.startBay} |
| | | onChange={(e) => handleChange(e.target.value, 'startBay')} |
| | | onChange={(e) => handleChange(+e.target.value, 'startBay')} |
| | | size="small" |
| | | type="number" |
| | | validate={[required()]} |
| | |
| | | label={translate("table.field.loc.startLev")} |
| | | name="startLev" |
| | | value={formData.startLev} |
| | | onChange={(e) => handleChange(e.target.value, 'startLev')} |
| | | onChange={(e) => handleChange(+e.target.value, 'startLev')} |
| | | size="small" |
| | | type="number" |
| | | validate={[required()]} |
| | |
| | | label={translate("table.field.loc.startRow")} |
| | | name="startRow" |
| | | value={formData.startRow} |
| | | onChange={(e) => handleChange(e.target.value, 'startRow')} |
| | | onChange={(e) => handleChange(+e.target.value, 'startRow')} |
| | | size="small" |
| | | type="number" |
| | | validate={[required()]} |
| | |
| | | label={translate("table.field.loc.endBay")} |
| | | name="endBay" |
| | | value={formData.endBay} |
| | | onChange={(e) => handleChange(e.target.value, 'endBay')} |
| | | onChange={(e) => handleChange(+e.target.value, 'endBay')} |
| | | size="small" |
| | | type="number" |
| | | validate={[required()]} |
| | |
| | | label={translate("table.field.loc.endLev")} |
| | | name="endLev" |
| | | value={formData.endLev} |
| | | onChange={(e) => handleChange(e.target.value, 'endLev')} |
| | | onChange={(e) => handleChange(+e.target.value, 'endLev')} |
| | | size="small" |
| | | type="number" |
| | | validate={[required()]} |
| | |
| | | label={translate("table.field.loc.endRow")} |
| | | name="endRow" |
| | | value={formData.endRow} |
| | | onChange={(e) => handleChange(e.target.value, 'endRow')} |
| | | onChange={(e) => handleChange(+e.target.value, 'endRow')} |
| | | size="small" |
| | | type="number" |
| | | validate={[required()]} |
| | |
| | | } |
| | | rowClick={() => false} |
| | | expand={() => <LocPanel />} |
| | | omit={['id', 'createTime', 'createBy', 'memo']} |
| | | omit={['id', 'createTime', 'createBy', 'memo', 'updateTime', 'updateBy']} |
| | | > |
| | | <NumberField source="id" /> |
| | | <NumberField source="warehouseId$" label="table.field.loc.warehouseId" /> |
| | |
| | | const record = useRecordContext(); |
| | | const notify = useNotify(); |
| | | const refresh = useRefresh(); |
| | | const { selectedIds } = useListContext(); |
| | | console.log(selectedIds) |
| | | |
| | | |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | |
| | |
| | | </> |
| | | |
| | | ) |
| | | } |
| | | const CustomBulkActionButton = () => { |
| | | const { selectedIds } = useListContext(); |
| | | const notify = useNotify(); |
| | | const refresh = useRefresh(); |
| | | |
| | | const handleCustomBulkAction = async () => { |
| | | if (selectedIds.length === 0) { |
| | | notify('请选择要操作的记录'); |
| | | return; |
| | | } |
| | | // 这里写具体的批量操作逻辑,例如向服务器发送请求 |
| | | try { |
| | | const res = await request.post('/loc/bulk-action', { ids: selectedIds }); |
| | | if (res?.data?.code === 200) { |
| | | refresh(); |
| | | notify('批量操作成功'); |
| | | } else { |
| | | notify(res.data.msg); |
| | | } |
| | | } catch (error) { |
| | | notify('批量操作失败,请稍后重试'); |
| | | } |
| | | }; |
| | | |
| | | return ( |
| | | <Button onClick={handleCustomBulkAction} label="自定义批量操作"> |
| | | {/* 可以添加自定义图标 */} |
| | | <EditIcon /> |
| | | </Button> |
| | | ); |
| | | }; |
| | | } |
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 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"; |
| | | |
| | | |
| | | |
| | | const InitModal = ({ open, setOpen }) => { |
| | | const refresh = useRefresh(); |
| | | const translate = useTranslate(); |
| | | |
| | | |
| | | const notify = useNotify(); |
| | | |
| | | const [formData, setFormData] = useState({ |
| | | 'status': null |
| | | }); |
| | | |
| | | const { selectedIds } = useListContext(); |
| | | |
| | | const handleClose = (event, reason) => { |
| | | if (reason !== "backdropClick") { |
| | | setOpen(false); |
| | | reset() |
| | | refresh(); |
| | | } |
| | | }; |
| | | |
| | | const reset = () => { |
| | | setFormData({ |
| | | 'status': 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 = { |
| | | 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 />}> |
| | | 确认 |
| | | </Button> |
| | | </Box> |
| | | </DialogActions> |
| | | </Form> |
| | | </Dialog> |
| | | ); |
| | | } |
| | | |
| | | export default InitModal; |
| | |
| | | import MatListAside from './MatnrListAside'; |
| | | import { display, height } from "@mui/system"; |
| | | import DashboardIcon from '@mui/icons-material/Dashboard'; |
| | | import EditIcon from '@mui/icons-material/Edit'; |
| | | import request from '@/utils/request'; |
| | | import BatchModal from './BatchModal'; |
| | | |
| | | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ |
| | | '& .css-1vooibu-MuiSvgIcon-root': { |
| | |
| | | |
| | | <StyledDatagrid |
| | | preferenceKey='matnr' |
| | | bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} |
| | | bulkActionButtons={<> <BatchButton /><BulkDeleteButton mutationMode={OPERATE_MODE} /></>} |
| | | rowClick={(id, resource, record) => false} |
| | | expand={() => <MatnrPanel />} |
| | | expandSingle={true} |
| | |
| | | </Button>) |
| | | |
| | | ) |
| | | } |
| | | |
| | | 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} |
| | | /> |
| | | </> |
| | | |
| | | ) |
| | | } |
| | |
| | | |
| | | const DictionarySelect = (props) => { |
| | | const { dictTypeCode, name, ...parmas } = props; |
| | | const { selectedIds } = useListContext(); |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | | const [list, setList] = useState([]) |
| | |
| | | setList(res.data.data.records.map((item) => { |
| | | return { |
| | | id: item.value, |
| | | name: item.value |
| | | name: item.label |
| | | } |
| | | })) |
| | | } else { |
| | |
| | | } from 'react-admin'; |
| | | |
| | | const StatusSelectInput = (props) => { |
| | | const { require = true, defaultValue = 1, ...rest } = props |
| | | const translate = useTranslate(); |
| | | |
| | | return ( |
| | | <SelectInput |
| | | label={translate('common.field.status')} |
| | | source="status" |
| | | validate={[required()]} |
| | | validate={[require && required()]} |
| | | choices={[ |
| | | { id: '1', name: 'common.enums.statusTrue' }, |
| | | { id: '0', name: 'common.enums.statusFalse' }, |
| | | ]} |
| | | defaultValue={1} |
| | | defaultValue={defaultValue} |
| | | helperText={false} |
| | | {...props} |
| | | {...rest} |
| | | /> |
| | | ) |
| | | } |