src/views/dnc/common/ProductStructureTree.vue
@@ -16,7 +16,8 @@
              <a-icon type="bars"/>
            </a-button>
          </a-dropdown>
          <a-button type="primary" @click="$refs.productModalFormRef.handleProductAdd('添加产品')">
          <a-button type="primary"
                    @click="$refs.productModalFormRef.triggerCorrespondingMethod({modalTitle:'添加产品',methodName:'handleProductAdd'})">
            <a-icon type="plus"></a-icon>
            产品
          </a-button>
@@ -44,18 +45,20 @@
    </a-spin>
    <!--产品弹窗-->
    <ProductModal ref="productModalFormRef" :currentTreeNodeInfo="rightClickSelected"/>
    <ProductModal ref="productModalFormRef" :currentTreeNodeInfo="rightClickSelected"
                  @submitSuccess="queryTreeData"/>
    <!--部件弹窗-->
    <ComponentModal :currentTreeNodeInfo="rightClickSelected"/>
    <ComponentModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
    <!--零件弹窗-->
    <PartModal :currentTreeNodeInfo="rightClickSelected"/>
    <PartModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
    <!--工序弹窗-->
    <ProcessModal :currentTreeNodeInfo="rightClickSelected"/>
    <ProcessModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
  </a-card>
</template>
<script>
  import dncApi from '@/api/dnc'
  import { deleteAction } from '@/api/manage'
  import ProductStructureTreeContextMenu from './modules/ProductStructureTree/ProductStructureTreeContextMenu'
  import ProductModal from '../base/modules/ProductStructure/Product/ProductModal'
  import ComponentModal from '../base/modules/ProductStructure/Component/ComponentModal'
@@ -87,7 +90,7 @@
        currentSelected: {},
        rightClickSelected: {},
        url: {
          delete: ''
          delete: '/nc/product/delete'
        }
      }
    },
@@ -107,8 +110,7 @@
            this.treeDataSource = res.list
            this.generateList(this.treeDataSource)
            // this.expandedKeys = this.allTreeKeys
            this.expandedKeys = [this.treeDataSource[0].id]
            console.log('treeDataSource', this.treeDataSource)
            if (this.expandedKeys.length === 0) this.expandedKeys = [this.treeDataSource[0].id]
          } else {
            this.$message.warn(res.message)
          }
@@ -158,26 +160,35 @@
              return
            }
            const that = this
            // deleteAction(that.url.delete, { id: this.rightClickSelected.id })
            //   .then((res) => {
            //     if (res.success) {
            //       that.queryTreeData()
            //       that.$notification.success({
            //         message: '消息',
            //         description: res.message
            //       })
            //     } else {
            //       that.$notification.warning({
            //         message: '消息',
            //         description: res.message
            //       })
            //     }
            //   })
            deleteAction(that.url.delete, { id: this.rightClickSelected.id })
              .then((res) => {
                if (res.success) {
                  that.queryTreeData()
                  that.$notification.success({
                    message: '消息',
                    description: res.message
                  })
                } else {
                  that.$notification.warning({
                    message: '消息',
                    description: res.message
                  })
                }
              })
          }
        })
      },
      /**
       * 自动展开添加下级节点的父节点
       */
      modalFormSubmitSuccess(isAddNextLevel) {
        // 判断是否为添加下级并且判断父节点是否展开
        if (isAddNextLevel && !this.expandedKeys.includes(this.rightClickSelected.id)) this.expandedKeys.push(this.rightClickSelected.id)
        this.queryTreeData()
      },
      /**
       * 树节点展开合并时触发
       * @param expandedKeys 展开项key
       */