| | |
| | | class="content"> |
| | | <template |
| | | v-if="n.v.ps != undefined && typeof n.v.ps.value === 'string' && n.v.ps.value.includes('检验值') && state == 1"> |
| | | <el-input v-if="getInspectionValueType(n.i) == 1" |
| | | <el-input |
| | | v-if="getInspectionValueType(n.i) == 1 || (getInspectionValueType(n.i) != 2 && getInspectionValueType(n.i) != 4)" |
| | | :key="'abc-' + '000' + index + '000' + i + '000' + j" v-model="n.v.v" |
| | | :disabled="(getInspectionItemType(n.i) == 1 && !dataAcquisitionEidtAble) || (n.u != userId && n.u != undefined && n.u != '')" |
| | | class="table_input" |
| | |
| | | <span v-else-if="getInspectionValueType(n.i) == 4" |
| | | :style="`font-family:${n.v.ff} !important;`">/</span> |
| | | </template> |
| | | <template v-else-if="n.v.ps != undefined && n.v.ps.value === '结论'"> |
| | | <el-select |
| | | v-if="(getInspectionValueType(n.i) == 2 || getInspectionValueType(n.i) == 5) && state == 1" |
| | | v-model="n.v.v" class="table_input" |
| | | @change="m => changeInput(m, `${item.templateId}-${n.r}-${n.c}-${n.i}`, n, 'getDataType')"> |
| | | <el-option :value="1" label="合格"></el-option> |
| | | <el-option :value="0" label="不合格"></el-option> |
| | | <el-option :value="3" label="不判定"></el-option> |
| | | <el-option :value="2" label="待定"></el-option> |
| | | </el-select> |
| | | <template v-if="state > 1"> |
| | | <span v-if="n.v.v === 1" :style="`font-family:${n.v.ff} !important;color: green;`">合格</span> |
| | | <span v-else-if="n.v.v === 0" :style="`font-family:${n.v.ff} !important;color: red;`">不合格</span> |
| | | <span v-else-if="n.v.v === 3" |
| | | :style="`font-family:${n.v.ff} !important;color: #3A7BFA;`">不判定</span> |
| | | <span v-else :style="`font-family:${n.v.ff} !important;`">待定</span> |
| | | </template> |
| | | <template v-if="getInspectionValueType(n.i) != 2 && state == 1"> |
| | | <span v-if="n.v.v === 1" :style="`font-family:${n.v.ff} !important;color: green;`">合格</span> |
| | | <span v-else-if="n.v.v === 0" :style="`font-family:${n.v.ff} !important;color: red;`">不合格</span> |
| | | <span v-else-if="n.v.v === 3" |
| | | :style="`font-family:${n.v.ff} !important;color: #3A7BFA;`">不判定</span> |
| | | <span v-else :style="`font-family:${n.v.ff} !important;`">待定</span> |
| | | </template> |
| | | </template> |
| | | <template v-else-if="n.v.ps != undefined && n.v.ps.value === '设备编码' && state == 1"> |
| | | <span>{{ n.v.v }}</span> |
| | | </template> |
| | | <template v-else-if="n.v.ps != undefined && n.v.ps.value === '设备名称'"> |
| | | <el-select v-model="n.v.v" :disabled="state > 1" class="table_input" filterable multiple |
| | | placeholder="设备" remote @change="(val) => changeEquip(val, n)" |
| | |
| | | {{ item.label + '--' + item.value }} |
| | | </el-option> |
| | | </el-select> |
| | | </template> |
| | | <template v-else-if="n.v.ps != undefined && n.v.ps.value === '要求值' && state == 1"> |
| | | <span :style="`font-family:${n.v.ff} !important;`">{{ getTell(n.i) }}</span> |
| | | </template> |
| | | <template v-else-if="n.v.ps != undefined && n.v.ps.value === '计算值' && state == 1"><span |
| | | :style="`font-family:${n.v.ff} !important;`">{{ toFixed(n.v.v, n.v.ct) }}</span></template> |
| | |
| | | return |
| | | } |
| | | this.currentSample.insProduct = this.HaveJson(list) |
| | | // 初始化传递到后端的参数 |
| | | // 初始化传递到后端的参数,按“模板id + 单元格坐标(r-c)”存 |
| | | this.param = {} |
| | | this.changeType = 0; |
| | | this.currentSample.insProduct.forEach(a => { |
| | | // 是否为成品电缆下的松套管项目,不是则执行初始化 |
| | | if (this.handleCasing(a.inspectionItem)) { |
| | | this.param[a.id] = { |
| | | insValue: [], |
| | | comValue: [], |
| | | resValue: null, |
| | | equipValue: [], |
| | | equipName: [], |
| | | insResult: null |
| | | } |
| | | } |
| | | }) |
| | | // await this.determineWhetherToCollectData()//是否需要数采 |
| | | if (this.currentSample.index == undefined) this.currentSample['index'] = 1 |
| | | let bushing = this.currentSample.bushing |
| | |
| | | if (m.templateId == val1) { |
| | | let list = await this.getCurrentProduct(this.currentSample.id, 0) |
| | | this.currentSample.insProduct = this.HaveJson(list)//赋值当前样品的检验项 |
| | | this.param = {}//初始化传到后端的参数 |
| | | this.currentSample.insProduct.forEach((a, j) => { |
| | | if (this.handleCasing(a.inspectionItem)) { |
| | | this.param[a.id] = { |
| | | insValue: [], |
| | | comValue: [], |
| | | resValue: null, |
| | | equipValue: [], |
| | | equipName: [], |
| | | insResult: null |
| | | } |
| | | } |
| | | }) |
| | | this.param = {}//初始化传到后端的参数,按“模板id + 单元格坐标(r-c)”存 |
| | | // 去重模板,返回有几个模板 |
| | | const mySet1 = new Set(); |
| | | this.tableLists = this.currentSample.insProduct.filter(m => { |
| | |
| | | // 特殊检验项--监听设备信息改变 |
| | | equipForm: { |
| | | deep: true, |
| | | handler(val) { |
| | | if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName == '温度循环检验原始记录' || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('热循环') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('温升试验')) && this.equipOptions && this.equipOptions.length > 0) { |
| | | // 初始化设备信息 |
| | | this.param[this.currentSample.insProduct[0].id].equipValue = [] |
| | | this.param[this.currentSample.insProduct[0].id].equipName = [] |
| | | if (this.equipForm.code0) { |
| | | // 赋值第一个设备的信息 |
| | | this.equipForm.value0 = this.equipOptions.find(m => m.value == this.equipForm.code0).label |
| | | this.param[this.currentSample.insProduct[0].id].equipValue.push({ |
| | | i: this.currentSample.insProduct[0].id, |
| | | v: { |
| | | v: this.equipForm.code0 |
| | | } |
| | | }) |
| | | this.param[this.currentSample.insProduct[0].id].equipName.push({ |
| | | i: this.currentSample.insProduct[0].id, |
| | | v: { |
| | | v: this.equipForm.value0 |
| | | } |
| | | }) |
| | | } |
| | | if (this.equipForm.code1) { |
| | | // 赋值第二个设备的信息 |
| | | this.equipForm.value1 = this.equipOptions.find(m => m.value == this.equipForm.code1).label |
| | | this.param[this.currentSample.insProduct[0].id].equipValue.push({ |
| | | i: this.currentSample.insProduct[0].id, |
| | | v: { |
| | | v: this.equipForm.code1 |
| | | } |
| | | }) |
| | | this.param[this.currentSample.insProduct[0].id].equipName.push({ |
| | | i: this.currentSample.insProduct[0].id, |
| | | v: { |
| | | v: this.equipForm.value1 |
| | | } |
| | | }) |
| | | } |
| | | // 保存数据 |
| | | this.saveInsContext() |
| | | } |
| | | } |
| | | handler(val) { }, |
| | | }, |
| | | }, |
| | | beforeDestroy() { |
| | |
| | | let list = await this.getCurrentProduct(m, type, cableTag) |
| | | if (list.length > 0) { |
| | | this.param = {} |
| | | list.forEach(a => { |
| | | this.param[a.id] = { |
| | | insValue: [], |
| | | comValue: [], |
| | | resValue: null, |
| | | equipValue: [], |
| | | equipName: [], |
| | | insResult: null |
| | | } |
| | | }) |
| | | this.getTableLists0(list) |
| | | this.worker.postMessage(JSON.stringify({ |
| | | type: 'saveData', |
| | |
| | | count++ |
| | | }) |
| | | }) |
| | | // 本次循环主要是控制合并,以及控制检验项信息是否展示出来,以便后续检验 |
| | | // 按后端下发的“模板ID + 模板行号”直接绑定检验项,不做名称比对,不隐藏任何行 |
| | | this.tableList.forEach(a => { |
| | | let dels = new Set()//需要删除的行 |
| | | let ids = []//所有检验项的id |
| | | let set3 = new Set() |
| | | a.template.forEach(b => { |
| | | let size1 = set3.size |
| | | let size2 = set3.add(b.r).size |
| | | if (size1 < size2) { |
| | | let str = '' |
| | | let str2 = '' |
| | | let unit2 = '' |
| | | let count4 = 0 |
| | | let isThree = 0 |
| | | a.template.forEach(c => { |
| | | // 获取到 检验项分类+检验项+检验子项的拼接,如果模板里的信息跟接口返回的检验项信息能够匹配则展示出来 |
| | | if (b.r === c.r) { |
| | | if (c.v.ps != undefined && c.v.ps.value === '检验项分类' && count4 === 0) { |
| | | // 三级分类 |
| | | isThree = 1 |
| | | } else if (c.v.ps != undefined && c.v.ps.value === '检验项' && count4 === 0) { |
| | | // 二级分类 |
| | | isThree = 0 |
| | | } |
| | | if (isThree == 0) { |
| | | if (c.v.ps != undefined && c.v.ps.value === '检验项') { |
| | | if (count4 === 0) { |
| | | str += c.v.v |
| | | count4 += 1 |
| | | } |
| | | } else if (c.v.ps != undefined && c.v.ps.value === '检验子项') { |
| | | if (count4 === 1) { |
| | | str += c.v.v |
| | | count4 += 1 |
| | | } |
| | | } |
| | | } else if (isThree == 1) { |
| | | if (c.v.ps != undefined && c.v.ps.value === '检验项分类') { |
| | | if (count4 === 0) { |
| | | str += c.v.v |
| | | count4 += 1 |
| | | } |
| | | } else if (c.v.ps != undefined && c.v.ps.value === '检验项') { |
| | | if (count4 === 1) { |
| | | str += c.v.v |
| | | count4 += 1 |
| | | } |
| | | } else if (c.v.ps != undefined && c.v.ps.value === '检验子项') { |
| | | if (count4 === 2) { |
| | | str += c.v.v |
| | | count4 += 1 |
| | | } |
| | | } |
| | | } |
| | | if (str === '机械性能干态拉伸强度(纵向)') { |
| | | if (c.v.ps != undefined && c.v.ps.value === '单位') { |
| | | str2 = str + c.v.v |
| | | unit2 = c.v.v |
| | | |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | if (str != '') { |
| | | let count2 = 0 |
| | | for (let i in this.currentSample.insProduct) { |
| | | let inspectionItemClass = this.currentSample.insProduct[i].inspectionItemClass == null || this.currentSample.insProduct[i].inspectionItemClass == undefined ? '' : this.currentSample.insProduct[i].inspectionItemClass |
| | | let inspectionItem = this.currentSample.insProduct[i].inspectionItem == null || this.currentSample.insProduct[i].inspectionItem == undefined ? '' : this.currentSample.insProduct[i].inspectionItem |
| | | let inspectionItemSubclass = this.currentSample.insProduct[i].inspectionItemSubclass == null || this.currentSample.insProduct[i].inspectionItemSubclass == undefined ? '' : this.currentSample.insProduct[i].inspectionItemSubclass |
| | | if (inspectionItemSubclass === '干态拉伸强度(纵向)') { |
| | | // 检验子项为'干态拉伸强度(纵向)'时,模版里是两个计算值对应相同的检验值并且计算方式不同,要根据相同的'单位'做特殊的渲染 |
| | | const unit = this.currentSample.insProduct[i].unit |
| | | if ((this.currentSample.insProduct[i].templateId === a.templateId && inspectionItemClass + inspectionItem + inspectionItemSubclass + unit === str2) || (this.currentSample.insProduct[i].templateId === a.templateId && !unit2.includes('/') && inspectionItemClass + inspectionItem + inspectionItemSubclass === str)) { |
| | | ids.push({ |
| | | r: b.r, |
| | | id: this.currentSample.insProduct[i].id, |
| | | product: this.currentSample.insProduct[i] |
| | | }) |
| | | break |
| | | } |
| | | } else { |
| | | // 如果相等,那么说明找到了,并且把id存起来,后续检验项也会在页面中显示出来 |
| | | if (this.currentSample.insProduct[i].templateId === a.templateId && inspectionItemClass + inspectionItem + inspectionItemSubclass === str) { |
| | | ids.push({ |
| | | r: b.r, |
| | | id: this.currentSample.insProduct[i].id, |
| | | product: this.currentSample.insProduct[i] |
| | | }) |
| | | break |
| | | } |
| | | } |
| | | count2++ |
| | | } |
| | | if (count2 == this.currentSample.insProduct.length) { |
| | | dels.add(b.r) |
| | | } |
| | | const directProducts = this.currentSample.insProduct.filter( |
| | | (product) => product.templateId === a.templateId && |
| | | product.templateRowIndex !== null && product.templateRowIndex !== undefined |
| | | ); |
| | | directProducts.forEach((product) => { |
| | | a.template.forEach((cell) => { |
| | | if (cell.r === product.templateRowIndex) { |
| | | cell.i = product.id; |
| | | } |
| | | } |
| | | }) |
| | | // 操作删除 |
| | | dels.forEach(del => { |
| | | for (let b = 0; b < a.template.length; b++) { |
| | | if (a.template[b].r === del) { |
| | | a.template.splice(b, 1) |
| | | b -= 1 |
| | | } |
| | | } |
| | | }) |
| | | // 操作赋值--主要赋值单位,试验方法等信息 |
| | | ids.forEach(id => { |
| | | for (let b = 0; b < a.template.length; b++) { |
| | | if (a.template[b].r === id.r) { |
| | | a.template[b].i = id.id |
| | | if (a.template[b].v.ps != undefined && a.template[b].v.ps.value === '单位') { |
| | | a.template[b].v.v = id.product.unit |
| | | } |
| | | if (a.template[b].v.ps != undefined && (a.template[b].v.ps.value === '试验方法' || a.template[b].v |
| | | .ps.value === '检测方法')) { |
| | | a.template[b].v.v = id.product.methodS |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | }); |
| | | }); |
| | | let set2 = new Set() |
| | | // 合并的数据处理,cs rs 代表合并的数量 |
| | | a.template.forEach(b => { |
| | |
| | | let arrs = [] |
| | | let set = new Set() |
| | | let count1 = 0 |
| | | let conclusionList = []; //结论列表 |
| | | let finalList = []; //最终值列表 |
| | | // 结论与最终值在这里一一对应,以下两个列表长度肯定是一样的,如果有不一样,那么多半是模板配置得问题 |
| | | conclusionList = a.template.filter(n => n.v.ps != undefined && n.v.ps.value === '结论')//结论列表 |
| | | finalList = a.template.filter(n => n.v.ps != undefined && n.v.ps.value === '最终值')//最终值列表 |
| | | a.template.forEach(b => { |
| | | if (b.v.ps != undefined && b.v.ps.value === '序号' && (b.v.mc == undefined || Object.keys(b.v.mc).length === 4)) { |
| | | // 对序号进行赋值 |
| | | count1++ |
| | | b.v.v = count1 |
| | | } |
| | | if (b.v.ps != undefined && b.v.ps.value === '要求值') { |
| | | // 对要求值进行赋值 |
| | | b.v.v = this.getAsk(b.i) |
| | | } |
| | | // 对页面的和给后端传参的检验值,计算值,设备编码,设备名称,最终值,结论进行初始化 |
| | | if (b.v.ps != undefined && typeof b.v.ps.value === 'string' && b.v.ps.value.includes('检验值')) { |
| | | // 初始化可填写/可计算单元格,后续按坐标回显 |
| | | if ( |
| | | b.v.ps != undefined && |
| | | typeof b.v.ps.value === 'string' && |
| | | (b.v.ps.value.includes('检验值') || |
| | | b.v.ps.value === '计算值' || |
| | | b.v.ps.value === '最终值' || |
| | | b.v.ps.value === '设备名称') |
| | | ) { |
| | | this.$set(b.v, 'v', '') |
| | | // b.v.v = '' |
| | | b.u = '' |
| | | b.i && this.param[b.i] && this.param[b.i].insValue.push(b) |
| | | } |
| | | if (b.v.ps != undefined && b.v.ps.value === '计算值') { |
| | | this.$set(b.v, 'v', '') |
| | | // b.v.v = '' |
| | | b.i && this.param[b.i] && this.param[b.i].comValue.push(b) |
| | | } |
| | | if (b.v.ps != undefined && b.v.ps.value === '设备编码') { |
| | | // b.v.v = '' |
| | | this.$set(b.v, 'v', '') |
| | | b.i && this.param[b.i] && this.param[b.i].equipValue.push(b) |
| | | } |
| | | if (b.v.ps != undefined && b.v.ps.value === '设备名称') { |
| | | this.$set(b.v, 'v', '') |
| | | // b.v.v = '' |
| | | b.i && this.param[b.i] && this.param[b.i].equipName.push(b) |
| | | } |
| | | if (b.v.ps != undefined && b.v.ps.value === '最终值') { |
| | | // b.v.v = '' |
| | | this.$set(b.v, 'v', '') |
| | | if (b.i !== undefined && this.param[b.i] && !this.param[b.i].resValue) { |
| | | this.param[b.i].resValue = b |
| | | } |
| | | } |
| | | if (b.v.ps != undefined && b.v.ps.value === '结论') { |
| | | if (b.i !== undefined && this.param[b.i] && !this.param[b.i].insResult) { |
| | | this.param[b.i].insResult = b |
| | | conclusionList.forEach((n, i) => { |
| | | if (n.r == b.r && n.c == b.c) { |
| | | b.v.f = |
| | | `(${this.comparisonList.find(j => j.value == (finalList[i].c)).label}${finalList[i].r + 1})` |
| | | |
| | | } |
| | | }) |
| | | if (b.v.ps.value.includes('检验值')) { |
| | | b.u = '' |
| | | } |
| | | } |
| | | set.add(b.r) |
| | |
| | | this.tableWidth += (a.style.columnlen[i] === undefined ? 100 : a.style.columnlen[i]) |
| | | } |
| | | }) |
| | | // 本次循环主要是对页面及后端传参进行初始化赋值 |
| | | this.currentSample.insProduct.forEach(async 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 = this.toFixed(comValue[i].v, this.param[a.id].comValue[i].v.ct) |
| | | } |
| | | } catch (e) { } |
| | | try { |
| | | // 检验值赋值 |
| | | let insValue = JSON.parse(a.insProductResult.insValue) |
| | | for (let i = 0; i < insValue.length; i++) { |
| | | if (this.param[a.id].insValue.find(m => m.c == insValue[i].c && m.r == insValue[i].r)) { |
| | | this.param[a.id].insValue.find(m => m.c == insValue[i].c && m.r == insValue[i].r).v.v = this.toFixed(insValue[i].v, this.param[a.id].insValue.find(m => m.c == insValue[i].c && m.r == insValue[i].r).v.ct) |
| | | this.param[a.id].insValue.find(m => m.c == insValue[i].c && m.r == insValue[i].r).u = insValue[i].u |
| | | // this.param[a.id].insValue[i].v.v = insValue[i].v |
| | | // this.param[a.id].insValue[i].u = insValue[i].u |
| | | } |
| | | } |
| | | } catch (e) { } |
| | | try { |
| | | // 设备编号赋值 |
| | | let equipValue = JSON.parse(a.insProductResult.equipValue) |
| | | if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName == '温度循环检验原始记录' || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('热循环') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('温升试验'))) { |
| | | // 特殊项目初始化 |
| | | this.param[a.id].equipValue = [] |
| | | for (let i = 0; i < equipValue.length; i++) { |
| | | this.param[a.id].equipValue.push({ |
| | | v: { |
| | | v: '' |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | for (let i = 0; i < equipValue.length; i++) { |
| | | if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName == '温度循环检验原始记录' || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('热循环') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('温升试验'))) { |
| | | // 温度循环设备赋值 |
| | | this.$set(this.equipForm, `code` + i, equipValue[i].v) |
| | | this.param[a.id].equipValue[i].v.v = equipValue[i].v |
| | | } else { |
| | | // 普通设备赋值 |
| | | this.param[a.id].equipValue[i].v.v = equipValue[i].v |
| | | } |
| | | } |
| | | } catch (e) { } |
| | | try { |
| | | // 设备名称赋值 |
| | | let equipName = JSON.parse(a.insProductResult.equipName) |
| | | for (let i = 0; i < equipName.length; i++) { |
| | | equipName[i].v !== '' && equipName[i].v.map(val => { |
| | | const index = this.equipOptions.findIndex(item => item.value === val) |
| | | if (index > -1) { |
| | | // 根据设备编码转换为相应的设备名称 |
| | | val = this.equipOptions[index].deviceName |
| | | } |
| | | }) |
| | | } |
| | | if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName == '温度循环检验原始记录' || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('热循环') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('温升试验'))) { |
| | | // 设备名称初始化 |
| | | this.param[a.id].equipName = [] |
| | | for (let i = 0; i < equipName.length; i++) { |
| | | this.param[a.id].equipName.push({ |
| | | v: { |
| | | v: '' |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | for (let i = 0; i < equipName.length; i++) { |
| | | if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName == '温度循环检验原始记录' || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('热循环') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('温升试验'))) { |
| | | // 温度循环赋值 |
| | | this.$set(this.equipForm, `value` + i, equipName[i].v) |
| | | this.param[a.id].equipName[i].v.v = equipName[i].v |
| | | } else { |
| | | // 普通设备名称赋值 |
| | | this.param[a.id].equipName[i].v.v = equipName[i].v |
| | | } |
| | | } |
| | | } catch (e) { |
| | | console.log('设备名称赋值----', e) |
| | | } |
| | | try { |
| | | // 最终值赋值 |
| | | this.param[a.id].resValue.v.v = this.toFixed(a.lastValue, this.param[a.id].resValue.v.ct) |
| | | // 结论赋值 |
| | | this.param[a.id].insResult.v.v = a.insResult |
| | | } catch (e) { } |
| | | }) |
| | | // 按“模板id + 单元格坐标(r-c)”回显已保存的值 |
| | | this.initParamByCoordinate() |
| | | // 对excel函数进行处理 |
| | | this.handleExcelMethod() |
| | | }, |
| | | // 按“模板id + 单元格坐标(r-c)”回显已保存的值 |
| | | initParamByCoordinate() { |
| | | this.param = {} |
| | | this.tableList.forEach(a => { |
| | | this.param[a.templateId] = {} |
| | | const product = this.currentSample.insProduct.find(m => m.templateId === a.templateId) |
| | | let saved = (product && (product.recordValues || product.insProductResult)) || {} |
| | | if (typeof saved === 'string') { |
| | | try { |
| | | saved = JSON.parse(saved) |
| | | } catch (e) { |
| | | saved = {} |
| | | } |
| | | } |
| | | a.template.forEach(cell => { |
| | | const key = `${cell.r}-${cell.c}` |
| | | const item = saved[key] |
| | | if (item === undefined || item === null) { |
| | | return |
| | | } |
| | | const value = typeof item === 'object' ? item.v : item |
| | | if (value === undefined || value === null) { |
| | | return |
| | | } |
| | | cell.v.v = value |
| | | if (typeof item === 'object' && item.u) { |
| | | cell.u = item.u |
| | | } |
| | | this.param[a.templateId][key] = { |
| | | v: value, |
| | | u: typeof item === 'object' ? item.u : cell.u |
| | | } |
| | | }) |
| | | }) |
| | | }, |
| | | // 检验值输入后触发的函数 |
| | | changeInput(m, code, n, getDataType) { |
| | |
| | | if (getDataType == 'getDataType') { |
| | | this.getDataType = 2; |
| | | } |
| | | let currentInsItemId = null//当前检验项id |
| | | if (n) { |
| | | currentInsItemId = JSON.parse(JSON.stringify(n.i)) |
| | | // 定义一个函数来验证分数是否有效 |
| | | if (typeof n.v.v == 'string') { |
| | | function isValidFraction(fraction) { |
| | |
| | | modelType: this.sampleProduct[0].model, |
| | | currentInsItem: n |
| | | })); |
| | | // 先保存主线程中已经输入的原始值。Worker 完成计算后会再次入队保存计算结果。 |
| | | if (n) { |
| | | this.saveInsContext() |
| | | } |
| | | } catch (error) { |
| | | console.log(444, error); |
| | | } |
| | |
| | | this.result = JSON.parse(event.data); |
| | | switch (this.result.method) { |
| | | case 'saveInsContext': |
| | | console.log(`output->`, 11111111111111) |
| | | this.$nextTick(() => { |
| | | // this.$delete(this.tableList[0],'arr') |
| | | this.$set(this.tableList[0], 'arr', this.result.value.tableList[0].arr) |
| | | this.param = this.result.value.param |
| | | if (this.result.value.currentInsItem) { |
| | | currentInsItemId = this.result.value.currentInsItem.i |
| | | } |
| | | // 特殊处理一下结论,会有这种特殊情况 |
| | | for (var i in this.param) { |
| | | if (this.param[i].insResult && this.param[i].insResult.v && this.param[i].insResult.v.v) { |
| | | if (this.param[i].insResult.v.v == '合格') { |
| | | this.$set(this.param[i].insResult.v, 'v', 1) |
| | | } else if (this.param[i].insResult.v.v == '不合格') { |
| | | this.$set(this.param[i].insResult.v, 'v', 0) |
| | | } |
| | | } |
| | | } |
| | | const resultValue = this.result.value |
| | | this.$set(this.tableList[0], 'arr', resultValue.tableList[0].arr) |
| | | this.param = resultValue.param |
| | | this.saveInsContext() |
| | | }) |
| | | break; |
| | | case 'tableList': |
| | |
| | | // 更新数据 |
| | | this.$delete(this.tableList[0], 'arr') |
| | | this.$set(this.tableList[0], 'arr', this.result.value[0].arr) |
| | | // this.param = this.result.value.param |
| | | if (this.result.value.currentInsItem) { |
| | | currentInsItemId = this.result.value.currentInsItem.i |
| | | } |
| | | }) |
| | | break; |
| | | case 'getCurrentInsProduct': |
| | | // 更新页面数据 |
| | | this.getCurrentInsProduct(this.result.value) |
| | | break; |
| | | } |
| | | }; |
| | | // 保存数据 |
| | | setTimeout(() => { |
| | | this.saveInsContext(currentInsItemId) |
| | | }, 200) |
| | | }, |
| | | // 是否需要数采 |
| | | // async determineWhetherToCollectData() { |
| | | // let res = determineWhetherToCollectData({ managementNumber: '' }) |
| | | // this.isGet = res.data |
| | | // }, |
| | | // 根据后端传参更新页面数据 param => this.tableList[0].insProductResult |
| | | getCurrentInsProduct(pId) { |
| | | if (!this.tableList[0].insProductResult) { |
| | | this.tableList[0].insProductResult = {} |
| | | } |
| | | for (let m in this.param[pId]) { |
| | | let value = this.param[pId][m] |
| | | switch (m) { |
| | | case 'comValue': |
| | | // 赋值计算值 |
| | | if (value && value.length > 0) { |
| | | this.tableList[0].insProductResult[m] = []; |
| | | value.forEach((a, i) => { |
| | | let obj = { |
| | | v: a.v.v, |
| | | } |
| | | this.tableList[0].insProductResult[m].push(obj); |
| | | }) |
| | | try { |
| | | this.tableList[0].insProductResult[m] = JSON.stringify(this.tableList[0].insProductResult[m]) |
| | | } catch (error) { |
| | | console.log(555, error); |
| | | } |
| | | } |
| | | break; |
| | | // 赋值检验值 |
| | | case 'insValue': |
| | | if (value && value.length > 0) { |
| | | this.tableList[0].insProductResult[m] = []; |
| | | value.forEach((a, i) => { |
| | | let obj = { |
| | | v: a.v.v, |
| | | u: a.u, |
| | | } |
| | | this.tableList[0].insProductResult[m].push(obj); |
| | | }) |
| | | try { |
| | | this.tableList[0].insProductResult[m] = JSON.stringify(this.tableList[0].insProductResult[m]) |
| | | } catch (error) { |
| | | console.log(666, error); |
| | | } |
| | | } |
| | | break; |
| | | // 赋值设备编号 |
| | | case 'equipValue': |
| | | if (value && value.length > 0) { |
| | | this.tableList[0].insProductResult[m] = []; |
| | | value.forEach((a, i) => { |
| | | let obj = { |
| | | v: a.v.v, |
| | | } |
| | | this.tableList[0].insProductResult[m].push(obj); |
| | | }) |
| | | try { |
| | | this.tableList[0].insProductResult[m] = JSON.stringify(this.tableList[0].insProductResult[m]) |
| | | } catch (error) { |
| | | console.log(777, error); |
| | | } |
| | | } |
| | | break; |
| | | // 赋值设备名称 |
| | | case 'equipName': |
| | | if (value && value.length > 0) { |
| | | this.tableList[0].insProductResult[m] = []; |
| | | value.forEach((a, i) => { |
| | | let obj = { |
| | | v: a.v.v, |
| | | } |
| | | this.tableList[0].insProductResult[m].push(obj); |
| | | }) |
| | | try { |
| | | this.tableList[0].insProductResult[m] = JSON.stringify(this.tableList[0].insProductResult[m]) |
| | | } catch (error) { |
| | | console.log(888, error); |
| | | } |
| | | } |
| | | break; |
| | | // 赋值最终值 |
| | | case 'resValue': |
| | | this.tableList[0].lastValue = value ? value.v.v : '' |
| | | break; |
| | | // 赋值结论 |
| | | case 'insResult': |
| | | this.tableList[0].insResult = value ? value.v.v : '' |
| | | break; |
| | | } |
| | | } |
| | | }, |
| | | // 对EXCEL函数进行处理 |
| | | handleExcelMethod() { |
| | | if (this.excelMethodList.length > 0) { |
| | |
| | | for (var a in this.currentSample.insProduct) { |
| | | if (this.currentSample.insProduct[a].id == id) { |
| | | return this.currentSample.insProduct[a].inspectionValueType |
| | | } |
| | | } |
| | | }, |
| | | // 获取要求描述 |
| | | getTell(id) { |
| | | for (var a in this.currentSample.insProduct) { |
| | | if (this.currentSample.insProduct[a].id == id) { |
| | | return this.currentSample.insProduct[a].tell |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | // 获取要求值 |
| | | getAsk(id) { |
| | | for (var a in this.currentSample.insProduct) { |
| | | if (this.currentSample.insProduct[a].id == id) { |
| | | return this.currentSample.insProduct[a].ask |
| | | } |
| | | } |
| | | }, |
| | | getSystemValue(n) { |
| | | let code = null |
| | | try { |
| | | this.param[n.i].equipValue.forEach(a => { |
| | | if (a.r === n.r) { |
| | | if (a.v.v == null || a.v.v == '') { |
| | | this.$message.error('请先选择采集的设备') |
| | | return |
| | | } else { |
| | | code = a.v.v |
| | | } |
| | | } |
| | | this.tableList.forEach(table => { |
| | | (table.arr || []).forEach(row => { |
| | | row.forEach(cell => { |
| | | if (cell.i == n.i && cell.r === n.r && cell.v.ps && cell.v.ps.value === '设备编码') { |
| | | if (cell.v.v == null || cell.v.v == '') { |
| | | this.$message.error('请先选择采集的设备') |
| | | return |
| | | } else { |
| | | code = cell.v.v |
| | | } |
| | | } |
| | | }) |
| | | }) |
| | | }) |
| | | } catch (e) { |
| | | // console.log(e); |
| | |
| | | }) |
| | | return |
| | | }, |
| | | // 统一在这里保存数据 |
| | | saveInsContext(currentInsItemId) { |
| | | try { |
| | | if (this.param) { |
| | | let param = null |
| | | if (currentInsItemId) { |
| | | param = { [currentInsItemId]: this.param[currentInsItemId] } |
| | | } else { |
| | | param = this.param |
| | | // 按“模板id + 单元格坐标(r-c)”从当前模板快照出待保存参数 |
| | | buildParam() { |
| | | const param = {} |
| | | this.tableList.forEach(a => { |
| | | param[a.templateId] = {} |
| | | a.template.forEach(cell => { |
| | | const isEditable = |
| | | cell.v.ps != undefined && |
| | | typeof cell.v.ps.value === 'string' && |
| | | (cell.v.ps.value.includes('检验值') || |
| | | cell.v.ps.value === '计算值' || |
| | | cell.v.ps.value === '最终值' || |
| | | cell.v.ps.value === '设备名称') |
| | | if (!isEditable) { |
| | | return |
| | | } |
| | | saveUnqualifiedContext({ |
| | | param: JSON.stringify(param), |
| | | currentTable: this.currentTable, |
| | | sampleId: this.currentSample.id |
| | | }).then(res => { |
| | | this.$message.success('已保存') |
| | | }) |
| | | // 向 Worker 发送消息,开始处理逻辑 |
| | | this.worker.postMessage(JSON.stringify({ |
| | | modelType: this.sampleProduct[0].model, |
| | | type: 'saveData', |
| | | tableList: this.tableList, |
| | | param: this.param, |
| | | currentTable: this.currentTable |
| | | })); |
| | | if ( |
| | | cell.v.ps.value.includes('检验值') && |
| | | (cell.v.v === '' || cell.v.v === null || cell.v.v === undefined) |
| | | ) { |
| | | return |
| | | } |
| | | param[a.templateId][`${cell.r}-${cell.c}`] = { |
| | | v: cell.v.v, |
| | | u: cell.u |
| | | } |
| | | }) |
| | | }) |
| | | return param |
| | | }, |
| | | // 统一在这里保存数据 |
| | | saveInsContext() { |
| | | try { |
| | | if (!this.param) { |
| | | return |
| | | } |
| | | const param = this.buildParam() |
| | | this.param = param |
| | | let isNoTestValue = '' |
| | | this.tableList.forEach(a => { |
| | | a.template.forEach(cell => { |
| | | if ( |
| | | cell.v.ps != undefined && |
| | | typeof cell.v.ps.value === 'string' && |
| | | cell.v.ps.value.includes('检验值') && |
| | | (cell.v.v === '' || cell.v.v === null || cell.v.v === undefined) |
| | | ) { |
| | | isNoTestValue = 1 |
| | | } |
| | | }) |
| | | }) |
| | | saveUnqualifiedContext({ |
| | | param: JSON.stringify(param), |
| | | currentTable: this.currentTable, |
| | | sampleId: this.currentSample.id, |
| | | isNoTestValue: isNoTestValue |
| | | }).then(res => { |
| | | this.$message.success('已保存') |
| | | }) |
| | | // 向 Worker 发送消息,开始处理逻辑 |
| | | this.worker.postMessage(JSON.stringify({ |
| | | modelType: this.sampleProduct[0].model, |
| | | type: 'saveData', |
| | | tableList: this.tableList, |
| | | param: this.param, |
| | | currentTable: this.currentTable |
| | | })); |
| | | } catch (error) { |
| | | console.log(999, error); |
| | | } |
| | | }, |
| | | // 设备改变 |
| | | changeEquip(val, n, v) { |
| | | try { |
| | | // this.$set(n.v,'v',val) |
| | | this.tableList[0].arr.forEach((item, index) => { |
| | | item.forEach((m, i) => { |
| | | if (this.param[m.i]) { |
| | | this.param[m.i].state = 1 |
| | | changeEquip(val, n) { |
| | | const selectedDevices = Array.isArray(val) ? [...val] : [] |
| | | const deviceCodes = selectedDevices.join(',') |
| | | this.$set(n.v, 'v', selectedDevices) |
| | | this.tableList.forEach(table => { |
| | | (table.arr || []).forEach(row => { |
| | | row.forEach(cell => { |
| | | if (cell.i == n.i && cell.v.ps) { |
| | | if (cell.v.ps.value === '设备名称') { |
| | | this.$set(cell.v, 'v', [...selectedDevices]) |
| | | } else if (cell.v.ps.value === '设备编码') { |
| | | this.$set(cell.v, 'v', deviceCodes) |
| | | } |
| | | } |
| | | // if(m.i==n.i&&m.v.ps&&m.v.ps.value=='设备名称'&&v){ |
| | | // this.$set(m.v,'v',v) |
| | | // } |
| | | }) |
| | | }) |
| | | for (let i in this.param) { |
| | | if (this.param[i].state != 1) { |
| | | delete this.param[i] |
| | | } |
| | | } |
| | | // if(val&&v){ |
| | | // for (let i1 in this.param[n.i].equipName) { |
| | | // if (this.param[n.i].equipName[i1].i === n.i && this.param[n.i].equipName[i1].r === n.r) { |
| | | // this.$delete(this.param[n.i].equipValue[i1].v,'v') |
| | | // this.$set(this.param[n.i].equipValue[i1].v,'v',val) |
| | | // this.$delete(this.param[n.i].equipName[i1].v,'v') |
| | | // this.$set(this.param[n.i].equipName[i1].v,'v',v) |
| | | // } |
| | | // } |
| | | // } |
| | | // this.equipOptions为设备名称下拉框选项数据 |
| | | for (let i1 in this.param[n.i].equipName) { |
| | | if (this.param[n.i].equipName[i1].i === n.i && this.param[n.i].equipName[i1].r === n.r) { |
| | | this.$delete(this.param[n.i].equipValue[i1].v, 'v') |
| | | // 将数组赋值给设备编码 |
| | | this.$set(this.param[n.i].equipValue[i1].v, 'v', val.join(',')) |
| | | this.$delete(this.param[n.i].equipName[i1].v, 'v') |
| | | // 将数组赋值给设备编码 |
| | | this.$set(this.param[n.i].equipName[i1].v, 'v', val) |
| | | this.tableList[0].arr.forEach((item, index) => { |
| | | item.forEach((m) => { |
| | | if (m.i == n.i && m.v.ps && m.v.ps.value == '设备编码') { |
| | | this.$set(m.v, 'v', val.join(',')) |
| | | } |
| | | if (m.i == n.i && m.v.ps && m.v.ps.value == '设备名称') { |
| | | this.$set(m.v, 'v', val) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | // 保存数据 |
| | | this.saveInsContext(n.i) |
| | | } catch (e) { |
| | | console.log('changeEquip----', e) |
| | | } |
| | | }) |
| | | // 选择、移除、清空均由 change 事件触发,立即保存。 |
| | | this.saveInsContext() |
| | | }, |
| | | getAuthorizedPerson() { |
| | | selectUserCondition({ type: 1 }).then((res) => { |
| | |
| | | this.param = {} |
| | | this.fiberOptic = [] |
| | | this.currentFiberOptic = null; |
| | | this.currentFiberOpticTape.productList.forEach(a => { |
| | | this.param[a.id] = { |
| | | insValue: [], |
| | | comValue: [], |
| | | resValue: null, |
| | | equipValue: [], |
| | | equipName: [], |
| | | insResult: null |
| | | } |
| | | }) |
| | | this.fiberOpticTapeVisible = false; |
| | | let list = await this.getCurrentProduct(this.currentFiberOpticTape.id, 1) |
| | | this.getTableLists0(list) |
| | |
| | | } |
| | | this.currentKey2 = index |
| | | this.currentFiberOptic = this.HaveJson(this.fiberOptic[index - 1]) |
| | | this.currentFiberOptic.productList.forEach(a => { |
| | | this.param[a.id] = { |
| | | insValue: [], |
| | | comValue: [], |
| | | resValue: null, |
| | | equipValue: [], |
| | | equipName: [], |
| | | insResult: null |
| | | } |
| | | }) |
| | | this.param = {} |
| | | let list = await this.getCurrentProduct(this.currentFiberOptic.id, 2) |
| | | this.getTableLists0(list) |
| | | }, |