licp
2024-03-21 890cd9ab8cfbd642c7240413a2f2f51b7f6f0fa5
src/components/do/b1-ins-order/add.vue
@@ -211,7 +211,7 @@
            border @selection-change="selectSample" highlight-current-row @row-click="rowClick" style="margin-top: 10px;">
            <el-table-column type="selection" width="60"></el-table-column>
            <el-table-column type="index" label="序号" width="65" align="center"></el-table-column>
            <el-table-column prop="sample" label="样品名称" align="center" show-overflow-tooltip min-width="100">
            <el-table-column prop="sample" label="样品名称" align="center" min-width="100">
               <template slot-scope="scope">
                  <el-input size="small" v-model="scope.row.sample" clearable></el-input>
               </template>
@@ -221,22 +221,22 @@
                  <el-input size="small" v-model="scope.row.sampleCode" clearable placeholder="不填写则系统自动生成"></el-input>
               </template>
            </el-table-column>
            <!-- <el-table-column prop="factory" label="工厂" align="center" show-overflow-tooltip min-width="100">
            <!-- <el-table-column prop="factory" label="工厂" align="center" min-width="100">
            </el-table-column>
            <el-table-column prop="laboratory" label="实验室" align="center" show-overflow-tooltip min-width="100">
            <el-table-column prop="laboratory" label="实验室" align="center" min-width="100">
            </el-table-column>
            <el-table-column prop="sampleType" label="样品类型" align="center" show-overflow-tooltip min-width="100">
            <el-table-column prop="sampleType" label="样品类型" align="center" min-width="100">
            </el-table-column> -->
            <el-table-column prop="model" label="样品型号" align="center" show-overflow-tooltip min-width="100">
            <el-table-column prop="model" label="样品型号" align="center" min-width="100">
               <template slot-scope="scope">
                  <el-select v-model="scope.row.model" filterable allow-create default-first-option placeholder="样品型号"
                     size="small">
                     size="small" @change="handleChangeModel">
                     <el-option v-for="item in models" :key="item.value" :label="item.label" :value="item.value">
                     </el-option>
                  </el-select>
               </template>
            </el-table-column>
            <el-table-column prop="standardMethodListId" label="检验标准" align="center" show-overflow-tooltip min-width="100">
            <el-table-column prop="standardMethodListId" label="检验标准" align="center" min-width="100">
               <template slot-scope="scope">
                  <el-select v-model="scope.row.method" :disabled="scope.row.model==null" filterable placeholder="检验标准" size="small"
                     :loading="methodLoad" @change="(value)=>methodChange(value, scope.row)" @focus="methodFocus">
@@ -245,14 +245,14 @@
                  </el-select>
               </template>
            </el-table-column>
            <el-table-column prop="unit" label="单位" align="center" show-overflow-tooltip min-width="100">
            <el-table-column prop="unit" label="单位" align="center" min-width="100">
               <template slot-scope="scope">
                  <el-select v-model="scope.row.unit" clearable size="small" style="width: 100%;">
                     <el-option v-for="(a, i) in units" :key="i" :label="a.label" :value="a.value"></el-option>
                  </el-select>
               </template>
            </el-table-column>
            <el-table-column prop="isLeave" label="是否留样" align="center" show-overflow-tooltip min-width="100">
            <el-table-column prop="isLeave" label="是否留样" align="center" min-width="100">
               <template slot-scope="scope">
                  <el-select v-model="scope.row.isLeave" size="small">
                     <el-option label="留样" :value="1"></el-option>
@@ -303,7 +303,7 @@
            <el-table-column prop="ask" label="要求值" min-width="220px">
               <template slot-scope="scope">
                  <el-input size="small" placeholder="要求值" v-model="scope.row.ask" clearable type="textarea"
                     :autosize="{ minRows: 1, maxRows: 3}"></el-input>
                     :autosize="{ minRows: 1, maxRows: 3}" @change="e=>requestChange(e,scope.row)"></el-input>
               </template>
            </el-table-column>
         </el-table>
@@ -576,9 +576,7 @@
         this.selectInsOrderTemplate()
         this.getAuthorizedPerson();
         this.selectEnumByCategoryForUnit()
         if (this.active == 1) {
            // 下单流程
         } else {
         if (this.active != 1){
            // 查看/审核流程
            // 请求接口,回显数据
            this.$axios.post(this.$api.insOrder.getInsOrder, {
@@ -637,8 +635,16 @@
               this.$message.error('未选择紧急程度')
            } else if (this.sampleList.length < 1) {
               this.$message.error('请添加一个样品')
            } else if (!this.sampleList.every(m => m.sampleCode)) {
               this.$message.error('输入样品编号')
            } else if (!this.sampleList.every(m => m.sample)) {
               this.$message.error('输入样品名称')
            }else if (!this.sampleList.every(m => m.model)) {
               this.$message.error('输入样品型号')
            }else if (!this.sampleList.every(m => m.method)) {
               this.$message.error('选择检验标准')
            }else if (!this.sampleList.every(m => m.unit)) {
               this.$message.error('输入单位')
            }else if (!this.sampleList.every(m => m.isLeave)) {
               this.$message.error('是否留样')
            } else {
               this.saveLoad = true
               this.$axios.post(this.$api.insOrder.addInsOrder, {
@@ -652,20 +658,7 @@
                  this.saveLoad = false
                  if (res.code == 201) return
                  this.$message.success('已提交')
                  // 如果紧急程度为紧急,需要直接下发人员
                  if (this.addObj.type == 2) {
                     this.issuedDialogVisible = true;
                     this.$axios.post(this.$api.insOrder.selectOrderManDay, {
                        id: res.data
                     }).then(ress => {
                        // TODO 需要再确认一下返回值
                        this.distributeData.orderId = res.data
                        // this.distributeData.sampleId = res.data.sampleId
                        this.distributeData.appointed = ress.data
                     })
                  } else {
                     this.$parent.playOrder(0)
                  }
            this.$parent.playOrder(0)
               })
            }
         },
@@ -682,7 +675,18 @@
               this.saveLoad = false
               if (res.code == 201) return
               this.$message.success('提交成功')
               this.$parent.playOrder(0)
               // 如果紧急程度为紧急,需要直接下发人员
          if (this.addObj.type == 2) {
                     this.issuedDialogVisible = true;
                     this.$axios.post(this.$api.insOrder.selectOrderManDay, {
                        id: this.currentId
                     }).then(ress => {
                        this.distributeData.orderId = this.currentId
                        this.distributeData.appointed = ress.data
                     })
                  } else {
                     this.$parent.playOrder(0)
                  }
            })
         },
         // 下发
@@ -698,7 +702,6 @@
            this.upLoad = true;
            this.$axios.post(this.$api.insOrder.upInsOrder, {
               orderId: this.distributeData.orderId,
               sampleId: this.distributeData.sampleId,
               appointed: this.distributeData.appointed,
               userId: this.distributeData.userId
            }).then(res => {
@@ -793,7 +796,7 @@
               this.count++
            }
            this.$refs.sampleTable.doLayout()
            this.selectsStandardMethodByFLSSM()
            // this.selectsStandardMethodByFLSSM()
         },
         selectsStandardMethodByFLSSM() {
            this.methodLoad = true
@@ -801,7 +804,18 @@
               tree: this.selectTree
            }).then(res => {
               this.methodLoad = false
               this.methods = res.data.standardMethodList
          if(res.data.standardMethodList.length==0&&this.selectTree.split('-').length==5){
            let arr = this.selectTree.split('-')
            let arr0 = arr.slice(0,arr.length-1)
            let selectTree = arr0.join('-').substring(0, arr0.join('-').length - 1)
            this.$axios.post(this.$api.standardTree.selectsStandardMethodByFLSSM, {
              tree: selectTree
            }).then(ress => {
              this.methods = ress.data.standardMethodList
            })
          }else{
            this.methods = res.data.standardMethodList
          }
            })
         },
         addStandardTree() {
@@ -906,6 +920,17 @@
         },
         upProductSelect(selection, row) {
            row.state = row.state == 1 ? 0 : 1
        this.sampleList.map(item=>{
          if(this.sampleIds.indexOf(item.id)>-1){
            item.insProduct.map(m=>{
              if(m.id==row.id){
                m.state = row.state;
              }
              return m;
            })
          }
          return item
        })
         },
         tableRowClassName({
            row,
@@ -988,8 +1013,7 @@
               this.units = res.data
            })
         },
         methodChange(val) {
            this.$refs.sampleTable.doLayout()
         methodChange(val, row) {
            this.getProductLoad = true
            this.$axios.post(this.$api.standardTree.selectStandardProductList, {
               model: this.addObj.model,
@@ -1002,14 +1026,7 @@
               res.data.forEach(a => {
                  a.state = 1
               })
               this.sampleIds.forEach(a => {
                  for (var b in this.sampleList) {
                     if (this.sampleList[b].id == a) {
                        this.sampleList[b].standardMethodListId = val
                        this.sampleList[b].insProduct = this.HaveJson(res.data)
                     }
                  }
               })
               row.insProduct = this.HaveJson(res.data)
               this.getProductLoad = false
               this.productList = []
               this.$refs.sampleTable.setCurrentRow()
@@ -1017,7 +1034,31 @@
         },
         methodFocus(){
            this.selectsStandardMethodByFLSSM()
         }
         },
      handleChangeModel(e){
        let num = this.selectTree.split('-').length;
        if(num==4){
          this.selectTree = this.selectTree + ' - '+ e
        }else{
          let arr = this.selectTree.split('-')
          let arr0 = arr.slice(0,arr.length-1)
          this.selectTree = arr0.join('-')+ '- '+ e
        }
      },
      // 要求值变化时
      requestChange(e,row){
        this.sampleList.map(item=>{
          if(this.sampleIds.indexOf(item.id)>-1){
            item.insProduct.map(m=>{
              if(m.id==row.id){
                m.ask = e;
              }
              return m;
            })
          }
          return item
        })
      }
      }
   }
</script>
</script>