+
0
? (
-
-
- {detail.roomImages.map((img, index) => (
-
- ))}
-
-
- )
- : (
- "无"
- ),
+
+
+ {detail.roomImages.map((img, index) => (
+
+ ))}
+
+
+ )
+ : "-",
span: 2,
},
]}
@@ -207,10 +214,8 @@ function View(props) {
columns={deviceColumns}
dataSource={detail.devices || []}
pagination={false}
- rowKey={(record, index) => index}
+ rowKey={(record, index) => record.id || `device-${index}`}
locale={{ emptyText: "暂无设备信息" }}
- bordered
- tableLayout="fixed"
/>
@@ -219,26 +224,17 @@ function View(props) {
columns={personnelColumns}
dataSource={detail.persons || []}
pagination={false}
- rowKey={(record, index) => index}
+ rowKey={(record, index) => record.id || `person-${index}`}
locale={{ emptyText: "暂无人员信息" }}
- bordered
- tableLayout="fixed"
/>
-
-
)}
);
diff --git a/src/pages/Container/BranchCompany/PumpRoom/Add/index.js b/src/pages/Container/BranchCompany/PumpRoom/Add/index.js
index 65425cf..3e1842e 100644
--- a/src/pages/Container/BranchCompany/PumpRoom/Add/index.js
+++ b/src/pages/Container/BranchCompany/PumpRoom/Add/index.js
@@ -1,7 +1,8 @@
-import { Permission } from "@cqsjjb/jjb-common-decorator/permission";
+import { Permission } from "@cqsjjb/jjb-common-decorator/permission";
import { Connect } from "@cqsjjb/jjb-dva-runtime";
-import { Button, Card, Col, Form, Input, InputNumber, message, Row, Space, Table } from "antd";
+import { Button, Card, Col, Form, Input, message, Row, Space, Table } from "antd";
import { useEffect, useState } from "react";
+import MapSelector from "zy-react-library/components/Map/MapSelector";
import Page from "zy-react-library/components/Page";
import DictionarySelect from "zy-react-library/components/Select/Dictionary";
import Upload from "zy-react-library/components/Upload";
@@ -17,6 +18,9 @@ function Add(props) {
const [form] = Form.useForm();
const [loading, setLoading] = useState(false);
const [submitting, setSubmitting] = useState(false);
+ const [mapOpen, setMapOpen] = useState(false);
+ const [mapLng, setMapLng] = useState("");
+ const [mapLat, setMapLat] = useState("");
// 设备信息列表
const [devices, setDeviceList] = useState([]);
@@ -43,7 +47,7 @@ function Add(props) {
// 设置设备列表
if (data.devices && data.devices.length > 0) {
- setDeviceList(data.devices.map((item, index) => ({ ...item, key: index })));
+ setDeviceList(data.devices.map((item, index) => ({ ...item, key: item.id || index })));
}
}
catch (error) {
@@ -56,7 +60,18 @@ function Add(props) {
useEffect(() => {
query.id && getData();
- }, []);
+ }, [query.id]);
+
+ const openMap = () => {
+ setMapLng(form.getFieldValue("lng") || "");
+ setMapLat(form.getFieldValue("lat") || "");
+ setMapOpen(true);
+ };
+
+ const handleMapConfirm = (lng, lat) => {
+ form.setFieldsValue({ lng, lat });
+ setMapOpen(false);
+ };
const onFinish = async (values) => {
// 验证设备列表
@@ -67,16 +82,17 @@ function Add(props) {
// 验证设备列表是否填写完整
const invalidDevice = devices.find(
- item => !item.deviceName || !item.deviceModel || !item.deviceQty || !item.deviceLocation,
+ item => !item.deviceCode || !item.deviceName || !item.deviceCategory
+ || !item.chargeUnit || !item.deviceLocation || !item.paramsSpec,
);
if (invalidDevice) {
message.warning("请完善设备信息");
return;
}
- // 楠岃瘉鍥剧墖鏄惁涓婁紶
+ // 验证图片是否上传
if (!values.roomImages || values.roomImages.length === 0) {
- message.warning("璇蜂笂浼犳秷闃叉车鎴垮浘鐗?");
+ message.warning("请上传消防泵房图片");
return;
}
@@ -102,9 +118,10 @@ function Add(props) {
devices: devices.map(({ key, ...device }) => ({
deviceCode: device.deviceCode,
deviceName: device.deviceName,
- deviceModel: device.deviceModel,
- deviceQty: device.deviceQty,
+ deviceCategory: device.deviceCategory,
+ chargeUnit: device.chargeUnit,
deviceLocation: device.deviceLocation,
+ paramsSpec: device.paramsSpec,
...(device.id && { id: device.id }),
})),
};
@@ -128,10 +145,12 @@ function Add(props) {
const addDevice = () => {
const newDevice = {
key: Date.now(),
+ deviceCode: "",
deviceName: "",
- deviceModel: "",
- deviceQty: null,
+ deviceCategory: "",
+ chargeUnit: "",
deviceLocation: "",
+ paramsSpec: "",
};
setDeviceList([...devices, newDevice]);
};
@@ -154,6 +173,7 @@ function Add(props) {
设备编号
>),
dataIndex: "deviceCode",
+ width: 150,
render: (text, record) => (
),
dataIndex: "deviceName",
+ width: 150,
render: (text, record) => (
*
- 设备型号
+ 设备分类
>),
- dataIndex: "deviceModel",
+ dataIndex: "deviceCategory",
+ width: 150,
render: (text, record) => (
updateDevice(record.key, "deviceModel", e.target.value)}
+ placeholder="请输入设备分类"
+ onChange={e => updateDevice(record.key, "deviceCategory", e.target.value)}
/>
),
},
{
title: (<>
*
- 设备数量
+ 负责单位
>),
- dataIndex: "deviceQty",
+ dataIndex: "chargeUnit",
+ width: 150,
render: (text, record) => (
-
updateDevice(record.key, "deviceQty", value)}
+ placeholder="请输入负责单位"
+ onChange={e => updateDevice(record.key, "chargeUnit", e.target.value)}
/>
),
},
{
title: (<>
*
- 设备位置
+ 具体位置
>),
dataIndex: "deviceLocation",
+ width: 150,
render: (text, record) => (
updateDevice(record.key, "deviceLocation", e.target.value)}
/>
),
},
+ {
+ title: (<>
+ *
+ 设备参数和规格
+ >),
+ dataIndex: "paramsSpec",
+ width: 180,
+ render: (text, record) => (
+ updateDevice(record.key, "paramsSpec", e.target.value)}
+ />
+ ),
+ },
{
title: "操作",
- width: 80,
+ width: 100,
align: "center",
render: (_, record) => (
removeDevice(record.key)}>
@@ -241,21 +278,20 @@ function Add(props) {
@@ -407,6 +428,14 @@ function Add(props) {
+
+ setMapOpen(false)}
+ longitude={mapLng}
+ latitude={mapLat}
+ onConfirm={handleMapConfirm}
+ />
);
}
diff --git a/src/pages/Container/BranchCompany/PumpRoom/List/index.js b/src/pages/Container/BranchCompany/PumpRoom/List/index.js
index 2be7ea6..963832b 100644
--- a/src/pages/Container/BranchCompany/PumpRoom/List/index.js
+++ b/src/pages/Container/BranchCompany/PumpRoom/List/index.js
@@ -19,11 +19,14 @@ function List(props) {
const [deleting, setDeleting] = useState(false);
const [statusDict, setStatusDict] = useState([]);
+ const [initialized, setInitialized] = useState(false);
const { getDictionary } = useDictionary();
+ // 一次性初始化字典和表单
useEffect(() => {
- const fetchDict = async () => {
+ const init = async () => {
+ // 加载字典
try {
const dict = await getDictionary({ dictValue: "fire_resource_contro_root_type" });
setStatusDict(Array.isArray(dict) ? dict : []);
@@ -31,23 +34,39 @@ function List(props) {
catch (error) {
setStatusDict([]);
}
+
+ // 设置表单初始值并加载数据
+ if (query.eqCorpId) {
+ form.setFieldsValue({ eqCorpId: query.eqCorpId });
+ }
+
+ getData();
+ setInitialized(true);
};
- fetchDict();
+
+ if (!initialized) {
+ init();
+ }
}, []);
+ // 监听 eqCorpId 变化
useEffect(() => {
- if (query.eqCorpId) {
- form.setFieldsValue({ eqCorpId: query.eqCorpId });
- getData();
+ if (initialized && query.eqCorpId) {
+ const currentCorpId = form.getFieldValue("eqCorpId");
+ if (currentCorpId !== query.eqCorpId) {
+ form.setFieldsValue({ eqCorpId: query.eqCorpId });
+ getData();
+ }
}
- }, [query.eqCorpId]);
+ }, [query.eqCorpId, initialized]);
const getStatusLabel = (record) => {
- if (record.roomStatusName)
- return record.roomStatusName;
+ if (!record) return "-";
+ if (record.roomStatusName) return record.roomStatusName;
const match = statusDict.find(item => item.dictValue === record.pumpRoomStatus);
return match?.dictLabel || record.pumpRoomStatus || "-";
};
+
const onDelete = (id) => {
Modal.confirm({
title: "确认删除",
@@ -63,9 +82,12 @@ function List(props) {
setDeleting(true);
try {
await props["pumpRoomDelete"]({ id });
- message.success("已删除");
+ message.success("删除成功");
getData();
}
+ catch (error) {
+ message.error("删除失败");
+ }
finally {
setDeleting(false);
}
@@ -77,18 +99,26 @@ function List(props) {
),
},
- { name: "eqCorpId", onlyForLabel: true },
+ {
+ name: "eqCorpId",
+ onlyForLabel: true,
+ },
]}
form={form}
onFinish={getData}
/>
+
(
@@ -103,43 +133,67 @@ function List(props) {
)}
columns={[
- // { title: "序号", width: 80, align: "center", render: (_, __, index) => index + 1 },
- { title: "消防泵房名称", dataIndex: "pumpRoomName", ellipsis: true, width: 120 },
+ {
+ title: "消防泵房名称",
+ dataIndex: "pumpRoomName",
+ width: 200,
+ ellipsis: true,
+ },
{
title: "消防泵房状态",
- width: 140,
+ width: 150,
align: "center",
+ ellipsis: true,
render: (_, record) => getStatusLabel(record),
},
- { title: "负责人", dataIndex: "principalName", width: 120 },
- { title: "负责人手机号", dataIndex: "principalPhone", width: 140 },
- { title: "设备数", dataIndex: "deviceCount", width: 100, align: "center" },
+ {
+ title: "负责人",
+ dataIndex: "principalName",
+ width: 120,
+ align: "center",
+ ellipsis: true,
+ },
+ {
+ title: "负责人手机号",
+ dataIndex: "principalPhone",
+ width: 150,
+ align: "center",
+ ellipsis: true,
+ },
+ {
+ title: "设备数",
+ dataIndex: "deviceCount",
+ width: 100,
+ align: "center",
+ render: text => text || 0,
+ },
{
title: "操作",
- fixed: "right",
- width: 180,
+ width: 200,
+ align: "center",
render: (_, record) => (
-
+
{
props.history.push(`./view?id=${record.id}`);
}}
>
查看
-
{
props.history.push(`./add?id=${record.id}`);
}}
>
编辑
-
onDelete(record.id)}
>
diff --git a/src/pages/Container/BranchCompany/PumpRoom/View/index.js b/src/pages/Container/BranchCompany/PumpRoom/View/index.js
index 480917c..d4c9cc4 100644
--- a/src/pages/Container/BranchCompany/PumpRoom/View/index.js
+++ b/src/pages/Container/BranchCompany/PumpRoom/View/index.js
@@ -31,28 +31,32 @@ function View(props) {
fetchDict();
}, []);
- const getStatusLabel = (record) => {
- if (!record)
+ // 获取状态显示文本
+ const getStatusLabel = () => {
+ if (!detail)
return "-";
- if (record.roomStatusName)
- return record.roomStatusName;
- const match = statusDict.find(item => item.dictValue === record.pumpRoomStatus);
- return match?.dictLabel || record.pumpRoomStatus || "-";
+ if (detail.roomStatusName)
+ return detail.roomStatusName;
+ const match = statusDict.find(item => item.dictValue === detail.pumpRoomStatus);
+ return match?.dictLabel || detail.pumpRoomStatus || "-";
};
+
const getData = async () => {
setLoading(true);
try {
const { data } = await props["pumpRoomDetail"]({ id: query.id });
- let nextDetail = data;
+
+ // 获取图片文件
const roomKey = data.roomId || data.pumpRoomId || data.id;
if (roomKey) {
const files = await getFile({
eqType: UPLOAD_FILE_TYPE_ENUM[302],
eqForeignKey: roomKey,
});
- nextDetail = { ...data, roomImages: files };
+ data.roomImages = files;
}
- setDetail(nextDetail);
+
+ setDetail(data);
}
catch (error) {
message.error("加载详情失败");
@@ -64,16 +68,63 @@ function View(props) {
useEffect(() => {
query.id && getData();
- }, []);
+ }, [query.id]);
// 设备表格列定义
const deviceColumns = [
- { title: "序号", width: 80, align: "center", render: (_, __, index) => index + 1 },
- { title: "设备编号", dataIndex: "deviceCode", align: "center" },
- { title: "设备名称", dataIndex: "deviceName", align: "center" },
- { title: "设备型号", dataIndex: "deviceModel", align: "center" },
- { title: "设备数量", dataIndex: "deviceQty", align: "center" },
- { title: "设备位置", dataIndex: "deviceLocation", align: "center" },
+ {
+ title: "序号",
+ width: 80,
+ align: "center",
+ render: (_, __, index) => index + 1,
+ },
+ {
+ title: "设备编号",
+ dataIndex: "deviceCode",
+ width: 150,
+ align: "center",
+ ellipsis: true,
+ render: text => text || "-",
+ },
+ {
+ title: "设备名称",
+ dataIndex: "deviceName",
+ width: 150,
+ align: "center",
+ ellipsis: true,
+ render: text => text || "-",
+ },
+ {
+ title: "设备分类",
+ dataIndex: "deviceCategory",
+ width: 150,
+ align: "center",
+ ellipsis: true,
+ render: text => text || "-",
+ },
+ {
+ title: "负责单位",
+ dataIndex: "chargeUnit",
+ width: 150,
+ align: "center",
+ ellipsis: true,
+ render: text => text || "-",
+ },
+ {
+ title: "具体位置",
+ dataIndex: "deviceLocation",
+ width: 150,
+ align: "center",
+ ellipsis: true,
+ render: text => text || "-",
+ },
+ {
+ title: "设备参数和规格",
+ dataIndex: "paramsSpec",
+ align: "center",
+ ellipsis: true,
+ render: text => text || "-",
+ },
];
return (
@@ -83,59 +134,62 @@ function View(props) {
isShowFooter={false}
>
{detail && (
- <>
-
+
+
0
? (
-
-
- {detail.roomImages.map((img, index) => (
-
- ))}
-
-
- )
- : (
- "无"
- ),
+
+
+ {detail.roomImages.map((img, index) => (
+
+ ))}
+
+
+ )
+ : "-",
span: 2,
},
]}
@@ -147,17 +201,18 @@ function View(props) {
columns={deviceColumns}
dataSource={detail.devices || []}
pagination={false}
- rowKey={(record, index) => index}
+ rowKey={(record, index) => record.id || `device-${index}`}
+ scroll={{ x: 1000 }}
locale={{ emptyText: "暂无设备信息" }}
/>
-
+
props.history.goBack()}>
返回
- >
+
)}
);
diff --git a/src/pages/Container/BranchCompany/RescueTeam/Add/index.js b/src/pages/Container/BranchCompany/RescueTeam/Add/index.js
index 06ada0e..cc737d6 100644
--- a/src/pages/Container/BranchCompany/RescueTeam/Add/index.js
+++ b/src/pages/Container/BranchCompany/RescueTeam/Add/index.js
@@ -17,7 +17,7 @@ function Add(props) {
// 消防队员列表
const [rescueMembers, setRescueMembers] = useState([]);
- // ⭐ 添加状态保存字典显示名称
+ // 添加状态保存字典显示名称
const [teamTypeName, setTeamTypeName] = useState("");
const [regionScopeName, setRegionScopeName] = useState("");
@@ -33,7 +33,7 @@ function Add(props) {
form.setFieldsValue(data);
- // ⭐ 设置字典显示名称
+ // 设置字典显示名称
if (data.teamTypeName) {
setTeamTypeName(data.teamTypeName);
}
@@ -43,7 +43,7 @@ function Add(props) {
// 设置消防队员列表
if (data.rescueMembers && data.rescueMembers.length > 0) {
- setRescueMembers(data.rescueMembers.map((item, index) => ({ ...item, key: index })));
+ setRescueMembers(data.rescueMembers.map((item, index) => ({ ...item, key: item.id || index })));
}
}
catch (error) {
@@ -83,7 +83,7 @@ function Add(props) {
...values,
establishDate: values.establishDate ? values.establishDate.format("YYYY-MM-DD") : null,
- // ⭐ 从状态中获取字典显示名称
+ // 从状态中获取字典显示名称
teamTypeName,
regionScopeName,
@@ -191,23 +191,23 @@ function Add(props) {