From 17924fac6b08fb267a2d3622e5743fd0002775a6 Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期二, 16 十二月 2025 08:37:56 +0800
Subject: [PATCH] #
---
zy-acs-flow/src/map/areaSettings/AreaBasicTab.jsx | 31 ++++++++++++++-
zy-acs-flow/src/map/areaSettings/index.jsx | 42 +++++++++++++++-----
2 files changed, 59 insertions(+), 14 deletions(-)
diff --git a/zy-acs-flow/src/map/areaSettings/AreaBasicTab.jsx b/zy-acs-flow/src/map/areaSettings/AreaBasicTab.jsx
index cda3851..0d4f5f2 100644
--- a/zy-acs-flow/src/map/areaSettings/AreaBasicTab.jsx
+++ b/zy-acs-flow/src/map/areaSettings/AreaBasicTab.jsx
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { useMemo } from 'react';
import {
Stack,
TextField,
@@ -23,6 +23,8 @@
codeList,
onSave,
disableSave,
+ onDelete,
+ canDelete = false,
}) => {
const translate = useTranslate();
const icon = <CheckBoxOutlineBlankIcon fontSize="small" />;
@@ -34,6 +36,26 @@
const getOptionId = (option) => {
return option?.id;
+ };
+
+ const handleSaveClick = () => {
+ if (disableSave) {
+ return;
+ }
+ const confirmMsg = translate('page.map.area.saveConfirm', { _: '纭淇濆瓨褰撳墠淇敼锛�' });
+ if (window.confirm(confirmMsg)) {
+ onSave?.();
+ }
+ };
+
+ const handleDeleteClick = () => {
+ if (!canDelete) {
+ return;
+ }
+ const confirmMsg = translate('page.map.area.deleteConfirm', { _: '鍒犻櫎鍚庡皢鏃犳硶鎭㈠锛岀‘璁ゅ垹闄わ紵' });
+ if (window.confirm(confirmMsg)) {
+ onDelete?.();
+ }
};
return (
@@ -148,10 +170,13 @@
</Paper>
</Box>
- <Box display="flex" justifyContent="flex-start">
- <Button variant="contained" onClick={onSave} disabled={disableSave}>
+ <Box display="flex" justifyContent="space-between" alignItems="center">
+ <Button variant="contained" onClick={handleSaveClick} disabled={disableSave}>
{translate('common.action.save', { _: '淇濆瓨' })}
</Button>
+ <Button variant="text" color="error" onClick={handleDeleteClick} disabled={!canDelete}>
+ {translate('common.action.delete', { _: '鍒犻櫎' })}
+ </Button>
</Box>
</Stack>
);
diff --git a/zy-acs-flow/src/map/areaSettings/index.jsx b/zy-acs-flow/src/map/areaSettings/index.jsx
index 103ac33..1c340fd 100644
--- a/zy-acs-flow/src/map/areaSettings/index.jsx
+++ b/zy-acs-flow/src/map/areaSettings/index.jsx
@@ -1,4 +1,4 @@
-import React, { useState, useEffect, useMemo } from 'react';
+import React, { useState, useEffect } from 'react';
import { useTranslate } from "react-admin";
import {
Drawer,
@@ -17,7 +17,7 @@
import { PAGE_DRAWER_WIDTH } from '@/config/setting';
import AreaBasicTab from './AreaBasicTab';
import AreaAdvancedTab from './AreaAdvancedTab';
-import { getAreaInfo, fetchAgvListAll } from '../http';
+import { getAreaInfo, fetchAgvListAll, updateAreaData, removeArea } from '../http';
const getAgvOptionId = (option) => {
if (typeof option === 'string') {
@@ -120,16 +120,35 @@
setActiveTab(newValue);
};
- const handleSaveBasic = () => {
- // console.log({
- // name,
- // agvIds: agvList.map(getAgvOptionId),
- // });
- // placeholder for save logic
- setInitialBasic({
+ const handleSaveBasic = async () => {
+ const areaId = sprite?.data?.id;
+ if (!areaId) {
+ return;
+ }
+ const payload = {
+ areaId,
name,
agvIds: agvList.map(getAgvOptionId),
- });
+ };
+ const success = await updateAreaData(payload);
+ if (success) {
+ setInitialBasic({
+ name,
+ agvIds: payload.agvIds,
+ });
+ fetchAreaInfo(areaId);
+ }
+ };
+
+ const handleDeleteArea = async () => {
+ const areaId = sprite?.data?.id;
+ if (!areaId) {
+ return;
+ }
+ const success = await removeArea(areaId);
+ if (success) {
+ onCancel?.();
+ }
};
const handleSaveAdvanced = () => {
@@ -141,7 +160,6 @@
agvList.map(getAgvOptionId),
initialBasic.agvIds
);
-
return (
<>
<Drawer
@@ -204,6 +222,8 @@
codeList={codeList}
onSave={handleSaveBasic}
disableSave={!basicDirty}
+ onDelete={handleDeleteArea}
+ canDelete={Boolean(sprite?.data?.id)}
/>
)}
{activeTab === 1 && (
--
Gitblit v1.9.1