#
luxiaotao1123
2024-11-07 20419510279545aabfe27b0d7e8638bbf105dc9f
#
2个文件已修改
1个文件已添加
139 ■■■■ 已修改文件
zy-acs-flow/src/page/loc/BulkUpdateButton.jsx 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/page/loc/LocList.jsx 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/LocController.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/page/loc/BulkUpdateButton.jsx
New file
@@ -0,0 +1,96 @@
// src/components/BulkUpdateButton.js
import React, { useState } from 'react';
import { useUpdateMany, useRefresh, useNotify, useUnselectAll, Button as RaButton } from 'react-admin';
import { Dialog, DialogActions, DialogContent, DialogTitle, TextField, Select, MenuItem } from '@mui/material';
import UpdateIcon from '@mui/icons-material/Update';
const BulkUpdateButton = ({ selectedIds, resource, label }) => {
    console.log('BulkUpdateButton rendered with selectedIds:', selectedIds);
    const [open, setOpen] = useState(false);
    const [formData, setFormData] = useState({});
    // Hooks 调用顺序调整
    const refresh = useRefresh();
    const notify = useNotify();
    const unselectAll = useUnselectAll(resource);
    const [updateMany, { loading }] = useUpdateMany(
        resource,
        { ids: selectedIds, data: formData },
        {
            onSuccess: () => {
                setOpen(false);
                refresh();
                notify('批量更新成功', { type: 'success' });
                unselectAll();
            },
            onError: (error) => {
                notify(`批量更新失败: ${error.message}`, { type: 'warning' });
            }
        }
    );
    const handleOpen = () => setOpen(true);
    const handleClose = () => setOpen(false);
    const handleChange = (e) => {
        const { name, value } = e.target;
        setFormData({
            ...formData,
            [name]: value,
        });
    };
    const handleSubmit = () => {
        updateMany();
    };
    return (
        <>
            <RaButton onClick={handleOpen} startIcon={<UpdateIcon />} label={label || '批量修改'}>
                {/* 如果使用 React-Admin 的 Button,可以省略子节点 */}
            </RaButton>
            <Dialog open={open} onClose={handleClose}>
                <DialogTitle>批量修改</DialogTitle>
                <DialogContent>
                    {/* 使用 Select 组件限制状态值 */}
                    <Select
                        margin="dense"
                        name="status"
                        label="状态"
                        fullWidth
                        variant="standard"
                        onChange={handleChange}
                        defaultValue=""
                    >
                        <MenuItem value="">
                            <em>无</em>
                        </MenuItem>
                        <MenuItem value="1">启用</MenuItem>
                        <MenuItem value="0">禁用</MenuItem>
                    </Select>
                    <TextField
                        margin="dense"
                        name="memo"
                        label="备注"
                        type="text"
                        fullWidth
                        variant="standard"
                        onChange={handleChange}
                    />
                </DialogContent>
                <DialogActions>
                    <RaButton onClick={handleClose} color="primary">
                        取消
                    </RaButton>
                    <RaButton onClick={handleSubmit} color="primary" disabled={loading}>
                        确认
                    </RaButton>
                </DialogActions>
            </Dialog>
        </>
    );
};
export default BulkUpdateButton;
zy-acs-flow/src/page/loc/LocList.jsx
@@ -46,6 +46,7 @@
import CorporateFareIcon from '@mui/icons-material/CorporateFare';
import LocInit from "./LocInit";
import rowSx from "./rowSx";
import BulkUpdateButton from "./BulkUpdateButton";
const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
    '& .css-1vooibu-MuiSvgIcon-root': {
@@ -67,21 +68,21 @@
    <ReferenceInput source="locSts" label="table.field.loc.locSts" reference="locSts" alwaysOn>
        <AutocompleteInput label="table.field.loc.locSts" optionText="name" filterToQuery={(val) => ({ name: val })} />
    </ReferenceInput>,
    <DateInput label='common.time.after' source="timeStart" alwaysOn />,
    <DateInput label='common.time.before' source="timeEnd" alwaysOn />,
    <NumberInput source="row" label="table.field.loc.row" alwaysOn />,
    <NumberInput source="bay" label="table.field.loc.bay" alwaysOn />,
    <NumberInput source="lev" label="table.field.loc.lev" alwaysOn />,
    <SearchInput source="condition" alwaysOn />,
    <ReferenceInput source="code" label="table.field.loc.code" reference="code" alwaysOn>
        <AutocompleteInput label="table.field.loc.code" optionText="data" filterToQuery={(val) => ({ data: val })} />
    </ReferenceInput>,
    <DateInput label='common.time.after' source="timeStart" />,
    <DateInput label='common.time.before' source="timeEnd" />,
    <TextInput source="uuid" label="table.field.loc.uuid" />,
    <ReferenceInput source="zoneId" label="table.field.loc.zoneId" reference="zone">
        <AutocompleteInput label="table.field.loc.zoneId" optionText="name" filterToQuery={(val) => ({ name: val })} />
    </ReferenceInput>,
    <TextInput source="name" label="table.field.loc.name" />,
    <ReferenceInput source="code" label="table.field.loc.code" reference="code" alwaysOn>
        <AutocompleteInput label="table.field.loc.code" optionText="data" filterToQuery={(val) => ({ data: val })} />
    </ReferenceInput>,
    <SearchInput source="condition" alwaysOn />,
    <NumberInput source="offset" label="table.field.loc.offset" />,
    <NumberInput source="row" label="table.field.loc.row" alwaysOn />,
    <NumberInput source="bay" label="table.field.loc.bay" alwaysOn />,
    <NumberInput source="lev" label="table.field.loc.lev" alwaysOn />,
    <TextInput source="barcode" label="table.field.loc.barcode" />,
    <TextInput source="zpallet" label="table.field.loc.zpallet" />,
    <ReferenceInput source="locType" label="table.field.loc.locType" reference="locType">
@@ -98,6 +99,22 @@
        ]}
    />,
]
const LocBulkActionButtons = (props) => {
    const translate = useTranslate();
    return (
        <>
            <BulkUpdateButton
                {...props}
                resource="loc"
                label={translate('ra.action.update')}
            />
            <BulkDeleteButton mutationMode={OPERATE_MODE} />
        </>
    );
};
const LocList = () => {
    const translate = useTranslate();
@@ -136,7 +153,7 @@
            >
                <StyledDatagrid
                    preferenceKey='loc'
                    bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />}
                    bulkActionButtons={<LocBulkActionButtons />}
                    rowClick={(id, resource, record) => false}
                    expand={() => <LocPanel />}
                    expandSingle={true}
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/LocController.java
@@ -2,20 +2,18 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zy.acs.common.utils.GsonUtils;
import com.zy.acs.common.utils.Utils;
import com.zy.acs.framework.common.Cools;
import com.zy.acs.framework.common.R;
import com.zy.acs.framework.exception.CoolException;
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.common.utils.ExcelUtil;
import com.zy.acs.manager.manager.controller.param.LocInitParam;
import com.zy.acs.manager.manager.entity.Loc;
import com.zy.acs.manager.manager.entity.Zone;
import com.zy.acs.manager.manager.enums.LocStsType;
import com.zy.acs.manager.manager.service.LocService;
import com.zy.acs.manager.manager.service.ZoneService;
import com.zy.acs.manager.system.controller.BaseController;
@@ -41,7 +39,7 @@
    public R page(@RequestBody Map<String, Object> map) {
        BaseParam baseParam = buildParam(map, BaseParam.class);
        PageParam<Loc, BaseParam> pageParam = new PageParam<>(baseParam, Loc.class);
        return R.ok().add(locService.page(pageParam, pageParam.buildWrapper(true)));
        return R.ok().add(locService.page(pageParam, pageParam.buildWrapper(false)));
    }
    @PreAuthorize("hasAuthority('manager:loc:list')")