实现产品结构树页面检索NC文件窗口中点击NC文件后界面跳转至树节点层级下NC文件界面功能
已修改6个文件
3230 ■■■■ 文件已修改
src/views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModalForm.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeTableList.vue 316 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchNcModal.vue 805 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/base/modules/ProductStructure/Document/NcDocumentTableList.vue 426 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue 857 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue 824 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModalForm.vue
@@ -49,7 +49,7 @@
      deviceCustomTypeList: [],
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 }
        sm: { span: 7 }
      },
      wrapperCol: {
        xs: { span: 24 },
src/views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeTableList.vue
@@ -8,162 +8,194 @@
</template>
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import DeviceCustomTypeModal from '@views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModal.vue'
import { deleteAction } from '@api/manage'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import DeviceCustomTypeModal
    from '@views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModal.vue'
  import { getAction, deleteAction } from '@api/manage'
export default {
  name: 'DeviceCustomTypeTableList',
  components: { DeviceCustomTypeModal },
  mixins: [JeecgListMixin],
  props: {
    currentTreeNodeInfo: {
      type: Object
    },
    size: {
      type: String
    }
  },
  data() {
    return {
      disableMixinCreated: true,
      columns: [
        // {
        //   title: '车间',
        //   dataIndex: 'productionId_dictText',
        //   align: 'center'
        // },
        {
          title: '轴数',
          dataIndex: 'deviceManagementCode_dictText',
          align: 'center'
        },
        {
          title: '数控系统类别',
          dataIndex: 'deviceManagementId_dictText',
          align: 'center'
        }
      ],
      dataSource: [],
      currentRightClickedTypeInfo: {},
      currentClickedTypeInfo: {},
      url: {
        list: '/nc/deviceType/getByBusinessId',
        delete: '/nc/deviceType/delete'
      }
    }
  },
  watch: {
    currentTreeNodeInfo: {
      handler(value) {
        this.currentClickedTypeInfo = {}
  export default {
    name: 'DeviceCustomTypeTableList',
    components: { DeviceCustomTypeModal },
    mixins: [JeecgListMixin],
    props: {
      currentTreeNodeInfo: {
        type: Object
      },
      immediate: true
    }
  },
  created() {
    this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
    this.$bus.$on('deviceCustomTypeAddSubmitSuccess', this.loadData)
  },
  methods: {
    setQueryParamAndLoadData() {
      console.log('currentLevelInfo', this.currentTreeNodeInfo)
      const { id, type } = this.currentTreeNodeInfo
      this.queryParam = Object.assign({}, { attributionId: id, attributionType: type })
      this.dataSource = []
      this.loadData()
      size: {
        type: String
      }
    },
    customRow(record) {
    data() {
      return {
        style: {
          backgroundColor: this.currentClickedTypeInfo.id === record.id ? '#BAE7FF' : 'transparent'
        },
        on: {
          contextmenu: event => {
            event.preventDefault()
            this.currentRightClickedTypeInfo = Object.assign({ param: 'deviceCustomType' }, record)
            this.$emit('handleTableContextMenuOpen', this.currentRightClickedTypeInfo)
        disableMixinCreated: true,
        columns: [
          // {
          //   title: '车间',
          //   dataIndex: 'productionId_dictText',
          //   align: 'center'
          // },
          {
            title: '轴数',
            dataIndex: 'deviceManagementCode_dictText',
            align: 'center'
          },
          click: () => {
            if (this.currentClickedTypeInfo.id === record.id) return
            this.currentClickedTypeInfo = Object.assign({}, record)
            this.$bus.$emit('sendCurrentClickedTypeInfo', record)
          {
            title: '数控系统类别',
            dataIndex: 'deviceManagementId_dictText',
            align: 'center'
          }
        ],
        dataSource: [],
        currentRightClickedTypeInfo: {},
        currentClickedTypeInfo: {},
        url: {
          list: '/nc/deviceType/getByBusinessId',
          delete: '/nc/deviceType/delete'
        }
      }
    },
    /**
     * 表格分页、排序改变、筛选时触发
     * @param pagination 分页器选项
     * @param filters 筛选选项
     * @param sorter 排序选项
     */
    handleTableChange(pagination, filters, sorter) {
      if (sorter.order) {
        this.isorter.column = sorter.field
        this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc'
      } else {
        this.isorter.column = 'createTime'
        this.isorter.order = 'desc'
      }
      for (let key in filters) {
        this.filters[key] = filters[key].join(',')
      }
      this.ipagination = pagination
      this.loadData()
    },
    /**
     * 删除工序或工步层级添加的设备类
     * @param tableRowInfo
     */
    handleTypeDelete(tableRowInfo) {
      const { id } = tableRowInfo
      const { $confirm, url, loadData, $notification, $destroyAll } = this
      $confirm({
        title: '提示',
        content: '确认删除此条记录吗?',
        okText: '确认',
        okType: 'danger',
        cancelText: '取消',
        onOk: () => {
          if (!url.delete) {
            this.$message.error('请设置url.delete属性!')
            return
          }
          deleteAction(url.delete, { id: id })
            .then((res) => {
              if (res.success) {
                $notification.success({
                  message: '消息',
                  description: res.message
                })
                loadData()
              } else {
                $notification.warning({
                  message: '消息',
                  description: res.message
                })
              }
            })
            .finally(() => {
              $destroyAll()
            })
    watch: {
      currentTreeNodeInfo: {
        handler(value) {
          this.currentClickedTypeInfo = {}
        },
        onCancel: () => {
          $destroyAll()
        }
      })
        immediate: true
      }
    },
    created() {
      this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
      this.$bus.$on('deviceCustomTypeAddSubmitSuccess', this.loadData)
    },
    methods: {
      setQueryParamAndLoadData() {
        const { id, type } = this.currentTreeNodeInfo
        this.queryParam = Object.assign({}, { attributionId: id, attributionType: type })
        this.dataSource = []
        this.loadData()
      },
    triggerCorrespondingMethod({ methodName, modalTitle, tableRowInfo }) {
      if (this[methodName] && tableRowInfo.param === 'deviceCustomType') this[methodName](tableRowInfo, modalTitle)
      loadData() {
        const params = this.getQueryParams()//查询条件
        this.loading = true
        getAction(this.url.list, params)
          .then((res) => {
            if (res.success) {
              this.dataSource = res.result.records || res.result
              const { autoClickedLevelInfo } = this.currentTreeNodeInfo
              if (autoClickedLevelInfo) {
                const tableRowRecord = this.dataSource.find(item => item.id === autoClickedLevelInfo.attributionId)
                this.handleTableRowClick(tableRowRecord)
              }
            } else {
              this.$message.warning(res.message)
            }
          }).finally(() => {
          this.loading = false
        })
      },
      /**
       * 自定义表格行功能
       * @param record 表格行记录
       */
      customRow(record) {
        return {
          style: {
            backgroundColor: this.currentClickedTypeInfo.id === record.id ? '#BAE7FF' : 'transparent'
          },
          on: {
            contextmenu: event => {
              event.preventDefault()
              this.currentRightClickedTypeInfo = Object.assign({ param: 'deviceCustomType' }, record)
              this.$emit('handleTableContextMenuOpen', this.currentRightClickedTypeInfo)
            },
            click: () => {
              this.handleTableRowClick(record)
            }
          }
        }
      },
      /**
       * 表格行点击事件
       * @param record 表格行记录
       */
      handleTableRowClick(record) {
        if (this.currentClickedTypeInfo.id === record.id) return
        this.currentClickedTypeInfo = Object.assign({}, record)
        this.$bus.$emit('sendCurrentClickedTypeInfo', record)
      },
      /**
       * 表格分页、排序改变、筛选时触发
       * @param pagination 分页器选项
       * @param filters 筛选选项
       * @param sorter 排序选项
       */
      handleTableChange(pagination, filters, sorter) {
        if (sorter.order) {
          this.isorter.column = sorter.field
          this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc'
        } else {
          this.isorter.column = 'createTime'
          this.isorter.order = 'desc'
        }
        for (let key in filters) {
          this.filters[key] = filters[key].join(',')
        }
        this.ipagination = pagination
        this.loadData()
      },
      /**
       * 删除工序或工步层级添加的设备类
       * @param tableRowInfo
       */
      handleTypeDelete(tableRowInfo) {
        const { id } = tableRowInfo
        const { $confirm, url, loadData, $notification, $destroyAll } = this
        $confirm({
          title: '提示',
          content: '确认删除此条记录吗?',
          okText: '确认',
          okType: 'danger',
          cancelText: '取消',
          onOk: () => {
            if (!url.delete) {
              this.$message.error('请设置url.delete属性!')
              return
            }
            deleteAction(url.delete, { id: id })
              .then((res) => {
                if (res.success) {
                  $notification.success({
                    message: '消息',
                    description: res.message
                  })
                  loadData()
                } else {
                  $notification.warning({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .finally(() => {
                $destroyAll()
              })
          },
          onCancel: () => {
            $destroyAll()
          }
        })
      },
      triggerCorrespondingMethod({ methodName, modalTitle, tableRowInfo }) {
        if (this[methodName] && tableRowInfo.param === 'deviceCustomType') this[methodName](tableRowInfo, modalTitle)
      }
    }
  }
}
</script>
<style scoped>
src/views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchNcModal.vue
@@ -49,7 +49,7 @@
                    </a-form-item>
                  </a-col>
                  <a-col :md="11" :sm="11">
                  <a-col :md="7" :sm="7">
                    <a-form-item label="上传时间">
                      <a-range-picker v-model="date" value-format="YYYY-MM-DD"
                                      @change="handleDateChange" allow-clear></a-range-picker>
@@ -66,7 +66,7 @@
            <a-table :columns="columns" :data-source="dataSource" bordered :pagination="false" :loading="loading"
                     :rowSelection="{selectedRowKeys: selectedRowKeys,selectedRows:selectionRows, onChange: onSelectChange}"
                     @change="handleTableChange"
                     @change="handleTableChange" :customRow="customRow"
                     :scroll="{y:456}" :size="size" rowKey="docId">
              <!-- 字符串超长截取省略号显示-->
@@ -120,430 +120,463 @@
        </a-tabs>
      </div>
    </div>
  </a-modal>
</template>
<script>
import { getAction } from '@/api/manage'
import dncApi from '@/api/dnc'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { getAction } from '@/api/manage'
  import dncApi from '@/api/dnc'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
export default {
  name: 'NcDocumentSearchNcModal',
  components: {},
  mixins: [JeecgListMixin],
  props: {
    currentDocumentInfo: {
      type: Object
    },
    size: {
      type: String
    }
  },
  data() {
    return {
      disableMixinCreated: true,
      visible: false,
      title: '',
      columns: [
        {
          title: '序号',
          dataIndex: 'rowIndex',
          key: 'rowIndex',
          width: 50,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '节点名称',
          dataIndex: 'nodeName',
          align: 'center',
          width: 80,
          sorter: false
        },
        {
          title: '节点代号',
          dataIndex: 'nodeCode',
          align: 'center',
          width: 80,
          sorter: false
        },
        {
          title: '数控系统类别',
          dataIndex: 'deviceName',
          align: 'center',
          width: 80,
          sorter: false
        },
        {
          title: '轴数',
          dataIndex: 'deviceCode',
          align: 'center',
          width: 50,
          sorter: false
        },
        {
          title: '文件名称',
          dataIndex: 'docName',
          key: 'docName',
          align: 'center',
          scopedSlots: { customRender: 'docName' },
          width: 240,
          sorter: true
        },
        {
          title: '出库状态',
          dataIndex: 'pullStatus_dictText',
          key: 'pullStatus',
          align: 'center',
          width: 80,
          filters: [
            { text: '未出库', value: 1 },
            { text: '已出库', value: 2 }
          ]
        },
        {
          title: '状  态',
          dataIndex: 'docDispatchStatus_dictText',
          key: 'docDispatchStatus',
          align: 'center',
          width: 60,
          filters: [
            { text: '编制', value: 1 },
            { text: '校对', value: 2 },
            { text: '批准', value: 3 },
            { text: '试切', value: 4 },
            { text: '定型', value: 5 }
          ]
        },
        {
          title: '创建时间',
          dataIndex: 'createTime',
          align: 'center',
          width: 150,
          sorter: true
        }
      ],
      searchValue: '',
      searchInput: '',
      spinning: false,
      treeDataSource: [],
      allTreeKeys: [],
      checkedKeys: [],
      expandedKeys: [],
      autoExpandParent: true,
      isExpandAllTreeNode: true,
      date: [],
      url: {
        list: '/nc/product/query/nc'
  export default {
    name: 'NcDocumentSearchNcModal',
    components: {},
    mixins: [JeecgListMixin],
    props: {
      currentDocumentInfo: {
        type: Object
      },
      size: {
        type: String
      }
    }
  },
  watch: {
    visible: {
      handler(value) {
        if (value) {
          this.resetData()
          this.loadData()
          this.getDocumentAssignDeviceTreeByApi()
    },
    data() {
      return {
        disableMixinCreated: true,
        visible: false,
        title: '',
        columns: [
          {
            title: '序号',
            dataIndex: 'rowIndex',
            key: 'rowIndex',
            width: 50,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '节点名称',
            dataIndex: 'nodeName',
            align: 'center',
            width: 80,
            sorter: false
          },
          {
            title: '节点代号',
            dataIndex: 'nodeCode',
            align: 'center',
            width: 80,
            sorter: false
          },
          {
            title: '数控系统类别',
            dataIndex: 'deviceName',
            align: 'center',
            width: 80,
            sorter: false
          },
          {
            title: '轴数',
            dataIndex: 'deviceCode',
            align: 'center',
            width: 50,
            sorter: false
          },
          {
            title: '文件名称',
            dataIndex: 'docName',
            key: 'docName',
            align: 'center',
            scopedSlots: { customRender: 'docName' },
            width: 240,
            sorter: true
          },
          {
            title: '出库状态',
            dataIndex: 'pullStatus_dictText',
            key: 'pullStatus',
            align: 'center',
            width: 80,
            filters: [
              { text: '未出库', value: 1 },
              { text: '已出库', value: 2 }
            ]
          },
          {
            title: '状  态',
            dataIndex: 'docDispatchStatus_dictText',
            key: 'docDispatchStatus',
            align: 'center',
            width: 60,
            filters: [
              { text: '编制', value: 1 },
              { text: '校对', value: 2 },
              { text: '批准', value: 3 },
              { text: '试切', value: 4 },
              { text: '定型', value: 5 }
            ]
          },
          {
            title: '创建时间',
            dataIndex: 'createTime',
            align: 'center',
            width: 150,
            sorter: true
          }
        ],
        searchValue: '',
        searchInput: '',
        spinning: false,
        fullScreenSpinning: false,
        treeDataSource: [],
        allTreeKeys: [],
        checkedKeys: [],
        expandedKeys: [],
        autoExpandParent: true,
        isExpandAllTreeNode: true,
        date: [],
        url: {
          list: '/nc/product/query/nc'
        }
      }
    },
    isExpandAllTreeNode: {
      handler(value) {
        if (value) this.expandedKeys = this.allTreeKeys
        else this.expandedKeys = []
      }
    }
  },
  created() {
    this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
  },
  methods: {
    handleSearchNc() {
      this.visible = true
    },
    // 获取当前对应文档列表
    loadData() {
      this.dataSource = []
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      var params = this.getQueryParams()//查询条件
      if (!params) return false
      params.attributionType = this.currentDocumentInfo.type
      params.attributionId = this.currentDocumentInfo.key
      this.loading = true
      getAction(this.url.list, params).then((res) => {
        if (res.success) this.dataSource = res.result
        else this.$message.warning(res.message)
      }).finally(() => {
        this.loading = false
      })
    },
    // 获取DNC设备树
    getDocumentAssignDeviceTreeByApi() {
      this.spinning = true
      this.treeDataSource = []
      dncApi.getDeviceTreeDataApi()
        .then(res => {
          if (res.success) {
            this.dataList = []
            this.allTreeKeys = []
            this.treeDataSource = res.result
            this.generateList(this.treeDataSource)
            this.expandedKeys = this.allTreeKeys
          } else {
            this.$message.warn(res.message)
    watch: {
      visible: {
        handler(value) {
          if (value) {
            this.resetData()
            this.loadData()
            this.getDocumentAssignDeviceTreeByApi()
          }
        })
        .finally(() => {
          this.spinning = false
        })
    },
    // 时间选择器选择完成后触发
    handleDateChange(value) {
      this.queryParam.startTime = value[0]
      this.queryParam.endTime = value[1]
    },
    /**
     * 表格分页、排序改变、筛选时触发
     * @param pagination 分页器选项
     * @param filters 筛选选项
     * @param sorter 排序选项
     */
    handleTableChange(pagination, filters, sorter) {
      if (sorter.order) {
        this.isorter.column = sorter.field
        this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc'
      } else {
        this.isorter.column = 'createTime'
        this.isorter.order = 'desc'
        }
      },
      isExpandAllTreeNode: {
        handler(value) {
          if (value) this.expandedKeys = this.allTreeKeys
          else this.expandedKeys = []
        }
      }
      for (let key in filters) {
        this.filters[key] = filters[key].join(',')
      }
      this.loadData()
    },
    created() {
      this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
    },
    methods: {
      handleSearchNc() {
        this.visible = true
      },
    // 指派到设备窗口点击确定指派设备后触发
    handleAssignDocumentToDevice() {
      const {
        checkedKeys,
        selectedRowKeys,
        selectionRows,
        dataList,
        $confirm,
        $notification,
        currentDocumentInfo,
        queryParam: { applyReason },
        $destroyAll,
        $bus
      } = this
      const { attributionId, attributionType } = currentDocumentInfo
      const paramsArray = []
      // 过滤车间key仅放入设备key
      const treeCheckedDeviceKeys = []
      checkedKeys.forEach(checkedKey => {
        const device = dataList.find(item => item.key === checkedKey && item.type === 2)
        if (device) treeCheckedDeviceKeys.push(device.key)
      })
      if (treeCheckedDeviceKeys.length === 0 || selectedRowKeys.length === 0) {
        $notification.warning({
          message: '消息',
          description: '请选择设备或文档'
      // 获取当前对应文档列表
      loadData() {
        this.dataSource = []
        if (!this.url.list) {
          this.$message.error('请设置url.list属性!')
          return
        }
        var params = this.getQueryParams()//查询条件
        if (!params) return false
        params.attributionType = this.currentDocumentInfo.type
        params.attributionId = this.currentDocumentInfo.key
        this.loading = true
        getAction(this.url.list, params).then((res) => {
          if (res.success) this.dataSource = res.result
          else this.$message.warning(res.message)
        }).finally(() => {
          this.loading = false
        })
        return
      }
      },
      $confirm({
        title: '提示',
        content: `确认提交吗?`,
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
          // 双重循环确定每一组设备与文档的参数
          treeCheckedDeviceKeys.forEach(deviceId => {
            selectionRows.forEach(({ docId, publishFileId ,attributionId,attributionType}) => {
              paramsArray.push({
                docId,
                deviceId,
                fileId: publishFileId,
                attributionId,
                attributionType,
                applyReason
              })
            })
      /**
       * 列表自定义行
       * @param record 列表行记录
       */
      customRow(record) {
        return {
          style: {
            cursor: 'pointer'
          },
          on: {
            click: () => {
              let selectedRowKeys = [...this.selectedRowKeys]
              let selectionRows = [...this.selectionRows]
              if (selectedRowKeys.includes(record.docId)) {
                selectedRowKeys = selectedRowKeys.filter(item => item !== record.docId)
                selectionRows = selectionRows.filter(item => item.docId !== record.docId)
              } else {
                selectedRowKeys.push(record.docId)
                selectionRows.push(record)
              }
              this.onSelectChange(selectedRowKeys, selectionRows)
            },
            dblclick: () => {
              this.$emit('searchTreeNode', record)
              this.visible = false
            }
          }
        }
      },
      // 获取DNC设备树
      getDocumentAssignDeviceTreeByApi() {
        this.spinning = true
        this.treeDataSource = []
        dncApi.getDeviceTreeDataApi()
          .then(res => {
            if (res.success) {
              this.dataList = []
              this.allTreeKeys = []
              this.treeDataSource = res.result
              this.generateList(this.treeDataSource)
              this.expandedKeys = this.allTreeKeys
            } else {
              this.$message.warn(res.message)
            }
          })
          .finally(() => {
            this.spinning = false
          })
      },
          paramsArray.forEach(item => {
            dncApi.assignDocumentToDeviceApi(item)
              .then(res => {
                if (res.success) {
                  $bus.$emit('reloadMainBottomTableData', 'useDocumentEquipment')
                  $notification.success({
                    message: '消息',
                    description: res.message
                  })
                } else {
                  $notification.error({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .catch(err => {
                $notification.error({
                  message: '消息',
                  description: err.message
      // 时间选择器选择完成后触发
      handleDateChange(value) {
        this.queryParam.startTime = value[0]
        this.queryParam.endTime = value[1]
      },
      /**
       * 表格分页、排序改变、筛选时触发
       * @param pagination 分页器选项
       * @param filters 筛选选项
       * @param sorter 排序选项
       */
      handleTableChange(pagination, filters, sorter) {
        if (sorter.order) {
          this.isorter.column = sorter.field
          this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc'
        } else {
          this.isorter.column = 'createTime'
          this.isorter.order = 'desc'
        }
        for (let key in filters) {
          this.filters[key] = filters[key].join(',')
        }
        this.loadData()
      },
      // 指派到设备窗口点击确定指派设备后触发
      handleAssignDocumentToDevice() {
        const {
          checkedKeys,
          selectedRowKeys,
          selectionRows,
          dataList,
          $confirm,
          $notification,
          currentDocumentInfo,
          queryParam: { applyReason },
          $destroyAll,
          $bus
        } = this
        const { attributionId, attributionType } = currentDocumentInfo
        const paramsArray = []
        // 过滤车间key仅放入设备key
        const treeCheckedDeviceKeys = []
        checkedKeys.forEach(checkedKey => {
          const device = dataList.find(item => item.key === checkedKey && item.type === 2)
          if (device) treeCheckedDeviceKeys.push(device.key)
        })
        if (treeCheckedDeviceKeys.length === 0 || selectedRowKeys.length === 0) {
          $notification.warning({
            message: '消息',
            description: '请选择设备或文档'
          })
          return
        }
        $confirm({
          title: '提示',
          content: `确认提交吗?`,
          okText: '确认',
          cancelText: '取消',
          onOk: () => {
            // 双重循环确定每一组设备与文档的参数
            treeCheckedDeviceKeys.forEach(deviceId => {
              selectionRows.forEach(({ docId, publishFileId, attributionId, attributionType }) => {
                paramsArray.push({
                  docId,
                  deviceId,
                  fileId: publishFileId,
                  attributionId,
                  attributionType,
                  applyReason
                })
              })
              .finally(() => {
                $destroyAll()
              })
          })
        },
        onCancel: () => {
          $destroyAll()
        }
      })
    },
            })
    /* 输入查询内容变化时触发 */
    handleSearchInputChange() {
      let search = this.searchInput
      console.log('data', this.dataList)
      console.log('search', search)
      let expandedKeys = this.dataList
        .map(item => {
          if (item.title != null) {
            if (item.title.indexOf(search) > -1) {
              return this.getParentKey(item.key, this.treeDataSource)
            }
            return null
            paramsArray.forEach(item => {
              dncApi.assignDocumentToDeviceApi(item)
                .then(res => {
                  if (res.success) {
                    $bus.$emit('reloadMainBottomTableData', 'useDocumentEquipment')
                    $notification.success({
                      message: '消息',
                      description: res.message
                    })
                  } else {
                    $notification.error({
                      message: '消息',
                      description: res.message
                    })
                  }
                })
                .catch(err => {
                  $notification.error({
                    message: '消息',
                    description: err.message
                  })
                })
                .finally(() => {
                  $destroyAll()
                })
            })
          },
          onCancel: () => {
            $destroyAll()
          }
        })
        .filter((item, i, self) => item && self.indexOf(item) === i)
      Object.assign(this, {
        expandedKeys,
        searchValue: search,
        autoExpandParent: true
      })
    },
      },
    /**
     * 树节点展开合并时触发
     * @param expandedKeys 展开项key
     */
    handleTreeNodeExpand(expandedKeys) {
      this.expandedKeys = expandedKeys
      this.autoExpandParent = false
    },
      /* 输入查询内容变化时触发 */
      handleSearchInputChange() {
        let search = this.searchInput
        console.log('data', this.dataList)
        console.log('search', search)
        let expandedKeys = this.dataList
          .map(item => {
            if (item.title != null) {
              if (item.title.indexOf(search) > -1) {
                return this.getParentKey(item.key, this.treeDataSource)
              }
              return null
            }
          })
          .filter((item, i, self) => item && self.indexOf(item) === i)
        Object.assign(this, {
          expandedKeys,
          searchValue: search,
          autoExpandParent: true
        })
      },
    /**
     * 树节点复选框选中时触发
     * @param selectedKeys 选中节点key
     * @param {node} node 节点对象
     */
    handleTreeNodeCheck(checkedKeys, { node }) {
      let record = node.dataRef
      this.checkedKeys = checkedKeys
    },
      /**
       * 树节点展开合并时触发
       * @param expandedKeys 展开项key
       */
      handleTreeNodeExpand(expandedKeys) {
        this.expandedKeys = expandedKeys
        this.autoExpandParent = false
      },
    /**
     * 树节点选中时触发(模拟树节点复选框选中时的效果)
     * @param selectedKeys 选中节点key
     * @param {node} node 节点对象
     */
    handleTreeNodeSelect(selectedKeys, { node }) {
      node.$el.childNodes[1].click()
    },
      /**
       * 树节点复选框选中时触发
       * @param selectedKeys 选中节点key
       * @param {node} node 节点对象
       */
      handleTreeNodeCheck(checkedKeys, { node }) {
        let record = node.dataRef
        this.checkedKeys = checkedKeys
      },
    /**
     * 递归获得输入项的父级key
     * @param key 子项key
     * @param tree 子项
     */
    getParentKey(key, tree) {
      let parentKey
      for (let i = 0; i < tree.length; i++) {
        const node = tree[i]
        if (node.children) {
          if (node.children.some(item => item.key === key)) {
            parentKey = node.key
            console.log('parentKey', parentKey)
          } else if (
            this.getParentKey(key, node.children)) {
            parentKey = this.getParentKey(key, node.children)
      /**
       * 树节点选中时触发(模拟树节点复选框选中时的效果)
       * @param selectedKeys 选中节点key
       * @param {node} node 节点对象
       */
      handleTreeNodeSelect(selectedKeys, { node }) {
        node.$el.childNodes[1].click()
      },
      /**
       * 递归获得输入项的父级key
       * @param key 子项key
       * @param tree 子项
       */
      getParentKey(key, tree) {
        let parentKey
        for (let i = 0; i < tree.length; i++) {
          const node = tree[i]
          if (node.children) {
            if (node.children.some(item => item.key === key)) {
              parentKey = node.key
              console.log('parentKey', parentKey)
            } else if (
              this.getParentKey(key, node.children)) {
              parentKey = this.getParentKey(key, node.children)
            }
          }
        }
      }
      return parentKey
    },
        return parentKey
      },
    /**
     * 递归获得所有树节点key
     * @param data 设备树数据
     */
    generateList(data) {
      for (let i = 0; i < data.length; i++) {
        const node = data[i]
        const key = node.key
        const title = node.title
        const type = node.type
        this.dataList.push({ key, title, type })
        this.allTreeKeys.push(key)
        if (node.children) this.generateList(node.children)
      }
    },
      /**
       * 递归获得所有树节点key
       * @param data 设备树数据
       */
      generateList(data) {
        for (let i = 0; i < data.length; i++) {
          const node = data[i]
          const key = node.key
          const title = node.title
          const type = node.type
          this.dataList.push({ key, title, type })
          this.allTreeKeys.push(key)
          if (node.children) this.generateList(node.children)
        }
      },
    resetData() {
      this.searchInput = ''
      this.expandedKeys = []
      this.selectedRowKeys = []
      this.selectionRows = {}
      this.checkedKeys = []
      this.filters = {}
      this.isorter = Object.assign({}, this.defaultSorter)
    },
      resetData() {
        this.searchInput = ''
        this.expandedKeys = []
        this.selectedRowKeys = []
        this.selectionRows = []
        this.checkedKeys = []
        this.filters = {}
        this.isorter = Object.assign({}, this.defaultSorter)
      },
    handleDelete() {
      // 此处函数为屏蔽mixins中的同名函数,通用函数写在父级中
    },
      handleDelete() {
        // 此处函数为屏蔽mixins中的同名函数,通用函数写在父级中
      },
    triggerCorrespondingMethod({ methodName, modalTitle }) {
      if (this[methodName]) {
        this[methodName]()
        this.title = modalTitle
      triggerCorrespondingMethod({ methodName, modalTitle }) {
        if (this[methodName]) {
          this[methodName]()
          this.title = modalTitle
        }
      }
    }
  }
}
</script>
<style scoped lang="less">
/deep/ .ant-modal {
  .tabs-container {
    display: flex;
    justify-content: space-between;
  /deep/ .ant-modal {
    .tabs-container {
      display: flex;
      justify-content: space-between;
    .replaceSearch {
      color: #40a9ff;
      font-weight: bold;
      background-color: rgb(204, 204, 204);
      .replaceSearch {
        color: #40a9ff;
        font-weight: bold;
        background-color: rgb(204, 204, 204);
      }
    }
  }
}
::-webkit-scrollbar {
  width: 8px;
}
  ::-webkit-scrollbar {
    width: 8px;
  }
</style>
src/views/dnc/base/modules/ProductStructure/Document/NcDocumentTableList.vue
@@ -17,234 +17,250 @@
</template>
<script>
import { getAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import DocumentModal from '../../../../common/DocumentModal'
import NcDocumentAssignModal from './NcDocumentAssignModal'
import dncApi from '@api/dnc'
  import { getAction } from '@/api/manage'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import DocumentModal from '../../../../common/DocumentModal'
  import NcDocumentAssignModal from './NcDocumentAssignModal'
  import dncApi from '@api/dnc'
export default {
  name: 'NcDocumentTableList',
  components: { NcDocumentAssignModal, DocumentModal },
  mixins: [JeecgListMixin],
  props: {
    currentNCDocumentAttributionInfo: {
      type: Object
    },
    size: {
      type: String
    }
  },
  data() {
    return {
      disableMixinCreated: true,
      columns: [
        {
          title: '序号',
          dataIndex: 'rowIndex',
          key: 'rowIndex',
          width: 50,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '文件名称',
          dataIndex: 'docName',
          key: 'docName',
          align: 'center',
          scopedSlots: {customRender: 'docName'},
          width: 500,
          sorter: true
        },
        {
          title: '出库状态',
          dataIndex: 'pullStatus_dictText',
          key: 'pullStatus',
          align: 'center',
          filters: [
            { text: '未出库', value: 1 },
            { text: '已出库', value: 2 }
          ],
          width: 100
        },
        {
          title: '状态',
          dataIndex: 'docDispatchStatus_dictText',
          key: 'docDispatchStatus',
          align: 'center',
          filters: [
            { text: '编制', value: 1 },
            { text: '校对', value: 2 },
            { text: '批准', value: 3 },
            { text: '试切', value: 4 },
            { text: '定型', value: 5 }
          ],
          width: 70
        },
        { title: '系统指定版本', dataIndex: 'publishVersion', align: 'center', width: 120 },
        {
          title: '创建时间',
          dataIndex: 'createTime',
          align: 'center',
          width: 150,
          sorter: true
        }
      ],
      dataSource: [],
      currentRightClickedDocumentInfo: {},
      currentClickedDocumentInfo: {},
      url: {
        list: '/nc/doc/find/page'
      }
    }
  },
  watch: {
    currentNCDocumentAttributionInfo: {
      handler(value) {
        this.currentClickedDocumentInfo = this.currentRightClickedDocumentInfo = {}
  export default {
    name: 'NcDocumentTableList',
    components: { NcDocumentAssignModal, DocumentModal },
    mixins: [JeecgListMixin],
    props: {
      currentNCDocumentAttributionInfo: {
        type: Object
      },
      immediate: true
    }
  },
  created() {
    this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
  },
  methods: {
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      size: {
        type: String
      }
      console.log('currentNCDocumentAttributionInfo', this.currentNCDocumentAttributionInfo)
      const { attributionId, attributionType, docClassCode } = this.currentNCDocumentAttributionInfo
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) this.ipagination.current = 1
      var params = this.getQueryParams()//查询条件
      params.attributionId = attributionId
      params.attributionType = attributionType
      params.docClassCode = docClassCode
      if (!params) return false
      this.dataSource = []
      this.loading = true
      getAction(this.url.list + `/${this.ipagination.current}/${this.ipagination.pageSize}`, params).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records
          if (res.result.total) {
            this.ipagination.total = res.result.total
          } else {
            this.ipagination.total = 0
          }
        } else {
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    },
    customRow(record) {
    data() {
      return {
        style: {
          backgroundColor: this.currentClickedDocumentInfo.docId === record.docId ? '#BAE7FF' : 'transparent'
        },
        on: {
          contextmenu: event => {
            event.preventDefault()
            this.currentRightClickedDocumentInfo = Object.assign({ param: 'NC' }, record)
            this.$emit('handleTableContextMenuOpen', this.currentRightClickedDocumentInfo)
        disableMixinCreated: true,
        columns: [
          {
            title: '序号',
            dataIndex: 'rowIndex',
            key: 'rowIndex',
            width: 50,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          click: () => {
            if (this.currentClickedDocumentInfo.docId === record.docId) return
            this.currentClickedDocumentInfo = Object.assign({}, record)
            this.$bus.$emit('sendCurrentClickedDocumentInfo', record)
          {
            title: '文件名称',
            dataIndex: 'docName',
            key: 'docName',
            align: 'center',
            scopedSlots: { customRender: 'docName' },
            width: 500,
            sorter: true
          },
          {
            title: '出库状态',
            dataIndex: 'pullStatus_dictText',
            key: 'pullStatus',
            align: 'center',
            filters: [
              { text: '未出库', value: 1 },
              { text: '已出库', value: 2 }
            ],
            width: 100
          },
          {
            title: '状态',
            dataIndex: 'docDispatchStatus_dictText',
            key: 'docDispatchStatus',
            align: 'center',
            filters: [
              { text: '编制', value: 1 },
              { text: '校对', value: 2 },
              { text: '批准', value: 3 },
              { text: '试切', value: 4 },
              { text: '定型', value: 5 }
            ],
            width: 70
          },
          { title: '系统指定版本', dataIndex: 'publishVersion', align: 'center', width: 120 },
          {
            title: '创建时间',
            dataIndex: 'createTime',
            align: 'center',
            width: 150,
            sorter: true
          }
        ],
        dataSource: [],
        currentRightClickedDocumentInfo: {},
        currentClickedDocumentInfo: {},
        url: {
          list: '/nc/doc/find/page'
        }
      }
    },
    /**
     * 表格分页、排序改变、筛选时触发
     * @param pagination 分页器选项
     * @param filters 筛选选项
     * @param sorter 排序选项
     */
    handleTableChange(pagination, filters, sorter) {
      if (sorter.order) {
        this.isorter.column = sorter.field
        this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc'
      } else {
        this.isorter.column = 'createTime'
        this.isorter.order = 'desc'
    watch: {
      currentNCDocumentAttributionInfo: {
        handler(value) {
          this.currentClickedDocumentInfo = this.currentRightClickedDocumentInfo = {}
        },
        immediate: true
      }
      for (let key in filters) {
        this.filters[key] = filters[key].join(',')
      }
      this.ipagination = pagination
      this.loadData()
    },
    handleDocumentEdit(record, modalTitle) {
      if (!this.$refs.modalForm) return
      this.$refs.modalForm.edit(record)
      this.$refs.modalForm.title = modalTitle
    created() {
      this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
    },
    methods: {
      loadData(arg) {
        if (!this.url.list) {
          this.$message.error('请设置url.list属性!')
          return
        }
        const { attributionId, attributionType, docClassCode, autoClickedLevelInfo } = this.currentNCDocumentAttributionInfo
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) this.ipagination.current = 1
        var params = this.getQueryParams()//查询条件
        params.attributionId = attributionId
        params.attributionType = attributionType
        params.docClassCode = docClassCode
        if (!params) return false
        this.dataSource = []
        this.loading = true
        getAction(this.url.list + `/${this.ipagination.current}/${this.ipagination.pageSize}`, params).then((res) => {
          if (res.success) {
            this.dataSource = res.result.records
            if (autoClickedLevelInfo) {
              const tableRowRecord = this.dataSource.find(item => item.docId === autoClickedLevelInfo.docId)
              this.handleTableRowClick(tableRowRecord)
              this.$bus.$emit('searchNcFinished')
            }
            if (res.result.total) {
              this.ipagination.total = res.result.total
            } else {
              this.ipagination.total = 0
            }
          } else {
            this.$message.warning(res.message)
          }
        }).finally(() => {
          this.loading = false
        })
      },
    handleDocumentAssign(record, modalTitle) {
      if (!this.$refs.documentAssignModalRef) return
      this.$refs.documentAssignModalRef.title = modalTitle
      this.$refs.documentAssignModalRef.visible = true
    },
      /**
       * 自定义表格行功能
       * @param record 表格行记录
       */
      customRow(record) {
        return {
          style: {
            backgroundColor: this.currentClickedDocumentInfo.docId === record.docId ? '#BAE7FF' : 'transparent'
          },
          on: {
            contextmenu: event => {
              event.preventDefault()
              this.currentRightClickedDocumentInfo = Object.assign({ param: 'NC' }, record)
              this.$emit('handleTableContextMenuOpen', this.currentRightClickedDocumentInfo)
            },
            click: () => {
              this.handleTableRowClick(record)
            }
          }
        }
      },
    handleDocumentExtract(record){
      const that = this
      const { docId,attributionId, attributionType } = record
      that.$confirm({
        title: '提示',
        content: `确认提取刀具吗?`,
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
          dncApi.extractToolsApi({ docId, attributionId, attributionType })
            .then(res => {
              if (res.success) {
                that.$notification.success({
                  message: '消息',
                  description: `提取成功`
                })
              } else {
      /**
       * 表格行点击事件
       * @param record 表格行记录
       */
      handleTableRowClick(record) {
        if (this.currentClickedDocumentInfo.docId === record.docId) return
        this.currentClickedDocumentInfo = Object.assign({}, record)
        this.$bus.$emit('sendCurrentClickedDocumentInfo', record)
      },
      /**
       * 表格分页、排序改变、筛选时触发
       * @param pagination 分页器选项
       * @param filters 筛选选项
       * @param sorter 排序选项
       */
      handleTableChange(pagination, filters, sorter) {
        if (sorter.order) {
          this.isorter.column = sorter.field
          this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc'
        } else {
          this.isorter.column = 'createTime'
          this.isorter.order = 'desc'
        }
        for (let key in filters) {
          this.filters[key] = filters[key].join(',')
        }
        this.ipagination = pagination
        this.loadData()
      },
      handleDocumentEdit(record, modalTitle) {
        if (!this.$refs.modalForm) return
        this.$refs.modalForm.edit(record)
        this.$refs.modalForm.title = modalTitle
      },
      handleDocumentAssign(record, modalTitle) {
        if (!this.$refs.documentAssignModalRef) return
        this.$refs.documentAssignModalRef.title = modalTitle
        this.$refs.documentAssignModalRef.visible = true
      },
      handleDocumentExtract(record) {
        const that = this
        const { docId, attributionId, attributionType } = record
        that.$confirm({
          title: '提示',
          content: `确认提取刀具吗?`,
          okText: '确认',
          cancelText: '取消',
          onOk: () => {
            dncApi.extractToolsApi({ docId, attributionId, attributionType })
              .then(res => {
                if (res.success) {
                  that.$notification.success({
                    message: '消息',
                    description: `提取成功`
                  })
                } else {
                  that.$notification.error({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .catch(err => {
                that.$notification.error({
                  message: '消息',
                  description: res.message
                  description: err.message
                })
              }
            })
            .catch(err => {
              that.$notification.error({
                message: '消息',
                description: err.message
              })
            })
            .finally(() => {
              that.$destroyAll()
            })
        },
        onCancel: () => {
          that.$destroyAll()
        }
      })
    },
              .finally(() => {
                that.$destroyAll()
              })
          },
          onCancel: () => {
            that.$destroyAll()
          }
        })
      },
    handleDelete() {
      // 此处函数为屏蔽mixins中的同名函数,通用函数写在父级中
    },
      handleDelete() {
        // 此处函数为屏蔽mixins中的同名函数,通用函数写在父级中
      },
    triggerCorrespondingMethod({ methodName, level, modalTitle, tableRowInfo }) {
      if (this[methodName] && tableRowInfo.param === 'NC') this[methodName](tableRowInfo, modalTitle)
      triggerCorrespondingMethod({ methodName, level, modalTitle, tableRowInfo }) {
        if (this[methodName] && tableRowInfo.param === 'NC') this[methodName](tableRowInfo, modalTitle)
      }
    }
  }
}
</script>
<style scoped>
src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue
@@ -30,478 +30,481 @@
</template>
<script>
import dncApi from '@/api/dnc'
import NcDocumentTableList from './Document/NcDocumentTableList'
import OtherDocumentTableList from './Document/OtherDocumentTableList'
import TableContextMenu from '../../../common/TableContextMenu'
import DocumentBatchDeleteModal from '../../../common/DocumentBatchDeleteModal'
import DeviceCustomTypeTableList
  from '@views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeTableList.vue'
import { getAction } from '@api/manage'
  import dncApi from '@/api/dnc'
  import NcDocumentTableList from './Document/NcDocumentTableList'
  import OtherDocumentTableList from './Document/OtherDocumentTableList'
  import TableContextMenu from '../../../common/TableContextMenu'
  import DocumentBatchDeleteModal from '../../../common/DocumentBatchDeleteModal'
  import DeviceCustomTypeTableList
    from '@views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeTableList.vue'
  import { getAction } from '@api/manage'
export default {
  name: 'ProductStructureMainTop',
  components: {
    DeviceCustomTypeTableList,
    DocumentBatchDeleteModal,
    TableContextMenu,
    OtherDocumentTableList,
    NcDocumentTableList
  },
  data() {
    return {
      activeTabKey: 2,
      tableContainerSize: 'small',
      isProcessHasDeviceTypeList: false,
      isProcessStepHasDeviceTypeList: false,
      currentRightClickedTableRowInfo: {},
      currentTreeNodeInfo: {},
      currentClickedTypeInfo: {},
      currentNCDocumentAttributionInfo: {},//当前NC文档的所属级即父级的详细信息(引入设备类后NC挂载至设备类下反之则挂载在工序和工步下)
      hasLoadedDataTabKeyArray: []
    }
  },
  created() {
    this.$bus.$on('sendCurrentTreeNodeInfo', this.receiveCurrentTreeNodeInfo)
    this.$bus.$on('sendCurrentClickedTypeInfo', this.receiveCurrentClickedTypeInfo)
    this.$bus.$on('reloadDocumentListData', this.reloadDocumentListData)
    this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
    this.getDeviceTypeListDisplayPermission('dnc_device_type_process', 'isProcessHasDeviceTypeList')
    this.getDeviceTypeListDisplayPermission('dnc_device_type_step', 'isProcessStepHasDeviceTypeList')
  },
  beforeDestroy() {
    this.$bus.$off('sendCurrentTreeNodeInfo', this.receiveCurrentTreeNodeInfo)
    this.$bus.$off('sendCurrentClickedTypeInfo', this.receiveCurrentClickedTypeInfo)
    this.$bus.$off('reloadDocumentListData', this.reloadDocumentListData)
    this.$bus.$off('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
  },
  methods: {
    /**
     * 获取设备类型列表在工序和工步层级的展示权限
     * @param settingKey 各层级展示权限key
     * @param dataProperty 组件data中的属性值用来控制是否展示
     */
    getDeviceTypeListDisplayPermission(settingKey, dataProperty) {
      getAction(`/system/sysParams/query/by/settingKey?settingKey=${settingKey}`).then(res => {
        if (res.success) {
          this[dataProperty] = res.result.settingValue === '1'
        }
      })
  export default {
    name: 'ProductStructureMainTop',
    components: {
      DeviceCustomTypeTableList,
      DocumentBatchDeleteModal,
      TableContextMenu,
      OtherDocumentTableList,
      NcDocumentTableList
    },
    /**
     * 接收树组件传来的当前选中的树节点信息
     * @param treeNodeInfo 树节点信息
     */
    receiveCurrentTreeNodeInfo(treeNodeInfo) {
      console.log('treeNodeInfo', treeNodeInfo)
      const { id, type } = treeNodeInfo
      // 从树组件接受树节点信息后从父组件流入子组件并重置数据
      this.currentClickedTypeInfo = this.currentRightClickedTableRowInfo = {}
      this.currentTreeNodeInfo = treeNodeInfo
      this.currentNCDocumentAttributionInfo = Object.assign({}, {
        attributionId: id,
        attributionType: type,
        docClassCode: 'NC'
      })
      this.hasLoadedDataTabKeyArray = []
      if (+type === 5 || +type === 6) {
        this.activeTabKey = 1
        this.$nextTick(() => {
          if (this.$refs.deviceCustomTypeTableList) {
            this.$refs.deviceCustomTypeTableList.setQueryParamAndLoadData()
            // 切换树之后清空NC程序列表
            if (this.$refs.ncDocumentTableListRef && this.$refs.ncDocumentTableListRef.dataSource.length > 0) this.$refs.ncDocumentTableListRef.dataSource = []
          } else if (this.$refs.ncDocumentTableListRef) this.$refs.ncDocumentTableListRef.loadData(1)
        })
      } else {
        this.activeTabKey = 2
        this.$nextTick(() => {
          if (this.$refs.otherDocumentTableListRef) this.$refs.otherDocumentTableListRef.loadData(1)
        })
      }
      this.hasLoadedDataTabKeyArray.push(this.activeTabKey)
    },
    /**
     * 接受当前点击的设备类信息
     * @param record 当前点击的设备类行信息
     */
    receiveCurrentClickedTypeInfo(record) {
      const { id, attributionType } = record
      this.currentClickedTypeInfo = Object.assign({}, record)
      this.currentNCDocumentAttributionInfo = Object.assign({}, {
        attributionId: id,
        attributionType,
        docClassCode: 'NC'
      })
      this.$nextTick(() => {
        if (this.$refs.ncDocumentTableListRef) this.$refs.ncDocumentTableListRef.loadData(1)
      })
    },
    /**
     * 控制右键菜单开启
     * @param record 当前表格行信息
     */
    handleTableContextMenuOpen(record) {
      this.currentRightClickedTableRowInfo = Object.assign({}, record)
      this.$refs.tableContextMenuRef.currentMenuLevel = record.param
      this.$refs.tableContextMenuRef.menuStyle.top = event.clientY + 'px'
      this.$refs.tableContextMenuRef.menuStyle.left = event.clientX + 'px'
      this.$refs.tableContextMenuRef.menuVisible = true
      document.body.addEventListener('click', this.handleMenuClose)
    },
    /**
     * tab栏切换时触发
     * @param activeTabKey 切换后的tabKey
     */
    handleTabChange(activeTabKey) {
      if (!this.hasLoadedDataTabKeyArray.includes(activeTabKey)) {
        this.$nextTick(() => {
          if (this.$refs.otherDocumentTableListRef) this.$refs.otherDocumentTableListRef.loadData(1)
        })
        // 阻止接口在同一文档一次点击内多次触发
        this.hasLoadedDataTabKeyArray.push(activeTabKey)
    data() {
      return {
        activeTabKey: 2,
        tableContainerSize: 'small',
        isProcessHasDeviceTypeList: false,
        isProcessStepHasDeviceTypeList: false,
        currentRightClickedTableRowInfo: {},
        currentTreeNodeInfo: {},
        currentClickedTypeInfo: {},
        currentNCDocumentAttributionInfo: {},//当前NC文档的所属级即父级的详细信息(引入设备类后NC挂载至设备类下反之则挂载在工序和工步下)
        hasLoadedDataTabKeyArray: []
      }
    },
    created() {
      this.$bus.$on('sendCurrentTreeNodeInfo', this.receiveCurrentTreeNodeInfo)
      this.$bus.$on('sendCurrentClickedTypeInfo', this.receiveCurrentClickedTypeInfo)
      this.$bus.$on('reloadDocumentListData', this.reloadDocumentListData)
      this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
      this.getDeviceTypeListDisplayPermission('dnc_device_type_process', 'isProcessHasDeviceTypeList')
      this.getDeviceTypeListDisplayPermission('dnc_device_type_step', 'isProcessStepHasDeviceTypeList')
    },
    beforeDestroy() {
      this.$bus.$off('sendCurrentTreeNodeInfo', this.receiveCurrentTreeNodeInfo)
      this.$bus.$off('sendCurrentClickedTypeInfo', this.receiveCurrentClickedTypeInfo)
      this.$bus.$off('reloadDocumentListData', this.reloadDocumentListData)
      this.$bus.$off('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
    },
    methods: {
      /**
       * 获取设备类型列表在工序和工步层级的展示权限
       * @param settingKey 各层级展示权限key
       * @param dataProperty 组件data中的属性值用来控制是否展示
       */
      getDeviceTypeListDisplayPermission(settingKey, dataProperty) {
        getAction(`/system/sysParams/query/by/settingKey?settingKey=${settingKey}`).then(res => {
          if (res.success) {
            this[dataProperty] = res.result.settingValue === '1'
          }
        })
      },
    /**
     * 文档以及NC程序导入/出库/入库/取消出库/发布/归档成功后触发重新加载文档列表
     * @param docClassCode 文档类别
     * @param attributionType 文档父级type类型
     * @param attributionId 文档父级Id
     */
    reloadDocumentListData({ docClassCode, attributionType, attributionId }) {
      console.log('docClassCode, attributionType, attributionId', docClassCode, attributionType, attributionId)
      // 在此处设备NC文档父级参数是可此方法是结构树以及设备类两种不同导入方式的共同出口
      this.currentNCDocumentAttributionInfo = Object.assign({}, { docClassCode, attributionId, attributionType })
      /**
       * 接收树组件传来的当前选中的树节点信息
       * @param treeNodeInfo 树节点信息
       */
      receiveCurrentTreeNodeInfo(treeNodeInfo) {
        const { id, type, autoClickedLevelInfo } = treeNodeInfo
        // 从树组件接受树节点信息后从父组件流入子组件并重置数据
        this.currentClickedTypeInfo = this.currentRightClickedTableRowInfo = {}
        this.currentTreeNodeInfo = treeNodeInfo
        this.currentNCDocumentAttributionInfo = Object.assign({}, {
          attributionId: id,
          attributionType: type,
          docClassCode: 'NC',
          autoClickedLevelInfo
        })
        this.hasLoadedDataTabKeyArray = []
      // 判断当前右侧展示的文档的所属是否是当前左键选中树节点或设备类,若不是当前左键选中的则在导入后不刷新右侧的文档列表(避免无效刷新)
      // 判断是否是在文档列表中进行出库/入库/发布/归档等操作,若是在文档列表中操作则操作成功后直接刷新文档列表
      if (!this.currentRightClickedTableRowInfo.hasOwnProperty('docId')) {
        if (this.currentRightClickedTableRowInfo.hasOwnProperty('deviceManagementId')) {
          // 此种情况是在引入设备类并在设备类列表中进行NC文档导入
          if (this.currentClickedTypeInfo.id !== attributionId) return
        if (+type === 5 || +type === 6) {
          this.activeTabKey = 1
          this.$nextTick(() => {
            if (this.$refs.deviceCustomTypeTableList) {
              this.$refs.deviceCustomTypeTableList.setQueryParamAndLoadData()
              // 切换树之后清空NC程序列表
              if (this.$refs.ncDocumentTableListRef && this.$refs.ncDocumentTableListRef.dataSource.length > 0) this.$refs.ncDocumentTableListRef.dataSource = []
            }
            else if (this.$refs.ncDocumentTableListRef) this.$refs.ncDocumentTableListRef.loadData(1)
          })
        } else {
          // 此种情况是在结构树节点上进行文档导入
          if (this.currentTreeNodeInfo.id !== attributionId) return
          this.activeTabKey = 2
          this.$nextTick(() => {
            if (this.$refs.otherDocumentTableListRef) this.$refs.otherDocumentTableListRef.loadData(1)
          })
        }
      }
        this.hasLoadedDataTabKeyArray.push(this.activeTabKey)
      },
      if (docClassCode === 'NC') {
      /**
       * 接受当前点击的设备类信息
       * @param record 当前点击的设备类行信息
       */
      receiveCurrentClickedTypeInfo(record) {
        const { id, attributionType } = record
        const { autoClickedLevelInfo } = this.currentTreeNodeInfo
        this.currentClickedTypeInfo = Object.assign({}, record)
        this.currentNCDocumentAttributionInfo = Object.assign({}, {
          attributionId: id,
          attributionType,
          docClassCode: 'NC',
          autoClickedLevelInfo
        })
        this.$nextTick(() => {
          if (this.$refs.ncDocumentTableListRef) this.$refs.ncDocumentTableListRef.loadData(1)
        })
      } else {
        if (this.$refs.otherDocumentTableListRef) this.$refs.otherDocumentTableListRef.loadData(1)
      }
    },
      },
    // 下载当前右键选中文档
    handleDownload() {
      const that = this
      const { docId, docName } = this.currentRightClickedTableRowInfo
      dncApi.downloadDocumentApi({ docId, docName })
        .then(res => {
          if (!res.success) {
      /**
       * 控制右键菜单开启
       * @param record 当前表格行信息
       */
      handleTableContextMenuOpen(record) {
        this.currentRightClickedTableRowInfo = Object.assign({}, record)
        this.$refs.tableContextMenuRef.currentMenuLevel = record.param
        this.$refs.tableContextMenuRef.menuStyle.top = event.clientY + 'px'
        this.$refs.tableContextMenuRef.menuStyle.left = event.clientX + 'px'
        this.$refs.tableContextMenuRef.menuVisible = true
        document.body.addEventListener('click', this.handleMenuClose)
      },
      /**
       * tab栏切换时触发
       * @param activeTabKey 切换后的tabKey
       */
      handleTabChange(activeTabKey) {
        if (!this.hasLoadedDataTabKeyArray.includes(activeTabKey)) {
          this.$nextTick(() => {
            if (this.$refs.otherDocumentTableListRef) this.$refs.otherDocumentTableListRef.loadData(1)
          })
          // 阻止接口在同一文档一次点击内多次触发
          this.hasLoadedDataTabKeyArray.push(activeTabKey)
        }
      },
      /**
       * 文档以及NC程序导入/出库/入库/取消出库/发布/归档成功后触发重新加载文档列表
       * @param docClassCode 文档类别
       * @param attributionType 文档父级type类型
       * @param attributionId 文档父级Id
       */
      reloadDocumentListData({ docClassCode, attributionType, attributionId }) {
        console.log('docClassCode, attributionType, attributionId', docClassCode, attributionType, attributionId)
        // 在此处设备NC文档父级参数是可此方法是结构树以及设备类两种不同导入方式的共同出口
        this.currentNCDocumentAttributionInfo = Object.assign({}, { docClassCode, attributionId, attributionType })
        // 判断当前右侧展示的文档的所属是否是当前左键选中树节点或设备类,若不是当前左键选中的则在导入后不刷新右侧的文档列表(避免无效刷新)
        // 判断是否是在文档列表中进行出库/入库/发布/归档等操作,若是在文档列表中操作则操作成功后直接刷新文档列表
        if (!this.currentRightClickedTableRowInfo.hasOwnProperty('docId')) {
          if (this.currentRightClickedTableRowInfo.hasOwnProperty('deviceManagementId')) {
            // 此种情况是在引入设备类并在设备类列表中进行NC文档导入
            if (this.currentClickedTypeInfo.id !== attributionId) return
          } else {
            // 此种情况是在结构树节点上进行文档导入
            if (this.currentTreeNodeInfo.id !== attributionId) return
          }
        }
        if (docClassCode === 'NC') {
          this.$nextTick(() => {
            if (this.$refs.ncDocumentTableListRef) this.$refs.ncDocumentTableListRef.loadData(1)
          })
        } else {
          if (this.$refs.otherDocumentTableListRef) this.$refs.otherDocumentTableListRef.loadData(1)
        }
      },
      // 下载当前右键选中文档
      handleDownload() {
        const that = this
        const { docId, docName } = this.currentRightClickedTableRowInfo
        dncApi.downloadDocumentApi({ docId, docName })
          .then(res => {
            if (!res.success) {
              that.$notification.error({
                message: '消息',
                description: res.message
              })
            }
          })
          .catch(err => {
            that.$notification.error({
              message: '消息',
              description: res.message
              description: err.message
            })
          })
      },
      // 删除当前右键选中文档
      handleDelete() {
        const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo
        const that = this
        that.$confirm({
          title: '提示',
          content: `删除后不可取消,确认删除吗?`,
          okText: '确认',
          cancelText: '取消',
          onOk: () => {
            dncApi.deleteDocumentApi({ docId, attributionType, attributionId })
              .then((res) => {
                if (res.success) {
                  that.$notification.success({
                    message: '消息',
                    description: res.message
                  })
                  that.reloadDocumentListData({ docClassCode: param, attributionId, attributionType })
                } else {
                  that.$notification.warning({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .finally(() => {
                that.$destroyAll()
              })
          },
          onCancel: () => {
            that.$destroyAll()
          }
        })
        .catch(err => {
          that.$notification.error({
            message: '消息',
            description: err.message
          })
      },
      /**
       * 点击批量删除后出现弹窗
       * @param modalTitle 弹窗标题
       */
      handleBatchRemove(modalTitle) {
        if (!this.$refs.documentBatchDeleteModalRef) return
        this.$refs.documentBatchDeleteModalRef.title = modalTitle
        this.$refs.documentBatchDeleteModalRef.visible = true
      },
      /**
       * 出库当前右键选中文档
       * @param menuLabel
       */
      handlePull(menuLabel) {
        const that = this
        const { docId, docName, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo
        that.$confirm({
          title: '提示',
          content: `确认${menuLabel}吗?`,
          okText: '确认',
          cancelText: '取消',
          onOk: () => {
            dncApi.documentOutboundApi({ docId, docName })
              .then(res => {
                if (res.success) {
                  that.reloadDocumentListData({ docClassCode: param, attributionId, attributionType })
                  that.$notification.success({
                    message: '消息',
                    description: `${menuLabel}成功`
                  })
                } else {
                  that.$notification.error({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .catch(err => {
                that.$notification.error({
                  message: '消息',
                  description: err.message
                })
              })
              .finally(() => {
                that.$destroyAll()
              })
          },
          onCancel: () => {
            that.$destroyAll()
          }
        })
    },
      },
    // 删除当前右键选中文档
    handleDelete() {
      const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo
      const that = this
      that.$confirm({
        title: '提示',
        content: `删除后不可取消,确认删除吗?`,
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
          dncApi.deleteDocumentApi({docId,attributionType,attributionId})
            .then((res) => {
              if (res.success) {
                that.$notification.success({
                  message: '消息',
                  description: res.message
                })
                that.reloadDocumentListData({ docClassCode: param, attributionId, attributionType })
              } else {
                that.$notification.warning({
                  message: '消息',
                  description: res.message
                })
              }
            })
            .finally(() => {
              that.$destroyAll()
            })
        },
        onCancel: () => {
          that.$destroyAll()
        }
      })
    },
    /**
     * 点击批量删除后出现弹窗
     * @param modalTitle 弹窗标题
     */
    handleBatchRemove(modalTitle) {
      if (!this.$refs.documentBatchDeleteModalRef) return
      this.$refs.documentBatchDeleteModalRef.title = modalTitle
      this.$refs.documentBatchDeleteModalRef.visible = true
    },
    /**
     * 出库当前右键选中文档
     * @param menuLabel
     */
    handlePull(menuLabel) {
      const that = this
      const { docId, docName, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo
      that.$confirm({
        title: '提示',
        content: `确认${menuLabel}吗?`,
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
          dncApi.documentOutboundApi({ docId, docName })
            .then(res => {
              if (res.success) {
                that.reloadDocumentListData({ docClassCode: param, attributionId, attributionType })
                that.$notification.success({
                  message: '消息',
                  description: `${menuLabel}成功`
                })
              } else {
      /**
       * 取消出库当前右键选中文档
       * @param menuLabel
       */
      handleCancelPull(menuLabel) {
        const that = this
        const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo
        that.$confirm({
          title: '提示',
          content: `确认${menuLabel}吗?`,
          okText: '确认',
          cancelText: '取消',
          onOk: () => {
            dncApi.documentCancelOutboundApi(docId)
              .then(res => {
                if (res.success) {
                  this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType })
                  that.$notification.success({
                    message: '消息',
                    description: res.message
                  })
                } else {
                  that.$notification.error({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .catch(err => {
                that.$notification.error({
                  message: '消息',
                  description: res.message
                  description: err.message
                })
              }
            })
            .catch(err => {
              that.$notification.error({
                message: '消息',
                description: err.message
              })
            })
            .finally(() => {
              that.$destroyAll()
            })
        },
        onCancel: () => {
          that.$destroyAll()
        }
      })
    },
              .finally(() => {
                that.$destroyAll()
              })
          },
          onCancel() {
            that.$destroyAll()
          }
        })
      },
    /**
     * 取消出库当前右键选中文档
     * @param menuLabel
     */
    handleCancelPull(menuLabel) {
      const that = this
      const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo
      that.$confirm({
        title: '提示',
        content: `确认${menuLabel}吗?`,
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
          dncApi.documentCancelOutboundApi(docId)
            .then(res => {
              if (res.success) {
                this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType })
                that.$notification.success({
                  message: '消息',
                  description: res.message
                })
              } else {
      /**
       * 发布当前右键选中文档
       * @param menuLabel
       */
      handlePublish(menuLabel) {
        const that = this
        const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo
        that.$confirm({
          title: '提示',
          content: `确认${menuLabel}吗?`,
          okText: '确认',
          cancelText: '取消',
          onOk: () => {
            dncApi.documentPublishApi(docId)
              .then(res => {
                if (res.success) {
                  this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType })
                  this.$bus.$emit('reloadMainBottomTableData', 'documentVersion')
                  that.$notification.success({
                    message: '消息',
                    description: res.message
                  })
                } else {
                  that.$notification.error({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .catch(err => {
                that.$notification.error({
                  message: '消息',
                  description: res.message
                  description: err.message
                })
              }
            })
            .catch(err => {
              that.$notification.error({
                message: '消息',
                description: err.message
              })
            })
            .finally(() => {
              that.$destroyAll()
            })
        },
        onCancel() {
          that.$destroyAll()
        }
      })
    },
              .finally(() => {
                that.$destroyAll()
              })
          },
          onCancel() {
            that.$destroyAll()
          }
        })
      },
    /**
     * 发布当前右键选中文档
     * @param menuLabel
     */
    handlePublish(menuLabel) {
      const that = this
      const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo
      that.$confirm({
        title: '提示',
        content: `确认${menuLabel}吗?`,
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
          dncApi.documentPublishApi(docId)
            .then(res => {
              if (res.success) {
                this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType })
                this.$bus.$emit('reloadMainBottomTableData', 'documentVersion')
                that.$notification.success({
                  message: '消息',
                  description: res.message
                })
              } else {
      /**
       * 重新发布当前右键选中文档并重新发布退回上一文档版本
       * @param menuLabel
       */
      handleRepublish(menuLabel) {
        const that = this
        const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo
        that.$confirm({
          title: '提示',
          content: `确认${menuLabel}吗?`,
          okText: '确认',
          cancelText: '取消',
          onOk: () => {
            dncApi.documentRepublishApi(docId)
              .then(res => {
                if (res.success) {
                  this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType })
                  that.$notification.success({
                    message: '消息',
                    description: res.message
                  })
                } else {
                  that.$notification.error({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .catch(err => {
                that.$notification.error({
                  message: '消息',
                  description: res.message
                  description: err.message
                })
              }
            })
            .catch(err => {
              that.$notification.error({
                message: '消息',
                description: err.message
              })
            })
            .finally(() => {
              that.$destroyAll()
            })
        },
        onCancel() {
          that.$destroyAll()
        }
      })
    },
              .finally(() => {
                that.$destroyAll()
              })
          },
          onCancel() {
            that.$destroyAll()
          }
        })
      },
    /**
     * 重新发布当前右键选中文档并重新发布退回上一文档版本
     * @param menuLabel
     */
    handleRepublish(menuLabel) {
      const that = this
      const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo
      that.$confirm({
        title: '提示',
        content: `确认${menuLabel}吗?`,
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
          dncApi.documentRepublishApi(docId)
            .then(res => {
              if (res.success) {
                this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType })
                that.$notification.success({
                  message: '消息',
                  description: res.message
                })
              } else {
      /**
       * 归档当前右键选中文档且后续无法继续发布或归档
       * @param menuLabel
       */
      handlePigeonhole(menuLabel) {
        const that = this
        const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo
        that.$confirm({
          title: '提示',
          content: `${menuLabel}后不可取消,确认${menuLabel}吗?`,
          okText: '确认',
          cancelText: '取消',
          onOk: () => {
            dncApi.documentPigeonholeApi(docId)
              .then(res => {
                if (res.success) {
                  this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType })
                  that.$notification.success({
                    message: '消息',
                    description: res.message
                  })
                } else {
                  that.$notification.error({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .catch(err => {
                that.$notification.error({
                  message: '消息',
                  description: res.message
                  description: err.message
                })
              }
            })
            .catch(err => {
              that.$notification.error({
                message: '消息',
                description: err.message
              })
            })
            .finally(() => {
              that.$destroyAll()
            })
        },
        onCancel() {
          that.$destroyAll()
        }
      })
    },
    /**
     * 归档当前右键选中文档且后续无法继续发布或归档
     * @param menuLabel
     */
    handlePigeonhole(menuLabel) {
      const that = this
      const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo
      that.$confirm({
        title: '提示',
        content: `${menuLabel}后不可取消,确认${menuLabel}吗?`,
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
          dncApi.documentPigeonholeApi(docId)
            .then(res => {
              if (res.success) {
                this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType })
                that.$notification.success({
                  message: '消息',
                  description: res.message
                })
              } else {
                that.$notification.error({
                  message: '消息',
                  description: res.message
                })
              }
            })
            .catch(err => {
              that.$notification.error({
                message: '消息',
                description: err.message
              .finally(() => {
                that.$destroyAll()
              })
            })
            .finally(() => {
              that.$destroyAll()
            })
        },
        onCancel() {
          that.$destroyAll()
        }
      })
    },
          },
          onCancel() {
            that.$destroyAll()
          }
        })
      },
    // 控制右键菜单关闭
    handleMenuClose() {
      this.$refs.tableContextMenuRef.menuVisible = false
      document.body.removeEventListener('click', this.handleMenuClose)
    },
      // 控制右键菜单关闭
      handleMenuClose() {
        this.$refs.tableContextMenuRef.menuVisible = false
        document.body.removeEventListener('click', this.handleMenuClose)
      },
    triggerCorrespondingMethod({ methodName, modalTitle }) {
      if (this[methodName]) this[methodName](modalTitle)
      triggerCorrespondingMethod({ methodName, modalTitle }) {
        if (this[methodName]) this[methodName](modalTitle)
      }
    }
  }
}
</script>
<style scoped>
/deep/ .ant-table-tbody .ant-table-row {
  cursor: pointer;
}
  /deep/ .ant-table-tbody .ant-table-row {
    cursor: pointer;
  }
</style>
src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue
@@ -4,7 +4,7 @@
      <div style="display: flex;flex-direction: column;height: 100%">
        <div style="display: flex;justify-content: space-between">
          <a-input placeholder="输入关键字进行搜索" allowClear v-model="searchInput"
                   @change="handleSearchInputChange" />
                   @change="handleSearchInputChange"/>
          <!--          <a-tooltip title="刷新">-->
          <!--            <a-button icon="reload" @click="handleTreeReload" style="width: 18%;margin-left: 8px"></a-button>-->
          <!--          </a-tooltip>-->
@@ -31,16 +31,16 @@
                  @select="handleTreeSelect" @expand="handleTreeExpand" @rightClick="handleTreeRightClick">
            <template slot="title" slot-scope="{ label, parentId, key:treeKey,type}">
              <ProductStructureTreeContextMenu ref="contextMenuRef"
                                               :treeParams="{label,treeKey,searchValue,type}" />
                                               :treeParams="{label,treeKey,searchValue,type}"/>
            </template>
            <a-icon slot="switcherIcon" type="down" />
            <a-icon slot="product" type="shopping" />
            <a-icon slot="component" type="camera" />
            <a-icon slot="part" type="hdd" />
            <a-icon slot="processSpecVersion" type="tag" />
            <a-icon slot="process" type="apartment" />
            <a-icon slot="processStep" type="tool" />
            <a-icon slot="switcherIcon" type="down"/>
            <a-icon slot="product" type="shopping"/>
            <a-icon slot="component" type="camera"/>
            <a-icon slot="part" type="hdd"/>
            <a-icon slot="processSpecVersion" type="tag"/>
            <a-icon slot="process" type="apartment"/>
            <a-icon slot="processStep" type="tool"/>
          </a-tree>
        </div>
      </div>
@@ -48,421 +48,481 @@
    <!--产品弹窗-->
    <ProductModal ref="productModalFormRef" :currentTreeNodeInfo="rightClickSelected"
                  @submitSuccess="getTreeDataByApi" />
                  @submitSuccess="getTreeDataByApi"/>
    <!--部件弹窗-->
    <ComponentModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
    <ComponentModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
    <!--零件弹窗-->
    <PartModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
    <PartModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
    <!--工艺规程版本弹窗-->
    <ProcessSpecVersionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
    <ProcessSpecVersionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
    <!--工序弹窗-->
    <ProcessModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
    <ProcessModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
    <!--工步弹窗-->
    <ProcessStepModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
    <ProcessStepModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
    <!--权限配置弹窗-->
    <AssignPermissionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
    <AssignPermissionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
    <!--检索电子模板弹窗-->
    <NcDocumentSearchModal :currentDocumentInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
    <NcDocumentSearchModal :currentDocumentInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
    <!--检索NC文件弹窗-->
    <NcDocumentSearchNcModal :currentDocumentInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
    <NcDocumentSearchNcModal :currentDocumentInfo="rightClickSelected" @searchTreeNode="searchTreeNode"
                             @submitSuccess="modalFormSubmitSuccess"/>
    <!--引用部件-->
    <NcComponentBorrowModal :currentBorrowInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
    <NcComponentBorrowModal :currentBorrowInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
    <!--产品结构树基本右键菜单(空白处触发)-->
    <ProductStructureBaseContextMenu ref="baseContextmenuRef" />
    <ProductStructureBaseContextMenu ref="baseContextmenuRef"/>
    <div class="full-screen-container" v-if="fullScreenSpinning">
      <a-spin :spinning="fullScreenSpinning" size="large" tip="NC文件检索中..."/>
    </div>
  </a-card>
</template>
<script>
import dncApi from '@/api/dnc'
import { deleteAction } from '@/api/manage'
import ProductStructureTreeContextMenu from './ProductStructureTreeContextMenu'
import ProductModal from './Product/ProductModal'
import ComponentModal from './Component/ComponentModal'
import PartModal from './Part/PartModal'
import ProcessSpecVersionModal from './ProcessSpecVersion/ProcessSpecVersionModal'
import ProcessModal from './Process/ProcessModal'
import ProcessStepModal from './ProcessStep/ProcessStepModal'
import AssignPermissionModal from './Permission/AssignPermissionModal'
import DeviceCustomTypeModal from '@views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModal.vue'
import ProductStructureBaseContextMenu
  from '@views/dnc/base/modules/ProductStructure/ProductStructureBaseContextMenu.vue'
import NcDocumentSearchModal from '@views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchModal.vue'
import NcDocumentSearchNcModal from '@views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchNcModal.vue'
import NcComponentBorrowModal from '@views/dnc/base/modules/ProductStructure/Document/NcComponentBorrowModal.vue'
  import dncApi from '@/api/dnc'
  import { deleteAction } from '@/api/manage'
  import ProductStructureTreeContextMenu from './ProductStructureTreeContextMenu'
  import ProductModal from './Product/ProductModal'
  import ComponentModal from './Component/ComponentModal'
  import PartModal from './Part/PartModal'
  import ProcessSpecVersionModal from './ProcessSpecVersion/ProcessSpecVersionModal'
  import ProcessModal from './Process/ProcessModal'
  import ProcessStepModal from './ProcessStep/ProcessStepModal'
  import AssignPermissionModal from './Permission/AssignPermissionModal'
  import DeviceCustomTypeModal
    from '@views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModal.vue'
  import ProductStructureBaseContextMenu
    from '@views/dnc/base/modules/ProductStructure/ProductStructureBaseContextMenu.vue'
  import NcDocumentSearchModal from '@views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchModal.vue'
  import NcDocumentSearchNcModal from '@views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchNcModal.vue'
  import NcComponentBorrowModal from '@views/dnc/base/modules/ProductStructure/Document/NcComponentBorrowModal.vue'
export default {
  name: 'ProductStructureTree',
  components: {
    ProductStructureBaseContextMenu,
    DeviceCustomTypeModal,
    AssignPermissionModal,
    ProcessStepModal,
    ProcessModal,
    ProcessSpecVersionModal,
    PartModal,
    ComponentModal,
    ProductModal,
    ProductStructureTreeContextMenu,
    NcDocumentSearchModal,
    NcDocumentSearchNcModal,
    NcComponentBorrowModal
  },
  data() {
    return {
      searchInput: '',
      cardLoading: false,
      loading: false,
      treeDataSource: [],
      selectedKeys: [],
      expandedKeys: [],
      beforeSearchExpandedKeys: [],
      searchValue: '',
      dataList: [],
      autoExpandParent: true,
      checkStrictly: true,
      allTreeKeys: [],
      rightClickSelected: {},
      url: {
        delete: '/nc/product/delete'
      }
    }
  },
  created() {
    this.getTreeDataByApi()
    this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
  },
  beforeDestroy() {
    this.$bus.$off('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
  },
  methods: {
    // 调用接口获取树的数据
    getTreeDataByApi() {
      this.loading = true
      this.cardLoading = true
      this.treeDataSource = []
      dncApi.getProductStructureTreeApi()
        .then(res => {
          if (res.success) {
            this.dataList = []
            this.allTreeKeys = []
            this.treeDataSource = res.result
            this.generateList(this.treeDataSource)
            // this.expandedKeys = this.allTreeKeys
            if (this.expandedKeys.length === 0) this.expandedKeys = this.beforeSearchExpandedKeys = [this.treeDataSource[0].id]
          } else {
            this.$message.warn(res.message)
          }
        }).finally(() => {
        this.loading = false
        this.cardLoading = false
      })
  export default {
    name: 'ProductStructureTree',
    components: {
      ProductStructureBaseContextMenu,
      DeviceCustomTypeModal,
      AssignPermissionModal,
      ProcessStepModal,
      ProcessModal,
      ProcessSpecVersionModal,
      PartModal,
      ComponentModal,
      ProductModal,
      ProductStructureTreeContextMenu,
      NcDocumentSearchModal,
      NcDocumentSearchNcModal,
      NcComponentBorrowModal
    },
    /**
     * 树节点选中时触发
     * @param selectedKeys 选中节点key
     * @param {node} node 节点对象
     */
    handleTreeSelect(selectedKeys, { node }) {
      const that = this
      let record = node.dataRef
      const { id, type } = record
      dncApi.getProductStructureTreeNodeEntityApi({ id, type })
        .then(res => {
          if (res.success) {
            let currentSelectedNodeInfo
            if (res.result.length > 0) {
              currentSelectedNodeInfo = Object.assign({}, record, { entity: res.result[0] })
            } else {
              currentSelectedNodeInfo = {}
              that.$notification.warning({
                message: '消息',
                description: '暂无该节点详细信息'
              })
            }
            // 向右侧父级组件发送当前选中树节点信息
            this.$bus.$emit('sendCurrentTreeNodeInfo', currentSelectedNodeInfo)
          } else {
            that.$notification.error({
              message: '消息',
              description: res.message
            })
          }
        })
      if (selectedKeys.length === 0) return
      this.selectedKeys = selectedKeys
    },
    /**
     * 树节点右键单击节点时触发
     * @param node 节点对象
     */
    handleTreeRightClick({ node }) {
      if (this.$refs.baseContextmenuRef) this.$refs.baseContextmenuRef.menuVisible = false
      const that = this
      const record = node.dataRef
      const { id, type } = record
      dncApi.getProductStructureTreeNodeEntityApi({ id, type })
        .then(res => {
          if (res.success) {
            if (res.result.length > 0) {
              that.rightClickSelected = Object.assign({}, record, { entity: res.result[0] })
            } else {
              that.rightClickSelected = {}
              that.$notification.warning({
                message: '消息',
                description: '暂无该节点详细信息'
              })
            }
          } else {
            that.$notification.error({
              message: '消息',
              description: res.message
            })
          }
        })
    },
    // 树节点右键单击菜单中删除按钮时触发
    handleDelete() {
      const that = this
      const { rightClickSelected: { id, type }, $confirm, url, $notification } = that
      $confirm({
        title: '提示',
        content: '确认删除此条记录吗?',
        okText: '确认',
        okType: 'danger',
        cancelText: '取消',
        onOk: () => {
          if (!url.delete) {
            this.$message.error('请设置url.delete属性!')
            return
          }
          deleteAction(url.delete + `/${id}/${type}`)
            .then((res) => {
              if (res.success) {
                that.getTreeDataByApi()
                $notification.success({
                  message: '消息',
                  description: res.message
                })
              } else {
                $notification.warning({
                  message: '消息',
                  description: res.message
                })
              }
            })
            .finally(() => {
              that.$destroyAll()
            })
        },
        onCancel: () => {
          that.$destroyAll()
    data() {
      return {
        searchInput: '',
        cardLoading: false,
        loading: false,
        treeDataSource: [],
        selectedKeys: [],
        expandedKeys: [],
        beforeSearchExpandedKeys: [],
        searchValue: '',
        dataList: [],
        autoExpandParent: true,
        checkStrictly: true,
        allTreeKeys: [],
        rightClickSelected: {},
        fullScreenSpinning: false,
        url: {
          delete: '/nc/product/delete'
        }
      })
      }
    },
    /**
     * 自动展开添加下级节点的父节点
     * @param isAddNextLevel 是否需要展开下级
     */
    modalFormSubmitSuccess(isAddNextLevel) {
      // 判断是否为添加下级并且判断父节点是否展开
      if (isAddNextLevel && !this.expandedKeys.includes(this.rightClickSelected.id)) this.expandedKeys.push(this.rightClickSelected.id)
    created() {
      this.getTreeDataByApi()
      this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
      this.$bus.$on('searchNcFinished', () => this.fullScreenSpinning = false)
    },
    /**
     * 树节点展开合并时触发
     * @param expandedKeys 展开项key
     */
    handleTreeExpand(expandedKeys) {
      this.expandedKeys = this.beforeSearchExpandedKeys = expandedKeys
      this.autoExpandParent = false
    beforeDestroy() {
      this.$bus.$off('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
    },
    methods: {
      // 调用接口获取树的数据
      getTreeDataByApi() {
        this.loading = true
        this.cardLoading = true
        this.treeDataSource = []
        dncApi.getProductStructureTreeApi()
          .then(res => {
            if (res.success) {
              this.dataList = []
              this.allTreeKeys = []
              this.treeDataSource = res.result
              this.generateList(this.treeDataSource)
              // this.expandedKeys = this.allTreeKeys
              if (this.expandedKeys.length === 0) this.expandedKeys = this.beforeSearchExpandedKeys = [this.treeDataSource[0].id]
            } else {
              this.$message.warn(res.message)
            }
          }).finally(() => {
          this.loading = false
          this.cardLoading = false
        })
      },
    // 输入查询内容变化时触发(增加防抖机制)
    handleSearchInputChange() {
      const that = this
      let timer
      if (timer) clearTimeout(timer)
      timer = setTimeout(function() {
        that.searchAndExpandTreeNode() // 加小括号调用函数
      }, 1000)
    },
    // 防抖函数中触发搜索并展开树节点
    searchAndExpandTreeNode() {
      let search = this.searchInput
      let expandedKeys
      let autoExpandParent
      if (search !== '') {
        expandedKeys = this.dataList
          .map(item => {
            if (item.title != null) {
              if (item.title.indexOf(search) > -1) {
                return this.getParentKey(item.key, this.treeDataSource)
      /**
       * 树节点选中时触发
       * @param selectedKeys 选中节点key
       * @param eventOrRecord  节点对象或者手动传入record
       */
      handleTreeSelect(selectedKeys, eventOrRecord) {
        const that = this
        let record = eventOrRecord.node ? eventOrRecord.node.dataRef : eventOrRecord
        const { id, type } = record
        dncApi.getProductStructureTreeNodeEntityApi({ id, type })
          .then(res => {
            if (res.success) {
              let currentSelectedNodeInfo
              if (res.result.length > 0) {
                currentSelectedNodeInfo = Object.assign({}, record, { entity: res.result[0] })
              } else {
                currentSelectedNodeInfo = {}
                that.$notification.warning({
                  message: '消息',
                  description: '暂无该节点详细信息'
                })
              }
              return null
              // 向右侧父级组件发送当前选中树节点信息
              this.$bus.$emit('sendCurrentTreeNodeInfo', currentSelectedNodeInfo)
            } else {
              that.$notification.error({
                message: '消息',
                description: res.message
              })
            }
          })
          .filter((item, i, self) => item && self.indexOf(item) === i)
        autoExpandParent = true
      } else {
        expandedKeys = this.beforeSearchExpandedKeys
        autoExpandParent = false
      }
      Object.assign(this, {
        expandedKeys,
        searchValue: search,
        autoExpandParent
      })
    },
        if (selectedKeys.length === 0) return
        this.selectedKeys = selectedKeys
      },
    /**
     * 递归获得输入项的父级key
     * @param key 子项key
     * @param tree 子项
     */
    getParentKey(key, tree) {
      let parentKey
      for (let i = 0; i < tree.length; i++) {
        const node = tree[i]
        if (node.children) {
          if (node.children.some(item => item.key === key)) {
            parentKey = node.key
          } else if (
            this.getParentKey(key, node.children)) {
            parentKey = this.getParentKey(key, node.children)
      /**
       * 树节点右键单击节点时触发
       * @param node 节点对象
       */
      handleTreeRightClick({ node }) {
        if (this.$refs.baseContextmenuRef) this.$refs.baseContextmenuRef.menuVisible = false
        const that = this
        const record = node.dataRef
        const { id, type } = record
        dncApi.getProductStructureTreeNodeEntityApi({ id, type })
          .then(res => {
            if (res.success) {
              if (res.result.length > 0) {
                that.rightClickSelected = Object.assign({}, record, { entity: res.result[0] })
              } else {
                that.rightClickSelected = {}
                that.$notification.warning({
                  message: '消息',
                  description: '暂无该节点详细信息'
                })
              }
            } else {
              that.$notification.error({
                message: '消息',
                description: res.message
              })
            }
          })
      },
      // 树节点右键单击菜单中删除按钮时触发
      handleDelete() {
        const that = this
        const { rightClickSelected: { id, type }, $confirm, url, $notification } = that
        $confirm({
          title: '提示',
          content: '确认删除此条记录吗?',
          okText: '确认',
          okType: 'danger',
          cancelText: '取消',
          onOk: () => {
            if (!url.delete) {
              this.$message.error('请设置url.delete属性!')
              return
            }
            deleteAction(url.delete + `/${id}/${type}`)
              .then((res) => {
                if (res.success) {
                  that.getTreeDataByApi()
                  $notification.success({
                    message: '消息',
                    description: res.message
                  })
                } else {
                  $notification.warning({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .finally(() => {
                that.$destroyAll()
              })
          },
          onCancel: () => {
            that.$destroyAll()
          }
        })
      },
      /**
       * 自动展开添加下级节点的父节点
       * @param isAddNextLevel 是否需要展开下级
       */
      modalFormSubmitSuccess(isAddNextLevel) {
        // 判断是否为添加下级并且判断父节点是否展开
        if (isAddNextLevel && !this.expandedKeys.includes(this.rightClickSelected.id)) this.expandedKeys.push(this.rightClickSelected.id)
        this.getTreeDataByApi()
      },
      /**
       * 树节点展开合并时触发
       * @param expandedKeys 展开项key
       */
      handleTreeExpand(expandedKeys) {
        this.expandedKeys = this.beforeSearchExpandedKeys = expandedKeys
        this.autoExpandParent = false
      },
      /**
       * 检索NC文件弹窗中双击行记录后触发搜索NC文件对应树节点并模拟选中树节点查询对应设备类或NC文件
       * @param searchNcRecord 检索NC文件弹窗中双击获得的NC文件列表行记录
       */
      searchTreeNode(searchNcRecord) {
        this.fullScreenSpinning = true
        const { attributionId, nodeCode, nodeName, nodeId, docId } = searchNcRecord
        this.searchInput = `[${nodeCode}]${nodeName}`
        this.searchAndExpandTreeNode()
        const treeNodeRecord = Object.assign({
          autoClickedLevelInfo: {
            attributionId,
            docId
          }
        }, this.getTreeNodeRecord(nodeId, this.treeDataSource))
        this.handleTreeSelect([treeNodeRecord.id], treeNodeRecord)
      },
      // 输入查询内容变化时触发(增加防抖机制)
      handleSearchInputChange() {
        const that = this
        let timer
        if (timer) clearTimeout(timer)
        timer = setTimeout(function() {
          that.searchAndExpandTreeNode() // 加小括号调用函数
        }, 1000)
      },
      // 防抖函数中触发搜索并展开树节点
      searchAndExpandTreeNode() {
        let search = this.searchInput
        let expandedKeys
        let autoExpandParent
        if (search !== '') {
          expandedKeys = this.dataList
            .map(item => {
              if (item.title != null) {
                if (item.title.indexOf(search) > -1) {
                  return this.getParentKey(item.key, this.treeDataSource)
                }
                return null
              }
            })
            .filter((item, i, self) => item && self.indexOf(item) === i)
          autoExpandParent = true
        } else {
          expandedKeys = this.beforeSearchExpandedKeys
          autoExpandParent = false
        }
        Object.assign(this, {
          expandedKeys,
          searchValue: search,
          autoExpandParent
        })
      },
      /**
       * 递归获得输入项的父级key
       * @param key 子项key
       * @param tree 子项
       */
      getParentKey(key, tree) {
        let parentKey
        for (let i = 0; i < tree.length; i++) {
          const node = tree[i]
          if (node.children) {
            if (node.children.some(item => item.key === key)) {
              parentKey = node.key
            } else if (
              this.getParentKey(key, node.children)) {
              parentKey = this.getParentKey(key, node.children)
            }
          }
        }
        return parentKey
      },
      /**
       * 递归获得输入项的record对象
       * @param key record对象key值
       * @param tree 树节点
       */
      getTreeNodeRecord(key, tree) {
        let treeNodeRecord
        for (let i = 0; i < tree.length; i++) {
          const node = tree[i]
          if (node.children) {
            if (node.children.findIndex(item => item.key === key) > -1) {
              treeNodeRecord = node.children.find(item => item.key === key)
            } else if (this.getTreeNodeRecord(key, node.children)) {
              treeNodeRecord = this.getTreeNodeRecord(key, node.children)
            }
          }
        }
        return treeNodeRecord
      },
      /**
       * 递归获得所有树节点key
       * @param data
       */
      generateList(data) {
        for (let i = 0; i < data.length; i++) {
          data[i].key = data[i].id
          const node = data[i]
          const key = node.id
          const title = node.label
          this.dataList.push({ key, title })
          this.allTreeKeys.push(key)
          this.setTreeNodeIcon(node)
          if (node.children) this.generateList(node.children)
        }
      },
      /**
       * 树所在父元素的右键事件
       * @param event 事件对象
       */
      openBaseContextMenu(event) {
        event.preventDefault()
        if (event.target.id !== 'tree-container') return
        this.$refs.baseContextmenuRef.menuStyle.top = event.clientY + 'px'
        this.$refs.baseContextmenuRef.menuStyle.left = event.clientX + 'px'
        this.$refs.baseContextmenuRef.menuVisible = true
        document.body.addEventListener('click', this.handleBaseContextMenuClose)
      },
      /**
       * 设置树节点图标
       * @param treeNode
       */
      setTreeNodeIcon(treeNode) {
        switch (+treeNode.type) {
          case 1:
            treeNode.slots = { icon: 'product' }
            break
          case 2:
            treeNode.slots = { icon: 'component' }
            break
          case 3:
            treeNode.slots = { icon: 'part' }
            break
          case 4:
            treeNode.slots = { icon: 'processSpecVersion' }
            break
          case 5:
            treeNode.slots = { icon: 'process' }
            break
          case 6:
            treeNode.slots = { icon: 'processStep' }
            break
          default:
        }
      },
      // 控制基础右键菜单关闭
      handleBaseContextMenuClose() {
        if (this.$refs.baseContextmenuRef) this.$refs.baseContextmenuRef.menuVisible = false
        document.body.removeEventListener('click', this.handleBaseContextMenuClose)
      },
      // 刷新重新获取树的数据
      handleTreeReload() {
        this.getTreeDataByApi()
      },
      triggerCorrespondingMethod({ methodName }) {
        if (this[methodName]) this[methodName]()
      }
      return parentKey
    },
    /**
     * 递归获得所有树节点key
     * @param data
     */
    generateList(data) {
      for (let i = 0; i < data.length; i++) {
        data[i].key = data[i].id
        const node = data[i]
        const key = node.id
        const title = node.label
        this.dataList.push({ key, title })
        this.allTreeKeys.push(key)
        this.setTreeNodeIcon(node)
        if (node.children) this.generateList(node.children)
      }
    },
    /**
     * 树所在父元素的右键事件
     * @param event 事件对象
     */
    openBaseContextMenu(event) {
      event.preventDefault()
      if (event.target.id !== 'tree-container') return
      this.$refs.baseContextmenuRef.menuStyle.top = event.clientY + 'px'
      this.$refs.baseContextmenuRef.menuStyle.left = event.clientX + 'px'
      this.$refs.baseContextmenuRef.menuVisible = true
      document.body.addEventListener('click', this.handleBaseContextMenuClose)
    },
    /**
     * 设置树节点图标
     * @param treeNode
     */
    setTreeNodeIcon(treeNode) {
      switch (+treeNode.type) {
        case 1:
          treeNode.slots = { icon: 'product' }
          break
        case 2:
          treeNode.slots = { icon: 'component' }
          break
        case 3:
          treeNode.slots = { icon: 'part' }
          break
        case 4:
          treeNode.slots = { icon: 'processSpecVersion' }
          break
        case 5:
          treeNode.slots = { icon: 'process' }
          break
        case 6:
          treeNode.slots = { icon: 'processStep' }
          break
        default:
      }
    },
    // 控制基础右键菜单关闭
    handleBaseContextMenuClose() {
      if(this.$refs.baseContextmenuRef)this.$refs.baseContextmenuRef.menuVisible = false
      document.body.removeEventListener('click', this.handleBaseContextMenuClose)
    },
    // 刷新重新获取树的数据
    handleTreeReload() {
      this.getTreeDataByApi()
    },
    triggerCorrespondingMethod({ methodName }) {
      if (this[methodName]) this[methodName]()
    }
  }
}
</script>
<style lang="less" scoped>
/deep/ .ant-card-body {
  padding: 0 12px 0 0;
}
/deep/ .ant-card-body, /deep/ .ant-spin-nested-loading, /deep/ .ant-spin-container {
  height: 100%;
}
/deep/ .ant-tree-title, .ant-tree-title .ant-dropdown-trigger {
  display: inline-block;
  width: calc(100% - 24px) !important;
}
::-webkit-scrollbar {
  width: 8px;
}
@media screen and (min-width: 1920px) {
  .tree_con {
    height: 748px !important;
  /deep/ .ant-card-body {
    padding: 0 12px 0 0;
  }
}
@media screen and (min-width: 1680px) and (max-width: 1920px) {
  .tree_con {
    height: 748px !important;
  /deep/ .ant-card-body, /deep/ .ant-spin-nested-loading, /deep/ .ant-spin-container {
    height: 100%;
  }
}
@media screen and (min-width: 1400px) and (max-width: 1680px) {
  .tree_con {
    height: 600px !important;
  /deep/ .ant-tree-title, .ant-tree-title .ant-dropdown-trigger {
    display: inline-block;
    width: calc(100% - 24px) !important;
  }
}
@media screen and (min-width: 1280px) and (max-width: 1400px) {
  .tree_con {
    height: 501px !important;
  ::-webkit-scrollbar {
    width: 8px;
  }
}
@media screen and (max-width: 1280px) {
  .tree_con {
    height: 501px !important;
  .full-screen-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, .8);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
}
  @media screen and (min-width: 1920px) {
    .tree_con {
      height: 748px !important;
    }
  }
  @media screen and (min-width: 1680px) and (max-width: 1920px) {
    .tree_con {
      height: 748px !important;
    }
  }
  @media screen and (min-width: 1400px) and (max-width: 1680px) {
    .tree_con {
      height: 600px !important;
    }
  }
  @media screen and (min-width: 1280px) and (max-width: 1400px) {
    .tree_con {
      height: 501px !important;
    }
  }
  @media screen and (max-width: 1280px) {
    .tree_con {
      height: 501px !important;
    }
  }
</style>