소스 검색

展开收起修改

zhangxc 5 년 전
부모
커밋
698b0f01e6
1개의 변경된 파일18개의 추가작업 그리고 4개의 파일을 삭제
  1. 18 4
      src/components/medicalTerm/AddAssistCheckMultRelation.vue

+ 18 - 4
src/components/medicalTerm/AddAssistCheckMultRelation.vue

@@ -30,11 +30,13 @@
             :data="list"
             :props="defaultProps"
             node-key="conceptId"
-            default-expand-all
             draggable
             :allow-drag="allowDrag"
             :allow-drop="allowDrop"
-            :expand-on-click-node="false">
+            :expand-on-click-node="true"
+            :default-expanded-keys="defaultExpandedArr"
+            @node-click = "handleNodeClick"
+          >
             <span class="custom-tree-node" slot-scope="{ node, data }">
                 <span class="custom-tree-node-name ellipsis" :class="{colorGray: data.isDeletedConcept == 'Y'}" :title="node.label">{{ node.label }}</span>
                 <span class="btn-box">
@@ -143,6 +145,7 @@ import apis from '@api/medicalTerm.js';
           this.minTitle = '辅检层级关联维护-修改'
           const item = JSON.parse(JSON.stringify(data))
           item.level = 0
+          item.isExpanded = false
           item.nodeList = this.IteraNodeList(item.nodeList, [], 1)
           this.list[0] = item
       }
@@ -168,6 +171,17 @@ import apis from '@api/medicalTerm.js';
       allowDrag(draggingNode) {
         return draggingNode.data.level != 0;//一级不可拖动
       },
+      handleNodeClick(data) {
+          if(data.nodeList.length > 0) {
+            if(!data.isExpanded) {
+              this.defaultExpandedArr.push(data.conceptId)
+            } else {
+              this.defaultExpandedArr = this.defaultExpandedArr.filter(item => item !== data.conceptId)
+            }
+            this.$set(data, 'isExpanded', !data.isExpanded);
+          }
+      
+      },
       addConcept(e) {
         this.addLevel = 0;
         this.openSearch(e);
@@ -205,10 +219,10 @@ import apis from '@api/medicalTerm.js';
         for(let i = 0; i <nodeList.length; i++) {
           let newChild;
           if(type == '0') { //添加的时候保存所有的id列表
-            newChild = {conceptId: nodeList[i].conceptId, relationId: 17,nodeList:[],sonRelationId: 17}
+            newChild = {conceptId: nodeList[i].conceptId, relationId: 17,nodeList:[],sonRelationId: 17,isExpanded:false}
           } else if(type == '1') {  //修改的时候添加层级
             const item = JSON.parse(JSON.stringify(nodeList[i]))
-            newChild = Object.assign(item, {level:  level, nodeList: [],sonRelationId: 17})
+            newChild = Object.assign(item, {level:  level, nodeList: [],sonRelationId: 17,isExpanded:false})
           } else if(type == '2') { //移除节点的时候同时移除节点(搜索时排除的id列表)
             newChild = nodeList[i].conceptId
           }