zss
2024-01-11 17f0e644be8c98b547f6994a7e827d328e7b532e
src/views/quality/packageinspect/packageInspect-form.vue
@@ -68,11 +68,10 @@
            <el-col :span="12" style="text-align: right;">
                <el-dropdown @command="handleCommand" v-if="!isShow && resultVal==null">
                    <el-button size="mini" style="margin-right: 10px;" type="primary" >
                        切换默认检验项<i class="el-icon-arrow-down el-icon--right"></i>
                        切换检验项模板<i class="el-icon-arrow-down el-icon--right"></i>
                    </el-button>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item command="1">检验项目1</el-dropdown-item>
                        <el-dropdown-item divided command="2">检验项目2</el-dropdown-item>
                        <el-dropdown-item :key="index" v-for="(item,index) in inspectMoulds" :command="item.father">{{item.father}}</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
              <el-button v-if="resultVal=='' || resultVal==null" size="mini" @click="clickAddLine()">添加检验项目</el-button>
@@ -124,6 +123,7 @@
                        <el-select style="width:100%" :disabled="resultVal!=null" @change="changeResult" v-model="scope.row.result" v-if="!scope.row.children">
                            <el-option label="合格" value="合格"></el-option>
                            <el-option label="不合格" value="不合格"></el-option>
                            <el-option label="不适用" value="不适用"></el-option>
                        </el-select>
                    </template>
                  </el-table-column>
@@ -194,6 +194,7 @@
  updatePackageInspectById,
  getCustomer,
} from '@/api/quality/packageInspect'
import {getAllTemplateByEnable} from '@/api/quality/packageInspectTemp'
import {inspect1,inspect2} from '@/const/defaultPackageInspect'
export default {
    computed:{
@@ -202,6 +203,7 @@
    },
    data(){
        return{
            inspectMoulds: [],
            isShow: false,
            submitData: {
              id:null,
@@ -253,7 +255,10 @@
          this.resultVal=val
        }
      }
      this.getAllInspect()
      this.init()
      this.checkShowState()
    },
    watch:{
      dialogVisible(newVal){
@@ -263,15 +268,34 @@
      }
    },
    methods:{
      checkShowState(){
        let num = 0
        this.list.forEach(ele=>{
            if(ele.children){
                ele.children.forEach(c=>{
                    if(c.pid){
                        num++
                    }
                })
            }
        })
        this.isShow = num==0
      },
      getAllInspect(){
        getAllTemplateByEnable().then(res=>{
            if(res.status===200){
                this.inspectMoulds = res.data.data
            }
        }).catch(error=>{
            console.error(error)
        })
      },
      handleCommand(command) {
        switch(command){
            case "1":
                this.init(inspect1)
            break;
            case "2":
                this.init(inspect2)
            break;
        }
        this.inspectMoulds.forEach(ele=>{
            if(ele.father==command){
                this.init(ele.children)
            }
        })
      },
      changeResult(){
        let result = ''
@@ -433,7 +457,27 @@
            _than.list = []
            let userNameList = []
            if(dataList){
                _than.list = JSON.parse(JSON.stringify(dataList))
                let tempList = []
                dataList.forEach(ele=>{
                    let obj = {
                        randomId: Math.random(),
                        name: ele.inspectName,
                        children: []
                    }
                    if(ele.children){
                        ele.children.forEach(e=>{
                            obj.children.push({
                                required: e.inspectRequired,
                                randomId: Math.random(),
                                isEdit: false,
                                note: '',
                                result: ''
                            })
                        })
                    }
                    tempList.push(obj)
                })
                _than.list = tempList
            }
            data.packageInsProductS.forEach(item => {
              if (item.children) {
@@ -462,9 +506,9 @@
                    _than.list.push(ele)
                }
              })
              let find1 = this.list.find(ele=>ele.name===inspect1[0].name&&ele.isEdit) !=undefined;
              let find2 = this.list.find(ele=>ele.name===inspect2[0].name&&ele.isEdit) !=undefined;
              this.isShow = find1||find2
            //   let find1 = this.list.find(ele=>ele.name===inspect1[0].name&&ele.isEdit) !=undefined;
            //   let find2 = this.list.find(ele=>ele.name===inspect2[0].name&&ele.isEdit) !=undefined;
            //   this.isShow = find1||find2
              _than.conclusionTable = [{
                packageNo: data.packageNo,
                userName: Array.from(new Set(userNameList)).join(','),