From 1bffcfe8e886718a6d8451bb7c027960da78d9c8 Mon Sep 17 00:00:00 2001 From: shenzhidan Date: Fri, 6 Feb 2026 17:28:19 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=B6=88=E9=98=B2=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=95=B4=E4=BD=93=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 3 + .../BranchCompany/ControlRoom/Add/index.js | 111 ++++---- .../BranchCompany/ControlRoom/List/index.js | 129 ++++++--- .../BranchCompany/ControlRoom/View/index.js | 112 ++++---- .../BranchCompany/PumpRoom/Add/index.js | 155 +++++----- .../BranchCompany/PumpRoom/List/index.js | 98 +++++-- .../BranchCompany/PumpRoom/View/index.js | 145 +++++++--- .../BranchCompany/RescueTeam/Add/index.js | 95 +++---- .../BranchCompany/RescueTeam/List/index.js | 124 ++++++-- .../BranchCompany/RescueTeam/View/index.js | 44 ++- .../BranchCompany/WaterSource/Add/index.js | 96 +++---- .../BranchCompany/WaterSource/List/index.js | 93 ++++-- .../BranchCompany/WaterSource/View/index.js | 266 +++++------------- .../Supervision/FireResourceStats/index.js | 79 +++--- 14 files changed, 843 insertions(+), 707 deletions(-) diff --git a/src/main.js b/src/main.js index 7f79acf..4187033 100644 --- a/src/main.js +++ b/src/main.js @@ -11,6 +11,9 @@ require("zy-react-library/css/common.less"); dayjs.locale("zh-cn"); setJJBCommonAntdMessage(message); +window.mapLongitude = "119.69457721306945"; +window.mapLatitude = "39.940504336846665"; + const app = setup(); // 非底座环境运行 diff --git a/src/pages/Container/BranchCompany/ControlRoom/Add/index.js b/src/pages/Container/BranchCompany/ControlRoom/Add/index.js index 563624d..339c8a2 100644 --- a/src/pages/Container/BranchCompany/ControlRoom/Add/index.js +++ b/src/pages/Container/BranchCompany/ControlRoom/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 { 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 [deviceList, setDeviceList] = useState([]); @@ -36,10 +40,10 @@ function Add(props) { try { const { data } = await props["controlRoomDetail"]({ id: query.id }); - // ⭐ 如果有业务ID,查询图片文件 + // 如果有业务ID,查询图片文件 if (data.roomId) { const files = await getFile({ - eqType: UPLOAD_FILE_TYPE_ENUM[302], // 消防点检检查合格图片 + eqType: UPLOAD_FILE_TYPE_ENUM[302], eqForeignKey: data.roomId, }); data.roomImages = files; @@ -70,6 +74,17 @@ function Add(props) { query.id && getData(); }, []); + 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) => { // 验证设备列表 if (deviceList.length === 0) { @@ -109,18 +124,18 @@ function Add(props) { setSubmitting(true); try { - // ⭐ 先删除标记删除的文件 + // 先删除标记删除的文件 if (deleteFiles.length > 0) { await deleteFile({ single: false, files: deleteFiles }); } - // ⭐ 上传图片文件,获取业务ID(room_id) + // 上传图片文件,获取业务ID(room_id) const { id: roomId } = await uploadFile({ single: false, files: values.roomImages, params: { - type: UPLOAD_FILE_TYPE_ENUM[302], // ⭐ 消防点检检查合格图片 - foreignKey: values.roomId, // 编辑时传入已有的 roomId + type: UPLOAD_FILE_TYPE_ENUM[302], + foreignKey: values.roomId, }, }); @@ -129,7 +144,7 @@ function Add(props) { // 构建提交参数 const params = { ...values, - roomId, // ⭐ 使用上传返回的业务ID + roomId, // 设备列表:去掉前端添加的 key devices: deviceList.map(({ key, ...device }) => ({ deviceName: device.deviceName, @@ -213,7 +228,7 @@ function Add(props) { title: (<> * 设备名称 - ), + ), dataIndex: "deviceName", render: (text, record) => ( * 设备型号 - ), + ), dataIndex: "deviceModel", render: (text, record) => ( * 设备数量 - ), + ), dataIndex: "deviceQty", render: (text, record) => ( * 设备位置 - ), + ), dataIndex: "deviceLocation", render: (text, record) => ( * 人员姓名 - ), + ), dataIndex: "personName", render: (text, record) => ( * 人员手机号 - ), + ), dataIndex: "personPhone", render: (text, record) => ( {/* 添加隐藏字段保存 roomId */} @@ -357,8 +372,6 @@ function Add(props) { - + - + + + + + + @@ -461,10 +460,10 @@ function Add(props) { @@ -512,7 +511,7 @@ function Add(props) { dataSource={personnelList} pagination={false} rowKey="key" - locale={{ emptyText: "暂无人员信息,请点击新增按钮添加" }} + locale={{ emptyText: "暂无人员信息,请点击新增按钮添加" }} /> @@ -527,6 +526,14 @@ function Add(props) { + + setMapOpen(false)} + longitude={mapLng} + latitude={mapLat} + onConfirm={handleMapConfirm} + /> ); } diff --git a/src/pages/Container/BranchCompany/ControlRoom/List/index.js b/src/pages/Container/BranchCompany/ControlRoom/List/index.js index 3f94a62..d17e952 100644 --- a/src/pages/Container/BranchCompany/ControlRoom/List/index.js +++ b/src/pages/Container/BranchCompany/ControlRoom/List/index.js @@ -19,25 +19,14 @@ function List(props) { const [deleting, setDeleting] = useState(false); const [statusDict, setStatusDict] = useState([]); + const [initialized, setInitialized] = useState(false); const { getDictionary } = useDictionary(); + // 一次性初始化字典和表单 useEffect(() => { - if (props.location?.state?.refresh) { - getData(); - props.history.replace({ ...props.location, state: {} }); - } - }, [props.location?.state?.refresh]); - - useEffect(() => { - if (query.eqCorpId) { - form.setFieldsValue({ eqCorpId: query.eqCorpId }); - getData(); - } - }, [query.eqCorpId]); - - useEffect(() => { - const fetchDict = async () => { + const init = async () => { + // 加载字典 try { const dict = await getDictionary({ dictValue: "fire_resource_contro_root_type" }); setStatusDict(Array.isArray(dict) ? dict : []); @@ -45,13 +34,35 @@ function List(props) { catch (error) { setStatusDict([]); } + + // 设置表单初始值并加载数据 + if (query.eqCorpId) { + form.setFieldsValue({ eqCorpId: query.eqCorpId }); + } + + getData(); + setInitialized(true); }; - fetchDict(); + + if (!initialized) { + init(); + } }, []); + // 监听 eqCorpId 变化 + useEffect(() => { + if (initialized && query.eqCorpId) { + const currentCorpId = form.getFieldValue("eqCorpId"); + if (currentCorpId !== query.eqCorpId) { + form.setFieldsValue({ eqCorpId: query.eqCorpId }); + getData(); + } + } + }, [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.roomStatus); return match?.dictLabel || record.roomStatus || "-"; }; @@ -71,9 +82,12 @@ function List(props) { setDeleting(true); try { await props["controlRoomDelete"]({ id: String(id) }); - message.success("已删除"); + message.success("删除成功"); getData(); } + catch (error) { + message.error("删除失败"); + } finally { setDeleting(false); } @@ -85,29 +99,29 @@ function List(props) { ), - span: 4, - formItemProps: { style: { marginLeft: 16 } }, }, - { name: "eqCorpId", onlyForLabel: true }, + { + name: "eqCorpId", + onlyForLabel: true, + }, ]} form={form} onFinish={getData} /> + ( - {/* {props.permission("xfkzs-btn-add") && ( */} - {/* )} */} )} columns={[ - // { title: "序号", width: 80, align: "center", render: (_, __, index) => index + 1 }, - { title: "消防控制室名称", dataIndex: "roomName", ellipsis: true, width: 140 }, + { + title: "消防控制室名称", + dataIndex: "roomName", + width: 200, + ellipsis: true, + }, { title: "消防控制室状态", - width: 140, + width: 150, align: "center", + ellipsis: true, render: (_, record) => getStatusLabel(record), }, - { title: "负责人", dataIndex: "principalName", width: 120, align: "center" }, - { title: "负责人手机号", dataIndex: "principalPhone", width: 140, align: "center" }, - { title: "设备数", dataIndex: "deviceCount", width: 100, align: "center" }, - { title: "人员数", dataIndex: "personCount", 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: "人员数", + dataIndex: "personCount", + width: 100, + align: "center", + render: text => text || 0, + }, { title: "操作", - fixed: "right", - width: 180, + width: 200, + align: "center", render: (_, record) => ( - - {/* {props.permission("xfkzs-btn-view") && ( */} + - {/* )} */} - - {/* {props.permission("xfkzs-btn-edit") && ( */} - {/* )} */} - - {/* {props.permission("xfkzs-btn-delete") && ( */} - {/* )} */} ), }, diff --git a/src/pages/Container/BranchCompany/ControlRoom/View/index.js b/src/pages/Container/BranchCompany/ControlRoom/View/index.js index b99e8c9..180ce28 100644 --- a/src/pages/Container/BranchCompany/ControlRoom/View/index.js +++ b/src/pages/Container/BranchCompany/ControlRoom/View/index.js @@ -14,7 +14,6 @@ function View(props) { const [loading, setLoading] = useState(false); const [detail, setDetail] = useState(null); const [statusDict, setStatusDict] = useState([]); - const [statusLabel, setStatusLabel] = useState("-"); const { loading: dictLoading, getDictionary } = useDictionary(); const { loading: getFileLoading, getFile } = useGetFile(); @@ -24,16 +23,16 @@ function View(props) { try { const { data } = await props["controlRoomDetail"]({ id: query.id }); - let nextDetail = data; + // 获取图片文件 if (data.roomId) { const files = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM[302], eqForeignKey: data.roomId, }); - nextDetail = { ...data, roomImages: files }; + data.roomImages = files; } - setDetail(nextDetail); + setDetail(data); } catch (error) { message.error("加载详情失败"); @@ -60,19 +59,15 @@ function View(props) { fetchDict(); }, []); - useEffect(() => { + // 获取状态显示文本 + const getStatusLabel = () => { if (!detail) - return; + return "-"; const match = statusDict.find(item => item.dictValue === detail.roomStatus); - setStatusLabel(match?.dictLabel || detail.roomStatusName || detail.roomStatus || "-"); - }, [detail, statusDict]); - - const longitude = detail?.lng ?? detail?.longitude; - const latitude = detail?.lat ?? detail?.latitude; - const lngLatText = longitude != null && latitude != null - ? `${longitude}, ${latitude}` - : (longitude ?? latitude ?? "-"); + return match?.dictLabel || detail.roomStatusName || detail.roomStatus || "-"; + }; + // 设备表格列定义 const deviceColumns = [ { title: "序号", @@ -86,6 +81,7 @@ function View(props) { width: 180, align: "center", ellipsis: true, + render: text => text || "-", }, { title: "设备型号", @@ -93,22 +89,25 @@ function View(props) { width: 180, align: "center", ellipsis: true, + render: text => text || "-", }, { title: "设备数量", dataIndex: "deviceQty", - align: "center", width: 120, + align: "center", + render: text => text || 0, }, { title: "设备位置", dataIndex: "deviceLocation", align: "center", ellipsis: true, - width: 240, + render: text => text || "-", }, ]; + // 人员表格列定义 const personnelColumns = [ { title: "序号", @@ -122,6 +121,7 @@ function View(props) { width: 160, align: "center", ellipsis: true, + render: text => text || "-", }, { title: "人员手机号", @@ -129,13 +129,14 @@ function View(props) { width: 180, align: "center", ellipsis: true, + render: text => text || "-", }, { title: "人员值班情况", - render: (_, record) => record.dutyDesc || "-", + dataIndex: "dutyDesc", align: "center", ellipsis: true, - width: 240, + render: text => text || "-", }, ]; @@ -146,13 +147,17 @@ function View(props) { isShowFooter={false} > {detail && ( - <> - +
+ 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) => (
- + - + + + + + + + - - @@ -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) => ( - + - - - + )} ); 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) {
- {/* 第一行:救援队名称、类型 */} + {/* 第一行:救援队名称(单列) */} -
+ + + {/* 第二行:类型、负责人单位或部门 */} + { - // ⭐ 监听选择事件,保存显示名称 setTeamTypeName(option?.children || option?.label || ""); }} /> + + + + + + - {/* 第二行:队长、队长电话 */} + {/* 第三行:队长、队长电话 */} - {/* 第三行:指挥人员、建立日期 */} + {/* 第四行:指挥人员、建立日期 */} - {/* 第四行:所属区域或范围、职责和任务范围 */} + {/* 第五行:所属区域或范围、职责和任务范围 */} { - // ⭐ 监听选择事件,保存显示名称 setRegionScopeName(option?.children || option?.label || ""); }} /> @@ -335,37 +331,12 @@ function Add(props) { - - - - - - {/* 第五行:负责人单位或部门(单独一行) */} - - - - + @@ -385,7 +356,7 @@ function Add(props) { dataSource={rescueMembers} pagination={false} rowKey="key" - locale={{ emptyText: "暂无队员信息,请点击新增按钮添加" }} + locale={{ emptyText: "暂无队员信息,请点击新增按钮添加" }} /> diff --git a/src/pages/Container/BranchCompany/RescueTeam/List/index.js b/src/pages/Container/BranchCompany/RescueTeam/List/index.js index 6a3eddb..abbf6b6 100644 --- a/src/pages/Container/BranchCompany/RescueTeam/List/index.js +++ b/src/pages/Container/BranchCompany/RescueTeam/List/index.js @@ -8,7 +8,6 @@ import DictionarySelect from "zy-react-library/components/Select/Dictionary"; import Table from "zy-react-library/components/Table"; import useGetUrlQuery from "zy-react-library/hooks/useGetUrlQuery"; import useTable from "zy-react-library/hooks/useTable"; -import { getLabelName } from "zy-react-library/utils"; import { NS_RESCUE_TEAM } from "~/enumerate/namespace"; function List(props) { @@ -18,13 +17,29 @@ function List(props) { const { tableProps, getData } = useTable(props["rescueTeamList"], { form }); const [deleting, setDeleting] = useState(false); + const [initialized, setInitialized] = useState(false); + // 一次性初始化表单 useEffect(() => { - if (query.eqCorpId) { - form.setFieldsValue({ eqCorpId: query.eqCorpId }); + if (!initialized) { + if (query.eqCorpId) { + form.setFieldsValue({ eqCorpId: query.eqCorpId }); + } getData(); + setInitialized(true); } - }, [query.eqCorpId]); + }, []); + + // 监听 eqCorpId 变化 + useEffect(() => { + if (initialized && query.eqCorpId) { + const currentCorpId = form.getFieldValue("eqCorpId"); + if (currentCorpId !== query.eqCorpId) { + form.setFieldsValue({ eqCorpId: query.eqCorpId }); + getData(); + } + } + }, [query.eqCorpId, initialized]); const onDelete = (id) => { Modal.confirm({ @@ -41,9 +56,12 @@ function List(props) { setDeleting(true); try { await props["rescueTeamDelete"]({ id }); - message.success("已删除"); + message.success("删除成功"); getData(); } + catch (error) { + message.error("删除失败"); + } finally { setDeleting(false); } @@ -55,24 +73,42 @@ function List(props) { ), }, - { name: "likeChargeOrgDept", label: "负责人单位或部门" }, - { name: "likeCaptainName", label: "队长" }, - { name: "eqCorpId", onlyForLabel: true }, + { + name: "likeChargeOrgDept", + label: "负责人单位或部门", + }, + { + name: "likeCaptainName", + label: "队长", + }, + { + name: "eqRegionScope", + label: "所属区域或范围", + render: (), + }, + { + name: "eqCorpId", + onlyForLabel: true, + }, ]} form={form} onFinish={getData} /> +
( - {/* {props.permission("jydgl-btn-add") && ( */} - {/* )} */} )} columns={[ - // { title: "序号", width: 80, align: "center", render: (_, __, index) => index + 1 }, - { title: "救援队名称", dataIndex: "teamName", ellipsis: true }, + { + title: "救援队名称", + dataIndex: "teamName", + width: 200, + ellipsis: true, + }, { title: "类型", dataIndex: "teamTypeName", - width: 140, + width: 150, align: "center", + ellipsis: true, + }, + { + title: "负责人单位或部门", + dataIndex: "chargeOrgDept", + width: 200, + ellipsis: true, + }, + { + title: "队长", + dataIndex: "captainName", + width: 120, + align: "center", + ellipsis: true, + }, + { + title: "指挥人员", + dataIndex: "commandCrew", + width: 120, + align: "center", + ellipsis: true, + }, + { + title: "所属区域或范围", + dataIndex: "regionScopeName", + width: 150, + align: "center", + ellipsis: true, + render: text => text || "-", + }, + { + title: "队员人数", + dataIndex: "memberCount", + width: 100, + align: "center", + render: text => text || 0, }, - { title: "负责人单位或部门", dataIndex: "chargeOrgDept", ellipsis: true }, - { title: "队长", dataIndex: "captainName", width: 120, align: "center" }, - { title: "指挥人员", dataIndex: "commandCrew", width: 120, align: "center" }, - { title: "队员人数", dataIndex: "memberCount", width: 110, align: "center" }, { title: "操作", - fixed: "right", - width: 180, + width: 200, + align: "center", render: (_, record) => ( - - {/* {props.permission("jydgl-btn-view") && ( */} + - {/* )} */} - - {/* {props.permission("jydgl-btn-edit") && ( */} - {/* )} */} - - {/* {props.permission("jydgl-btn-delete") && ( */} - {/* )} */} ), }, diff --git a/src/pages/Container/BranchCompany/RescueTeam/View/index.js b/src/pages/Container/BranchCompany/RescueTeam/View/index.js index da1fb97..1383fa2 100644 --- a/src/pages/Container/BranchCompany/RescueTeam/View/index.js +++ b/src/pages/Container/BranchCompany/RescueTeam/View/index.js @@ -31,9 +31,22 @@ function View(props) { // 队员表格列定义 const memberColumns = [ - { title: "序号", width: 80, align: "center", render: (_, __, index) => index + 1 }, - { title: "队员", dataIndex: "personName" }, - { title: "队员电话", dataIndex: "personPhone" }, + { + title: "序号", + width: 80, + align: "center", + render: (_, __, index) => index + 1, + }, + { + title: "队员姓名", + dataIndex: "personName", + render: text => text || "-", + }, + { + title: "队员电话", + dataIndex: "personPhone", + render: text => text || "-", + }, ]; return ( @@ -43,14 +56,14 @@ function View(props) { isShowFooter={false} > {detail && ( - <> - +
+ @@ -100,17 +114,17 @@ function View(props) { columns={memberColumns} dataSource={detail.rescueMembers || []} pagination={false} - rowKey={(record, index) => index} + rowKey={(record, index) => record.id || `member-${index}`} locale={{ emptyText: "暂无队员信息" }} /> -
+
- +
)} ); diff --git a/src/pages/Container/BranchCompany/WaterSource/Add/index.js b/src/pages/Container/BranchCompany/WaterSource/Add/index.js index 93dd5d9..d2b02a2 100644 --- a/src/pages/Container/BranchCompany/WaterSource/Add/index.js +++ b/src/pages/Container/BranchCompany/WaterSource/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 } 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 useGetUrlQuery from "zy-react-library/hooks/useGetUrlQuery"; @@ -12,6 +13,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 getData = async () => { setLoading(true); @@ -31,6 +35,17 @@ function Add(props) { query.id && getData(); }, []); + 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) => { setSubmitting(true); try { @@ -58,9 +73,9 @@ function Add(props) { @@ -68,8 +83,6 @@ function Add(props) { - -
- + - + + + + + + - + @@ -186,8 +181,6 @@ function Add(props) { @@ -200,8 +193,6 @@ function Add(props) { @@ -212,8 +203,6 @@ function Add(props) { @@ -242,14 +229,11 @@ function Add(props) { - @@ -257,8 +241,6 @@ function Add(props) { @@ -268,7 +250,7 @@ function Add(props) { - + @@ -278,6 +260,14 @@ function Add(props) { + + setMapOpen(false)} + longitude={mapLng} + latitude={mapLat} + onConfirm={handleMapConfirm} + /> ); } diff --git a/src/pages/Container/BranchCompany/WaterSource/List/index.js b/src/pages/Container/BranchCompany/WaterSource/List/index.js index 36eb366..afe8a28 100644 --- a/src/pages/Container/BranchCompany/WaterSource/List/index.js +++ b/src/pages/Container/BranchCompany/WaterSource/List/index.js @@ -1,7 +1,7 @@ import { Permission } from "@cqsjjb/jjb-common-decorator/permission"; import { Connect } from "@cqsjjb/jjb-dva-runtime"; import { Button, Form, message, Modal, Space } from "antd"; -import { useEffect, useState } from "react"; +import { useEffect, useMemo, useRef, useState } from "react"; import Page from "zy-react-library/components/Page"; import Search from "zy-react-library/components/Search"; import DictionarySelect from "zy-react-library/components/Select/Dictionary"; @@ -15,10 +15,34 @@ function List(props) { const [form] = Form.useForm(); const query = useGetUrlQuery(); - const { tableProps, getData } = useTable(props["waterSourceList"], { form }); + const { tableProps, getData } = useTable(props["waterSourceList"], { + form, + params: () => (query.eqCorpId ? { eqCorpId: query.eqCorpId } : {}), + useStorageQueryCriteria: false, + }); const [deleting, setDeleting] = useState(false); + const corpIdRef = useRef(query.eqCorpId); const [statusDict, setStatusDict] = useState([]); + const searchOptions = useMemo(() => ([ + { + name: "likeWaterSourceName", + label: "消防水源名称", + }, + { + name: "eqWaterSourceStatus", + label: "消防水源状态", + render: (), + }, + { + name: "likeBelongOrgDept", + label: "所属单位或部门", + }, + { + name: "eqCorpId", + onlyForLabel: true, + }, + ]), []); const { getDictionary } = useDictionary(); @@ -38,15 +62,20 @@ function List(props) { useEffect(() => { if (query.eqCorpId) { form.setFieldsValue({ eqCorpId: query.eqCorpId }); - getData(); + if (corpIdRef.current !== query.eqCorpId) { + getData(); + } } + corpIdRef.current = query.eqCorpId; }, [query.eqCorpId]); const getStatusLabel = (record) => { + if (!record) + return "-"; if (record.sourceStatusName) return record.sourceStatusName; const match = statusDict.find(item => item.dictValue === record.waterSourceStatus); - return match?.dictLabel || record.sourceStatus || "-"; + return match?.dictLabel || record.waterSourceStatus || "-"; }; const onDelete = (id) => { @@ -64,9 +93,12 @@ function List(props) { setDeleting(true); try { await props["waterSourceDelete"]({ id }); - message.success("已删除"); + message.success("删除成功"); getData(); } + catch (error) { + message.error("删除失败"); + } finally { setDeleting(false); } @@ -78,19 +110,12 @@ function List(props) { ), - }, - { name: "likeBelongOrgDept", label: "所属单位或部门" }, - { name: "eqCorpId", onlyForLabel: true }, - ]} + wrapperCol={{ span: 16 }} + options={searchOptions} form={form} onFinish={getData} /> +
( @@ -105,42 +130,60 @@ function List(props) { )} columns={[ - // { title: "序号", width: 80, align: "center", render: (_, __, index) => index + 1 }, - { title: "消防水源名称", dataIndex: "waterSourceName", ellipsis: true }, + { + title: "消防水源名称", + dataIndex: "waterSourceName", + width: 200, + ellipsis: true, + }, { title: "消防水源状态", - width: 140, + dataIndex: "waterSourceStatus", + width: 150, align: "center", + ellipsis: true, render: (_, record) => getStatusLabel(record), }, - { title: "所属单位或部门", dataIndex: "belongOrgDept", ellipsis: true }, - { title: "水源位置", dataIndex: "waterLocation", ellipsis: true }, + + { + title: "水源位置", + dataIndex: "waterLocation", + width: 200, + ellipsis: true, + }, + { + title: "所属单位或部门", + dataIndex: "belongOrgDept", + width: 200, + ellipsis: true, + }, { title: "操作", - fixed: "right", - width: 180, + width: 200, + align: "center", render: (_, record) => ( - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+ + -
+
- +
)} ); diff --git a/src/pages/Container/Supervision/FireResourceStats/index.js b/src/pages/Container/Supervision/FireResourceStats/index.js index 14b2d8d..158721b 100644 --- a/src/pages/Container/Supervision/FireResourceStats/index.js +++ b/src/pages/Container/Supervision/FireResourceStats/index.js @@ -26,81 +26,80 @@ function FireResourceStats(props) { } }; + // 渲染可点击的数量链接 + const renderCountLink = (text, record, type) => { + const count = text || 0; + + // 如果数量为0,只显示数字不可点击 + if (count === 0) { + return 0; + } + + return ( + handleViewDetail(record, type)} + > + {count} + + ); + }; + return ( +
index + 1 }, { title: "企业名称", dataIndex: "corpName", + width: 300, ellipsis: true, - render: text => text || "一公司", - width: 200, + render: text => text || "-", }, { title: "消防救援队数", dataIndex: "rescueTeamCount", - width: 140, + width: 150, align: "center", - render: (text, record) => ( - handleViewDetail(record, "rescueTeam")} - > - {text || 0} - - ), + render: (text, record) => renderCountLink(text, record, "rescueTeam"), }, { title: "消防控制室数", dataIndex: "controlRoomCount", - width: 140, + width: 150, align: "center", - render: (text, record) => ( - handleViewDetail(record, "controlRoom")} - > - {text || 0} - - ), + render: (text, record) => renderCountLink(text, record, "controlRoom"), }, { title: "消防泵房数", dataIndex: "pumpRoomCount", - width: 140, + width: 150, align: "center", - render: (text, record) => ( - handleViewDetail(record, "pumpRoom")} - > - {text || 0} - - ), + render: (text, record) => renderCountLink(text, record, "pumpRoom"), }, { title: "消防水源数", dataIndex: "waterSourceCount", - width: 140, + width: 150, align: "center", - render: (text, record) => ( - handleViewDetail(record, "waterSource")} - > - {text || 0} - - ), + render: (text, record) => renderCountLink(text, record, "waterSource"), }, ]} {...tableProps}