设备结构树模块指派NC文件到产品中的产品结构树展开选中节点下的所有子项功能
已修改1个文件
54 ■■■■ 文件已修改
src/views/dnc/base/modules/DeviceStructure/Document/HasReceivedDocumentAssignModal.vue 54 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/base/modules/DeviceStructure/Document/HasReceivedDocumentAssignModal.vue
@@ -45,14 +45,17 @@
      <div style="width: 26%">
        <a-tabs>
          <a-tab-pane tab="设备列表">
          <a-tab-pane tab="产品列表">
            <a-spin :spinning="spinning">
              <div style="display: flex;flex-direction: column;">
                <div style="display: flex">
                  <a-input placeholder="输入关键字进行搜索" allowClear v-model="searchInput"
                           @change="handleSearchInputChange"/>
                  <a-button type="primary" @click="isExpandAllTreeNode=!isExpandAllTreeNode" style="margin: 0 8px">
                    展开/折叠
                  <a-button type="primary" @click="expandCurrentActiveTreeNodeSon" style="margin: 0 8px"
                            :disabled="!currentActiveTreeNode.children||(currentActiveTreeNode.children&&currentActiveTreeNode.children.length===0)">
                    <span v-if="!expandedKeys.includes(currentActiveTreeNode.id)">展开</span>
                    <span v-else>折叠</span>
                    当前节点
                  </a-button>
                </div>
@@ -62,6 +65,7 @@
                          :autoExpandParent="autoExpandParent" @select="handleTreeNodeSelect" checkStrictly
                          :treeData="treeDataSource" @check="handleTreeNodeCheck" @expand="handleTreeNodeExpand">
                    <template slot="title" slot-scope="{ label, parentId, entity, key:treeKey,type}">
                      <!--nc文件层级-->
                      <a-tooltip :title="label" v-if="type==99">
                          <span v-if="label.indexOf(searchValue) > -1">
                      {{ label.substr(0, label.indexOf(searchValue)) }}
@@ -70,6 +74,8 @@
                    </span>
                        <span v-else>{{ label }}</span>
                      </a-tooltip>
                      <!--非文件层级-->
                      <template v-else>
                         <span v-if="label.indexOf(searchValue) > -1">
                      {{ label.substr(0, label.indexOf(searchValue)) }}
@@ -187,6 +193,7 @@
        autoExpandParent: true,
        isExpandAllTreeNode: false,
        confirmLoading: false,
        currentActiveTreeNode: {},
        date: [],
        url: {
          list: '/nc/doc/find/list'
@@ -412,12 +419,10 @@
      /**
       * 树节点复选框选中时触发
       * @param selectedKeys 选中节点key
       * @param checkedObj 选中节点对象
       * @param {node} node 节点对象
       */
      handleTreeNodeCheck(checkedObj, { node }) {
        console.log('checkedObj', checkedObj)
        console.log('node', node.dataRef)
        let record = node.dataRef
        if (record.type !== 99) return
        this.checkedKeys = checkedObj.checked.slice(-1)
@@ -429,7 +434,40 @@
       * @param {node} node 节点对象
       */
      handleTreeNodeSelect(selectedKeys, { node }) {
        const record = node.dataRef
        node.$el.childNodes[1].click()
        if (this.currentActiveTreeNode.key === record.key) {
          this.currentActiveTreeNode = {}
          return
        }
        this.currentActiveTreeNode = Object.assign({}, record)
      },
      // 展开当前选中树节点下所有子项
      expandCurrentActiveTreeNodeSon() {
        const activeNode = this.currentActiveTreeNode
        const sonKeys = this.getCurrentTreeNodeSonKeys(activeNode)
        if (!this.expandedKeys.includes(activeNode.id)) {
          this.expandedKeys = [...this.expandedKeys, this.currentActiveTreeNode.id, ...sonKeys]
        } else {
          this.expandedKeys = this.expandedKeys.filter(expandKey => !sonKeys.includes(expandKey) && expandKey !== activeNode.id)
        }
      },
      /**
       * 递归获取选中节点所有子节点key
       * @param treeNode 树节点
       */
      getCurrentTreeNodeSonKeys(treeNode) {
        let sonKeys = []
        if (treeNode.children && treeNode.children.length > 0) {
          for (let index = 0; index < treeNode.children.length; index++) {
            const node = treeNode.children[index]
            sonKeys.push(node.id)
            sonKeys = [...sonKeys, ...this.getCurrentTreeNodeSonKeys(node)]
          }
        }
        return sonKeys
      },
      /**
@@ -455,7 +493,7 @@
      /**
       * 递归获得所有树节点key
       * @param data 设备树数据
       * @param data 树数据
       */
      generateList(data) {
        for (let i = 0; i < data.length; i++) {
@@ -502,7 +540,7 @@
        this.searchInput = this.searchValue = ''
        this.expandedKeys = []
        this.selectedRowKeys = []
        this.selectionRows = {}
        this.selectionRows = this.currentActiveTreeNode = {}
        this.checkedKeys = []
        this.filters = {}
        this.isorter = Object.assign({}, this.defaultSorter)