zouyu
2023-12-25 1dc18db8439ce29fee28edf6627aaadc8726c49c
src/views/technology/routing/index.vue
@@ -13,20 +13,21 @@
        ref="routingTable"
      >
        <template #toolbar>
          <el-button
            v-if="permissions.technology_routing_ifssync"
            type="primary"
            :loading="ifsSynsLoading"
            @click="syncIfs"
            >IFS同步</el-button
          >
          <el-button
            v-if="permissions.technology_routing_advancecalc"
            type="primary"
            :loading="preCalcLoading"
            @click="calcTech"
            >提前计算</el-button
          >
          <el-button v-if="permissions.technology_routing_add"
          type="primary" @click="addOrUpdateHandle">新增</el-button>
          <el-button @click="() => {this.approveHandle('ACCEPT')}"
          :disabled="!uniqueStateArr.includes('01draft')"
          v-if="permissions.technology_routing_accept">批准</el-button>
          <el-button @click="() => {this.approveHandle('REVOKE')}"
          :disabled="!uniqueStateArr.includes('02accepted')"
          v-if="permissions.technology_routing_revoke">撤回</el-button>
          <el-button @click="() => {this.approveHandle('CANCEL')}"
          :disabled="!uniqueStateArr.includes('02accepted')"
          v-if="permissions.technology_routing_cancel">拒绝</el-button>
          <el-button @click="copyRouting"
          v-if="permissions.technology_routing_cancel">复制</el-button>
          <el-button @click="() => {this.deleteAll()}" type="primary"
          v-if="permissions.technology_routing_batch_del">批量删除</el-button>
        </template>
      </ttable>
      <el-dialog title="导入" :visible.sync="importRoutingVisible" width="50%">
@@ -114,7 +115,6 @@
import {
  fetchList,
  delObj,
  changeState,
  changeStateBatch,
  exportRoutingTemplate,
  routingIfsSync,
@@ -132,13 +132,14 @@
  data() {
    return {
      ids: [],
      uniqueStateArr: [],
      ajaxFun: fetchList,
      multipleSelection: [],
      isShowQuery: false,
      customUpload: true,
      uploadInfo: {
        // 是否展示上传EXCEL以及对应的url
        isShow: true,
        isShow: false,
        url: '/mes/routing/uploadExcel'
      },
      prelang: 'routing',
@@ -196,7 +197,7 @@
            noShowTip: false
          },
          // 是否为主工艺
          {
          /* {
            minWidth: '120',
            prop: 'master',
            label: '主工艺',
@@ -210,7 +211,7 @@
            formatter: (row, column, cellValue) => {
              return cellValue == true ? '是' : '否'
            }
          },
          }, */
          // 状态
          {
            minWidth: '120',
@@ -266,19 +267,19 @@
            searchInfoType: 'text'
          },
          // 工艺类型
          {
            minWidth: '120',
            prop: 'bomTypeDb',
            label: '工艺类型',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'select',
            formatter: this.formatBomTypeDbType,
            optList: () => {
              return this.bomTypeDbOptions
            }
          },
          // {
          //   minWidth: '120',
          //   prop: 'bomTypeDb',
          //   label: '工艺类型',
          //   sort: true,
          //   isTrue: true,
          //   isSearch: true,
          //   searchInfoType: 'select',
          //   formatter: this.formatBomTypeDbType,
          //   optList: () => {
          //     return this.bomTypeDbOptions
          //   }
          // },
          // 逐步采用日期
          {
            minWidth: '200',
@@ -300,7 +301,7 @@
            searchInfoType: 'datetimerange'
          },
          // 替代
          {
          /* {
            minWidth: '120',
            prop: 'alternativeNo',
            label: '替代',
@@ -308,9 +309,9 @@
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          }, */
          // 替代描述
          {
         /*  {
            minWidth: '120',
            prop: 'alternativeDesc',
            label: '替代描述',
@@ -318,7 +319,7 @@
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          }, */
          // 是否已同步至IFS
          // {
          //   minWidth: '120',
@@ -356,65 +357,8 @@
            searchInfoType: 'datetimerange'
          }
        ],
        toolbar: [
          {
            text: '新增',
            type: 'primary',
            fun: this.addOrUpdateHandle,
            disabled: false,
            permitArr: []
          },
          {
            text: '批准',
            fun: () => {
              this.approveHandle('ACCEPT')
            },
            disabled: false,
            permitArr: ['01draft']
          },
          {
            text: '撤回',
            fun: () => {
              this.approveHandle('REVOKE')
            },
            disabled: false,
            permitArr: ['02accepted']
          },
          {
            text: '拒绝',
            fun: () => {
              this.approveHandle('CANCEL')
            },
            disabled: false,
            permitArr: ['02accepted']
          },
          {
            text: '复制',
            fun: this.copyRouting,
            disabled: false,
            permitArr: []
          },
          {
            text: '删除',
            fun: () => {
              this.deleteAll()
            },
            disabled: false,
            permitArr: []
          }
        ],
        operator: [
          {
            text: '删除',
            type: 'text',
            size: 'small',
            fun: this.deleteHandle
            // show: {
            //   val: ['01draft'],
            //   key: 'state'
            // }
          }
        ],
        toolbar: [],
        operator: null,
        operatorConfig: {
          fixed: 'right',
          label: '操作',
@@ -491,6 +435,20 @@
    this.getData()
  },
  created() {
    if(this.permissions.technology_routing_del){
      this.table.operator = [
          {
            text: '删除',
            type: 'text',
            size: 'small',
            fun: this.deleteHandle
            // show: {
            //   val: ['01draft'],
            //   key: 'state'
            // }
          }
        ]
    }
    this.getBomTypeDbOptions()
  },
  methods: {
@@ -508,6 +466,10 @@
    },
    // 新增 / 修改
    addOrUpdateHandle(row) {
      if(!this.permissions.technology_routing_edit && row.id!=null){
        this.$message.error("该角色没有操作权限")
        return
      }
      this.$router.push({
        name: 'routingForm',
        query: { id: row == null ? null : row.id }
@@ -613,21 +575,22 @@
          uniqueStateArr.push(stateArr[i])
        }
      }
      this.uniqueStateArr = uniqueStateArr
      // 循环表头按钮,判断每个按钮的permitArr是否完全包含选中状态,若完全包含,则按钮亮,否则按钮灰
      var toolbar = this.table.toolbar
      for (var j = 0; j < toolbar.length; j++) {
        if (
          uniqueStateArr.every((val) =>
            toolbar[j].permitArr.length <= 0
              ? true
              : toolbar[j].permitArr.includes(val)
          )
        ) {
          toolbar[j].disabled = false
        } else {
          toolbar[j].disabled = true
        }
      }
      // var toolbar = this.table.toolbar
      // for (var j = 0; j < toolbar.length; j++) {
      //   if (
      //     uniqueStateArr.every((val) =>
      //       toolbar[j].permitArr.length <= 0
      //         ? true
      //         : toolbar[j].permitArr.includes(val)
      //     )
      //   ) {
      //     toolbar[j].disabled = false
      //   } else {
      //     toolbar[j].disabled = true
      //   }
      // }
      // 将选中记录赋值给multipleSelection
      this.multipleSelection = val
    },