| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 | 
							- <template>
 
-   <div id="DeviceTree">
 
-     <div v-if="showHeader" class="page-header" style="margin-bottom: 1rem;">
 
-       <div class="page-title">业务分组</div>
 
-       <div class="page-header-btn">
 
-         <div style="display: inline;">
 
-           <el-input @input="search" style="visibility:hidden; margin-right: 1rem; width: 12rem;" size="mini" placeholder="关键字"
 
-                     prefix-icon="el-icon-search" v-model="searchSrt" clearable></el-input>
 
-           <el-checkbox v-model="showCode">显示编号</el-checkbox>
 
-         </div>
 
-       </div>
 
-     </div>
 
-     <div v-if="showHeader" style="height: 2rem; background-color: #FFFFFF" ></div>
 
-     <div>
 
-       <vue-easy-tree
 
-         class="flow-tree"
 
-         ref="veTree"
 
-         node-key="deviceId"
 
-         height="78vh"
 
-         lazy
 
-         style="padding: 0 0 2rem 0.5rem"
 
-         :load="loadNode"
 
-         :data="treeData"
 
-         :props="props"
 
-         :default-expanded-keys="['']"
 
-         @node-contextmenu="contextmenuEventHandler"
 
-         @node-click="nodeClickHandler"
 
-       >
 
-         <span class="custom-tree-node" slot-scope="{ node, data }">
 
-           <span @click.stop v-if="edit">
 
-             <el-radio v-if="node.data.type === 0 && node.level > 2" style="margin-right: 0" v-model="chooseId" @input="chooseIdChange(node.data.deviceId, node.data.businessGroup)" :label="node.data.deviceId">{{''}}</el-radio>
 
-           </span>
 
-           <span v-if="node.data.type === 0" style="color: #409EFF" class="iconfont icon-bianzubeifen3"></span>
 
-           <span v-if="node.data.type === 1" style="color: #409EFF" class="iconfont icon-shexiangtou2"></span>
 
-           <span style=" padding-left: 1px" v-if="node.data.deviceId !=='' && showCode" :title="node.data.deviceId">{{ node.label }}(编号:{{ node.data.deviceId }})</span>
 
-           <span style=" padding-left: 1px" v-if="node.data.deviceId ==='' || !showCode" :title="node.data.deviceId">{{ node.label }}</span>
 
-         </span>
 
-       </vue-easy-tree>
 
-     </div>
 
-     <groupEdit ref="groupEdit"></groupEdit>
 
-     <gbDeviceSelect ref="gbDeviceSelect"></gbDeviceSelect>
 
-   </div>
 
- </template>
 
- <script>
 
- import VueEasyTree from "@wchbrad/vue-easy-tree";
 
- import groupEdit from './../dialog/groupEdit'
 
- import gbDeviceSelect from './../dialog/GbDeviceSelect'
 
- export default {
 
-   name: 'DeviceTree',
 
-   components: {
 
-     VueEasyTree, groupEdit, gbDeviceSelect
 
-   },
 
-   data() {
 
-     return {
 
-       props: {
 
-         label: "name",
 
-       },
 
-       showCode: false,
 
-       searchSrt: "",
 
-       chooseId: "",
 
-       treeData: [],
 
-     }
 
-   },
 
-   props: ['edit', 'clickEvent', 'chooseIdChange', 'onChannelChange', 'showHeader'],
 
-   created() {
 
-   },
 
-   methods: {
 
-     search() {
 
-     },
 
-     loadNode: function (node, resolve) {
 
-       if (node.level === 0) {
 
-         resolve([{
 
-           deviceId: "",
 
-           name: "根资源组",
 
-           isLeaf: false,
 
-           type: 0
 
-         }]);
 
-       } else {
 
-         this.$axios({
 
-           method: 'get',
 
-           url: `/api/group/tree/list`,
 
-           params: {
 
-             query: this.searchSrt,
 
-             parent: node.data.id
 
-           }
 
-         }).then((res) => {
 
-           if (res.data.code === 0) {
 
-             resolve(res.data.data);
 
-           }
 
-         }).catch(function (error) {
 
-           console.log(error);
 
-         });
 
-       }
 
-     },
 
-     reset: function () {
 
-       this.$forceUpdate();
 
-     },
 
-     contextmenuEventHandler: function (event, data, node, element) {
 
-       if (!this.edit) {
 
-         return;
 
-       }
 
-       console.log(node.level)
 
-       if (node.data.type === 1) {
 
-         data.parentId = node.parent.data.id;
 
-         this.$contextmenu({
 
-           items: [
 
-             {
 
-               label: "移除通道",
 
-               icon: "el-icon-delete",
 
-               disabled: false,
 
-               onClick: () => {
 
-                 console.log(data)
 
-                 this.$axios({
 
-                   method: "post",
 
-                   url: `/api/common/channel/group/delete`,
 
-                   data: {
 
-                     channelIds: [data.id]
 
-                   }
 
-                 }).then((res) => {
 
-                   console.log("移除成功")
 
-                   if (this.onChannelChange) {
 
-                     this.onChannelChange()
 
-                   }
 
-                   node.parent.loaded = false
 
-                   node.parent.expand();
 
-                 }).catch(function (error) {
 
-                   console.log(error);
 
-                 });
 
-               }
 
-             }
 
-           ],
 
-           event, // 鼠标事件信息
 
-           customClass: "custom-class", // 自定义菜单 class
 
-           zIndex: 3000, // 菜单样式 z-index
 
-         });
 
-       } else if (node.data.type === 0) {
 
-         this.$contextmenu({
 
-           items: [
 
-             {
 
-               label: "刷新节点",
 
-               icon: "el-icon-refresh",
 
-               disabled: false,
 
-               onClick: () => {
 
-                 this.refreshNode(node);
 
-               }
 
-             },
 
-             {
 
-               label: "新建节点",
 
-               icon: "el-icon-plus",
 
-               disabled: false,
 
-               onClick: () => {
 
-                 this.addGroup(data.id, node);
 
-               }
 
-             },
 
-             {
 
-               label: "编辑节点",
 
-               icon: "el-icon-edit",
 
-               disabled: node.level === 1,
 
-               onClick: () => {
 
-                 this.editGroup(data, node);
 
-               }
 
-             },
 
-             {
 
-               label: "删除节点",
 
-               icon: "el-icon-delete",
 
-               disabled: node.level === 1,
 
-               divided: true,
 
-               onClick: () => {
 
-                 this.$confirm('确定删除?', '提示', {
 
-                   confirmButtonText: '确定',
 
-                   cancelButtonText: '取消',
 
-                   type: 'warning'
 
-                 }).then(() => {
 
-                   this.removeGroup(data.id, node)
 
-                 }).catch(() => {
 
-                 });
 
-               }
 
-             },
 
-             {
 
-               label: "添加设备",
 
-               icon: "el-icon-plus",
 
-               disabled: node.level <= 2,
 
-               onClick: () => {
 
-                 this.addChannelFormDevice(data.id, node)
 
-               }
 
-             },
 
-             {
 
-               label: "移除设备",
 
-               icon: "el-icon-delete",
 
-               disabled: node.level <= 2,
 
-               onClick: () => {
 
-                 this.removeChannelFormDevice(data.id, node)
 
-               }
 
-             },
 
-             // {
 
-             //   label: "导出",
 
-             //   icon: "el-icon-download",
 
-             //   disabled: false,
 
-             //   children: [
 
-             //     {
 
-             //       label: "导出到文件",
 
-             //       onClick: () => {
 
-             //
 
-             //       },
 
-             //     },
 
-             //     {
 
-             //       label: "导出到其他平台",
 
-             //       onClick: () => {
 
-             //
 
-             //       },
 
-             //     }
 
-             //   ]
 
-             // },
 
-           ],
 
-           event, // 鼠标事件信息
 
-           customClass: "custom-class", // 自定义菜单 class
 
-           zIndex: 3000, // 菜单样式 z-index
 
-         });
 
-       }
 
-       return false;
 
-     },
 
-     removeGroup: function (id, node) {
 
-       this.$axios({
 
-         method: "delete",
 
-         url: `/api/group/delete`,
 
-         params: {
 
-           id: node.data.id,
 
-         }
 
-       }).then((res) => {
 
-         if (res.data.code === 0) {
 
-           console.log("移除成功")
 
-           node.parent.loaded = false
 
-           node.parent.expand();
 
-           if (this.onChannelChange) {
 
-             this.onChannelChange()
 
-           }
 
-         }
 
-       }).catch(function (error) {
 
-           console.log(error);
 
-       });
 
-     },
 
-     addChannelFormDevice: function (id, node) {
 
-       this.$refs.gbDeviceSelect.openDialog((rows)=>{
 
-         let deviceIds = []
 
-         for (let i = 0; i < rows.length; i++) {
 
-           deviceIds.push(rows[i].id)
 
-         }
 
-         this.$axios({
 
-           method: 'post',
 
-           url: `/api/common/channel/group/device/add`,
 
-           data: {
 
-             parentId: node.data.deviceId,
 
-             businessGroup: node.data.businessGroup,
 
-             deviceIds: deviceIds,
 
-           }
 
-         }).then((res)=> {
 
-           if (res.data.code === 0) {
 
-             this.$message.success({
 
-             showClose: true,
 
-             message: "保存成功"
 
-           })
 
-             if (this.onChannelChange) {
 
-               this.onChannelChange()
 
-             }
 
-             node.loaded = false
 
-             node.expand();
 
-           }else {
 
-             this.$message.error({
 
-               showClose: true,
 
-               message: res.data.msg
 
-             })
 
-           }
 
-           this.loading = false
 
-         }).catch((error)=> {
 
-           this.$message.error({
 
-             showClose: true,
 
-             message: error
 
-           })
 
-           this.loading = false
 
-         });
 
-       })
 
-     },
 
-     removeChannelFormDevice: function (id, node) {
 
-       this.$refs.gbDeviceSelect.openDialog((rows)=>{
 
-         let deviceIds = []
 
-         for (let i = 0; i < rows.length; i++) {
 
-           deviceIds.push(rows[i].id)
 
-         }
 
-         this.$axios({
 
-           method: 'post',
 
-           url: `/api/common/channel/group/device/delete`,
 
-           data: {
 
-             deviceIds: deviceIds,
 
-           }
 
-         }).then((res)=> {
 
-           if (res.data.code === 0) {
 
-             this.$message.success({
 
-             showClose: true,
 
-             message: "保存成功"
 
-           })
 
-             if (this.onChannelChange) {
 
-               this.onChannelChange()
 
-             }
 
-             node.loaded = false
 
-             node.expand();
 
-           }else {
 
-             this.$message.error({
 
-               showClose: true,
 
-               message: res.data.msg
 
-             })
 
-           }
 
-           this.loading = false
 
-         }).catch((error)=> {
 
-           this.$message.error({
 
-             showClose: true,
 
-             message: error
 
-           })
 
-           this.loading = false
 
-         });
 
-       })
 
-     },
 
-     refreshNode: function (node) {
 
-       node.loaded = false
 
-       node.expand();
 
-     },
 
-     refresh: function (id) {
 
-       // 查询node
 
-       let node = this.$refs.veTree.getNode(id)
 
-       node.loaded = false
 
-       node.expand();
 
-     },
 
-     addGroup: function (id, node) {
 
-       this.$refs.groupEdit.openDialog({
 
-         id: 0,
 
-         name: "",
 
-         deviceId: "",
 
-         civilCode: "",
 
-         parentDeviceId: node.level > 2 ? node.data.deviceId:"",
 
-         parentId: node.data.id,
 
-         businessGroup: node.level > 2 ? node.data.businessGroup: node.data.deviceId,
 
-       },form => {
 
-         node.loaded = false
 
-         node.expand();
 
-       }, id);
 
-     },
 
-     editGroup: function (id, node) {
 
-       console.log(node)
 
-       this.$refs.groupEdit.openDialog(node.data,form => {
 
-         node.parent.loaded = false
 
-         node.parent.expand();
 
-       }, id);
 
-     },
 
-     nodeClickHandler: function (data, node, tree) {
 
-       if (this.clickEvent) {
 
-         this.clickEvent(data)
 
-       }
 
-     }
 
-   },
 
-   destroyed() {
 
-     // if (this.jessibuca) {
 
-     //   this.jessibuca.destroy();
 
-     // }
 
-     // this.playing = false;
 
-     // this.loaded = false;
 
-     // this.performance = "";
 
-   },
 
- }
 
- </script>
 
- <style>
 
- .device-tree-main-box {
 
-   text-align: left;
 
- }
 
- .device-online {
 
-   color: #252525;
 
- }
 
- .device-offline {
 
-   color: #727272;
 
- }
 
- .custom-tree-node .el-radio__label {
 
-   padding-left: 4px !important;
 
- }
 
- </style>
 
 
  |