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>
@@ -36,33 +37,40 @@
            <a-icon slot="product" type="shopping"/>
            <a-icon slot="component" type="camera"/>
            <a-icon slot="part" type="hdd"/>
            <a-icon slot="process" type="apartment"/>
            <a-icon slot="processStep" type="tool"/>
          </a-tree>
        </div>
      </div>
    </a-spin>
    <!--产品弹窗-->
    <ProductModal ref="productModalFormRef" :currentTreeNodeInfo="rightClickSelected"/>
    <ProductModal ref="productModalFormRef" :currentTreeNodeInfo="rightClickSelected"
                  @submitSuccess="queryTreeData"/>
    <!--部件弹窗-->
    <ComponentModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
    <!--零件弹窗-->
    <ComponentModal :currentTreeNodeInfo="rightClickSelected"/>
    <!--导入文件公共弹窗-->
    <ImportFileModal/>
    <PartModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
    <!--工序弹窗-->
    <ProcessModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
  </a-card>
</template>
<script>
  import dncApi from '@/api/dnc'
  import { deleteAction } from '@/api/manage'
  import { mapActions } from 'vuex'
  import ProductStructureTreeContextMenu from './modules/ProductStructureTree/ProductStructureTreeContextMenu'
  import ProductModal from '../base/modules/ProductStructure/Product/ProductModal'
  import ImportFileModal from './ImportFileModal'
  import ComponentModal from '../base/modules/ProductStructure/Component/ComponentModal'
  import PartModal from '../base/modules/ProductStructure/Part/PartModal'
  import ProcessModal from '../base/modules/ProductStructure/Process/ProcessModal'
  export default {
    name: 'ProductStructureTree',
    components: {
      ProcessModal,
      PartModal,
      ComponentModal,
      ImportFileModal,
      ProductModal,
      ProductStructureTreeContextMenu
    },
@@ -82,7 +90,7 @@
        currentSelected: {},
        rightClickSelected: {},
        url: {
          delete: ''
          delete: '/nc/product/delete'
        }
      }
    },
@@ -91,343 +99,18 @@
      this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
    },
    methods: {
      ...mapActions(['QueryProduction']),
      queryTreeData() {
        this.loading = true
        this.cardLoading = true
        this.QueryProduction().then(res => {
        dncApi.getProductStructureTreeApi().then(res => {
          console.log('res', res)
          if (res.success) {
            this.dataList = []
            this.allTreeKeys = []
            // this.treeDataSource = res.result
            this.treeDataSource = [
              {
                'id': '1869253349344432129',
                'label': '[让外人]测试',
                'iconClass': '',
                'parentId': '1869253349344432129',
                'children': [
                  {
                    'id': '1869254044432879617',
                    'label': '[378]qgwqg',
                    'iconClass': '',
                    'parentId': '1869253349344432129',
                    'children': [
                      {
                        'id': '1869260302133137410',
                        'label': '[ggjuk]谔谔去',
                        'iconClass': '',
                        'parentId': '1869254044432879617',
                        'children': [
                          {
                            'id': '1869294654070075393',
                            'label': '[8989]qwfq',
                            'iconClass': '',
                            'parentId': '1869260302133137410',
                            'children': null,
                            'type': 2,
                            'entity': {
                              'componentId': '1869294654070075393',
                              'parentId': '1869260302133137410',
                              'productId': '1869253349344432129',
                              'componentName': 'qwfq',
                              'materielCode': '',
                              'materielDesp': '',
                              'componentModel': '',
                              'componentScale': '',
                              'componentWeight': null,
                              'rankLevel': 3,
                              'assembleType': null,
                              'produceType': null,
                              'processType': null,
                              'structureType': null,
                              'componentCode': '8989',
                              'componentStatus': 1,
                              'description': '',
                              'createTime': '2024-12-18 16:12:30',
                              'updateTime': null,
                              'createUser': '1254966905669160962',
                              'updateUser': ''
                            },
                            'leaf': false,
                            'rfield': '1869253349344432129'
                          },
                          {
                            'id': '1869294701801254913',
                            'label': '[888]7878',
                            'iconClass': '',
                            'parentId': '1869260302133137410',
                            'children': null,
                            'type': 2,
                            'entity': {
                              'componentId': '1869294701801254913',
                              'parentId': '1869260302133137410',
                              'productId': '1869253349344432129',
                              'componentName': '7878',
                              'materielCode': '',
                              'materielDesp': '',
                              'componentModel': '',
                              'componentScale': '',
                              'componentWeight': null,
                              'rankLevel': 3,
                              'assembleType': null,
                              'produceType': null,
                              'processType': null,
                              'structureType': null,
                              'componentCode': '888',
                              'componentStatus': 1,
                              'description': '',
                              'createTime': '2024-12-18 16:12:41',
                              'updateTime': null,
                              'createUser': '1254966905669160962',
                              'updateUser': ''
                            },
                            'leaf': false,
                            'rfield': '1869253349344432129'
                          },
                          {
                            'id': '1869294780935188482',
                            'label': '[6855]ww',
                            'iconClass': '',
                            'parentId': '1869260302133137410',
                            'children': null,
                            'type': 2,
                            'entity': {
                              'componentId': '1869294780935188482',
                              'parentId': '1869260302133137410',
                              'productId': '1869253349344432129',
                              'componentName': 'ww',
                              'materielCode': '',
                              'materielDesp': '',
                              'componentModel': '',
                              'componentScale': '',
                              'componentWeight': null,
                              'rankLevel': 3,
                              'assembleType': null,
                              'produceType': null,
                              'processType': null,
                              'structureType': null,
                              'componentCode': '6855',
                              'componentStatus': 1,
                              'description': '',
                              'createTime': '2024-12-18 16:13:00',
                              'updateTime': null,
                              'createUser': '1254966905669160962',
                              'updateUser': ''
                            },
                            'leaf': false,
                            'rfield': '1869253349344432129'
                          },
                          {
                            'id': '1876199480437153794',
                            'label': '[354]zzzzzzzzzzzzzzzzz',
                            'iconClass': '',
                            'parentId': '1869260302133137410',
                            'children': null,
                            'type': 3,
                            'entity': {
                              'partsId': '1876199480437153794',
                              'partsName': 'zzzzzzzzzzzzzzzzz',
                              'productId': '1869253349344432129',
                              'componentId': '1869260302133137410',
                              'materielCode': '',
                              'materielDesp': '',
                              'partsModel': '',
                              'partsScale': '',
                              'partsWeight': null,
                              'assembleType': null,
                              'produceType': null,
                              'processType': null,
                              'structureType': null,
                              'partsCode': '354',
                              'partsStatus': 1,
                              'description': '',
                              'createTime': '2025-01-06 17:29:49',
                              'updateTime': null,
                              'createUser': '1254966905669160962',
                              'updateUser': ''
                            },
                            'leaf': false,
                            'rfield': '1869260302133137410'
                          }
                        ],
                        'type': 2,
                        'entity': {
                          'componentId': '1869260302133137410',
                          'parentId': '1869254044432879617',
                          'productId': '1869253349344432129',
                          'componentName': '谔谔去',
                          'materielCode': '',
                          'materielDesp': '',
                          'componentModel': '',
                          'componentScale': '',
                          'componentWeight': null,
                          'rankLevel': 2,
                          'assembleType': null,
                          'produceType': null,
                          'processType': null,
                          'structureType': null,
                          'componentCode': 'ggjuk',
                          'componentStatus': 1,
                          'description': '',
                          'createTime': '2024-12-18 13:56:00',
                          'updateTime': null,
                          'createUser': '1254966905669160962',
                          'updateUser': ''
                        },
                        'leaf': false,
                        'rfield': '1869253349344432129'
                      }
                    ],
                    'type': 2,
                    'entity': {
                      'componentId': '1869254044432879617',
                      'parentId': null,
                      'productId': '1869253349344432129',
                      'componentName': 'qgwqg',
                      'materielCode': '',
                      'materielDesp': '',
                      'componentModel': '',
                      'componentScale': '',
                      'componentWeight': null,
                      'rankLevel': 1,
                      'assembleType': null,
                      'produceType': null,
                      'processType': null,
                      'structureType': null,
                      'componentCode': '378',
                      'componentStatus': 1,
                      'description': '88',
                      'createTime': '2022-12-18 13:32:48',
                      'updateTime': '2024-12-18 13:32:48',
                      'createUser': '1254966905669160962',
                      'updateUser': '1254966905669160962'
                    },
                    'leaf': false,
                    'rfield': '1869253349344432129'
                  },
                  {
                    'id': '1869253419041181697',
                    'label': '[876]为全国前五给',
                    'iconClass': '',
                    'parentId': '1869253349344432129',
                    'children': null,
                    'type': 2,
                    'entity': {
                      'componentId': '1869253419041181697',
                      'parentId': null,
                      'productId': '1869253349344432129',
                      'componentName': '为全国前五给',
                      'materielCode': '',
                      'materielDesp': '',
                      'componentModel': '56',
                      'componentScale': '',
                      'componentWeight': null,
                      'rankLevel': 1,
                      'assembleType': null,
                      'produceType': null,
                      'processType': null,
                      'structureType': null,
                      'componentCode': '876',
                      'componentStatus': 1,
                      'description': '',
                      'createTime': '2024-12-18 13:28:39',
                      'updateTime': '2024-12-18 14:03:55',
                      'createUser': '1254966905669160962',
                      'updateUser': '1254966905669160962'
                    },
                    'leaf': false,
                    'rfield': '1869253349344432129'
                  },
                  {
                    'id': '1869294861876867073',
                    'label': '[777]he',
                    'iconClass': '',
                    'parentId': '1869253349344432129',
                    'children': [
                      {
                        'id': '1876087437913108481',
                        'label': '[ddd]和维护',
                        'iconClass': '',
                        'parentId': '1869294861876867073',
                        'children': null,
                        'type': 2,
                        'entity': {
                          'componentId': '1876087437913108481',
                          'parentId': '1869294861876867073',
                          'productId': '1869253349344432129',
                          'componentName': '和维护',
                          'materielCode': '',
                          'materielDesp': '',
                          'componentModel': '',
                          'componentScale': '',
                          'componentWeight': null,
                          'rankLevel': 2,
                          'assembleType': null,
                          'produceType': null,
                          'processType': null,
                          'structureType': null,
                          'componentCode': 'ddd',
                          'componentStatus': 1,
                          'description': '',
                          'createTime': '2025-01-06 10:04:36',
                          'updateTime': null,
                          'createUser': '1254966905669160962',
                          'updateUser': ''
                        },
                        'leaf': false,
                        'rfield': '1869253349344432129'
                      }
                    ],
                    'type': 2,
                    'entity': {
                      'componentId': '1869294861876867073',
                      'parentId': null,
                      'productId': '1869253349344432129',
                      'componentName': 'he',
                      'materielCode': '',
                      'materielDesp': '',
                      'componentModel': '',
                      'componentScale': '',
                      'componentWeight': null,
                      'rankLevel': 1,
                      'assembleType': null,
                      'produceType': null,
                      'processType': null,
                      'structureType': null,
                      'componentCode': '777',
                      'componentStatus': 1,
                      'description': '',
                      'createTime': '2024-12-18 16:13:20',
                      'updateTime': null,
                      'createUser': '1254966905669160962',
                      'updateUser': ''
                    },
                    'leaf': false,
                    'rfield': '1869253349344432129'
                  }
                ],
                'type': 1,
                'entity': {
                  'productId': '1869253349344432129',
                  'productNo': '让外人',
                  'productModel': '',
                  'productName': '测试',
                  'productStatus': 1,
                  'createTime': '2024-12-18 13:28:22',
                  'updateTime': null,
                  'createUser': '1254966905669160962',
                  'updateUser': null
                },
                'leaf': false,
                'rfield': null
              }
            ]
            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)
          }
@@ -494,6 +177,15 @@
              })
          }
        })
      },
      /**
       * 自动展开添加下级节点的父节点
       */
      modalFormSubmitSuccess(isAddNextLevel) {
        // 判断是否为添加下级并且判断父节点是否展开
        if (isAddNextLevel && !this.expandedKeys.includes(this.rightClickSelected.id)) this.expandedKeys.push(this.rightClickSelected.id)
        this.queryTreeData()
      },
      /**
@@ -582,6 +274,12 @@
          case 3:
            treeNode.slots = { icon: 'part' }
            break
          case 4:
            treeNode.slots = { icon: 'process' }
            break
          case 5:
            treeNode.slots = { icon: 'processStep' }
            break
          default:
        }
      }