| | |
| | | :show-checkbox="TreeDataPool.multiple" |
| | | :readonly="TreeDataPool.readonly" |
| | | :gb28181="gb28181" |
| | | :setting="setting" |
| | | @onCreated="handleCreated" |
| | | @onClick="itemClick" |
| | | @onCheck="itemCheck" |
| | | @onDblClick="onDblClick" |
| | | @onAddNode="addNode" |
| | | @onRemoveNode="delNode" |
| | | @onRenameNode="editNode" |
| | | @onAddDevice="addCamera" |
| | | @onImport="importCameras" |
| | | @onExpand="itemExpand" |
| | | @onCollapse="itemCollapse" |
| | | @onShowPic="showCameraPic" |
| | | /> |
| | | <div class="dialog-box-bg" v-show="showDialog" @click="hideDialogBox"></div> |
| | | <div |
| | |
| | | :style="{ left: clientX + 'px', top: clientY + 'px' }" |
| | | > |
| | | <el-card :body-style="{ padding: '10px' }"> |
| | | <el-form :model="dialogForm" size="mini" :rules="rules" ref="dialogForm" label-width="70px"> |
| | | <el-form |
| | | :model="dialogForm" |
| | | size="mini" |
| | | :rules="rules" |
| | | ref="dialogForm" |
| | | label-width="70px" |
| | | > |
| | | <el-form-item label="名称:" prop="name"> |
| | | <el-input v-model="dialogForm.text"></el-input> |
| | | <el-input |
| | | v-model="dialogForm.text" |
| | | oninput="if(value.length>10)value=value.slice(0,10)" |
| | | ></el-input> |
| | | </el-form-item> |
| | | <div class="text-center pb-2"> |
| | | <el-button size="mini" type="primary" @click="submitForm">保存</el-button> |
| | | <el-button size="mini" type="primary" @click="submitForm" |
| | | >保存</el-button |
| | | > |
| | | <el-button size="mini" @click="hideDialogBox">取消</el-button> |
| | | </div> |
| | | </el-form> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | // import VJstree from "./jsTree"; |
| | | import ZTree from "./zTree/ztree" |
| | | import ZTree from "./zTree/ztree"; |
| | | |
| | | export default { |
| | | name: "GiantTreeMenu", |
| | | components: { |
| | | ZTree |
| | | ZTree, |
| | | }, |
| | | props: { |
| | | app: { |
| | | type: String, |
| | | default: "Video" |
| | | default: "Video", |
| | | }, |
| | | node: { |
| | | type: Array |
| | | type: Array, |
| | | }, |
| | | treeName: { |
| | | type: String, |
| | | default: "" |
| | | default: "", |
| | | }, |
| | | gb28181: { |
| | | type: Boolean, |
| | | default: false |
| | | default: false, |
| | | }, |
| | | height: { |
| | | type: Number, |
| | | default: 0 |
| | | } |
| | | default: 0, |
| | | }, |
| | | setting: { |
| | | type: Object, |
| | | require: false, |
| | | default: function () { |
| | | return {}; |
| | | }, |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | | hoverNodeId: "", |
| | | showDialog: false, |
| | | clientX: 0, |
| | | clientY: 0, |
| | | dialogForm: { |
| | | text: "" |
| | | text: "", |
| | | }, |
| | | rules: { |
| | | text: [ |
| | | { required: true, message: "请输入节点名称", trigger: "change" }, |
| | | { min: 2, max: 10, message: "长度在2到10个字", trigger: "change" } |
| | | ] |
| | | } |
| | | { min: 2, max: 10, message: "长度在2到10个字", trigger: "change" }, |
| | | ], |
| | | }, |
| | | curNodeTid: "", |
| | | }; |
| | | }, |
| | | created() { |
| | | // console.log(this.height, '树高度') |
| | | this.TreeDataPool.zTree = true; |
| | | |
| | | this.TreeDataPool.activeVideoIndex = sessionStorage.activeIndexVideo |
| | | ? Number(sessionStorage.activeIndexVideo) |
| | | : this.TreeDataPool.activeVideoIndex; |
| | |
| | | if (newValue !== this.treeName) { |
| | | this.TreeDataPool.cleanTree(this.treeName); |
| | | } |
| | | } |
| | | }, |
| | | }, |
| | | methods: { |
| | | handleCreated: function (ztreeObj) { |
| | | let _this = this; |
| | | this.ztreeObj = ztreeObj; |
| | | ztreeObj.expandAll(true); |
| | | // onCreated 中操作ztreeObj对象展开第一个节点 |
| | | // ztreeObj.expandNode(ztreeObj.getNodes()[0], true); |
| | | |
| | | // 摄像机配置切换时, 设置选中状态 |
| | | if (this.TreeDataPool.selectedNode.id) { |
| | | // 取消所有多选的节点,仅保留当前单选的节点 |
| | | this.TreeDataPool.selectedNodes = [this.TreeDataPool.selectedNode.id]; |
| | | this.curNodeTid = this.TreeDataPool.selectedNode.tId; |
| | | //摄像机信息更新信息后,如果节点位置有变tId就不准了,this.TreeDataPool.selectedNode此时还是旧的信息 |
| | | let ztreeNodes = ztreeObj.getNodes(); |
| | | //var curNodeTid = ''; |
| | | _this.findTidByIdFromArr(ztreeNodes); |
| | | this.TreeDataPool.selectedNode.tId = _this.curNodeTid; |
| | | let node = this.ztreeObj.getNodeByTId( |
| | | this.TreeDataPool.selectedNode.tId |
| | | ); |
| | | |
| | | // 多选时, 选中单选单击的节点 |
| | | if (this.TreeDataPool.multiple) { |
| | | this.ztreeObj.checkAllNodes(false); |
| | | this.ztreeObj.checkNode(node, true, false, false); |
| | | } |
| | | |
| | | this.ztreeObj.selectNode(node, false, true); |
| | | } |
| | | }, |
| | | |
| | | findTidByIdFromArr(arr) { |
| | | let len = arr.length; |
| | | let _this = this; |
| | | for (var i = 0; i < len; i++) { |
| | | if (arr[i].id == this.TreeDataPool.selectedNode.id) { |
| | | _this.curNodeTid = arr[i].tId; |
| | | break; |
| | | } |
| | | if (arr[i].children) { |
| | | this.findTidByIdFromArr(arr[i].children); |
| | | } |
| | | } |
| | | }, |
| | | onDblClick(evt, treeId, item) { |
| | | if (item.type !== "4" || this.app !== "Camera") { |
| | | return; |
| | | } |
| | | // console.log('activeForceChoose', this.TreeDataPool.activeForceChoose) |
| | | this.TreeDataPool.activeVideoId = item.id; |
| | | let videoArr = this.TreeDataPool.videoArr; |
| | | let nullVideoIndex = ""; |
| | |
| | | this.TreeDataPool.activeVideoIndex !== "" && |
| | | this.TreeDataPool.activeVideoIndex <= videoArr.length - 1 |
| | | ) { |
| | | this.TreeDataPool.setVideoArr(this.TreeDataPool.activeVideoIndex, undefined, this); |
| | | this.TreeDataPool.setVideoArr( |
| | | this.TreeDataPool.activeVideoIndex, |
| | | undefined, |
| | | this |
| | | ); |
| | | this.$nextTick(() => { |
| | | this.TreeDataPool.setVideoArr( |
| | | this.TreeDataPool.activeVideoIndex, |
| | | item, |
| | | this |
| | | ); |
| | | }) |
| | | }); |
| | | return; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | if (nullVideoIndex === "") { |
| | | this.TreeDataPool.setVideoArr(this.TreeDataPool.activeVideoIndex, undefined, this); |
| | | this.TreeDataPool.setVideoArr( |
| | | this.TreeDataPool.activeVideoIndex, |
| | | undefined, |
| | | this |
| | | ); |
| | | this.$nextTick(() => { |
| | | this.TreeDataPool.setVideoArr( |
| | | this.TreeDataPool.activeVideoIndex, |
| | | item, |
| | | this |
| | | ); |
| | | }) |
| | | }); |
| | | } else { |
| | | // this.TreeDataPool.setVideoArr(this.TreeDataPool.activeVideoIndex, undefined, this); |
| | | this.$nextTick(() => { |
| | |
| | | item, |
| | | this |
| | | ); |
| | | }) |
| | | }); |
| | | this.TreeDataPool.activeVideoIndex = nullVideoIndex; |
| | | } |
| | | }, |
| | |
| | | importCameras(node) { |
| | | this.$emit("import", node); |
| | | }, |
| | | addNode(event, node) { |
| | | addNode(node) { |
| | | this.dialogForm = { |
| | | text: "", |
| | | method: "add", |
| | | node: node.id |
| | | node: node.id, |
| | | }; |
| | | this.showDialogBox(event); |
| | | }, |
| | |
| | | method: "edit", |
| | | node: node.id, |
| | | alias: node.alias, |
| | | gb28181: this.gb28181 |
| | | gb28181: this.gb28181, |
| | | }; |
| | | this.showDialogBox(event); |
| | | }, |
| | |
| | | }, |
| | | submitForm() { |
| | | // 提交新增或者编辑区域节点表单 |
| | | this.$refs.dialogForm.validate(valid => { |
| | | this.$refs.dialogForm.validate((valid) => { |
| | | if (valid) { |
| | | if (this.dialogForm.method == "add") { |
| | | this.TreeDataPool.add(this.dialogForm.text, this.dialogForm.node); |
| | |
| | | |
| | | this.TreeDataPool.updateZTreeCheckNodes([treeNode]); |
| | | }, |
| | | // itemClick(treeNode) { |
| | | // this.TreeDataPool.selectedNode = treeNode; |
| | | // this.TreeDataPool.treeType = this.treeName; |
| | | |
| | | // // 多选 |
| | | // if (this.TreeDataPool.multiple) { |
| | | // // 单击某一个节点文字时 取消所有勾选状态 然后选中自身 |
| | | // this.ztreeObj.checkAllNodes(false); |
| | | // this.ztreeObj.checkNode(treeNode, true, false, false); |
| | | // } |
| | | |
| | | // this.TreeDataPool.updateZTreeCheckNodes([treeNode]); |
| | | // }, |
| | | itemCheck(evt, treeId, treeNode) { |
| | | this.TreeDataPool.selectedNode = treeNode; |
| | | this.TreeDataPool.treeType = this.treeName; |
| | | |
| | | debugger; |
| | | // 多选 |
| | | // this.ztreeObj.checkNode(treeNode, true, false, false); |
| | | let checkedNodes = this.ztreeObj.getCheckedNodes(true); |
| | | this.TreeDataPool.updateZTreeCheckNodes(checkedNodes); |
| | | |
| | | // 实时统计选中个数 |
| | | this.TreeDataPool.countCheckedNodes(checkedNodes); |
| | | |
| | | // 保存一份数据 |
| | | this.TreeDataPool.activeTreeData = this.ztreeObj.getNodes(); |
| | | }, |
| | | //展开 |
| | | itemExpand(e, id, node) { |
| | | this.TreeDataPool.foldNodeList[node.id] = true |
| | | delete this.TreeDataPool.foldNodeList[node.id]; |
| | | }, |
| | | // 折叠 |
| | | itemCollapse(e, id, node) { |
| | | delete this.TreeDataPool.foldNodeList[node.id] |
| | | this.TreeDataPool.foldNodeList[node.id] = true; |
| | | }, |
| | | dropNode(node, item, draggedItem, e) { |
| | | // console.log('dropNode', node, item, draggedItem); |
| | | this.TreeDataPool.dropNode(draggedItem.id, item.id) |
| | | } |
| | | } |
| | | this.TreeDataPool.dropNode(draggedItem.id, item.id); |
| | | }, |
| | | showCameraPic(nodeId) { |
| | | this.TreeDataPool.showBaseImage(nodeId); |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | <style lang="scss" scoped> |
| | |
| | | } |
| | | .tree-menu { |
| | | // max-width: 350px; |
| | | overflow-x: hidden; |
| | | overflow-x: auto; |
| | | overflow-y: hidden; |
| | | margin-bottom: 4px; |
| | | } |
| | |
| | | background: rgba(0, 0, 0, 0.4); |
| | | } |
| | | .tree-menu:hover { |
| | | overflow-x: visible; |
| | | overflow-y: auto; |
| | | margin-bottom: 0px; |
| | | } |
| | | </style> |