添加按钮权限
parent
40c99ec0fa
commit
cb2c854c1a
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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}");
|
||||
|
|
|
|||
|
|
@ -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) {
|
|||
>
|
||||
<DictionarySelect
|
||||
dictValue="alarmType"
|
||||
onGetLabel={label => {
|
||||
onGetLabel={(label) => {
|
||||
alarmTypeName.current = label;
|
||||
}}
|
||||
/>
|
||||
|
|
@ -203,7 +205,7 @@ function AssignModal(props) {
|
|||
>
|
||||
<DictionarySelect
|
||||
dictValue="alarmLevel"
|
||||
onGetLabel={label => {
|
||||
onGetLabel={(label) => {
|
||||
alarmLevelName.current = label;
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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={() => (
|
||||
<Space>
|
||||
{
|
||||
// props.permission("bjczfp-plcz") &&
|
||||
props.permission("bjczfp-plcz")
|
||||
|
||||
&& (
|
||||
<Button type="primary" onClick={handleBatchAssign}>
|
||||
批量处置
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
</Space>
|
||||
)}
|
||||
|
|
@ -99,6 +102,7 @@ function AssignList(props) {
|
|||
type="link"
|
||||
onClick={() => {
|
||||
setDetailId(record.id);
|
||||
|
||||
setDetailOpen(true);
|
||||
}}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -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) => (
|
||||
<Space>
|
||||
<Button type="link" onClick={() => handleViewDetail(record)}>
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => {
|
||||
setFireRegionId(record.fireRegionId);
|
||||
setAlarmRecordId(record.alarmRecordId);
|
||||
handleViewDetail(record);
|
||||
}}
|
||||
>
|
||||
查看
|
||||
</Button>
|
||||
</Space>
|
||||
|
|
@ -95,6 +104,8 @@ function AlarmRecordList(props) {
|
|||
<AlarmRecordView
|
||||
open={detailOpen}
|
||||
currentId={currentId}
|
||||
fireRegionId={fireRegionId}
|
||||
alarmRecordId={alarmRecordId}
|
||||
type={1}
|
||||
alarmRecordInfo={props.alarmRecordInfo}
|
||||
onCancel={() => {
|
||||
|
|
|
|||
|
|
@ -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) {
|
|||
<Descriptions.Item label="处置人">{detail.disposeUserName || "-"}</Descriptions.Item>
|
||||
<Descriptions.Item label="处置时间">{detail.disposeTime || "-"}</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}>
|
||||
{detail.videoUrl
|
||||
? (
|
||||
|
|
|
|||
|
|
@ -107,25 +107,27 @@ function DeviceRegionList(props) {
|
|||
width: 260,
|
||||
render: (_, record) => (
|
||||
<Space>
|
||||
{/* {props.permission("sbqugl-glcgq") && ( */}
|
||||
{props.permission("sbqugl-glcgq") && (
|
||||
<Button type="link" onClick={() => handleOpenBind(record)}>
|
||||
关联传感器
|
||||
</Button>
|
||||
{/* )} */}
|
||||
{/* {props.permission("sbqugl-szfer") && ( */}
|
||||
)}
|
||||
{props.permission("sbqugl-szfer") && (
|
||||
<Button type="link" onClick={() => handleOpenManager(record)}>
|
||||
设置负责人
|
||||
</Button>
|
||||
{/* )} */}
|
||||
)}
|
||||
{
|
||||
// props.permission("sbqugl-info") &&
|
||||
props.permission("sbqugl-info")
|
||||
|
||||
&& (
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => handleOpenView(record)}
|
||||
>
|
||||
查看
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
</Space>
|
||||
),
|
||||
|
|
|
|||
|
|
@ -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,7 +118,7 @@ function SensorDeviceList(props) {
|
|||
rowKey="id"
|
||||
toolBarRender={() => (
|
||||
<Space>
|
||||
{/* {props.permission("cgqsbgl-add") && ( */}
|
||||
{props.permission("cgqsbgl-add") && (
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<AddIcon />}
|
||||
|
|
@ -130,7 +129,7 @@ function SensorDeviceList(props) {
|
|||
>
|
||||
新增
|
||||
</Button>
|
||||
{/* )} */}
|
||||
)}
|
||||
</Space>
|
||||
)}
|
||||
columns={[
|
||||
|
|
@ -176,8 +175,9 @@ function SensorDeviceList(props) {
|
|||
render: (_, record) => (
|
||||
<Space>
|
||||
{
|
||||
// props.permission("cgqsbgl-info") &&
|
||||
props.permission("cgqsbgl-info")
|
||||
|
||||
&& (
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => {
|
||||
|
|
@ -187,8 +187,9 @@ function SensorDeviceList(props) {
|
|||
>
|
||||
查看
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
{/* {props.permission("cgqsbgl-edit") && ( */}
|
||||
{props.permission("cgqsbgl-edit") && (
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => {
|
||||
|
|
@ -198,26 +199,29 @@ function SensorDeviceList(props) {
|
|||
>
|
||||
编辑
|
||||
</Button>
|
||||
{/* )} */}
|
||||
)}
|
||||
|
||||
{/* {props.permission("cgqsbgl-del") && ( */}
|
||||
{props.permission("cgqsbgl-del") && (
|
||||
<Button danger type="link" onClick={() => handleDelete(record)}>
|
||||
删除
|
||||
</Button>
|
||||
{/* )} */}
|
||||
)}
|
||||
{
|
||||
// props.permission("cgqsbgl-locate") &&
|
||||
props.permission("cgqsbgl-locate")
|
||||
|
||||
&& (
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => handleOpen(record)}
|
||||
>
|
||||
定位
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
{
|
||||
// props.permission("cgqsbgl-sssj") &&
|
||||
props.permission("cgqsbgl-sssj")
|
||||
|
||||
&& (
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => {
|
||||
|
|
@ -227,8 +231,9 @@ function SensorDeviceList(props) {
|
|||
>
|
||||
实时数据
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
{/* {props.permission("cgqsbgl-yzsd") && record.sensorAttr === "NUMBER" && record.thresholdFlag === 1 && ( */}
|
||||
{props.permission("cgqsbgl-yzsd") && record.sensorAttr === "NUMBER" && record.thresholdFlag === 1 && (
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => {
|
||||
|
|
@ -239,7 +244,7 @@ function SensorDeviceList(props) {
|
|||
>
|
||||
阈值设定
|
||||
</Button>
|
||||
{/* )} */}
|
||||
)}
|
||||
|
||||
</Space>
|
||||
),
|
||||
|
|
@ -304,6 +309,7 @@ function SensorDeviceList(props) {
|
|||
open={realtimeOpen}
|
||||
record={currentRecord}
|
||||
sensorDeviceList={props["sensorDevicelistBySensorDevice"]}
|
||||
sensorDeviceLineChart={props["sensorDeviceLineChart"]}
|
||||
onCancel={() => {
|
||||
setRealtimeOpen(false);
|
||||
setCurrentRecord({});
|
||||
|
|
|
|||
|
|
@ -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,10 +59,12 @@ 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,
|
||||
|
|
@ -111,6 +112,7 @@ function RealtimeModal(props) {
|
|||
window.removeEventListener("resize", handleResize);
|
||||
chart.dispose();
|
||||
};
|
||||
});
|
||||
}, [props.open, record]);
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ function SensorTypeList(props) {
|
|||
width: 220,
|
||||
render: (_, record) => (
|
||||
<Space>
|
||||
{/* { */}
|
||||
{/* props.permission("cgqbj-info") && ( */}
|
||||
{
|
||||
props.permission("cgqbj-info") && (
|
||||
|
||||
<Button
|
||||
type="link"
|
||||
|
|
@ -84,8 +84,8 @@ function SensorTypeList(props) {
|
|||
查看
|
||||
</Button>
|
||||
)
|
||||
{/* } */}
|
||||
{/* {props.permission("cgqbj-edit") && ( */}
|
||||
}
|
||||
{props.permission("cgqbj-edit") && (
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => {
|
||||
|
|
@ -95,12 +95,12 @@ function SensorTypeList(props) {
|
|||
>
|
||||
编辑
|
||||
</Button>
|
||||
{/* )} */}
|
||||
{/* {props.permission("cgqbj-del") && ( */}
|
||||
)}
|
||||
{props.permission("cgqbj-del") && (
|
||||
<Button danger type="link" onClick={() => handleDelete(record)}>
|
||||
删除
|
||||
</Button>
|
||||
{/* )} */}
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue