#
vincentlu
3 天以前 89ca1eb19972e8f5e0baccbaffcfa7fbb2ae85c3
#
1个文件已添加
4个文件已修改
109 ■■■■ 已修改文件
zy-acs-flow/src/i18n/en.js 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/i18n/zh.js 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/page/components/ConfirmButton.jsx 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/page/lane/LaneDeleteAllButton.jsx 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/page/lane/LaneList.jsx 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/i18n/en.js
@@ -654,6 +654,11 @@
                entryAngle: 'Set the lane entry angle (0-360). -1 means no restriction',
                maximum: 'Adjust the maximum load capacity. -1 means no restriction',
            },
            actions: {
                deleteAll: 'DELETE ALL',
                deleteAllSuccess: 'Delete all successfully.',
                deleteAllError: 'Failed to delete all.',
            },
        },
        agv: {
            show: {
zy-acs-flow/src/i18n/zh.js
@@ -654,6 +654,11 @@
                entryAngle: '设置车体进入巷道角度 (0-360),-1表示无限制',
                maximum: '调整巷道车体承载量,-1表示无限制',
            },
            actions: {
                deleteAll: '清空巷道',
                deleteAllSuccess: '巷道已全部删除',
                deleteAllError: '清空巷道失败',
            },
        },
        agv: {
            show: {
zy-acs-flow/src/page/components/ConfirmButton.jsx
@@ -1,11 +1,11 @@
import React, { useState, useRef, useEffect, useMemo, useCallback } from "react";
import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@mui/material';
import {
    useTranslate,
    useTranslate
} from 'react-admin';
const ConfirmButton = (props) => {
    const { label, onConfirm, data, ...rest } = props;
    const { label, onConfirm, renderButton, ...rest } = props;
    const translate = useTranslate();
    const buttonRef = useRef(null);
    const [open, setOpen] = useState(false);
@@ -25,8 +25,18 @@
        onConfirm();
    };
    return (
        <>
    const buttonElement = renderButton
        ? renderButton({
            buttonProps: {
                ref: buttonRef,
                onClick: handleClickOpen,
                'aria-label': translate(label),
                ...rest,
            },
            label,
            translate,
        })
        : (
            <Button
                ref={buttonRef}
                onClick={handleClickOpen}
@@ -35,6 +45,11 @@
            >
                {translate(label)}
            </Button>
        );
    return (
        <>
            {buttonElement}
            <Dialog
                aria-labelledby="dialog-title"
                aria-describedby="dialog-description"
zy-acs-flow/src/page/lane/LaneDeleteAllButton.jsx
New file
@@ -0,0 +1,55 @@
import React, { useCallback, useState } from "react";
import DeleteSweepIcon from '@mui/icons-material/DeleteSweep';
import {
    useDataProvider,
    useNotify,
    useRefresh,
    Button as RaButton,
} from 'react-admin';
import ConfirmButton from "../components/ConfirmButton";
const LaneDeleteAllButton = () => {
    const dataProvider = useDataProvider();
    const notify = useNotify();
    const refresh = useRefresh();
    const [loading, setLoading] = useState(false);
    const handleConfirm = useCallback(() => {
        setLoading(true);
        dataProvider.delete('lane', {
            id: '__purge_all__',
            meta: { deleteAll: true },
        }).then(() => {
            notify('page.lane.actions.deleteAllSuccess', { type: 'info' });
            refresh();
        }).catch((error) => {
            console.error(error);
            notify('page.lane.actions.deleteAllError', { type: 'error' });
        }).finally(() => {
            setLoading(false);
        });
    }, [dataProvider, notify, refresh]);
    return (
        <ConfirmButton
            label="page.lane.actions.deleteAll"
            onConfirm={handleConfirm}
            disabled={loading}
            renderButton={({ buttonProps }) => (
                <RaButton
                    {...buttonProps}
                    label="page.lane.actions.deleteAll"
                    color="error"
                    size="small"
                    startIcon={<DeleteSweepIcon />}
                    sx={{
                        fontWeight: 600,
                        textTransform: 'none',
                    }}
                />
            )}
        />
    );
};
export default LaneDeleteAllButton;
zy-acs-flow/src/page/lane/LaneList.jsx
@@ -43,6 +43,7 @@
import MyField from "../components/MyField";
import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
import * as Common from '@/utils/common';
import LaneDeleteAllButton from "./LaneDeleteAllButton";
const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
    '& .css-1vooibu-MuiSvgIcon-root': {
@@ -70,18 +71,18 @@
const filters = [
    <SearchInput source="condition" alwaysOn />,
    <DateInput label='common.time.after' source="timeStart" alwaysOn />,
    <DateInput label='common.time.before' source="timeEnd" alwaysOn />,
    // <DateInput label='common.time.after' source="timeStart" alwaysOn />,
    // <DateInput label='common.time.before' source="timeEnd" alwaysOn />,
    <TextInput source="uuid" label="table.field.lane.uuid" />,
    // <TextInput source="uuid" label="table.field.lane.uuid" />,
    <ReferenceInput source="zoneId" label="table.field.lane.zoneId" reference="zone">
        <AutocompleteInput label="table.field.lane.zoneId" optionText="name" filterToQuery={(val) => ({ name: val })} />
    </ReferenceInput>,
    <TextInput source="name" label="table.field.lane.name" />,
    <TextInput source="hashCode" label="table.field.lane.hashCode" />,
    <TextInput source="codes" label="table.field.lane.codes" />,
    <NumberInput source="entryAngle" label="table.field.lane.entryAngle" />,
    <NumberInput source="maximum" label="table.field.lane.maximum" />,
    // <TextInput source="name" label="table.field.lane.name" />,
    // <TextInput source="hashCode" label="table.field.lane.hashCode" />,
    // <TextInput source="codes" label="table.field.lane.codes" />,
    // <NumberInput source="entryAngle" label="table.field.lane.entryAngle" />,
    // <NumberInput source="maximum" label="table.field.lane.maximum" />,
    <TextInput label="common.field.memo" source="memo" />,
    <SelectInput
@@ -92,6 +93,7 @@
            { id: '0', name: 'common.enums.statusFalse' },
        ]}
        resettable
        alwaysOn
    />,
]
@@ -118,8 +120,9 @@
                sort={{ field: "create_time", order: "desc" }}
                actions={(
                    <TopToolbar>
                        <FilterButton />
                        {/* <FilterButton /> */}
                        {/* <MyCreateButton onClick={() => { setCreateDialog(true) }} /> */}
                        <LaneDeleteAllButton />
                        <SelectColumnsButton preferenceKey='lane' />
                        <MyExportButton />
                    </TopToolbar>