lxp
2024-08-12 14b15cb429be4c2cf9d7372afcd3bf1e6c53d6af
src/components/do/b1-ins-order/fiberoptic-config.vue
@@ -35,12 +35,12 @@
              </div>
              <div class="search-item" style="margin-right: 10px;">
                <label style="width: 100px">每根管抽检标准量</label>
                <el-input v-model="packageInfo.standNum" placeholder="请输入" size="small" @blur="addStandNum" :disabled="active!=1" style="width:100px"></el-input>
                <el-input v-model="packageInfo.standNum" placeholder="请输入" size="small" @blur="addStandNum" :disabled="packageInfo.radio===0||active!=1" style="width:100px"></el-input>
              </div>
              <div class="search-item">
                <label style="width: 100px">每根管抽检检测量</label>
                <el-input v-model="packageInfo.testNum" placeholder="请输入" size="small" @blur="addTestNum"
                  :disabled="packageInfo.radio===0||active!=1" style="width:100px"></el-input>
                  :disabled="packageInfo.radio===0||active!=1" style="width:70px"></el-input>
              </div>
            </div>
            <el-table ref="table0" :data="bushing" tooltip-effect="dark" style="width: 100%" height="203px" size="small"
@@ -95,8 +95,14 @@
              </el-table-column> -->
              <el-table-column prop="ask" label="检测要求" show-overflow-tooltip width="200px">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.ask" placeholder="请输入" size="small" :disabled="active!=1" v-if="!isAskOnlyRead"></el-input>
                  <el-input v-model="scope.row.ask" placeholder="请输入" size="small" :disabled="active!=1" v-if="!isAskOnlyRead" @change="changeASk(scope.row,'ask')"></el-input>
                  <span v-else>{{ scope.row.ask }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="tell" label="要求描述" show-overflow-tooltip width="150">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.tell" placeholder="请输入" size="small" :disabled="active!=1" v-if="!isAskOnlyRead" @change="changeASk(scope.row)"></el-input>
                  <span v-else>{{ scope.row.tell }}</span>
                </template>
              </el-table-column>
            </el-table>
@@ -152,8 +158,11 @@
              </div>
            </div>
            <el-table ref="table2" :data="fibersList" tooltip-effect="dark" style="width: 100%" height="270px"
            <!-- <el-table ref="table2" :data="fibersList" tooltip-effect="dark" style="width: 100%" height="270px"
              size="small" @selection-change="handleSelectionChange" highlight-current-row @row-click="(row, column, event)=>rowClickFiber(row, column, event,1)"
              :header-cell-class-name="setClassName0"> -->
              <el-table ref="table2" :data="fibersList" tooltip-effect="dark" style="width: 100%" height="270px"
              size="small" @selection-change="handleSelectionChange" highlight-current-row
              :header-cell-class-name="setClassName0">
              <el-table-column
              type="selection"
@@ -227,9 +236,12 @@
                </el-select>
              </div>
            </div>
            <el-table ref="table3" :data="fiberList" tooltip-effect="dark" style="width: 100%" height="270px"
            <!-- <el-table ref="table3" :data="fiberList" tooltip-effect="dark" style="width: 100%" height="270px"
              size="small" highlight-current-row @selection-change="handleSelectionChange4"
              @row-click="(row, column, event)=>rowClickFiber(row, column, event,0)"
              :header-cell-class-name="setClassName0"> -->
              <el-table ref="table3" :data="fiberList" tooltip-effect="dark" style="width: 100%" height="270px"
              size="small" highlight-current-row @selection-change="handleSelectionChange4"
              :header-cell-class-name="setClassName0">
              <el-table-column
              type="selection"
@@ -506,7 +518,7 @@
        this.detectionSelect = val
        // 赋值检测项信息 光纤带
        if(this.detectionItems.type == 1) {
          this.multiFiberList.forEach(item => {
            this.multiFiberList.forEach(item => {
            this.fibersList.forEach(a => {
              if(a.ident == item.ident){
                a.productList  =  []
@@ -514,8 +526,10 @@
              }
            })
          })
      }
      console.log(this.fibersList);
      if(this.detectionItems.type == 0) {
        // 赋值检测项信息 光纤
        this.selectFiberList.forEach(item => {
@@ -526,8 +540,9 @@
              }
            })
          })
          if(this.multiFiberList.length == 1) {
          // 选择的时候就将fiberList的值赋值给对应的fiberList
          setTimeout(() => {
            if(this.multiFiberList.length > 0) {
            this.multiFiberList.forEach(item => {
            this.fibersList.forEach(a => {
              if(a.ident == item.ident){
@@ -535,11 +550,8 @@
              }
            })
          })
          }else if(this.multiFiberList.length > 1) {
            this.fibersList.forEach(item => {
              item.fiber = this.fiberList
            })
          }
          },100)
        }
      },
      handleSelectionChange4(val){
@@ -547,6 +559,143 @@
        if(val != 0) {
          this.rowClickFiber(val[val.length-1],null,null,0)
        }
      },
      changeASk(row,type) {
        if(type == 'ask') {
          // 如果检测要求含有正负号
          if(row.tell.indexOf('±') != -1) {
            let left = row.tell.substring(0,row.tell.indexOf('±'))
            let right = row.tell.substring(row.tell.indexOf('±')+1)
            // 如果可以转化为数值
           if(!isNaN(Number(left)) && !isNaN(Number(right))) {
              if(row.ask.indexOf('-') != -1) {
                  let left1 = row.ask.substring(0,row.ask.indexOf('-'))
                  let right1 = row.ask.substring(row.ask.indexOf('-')+1)
                  if(Number(left1) != (Number(left) - Number(right)) || Number(right1) != (Number(left) + Number(right))) {
                    this.$message.error('检测要求不符合要求描述')
                    row.ask = (Number(left) - Number(right)) + '-' + (Number(left) + Number(right))
                  }
              }else {
                this.$message.error('检测要求不符合规范')
                row.ask = left + '-' + right
                return
              }
           }
           // 如果要求描述左边不能转化为数值
           else if(isNaN(Number(left)) && !isNaN(Number(right))) {
            const regex = /[~-]/
            const match = left.match(regex)
            // 左边含有 - ~ 符号
            if(match) {
              let newLeft = '';
              if(left.includes('(')) {
               newLeft = left.replace('(','(')
              }
              if(left.includes(')')) {
                newLeft = newLeft.replace(')',')')
              }
              const regexTwo = /\((\d+(\.\d+)?)([~-])(\d+(\.\d+)?)\)/;
              const matchTwo = newLeft.match(regexTwo);
              let leftTwo = Number(matchTwo[1]) - Number(right)
              let rightTwo = Number(matchTwo[4]) + Number(right)
              console.log(matchTwo);
              console.log(leftTwo,rightTwo);
              console.log(row.ask.indexOf('-'));
              if(row.ask.indexOf('-') != -1) {
                  let left1 = row.ask.substring(0,row.ask.indexOf('-'))
                  let right1 = row.ask.substring(row.ask.indexOf('-')+1)
                  if(Number(left1) != leftTwo || Number(right1) != rightTwo) {
                    this.$message.error('检测要求不符合要求描述')
                    row.ask = leftTwo + '-' + rightTwo
                  }
              }else {
                this.$message.error('检测要求不符合规范')
                row.ask = leftTwo + '-' + rightTwo
                return
              }
            }
           }
          }
          // 如果检测要求含有≤ < ≥ > 符号
          const regex = /[≤<≥>]/
          const match = row.tell.match(regex)
          if(match) {
            // 符号不一致
            if( row.ask.indexOf(match[0]) != 0) {
                this.$message.error('检测要求不符合要求描述')
                row.ask = match[0]
                return
              }else {
                // 符号一致
                const regex = new RegExp(`${match[0]}(\\d+(\\.\\d+)?)`, 'g')
                const matchTow = row.tell.match(regex);
              let right =  Number(matchTow[0].split(match[0])[1])
              let left = row.ask.substring(row.ask.indexOf(match[0])+1)
              if(Number(left) != Number(right)) {
                this.$message.error('检测要求不符合要求描述')
                row.ask = match[0] + right
              }
              }
            }
            // 如果要求描述含有范围
            const regexTwo = /[~-]/
            const matchTwo = row.tell.match(regexTwo)
            const matchAsk = row.ask.match(regexTwo)
            if(matchTwo) {
              let left = row.tell.substring(0,row.tell.indexOf(matchTwo[0]))
              let right = row.tell.substring(row.tell.indexOf(matchTwo[0])+1)
              if(!isNaN(Number(left)) && !isNaN(Number(right))) {
                let leftAsk = row.ask.substring(0,row.ask.indexOf(matchAsk[0]))
                let rightAsk = row.ask.substring(row.ask.indexOf(matchAsk[0])+1)
                if(Number(leftAsk) != Number(left) || Number(rightAsk) != Number(right)) {
                  this.$message.error('检测要求不符合要求描述')
                  row.ask = left + '-' + right
                }
              }
            }
          }
        // 先勾选的情况下
          this.detectionSelect.forEach(item => {
            if(item.id == row.id) {
              item.ask = row.ask
              item.tell = row.tell
              // 光纤 0  光纤带 1
            if(item.isFibers == 0) {
              this.selectFiberList.forEach(a => {
                this.fiberList.forEach(b => {
                  if(b.ident == a.ident){
                    b.productList.forEach(item => {
                      if(item.id == row.id) {
                        item.ask = row.ask
                        item.tell = row.tell
                      }
                    })
                  }
                })
              })
            }
            if(item.isFibers == 1) {
              this.multiFiberList.forEach(a => {
                this.fibersList.forEach(b => {
                  if(b.ident == a.ident){
                    b.productList.forEach(item => {
                      if(item.id == row.id) {
                        item.ask = row.ask
                        item.tell = row.tell
                      }
                    })
                  }
                })
              })
            }
            }
          })
      },
      outConfig() {
        this.$parent.configShow = false
@@ -575,6 +724,11 @@
      },
      // 套管标准量赋值
      addStandNum() {
        if(this.packageInfo.testNum > this.packageInfo.standNum) {
          this.$message.error('检测量不能大于标准量')
          this.packageInfo.testNum = this.packageInfo.standNum
        }
        if(this.selectBushing.length > 0) {
          this.bushing.forEach(item => {
          this.selectBushing.forEach(a => {
@@ -606,24 +760,32 @@
        this.fiberList = []
        this.fibersList = []
        this.detectionItems = []
        // 页面是否含有光纤带
        if(this.packageInfo.ismiers) {
          // 全检
          if (this.packageInfo.radio == 0) {
            if(this.packageInfo.standNum == null || this.packageInfo.standNum == '') {
          this.$message.error('请先输入标准量')
          return
        }
          // 根据标准量赋值检测量
          if(parseInt(this.packageInfo.standNum) > 0 ) {
            // 给光纤带赋值
            this.packageInfo.testNum = this.packageInfo.standNum
            this.selectBushing = this.bushing
            // 给光纤带赋值
            this.bushing.forEach(item => {
                item.testNum = this.packageInfo.testNum
                item.standNum = this.packageInfo.standNum
                this.$refs.table0.toggleRowSelection(item, true)
              })
            this.addFibers()
            this.multiFiberList = this.fibersList
            // 默认勾选
            setTimeout(() => {
              this.selectBushing.forEach(item =>{
              let rowToSelect =  this.bushing.find(a => a.ident == item.ident)
              this.$refs.table0.toggleRowSelection(rowToSelect, true)
              })
              // this.selectBushing.forEach(item =>{
              // let rowToSelect =  this.bushing.find(a => a.ident == item.ident)
              // this.$refs.table0.toggleRowSelection(rowToSelect, true)
              // })
              this.multiFiberList.forEach(item =>{
              let rowToSelect =  this.fibersList.find(a => a.ident == item.ident)
@@ -634,15 +796,29 @@
      }
        }else {
          if(this.packageInfo.radio == 0) {
            if(this.packageInfo.standNum == null || this.packageInfo.standNum == '') {
          this.$message.error('请先输入标准量')
          return
        }
            if(parseInt(this.packageInfo.standNum) > 0 ) {
              this.packageInfo.testNum = this.packageInfo.standNum
            this.packageInfo.testNum = this.packageInfo.standNum
              this.bushing.forEach(item => {
                item.testNum = this.packageInfo.testNum
                item.standNum = this.packageInfo.standNum
                this.$refs.table0.toggleRowSelection(item, true)
              })
              console.log(this.bushing);
              this.selectBushing = this.bushing
              this.addFiber()
              // 默认勾选
            setTimeout(() => {
              this.selectBushing.forEach(item =>{
              let rowToSelect =  this.bushing.find(a => a.ident == item.ident)
              this.$refs.table0.toggleRowSelection(rowToSelect, true)
              // this.selectBushing.forEach(item =>{
              // let rowToSelect =  this.bushing.find(a => a.ident == item.ident)
              // this.$refs.table0.toggleRowSelection(rowToSelect, true)
              // })
              this.fiberList.forEach(item =>{
                this.$refs.table3.toggleRowSelection(item, true)
              })
            }, 200)
            }
@@ -791,17 +967,7 @@
            this.$message.error('请选择数据')
            return
          }
          this.selectFiberList.forEach(item => {
            this.fiberList.forEach(a => {
              if(a.ident == item.ident){
                a.model = this.mireModel.split(' - ')[1] // 光纤规格
                a.noSplitModel = this.mireModel // 光纤规格
                if(this.mireStandards != null) {
                  a.standard = this.mireStandards.find(a => a.id == this.mireStandard).code  // 参考标准
                }
              }
            })
          })
         if (val === null || val === '') return
         if(this.mireStandards == null ) return
        this.$axios.post(this.$api.standardTree.selectStandardProductList, {
@@ -822,6 +988,18 @@
          this.detectionType = 0
           this.$set(this.detectionItems,'type',0)
          }
          this.mireStandards.find(a => a.id == val).code == '委托要求'?this.isAskOnlyRead = false:this.isAskOnlyRead = true
          this.selectFiberList.forEach(item => {
            this.fiberList.forEach(a => {
              if(a.ident == item.ident){
                a.model = this.mireModel.split(' - ')[1] // 光纤规格
                a.noSplitModel = this.mireModel // 光纤规格
                if(this.mireStandards != null) {
                  a.standard = this.mireStandards.find(a => a.id == this.mireStandard).code  // 参考标准
                }
              }
            })
          })
        })
      },
@@ -871,6 +1049,8 @@
            this.detectionItems = res.data
            this.detectionType = 1
            this.$set(this.detectionItems,'type',1)
            // 判断是否为委托要求
            this.miresStandards.find(a => a.id == val).code == '委托要求'?this.isAskOnlyRead = false:this.isAskOnlyRead = true
          }
          // 给选中的光纤带赋值
@@ -1184,6 +1364,21 @@
          // 将获取的检测项信息赋值
          this.detectionItems = []
          if(res.data != null && res.data.length != 0){
            res.data.forEach(a => {
              this.$set(a,'isFibers',1)
            })
            // 判断是否为委托要求
            this.miresStandards.find(a => a.id == this.miresStandard).code == '委托要求'?this.isAskOnlyRead = false:this.isAskOnlyRead = true
            if(!this.isAskOnlyRead){
              row.productList.forEach(a => {
                res.data.forEach(b => {
                  if(a.id == b.id){
                    b.ask = a.ask
                    b.tell = a.tell
                  }
                })
              })
            }
            this.detectionItems = res.data
            this.detectionType = 1
            this.$set(this.detectionItems,'type',1)
@@ -1200,7 +1395,7 @@
            }
          }
        })
        },1000)
        },500)
      }else if(type == 0) {
        if((row.noSplitModel == null || row.noSplitModel == '') && (row.standard == null || row.standard == '')){
            this.detectionItems = []
@@ -1227,10 +1422,24 @@
          if(res.data != null && res.data.length != 0){
           res.data.forEach(a => {
            a.state = 0
            this.$set(a,'isFibers',0)
          })
          // 判断是否为委托要求
          this.mireStandards.find(a => a.id == this.mireStandard).code == '委托要求'?this.isAskOnlyRead = false:this.isAskOnlyRead = true
          if(!this.isAskOnlyRead){
            row.productList.forEach(a => {
              res.data.forEach(b => {
                if(a.id == b.id){
                  b.ask = a.ask
                  b.tell = a.tell
                }
              })
            })
          }
          this.detectionItems = res.data
          this.detectionType = 0
          this.$set(this.detectionItems,'type',0)
          if (row.productList != null && row.productList.length > 0) {
            let product =  JSON.parse(JSON.stringify(row.productList))
@@ -1245,7 +1454,7 @@
            }
          }
        })
        },1000);
        },500);
      }
    },
      toggleSelection(row) {
@@ -1456,6 +1665,208 @@
        // this.$message.success('已保存')
        // this.$emit('saveFiberopticConfig')
        let flag = true
        let flags = true
        // 光纤检测项信息校验
        this.fiberList.forEach(item=>{
          if(item.productList.length > 0){
            item.productList.forEach(row=>{
              // 如果检测要求含有正负号
          if(row.tell.indexOf('±') != -1) {
            let left = row.tell.substring(0,row.tell.indexOf('±'))
            let right = row.tell.substring(row.tell.indexOf('±')+1)
            // 如果可以转化为数值
           if(!isNaN(Number(left)) && !isNaN(Number(right))) {
              if(row.ask.indexOf('-') != -1) {
                  let left1 = row.ask.substring(0,row.ask.indexOf('-'))
                  let right1 = row.ask.substring(row.ask.indexOf('-')+1)
                  if(Number(left1) != (Number(left) - Number(right)) || Number(right1) != (Number(left) + Number(right))) {
                    // this.$message.error('11111')
                    flag = false
                  }
              }else {
                // this.$message.error('2222')
                flag = false
                return
              }
           }
           // 如果要求描述左边不能转化为数值
           else if(isNaN(Number(left)) && !isNaN(Number(right))) {
            const regex = /[~-]/
            const match = left.match(regex)
            // 左边含有 - ~ 符号
            if(match) {
              let newLeft = '';
              if(left.includes('(')) {
               newLeft = left.replace('(','(')
              }
              if(left.includes(')')) {
                newLeft = newLeft.replace(')',')')
              }
              const regexTwo = /\((\d+(\.\d+)?)([~-])(\d+(\.\d+)?)\)/;
              const matchTwo = newLeft.match(regexTwo);
              let leftTwo = Number(matchTwo[1]) - Number(right)
              let rightTwo = Number(matchTwo[4]) + Number(right)
              if(row.ask.indexOf('-') != -1) {
                  let left1 = row.ask.substring(0,row.ask.indexOf('-'))
                  let right1 = row.ask.substring(row.ask.indexOf('-')+1)
                  if(Number(left1) != leftTwo || Number(right1) != rightTwo) {
                    // this.$message.error('33333')
                    flag = false
                  }
              }else {
                // this.$message.error('44444')
                flag = false
                return
              }
            }
           }
          }
          // 如果检测要求含有≤ < ≥ > 符号
          const regex = /[≤<≥>]/
          const match = row.tell.match(regex)
          if(match) {
            // 符号不一致
            if( row.ask.indexOf(match[0]) != 0) {
                // this.$message.error('555555')
                flag = false
                return
              }else {
                // 符号一致
                const regex = new RegExp(`${match[0]}(\\d+(\\.\\d+)?)`, 'g')
                const matchTow = row.tell.match(regex);
              let right =  Number(matchTow[0].split(match[0])[1])
              let left = row.ask.substring(row.ask.indexOf(match[0])+1)
              if(Number(left) != Number(right)) {
                // this.$message.error('666666')
                flag = false
              }
              }
            }
            // 如果要求描述含有范围
            const regexTwo = /[~-]/
            const matchTwo = row.tell.match(regexTwo)
            const matchAsk = row.ask.match(regexTwo)
            if(matchTwo) {
              let left = row.tell.substring(0,row.tell.indexOf(matchTwo[0]))
              let right = row.tell.substring(row.tell.indexOf(matchTwo[0])+1)
              if(!isNaN(Number(left)) && !isNaN(Number(right))) {
                let leftAsk = row.ask.substring(0,row.ask.indexOf(matchAsk[0]))
                let rightAsk = row.ask.substring(row.ask.indexOf(matchAsk[0])+1)
                if(Number(leftAsk) != Number(left) || Number(rightAsk) != Number(right)) {
                  // this.$message.error('777777')
                  flag = false
                }
              }
            }
            })
          }
        })
        // 光纤带检测项信息校验
        this.fibersList.forEach(item=>{
          if(item.productList.length > 0){
            item.productList.forEach(row=>{
              // 如果检测要求含有正负号
          if(row.tell.indexOf('±') != -1) {
            let left = row.tell.substring(0,row.tell.indexOf('±'))
            let right = row.tell.substring(row.tell.indexOf('±')+1)
            // 如果可以转化为数值
           if(!isNaN(Number(left)) && !isNaN(Number(right))) {
              if(row.ask.indexOf('-') != -1) {
                  let left1 = row.ask.substring(0,row.ask.indexOf('-'))
                  let right1 = row.ask.substring(row.ask.indexOf('-')+1)
                  if(Number(left1) != (Number(left) - Number(right)) || Number(right1) != (Number(left) + Number(right))) {
                    // this.$message.error('11111')
                    flags = false
                  }
              }else {
                // this.$message.error('2222')
                flags = false
                return
              }
           }
           // 如果要求描述左边不能转化为数值
           else if(isNaN(Number(left)) && !isNaN(Number(right))) {
            const regex = /[~-]/
            const match = left.match(regex)
            // 左边含有 - ~ 符号
            if(match) {
              let newLeft = '';
              if(left.includes('(')) {
               newLeft = left.replace('(','(')
              }
              if(left.includes(')')) {
                newLeft = newLeft.replace(')',')')
              }
              const regexTwo = /\((\d+(\.\d+)?)([~-])(\d+(\.\d+)?)\)/;
              const matchTwo = newLeft.match(regexTwo);
              let leftTwo = Number(matchTwo[1]) - Number(right)
              let rightTwo = Number(matchTwo[4]) + Number(right)
              if(row.ask.indexOf('-') != -1) {
                  let left1 = row.ask.substring(0,row.ask.indexOf('-'))
                  let right1 = row.ask.substring(row.ask.indexOf('-')+1)
                  if(Number(left1) != leftTwo || Number(right1) != rightTwo) {
                    // this.$message.error('33333')
                    flags = false
                  }
              }else {
                // this.$message.error('44444')
                flags = false
                return
              }
            }
           }
          }
          // 如果检测要求含有≤ < ≥ > 符号
          const regex = /[≤<≥>]/
          const match = row.tell.match(regex)
          if(match) {
            // 符号不一致
            if( row.ask.indexOf(match[0]) != 0) {
                // this.$message.error('555555')
                flags = false
                return
              }else {
                // 符号一致
                const regex = new RegExp(`${match[0]}(\\d+(\\.\\d+)?)`, 'g')
                const matchTow = row.tell.match(regex);
              let right =  Number(matchTow[0].split(match[0])[1])
              let left = row.ask.substring(row.ask.indexOf(match[0])+1)
              if(Number(left) != Number(right)) {
                // this.$message.error('666666')
                flags = false
              }
              }
            }
            // 如果要求描述含有范围
            const regexTwo = /[~-]/
            const matchTwo = row.tell.match(regexTwo)
            const matchAsk = row.ask.match(regexTwo)
            if(matchTwo) {
              let left = row.tell.substring(0,row.tell.indexOf(matchTwo[0]))
              let right = row.tell.substring(row.tell.indexOf(matchTwo[0])+1)
              if(!isNaN(Number(left)) && !isNaN(Number(right))) {
                let leftAsk = row.ask.substring(0,row.ask.indexOf(matchAsk[0]))
                let rightAsk = row.ask.substring(row.ask.indexOf(matchAsk[0])+1)
                if(Number(leftAsk) != Number(left) || Number(rightAsk) != Number(right)) {
                  // this.$message.error('777777')
                  flags = false
                }
              }
            }
            })
          }
        })
        if(this.bushing.length === 0){
          this.$message.error('缺少套管无法保存')
          return
@@ -1477,8 +1888,14 @@
        this.sample.forEach(a=>{
          a.bushing = this.bushing
        })
        this.$message.success('已保存')
        if(flag && flags) {
          this.$message.success('已保存')
        this.$emit('saveFiberopticConfig')
        }else if(!flag) {
          this.$message.error('光纤保存的检测项中含有不符合要求的数据')
        }else if(!flags) {
          this.$message.error('光纤带保存的检测项中含有不符合要求的数据')
        }
      },
      beforeClose(done){
        if (this.bsm1) {