王震
2023-11-02 d2618a0663e823504742448cf25fe8e2eec48cdf
src/views/quality/finishedProductInspection/finishedProduct-form.vue
ÎļþÃû´Ó src/views/quality/finishedProductInspection/finishedProductInspectionAdd.vue ÐÞ¸Ä
@@ -4,7 +4,8 @@
    <div class="page-header">
        <div class="header-left">
            <a @click="$router.go(-1)"><i class="icon-btn-back"></i></a>
            <h2>编辑-产品检验单</h2>
            <h2 v-if="resultVal!=null && processInspectVo.id!=null">查看-产品检验单</h2>
            <h2 v-else>编辑-产品检验单</h2>
        </div>
        <div class="btn-group header-right">
            <el-button @click="addTestProject" v-if="processInspectVo.id==null">生成检验项目</el-button>
@@ -35,14 +36,6 @@
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="质量追溯号:">
                                <el-input disabled v-model="processInspectVo.qualityTraceability"
                                    placeholder="请输入质量追溯号" autocomplete="off" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="6">
                            <el-form-item label="产品名称:">
                                <el-select style="width: 100%" @change="changeOptionsSamplename" :disabled="processInspectVo.id != null"
                                    v-model="processInspectVo.material" size="small" placeholder="请选择产品名称">
@@ -52,6 +45,8 @@
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="6">
                            <el-form-item label="产品编码:">
                                <el-input disabled v-model="processInspectVo.mcode"
@@ -70,8 +65,6 @@
                                    placeholder="请输入单位" autocomplete="off" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="6">
                            <el-form-item label="数量:">
                                <el-input v-model="processInspectVo.quantity" placeholder="请输入数量"
@@ -85,7 +78,7 @@
        <div class="finishedProduct-detail">
            <el-row style="width:100%;z-index: 10;height:30px;">
                <el-col :span="12" class="inspectionProject_span">检验项目</el-col>
                <el-col :span="12" class="inspectionProject_span" style="text-align: right;">
                <el-col v-if="resultVal==null" :span="12" class="inspectionProject_span" style="text-align: right;">
                    <el-button size="mini" @click="clickAddInspectionColumn()">添加检测值列</el-button>
                    <el-button size="mini" @click="clickDeleteInspectionColumn()">删除检测值列</el-button>
                </el-col>
@@ -109,16 +102,20 @@
                                    placement="top-start">
                                    <el-input :disabled="scope.row.eId == null" v-model="scope.row.empiricalValueAddss[index]"
                                        @blur="changeState(scope.row, index)" placeholder="请输入检测值"></el-input>
                                    <span v-if="resultVal != null" v-text="scope.row.empiricalValueAddss[index]"></span>
                                </el-tooltip>
                            </template>
                        </el-table-column>
                        <el-table-column prop="deviceName" label="试验设备" min-width="250">
                            <template slot-scope="scope">
                                <span v-if="resultVal!=null && processInspectVo.id!=null" v-text="scope.row.ename"></span>
                                <div v-else>
                                <el-select style="width:100%" v-model="scope.row.eId" 
                                v-if="scope.row.iname != null" filterable @change="updateDevice(scope.row)">
                                    <el-option v-for="(item,index) in deviceList" 
                                    :key="index" :value="item.id" :label="item.number +'-'+ item.name"></el-option>
                                </el-select>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="结论" fixed="right" min-width="100">
@@ -148,13 +145,13 @@
                        <el-table-column prop="userName" label="检验员"></el-table-column>
                        <el-table-column prop="result" label="检验结论">
                            <template slot-scope="scope">
                                <el-tag type="success" v-if="scope.row.result == 1">合格</el-tag>
                                <el-tag type="danger" v-else-if="scope.row.result == 0">不合格</el-tag>
                                <el-tag type="success" v-if="scope.row.result == '1'">合格</el-tag>
                                <el-tag type="danger" v-else-if="scope.row.result == '0'">不合格</el-tag>
                            </template>
                        </el-table-column>
                        <el-table-column  label="操作">
                            <template>
                                <el-button type="text"  @click="submitSave()" size="small">上报</el-button>
                                <el-button type="text" :disabled="resultVal!=null && processInspectVo.id!=null"  @click="submitSave()" size="small">上报</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
@@ -178,6 +175,7 @@
export default {
    data() {
        return {
            resultVal: null,
            deviceList: [],
            hasChildren: true,
            optionsSamplename: [],
@@ -214,6 +212,11 @@
    mounted() {
        this.getDeviceList()
        this.processInspectVo.id = this.$route.query.id
        this.resultVal = this.$route.query.resultVal
        if(this.resultVal == null){
            let val = sessionStorage.getItem("finished-resultVal");
            val == undefined ? this.resultVal=null : this.resultVal = val
        }
        this.init()
    },
    methods: {
@@ -240,15 +243,40 @@
                    number: value
                    }
                    updateFinishedInspectById(data).then(res => {
                        if(res.data.data.indexOf("成功") > 0){
                        this.$message.success("上报成功");
                            this.checkTestState()
                        }else{
                            this.$message.warning(res.data.data)
                        }
                    });
                }).catch(() => {});
            }else{
                updateFinishedInspectById({id:this.processInspectVo.id,number:0}).then(res => {
                    if(res.data.data.indexOf("成功") > 0){
                    this.$message.success("上报成功");
                            this.checkTestState()
                        }else{
                            this.$message.warning(res.data.data)
                        }
                });
            }
            this.init()
        },
        checkTestState(){
            let resultVal = '1'
            this.inspectionItems.forEach(item=>{
                if(item.children){
                    item.children.forEach(obj=>{
                        if(obj.iresult == 0){
                            resultVal = '0'
                        }
                    })
                }
            })
            this.resultVal = resultVal
            this.inspectionResultForm[0].result = resultVal
            sessionStorage.setItem("finished-resultVal",resultVal)
        },
        init(){
            let id = this.processInspectVo.id
@@ -263,7 +291,6 @@
                    this.processInspectVo.specificationsModel = result.specs
                    this.processInspectVo.unit = result.punit
                    this.processInspectVo.quantity = result.quantity
                    let resultVal = 1
                    let userList = []
                    result.children.forEach(item=>{
                        item.iid = Math.random()
@@ -275,9 +302,6 @@
                                }
                                if(obj.inspectionValue){
                                    arr = obj.inspectionValue.split(",")
                                }
                                if(obj.iresult && obj.iresult == 0){
                                    resultVal = 0
                                }
                                obj.empiricalValueAddss = arr
                                if(arr.length > this.empiricalValueAdd){
@@ -291,7 +315,7 @@
                        materialCode: result.materialCode,
                        material: result.material,
                        userName: Array.from(new Set(userList)).join(","),
                        result: resultVal,
                        result: this.resultVal==null ? '' : this.resultVal,
                    }]
                }).catch(error=>{
                    console.log(error)
@@ -425,7 +449,7 @@
<style scoped>
.finishedProduct-detail {
  width: 100%;
  height: 470px;
  height: 500px;
  padding: 10px 20px;
  display: flex;
  border: 1px solid #ddd;
@@ -449,7 +473,7 @@
.finishedProduct-basic {
  background-color: #fff;
  height: 155px;
  height: 120px;
  display: flex;
  flex-wrap: wrap;
  padding: 10px 20px;