添加按钮权限

main
853931625@qq.com 2026-04-30 17:37:39 +08:00
parent 40c99ec0fa
commit cb2c854c1a
10 changed files with 237 additions and 190 deletions

View File

@ -32,7 +32,7 @@
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"zy-react-library": "^1.2.39" "zy-react-library": "^1.3.8"
}, },
"devDependencies": { "devDependencies": {
"@antfu/eslint-config": "^5.4.1", "@antfu/eslint-config": "^5.4.1",

View File

@ -8,3 +8,4 @@ export const sensorDeviceStatus = declareRequest("sensorDeviceLoading", "Put > @
export const sensorDeviceThreshold = declareRequest("sensorDeviceLoading", "Put > @/iotalarm/sensorDevice/threshold"); export const sensorDeviceThreshold = declareRequest("sensorDeviceLoading", "Put > @/iotalarm/sensorDevice/threshold");
export const sensorDeviceRemove = declareRequest("sensorDeviceLoading", "Post > @/iotalarm/sensorDevice/{id}"); export const sensorDeviceRemove = declareRequest("sensorDeviceLoading", "Post > @/iotalarm/sensorDevice/{id}");
export const sensorDevicelistBySensorDevice = declareRequest("sensorDeviceLoading", "Post > @/iotalarm/alarmRecord/listBySensorDevice"); export const sensorDevicelistBySensorDevice = declareRequest("sensorDeviceLoading", "Post > @/iotalarm/alarmRecord/listBySensorDevice");
export const sensorDeviceLineChart = declareRequest("sensorDeviceLoading", "Get > /iotalarm/alarmRecord/lineChart/{id}");

View File

@ -34,7 +34,7 @@ function AssignModal(props) {
} }
}); });
} }
}, [form, props.open, props.isBatch, props.alarmId]); }, [props.open]);
useEffect(() => { useEffect(() => {
getUserInfo().then((data) => { getUserInfo().then((data) => {
@ -75,7 +75,8 @@ function AssignModal(props) {
if (props.isBatch) { if (props.isBatch) {
values.ids = props.alarmIds; values.ids = props.alarmIds;
res = await props.alarmAssign(values); res = await props.alarmAssign(values);
} else { }
else {
values.ids = [props.alarmId]; values.ids = [props.alarmId];
res = await props.alarmAssign(values); res = await props.alarmAssign(values);
} }
@ -85,7 +86,8 @@ function AssignModal(props) {
props.getData(); props.getData();
message.success("处置成功"); message.success("处置成功");
} }
} finally { }
finally {
setSubmitting(false); setSubmitting(false);
} }
}; };
@ -184,7 +186,7 @@ function AssignModal(props) {
> >
<DictionarySelect <DictionarySelect
dictValue="alarmType" dictValue="alarmType"
onGetLabel={label => { onGetLabel={(label) => {
alarmTypeName.current = label; alarmTypeName.current = label;
}} }}
/> />
@ -203,7 +205,7 @@ function AssignModal(props) {
> >
<DictionarySelect <DictionarySelect
dictValue="alarmLevel" dictValue="alarmLevel"
onGetLabel={label => { onGetLabel={(label) => {
alarmLevelName.current = label; alarmLevelName.current = label;
}} }}
/> />

View File

@ -16,6 +16,7 @@ function AssignList(props) {
const [detailId, setDetailId] = useState(""); const [detailId, setDetailId] = useState("");
const [selectedRowKeys, setSelectedRowKeys] = useState([]); const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const [currentAlarmId, setCurrentAlarmId] = useState(null); const [currentAlarmId, setCurrentAlarmId] = useState(null);
const [isBatch, setIsBatch] = useState(false); const [isBatch, setIsBatch] = useState(false);
const { tableProps, getData } = useTable(props.alarmRecordList, { const { tableProps, getData } = useTable(props.alarmRecordList, {
form, form,
@ -64,11 +65,13 @@ function AssignList(props) {
toolBarRender={() => ( toolBarRender={() => (
<Space> <Space>
{ {
// props.permission("bjczfp-plcz") && props.permission("bjczfp-plcz")
&& (
<Button type="primary" onClick={handleBatchAssign}> <Button type="primary" onClick={handleBatchAssign}>
批量处置 批量处置
</Button> </Button>
)
} }
</Space> </Space>
)} )}
@ -99,6 +102,7 @@ function AssignList(props) {
type="link" type="link"
onClick={() => { onClick={() => {
setDetailId(record.id); setDetailId(record.id);
setDetailOpen(true); setDetailOpen(true);
}} }}
> >

View File

@ -14,6 +14,8 @@ function AlarmRecordList(props) {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [detailOpen, setDetailOpen] = useState(false); const [detailOpen, setDetailOpen] = useState(false);
const [currentId, setCurrentId] = useState(""); const [currentId, setCurrentId] = useState("");
const [fireRegionId, setFireRegionId] = useState(null);
const [alarmRecordId, setAlarmRecordId] = useState(null);
const { tableProps, getData } = useTable(props.alarmRecordList, { const { tableProps, getData } = useTable(props.alarmRecordList, {
form, form,
transform: formData => ({ transform: formData => ({
@ -79,10 +81,17 @@ function AlarmRecordList(props) {
{ {
title: "操作", title: "操作",
width: 100, width: 100,
hidden: !props.permission("bjjlgl-info"), // hidden: !props.permission("bjjlgl-info"),
render: (_, record) => ( render: (_, record) => (
<Space> <Space>
<Button type="link" onClick={() => handleViewDetail(record)}> <Button
type="link"
onClick={() => {
setFireRegionId(record.fireRegionId);
setAlarmRecordId(record.alarmRecordId);
handleViewDetail(record);
}}
>
查看 查看
</Button> </Button>
</Space> </Space>
@ -95,6 +104,8 @@ function AlarmRecordList(props) {
<AlarmRecordView <AlarmRecordView
open={detailOpen} open={detailOpen}
currentId={currentId} currentId={currentId}
fireRegionId={fireRegionId}
alarmRecordId={alarmRecordId}
type={1} type={1}
alarmRecordInfo={props.alarmRecordInfo} alarmRecordInfo={props.alarmRecordInfo}
onCancel={() => { onCancel={() => {

View File

@ -2,7 +2,10 @@ import { Descriptions, Divider, Modal } from "antd";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import VideoIcon from "zy-react-library/components/Icon/VideoIcon"; 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 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 { getLabelName } from "zy-react-library/utils";
import { DISPOSAL_STATIS, SENSOR_ATTR_OPTIONS } from "~/enumerate/constant"; import { DISPOSAL_STATIS, SENSOR_ATTR_OPTIONS } from "~/enumerate/constant";
import { renderAlarmCurrentValue } from "~/utils/alarm"; import { renderAlarmCurrentValue } from "~/utils/alarm";
@ -11,18 +14,31 @@ import BaiduMap from "../../BaiduMap";
function DetailModal(props) { function DetailModal(props) {
const [detail, setDetail] = useState({}); const [detail, setDetail] = useState({});
const [videoModalOpen, setVideoModalOpen] = useState(false); 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(() => { useEffect(() => {
if (!props.open) { if (!props.open) {
return; return;
} }
getImageFun();
props.alarmRecordInfo({ id: props.currentId }).then((res) => { props.alarmRecordInfo({ id: props.currentId }).then((res) => {
if (res?.success) { if (res?.success) {
setDetail(res.data || {}); setDetail(res.data || {});
} }
}); });
}, [props.open, props.currentId, props.alarmRecordInfo]); }, [props.open, props.currentId]);
const formatTime = (value) => { const formatTime = (value) => {
if (!value) { if (!value) {
@ -110,7 +126,10 @@ function DetailModal(props) {
<Descriptions.Item label="处置人">{detail.disposeUserName || "-"}</Descriptions.Item> <Descriptions.Item label="处置人">{detail.disposeUserName || "-"}</Descriptions.Item>
<Descriptions.Item label="处置时间">{detail.disposeTime || "-"}</Descriptions.Item> <Descriptions.Item label="处置时间">{detail.disposeTime || "-"}</Descriptions.Item>
<Descriptions.Item label="处置结果" span={2}>{detail.disposeResult || "-"}</Descriptions.Item> <Descriptions.Item label="处置结果" span={2}>{detail.disposeResult || "-"}</Descriptions.Item>
<Descriptions.Item label="处置图片" span={2}>{detail.disposeImage || "-"}</Descriptions.Item> <Descriptions.Item label="处置图片" span={2}>
{" "}
<PreviewImg files={disposalFiles} />
</Descriptions.Item>
<Descriptions.Item label="处置视频" span={2}> <Descriptions.Item label="处置视频" span={2}>
{detail.videoUrl {detail.videoUrl
? ( ? (

View File

@ -107,25 +107,27 @@ function DeviceRegionList(props) {
width: 260, width: 260,
render: (_, record) => ( render: (_, record) => (
<Space> <Space>
{/* {props.permission("sbqugl-glcgq") && ( */} {props.permission("sbqugl-glcgq") && (
<Button type="link" onClick={() => handleOpenBind(record)}> <Button type="link" onClick={() => handleOpenBind(record)}>
关联传感器 关联传感器
</Button> </Button>
{/* )} */} )}
{/* {props.permission("sbqugl-szfer") && ( */} {props.permission("sbqugl-szfer") && (
<Button type="link" onClick={() => handleOpenManager(record)}> <Button type="link" onClick={() => handleOpenManager(record)}>
设置负责人 设置负责人
</Button> </Button>
{/* )} */} )}
{ {
// props.permission("sbqugl-info") && props.permission("sbqugl-info")
&& (
<Button <Button
type="link" type="link"
onClick={() => handleOpenView(record)} onClick={() => handleOpenView(record)}
> >
查看 查看
</Button> </Button>
)
} }
</Space> </Space>
), ),

View File

@ -50,7 +50,6 @@ function SensorDeviceList(props) {
const handleConfirm = (lng, lat, extra) => { const handleConfirm = (lng, lat, extra) => {
rowData.latitude = lat; rowData.latitude = lat;
rowData.longitude = lng; rowData.longitude = lng;
console.log(rowData);
props["sensorDeviceEdit"](rowData).then((res) => { props["sensorDeviceEdit"](rowData).then((res) => {
if (res?.success) { if (res?.success) {
message.success("定位成功!"); message.success("定位成功!");
@ -119,7 +118,7 @@ function SensorDeviceList(props) {
rowKey="id" rowKey="id"
toolBarRender={() => ( toolBarRender={() => (
<Space> <Space>
{/* {props.permission("cgqsbgl-add") && ( */} {props.permission("cgqsbgl-add") && (
<Button <Button
type="primary" type="primary"
icon={<AddIcon />} icon={<AddIcon />}
@ -130,7 +129,7 @@ function SensorDeviceList(props) {
> >
新增 新增
</Button> </Button>
{/* )} */} )}
</Space> </Space>
)} )}
columns={[ columns={[
@ -176,8 +175,9 @@ function SensorDeviceList(props) {
render: (_, record) => ( render: (_, record) => (
<Space> <Space>
{ {
// props.permission("cgqsbgl-info") && props.permission("cgqsbgl-info")
&& (
<Button <Button
type="link" type="link"
onClick={() => { onClick={() => {
@ -187,8 +187,9 @@ function SensorDeviceList(props) {
> >
查看 查看
</Button> </Button>
)
} }
{/* {props.permission("cgqsbgl-edit") && ( */} {props.permission("cgqsbgl-edit") && (
<Button <Button
type="link" type="link"
onClick={() => { onClick={() => {
@ -198,26 +199,29 @@ function SensorDeviceList(props) {
> >
编辑 编辑
</Button> </Button>
{/* )} */} )}
{/* {props.permission("cgqsbgl-del") && ( */} {props.permission("cgqsbgl-del") && (
<Button danger type="link" onClick={() => handleDelete(record)}> <Button danger type="link" onClick={() => handleDelete(record)}>
删除 删除
</Button> </Button>
{/* )} */} )}
{ {
// props.permission("cgqsbgl-locate") && props.permission("cgqsbgl-locate")
&& (
<Button <Button
type="link" type="link"
onClick={() => handleOpen(record)} onClick={() => handleOpen(record)}
> >
定位 定位
</Button> </Button>
)
} }
{ {
// props.permission("cgqsbgl-sssj") && props.permission("cgqsbgl-sssj")
&& (
<Button <Button
type="link" type="link"
onClick={() => { onClick={() => {
@ -227,8 +231,9 @@ function SensorDeviceList(props) {
> >
实时数据 实时数据
</Button> </Button>
)
} }
{/* {props.permission("cgqsbgl-yzsd") && record.sensorAttr === "NUMBER" && record.thresholdFlag === 1 && ( */} {props.permission("cgqsbgl-yzsd") && record.sensorAttr === "NUMBER" && record.thresholdFlag === 1 && (
<Button <Button
type="link" type="link"
onClick={() => { onClick={() => {
@ -239,7 +244,7 @@ function SensorDeviceList(props) {
> >
阈值设定 阈值设定
</Button> </Button>
{/* )} */} )}
</Space> </Space>
), ),
@ -304,6 +309,7 @@ function SensorDeviceList(props) {
open={realtimeOpen} open={realtimeOpen}
record={currentRecord} record={currentRecord}
sensorDeviceList={props["sensorDevicelistBySensorDevice"]} sensorDeviceList={props["sensorDevicelistBySensorDevice"]}
sensorDeviceLineChart={props["sensorDeviceLineChart"]}
onCancel={() => { onCancel={() => {
setRealtimeOpen(false); setRealtimeOpen(false);
setCurrentRecord({}); setCurrentRecord({});

View File

@ -3,39 +3,38 @@ import {
SearchOutlined, SearchOutlined,
} from "@ant-design/icons"; } from "@ant-design/icons";
import { Button, DatePicker, Form, Modal, Space } from "antd"; import { Button, DatePicker, Form, Modal, Space } from "antd";
import dayjs from "dayjs";
import * as echarts from "echarts"; import * as echarts from "echarts";
import { useEffect, useRef } from "react"; import { useEffect, useRef } from "react";
import Table from "zy-react-library/components/Table"; import Table from "zy-react-library/components/Table";
import useTable from "zy-react-library/hooks/useTable"; import useTable from "zy-react-library/hooks/useTable";
const COLLECT_INTERVAL_SECONDS = 10; // const COLLECT_INTERVAL_SECONDS = 10;
const COLLECT_DURATION_SECONDS = 60 * 60; // const COLLECT_DURATION_SECONDS = 60 * 60;
function getMockCollectData(record) { // function getMockCollectData(record) {
const now = dayjs(); // const now = dayjs();
const rangeMin = Number(record.rangeMin); // const rangeMin = Number(record.rangeMin);
const rangeMax = Number(record.rangeMax); // const rangeMax = Number(record.rangeMax);
const hasRange = Number.isFinite(rangeMin) && Number.isFinite(rangeMax) && rangeMax > rangeMin; // const hasRange = Number.isFinite(rangeMin) && Number.isFinite(rangeMax) && rangeMax > rangeMin;
const base = hasRange ? (rangeMin + rangeMax) / 2 : 50; // const base = hasRange ? (rangeMin + rangeMax) / 2 : 50;
const amplitude = hasRange ? (rangeMax - rangeMin) * 0.18 : 8; // const amplitude = hasRange ? (rangeMax - rangeMin) * 0.18 : 8;
const count = COLLECT_DURATION_SECONDS / COLLECT_INTERVAL_SECONDS; // const count = COLLECT_DURATION_SECONDS / COLLECT_INTERVAL_SECONDS;
//
return Array.from({ length: count + 1 }, (_, index) => { // return Array.from({ length: count + 1 }, (_, index) => {
const time = now.subtract(COLLECT_DURATION_SECONDS - index * COLLECT_INTERVAL_SECONDS, "second"); // const time = now.subtract(COLLECT_DURATION_SECONDS - index * COLLECT_INTERVAL_SECONDS, "second");
const value = record.sensorAttr === "SWITCH" // const value = record.sensorAttr === "SWITCH"
? Math.round(Math.random()) // ? Math.round(Math.random())
: base // : base
+ Math.sin(index / 10) * amplitude // + Math.sin(index / 10) * amplitude
+ (Math.random() - 0.5) * amplitude * 0.5; // + (Math.random() - 0.5) * amplitude * 0.5;
//
return { // return {
time: time.format("HH:mm:ss"), // time: time.format("HH:mm:ss"),
value: Number(value.toFixed(2)), // value: Number(value.toFixed(2)),
}; // };
}); // });
} // }
function RealtimeModal(props) { function RealtimeModal(props) {
const [form] = Form.useForm(); const [form] = Form.useForm();
@ -60,10 +59,12 @@ function RealtimeModal(props) {
if (!props.open || !chartRef.current) { if (!props.open || !chartRef.current) {
return; 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 chart = echarts.init(chartRef.current);
const data = getMockCollectData(record);
console.log(data);
chart.setOption({ chart.setOption({
grid: { grid: {
top: 48, top: 48,
@ -111,6 +112,7 @@ function RealtimeModal(props) {
window.removeEventListener("resize", handleResize); window.removeEventListener("resize", handleResize);
chart.dispose(); chart.dispose();
}; };
});
}, [props.open, record]); }, [props.open, record]);
return ( return (

View File

@ -71,8 +71,8 @@ function SensorTypeList(props) {
width: 220, width: 220,
render: (_, record) => ( render: (_, record) => (
<Space> <Space>
{/* { */} {
{/* props.permission("cgqbj-info") && ( */} props.permission("cgqbj-info") && (
<Button <Button
type="link" type="link"
@ -84,8 +84,8 @@ function SensorTypeList(props) {
查看 查看
</Button> </Button>
) )
{/* } */} }
{/* {props.permission("cgqbj-edit") && ( */} {props.permission("cgqbj-edit") && (
<Button <Button
type="link" type="link"
onClick={() => { onClick={() => {
@ -95,12 +95,12 @@ function SensorTypeList(props) {
> >
编辑 编辑
</Button> </Button>
{/* )} */} )}
{/* {props.permission("cgqbj-del") && ( */} {props.permission("cgqbj-del") && (
<Button danger type="link" onClick={() => handleDelete(record)}> <Button danger type="link" onClick={() => handleDelete(record)}>
删除 删除
</Button> </Button>
{/* )} */} )}
</Space> </Space>
), ),
}, },