licp
2024-05-06 d271f2493796a557eac67b95b310df776abaf48b
src/views/quality/processconfiguration/index.vue
@@ -9,6 +9,7 @@
        :prelang="prelang"
        :options="options"
        :ajaxFun="ajaxFun"
        @queryParam="getQueryParam($event)"
        ref="processconfiguration"
      >
        <template #toolbar></template>
@@ -38,23 +39,60 @@
                </div>
                <div v-if="type === '产品检验' ">
                    <el-radio-group v-model="checkList">
                      <el-radio label="返修">返修</el-radio>
                      <el-radio label="接收">接收</el-radio>
                      <el-radio label="降级使用">降级使用</el-radio>
                      <el-radio label="报废">报废</el-radio>
                        <el-row>
                          <div style="padding: 20px;">
                            <el-radio label="返修">返修</el-radio>
                            <el-radio label="接收">接收</el-radio>
                            <el-radio label="降级使用">降级使用</el-radio>
                            <el-radio label="报废">报废</el-radio>
                        </div>
                          <div style="padding: 20px;">
                            <el-radio label="降为他用">降为他用</el-radio>
                        </div>
                        </el-row>
                    </el-radio-group>
                    <div class="search" style="margin-left: 20px;" v-if="checkList=='返修'">
                        <label style="margin-right: 10px;">工序</label>
                        <el-select v-model="moRoutingOperationId" placeholder="请选择">
                            <el-option
                            v-for="item in listOptions"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                            </el-option>
                        </el-select>
                    </div>
                </div>
                <div v-if="type ===  '过程检验'">
                    <el-radio-group v-model="checkList">
                      <el-radio label="返修">返修</el-radio>
                      <el-radio label="接收">接收</el-radio>
                      <el-radio label="降级使用">降级使用</el-radio>
                      <el-radio label="报废">报废</el-radio>
                      <el-row>
                          <div style="padding: 20px;">
                          <el-radio label="返修">返修</el-radio>
                          <el-radio label="接收">接收</el-radio>
                          <el-radio label="降级使用">降级使用</el-radio>
                          <el-radio label="报废">报废</el-radio>
                          </div>
                          <div style="padding: 20px;">
                          <el-radio label="返工">返工</el-radio>
                          <el-radio label="降为他用">降为他用</el-radio>
                          </div>
                    </el-row>
                    </el-radio-group>
                    <div class="search" style="margin-left: 20px;" v-if="checkList=='返修'">
                        <label style="margin-right: 10px;">工序</label>
                        <el-select v-model="moRoutingOperationId" placeholder="请选择">
                            <el-option
                            v-for="item in listOptions"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                            </el-option>
                        </el-select>
                    </div>
                </div>
            </el-form>
            <span slot="footer" >
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button @click="WayCancel()">取 消</el-button>
                <el-button type="primary" @click="WaySure()">确 定</el-button>
            </span>
        </el-dialog>
@@ -63,20 +101,28 @@
</template>
<script>
import { UnqualifiedList,pullInsUnapi,AuditSuggestion
import {
  UnqualifiedList,
  pullInsUnapi,
  AuditSuggestion,
  exportData,
  chooseMoRoutingOperation,
} from '@/api/quality/unqualifiedprocess'
import TableForm from './table-form'
import { mapGetters } from 'vuex'
// import { remote } from '@/api/admin/dict'
import { transform } from '@/util/fileTransform'
import ttable from '@/views/common/ztt-table.vue'
export default {
  data() {
    return {
      queryParam: {},
      checkList: "",
      moRoutingOperationId:"",
      // WayIdea:'',
      UserId:{},
      type:'',
      ajaxFun: UnqualifiedList,
      ajaxFun: UnqualifiedList,pullInsUnapi,AuditSuggestion,
      addOrUpdateVisible: false,
      multipleSelection: [],
      typeOptions: [],
@@ -122,6 +168,15 @@
                  return this.materialType
            // render: { fun: this.addOrUpdateHandle }
              }
          },
          // 检验编号
          {
            minWidth: '140',
            prop: 'inspectNo',
            label: '检验编号',
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text',
          },
          // 产品名称
          {
@@ -247,65 +302,16 @@
          //     return this.processModeOptions
          //   }
          // },
          //发起人
            // {
            //   minWidth: '200',
            //   prop: 'originator',
            //   label: '发起人',
            //   sort: true,
            //   isTrue: true,
            //   isSearch: true,
            //   searchInfoType: 'text'
            // },
          // 审核人
          // {
          //   minWidth: '140',
          //   prop: 'examiner',
          //   label: '审核人',
          //   sort: true,
          //   isTrue: true,
          //   isSearch: true,
          //   searchInfoType: 'text'
          // },
          // 处理人
          // {
          //   minWidth: '120',
          //   prop: 'handler',
          //   label: '处理人',
          //   sort: true,
          //   isTrue: true,
          //   isSearch: true,
          //   searchInfoType: 'text'
          // },
        ],
        toolbar: [
          {
            text: '导出',
            type: 'primary',
            // fun: this.addOrUpdateHandle
          },
        ],
        operator: [
          // {
          //   text: '删除',
          //   type: 'text',
          //   size: 'small',
          //   fun: this.deleteHandle
          //   text: '导出',
          //   type: 'primary',
          //   fun: this.handleExport
          // },
          {
            text: '提交审核',
            type: 'text',
            size: 'small',
            fun: this.Submitreview
          },
          {
            text: '审核结果',
            type: 'text',
            size: 'small',
            fun: this.AuditResult
          }
        ],
        operator: null,
        operatorConfig: {
          fixed: 'right',
          label: '操作',
@@ -313,8 +319,9 @@
          minWidth: 100
        }
      },
      materialType: [{label:'原材料检验',value:'原材料检验'},{label:'过程检验',value:'过程检验'},{label:'产品检验',value:'产品检验'}],
      StateList: [{label:'全部',value:''},{label:'已提交审核',value:'1'},{label:'待处理',value:'0'},{label:'已处理',value:'2'}],
      listOptions:[],
      materialType: [{label:'原材料检验',value:'原材料检验'},{label:'过程检验',value:'过程检验'},{label:'产品检验',value:'产品检验'},{label:'包装检验',value:'包装检验'}],
      StateList: [{label:'全部',value:''},{label:'已提交审核',value:'1'},{label:'待处理',value:'0'},{label:'已完成',value:'2'}],
      insStateList: [{label:'其他',value:''},{label:'瑕疵',value:'1'}],
    }
  },
@@ -324,42 +331,105 @@
  },
  computed: {
    ...mapGetters(['permissions'])
  },
  watch: {
    checkList(val){
        if(val!='返修'){
            this.moRoutingOperationId = null
        }
    }
  },
  created() {
    // this.getType()
    let arr = []
    if(this.permissions.quality_processconfiguration_submit){
      arr.push({
            text: '提交审核',
            type: 'text',
            size: 'small',
            fun: this.Submitreview,
            show: {
                key: 'state',
                val: [0]
            }
          })
    }
    if(this.permissions.quality_processconfiguration_result){
        arr.push({
            text: '审核结果',
            type: 'text',
            size: 'small',
            fun: this.AuditResult,
            showFun: (row)=>{return row.type != '原材料检验'}
          })
    }
    this.table.operator = arr.length>0 ? arr : null
  },
  methods: {
    chooseMoRoutingOperation(id){
        chooseMoRoutingOperation({id}).then(res =>{
            this.listOptions = res.data.data
        })
    },
    getQueryParam(data){
      this.queryParam = data
    },
    handleExport(){
      exportData(this.queryParam).then(res=>{
          this.downloadFun(res)
      }).catch(error=>{
          console.log(error);
      })
    },
    downloadFun(result){
        if(result == null || result == undefined){
            return;
        }
        var nameList = result.headers['content-disposition'];
        nameList = decodeURI(nameList);
        var fileName = nameList.split('=')[1];
        const blob = new Blob([result.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
        const downloadElement = document.createElement('a') // 新建一个DOM节点
        const href = window.URL.createObjectURL(blob) // 创建下载的链接
        downloadElement.href = href
        downloadElement.download = fileName // 下载后文件名
        document.body.appendChild(downloadElement) // 将新增的节点挂载到页面上
        downloadElement.click() // 点击下载
        document.body.removeChild(downloadElement) // 下载完成移除元素
        window.URL.revokeObjectURL(href)
    },
    //审核结果
    AuditResult(row){
      console.log(row);
      this.UserId = row.id
      this.type = row.type
      this.dialogVisible = true;
      console.log(row.type);
      // setTimeout(() => {
         //       if (this.type === 原材料检验) {
         //          return
         //       } else
      //     if (this.type === 产品检验) {
         //       }
         //    }, 100)
      this.chooseMoRoutingOperation(row.id)
    },
    WayCancel(){
      this.dialogVisible = false
      this.checkList = null
      this.moRoutingOperationId = null
      this.WayIdea = null
    },
    WaySure(){
      AuditSuggestion({id:this.UserId,way:this.checkList}).then(
      AuditSuggestion({id:this.UserId,way:this.checkList,moRoutingOperationId:Number(this.moRoutingOperationId)*1}).then(
        res =>{
          this.checkList = null
          this.moRoutingOperationId = null
          this.WayIdea = null
          this.$refs.processconfiguration.refreshData()
          ;})
      this.dialogVisible = false
    },
    //提交审核
   Submitreview(row){
      console.log(row.id);
       pullInsUnapi({id:row.id}).then(res =>{
        console.log(res);
        this.$refs.processconfiguration.refreshData()
       })
    },
    //状态
    formatInsState(row, column, cellValue){
            if(cellValue != undefined || cellValue != null){
@@ -370,7 +440,7 @@
                  return "<span style='color:#34BD66;'>已提交审核</span>"
                }
                if(cellValue == 2){
                  return "<span style='color:#34BD66;'>已处理</span>"
                  return "<span style='color:#34BD66;'>已完成</span>"
                }
            }
        },
@@ -381,24 +451,10 @@
            }
            return "<span style='color:#34BD66;'></span>"
        }
    },
    // materialTypeList(row, column, cellValue){
    //         if(cellValue != undefined || cellValue != null){
    //             if(cellValue == 原材料检验){
    //                 return "<span style='color:#E84738;'>原材料检验</span>"
    //             }
    //             if(cellValue == 过程检验){
    //               return "<span style='color:#34BD66;'>过程检验</span>"
    //             }
    //             if(cellValue == 质量检验){
    //               return "<span style='color:#34BD66;'>质量检验</span>"
    //             }
    //         }
    //     },
    },
    // 获取数据列表
    getData() {
      this.$refs.processconfiguration.getDataList()
      // this.$refs.processconfiguration.getDataList()
    },
    handleSelectionChange(val) {
      // 多行选中