diff --git a/web/client/src/layout/containers/layout/index.jsx b/web/client/src/layout/containers/layout/index.jsx index 0fb8441..0d827c6 100644 --- a/web/client/src/layout/containers/layout/index.jsx +++ b/web/client/src/layout/containers/layout/index.jsx @@ -12,7 +12,7 @@ import PerfectScrollbar from 'perfect-scrollbar'; import { useLocation } from "react-router"; NProgress.configure({ - template: ` + template: `
@@ -25,302 +25,304 @@ NProgress.configure({ let scrollbar // const location111 = useLocation(); const LayoutContainer = props => { - const { - dispatch, msg, user, copyright, children, sections, clientWidth, clientHeight, - location, match, routes, history, socket, - } = props - const [collapsed, setCollapsed] = useState(false) + const { + dispatch, msg, user, copyright, children, sections, clientWidth, clientHeight, + location, match, routes, history, socket, + } = props + const [collapsed, setCollapsed] = useState(false) - NProgress.start(); + NProgress.start(); - const resize_ = () => { - dispatch(resize( - document.getElementById('PomsApp').clientHeight, - document.getElementById('PomsApp').clientWidth - (collapsed ? 120 : 240) - )); - } - function deepCopy (data) {//深拷贝 - //string,number,bool,null,undefined,symbol - //object,array,date - if (data && typeof data === "object") { - //针对函数的拷贝 - if (typeof data === "function") { - let tempFunc = data.bind(null); - tempFunc.prototype = deepCopy(data.prototype); - return tempFunc; - } + const resize_ = () => { + dispatch(resize( + document.getElementById('PomsApp').clientHeight, + document.getElementById('PomsApp').clientWidth - (collapsed ? 120 : 240) + )); + } + function deepCopy (data) {//深拷贝 + //string,number,bool,null,undefined,symbol + //object,array,date + if (data && typeof data === "object") { + //针对函数的拷贝 + if (typeof data === "function") { + let tempFunc = data.bind(null); + tempFunc.prototype = deepCopy(data.prototype); + return tempFunc; + } - switch (Object.prototype.toString.call(data)) { - case "[object String]": - return data.toString(); - case "[object Number]": - return Number(data.toString()); - case "[object Boolean]": - return new Boolean(data.toString()); - case "[object Date]": - return new Date(data.getTime()); - case "[object Array]": - var arr = []; - for (let i = 0; i < data.length; i++) { - arr[i] = deepCopy(data[i]); - } - return arr; + switch (Object.prototype.toString.call(data)) { + case "[object String]": + return data.toString(); + case "[object Number]": + return Number(data.toString()); + case "[object Boolean]": + return new Boolean(data.toString()); + case "[object Date]": + return new Date(data.getTime()); + case "[object Array]": + var arr = []; + for (let i = 0; i < data.length; i++) { + arr[i] = deepCopy(data[i]); + } + return arr; - //js自带对象或用户自定义类实例 - case "[object Object]": - var obj = {}; - for (let key in data) { - //会遍历原型链上的属性方法,可以用hasOwnProperty来控制 (obj.hasOwnProperty(prop) - obj[key] = deepCopy(data[key]); - } - return obj; - } - } else { - //string,number,bool,null,undefined,symbol - return data; - } - } - const [allItems, setAllItems] = useState([]) - const [headerItems, setHeaderItems] = useState([]) - const [leftItems, setLeftItems] = useState([]) - const [leftChange, setLeftChange] = useState(true) - const [leftShow, setLeftShow] = useState(false) - useEffect(() => { - let topItems = []//头部导航 - const lastSelectedKeys = localStorage.getItem('poms_selected_sider') - let nextItems = []//所有导航 - for (let c of sections) { - if (typeof c.getNavItem == 'function') { - let item = c.getNavItem(user, dispatch); - if (item) { - nextItems.push.apply(nextItems, item) - if (item.length > 0) { - for (let j = 0; j < item.length; j++) { - let itm = deepCopy(item[j]); - if (itm.hasOwnProperty('items')) { - for (let i = 0; i < itm.items.length; i++) { - itm.items[i].fatherKey = itm.itemKey - delete itm.items[i].items - } - topItems.push(itm) - } - else { - topItems.push.apply(topItems, item) - } + //js自带对象或用户自定义类实例 + case "[object Object]": + var obj = {}; + for (let key in data) { + //会遍历原型链上的属性方法,可以用hasOwnProperty来控制 (obj.hasOwnProperty(prop) + obj[key] = deepCopy(data[key]); + } + return obj; + } + } else { + //string,number,bool,null,undefined,symbol + return data; + } + } + const [allItems, setAllItems] = useState([]) + const [headerItems, setHeaderItems] = useState([]) + const [leftItems, setLeftItems] = useState([]) + const [leftChange, setLeftChange] = useState(true) + const [leftShow, setLeftShow] = useState(false) + useEffect(() => { + let topItems = []//头部导航 + const lastSelectedKeys = localStorage.getItem('poms_selected_sider') + let nextItems = []//所有导航 + for (let c of sections) { + if (typeof c.getNavItem == 'function') { + let item = c.getNavItem(user, dispatch); + if (item) { + nextItems.push.apply(nextItems, item) + if (item.length > 0) { + for (let j = 0; j < item.length; j++) { + let itm = deepCopy(item[j]); + if (itm.hasOwnProperty('items')) { + for (let i = 0; i < itm.items.length; i++) { + itm.items[i].fatherKey = itm.itemKey + delete itm.items[i].items } - } - } + topItems.push(itm) + } + else { + topItems.push.apply(topItems, item) + } + } + } } - } - setAllItems(nextItems) - setHeaderItems(topItems) - if (lastSelectedKeys) {//如果有缓存 - for (let i = 0; i < nextItems.length; i++) { - if (JSON.parse(lastSelectedKeys)[0] == nextItems[i].itemKey) { + } + } + setAllItems(nextItems) + setHeaderItems(topItems) + if (lastSelectedKeys) {//如果有缓存 + for (let i = 0; i < nextItems.length; i++) { + if (JSON.parse(lastSelectedKeys)[0] == nextItems[i].itemKey) { - let openArr = [] - for (let j = 0; j < nextItems[i].items.length; j++) { - openArr.push(nextItems[i].items[j].itemKey) - } - localStorage.setItem('poms_open_sider', JSON.stringify(openArr)) - setLeftItems(nextItems[i].items) - } + let openArr = [] + for (let j = 0; j < nextItems[i].items.length; j++) { + openArr.push(nextItems[i].items[j].itemKey) + } + localStorage.setItem('poms_open_sider', JSON.stringify(openArr)) + setLeftItems(nextItems[i].items) } - setLeftShow(true) - } - else { - setLeftShow(false) - } + } + setLeftShow(true) + } + else { + setLeftShow(false) + } - window.addEventListener('resize', resize_); - return () => { - window.removeEventListener('resize', resize_); - } - }, []) + window.addEventListener('resize', resize_); + return () => { + window.removeEventListener('resize', resize_); + } + }, []) - useEffect(() => { - let pathnameArr = location.pathname.split('/') - if (location.pathname == '/userCenter') { - localStorage.setItem('poms_open_sider', JSON.stringify([])) - localStorage.removeItem('poms_selected_sider') - setLeftShow(false) - } - let openArr = [] - for (let i = 0; i < allItems.length; i++) { - if (allItems[i].items) { - for (let j = 0; j < allItems[i].items.length; j++) { - if (allItems[i].items[j].items) { - for (let k = 0; k < allItems[i].items[j].items.length; k++) { - if (allItems[i].items[j].items[k].to == location.pathname) { - for (let o = 0; o < allItems[i].items.length; o++) { - openArr.push(allItems[i].items[o].itemKey) - } - localStorage.setItem('poms_selected_sider', JSON.stringify([pathnameArr[1]])) - localStorage.setItem('poms_open_sider', JSON.stringify(openArr)) - setLeftItems(allItems[i].items) - setLeftShow(true) - } + useEffect(() => { + let pathnameArr = location.pathname.split('/') + if (location.pathname == '/userCenter') { + localStorage.setItem('poms_open_sider', JSON.stringify([])) + localStorage.removeItem('poms_selected_sider') + setLeftShow(false) + } + let openArr = [] + for (let i = 0; i < allItems.length; i++) { + if (allItems[i].items) { + for (let j = 0; j < allItems[i].items.length; j++) { + if (allItems[i].items[j].items) { + for (let k = 0; k < allItems[i].items[j].items.length; k++) { + if (allItems[i].items[j].items[k].to == location.pathname) { + for (let o = 0; o < allItems[i].items.length; o++) { + openArr.push(allItems[i].items[o].itemKey) } - } - } + localStorage.setItem('poms_selected_sider', JSON.stringify([pathnameArr[1]])) + localStorage.setItem('poms_open_sider', JSON.stringify(openArr)) + setLeftItems(allItems[i].items) + setLeftShow(true) + } + } + } } - } - }, [location]) + } + } + }, [location]) - useEffect(() => { - NProgress.done(); - if ((!user || !user.authorized)) { - history.push('/signin'); - } - if (msg) { - if (msg.done) { - Notification.success({ - // title: msg.done, - content: msg.done, - duration: 2, - }) - } - if (msg.error) { - Notification.error({ - // title: msg.error, - content: msg.error, - duration: 2, - }) - } - } - const dom = document.getElementById('page-content'); - if (dom) { + useEffect(() => { + NProgress.done(); + if ((!user || !user.authorized)) { + history.push('/signin'); + } + if (msg) { + if (msg.done) { + Notification.success({ + // title: msg.done, + content: msg.done, + duration: 2, + }) + } + if (msg.error) { + Notification.error({ + // title: msg.error, + content: msg.error, + duration: 2, + }) + } + } + const dom = document.getElementById('page-content'); + setTimeout(() => { + if (dom) { if (!scrollbar) { - scrollbar = new PerfectScrollbar('#page-content', { suppressScrollX: true }); - scrollbar.update(); + scrollbar = new PerfectScrollbar('#page-content', { suppressScrollX: true }); + // scrollbar.update(); } else { - scrollbar.update(); - dom.scrollTop = 0; + scrollbar.update(); + dom.scrollTop = 0; } - } - }) + } + }, 300) + }) - // websocket 使用测试 - useEffect(() => { - // console.log(socket) - if (socket) { - socket.on('CAMERA_ONLINE', function (msg) { - console.info(msg); - if (msg.online == 'ON') { - Notification.success({ - title: 'Hi', - content: (
{msg.name}
已上线。
), - duration: 2, - }) - } - if (msg.online == 'OFF') { - Notification.error({ - title: 'Hi', - content: (
{msg.name}
发生离线。
), - duration: 2, - }) - } - }); - return () => { - socket.off("CAMERA_ONLINE"); + // websocket 使用测试 + useEffect(() => { + // console.log(socket) + if (socket) { + socket.on('CAMERA_ONLINE', function (msg) { + console.info(msg); + if (msg.online == 'ON') { + Notification.success({ + title: 'Hi', + content: (
{msg.name}
已上线。
), + duration: 2, + }) } - } - }, [socket]) - - return ( - - { - <> - -
{ - setCollapsed(!collapsed); - }} - collapsed={collapsed} - history={history} - tochange={(val) => { - setLeftChange(!leftChange) - if (val.fatherKey) { - for (let i = 0; i < allItems.length; i++) { - if (val.fatherKey == allItems[i].itemKey) { - let openArr = [] - for (let j = 0; j < allItems[i].items.length; j++) { - openArr.push(allItems[i].items[j].itemKey) - } - localStorage.setItem('poms_selected_sider', JSON.stringify([val.fatherKey])) - localStorage.setItem('poms_open_sider', JSON.stringify(openArr)) - setLeftItems(allItems[i].items) - } - } - setLeftShow(true) - } - else { - localStorage.setItem('poms_open_sider', JSON.stringify([])) - localStorage.removeItem('poms_selected_sider') - setLeftShow(false) - } - history.push(val.to); - }} - /> - - - {leftShow ? ( - - ) : ('')} - -
-
-
- {children} -
- -
- -
-
-
-
- + if (msg.online == 'OFF') { + Notification.error({ + title: 'Hi', + content: (
{msg.name}
发生离线。
), + duration: 2, + }) } - - ) + }); + return () => { + socket.off("CAMERA_ONLINE"); + } + } + }, [socket]) + + return ( + + { + <> + +
{ + setCollapsed(!collapsed); + }} + collapsed={collapsed} + history={history} + tochange={(val) => { + setLeftChange(!leftChange) + if (val.fatherKey) { + for (let i = 0; i < allItems.length; i++) { + if (val.fatherKey == allItems[i].itemKey) { + let openArr = [] + for (let j = 0; j < allItems[i].items.length; j++) { + openArr.push(allItems[i].items[j].itemKey) + } + localStorage.setItem('poms_selected_sider', JSON.stringify([val.fatherKey])) + localStorage.setItem('poms_open_sider', JSON.stringify(openArr)) + setLeftItems(allItems[i].items) + } + } + setLeftShow(true) + } + else { + localStorage.setItem('poms_open_sider', JSON.stringify([])) + localStorage.removeItem('poms_selected_sider') + setLeftShow(false) + } + history.push(val.to); + }} + /> + + + {leftShow ? ( + + ) : ('')} + +
+
+
+ {children} +
+ +
+ +
+
+
+
+ + } + + ) } function mapStateToProps (state) { - const { global, auth, ajaxResponse, webSocket } = state; - return { - title: global.title, - copyright: global.copyright, - sections: global.sections, - actions: global.actions, - clientWidth: global.clientWidth, - clientHeight: global.clientHeight, - msg: ajaxResponse.msg, - user: auth.user, - socket: webSocket.socket - }; + const { global, auth, ajaxResponse, webSocket } = state; + return { + title: global.title, + copyright: global.copyright, + sections: global.sections, + actions: global.actions, + clientWidth: global.clientWidth, + clientHeight: global.clientHeight, + msg: ajaxResponse.msg, + user: auth.user, + socket: webSocket.socket + }; } export default connect(mapStateToProps)(LayoutContainer); \ No newline at end of file diff --git a/web/client/src/sections/control/containers/control.jsx b/web/client/src/sections/control/containers/control.jsx index 2a8e40d..4659cd2 100644 --- a/web/client/src/sections/control/containers/control.jsx +++ b/web/client/src/sections/control/containers/control.jsx @@ -235,6 +235,7 @@ const Control = (props) => { let webtop = 0 let webId = document.getElementById('web'); if (web) clearInterval(web) + let memberId = document.getElementById('member'); if (memberId) { function webstart () { member = setInterval(() => { @@ -701,236 +702,236 @@ const Control = (props) => { {/* 统计概览 */} { - exhibition.current?.overall?.find(v => v.key == 'statistical') ? <> -
-
-
-
统计概览
-
STATISTICAL OVERVIEW
-
-
- { - setSetup(true) - setTableType('statistical') - attribute('statistical') - setSetData(5) - }} /> + exhibition.current?.overall?.find(v => v.key == 'statistical') ? <> +
+
+
+
统计概览
+
STATISTICAL OVERVIEW
+
+
+ { + setSetup(true) + setTableType('statistical') + attribute('statistical') + setSetData(5) + }} /> +
-
- {/* 统计概览 */} -
-
- {/* 项目 */} - { - pepProjectId ? - '' : -
- {pomsList?.map((v, index) => { - return
setProjectId(v.pepProjectId)}>{v.pepProjectName}
- })} -
} - - {/* 项目里程碑 */} - { - exhibition.current?.statistical?.find(v => v.key == 'milestone') && projectId && - projectData?.find(u => u.id == projectId)?.pepProjectName ? -
-
- 项目里程碑 -
-
-
-
- 立项时间: -
-
- 暂无 -
+ {/* 统计概览 */} +
+
+ {/* 项目 */} + { + pepProjectId ? + '' : +
+ {pomsList?.map((v, index) => { + return
setProjectId(v.pepProjectId)}>{v.pepProjectName}
+ })} +
} + + {/* 项目里程碑 */} + { + exhibition.current?.statistical?.find(v => v.key == 'milestone') && projectId && + projectData?.find(u => u.id == projectId)?.pepProjectName ? +
+
+ 项目里程碑
-
-
- 施工时间: +
+
+
+ 立项时间: +
+
+ 暂无 +
-
- 暂无 +
+
+ 施工时间: +
+
+ 暂无 +
-
-
-
-
- 内验时间: +
+
+
+ 内验时间: +
+
+ 暂无 +
-
- 暂无 +
+
+ 外验时间: +
+
+ 暂无 +
-
+
- 外验时间: -
-
- 暂无 -
-
-
-
-
- 工程维保时间: -
-
- 暂无 -
-
-
-
-
- 售后维修时间: + 工程维保时间:
暂无
- {/* 进行中 */} -
-
- : ""} - {/* 相关成员 */} - {exhibition.current?.statistical?.find(v => v.key == 'personnel') ? -
-
- 相关成员 -
-
- {memberList?.map((item, index) => { - return ( -
-
-
- 成员 -
-
- {item.name} -
-
- (负责人) -
+
+
+
+ 售后维修时间:
-
- index > 0 ? ',' + v : v)}> -
- {item.department[0]} -
-
+
+ 暂无
- ) - })} -
-
- : ""} - {/* 平台设备接入 */} - {exhibition.current?.statistical?.find(v => v.key == 'DeviceAccess') ? -
-
- 平台设备接入 -
-
- { - equipmentList.map((item, index) => { + {/* 进行中 */} +
+
+ : ""} + {/* 相关成员 */} + {exhibition.current?.statistical?.find(v => v.key == 'personnel') ? +
+
+ 相关成员 +
+
+ {memberList?.map((item, index) => { return ( -
-
- 5阶ZK1高清摄球机 -
-
- 视频 -
-
- 网络 - {/* 网络 */} +
+
+
+ 成员 +
+
+ {item.name} +
+
+ (负责人) +
-
- 在线 +
+ index > 0 ? ',' + v : v)}> +
+ {item.department[0]} +
+
- {/*
- 掉线 -
*/}
) - }) - } -
-
- : ""} - {/* 关联web应用 */} - {exhibition.current?.statistical?.find(v => v.key == 'web') ? -
-
- 关联web应用 + })} +
-
- { - webList.map((item, index) => { - return ( -
-
+ : ""} + {/* 平台设备接入 */} + {exhibition.current?.statistical?.find(v => v.key == 'DeviceAccess') ? +
+
+ 平台设备接入 +
+
+ { + equipmentList.map((item, index) => { + return ( +
+
+ 5阶ZK1高清摄球机 +
+
+ 视频 +
- web应用 + 网络 + {/* 网络 */}
-
- - {item.url} - +
+ 在线
+ {/*
+ 掉线 +
*/}
-
- {item.name} -
-
- ) - }) - } -
-
- : ""} - {/* 异常&问题 */} - {exhibition.current?.statistical?.find(v => v.key == 'problem') ? -
-
- 异常&问题 + ) + }) + } +
-
- { - problemsList?.map((v, index) => { - return ( -
{ - dispatch(push(v.url)) - }}> -
- 【{v.SourceName}】{v.groupName}{v.groupName == '视频异常' ? "" : ',诊断为 '} {v.typeName},请前往确认 + : ""} + {/* 关联web应用 */} + {exhibition.current?.statistical?.find(v => v.key == 'web') ? +
+
+ 关联web应用 +
+
+ { + webList.map((item, index) => { + return ( +
+
+
+ web应用 +
+ +
+
+ {item.name} +
-
- {moment(v.StartTime).format("YYYY-MM-DD HH:mm:ss")} + ) + }) + } +
+
+ : ""} + {/* 异常&问题 */} + {exhibition.current?.statistical?.find(v => v.key == 'problem') ? +
+
+ 异常&问题 +
+
+ { + problemsList?.map((v, index) => { + return ( +
{ + dispatch(push(v.url)) + }}> +
+ 【{v.SourceName}】{v.groupName}{v.groupName == '视频异常' ? "" : ',诊断为 '} {v.typeName},请前往确认 +
+
+ {moment(v.StartTime).format("YYYY-MM-DD HH:mm:ss")} +
-
- ) - }) - } + ) + }) + } +
-
- : ""} -
-
: ""} + : ""} +
+
: ""}
{exhibition.current?.overall?.find(v => v.key == 'analyse') ?