zouyu
2024-01-03 03be129c50068164b8cc4186d4d4e5b860503476
src/views/quality/packageinspect/packageInspect-form.vue
@@ -63,13 +63,20 @@
        </el-form>
      </div>
      <div class="packageInspect-detail">
        <el-row :gutter="10" style="width:100%;z-index: 10;height:50px;">
            <el-col :sm="18" :lg="20">检验项目</el-col>
            <el-col :sm="3" :lg="2" >
              <el-button v-if="resultVal=='' || resultVal==null" size="small" @click="clickAddLine()">添加检验项目</el-button>
            </el-col>
            <el-col :sm="3" :lg="2">
              <el-button v-if="resultVal=='' || resultVal==null" style="width:100%" type="primary"  size="small"
        <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">
                    <el-button size="mini" style="margin-right: 10px;" type="primary" >
                        切换默认检验项<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-menu>
                </el-dropdown>
              <el-button v-if="resultVal=='' || resultVal==null" size="mini" @click="clickAddLine()">添加检验项目</el-button>
              <el-button v-if="resultVal=='' || resultVal==null" type="primary" size="mini"
              @click="savePackIns()">保存</el-button>
            </el-col>
        </el-row>
@@ -90,19 +97,22 @@
                  </el-table-column>
                  <el-table-column prop="name" label="项目" width="160">
                    <template slot-scope="scope">
                        <el-input :readonly="resultVal!=null" v-if="scope.row.children" class="inline-input" style="width:80%;" v-model="scope.row.name"
                        <el-input :readonly="resultVal!=null || !scope.row.isEdit" v-if="scope.row.children" class="inline-input" style="width:80%;" v-model="scope.row.name"
                          placeholder="请输入项目名称"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column prop="required" label="要求" width="160" show-overflow-tooltip>
                  <el-table-column prop="required" label="要求" width="160">
                    <template slot-scope="scope">
                      <div v-if="!scope.row.children">
                      <el-input :readonly="resultVal!=null" v-model="scope.row.required"
                        placeholder="请输入要求"></el-input>
                        <el-tooltip :content="scope.row.required">
                            <el-input :readonly="resultVal!=null || !scope.row.isEdit"
                            v-model="scope.row.required"
                              placeholder="请输入要求"></el-input>
                        </el-tooltip>
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column prop="note" label="检验描述" width="160" show-overflow-tooltip>
                  <el-table-column prop="note" label="检验描述" width="160">
                    <template slot-scope="scope">
                      <div v-if="!scope.row.children">
                        <el-input :readonly="resultVal!=null" v-model="scope.row.note" placeholder="检验描述"></el-input>
@@ -119,10 +129,10 @@
                  </el-table-column>
                  <el-table-column v-if="resultVal=='' || resultVal==null" fixed="right" style="background-color: white;" label="操作" width="200">
                    <template slot-scope="scope">
                      <el-button v-if="scope.row.children" icon="el-icon-circle-plus-outline" type="text" @click="clickAddChildren(scope.row,scope.$index)">添加行</el-button>
                      <el-button v-if="!scope.row.children" icon="el-icon-circle-close" type="text"
                      <el-button v-if="scope.row.children && scope.row.isEdit" icon="el-icon-circle-plus-outline" type="text" @click="clickAddChildren(scope.row,scope.$index)">添加行</el-button>
                      <el-button v-if="!scope.row.children && scope.row.isEdit" icon="el-icon-circle-close" type="text"
                      @click="clickDelLine(scope.row,scope.$index,scope.row.children!=null)">取消</el-button>
                      <el-button v-if="scope.row.children" icon="el-icon-circle-close" type="text"
                      <el-button v-if="scope.row.children && scope.row.isEdit" icon="el-icon-circle-close" type="text"
                      @click="clickDelLine(scope.row,scope.$index,scope.row.children!=null)">删除项目</el-button>
                    </template>
@@ -184,6 +194,7 @@
  updatePackageInspectById,
  getCustomer,
} from '@/api/quality/packageInspect'
import {inspect1,inspect2} from '@/const/defaultPackageInspect'
export default {
    computed:{},
    components:{
@@ -250,6 +261,16 @@
      }
    },
    methods:{
      handleCommand(command) {
        switch(command){
            case "1":
                this.init(inspect1)
            break;
            case "2":
                this.init(inspect2)
            break;
        }
      },
      changeResult(){
        let result = ''
        let data = this.list
@@ -322,12 +343,14 @@
          this.list.push({
            name: '',
            randomId: Math.random(),
            isEdit: true,
            children: [{
              name: '',
              note: '',
              required: '',
              result: '',
              randomId: Math.random(),
              isEdit: true,
            }]
          })
      },
@@ -339,6 +362,7 @@
            required: '',
            result: '',
            randomId: Math.random(),
            isEdit: true,
        })
      },
      // 删除行
@@ -392,22 +416,27 @@
          })
        }
      },
      init(){
        if(this.dataForm.id){
          fetchListById(this.dataForm.id).then(res=>{
      init(dataList){
        const _than = this
        if(_than.dataForm.id){
          fetchListById(_than.dataForm.id).then(res=>{
            let data = res.data.data
            this.dataForm.packInsNo = data.packInsNo
            this.dataForm.packageNo = data.packageNo
            this.dataForm.contractNo = data.contractNo
            this.dataForm.customerName = data.customerName
            this.dataForm.projectName = data.projectName
            this.dataForm.createTime = data.createTime
            this.dataForm.createUser = data.createUser
            this.list = []
            _than.dataForm.packInsNo = data.packInsNo
            _than.dataForm.packageNo = data.packageNo
            _than.dataForm.contractNo = data.contractNo
            _than.dataForm.customerName = data.customerName
            _than.dataForm.projectName = data.projectName
            _than.dataForm.createTime = data.createTime
            _than.dataForm.createUser = data.createUser
            _than.list = []
            let userNameList = []
            if(dataList){
                _than.list = JSON.parse(JSON.stringify(dataList))
            }
            data.packageInsProductS.forEach(item => {
              if (item.children) {
                    let ele = {
                      isEdit: true,
                      randomId: Math.random(),
                      name: null,
                      children: []
@@ -420,6 +449,7 @@
                      let o = {
                        name: item.name,
                        randomId: Math.random(),
                        isEdit: true,
                        required: obj.required,
                        pid: obj.pid,
                        note: obj.note?obj.note:'',
@@ -427,24 +457,24 @@
                      }
                      ele.children.push(o)
                    })
                    this.list.push(ele)
                    _than.list.push(ele)
                }
              })
              this.conclusionTable = [{
              _than.conclusionTable = [{
                packageNo: data.packageNo,
                userName: Array.from(new Set(userNameList)).join(','),
                result: null
              }]
              this.$nextTick(()=>{
                if(this.list.length>0){
                  this.changeResult()
              _than.$nextTick(()=>{
                if(_than.list.length>0){
                    _than.changeResult()
                }
              })
          }).catch(error=>{
            this.$message.error("获取失败",error)
            _than.$message.error("获取失败",error)
          })
        }else{
          this.conclusionTable = []
            _than.conclusionTable = []
        }
      },
    },