From cb2c854c1a3b7ece47a2295a395829e2d155ae81 Mon Sep 17 00:00:00 2001 From: "853931625@qq.com" Date: Thu, 30 Apr 2026 17:37:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8C=89=E9=92=AE=E6=9D=83?= =?UTF-8?q?=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/api/SensorDevice/index.js | 1 + .../List/components/AssignModal/index.js | 12 +- src/components/AlarmAssign/List/index.js | 12 +- src/components/AlarmRecord/List/index.js | 15 +- src/components/AlarmRecord/View/index.js | 23 ++- src/components/DeviceRegion/List/index.js | 38 ++--- src/components/SensorDevice/List/index.js | 120 +++++++------- .../components/RealtimeModal/index.js | 146 +++++++++--------- src/components/SensorType/List/index.js | 58 +++---- 10 files changed, 237 insertions(+), 190 deletions(-) diff --git a/package.json b/package.json index 41d6f71..d37451e 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "lodash-es": "^4.17.21", "react": "^18.2.0", "react-dom": "^18.2.0", - "zy-react-library": "^1.2.39" + "zy-react-library": "^1.3.8" }, "devDependencies": { "@antfu/eslint-config": "^5.4.1", diff --git a/src/api/SensorDevice/index.js b/src/api/SensorDevice/index.js index 7a22c9f..8bbb16f 100644 --- a/src/api/SensorDevice/index.js +++ b/src/api/SensorDevice/index.js @@ -8,3 +8,4 @@ export const sensorDeviceStatus = declareRequest("sensorDeviceLoading", "Put > @ export const sensorDeviceThreshold = declareRequest("sensorDeviceLoading", "Put > @/iotalarm/sensorDevice/threshold"); export const sensorDeviceRemove = declareRequest("sensorDeviceLoading", "Post > @/iotalarm/sensorDevice/{id}"); export const sensorDevicelistBySensorDevice = declareRequest("sensorDeviceLoading", "Post > @/iotalarm/alarmRecord/listBySensorDevice"); +export const sensorDeviceLineChart = declareRequest("sensorDeviceLoading", "Get > /iotalarm/alarmRecord/lineChart/{id}"); diff --git a/src/components/AlarmAssign/List/components/AssignModal/index.js b/src/components/AlarmAssign/List/components/AssignModal/index.js index ae98aca..011a221 100644 --- a/src/components/AlarmAssign/List/components/AssignModal/index.js +++ b/src/components/AlarmAssign/List/components/AssignModal/index.js @@ -34,7 +34,7 @@ function AssignModal(props) { } }); } - }, [form, props.open, props.isBatch, props.alarmId]); + }, [props.open]); useEffect(() => { getUserInfo().then((data) => { @@ -75,7 +75,8 @@ function AssignModal(props) { if (props.isBatch) { values.ids = props.alarmIds; res = await props.alarmAssign(values); - } else { + } + else { values.ids = [props.alarmId]; res = await props.alarmAssign(values); } @@ -85,7 +86,8 @@ function AssignModal(props) { props.getData(); message.success("处置成功"); } - } finally { + } + finally { setSubmitting(false); } }; @@ -184,7 +186,7 @@ function AssignModal(props) { > { + onGetLabel={(label) => { alarmTypeName.current = label; }} /> @@ -203,7 +205,7 @@ function AssignModal(props) { > { + onGetLabel={(label) => { alarmLevelName.current = label; }} /> diff --git a/src/components/AlarmAssign/List/index.js b/src/components/AlarmAssign/List/index.js index 818fcdb..5688e2b 100644 --- a/src/components/AlarmAssign/List/index.js +++ b/src/components/AlarmAssign/List/index.js @@ -16,6 +16,7 @@ function AssignList(props) { const [detailId, setDetailId] = useState(""); const [selectedRowKeys, setSelectedRowKeys] = useState([]); const [currentAlarmId, setCurrentAlarmId] = useState(null); + const [isBatch, setIsBatch] = useState(false); const { tableProps, getData } = useTable(props.alarmRecordList, { form, @@ -64,11 +65,13 @@ function AssignList(props) { toolBarRender={() => ( { - // props.permission("bjczfp-plcz") && + props.permission("bjczfp-plcz") - + && ( + + ) } )} @@ -99,6 +102,7 @@ function AssignList(props) { type="link" onClick={() => { setDetailId(record.id); + setDetailOpen(true); }} > diff --git a/src/components/AlarmRecord/List/index.js b/src/components/AlarmRecord/List/index.js index 8b93b8f..5f34844 100644 --- a/src/components/AlarmRecord/List/index.js +++ b/src/components/AlarmRecord/List/index.js @@ -14,6 +14,8 @@ function AlarmRecordList(props) { const [form] = Form.useForm(); const [detailOpen, setDetailOpen] = useState(false); const [currentId, setCurrentId] = useState(""); + const [fireRegionId, setFireRegionId] = useState(null); + const [alarmRecordId, setAlarmRecordId] = useState(null); const { tableProps, getData } = useTable(props.alarmRecordList, { form, transform: formData => ({ @@ -79,10 +81,17 @@ function AlarmRecordList(props) { { title: "操作", width: 100, - hidden: !props.permission("bjjlgl-info"), + // hidden: !props.permission("bjjlgl-info"), render: (_, record) => ( - @@ -95,6 +104,8 @@ function AlarmRecordList(props) { { diff --git a/src/components/AlarmRecord/View/index.js b/src/components/AlarmRecord/View/index.js index c6ed89d..1a0119a 100644 --- a/src/components/AlarmRecord/View/index.js +++ b/src/components/AlarmRecord/View/index.js @@ -2,7 +2,10 @@ import { Descriptions, Divider, Modal } from "antd"; import dayjs from "dayjs"; import { useEffect, useState } from "react"; import VideoIcon from "zy-react-library/components/Icon/VideoIcon"; +import PreviewImg from "zy-react-library/components/PreviewImg"; import Video from "zy-react-library/components/Video"; +import { UPLOAD_FILE_TYPE_ENUM } from "zy-react-library/enum/uploadFile/gwj"; +import UseGetFile from "zy-react-library/hooks/useGetFile"; import { getLabelName } from "zy-react-library/utils"; import { DISPOSAL_STATIS, SENSOR_ATTR_OPTIONS } from "~/enumerate/constant"; import { renderAlarmCurrentValue } from "~/utils/alarm"; @@ -11,18 +14,31 @@ import BaiduMap from "../../BaiduMap"; function DetailModal(props) { const [detail, setDetail] = useState({}); const [videoModalOpen, setVideoModalOpen] = useState(false); + const [disposalFiles, setDisposalFiles] = useState([]); + const { loading: getFileLoading, getFile } = UseGetFile(); + const getImageFun = async () => { + console.log(props); + const disposalFiles = props.fireRegionId + ? await getFile({ + eqType: UPLOAD_FILE_TYPE_ENUM["800"], + eqForeignKey: props.fireRegionId, + }) + : []; + setDisposalFiles(disposalFiles); + }; useEffect(() => { if (!props.open) { return; } + getImageFun(); props.alarmRecordInfo({ id: props.currentId }).then((res) => { if (res?.success) { setDetail(res.data || {}); } }); - }, [props.open, props.currentId, props.alarmRecordInfo]); + }, [props.open, props.currentId]); const formatTime = (value) => { if (!value) { @@ -110,7 +126,10 @@ function DetailModal(props) { {detail.disposeUserName || "-"} {detail.disposeTime || "-"} {detail.disposeResult || "-"} - {detail.disposeImage || "-"} + + {" "} + + {detail.videoUrl ? ( diff --git a/src/components/DeviceRegion/List/index.js b/src/components/DeviceRegion/List/index.js index c2b282a..1a7865d 100644 --- a/src/components/DeviceRegion/List/index.js +++ b/src/components/DeviceRegion/List/index.js @@ -107,25 +107,27 @@ function DeviceRegionList(props) { width: 260, render: (_, record) => ( - {/* {props.permission("sbqugl-glcgq") && ( */} - - {/* )} */} - {/* {props.permission("sbqugl-szfer") && ( */} - - {/* )} */} - { - // props.permission("sbqugl-info") && - - + )} + {props.permission("sbqugl-szfer") && ( + + )} + { + props.permission("sbqugl-info") + + && ( + + ) } ), diff --git a/src/components/SensorDevice/List/index.js b/src/components/SensorDevice/List/index.js index 40e31b2..607f54a 100644 --- a/src/components/SensorDevice/List/index.js +++ b/src/components/SensorDevice/List/index.js @@ -50,7 +50,6 @@ function SensorDeviceList(props) { const handleConfirm = (lng, lat, extra) => { rowData.latitude = lat; rowData.longitude = lng; - console.log(rowData); props["sensorDeviceEdit"](rowData).then((res) => { if (res?.success) { message.success("定位成功!"); @@ -119,18 +118,18 @@ function SensorDeviceList(props) { rowKey="id" toolBarRender={() => ( - {/* {props.permission("cgqsbgl-add") && ( */} - - {/* )} */} + {props.permission("cgqsbgl-add") && ( + + )} )} columns={[ @@ -176,70 +175,76 @@ function SensorDeviceList(props) { render: (_, record) => ( { - // props.permission("cgqsbgl-info") && + props.permission("cgqsbgl-info") + && ( + + ) + } + {props.permission("cgqsbgl-edit") && ( - } - {/* {props.permission("cgqsbgl-edit") && ( */} - - {/* )} */} + )} - {/* {props.permission("cgqsbgl-del") && ( */} - - {/* )} */} + {props.permission("cgqsbgl-del") && ( + + )} { - // props.permission("cgqsbgl-locate") && + props.permission("cgqsbgl-locate") - + && ( + + ) } { - // props.permission("cgqsbgl-sssj") && + props.permission("cgqsbgl-sssj") + && ( + + ) + } + {props.permission("cgqsbgl-yzsd") && record.sensorAttr === "NUMBER" && record.thresholdFlag === 1 && ( - } - {/* {props.permission("cgqsbgl-yzsd") && record.sensorAttr === "NUMBER" && record.thresholdFlag === 1 && ( */} - - {/* )} */} + )} ), @@ -304,6 +309,7 @@ function SensorDeviceList(props) { open={realtimeOpen} record={currentRecord} sensorDeviceList={props["sensorDevicelistBySensorDevice"]} + sensorDeviceLineChart={props["sensorDeviceLineChart"]} onCancel={() => { setRealtimeOpen(false); setCurrentRecord({}); diff --git a/src/components/SensorDevice/components/RealtimeModal/index.js b/src/components/SensorDevice/components/RealtimeModal/index.js index 5bfa12e..5f453a6 100644 --- a/src/components/SensorDevice/components/RealtimeModal/index.js +++ b/src/components/SensorDevice/components/RealtimeModal/index.js @@ -3,39 +3,38 @@ import { SearchOutlined, } from "@ant-design/icons"; import { Button, DatePicker, Form, Modal, Space } from "antd"; -import dayjs from "dayjs"; import * as echarts from "echarts"; import { useEffect, useRef } from "react"; import Table from "zy-react-library/components/Table"; import useTable from "zy-react-library/hooks/useTable"; -const COLLECT_INTERVAL_SECONDS = 10; -const COLLECT_DURATION_SECONDS = 60 * 60; +// const COLLECT_INTERVAL_SECONDS = 10; +// const COLLECT_DURATION_SECONDS = 60 * 60; -function getMockCollectData(record) { - const now = dayjs(); - const rangeMin = Number(record.rangeMin); - const rangeMax = Number(record.rangeMax); - const hasRange = Number.isFinite(rangeMin) && Number.isFinite(rangeMax) && rangeMax > rangeMin; - const base = hasRange ? (rangeMin + rangeMax) / 2 : 50; - const amplitude = hasRange ? (rangeMax - rangeMin) * 0.18 : 8; - const count = COLLECT_DURATION_SECONDS / COLLECT_INTERVAL_SECONDS; - - return Array.from({ length: count + 1 }, (_, index) => { - const time = now.subtract(COLLECT_DURATION_SECONDS - index * COLLECT_INTERVAL_SECONDS, "second"); - const value = record.sensorAttr === "SWITCH" - ? Math.round(Math.random()) - : base - + Math.sin(index / 10) * amplitude - + (Math.random() - 0.5) * amplitude * 0.5; - - return { - time: time.format("HH:mm:ss"), - value: Number(value.toFixed(2)), - }; - }); -} +// function getMockCollectData(record) { +// const now = dayjs(); +// const rangeMin = Number(record.rangeMin); +// const rangeMax = Number(record.rangeMax); +// const hasRange = Number.isFinite(rangeMin) && Number.isFinite(rangeMax) && rangeMax > rangeMin; +// const base = hasRange ? (rangeMin + rangeMax) / 2 : 50; +// const amplitude = hasRange ? (rangeMax - rangeMin) * 0.18 : 8; +// const count = COLLECT_DURATION_SECONDS / COLLECT_INTERVAL_SECONDS; +// +// return Array.from({ length: count + 1 }, (_, index) => { +// const time = now.subtract(COLLECT_DURATION_SECONDS - index * COLLECT_INTERVAL_SECONDS, "second"); +// const value = record.sensorAttr === "SWITCH" +// ? Math.round(Math.random()) +// : base +// + Math.sin(index / 10) * amplitude +// + (Math.random() - 0.5) * amplitude * 0.5; +// +// return { +// time: time.format("HH:mm:ss"), +// value: Number(value.toFixed(2)), +// }; +// }); +// } function RealtimeModal(props) { const [form] = Form.useForm(); @@ -60,57 +59,60 @@ function RealtimeModal(props) { if (!props.open || !chartRef.current) { return; } + console.log(props); + props.sensorDeviceLineChart({ id: props.record.sensorDeviceId }).then((res) => { + const data = res.data ? res.data : []; - const chart = echarts.init(chartRef.current); - const data = getMockCollectData(record); - console.log(data); - chart.setOption({ - grid: { - top: 48, - right: 24, - bottom: 48, - left: 56, - }, - tooltip: { - trigger: "axis", - }, - xAxis: { - type: "category", - boundaryGap: false, - data: data.map(item => item.time), - axisLabel: { - hideOverlap: true, + const chart = echarts.init(chartRef.current); + + chart.setOption({ + grid: { + top: 48, + right: 24, + bottom: 48, + left: 56, }, - }, - yAxis: { - type: "value", - // name: `采集值${unit}`, - scale: true, - }, - series: [ - { - name: "采集值", - type: "line", - smooth: true, - showSymbol: false, - data: data.map(item => item.value), - lineStyle: { - width: 2, - }, - areaStyle: { - opacity: 0.08, + tooltip: { + trigger: "axis", + }, + xAxis: { + type: "category", + boundaryGap: false, + data: data.map(item => item.time), + axisLabel: { + hideOverlap: true, }, }, - ], + yAxis: { + type: "value", + // name: `采集值${unit}`, + scale: true, + }, + series: [ + { + name: "采集值", + type: "line", + smooth: true, + showSymbol: false, + data: data.map(item => item.value), + lineStyle: { + width: 2, + }, + areaStyle: { + opacity: 0.08, + }, + }, + ], + }); + + const handleResize = () => chart.resize(); + window.addEventListener("resize", handleResize); + + return () => { + window.removeEventListener("resize", handleResize); + chart.dispose(); + }; }); - - const handleResize = () => chart.resize(); - window.addEventListener("resize", handleResize); - - return () => { - window.removeEventListener("resize", handleResize); - chart.dispose(); - }; }, [props.open, record]); return ( diff --git a/src/components/SensorType/List/index.js b/src/components/SensorType/List/index.js index 2be7888..506711f 100644 --- a/src/components/SensorType/List/index.js +++ b/src/components/SensorType/List/index.js @@ -71,36 +71,36 @@ function SensorTypeList(props) { width: 220, render: (_, record) => ( - {/* { */} - {/* props.permission("cgqbj-info") && ( */} + { + props.permission("cgqbj-info") && ( - - ) - {/* } */} - {/* {props.permission("cgqbj-edit") && ( */} - - {/* )} */} - {/* {props.permission("cgqbj-del") && ( */} - - {/* )} */} + + ) + } + {props.permission("cgqbj-edit") && ( + + )} + {props.permission("cgqbj-del") && ( + + )} ), },