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 b145d78..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 @@ -22,23 +22,49 @@ const MirroringDetail = (props) => { key: '0', }, ]); - const searchData = useRef({})//摄像头查询条件 - const [search, setSearch] = useState({}); //搜索条件 - const [indeterminate, setIndeterminate] = useState(true);//全选 + const [indeterminate, setIndeterminate] = useState(false);//全选 const [checkAll, setCheckall] = useState(false);//全选是否 - const onCheckAllChange = (e) => {//全选 - console.log(e); - setCheckedList(e.target.checked ? plainOptions : []); + 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); - }; - 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); + } + 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 || '', + }) + } + setShowCameraList(optionsList) + setPlainOptions(optionsList) }); } + function onChange (checkedList) {//摄像头选择 + setCheckedList(checkedList); + setIndeterminate(!!checkedList.length && checkedList.length < showCameraList.length); + setCheckall(checkedList.length === showCameraList.length); + } useEffect(() => { equipmentGetCamera(); }, []); @@ -86,7 +112,7 @@ const MirroringDetail = (props) => { 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) { + 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({ @@ -108,25 +134,27 @@ const MirroringDetail = (props) => { } } 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', - }] + 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', + }] + } } } } @@ -135,8 +163,6 @@ const MirroringDetail = (props) => { 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) { @@ -170,7 +196,43 @@ const MirroringDetail = (props) => { setEditKey('') } function cameraAdd (item) {//添加摄像头 - + let myplainOptions = JSON.parse(JSON.stringify(plainOptions)) + for (let i = 0; i < myplainOptions.length; i++) {//摄像头列表 + for (let j = 0; j < treeData.length; j++) {//第一级 + if (treeData[j].children) {//有没有子集 + for (let k = 0; k < treeData[j].children.length; k++) {//第二级 + if (treeData[j].children[k].children) {//有没有子集 + for (let l = 0; l < treeData[j].children[k].children.length; l++) {//第三级 + if (treeData[j].children[k].children[l].children) {//有没有子集 + for (let p = 0; p < treeData[j].children[k].children[l].children.length; p++) { + if (treeData[j].children[k].children[l].children[p].cameraId) { + if (myplainOptions[i].value == treeData[j].children[k].children[l].children[p].cameraId) { + myplainOptions.splice(i, 1) + } + } + } + } + else if (treeData[j].children[k].children[l].cameraId) {//有没有摄像头 + if (myplainOptions[i].value == treeData[j].children[k].children[l].cameraId) { + myplainOptions.splice(i, 1) + } + } + } + } + else if (treeData[j].children[k].cameraId) {//有没有摄像头 + if (myplainOptions[i].value == treeData[j].children[k].cameraId) { + myplainOptions.splice(i, 1) + } + } + } + } + } + } + console.log('myplainOptionsmyplainOptions', myplainOptions); + setCheckedList([]) + setShowCameraList(myplainOptions) + setAddCamera(true) + setAddCameraKey(item.key) } const renderLabel = (label, item) => {//树状展示 let keyArr = item.key.split('-') @@ -218,7 +280,7 @@ const MirroringDetail = (props) => { }