diff --git a/api/app/lib/controllers/alarm/app.js b/api/app/lib/controllers/alarm/app.js index b15521b..43d73fc 100644 --- a/api/app/lib/controllers/alarm/app.js +++ b/api/app/lib/controllers/alarm/app.js @@ -36,12 +36,12 @@ async function inspectionList (ctx) { const models = ctx.fs.dc.models; const { clickHouse } = ctx.app.fs const { utils: { anxinStrucIdRange, pomsProjectRange } } = ctx.app.fs - const { timeStart, timeEnd, projectId, appId, noted } = ctx.query + const { pepProjectId, timeStart, timeEnd, projectId, appId, noted } = ctx.query let pomsProjectIds = null if (!projectId && !appId) { let pomsProject = await pomsProjectRange({ - ctx, + ctx, pepProjectId }) pomsProjectIds = pomsProject.map(p => p.id) } diff --git a/api/app/lib/controllers/project/index.js b/api/app/lib/controllers/project/index.js index 1ecccec..6491184 100644 --- a/api/app/lib/controllers/project/index.js +++ b/api/app/lib/controllers/project/index.js @@ -22,8 +22,8 @@ async function pomsProject (ctx) { try { const models = ctx.fs.dc.models; const { clickHouse } = ctx.app.fs - const { userId, pepUserId } = ctx.fs.api - const { limit, page } = ctx.query + const { userId, pepUserId, userInfo, pepUserInfo } = ctx.fs.api + const { limit, page, global } = ctx.query let findOption = { where: { @@ -35,7 +35,9 @@ async function pomsProject (ctx) { model: models.App, } } - + if (global && !userInfo.role.includes('SuperAdmin') && !userInfo.role.includes('admin')) { + findOption.where = { id: { $in: userInfo.correlationProject } } + } if (limit) { findOption.limit = limit } diff --git a/web/client/src/layout/actions/global.js b/web/client/src/layout/actions/global.js index a33064a..015d0c5 100644 --- a/web/client/src/layout/actions/global.js +++ b/web/client/src/layout/actions/global.js @@ -43,4 +43,15 @@ export function initApiRoot () { }) }); } +} + +export const PEPPROJECTID = 'PEPPROJECTID'; +export function pepProject (pepProjectId) { + return { + type: PEPPROJECTID, + payload: { + pepProjectId: pepProjectId, + + } + } } \ No newline at end of file diff --git a/web/client/src/layout/components/header/index.jsx b/web/client/src/layout/components/header/index.jsx index 88effec..a9c3f29 100644 --- a/web/client/src/layout/components/header/index.jsx +++ b/web/client/src/layout/components/header/index.jsx @@ -1,12 +1,22 @@ "use strict"; -import React from "react"; -import { connect } from "react-redux"; -import { SplitButtonGroup, Dropdown, Button, Nav, Avatar } from '@douyinfe/semi-ui'; -import { IconTreeTriangleDown } from '@douyinfe/semi-icons'; +import React, { useEffect, useState } from 'react' +import { connect, createStore } from "react-redux"; +import Immutable from 'immutable'; +import { pepProject } from '../../actions/global'; +import { SplitButtonGroup, Dropdown, Button, Nav, Avatar, Input, Tooltip, Tabs, TabPane } from '@douyinfe/semi-ui'; +import { IconTreeTriangleDown, IconSearch } from '@douyinfe/semi-icons'; +import PerfectScrollbar from "perfect-scrollbar"; import "./index.less"; +let newScrollbar; const Header = (props) => { const { dispatch, history, user, actions, socket, headerItems, tochange } = props; + const { install } = actions + const [pomsList, setPomsList] = useState([]) + const [pomsName, setPomsName] = useState('全局') + const [pepProjectId, setPepProjectId] = useState() + const [keyword, setKeyword] = useState('') + const [Scrollbar, setScrollbar] = useState(false) let userRole = user?.pomsUserInfo?.role let modalRole = [] if (userRole) { @@ -21,8 +31,36 @@ const Header = (props) => { modal = [...new Set(modal)] modalRole = headerItems?.filter(v => modal.includes(v.itemKey)) if (userRole?.includes('SuperAdmin') || userRole?.includes('admin')) modalRole = headerItems - } + useEffect(() => { + dispatch(install.getProjectPoms({ global: 1 })).then((res) => { //获取已绑定项目 + if (res.success) { + setPomsList(res.payload.data?.rows?.filter(v => v.pepProjectIsDelete == 0)) + } + }) + }, []) + + useEffect(() => { + const domProject = document.getElementById("overall"); + if (domProject) { + newScrollbar = new PerfectScrollbar("#overall", { + suppressScrollX: true, + }); + if (domProject && newScrollbar) { + newScrollbar.update(); + } + } + }, [Scrollbar]) + + + + + useEffect(() => { + dispatch(pepProject(pepProjectId)) + console.log(); + }, [pepProjectId]) + + return ( <>
@@ -53,13 +91,65 @@ const Header = (props) => { ), text: ( <> + + { + setScrollbar(!Scrollbar) + }} + render={ + + + +
+ } onChange={(v) => setKeyword(v)} showClear> +
+ {pomsList?.length > 0 ? + pomsList.filter(u => u.pepProjectName?.includes(keyword))?.map(v => { + return - {/* */} - - {/* { }} menu={{}} trigger="click" position="bottomRight"> */} - - {/* */} - {/* */} + { + v.pepProjectName?.length > 15 ? {v.pepProjectName}
}> +
+
{ + console.log(v.pepProjectId); + setPomsName(v.pepProjectName) + setPepProjectId(v.pepProjectId) + }}> + {v.pepProjectName?.length > 15 ? `${v.pepProjectName?.substr(0, 15)}` : v.pepProjectName} +
+
+ + :
{ + console.log(v.pepProjectId); + setPomsName(v.pepProjectName) + setPepProjectId(v.pepProjectId) + }}>{v.pepProjectName}
+ } + + }) : "" + } +
+ + { + setPomsName('全局') + setPepProjectId('') + }}>全局} itemKey="全局"> + + + + } trigger="click" position="bottomRight"> + + + + ), }} diff --git a/web/client/src/layout/reducers/global.js b/web/client/src/layout/reducers/global.js index 600c572..2590521 100644 --- a/web/client/src/layout/reducers/global.js +++ b/web/client/src/layout/reducers/global.js @@ -1,6 +1,6 @@ 'use strict'; import Immutable from 'immutable'; -import { INIT_LAYOUT, RESIZE, INIT_API_ROOT } from '../actions/global'; +import { INIT_LAYOUT, RESIZE, INIT_API_ROOT,PEPPROJECTID } from '../actions/global'; function global (state = { title: '', @@ -33,6 +33,10 @@ function global (state = { apiRoot: payload.apiRoot, iotVcmpWeb: payload.iotVcmpWeb }).toJS(); + case PEPPROJECTID: + return Immutable.fromJS(state).merge({ + pepProjectId: payload.pepProjectId, + }).toJS(); default: return state; } diff --git a/web/client/src/sections/problem/components/inspection.jsx b/web/client/src/sections/problem/components/inspection.jsx index ebf354d..d2c8b24 100644 --- a/web/client/src/sections/problem/components/inspection.jsx +++ b/web/client/src/sections/problem/components/inspection.jsx @@ -11,7 +11,7 @@ import { log } from "ezuikit-js"; let projectScrollbar; let timer -const Inspection = ({ dispatch, actions, user, route, statistic }) => { +const Inspection = ({ dispatch, actions, user, route, statistic, pepProjectId }) => { const { problem } = actions const [selectProject, setSelectProject] = useState([]) //所选项目 const [applyFilter, setApplyFilter] = useState([]) //应用筛选 @@ -26,22 +26,24 @@ const Inspection = ({ dispatch, actions, user, route, statistic }) => { const api = useRef(); const unfoldApi = useRef(false); - +console.log(pepProjectId); useEffect(() => { - dispatch(problem.getProjectPoms()).then((res) => { + dispatch(problem.getProjectPoms({ global: 1 })).then((res) => { if (res.success) { let project = [] let apply = [] res.payload.data?.rows?.map(v => { - project.push({ name: v.pepProjectName || v.name || v.id, value: v.id }) - v.apps.map(app => apply.push({ name: app.name, value: app.id })) + if (!pepProjectId || v.pepProjectId == pepProjectId) { + project.push({ name: v.pepProjectName || v.name || v.id, value: v.id }) + v.apps.map(app => apply.push({ name: app.name, value: app.id })) + } }) setSelectProject(project) setApplyFilter(apply) } }) - }, []) + }, [pepProjectId]) useEffect(() => { if (projectScrollbar) projectScrollbar.destroy() @@ -66,14 +68,14 @@ const Inspection = ({ dispatch, actions, user, route, statistic }) => { dispatch(problem.getAlarmLnspection({ timeStart: moment().day(moment().day() - 1).startOf('day').format('YYYY-MM-DD HH:mm:ss'), timeEnd: moment().endOf('day').format('YYYY-MM-DD HH:mm:ss') - , ...checkPatrol + , ...checkPatrol, pepProjectId: pepProjectId })).then((res) => { if (res.success) { setPatrolAbnormal(res.payload.data) setNotRead(res.payload.data.filter(v => !v.notedTime).length) } }) - }, [checkPatrol]) + }, [checkPatrol, pepProjectId]) useEffect(() => { @@ -334,7 +336,7 @@ function mapStateToProps (state) { return { user: auth.user, actions: global.actions, - // global: global, + pepProjectId: global.pepProjectId, // members: members.data, }; } diff --git a/web/client/src/sections/problem/components/sideSheet.jsx b/web/client/src/sections/problem/components/sideSheet.jsx index 391e59f..d4a320f 100644 --- a/web/client/src/sections/problem/components/sideSheet.jsx +++ b/web/client/src/sections/problem/components/sideSheet.jsx @@ -13,7 +13,7 @@ function SideSheets ({ dispatch, actions, close, alarmId }) { const { problem } = actions; const [clickStyle, setclickStyle] = useState(); - const [query, setQuery] = useState({ page: 0, pageSize: 10 }); + const [query, setQuery] = useState({ page: 0, limit: 10 }); const [dataSource, setdataSource] = useState([]); const [option, setOption] = useState({}); @@ -187,7 +187,7 @@ function SideSheets ({ dispatch, actions, close, alarmId }) { currentPage={query.page + 1} pageSizeOpts={[10, 20, 30, 40]} onChange={(currentPage, pageSize) => { - setQuery({ pageSize: pageSize, page: currentPage - 1 }); + setQuery({ limit: pageSize, page: currentPage - 1 }); }} /> : ""} diff --git a/web/client/src/sections/problem/components/tableData.jsx b/web/client/src/sections/problem/components/tableData.jsx index 6ac0a52..2a1e911 100644 --- a/web/client/src/sections/problem/components/tableData.jsx +++ b/web/client/src/sections/problem/components/tableData.jsx @@ -8,7 +8,7 @@ import { emit } from "superagent"; -const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition, +const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition, pepProjectId, selected, setSelected, setIfBulk, setConfirm, setGenre, query, setQuery, tableData, setTableData }) => { const { problem } = actions @@ -21,7 +21,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition useEffect(() => { switch (route) { case 'useAbnormal': - dispatch(problem.getAlarmLnspectionApi({ ...search, pepProjectId: '' })).then((res) => { + dispatch(problem.getAlarmLnspectionApi({ ...search, pepProjectId: pepProjectId })).then((res) => { if (res.success) { let typeData = { element: "元素异常", apiError: "接口报错 ", timeout: "加载超时" } let tableDatas = res.payload.data?.rows.map(v => ({ @@ -34,7 +34,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition createTime: v.createTime ? moment(v.createTime).format("YYYY-MM-DD HH:mm:ss") : "", updateTime: v.updateTime ? moment(v.updateTime).format("YYYY-MM-DD HH:mm:ss") : "", confirmTime: v.confirmTime ? moment(v.confirmTime).format("YYYY-MM-DD HH:mm:ss") : "", - alarmContent: v.alarmContent, + alarmContent: v.alarmContent || '无', screenshot: v.screenshot, type: v.type ? typeData[v.type] : "", confirm: v.confirm, @@ -54,7 +54,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition } }) - dispatch(problem.getAlarmVideoList({ ...search, pepProjectId: '' })).then((res) => { + dispatch(problem.getAlarmVideoList({ ...search, pepProjectId: pepProjectId })).then((res) => { if (res.success) { let tableDatas = res.payload.data?.map(v => ({ key: v.alarmId, @@ -72,7 +72,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition resolve: v.resolve || [], cameraChannelNo: v.cameraChannelNo, cameraSerialNo: v.cameraSerialNo, - cameraKindId: v.cameraKindId ? cameraKind?.find(v => v.value == v.cameraKindId)?.name : "", + cameraKindId: v.cameraKindId ? cameraKind?.find(u => u.value == v.cameraKindId)?.name : "", venderName: v.venderName, platform: v.platform, confirm: v.confirmContent, @@ -101,7 +101,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition }) setGenre(genreData) if (data && data[0]?.id) { - dispatch(problem.getAlarmDataList({ ...query, ...search, groupId: data.map(v => v.id).join(), pepProjectId: '' })).then((res) => { + dispatch(problem.getAlarmDataList({ ...query, ...search, groupId: data.map(v => v.id).join(), pepProjectId: pepProjectId })).then((res) => { if (res.success) { setCount(res.payload.data?.count || 0) let tableDatas = res.payload.data?.rows?.map(v => ({ @@ -111,10 +111,10 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition name: r.pepProject?.projectName, state: r.pepProject?.constructionStatus }))?.filter(c => c), createTime: v.StartTime ? moment(v.StartTime).format("YYYY-MM-DD HH:mm:ss") : "", - updateTime: v.EndTime ? moment(v.EndTime).format("YYYY-MM-DD HH:mm:ss") : "无", + updateTime: v.EndTime ? moment(v.EndTime).format("YYYY-MM-DD HH:mm:ss") : "", confirmTime: v.confirmedTime ? moment(v.confirmedTime).format("YYYY-MM-DD HH:mm:ss") : "", SourceName: v.SourceName, - AlarmGroupUnit: v.AlarmGroupUnit ? genreData.find(r => r.value == v.AlarmGroupUnit)?.name : "", + AlarmGroupUnit: v.AlarmGroupUnit ? genreData.find(r => r.value == v.AlarmGroupUnit)?.name : "无", Strategy: v.AlarmGroupUnit ? genreData.find(r => r.value == v.AlarmGroupUnit)?.name : "", type: route == 'deviceAbnormal' ? v.DeviceStatus == 0 ? "离线" : '' : v.AlarmGroupUnit ? genreData.find(r => r.value == v.AlarmGroupUnit)?.name : "", cameraKindId: v.AlarmGroupUnit ? genreData.find(r => r.value == v.AlarmGroupUnit)?.name : "", @@ -137,7 +137,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition break; } - }, [query, search]) + }, [query, search, pepProjectId]) return ( @@ -209,7 +209,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition label={collectData.common.name + ':'} field={collectData.common.field} key={collectData.common.field} - // onChange={(v) => console.log(v)} + // onChange={(v) => console.log(v)} />) return frame })()} @@ -334,7 +334,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition pageSizeOpts={[10, 20, 30, 40]} onChange={(currentPage, pageSize) => { setQuery({ limit: pageSize, page: currentPage - 1 }); - + }} /> : ""} @@ -348,11 +348,12 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition function mapStateToProps (state) { const { auth, global, members } = state; - // console.log(auth.user); + // console.log(global); return { user: auth.user, actions: global.actions, global: global, + pepProjectId: global.pepProjectId, // members: members, }; } diff --git a/web/client/src/sections/problem/containers/dataAlarm.jsx b/web/client/src/sections/problem/containers/dataAlarm.jsx index 6136bb7..69e4e74 100644 --- a/web/client/src/sections/problem/containers/dataAlarm.jsx +++ b/web/client/src/sections/problem/containers/dataAlarm.jsx @@ -161,7 +161,7 @@ const DataAlarm = ({ match, dispatch, actions, user, loading, socket, iotVcmpWeb //表格设置信息 const tableList = { dataLnterrupt: ['index', 'projectName', 'StructureName', 'SourceName', 'AlarmGroupUnit', 'AlarmCodeName', 'sustainTime', 'createTime', 'AlarmContent', 'CurrentLevel', 'updateTime', 'detailCount', 'confirm', 'confirmTime',], - dataAbnormal: ['index', 'projectName', 'StructureName', 'SourceName', 'type', 'alarmType', 'createTime', 'sustainTime', 'AlarmContent', 'CurrentLevel', 'updateTime', 'detailCount', 'confirm', 'confirmTime'], + dataAbnormal: ['index', 'projectName', 'StructureName', 'SourceName', 'type', 'createTime', 'sustainTime', 'AlarmContent', 'CurrentLevel', 'updateTime', 'detailCount', 'confirm', 'confirmTime'], strategyHit: ['index', 'projectName', 'StructureName', 'SourceName', 'Strategy', 'State', 'createTime', 'sustainTime', 'AlarmContent', 'CurrentLevel', 'updateTime', 'detailCount', 'confirm', 'confirmTime'], videoAbnormal: ['index', 'projectName', 'StructureName', 'SourceName', 'station', 'cameraKindId', 'sustainTime', 'venderName', 'point', 'cameraSerialNo', 'cameraChannelNo', 'platform', 'AlarmContent', 'resolve', 'createTime', 'updateTime', 'confirm', 'confirmTime', 'camerOnline'], useAbnormal: ['index', 'projectName', 'appName', 'url', 'type', 'alarmContent', 'createTime', 'sustainTime', 'updateTime', 'confirm', 'confirmTime'], @@ -228,7 +228,7 @@ const DataAlarm = ({ match, dispatch, actions, user, loading, socket, iotVcmpWeb return r.SourceName ?
{r.SourceName}
{data ?
{data}
: ""} -
: "" + : "无" } }, { name: '测点', sort: 4.1, value: 'point', render: (_, r, index) => r.station?.length > 0 ? r.station?.map(v =>
{v.name}
) : "无" }, @@ -250,7 +250,7 @@ const DataAlarm = ({ match, dispatch, actions, user, loading, socket, iotVcmpWeb { name: '产生次数', sort: 19, value: 'detailCount', render: (_, r, index) => r.detailCount + '次' }, { name: '确认信息', sort: 20, value: 'confirm', render: (_, r, index) => { - return r.State == 3 || r.autoRestore || r.confirmAuto ? '无' : r.State == 4 ? r.confirm || '无' : r.confirmTime ? r.confirm : '未确认' + return r.State == 3 || r.autoRestore || r.confirmAuto ? '无' : r.State == 4 ? r.confirm || '无' : r.confirmTime ? r.confirm || '无' : '未确认' } }, { name: '确认/恢复时间', sort: 21, value: 'confirmTime', render: (_, r, index) =>
{r.confirmTime ? r.confirmTime : "无"}
},