diff --git a/code/VideoAccess-VCMP/web/client/src/sections/openness/containers/mirroringDetail.jsx b/code/VideoAccess-VCMP/web/client/src/sections/openness/containers/mirroringDetail.jsx index df8205d..0c6113f 100644 --- a/code/VideoAccess-VCMP/web/client/src/sections/openness/containers/mirroringDetail.jsx +++ b/code/VideoAccess-VCMP/web/client/src/sections/openness/containers/mirroringDetail.jsx @@ -2,462 +2,668 @@ import React, { useEffect, useState, useRef } from 'react'; import { connect } from 'react-redux'; import '../style.less' import { Tree, Popconfirm, Typography, Input, Switch, Modal, Checkbox, CheckboxGroup } from "@douyinfe/semi-ui"; -import VideoScreen from '../components/videoScreen' const MirroringDetail = (props) => { - const { history, dispatch, actions, user, loading, StatusPushList } = props; - const { openness } = actions; - useEffect(() => { + const { history, dispatch, actions, user, loading, StatusPushList } = props; + const { openness } = actions; + useEffect(() => { - }, []); - // const = useRef(0) + }, []); + // const = useRef(0) - const [chooseNum, setChooseNum] = useState(0);//当前选择tab - const [chooseList, setChooseList] = useState(['节点', '样式', '功能']); - const [editKey, setEditKey] = useState('') - const [comingVisible, setComingVisible] = useState(false) - const [treeData, setTreeData] = useState([//树形控件数据 - { - label: '主要节点1', - value: '0', - key: '0', - }, - ]); - const searchData = useRef({})//摄像头查询条件 - const [search, setSearch] = useState({}); //搜索条件 - const [indeterminate, setIndeterminate] = useState(true);//全选 - const [checkAll, setCheckall] = useState(false);//全选是否 - const onCheckAllChange = (e) => {//全选 - console.log(e); - setCheckedList(e.target.checked ? plainOptions : []); - setIndeterminate(false); - setCheckall(e.target.checked); - }; - const equipmentGetCamera = () => { - searchData.current = { ...search } - dispatch(openness.getCamera(searchData.current)).then((res) => { - // limits.current = res.payload.data.data.length - console.log(res.payload.data.data); - }); - } - useEffect(() => { - equipmentGetCamera(); - }, []); - function nodeDelete (item) {//删除树状子节点 - let mainData = JSON.parse(JSON.stringify(treeData)) - let nodeKeyArr = item.key.split('-') - if (nodeKeyArr.length == 1) { - mainData.splice( - mainData.indexOf(mainData.find(function (element) { - return element.key === item.key - })), 1) - } else if (nodeKeyArr.length == 2) { - for (let index = 0; index < mainData.length; index++) { - mainData[index].children.splice( - mainData[index].children.indexOf(mainData[index].children.find(function (element) { - return element.key === item.key - })), 1) - } - } else if (nodeKeyArr.length == 3) { - for (let j = 0; j < mainData.length; j++) { - for (let i = 0; i < mainData[j].children.length; i++) { - mainData[j].children[i].children.splice( - mainData[j].children[i].children.indexOf(mainData[j].children[i].children.find(function (element) { - return element.key === item.key - })), 1) + const [chooseNum, setChooseNum] = useState(0);//当前选择tab + const [chooseList, setChooseList] = useState(['节点', '样式', '功能']); + const [editKey, setEditKey] = useState('') + const [comingVisible, setComingVisible] = useState(false) + const [treeData, setTreeData] = useState([//树形控件数据 + { + label: '主要节点1', + value: '0', + key: '0', + }, + ]); + const [indeterminate, setIndeterminate] = useState(false);//全选 + const [checkAll, setCheckall] = useState(false);//全选是否 + const [plainOptions, setPlainOptions] = useState([]);//摄像头选择 + const [checkedList, setCheckedList] = useState([]);//选中的摄像头列表 + const [mykeyword, setMykeyword] = useState('');//摄像头搜索 + const [showCameraList, setShowCameraList] = useState([])//展示的摄像头列表 + const [addCamera, setAddCamera] = useState(false);//添加视频弹框 + const [addCameraKey, setAddCameraKey] = useState('');//添加视频弹框 + + function onCheckAllChange (e) {//全选 + if (e.target.checked) { + let mycheckList = [] + for (let i = 0; i < showCameraList.length; i++) { + mycheckList.push(showCameraList[i].value) + } + setCheckedList(mycheckList) + } + else { + setCheckedList([]) + } + setIndeterminate(false); + setCheckall(e.target.checked); + } + function equipmentGetCamera () {//查询摄像头 + dispatch(openness.getCamera()).then((res) => { + let resList = res.payload.data.data + let optionsList = [] + for (let i = 0; i < resList.length; i++) { + optionsList.push({ + label: resList[i].name, + value: resList[i].id, + extra: 'DID:' + resList[i].gbCamera.did || '', + }) } - } - } else if (nodeKeyArr.length == 4) { - for (let k = 0; k < mainData.length; k++) { - for (let j = 0; j < mainData[k].children.length; j++) { - for (let i = 0; i < mainData[k].children[j].children.length; i++) { - mainData[k].children[j].children[i].children.splice( - mainData[k].children[j].children[i].children.indexOf(mainData[k].children[j].children[i].children.find(function (element) { + setShowCameraList(optionsList) + setPlainOptions(optionsList) + }); + } + function onChange (checkedList) {//摄像头选择 + setCheckedList(checkedList); + setIndeterminate(!!checkedList.length && checkedList.length < showCameraList.length); + setCheckall(checkedList.length === showCameraList.length); + } + useEffect(() => { + equipmentGetCamera(); + }, []); + function nodeDelete (item) {//删除树状子节点 + let mainData = JSON.parse(JSON.stringify(treeData)) + let nodeKeyArr = item.key.split('-') + if (nodeKeyArr.length == 1) { + mainData.splice( + mainData.indexOf(mainData.find(function (element) { + return element.key === item.key + })), 1) + } else if (nodeKeyArr.length == 2) { + for (let index = 0; index < mainData.length; index++) { + mainData[index].children.splice( + mainData[index].children.indexOf(mainData[index].children.find(function (element) { return element.key === item.key - })), 1) - } + })), 1) } - } - } - setTreeData(mainData) - } - function nodeAdd (item) {//添加树状子节点 - let mainData = JSON.parse(JSON.stringify(treeData)) - let nodeKeyArr = item.key.split('-') - if (nodeKeyArr.length == 1) { - for (let index = 0; index < mainData.length; index++) { - if (mainData[index].key == item.key) { - if (mainData[index].children && mainData[index].children > 0) { - let mainKey = mainData[index].children[mainData[index].children.length - 1].key - let thekeyarr = mainKey.split('-') - mainData[index].children.push({ - label: '二级节点' + (Number(thekeyarr[1]) + 2), - value: (Number(thekeyarr[0])) + '-' + (Number(thekeyarr[1]) + 1), - key: (Number(thekeyarr[0])) + '-' + (Number(thekeyarr[1]) + 1), - }) - } - else { - let mainKey = mainData[index].key - let thekeyarr = mainKey.split('-') - mainData[index].children = [{ - label: '二级节点1', - value: (Number(thekeyarr[0])) + '-0', - key: (Number(thekeyarr[0])) + '-0', - }] - } + } else if (nodeKeyArr.length == 3) { + for (let j = 0; j < mainData.length; j++) { + for (let i = 0; i < mainData[j].children.length; i++) { + mainData[j].children[i].children.splice( + mainData[j].children[i].children.indexOf(mainData[j].children[i].children.find(function (element) { + return element.key === item.key + })), 1) + } } - } - } else if (nodeKeyArr.length == 2) { - for (let index = 0; index < mainData.length; index++) { - for (let j = 0; j < mainData[index].children.length; j++) { - if (mainData[index].children[j].key == item.key) { - if (mainData[index].children[j].children && mainData[index].children[j].children.length > 0) { - let mainKey = mainData[index].children[j].children[mainData[index].children[j].children.length - 1].key - let thekeyarr = mainKey.split('-') - mainData[index].children[j].children.push({ - label: '三级节点' + (Number(thekeyarr[2]) + 2), - value: (Number(thekeyarr[0])) + '-' + (Number(thekeyarr[1])) + '-' + (Number(thekeyarr[2]) + 1), - key: (Number(thekeyarr[0])) + '-' + (Number(thekeyarr[1])) + '-' + (Number(thekeyarr[2]) + 1), - }) - } - else { - let mainKey = mainData[index].children[j].key - let thekeyarr = mainKey.split('-') - mainData[index].children[j].children = [{ - label: '三级节点1', - value: (Number(thekeyarr[0])) + '-' + (Number(thekeyarr[1])) + '-0', - key: (Number(thekeyarr[0])) + '-' + (Number(thekeyarr[1])) + '-0', - }] - } - } + } else if (nodeKeyArr.length == 4) { + for (let k = 0; k < mainData.length; k++) { + for (let j = 0; j < mainData[k].children.length; j++) { + for (let i = 0; i < mainData[k].children[j].children.length; i++) { + mainData[k].children[j].children[i].children.splice( + mainData[k].children[j].children[i].children.indexOf(mainData[k].children[j].children[i].children.find(function (element) { + return element.key === item.key + })), 1) + } + } } - } - } - setTreeData(mainData) - } - function changeLable (value, item) {//编辑摄像头名称 - console.log('valvalval', value); - console.log('itemitem', item); - let mainData = JSON.parse(JSON.stringify(treeData)) - let nodeKeyArr = item.key.split('-') - if (nodeKeyArr.length == 1) { - for (let index = 0; index < mainData.length; index++) { - if (mainData[index].key == item.key) { - mainData[index].label = value + } + setTreeData(mainData) + } + function nodeAdd (item) {//添加树状子节点 + let mainData = JSON.parse(JSON.stringify(treeData)) + let nodeKeyArr = item.key.split('-') + if (nodeKeyArr.length == 1) { + for (let index = 0; index < mainData.length; index++) { + if (mainData[index].key == item.key) { + if (mainData[index].children && mainData[index].children.length > 0) { + let mainKey = mainData[index].children[mainData[index].children.length - 1].key + let thekeyarr = mainKey.split('-') + mainData[index].children.push({ + label: '二级节点' + (Number(thekeyarr[1]) + 2), + value: (Number(thekeyarr[0])) + '-' + (Number(thekeyarr[1]) + 1), + key: (Number(thekeyarr[0])) + '-' + (Number(thekeyarr[1]) + 1), + }) + } + else { + let mainKey = mainData[index].key + let thekeyarr = mainKey.split('-') + mainData[index].children = [{ + label: '二级节点1', + value: (Number(thekeyarr[0])) + '-0', + key: (Number(thekeyarr[0])) + '-0', + }] + } + } } - } - } else if (nodeKeyArr.length == 2) { - for (let index = 0; index < mainData.length; index++) { - for (let j = 0; j < mainData[index].children.length; j++) { - if (mainData[index].children[j].key == item.key) { - mainData[index].children[j].label = value - } + } else if (nodeKeyArr.length == 2) { + for (let index = 0; index < mainData.length; index++) { + if (mainData[index].children) { + for (let j = 0; j < mainData[index].children.length; j++) { + if (mainData[index].children[j].key == item.key) { + if (mainData[index].children[j].children && mainData[index].children[j].children.length > 0) { + let mainKey = mainData[index].children[j].children[mainData[index].children[j].children.length - 1].key + let thekeyarr = mainKey.split('-') + mainData[index].children[j].children.push({ + label: '三级节点' + (Number(thekeyarr[2]) + 2), + value: (Number(thekeyarr[0])) + '-' + (Number(thekeyarr[1])) + '-' + (Number(thekeyarr[2]) + 1), + key: (Number(thekeyarr[0])) + '-' + (Number(thekeyarr[1])) + '-' + (Number(thekeyarr[2]) + 1), + }) + } + else { + let mainKey = mainData[index].children[j].key + let thekeyarr = mainKey.split('-') + mainData[index].children[j].children = [{ + label: '三级节点1', + value: (Number(thekeyarr[0])) + '-' + (Number(thekeyarr[1])) + '-0', + key: (Number(thekeyarr[0])) + '-' + (Number(thekeyarr[1])) + '-0', + }] + } + } + } + } } - } - } else if (nodeKeyArr.length == 3) { - for (let index = 0; index < mainData.length; index++) { - for (let j = 0; j < mainData[index].children.length; j++) { - for (let k = 0; k < mainData[index].children[j].children.length; k++) { - if (mainData[index].children[j].children[k].key == item.key) { - mainData[index].children[j].children[k].label = value - } - } + } + setTreeData(mainData) + } + function changeLable (value, item) {//编辑摄像头名称 + let mainData = JSON.parse(JSON.stringify(treeData)) + let nodeKeyArr = item.key.split('-') + if (nodeKeyArr.length == 1) { + for (let index = 0; index < mainData.length; index++) { + if (mainData[index].key == item.key) { + mainData[index].label = value + } } - } - } - setTreeData(mainData) - } - function lableBlur () { - setEditKey('') - } - function cameraAdd (item) {//添加摄像头 - - } - const renderLabel = (label, item) => {//树状展示 - let keyArr = item.key.split('-') - return ( -