licp
2024-04-16 c1e5dfb4c72a0ab2478d3b7295ab7deecd3f8c8c
src/components/do/b1-inspect-order-plan/Inspection.vue
@@ -18,24 +18,21 @@
   .center {
      width: calc(100% - 40px);
      height: calc(100% - 60px - 80px - 40px);
      max-height: 580px;
      background-color: #fff;
      border-radius: 3px;
      padding: 20px;
      position: relative;
    overflow-y: auto;
   }
   .center-box {
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-wrap: wrap;
      overflow-y: auto;
   }
   .tables {
      /* width: 800px; */
      margin-bottom: 16px;
   }
@@ -127,6 +124,11 @@
         <el-col :span="12" style="text-align: right;">
            <el-button size="small" type="primary" @click="sampleVisible=true">样品切换</el-button>
            <el-button size="small" type="primary" @click="taskVisible=true">任务切换</el-button>
        <el-button size="small" type="primary" @click="submit" v-show="state==1" :loading="submitLoading">提交</el-button>
        <!-- 复核 -->
        <el-button size="medium" type="primary" @click="upInsReview(1)" :loading="reviewLoading"
                  v-show="state>1">通过</el-button>
          <el-button size="medium" @click="upInsReview(0)" v-show="state>1">不通过</el-button>
            <el-button size="small" @click="$emit('goback')">返回</el-button>
         </el-col>
      </el-row>
@@ -169,11 +171,11 @@
                        <div class="content" :class="`content-h-${n.v.ht} content-v-${n.v.vt}`">
                           <template v-if="n.v.ps!=undefined && n.v.ps.value==='检验值'">
                              <el-input v-if="getInspectionValueType(n.i) == 1" class="table_input" v-model="n.v.v"
                                 :disabled="getInspectionItemType(n.i) == 1"
                                 :disabled="getInspectionItemType(n.i) == 1 || (n.u != userId && n.u != undefined && n.u != '')||state>1"
                                 @change="m=>changeInput(m,`${item.templateId}-${n.r}-${n.c}-${n.i}`)" />
                              <el-input v-else-if="getInspectionValueType(n.i) == 2" class="table_input" type="textarea"
                                 :autosize="{ minRows: 1}" v-model="n.v.v" />
                              <el-select v-else-if="getInspectionValueType(n.i) == 5" class="table_input" v-model="n.v.v">
                                 :autosize="{ minRows: 1}" v-model="n.v.v" :disabled="state>1" />
                              <el-select v-else-if="getInspectionValueType(n.i) == 5" class="table_input" v-model="n.v.v" :disabled="state>1">
                                 <el-option label="是" value="是"></el-option>
                                 <el-option label="否" value="否"></el-option>
                              </el-select>
@@ -181,7 +183,7 @@
                                 v-else-if="getInspectionValueType(n.i) == 4">/</span>
                              <el-button type="primary" icon="el-icon-edit" size="mini" circle
                                 v-if="getInspectionItemType(n.i) == 1" style="border: 0;margin-left: 2px;"
                                 @click="getSystemValue(n)">
                                 @click="getSystemValue(n)" :disabled="(n.u != userId && n.u != undefined && n.u != '')||state>1">
                              </el-button>
                           </template>
                           <template v-else-if="n.v.ps!=undefined && n.v.ps.value==='结论'">
@@ -190,12 +192,12 @@
                              <span v-else :style="`font-family:${n.v.ff} !important;`">待定</span>
                           </template>
                  <template v-else-if="n.v.ps!=undefined && n.v.ps.value==='设备'">
                              <el-select v-model="n.v.v" placeholder="请选择" @visible-change="e=>getEquipOptions(e,n.i)">
                              <el-select v-model="n.v.v" placeholder="请选择" @visible-change="e=>getEquipOptions(e,n.i)" :disabled="state>1">
                      <el-option
                        v-for="item in equipOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                        :value="item.label">
                      </el-option>
                    </el-select>
                           </template>
@@ -239,13 +241,25 @@
         <ValueTable class="value-table" ref="insOrderPlan" :url="$api.insOrderPlan.selectInsOrderPlanList"
            :componentData="componentData" :key="upIndex" />
      </el-drawer>
    <el-dialog title="检验复核" :visible.sync="reviewDia" width="400px">
         <div class="body" style="display: flex;" v-if="reviewDia">
            <div class="search_label" style="width: 120px;"><span class="required-span">* </span>不通过原因:</div>
            <div class="search_input">
               <el-input size="small" clearable v-model="noReason" type="textarea" :autosize="{ minRows: 3, maxRows: 5}"></el-input>
            </div>
         </div>
         <span slot="footer" class="dialog-footer">
            <el-button @click="reviewDia = false">取 消</el-button>
            <el-button type="primary" @click="handleReviewDia" :loading="reviewLoading">确 定</el-button>
         </span>
      </el-dialog>
   </div>
</template>
<script>
   import ValueTable from '../../tool/value-table.vue'
   export default {
      props: ['sonLaboratory', 'orderId'],
      props: ['sonLaboratory', 'orderId','state'],
      components: {
         ValueTable,
      },
@@ -253,6 +267,7 @@
         return {
            sampleVisible: false,
            taskVisible: false,
        submitLoading:false,
            searchForm: {
               sampleName: null,
               state: null
@@ -297,12 +312,17 @@
            currentKey: 1,
            comparisonList: [],
            excelMethodList: [],
        equipOptions:[]
        equipOptions:[],
            userId: 0,
        reviewLoading:false,
        reviewDia:false,
        noReason:''
         }
      },
      created() {
         this.componentData.entity.sonLaboratory = this.sonLaboratory;
         this.id = this.orderId;
         this.getUserInfo()
      },
      mounted() {
         this.getTypeDicts()
@@ -313,7 +333,8 @@
         id(val) {
            this.loading = true
            this.$axios.post(this.$api.insOrderPlan.doInsOrder, {
               id: val
               id: val,
          laboratory: this.sonLaboratory
            }).then(res => {
               this.insOrder = res.data.insOrder;
               this.urgentList.forEach(m => {
@@ -327,9 +348,9 @@
                  this.param[a.id] = {
                     insValue: [],
                     comValue: [],
                     resValue: [],
                     resValue: null,
              equipValue:null,
              intResult: null
              insResult: null
                  }
               })
               if (this.currentSample.index == undefined) this.currentSample['index'] = 1
@@ -343,13 +364,14 @@
      methods: {
         handleChangeSample(row, column, event) {
            this.currentSample = row;
            this.param = {}
            this.currentSample.insProduct.forEach(a => {
               this.param[a.id] = {
                  insValue: [],
                  comValue: [],
                  resValue: [],
                  resValue: null,
            equipValue:null,
            intResult: null
            insResult: null
               }
            })
            this.handleTableData()
@@ -428,26 +450,26 @@
            this.tableList.forEach(a => {
               let dels = []
               let ids = []
               a.template.forEach(b => {
                  if (b.v.ps != undefined && b.v.ps.value === '检验子项') {
                     let count = 0
                     for (let i in this.currentSample.insProduct) {
                        if (this.currentSample.insProduct[i].inspectionItemSubclass === b.v.v && this.currentSample
                           .insProduct[i].templateId === a.templateId) {
                           ids.push({
                              r: b.r,
                              id: this.currentSample.insProduct[i].id,
                              product: this.currentSample.insProduct[i]
                           })
                           break
                        }
                        count++
                     }
                     if (count === this.currentSample.insProduct.length) {
                        dels.push(b)
                     }
                  }
               })
          a.template.forEach(b => {
             if (b.v.ps != undefined && b.v.ps.value === '检验子项') {
                let count = 0
                for (let i in this.currentSample.insProduct) {
                   if (this.currentSample.insProduct[i].inspectionItemSubclass === b.v.v && this.currentSample
                      .insProduct[i].templateId === a.templateId) {
                      ids.push({
                         r: b.r,
                         id: this.currentSample.insProduct[i].id,
                         product: this.currentSample.insProduct[i]
                      })
                      break
                   }
                   count++
                }
                if (count === this.currentSample.insProduct.length) {
                   dels.push(b)
                }
             }
          })
               dels.forEach(del => {
                  for (let b = 0; b < a.template.length; b++) {
                     if (a.template[b].r === del.r) {
@@ -495,6 +517,7 @@
                  }
                  if (b.v.ps != undefined && b.v.ps.value === '检验值') {
                     b.v.v = ''
                     b.u = ''
                     this.param[b.i].insValue.push(b)
                  }
                  if (b.v.ps != undefined && b.v.ps.value === '计算值') {
@@ -509,10 +532,10 @@
                     b.v.v = ''
                     if (b.i === undefined) {
                        for (var c in this.param) {
                           this.param[c].resValue.push(b)
                           this.param[c].resValue = b
                        }
                     } else {
                        this.param[b.i].resValue.push(b)
                        this.param[b.i].resValue = b
                     }
                  }
            if (b.v.ps!=undefined&&b.v.ps.value==='结论'){
@@ -555,11 +578,29 @@
               })
               a.arr = arrs
            })
            /* this.currentSample.insProduct.forEach(a=>{
                for(var i=0;i<a.param.comValue.length;i++){
                    this.param[a.id].comValue[i].v.v = a.param.comValue[i].v.v
                }
            }) */
            this.currentSample.insProduct.forEach(a=>{
               try{
                  let comValue = JSON.parse(a.insProductResult.comValue)
                    for(var i=0;i<comValue.length;i++){
                        this.param[a.id].comValue[i].v.v = comValue[i].v
                    }
               }catch(e){}
               try{
                  let insValue = JSON.parse(a.insProductResult.insValue)
                     for(var i=0;i<insValue.length;i++){
                         this.param[a.id].insValue[i].v.v = insValue[i].v
                           this.param[a.id].insValue[i].u = insValue[i].u
                     }
               }catch(e){}
               try{
                  this.param[a.id].equipValue.v.v = a.insProductResult.equipValue
               }catch(e){}
               try{
                 this.param[a.id].resValue.v.v = a.lastValue
                 this.param[a.id].insResult.v.v = a.insResult
               }catch(e){
               }
            })
            this.handleExcelMethod()
         },
         changeInput(m, code) {
@@ -591,7 +632,7 @@
                                          break
                                       }
                                    }
                                    comValue[(tableCode + c.r)] = parseFloat(c.v.v)
                                    comValue[(tableCode + (c.r+1))] = parseFloat(c.v.v)
                                 }
                              }
                           })
@@ -625,19 +666,55 @@
                        } else {
                           item.v.v = 0
                        }
                        console.log(33333333333, this.param)
                        this.$axios.post(this.$api.insOrderPlan.saveInsContext, this.param, {
                           headers: {
                              'Content-Type': 'application/json'
                           }
                        }).then(res=>{
                           if(res.code==201){
                              this.$message.error('保存失败')
                              return
                           }
                           this.$message.success('已保存')
                        })
                     }
                  } else {
                     let comResult = 0;
                     switch (item.methodName) {
                        case 'AVERAGE':
                           let num = 0
                           for (var a in comValue) {
                              num += comValue[a]
                           }
                           comResult = num / Object.keys(comValue).length
                           break;
                        case 'SUM':
                           let sum = 0
                           for (var a in comValue) {
                              sum += comValue[a]
                           }
                           comResult = sum / Object.keys(comValue).length
                           comResult = sum
                           break;
                        default:
                  let valueList = [];
                  item.valueList.forEach(a => {
                    valueList.push({
                      name:`${this.comparisonList[a.c].label}${a.r+1}`,
                      value:0,
                    })
                  })
                  for (var a in comValue) {
                    valueList.forEach(b => {
                      if(b.name==a){
                        b.value = comValue[a]
                      }
                    })
                           }
                  let str = item.v.f.replace(/=/g,' ');
                  valueList.forEach(b => {
                    str = str.replace(b.name,b.value)
                  })
                  comResult = eval(str)
                           break;
                     }
                     list.forEach(a => {
@@ -685,9 +762,9 @@
                     item.valueList = valueList;
                  } else {
                     valueList = []
                     let regex = /[=\+\-\*\%\(\)\s]/g
                     let regex = /[=\+\-\*\%\(\)\/\s]/g
                     let mode = item.v.f.replace(regex, ' ').split(' ');
                     mode.filter(m => m).forEach(m => {
                     mode.filter(m => m&&!Number(m)).forEach(m => {
                        let r = m.split('')[1] - 1
                        let c = this.comparisonList.find(j => j.label == m.split('')[0]).value
                        valueList.push({
@@ -723,6 +800,14 @@
            }
         },
         getSystemValue(n) {
            try{
               if(this.param[n.i].equipValue.v.v == null||this.param[n.i].equipValue.v.v == ''){
                  this.$message.error('请先选择采集的设备')
                  return
               }
            }catch(e){
               this.$message.error('找不到设备内容')
            }
            this.$message.error('采集失败【已开放手动方式】')
            for (var a in this.currentSample.insProduct) {
               if (this.currentSample.insProduct[a].id == n.i) {
@@ -732,7 +817,7 @@
         },
      getEquipOptions(e,id){
        if(e){
          let category = this.tableList.find(m=>m.id==id).deviceGroup
          let category = this.currentSample.insProduct.find(m=>m.id==id).deviceGroup
          this.$axios.post(this.$api.deviceScope.selectDeviceByCategory, {category}).then(res => {
            if (res.code === 200 && res.data) {
              this.equipOptions = res.data.map(m=>{
@@ -745,6 +830,74 @@
            console.error(error)
          })
        }
      },
         getUserInfo() {
            this.$axios.get(this.$api.user.getUserInfo).then(res => {
               this.userId = res.data.id
            })
         },
      // 复核
      upInsReview(e){
        if(e==1){
          // 通过
          this.reviewLoading = true;
          this.$axios.post(this.$api.insOrderPlan.verifyPlan, {
            orderId:this.orderId,
            type:1,
            laboratory:this.sonLaboratory,
            tell:null
          }).then(res => {
            if (res.code === 200) {
              this.$message.success("操作成功")
              this.$emit('goback')
            }
            this.reviewLoading = false;
          }).catch(error => {
            console.error(error)
            this.reviewLoading = false;
          })
        }else{
          // 不通过
          this.reviewDia = true;
        }
      },
      handleReviewDia(){
        if(this.noReason){
          this.reviewLoading = true;
          this.$axios.post(this.$api.insOrderPlan.verifyPlan, {
            orderId:this.orderId,
            type:0,
            laboratory:this.sonLaboratory,
            tell:this.noReason
          }).then(res => {
            if (res.code === 200) {
              this.$message.success("操作成功")
              this.$emit('goback')
            }
            this.reviewLoading = false;
          }).catch(error => {
            console.error(error)
            this.reviewLoading = false;
          })
        }else{
          this.$message.error('未输入不通过原因')
        }
      },
      submit(){
        this.submitLoading = true;
        this.$axios.post(this.$api.insOrderPlan.submitPlan, {
            orderId:this.orderId,
            laboratory:this.sonLaboratory,
        }).then(res => {
          if (res.code === 200) {
            this.$message.success("操作成功")
            this.$emit('goback')
          }
          this.submitLoading = false;
        }).catch(error => {
          console.error(error)
          this.submitLoading = false;
        })
      }
     }
}