王震
2024-01-18 8b88172ca8801bf26a083098a09d637b11da9f01
src/views/quality/packageinspect/packageInspect-form.vue
@@ -66,13 +66,12 @@
        <el-row :gutter="10" style="width:100%;z-index: 10;height:30px;">
            <el-col :span="12">检验项目</el-col>
            <el-col :span="12" style="text-align: right;">
                <el-dropdown @command="handleCommand" v-if="!isShow">
                <el-dropdown @command="handleCommand" v-if="isShow">
                    <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>
@@ -93,7 +92,10 @@
                row-key="randomId" class="l-mes"
                default-expand-all
                :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
                  <el-table-column type="index" label="序号" width="60">
                  <el-table-column type="index" prop="parentIndex" label="序号" width="60">
                    <template scope="scope">
                        <span v-if="scope.row.isIndex">{{scope.row.parentIndex}}</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="name" label="项目" width="160">
                    <template slot-scope="scope">
@@ -124,6 +126,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,7 +197,7 @@
  updatePackageInspectById,
  getCustomer,
} from '@/api/quality/packageInspect'
import {inspect1,inspect2} from '@/const/defaultPackageInspect'
import {getAllTemplateByEnable} from '@/api/quality/packageInspectTemp'
export default {
    computed:{
    },
@@ -202,6 +205,7 @@
    },
    data(){
        return{
            inspectMoulds: [],
            isShow: true,
            submitData: {
              id:null,
@@ -253,7 +257,9 @@
          this.resultVal=val
        }
      }
      this.getAllInspect()
      this.init()
    },
    watch:{
      dialogVisible(newVal){
@@ -263,15 +269,34 @@
      }
    },
    methods:{
      checkShowState(){
        let num = 0
        this.list.forEach(ele=>{
            if(ele.children){
                ele.children.forEach(c=>{
                    if(c.pid){
                        num+=1
                    }
                })
            }
        })
        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 = ''
@@ -344,6 +369,8 @@
      clickAddLine() {
          this.list.push({
            name: '',
            isIndex : true,
            parentIndex : this.list.length + 1,
            randomId: Math.random(),
            isEdit: true,
            children: [{
@@ -433,11 +460,35 @@
            _than.list = []
            let userNameList = []
            if(dataList){
                _than.list = JSON.parse(JSON.stringify(dataList))
                let tempList = []
                dataList.forEach((ele,index)=>{
                    let obj = {
                        randomId: Math.random(),
                        name: ele.inspectName,
                        isIndex: true,
                        parentIndex: index+1,
                        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 => {
            data.packageInsProductS.forEach((item,index) => {
              if (item.children) {
                    let ele = {
                      isIndex: true,
                      parentIndex: index+1,
                      isEdit: true,
                      randomId: Math.random(),
                      name: null,
@@ -462,9 +513,7 @@
                    _than.list.push(ele)
                }
              })
              let find1 = _than.list.find(ele=>ele.name===inspect1[0].name) !=undefined;
              let find2 = _than.list.find(ele=>ele.name===inspect2[0].name) !=undefined;
              _than.isShow = find1||find2
              _than.conclusionTable = [{
                packageNo: data.packageNo,
                userName: Array.from(new Set(userNameList)).join(','),
@@ -473,6 +522,7 @@
              _than.$nextTick(()=>{
                if(_than.list.length>0){
                    _than.changeResult()
                    _than.checkShowState()
                }
              })
          }).catch(error=>{