From 582352c40d059274156d36205c940e998976b5a4 Mon Sep 17 00:00:00 2001 From: wenlele Date: Thu, 31 Aug 2023 08:59:53 +0800 Subject: [PATCH] =?UTF-8?q?UI=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/models/structure_off.js | 18 ++ .../components/customProjGroupModal.jsx | 2 +- .../projectGroup/containers/bigscreen.jsx | 176 +++++++++++++++--- 3 files changed, 164 insertions(+), 32 deletions(-) diff --git a/api/app/lib/models/structure_off.js b/api/app/lib/models/structure_off.js index 153f6a5..a923f4d 100644 --- a/api/app/lib/models/structure_off.js +++ b/api/app/lib/models/structure_off.js @@ -34,6 +34,24 @@ module.exports = dc => { field: "offline", autoIncrement: false }, + totnum: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: "测点总数", + primaryKey: false, + field: "totnum", + autoIncrement: false + }, + offnum: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: "离线个数", + primaryKey: false, + field: "offnum", + autoIncrement: false + }, offtime: { type: DataTypes.STRING, allowNull: false, diff --git a/web/client/src/layout/components/header/components/customProjGroupModal.jsx b/web/client/src/layout/components/header/components/customProjGroupModal.jsx index 41afab4..5b40557 100644 --- a/web/client/src/layout/components/header/components/customProjGroupModal.jsx +++ b/web/client/src/layout/components/header/components/customProjGroupModal.jsx @@ -27,7 +27,7 @@ const CustomProjGroupModal = (props) => { if (editData) { stoData.id = editData.id } - dispatch(actions.projectGroupAC.editProjectGroup(stoData)).then((res) => { + dispatch(actions.projectGroup.editProjectGroup(stoData)).then((res) => { if (res.success) { cancel({ refresh: true }) form.current?.reset() diff --git a/web/client/src/sections/projectGroup/containers/bigscreen.jsx b/web/client/src/sections/projectGroup/containers/bigscreen.jsx index 9eea52a..50f304d 100644 --- a/web/client/src/sections/projectGroup/containers/bigscreen.jsx +++ b/web/client/src/sections/projectGroup/containers/bigscreen.jsx @@ -1,4 +1,5 @@ import React, { useEffect, useRef, useState } from 'react'; +import { Skeleton, Button, Pagination, Select, Popconfirm, Table, Tooltip } from '@douyinfe/semi-ui'; import { connect } from 'react-redux'; import Header from '../components/header'; import Body from '../components/body' @@ -6,18 +7,104 @@ import Card from '../components/card' import '../style.less' import ReactECharts from 'echarts-for-react'; import moment from 'moment' +import PerfectScrollbar from "perfect-scrollbar"; - +let interrupt const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, groupStatisticOnline }) => { + const [InterruptRank, setInterruptRank] = useState([]) + const [online, setOnline] = useState([]) + const [value, setValue] = useState([]) + const [time, setTime] = useState([]) + + + useEffect(() => { let groupId = JSON.parse(localStorage.getItem('project_group'))?.find(v => user?.id == v.userId)?.projectGroupId console.log(); - dispatch(actions.projectGroup.groupStatisticOnline({ groupId })) + statisticOnline(groupId) }, []) - console.log(groupStatisticOnline); + let statisticOnline = (groupId) => { + dispatch(actions.projectGroup.groupStatisticOnline({ groupId })).then(res => { + console.log(res); + if (res.success) { + let Interrupt = [] + res.payload.data?.forEach(v => { + if (v.offline?.id) { + Interrupt.push({ name: v.name, ...v.offline }) + } + }) + Interrupt = Interrupt?.sort((a, b) => b.offline - a.offline) + setInterruptRank(Interrupt) + setOnline(res.payload.data || []) + setValue(res.payload.data?.map(v => v.id) || []) + // eChartsData(res.payload.data || [], res.payload.data?.map(v => v.id) || []) + } + }) + } + + // const eChartsData = (data, value) => { + // // 调用函数获取时间节点数组 + // let timeNodes = getTimeNodes() + // let dataList = [] + // data?.forEach(v => { + // if (value?.includes(v.id)) { + // v.timeNodes = [] + // timeNodes?.forEach(s => { + // if (v.online?.find(d => moment(d.collect_time).format('YYYY-MM-DD HH') == s)?.structure) { + // v.timeNodes.push([s,]) + // } else { + // v.timeNodes.push([s,null]) + // } + // }) + // } + // }) + + // } + + + + + function formatDate (date) { + var year = date.getFullYear(); + var month = String(date.getMonth() + 1).padStart(2, '0'); + var day = String(date.getDate()).padStart(2, '0'); + var hour = String(date.getHours()).padStart(2, '0'); + + return year + '-' + month + '-' + day + ' ' + hour; + } + + function getTimeNodes () { + var currentTime = new Date(); // 当前时间 + var timeNodes = []; + + for (var i = 0; i < 24; i++) { + var timeNode = formatDate(currentTime); + timeNodes.push(timeNode); + + currentTime.setHours(currentTime.getHours() - 1); // 减去1小时 + } + + return timeNodes; + } + + + + + function handleRow (record, index) {//斑马条纹 + // 给偶数行设置斑马纹 + if (index % 2 === 0) { + return { + style: { + background: '#F6F9FF', + } + }; + } else { + return {}; + } + } return (
@@ -40,52 +127,58 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou
-
- +
+ {/*
*/} +