| | |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="零件号" prop="code"> |
| | | <el-input v-model="dataForm.code"> |
| | | <el-input v-model="dataForm.code" :disabled="dataForm&&dataForm.id!==null&&dataForm.id!==''"> |
| | | <el-button |
| | | slot="append" |
| | | icon="el-icon-search" |
| | | :disabled="(resultVal!=null && resultVal!='')" |
| | | :disabled="dataForm&&dataForm.id!==null&&dataForm.id!==''" |
| | | @click="queryCode"></el-button> |
| | | <el-button |
| | | slot="append" |
| | | icon="el-icon-full-screen" |
| | | :disabled="(resultVal!=null && resultVal!='')" |
| | | :disabled="dataForm&&dataForm.id!==null&&dataForm.id!==''" |
| | | @click="Turnonthecamera"></el-button> |
| | | </el-input> |
| | | </el-form-item> |
| | |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="数量" prop="number"> |
| | | <el-input v-model="dataForm.number" :disabled="(resultVal!=null && resultVal!='')" /> |
| | | <el-input v-model="dataForm.number" :disabled="dataForm&&dataForm.id!==null&&dataForm.id!==''" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="备注" prop="remark"> |
| | | <el-input v-model="dataForm.remark" /> |
| | | <el-input :disabled="dataForm&&dataForm.id!==null&&dataForm.id!==''" v-model="dataForm.remark" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | <el-row style="width:100%;z-index: 10;height:50px;" v-if="resultVal==null"> |
| | | <el-col :span="12"></el-col> |
| | | <el-col :span="12" style="text-align: right;"> |
| | | <el-button v-if="dataForm.id&&resultVal==null" size="small" |
| | | type="primary" |
| | | @click="saveTable()">保存</el-button> |
| | | <el-button v-if="dataForm.id==null" size="small" @click="clickAddLine()">添加检验项目</el-button> |
| | | <el-button class="pad-addcol-btn" v-if="resultVal==null || dataForm.id==null" size="small" @click="addTeatValueColumn()">添加检测值列</el-button> |
| | | <el-button v-if="resultVal==null || dataForm.id==null" size="small" @click="delTeatValueColumn()">删除检测值列</el-button> |
| | |
| | | </el-table-column> |
| | | <el-table-column prop="father" label="检验项目" width="160"> |
| | | <template slot-scope="scope"> |
| | | <el-input v-if="scope.row.children" style="width:80%" :disabled="dataForm.id!=null" v-model="scope.row.father" placeholder="请输入检验项目"></el-input> |
| | | <el-input v-if="scope.row.children" style="width:80%" :disabled="dataForm.id!=null&&(resultVal!=null && resultVal!='')" v-model="scope.row.father" placeholder="请输入检验项目" |
| | | :ref="'inspectProject'+scope.$index" |
| | | :id="'inspectProject'+scope.$index" |
| | | @keyup.native="moveFocus($event, scope.$index, 'inspectProject')"></el-input> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="name" label="项目" width="160"> |
| | | <template slot-scope="scope"> |
| | | <div v-if="!scope.row.children"> |
| | | <el-input class="inline-input" :disabled="dataForm.id!=null" v-model="scope.row.name" |
| | | placeholder="请输入项目名称"></el-input> |
| | | <el-input class="inline-input" :disabled="dataForm.id!=null&&(resultVal!=null && resultVal!='')" v-model="scope.row.name" |
| | | placeholder="请输入项目名称" |
| | | :ref="'project'+scope.$index" |
| | | :id="'project'+scope.$index" |
| | | @keyup.native="moveFocus($event, scope.$index, 'project')"></el-input> |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="unit" label="单位" width="160"> |
| | | <template slot-scope="scope"> |
| | | <div v-if="!scope.row.children"> |
| | | <el-input :disabled="dataForm.id != null" v-model="scope.row.unit" placeholder="请输入单位"></el-input> |
| | | <el-input :disabled="dataForm.id!=null&&(resultVal!=null && resultVal!='')" v-model="scope.row.unit" placeholder="请输入单位" |
| | | :ref="'unit'+scope.$index" |
| | | :id="'unit'+scope.$index" |
| | | @keyup.native="moveFocus($event, scope.$index, 'unit')"></el-input> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | <el-table-column prop="required" label="标准值" width="160"> |
| | | <template slot-scope="scope"> |
| | | <div v-if="!scope.row.children"> |
| | | <el-input :disabled="dataForm.id != null" v-model="scope.row.required" |
| | | placeholder="请输入标准值"></el-input> |
| | | <el-input :disabled="dataForm.id!=null&&(resultVal!=null && resultVal!='')" v-model="scope.row.required" |
| | | placeholder="请输入标准值" |
| | | :ref="'standard'+scope.$index" |
| | | :id="'standard'+scope.$index" |
| | | @keyup.native="moveFocus($event, scope.$index, 'standard')"></el-input> |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | <el-tooltip :disabled="scope.row.deviceId != null" class="item" effect="dark" content="请先选择设备!" placement="top-start"> |
| | | <el-autocomplete clearable |
| | | cache="false" |
| | | ref="testValueInput" |
| | | @blur="checkTestValues(scope.row,'blur',$event)" |
| | | @select="checkTestValues(scope.row,'select',$event)" |
| | | :disabled="scope.row.deviceId == null || (dataForm.id!=null&&(resultVal!=null && resultVal!=''))" |
| | | v-model="scope.row.testValueList[index]" |
| | | :fetch-suggestions="querySearch" |
| | | placeholder="请输入或选择检测值" > |
| | | placeholder="请输入或选择检测值" |
| | | :ref="`detectionValue${index}`+scope.$index" |
| | | :id="`detectionValue${index}`+scope.$index" |
| | | @keyup.native="moveFocus($event, scope.$index, `detectionValue${index}`)" |
| | | popper-class="no-keyboard-events"> |
| | | <template slot-scope="{ item }"> |
| | | <div>{{ item.value }}</div> |
| | | </template> |
| | |
| | | <el-table-column prop="note" label="检验描述" width="160" > |
| | | <template slot-scope="scope"> |
| | | <div v-if="!scope.row.children"> |
| | | <el-input @blur="checkTestValues(scope.row,'blur',$event)" :disabled="scope.row.deviceId == null || (dataForm.id!=null&&(resultVal!=null && resultVal!=''))" v-model="scope.row.note" placeholder="检验描述"></el-input> |
| | | <el-input @blur="checkTestValues(scope.row,'blur',$event)" :disabled="scope.row.deviceId == null || (dataForm.id!=null&&(resultVal!=null && resultVal!=''))" v-model="scope.row.note" placeholder="检验描述" |
| | | :ref="`remark`+scope.$index" |
| | | :id="`remark`+scope.$index" |
| | | @keyup.native="moveFocus($event, scope.$index, `remark`)"></el-input> |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | getObj, |
| | | updateRawInsProduct, |
| | | updateRawInspectsById, |
| | | updateRawInsProduct2, |
| | | updateDeviceById, chooseIFS} from '@/api/quality/rawMaterial' |
| | | import { |
| | | getProcessConfigFiles, |
| | |
| | | // startTime: [{ required: true, message: '请选择报检日期', trigger: 'blur' }] |
| | | }, |
| | | deviceList: [], |
| | | keyfield:['inspectProject','project','unit','standard','remark'], |
| | | keyfield0:['detectionValue0'] |
| | | } |
| | | }, |
| | | beforeUpdate(){ |
| | |
| | | this.unqualifiedNum = null |
| | | } |
| | | }, |
| | | empiricalValueAdd(newVal){ |
| | | if(newVal!=this.keyfield0.length){ |
| | | if(newVal>this.keyfield0.length){ |
| | | this.keyfield0 = [] |
| | | for(let i=0;i<newVal;i++){ |
| | | this.keyfield0.push('detectionValue'+i) |
| | | } |
| | | }else{ |
| | | this.keyfield0.splice(this.keyfield0.length-1,1); |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | methods:{ |
| | | querySearch(queryString, cb){ |
| | |
| | | if(this.list){ |
| | | this.list.forEach(e=>{ |
| | | if(e.children){ |
| | | e.children.forEach(i=>{ |
| | | e.children.map(i=>{ |
| | | if(i.testValueList.length>1){ |
| | | let arr = i.testValue.split(",") |
| | | arr.splice((arr.length-1),1) |
| | | let obj = { |
| | | deviceId: i.deviceId, |
| | | rpId: i.rpId, |
| | | testValue: arr.join(","), |
| | | note: i.note |
| | | } |
| | | updateRawInsProduct(obj).then(res=>{ |
| | | if(res.data.code === 0){ |
| | | this.init(this.dataForm.id) |
| | | } |
| | | }) |
| | | i.testValueList = i.testValueList.splice(i.testValueList.length-1,1) |
| | | return i |
| | | // let arr = i.testValue.split(",") |
| | | // arr.splice((arr.length-1),1) |
| | | // let obj = { |
| | | // deviceId: i.deviceId, |
| | | // rpId: i.rpId, |
| | | // testValue: arr.join(","), |
| | | // note: i.note |
| | | // } |
| | | // updateRawInsProduct(obj).then(res=>{ |
| | | // if(res.data.code === 0){ |
| | | // this.init(this.dataForm.id) |
| | | // } |
| | | // }) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | this.saveTable() |
| | | } |
| | | }, |
| | | delTeatValueColumn(){ |
| | | if (this.empiricalValueAdd - 1 > 0) { |
| | | if (this.empiricalValueAddMaxNumber != this.empiricalValueAdd - 1) { |
| | | this.empiricalValueAdd = this.empiricalValueAdd - 1; |
| | | this.changeRowResult() |
| | | // this.changeRowResult() |
| | | this.list.forEach(i => { |
| | | if(i.children){ |
| | | i.children.forEach(ele=>{ |
| | |
| | | }) |
| | | } |
| | | }); |
| | | this.saveTable() |
| | | } |
| | | } |
| | | }, |
| | |
| | | if(!isTrue){ |
| | | return |
| | | } |
| | | this.changeState(row) |
| | | // this.changeState(row) |
| | | } |
| | | }, |
| | | changeState(row) { |
| | | saveTable() { |
| | | let rawInsProducts = []; |
| | | this.$nextTick(()=>{ |
| | | if (row.rpId != null && row.rpId != '') { |
| | | let val = row.testValueList.join(",") |
| | | if (val === undefined || val === '' || val === null) { |
| | | return |
| | | this.list.forEach(item=>{ |
| | | if(item.children){ |
| | | item.children.forEach(ele=>{ |
| | | let obj = JSON.parse(JSON.stringify(ele)) |
| | | obj.testValue = obj.testValueList.join(",") |
| | | obj.id = obj.rpId |
| | | delete obj.testValueList; |
| | | obj.name = ele.name; |
| | | obj.father = item.father; |
| | | obj.unit = ele.unit; |
| | | rawInsProducts.push(obj) |
| | | }) |
| | | } |
| | | let obj = { |
| | | deviceId: row.deviceId, |
| | | rpId: row.rpId, |
| | | testValue: val, |
| | | note: row.note |
| | | } |
| | | updateRawInsProduct(obj).then(res => { |
| | | if (res.data.code == 0) { |
| | | this.$message.success("更新成功") |
| | | } else { |
| | | this.$message.error("更新失败") |
| | | } |
| | | this.init(this.dataForm.id) |
| | | }) |
| | | }) |
| | | if(rawInsProducts.length>0){ |
| | | updateRawInsProduct2(rawInsProducts).then(res => { |
| | | if (res.data.code == 0) { |
| | | this.$message.success("更新成功") |
| | | } else { |
| | | this.$message.error("更新失败") |
| | | } |
| | | this.init(this.dataForm.id) |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | |
| | | data.rawInsProducts = this.list |
| | | addRawInspects(data).then(res=>{ |
| | | this.$message.success("保存成功") |
| | | // this.$router.go(-1) |
| | | this.$router.go(-1) |
| | | }).catch(error=>{ |
| | | this.$message.error(error) |
| | | }) |
| | |
| | | this.deviceList = res.data.data |
| | | }) |
| | | }, |
| | | }, |
| | | moveFocus(event, index, key) { |
| | | console.log(key, index,key) |
| | | let keyfield = this.insertArrayAt(this.keyfield,4,this.keyfield0); |
| | | // enter键 |
| | | // if (event.keyCode === 13) { // 回车 |
| | | // if (index === this.getLen() - 1 && key === keyfield[keyfield.length - 1]) { // 最后一行最后一个 |
| | | // console.log('最后一行最后一个无法回车') |
| | | // return |
| | | // } |
| | | // this.$nextTick(() => { |
| | | // event.target.blur() |
| | | // }) |
| | | // if (key === keyfield[keyfield.length - 1]) { // 当前行最后一个,跳转下一行第一个 |
| | | |
| | | // } else { // 跳转下一个 |
| | | // const nextkeyindex = keyfield.findIndex(k => k === key) + 1 |
| | | // this.$nextTick(() => { |
| | | // document.getElementById(keyfield[nextkeyindex] + index).focus() |
| | | // }) |
| | | // } |
| | | // } |
| | | |
| | | // 向上 =38 |
| | | if (event.keyCode === 38) { |
| | | console.log('向上') |
| | | if (index === 0) { // 第一行 |
| | | console.log('第一行无法向上') |
| | | return |
| | | } |
| | | document.getElementById(key + index).blur() |
| | | if(key.includes('detectionValue')){ |
| | | this.$refs[key + index][0].activated = false; |
| | | } |
| | | let i = 0; |
| | | while (true){ |
| | | let dom = document.getElementById(key + (index - 1-i)) |
| | | if(dom){ |
| | | dom.focus() |
| | | return |
| | | }else if((index-1-i)==0){ |
| | | return |
| | | } |
| | | i++ |
| | | } |
| | | } |
| | | |
| | | // 下 = 40 |
| | | if (event.keyCode === 40) { |
| | | console.log('向下') |
| | | if (index === this.getLen() - 1) { // 最后一行 |
| | | console.log('最后一行无法向下') |
| | | return |
| | | } |
| | | document.getElementById(key + index).blur() |
| | | if(key.includes('detectionValue')){ |
| | | this.$refs[key + index][0].activated = false; |
| | | } |
| | | this.$nextTick(() => { |
| | | let i = 0; |
| | | while (true){ |
| | | let dom = document.getElementById(key + (index + 1+i)) |
| | | console.log(dom,key + (index + 1+i)) |
| | | if(dom){ |
| | | dom.focus() |
| | | return |
| | | }else if((index+1+i)==this.getLen() - 1){ |
| | | return |
| | | } |
| | | i++ |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // 左 = 37 |
| | | if (event.keyCode === 37) { |
| | | console.log('向左') |
| | | if (index === 0 && key === keyfield[0]) { // 第一行第一个 |
| | | console.log('第一行第一个无法向左') |
| | | return |
| | | } |
| | | document.getElementById(key + index).blur() |
| | | const prevkeyindex = keyfield.findIndex(k => k === key) - 1 |
| | | this.$nextTick(() => { |
| | | let dom = document.getElementById(keyfield[prevkeyindex] + index) |
| | | if(dom){ |
| | | dom.focus() |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // 右 = 39 |
| | | if (event.keyCode === 39) { |
| | | console.log('向右') |
| | | if (index === this.getLen() - 1 && key === keyfield[keyfield.length - 1]) { // 最后一行最后一个 |
| | | console.log('最后一行最后一个无法向右') |
| | | return |
| | | } |
| | | document.getElementById(key + index).blur() |
| | | const nextkeyindex = keyfield.findIndex(k => k === key) + 1 |
| | | this.$nextTick(() => { |
| | | let dom = document.getElementById(keyfield[nextkeyindex] + index) |
| | | if(dom){ |
| | | dom.focus() |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | insertArrayAt(arr1, index, arr2) { |
| | | return arr1.slice(0, index).concat(arr2, arr1.slice(index)); |
| | | }, |
| | | getLen(){ |
| | | let arr = [] |
| | | this.list.forEach(item => { |
| | | arr.push(item) |
| | | item.children.forEach(child => { |
| | | arr.push(child) |
| | | }) |
| | | }) |
| | | return arr.length |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | /* .no-keyboard-events * { |
| | | pointer-events: none; |
| | | } */ |
| | | .rawMaterial-detail { |
| | | width: 100%; |
| | | height: 530px; |