zhaowei
2025-01-13 58848b1a18d29929ba84b0336860f258b913070f
src/views/dnc/common/TableContextMenu.vue
@@ -24,7 +24,7 @@
    name: 'TableContextMenu',
    components: {},
    props: {
      currentTableRowInfo: {
      tableRowInfo: {
        type: Object
      }
    },
@@ -43,25 +43,46 @@
        defaultContextMenuList: {
          //文档
          document: [
            { show: true, label: '编辑文档信息', code: 'document_edit', subMenu: [], icon: 'edit' },
            { show: true, label: '指派到设备', code: 'document_assign', subMenu: [], icon: 'cluster' },
            { show: false, label: '导出NC程序', code: 'document_export', subMenu: [], icon: 'export' },
            { show: true, label: '导入NC程序', code: 'document_import', subMenu: [], icon: 'import' },
            { show: true, label: '下载', code: 'document_download', subMenu: [], icon: 'download' },
            { show: true, label: '删除', code: 'document_delete', subMenu: [], icon: 'delete' },
            { show: true, label: '批量删除', code: 'document_batch_remove', subMenu: [], icon: 'delete' },
            { show: true, label: '编辑文档信息', code: 'document_edit', subMenu: [], icon: 'edit', isCommonMethod: false },
            {
              show: true,
              label: '指派到设备',
              code: 'document_assign',
              subMenu: [],
              icon: 'cluster',
              isCommonMethod: false
            },
            {
              show: false,
              label: '导出NC程序',
              code: 'document_export',
              subMenu: [],
              icon: 'export',
              isCommonMethod: true
            },
            { show: true, label: '导入NC程序', code: 'document_import', subMenu: [], icon: 'import', isCommonMethod: true },
            { show: true, label: '下载', code: 'document_download', subMenu: [], icon: 'download', isCommonMethod: true },
            { show: true, label: '删除', code: 'document_delete', subMenu: [], icon: 'delete', isCommonMethod: true },
            {
              show: true,
              label: '批量删除',
              code: 'document_batch_remove',
              subMenu: [],
              icon: 'delete',
              isCommonMethod: false
            },
            {
              show: true,
              label: '生命周期',
              subMenu: [
                { show: true, label: '出库', code: 'document_pull', icon: 'export' },
                { show: true, label: '取消出库', code: 'document_cancel_pull', icon: 'stop' },
                { show: true, label: '入库', code: 'document_push', icon: 'import' },
                { show: true, label: '发布', code: 'document_publish', icon: 'flag' },
                { show: true, label: '重新发布', code: 'document_republish', icon: 'reload' },
                { show: true, label: '归档', code: 'document_pigeonhole', icon: 'database' }
                { show: true, label: '出库', code: 'document_pull', icon: 'export', isCommonMethod: false },
                { show: true, label: '取消出库', code: 'document_cancel_pull', icon: 'stop', isCommonMethod: false },
                { show: true, label: '入库', code: 'document_push', icon: 'import', isCommonMethod: true },
                { show: true, label: '发布', code: 'document_publish', icon: 'flag', isCommonMethod: false },
                { show: true, label: '重新发布', code: 'document_republish', icon: 'reload', isCommonMethod: false },
                { show: true, label: '归档', code: 'document_pigeonhole', icon: 'database', isCommonMethod: false }
              ],
              icon: 'delete'
              icon: 'hourglass'
            }
          ]
        }
@@ -69,11 +90,25 @@
    },
    methods: {
      menuItemClick({ item, key }) {
        // process_add => handleProcessAdd 触发对应组件事件
        const methodName = 'handle' + key.split('_').map(item => item[0].toUpperCase() + item.slice(1)).join('')
        const menuKeyArray = key.split('_')
        const isCommonMethod = this.defaultContextMenuList[this.currentMenuLevel].find(item => item.code === key).isCommonMethod
        let methodName
        // 判断是否为公共方法,如果为公共方法则截取专有属性product/component/part/process等字段
        if (isCommonMethod) {
          // product_add => handleAdd 触发公共父级组件事件
          methodName = 'handle' + menuKeyArray.map(item => item[0].toUpperCase() + item.slice(1)).slice(1).join('')
        } else {
          // product_add => handleProcessAdd 触发对应组件事件
          methodName = 'handle' + menuKeyArray.map(item => item[0].toUpperCase() + item.slice(1)).join('')
        }
        const modalTitle = this.defaultContextMenuList[this.currentMenuLevel].find(item => item.code === key).label
        console.log('key', key)
        this.$bus.$emit('menuItemMethodTrigger', { level: this.currentMenuLevel, methodName, modalTitle })
        console.log('methodName---------------------------------------', methodName)
        console.log('tableRowInfo---------------------------------------', this.tableRowInfo)
        this.$bus.$emit('tableMenuItemMethodTrigger', {
          methodName,
          modalTitle,
          tableRowInfo: this.tableRowInfo
        })
      }
    }
  }