| | |
| | | </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" @change="changeASk(scope.row)"></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> |
| | |
| | | } |
| | | }, |
| | | |
| | | changeASk(row) { |
| | | 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) { |