| | |
| | | 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 != '') |
| | |
| | | 'getDataType' |
| | | ) |
| | | " /> |
| | | <!-- <el-select v-else-if="getInspectionValueType(n.i) == 5" v-model="n.v.v" :disabled="state > 1 || |
| | | getInspectionItemType(n.i) == 1 || |
| | | (n.u != userId && n.u != undefined && n.u != '') |
| | | " class="table_input" @change="(m) => |
| | | changeInput( |
| | | m, |
| | | `${item.templateId}-${n.r}-${n.c}-${n.i}`, |
| | | n, |
| | | 'getDataType' |
| | | ) |
| | | " @visible-change="(e) => getDic(e, n.i)"> |
| | | <el-option v-for="(e, i) in enumList" :key="i" :label="e.label" :value="e.value"></el-option> |
| | | </el-select> --> |
| | | <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', |
| | | 'changeSelect' |
| | | ) |
| | | "> |
| | | <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 === '设备名称' |
| | |
| | | {{ 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 && |
| | |
| | | loading: false, |
| | | ps: {}, |
| | | param: {}, |
| | | saveQueue: null, |
| | | currentKey: 1, |
| | | currentKey0: 1, |
| | | currentKey1: 1, |
| | |
| | | let list = await this.getCurrentProduct(this.currentSample.id, 0); |
| | | this.currentSample.insProduct = this.HaveJson(list); //赋值当前样品的检验项 |
| | | this.param = {}; //初始化传到后端的参数 |
| | | this.currentSample.insProduct.forEach((a, j) => { |
| | | this.param[a.id] = { |
| | | insValue: [], |
| | | comValue: [], |
| | | resValue: null, |
| | | equipValue: [], |
| | | equipName: [], |
| | | insResult: null, |
| | | }; |
| | | }); |
| | | // 去重模板,返回有几个模板 |
| | | const mySet1 = new Set(); |
| | | this.tableLists = this.currentSample.insProduct.filter((m) => { |
| | |
| | | // 初始化传递到后端的参数 |
| | | this.param = {}; |
| | | this.changeType = 0; |
| | | this.currentSample.insProduct.forEach((a) => { |
| | | this.param[a.id] = { |
| | | insValue: [], |
| | | comValue: [], |
| | | resValue: null, |
| | | equipValue: [], |
| | | equipName: [], |
| | | insResult: null, |
| | | }; |
| | | }); |
| | | if (this.currentSample.index == undefined) |
| | | this.currentSample["index"] = 1; |
| | | let bushing = this.currentSample.bushing; |
| | |
| | | // 初始化后端传参 |
| | | this.param = {}; |
| | | this.changeType = 0; |
| | | this.currentSample.insProduct.forEach((a, j) => { |
| | | this.param[a.id] = { |
| | | insValue: [], |
| | | comValue: [], |
| | | resValue: null, |
| | | equipValue: [], |
| | | equipName: [], |
| | | insResult: null, |
| | | }; |
| | | }); |
| | | // 处理页面列表数据 |
| | | this.getTableLists(); |
| | | this.currentKey = row.index; |
| | |
| | | let list = await this.getCurrentProduct(m, type, cableTag); |
| | | if (list && 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({ |
| | |
| | | count++; |
| | | }); |
| | | }); |
| | | // 本次循环主要是控制合并,以及控制检验项信息是否展示出来,以便后续检验 |
| | | // 按后端下发的“模板ID + 模板行号”直接绑定检验项,不做名称比对,不隐藏任何行 |
| | | this.tableList.forEach((a) => { |
| | | // 新聚订单直接按“模板ID + 模板行号”绑定检验记录,不再匹配分类和检验子项。 |
| | | const directProducts = this.currentSample.insProduct.filter( |
| | | (product) => product.templateId === a.templateId && |
| | | product.templateRowIndex !== null && product.templateRowIndex !== undefined |
| | | ); |
| | | if (directProducts.length > 0) { |
| | | directProducts.forEach((product) => { |
| | | a.template.forEach((cell) => { |
| | | if (cell.r === product.templateRowIndex) { |
| | | cell.i = product.id; |
| | | } |
| | | }); |
| | | directProducts.forEach((product) => { |
| | | a.template.forEach((cell) => { |
| | | if (cell.r === product.templateRowIndex) { |
| | | cell.i = product.id; |
| | | } |
| | | }); |
| | | return; |
| | | } |
| | | 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) { |
| | | if (c.v.v) { |
| | | c.v.v = c.v.v.replace(/\s*/g, ""); |
| | | } |
| | | str += c.v.v; |
| | | count4 += 1; |
| | | } |
| | | } else if ( |
| | | c.v.ps != undefined && |
| | | c.v.ps.value === "检验子项" |
| | | ) { |
| | | if (count4 === 1) { |
| | | if (c.v.v) { |
| | | c.v.v = c.v.v.replace(/\s*/g, ""); |
| | | } |
| | | str += c.v.v; |
| | | count4 += 1; |
| | | } |
| | | } |
| | | } else if (isThree == 1) { |
| | | if (c.v.ps != undefined && c.v.ps.value === "检验项分类") { |
| | | if (count4 === 0) { |
| | | if (c.v.v) { |
| | | c.v.v = c.v.v.replace(/\s*/g, ""); |
| | | } |
| | | str += c.v.v; |
| | | count4 += 1; |
| | | } |
| | | } else if (c.v.ps != undefined && c.v.ps.value === "检验项") { |
| | | if (count4 === 1) { |
| | | if (c.v.v) { |
| | | c.v.v = c.v.v.replace(/\s*/g, ""); |
| | | } |
| | | str += c.v.v; |
| | | count4 += 1; |
| | | } |
| | | } else if ( |
| | | c.v.ps != undefined && |
| | | c.v.ps.value === "检验子项" |
| | | ) { |
| | | if (count4 === 2) { |
| | | if (c.v.v) { |
| | | c.v.v = c.v.v.replace(/\s*/g, ""); |
| | | } |
| | | str += c.v.v; |
| | | count4 += 1; |
| | | } |
| | | } |
| | | } |
| | | if (str === "机械性能干态拉伸强度(纵向)") { |
| | | if (c.v.ps != undefined && c.v.ps.value === "单位") { |
| | | if (c.v.v) { |
| | | c.v.v = c.v.v.replace(/\s*/g, ""); |
| | | } |
| | | 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; |
| | | inspectionItemClass = inspectionItemClass.replace(/\s*/g, ""); |
| | | let inspectionItem = |
| | | this.currentSample.insProduct[i].inspectionItem == null || |
| | | this.currentSample.insProduct[i].inspectionItem == undefined |
| | | ? "" |
| | | : this.currentSample.insProduct[i].inspectionItem; |
| | | inspectionItem = inspectionItem.replace(/\s*/g, ""); |
| | | let inspectionItemSubclass = |
| | | this.currentSample.insProduct[i].inspectionItemSubclass == |
| | | null || |
| | | this.currentSample.insProduct[i].inspectionItemSubclass == |
| | | undefined |
| | | ? "" |
| | | : this.currentSample.insProduct[i].inspectionItemSubclass; |
| | | inspectionItemSubclass = inspectionItemSubclass.replace( |
| | | /\s*/g, |
| | | "" |
| | | ); |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | // 操作删除 |
| | | 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 代表合并的数量 |
| | |
| | | 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 && |
| | |
| | | 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("检验值") |
| | | (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); |
| | |
| | | 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++) { |
| | | if ( |
| | | this.param[a.id].comValue.find( |
| | | (m) => m.c == comValue[i].c && m.r == comValue[i].r |
| | | ) |
| | | ) { |
| | | this.param[a.id].comValue.find( |
| | | (m) => m.c == comValue[i].c && m.r == comValue[i].r |
| | | ).v.v = this.toFixed( |
| | | comValue[i].v, |
| | | this.param[a.id].comValue.find( |
| | | (m) => m.c == comValue[i].c && m.r == comValue[i].r |
| | | ).v.ct |
| | | ); |
| | | } else if (!comValue[i].c || !comValue[i].r) { |
| | | 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); |
| | | for (let i = 0; i < equipValue.length; i++) { |
| | | // 普通设备赋值 |
| | | 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; |
| | | } |
| | | }); |
| | | } |
| | | for (let i = 0; i < equipName.length; i++) { |
| | | // 普通设备名称赋值 |
| | | 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, changeSelect) { |
| | | 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) { |
| | |
| | | currentInsItem: n, |
| | | }) |
| | | ); |
| | | // 先保存主线程中已经输入的原始值。Worker 完成计算后会再次入队保存计算结果。 |
| | | // 这样即使用户输入后立即刷新、切换或返回,最后编辑的单元格也不会丢失。 |
| | | if (n) { |
| | | this.saveInsContext(); |
| | | } |
| | | } catch (error) { |
| | | console.log(444, error); |
| | | } |
| | |
| | | case "saveInsContext": |
| | | this.$nextTick(() => { |
| | | const resultValue = workerResult.value; |
| | | // this.$delete(this.tableList[0],'arr') |
| | | this.$set( |
| | | this.tableList[0], |
| | | "arr", |
| | | resultValue.tableList[0].arr |
| | | ); |
| | | this.param = resultValue.param; |
| | | // 特殊处理一下结论,会有这种特殊情况 |
| | | 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 sourceInsItemId = |
| | | resultValue.sourceInsItemId != null && |
| | | resultValue.sourceInsItemId !== "" |
| | | ? resultValue.sourceInsItemId |
| | | : currentInsItemId; |
| | | this.saveInsContext([ |
| | | sourceInsItemId, |
| | | resultValue.currentInsItemId, |
| | | ]); |
| | | this.saveInsContext(); |
| | | }); |
| | | break; |
| | | case "tableList": |
| | |
| | | // 更新数据 |
| | | this.$delete(this.tableList[0], "arr"); |
| | | this.$set(this.tableList[0], "arr", workerResult.value[0].arr); |
| | | // this.param = this.result.value.param |
| | | }); |
| | | break; |
| | | case "getCurrentInsProduct": |
| | | // 更新页面数据 |
| | | this.getCurrentInsProduct(workerResult.value); |
| | | break; |
| | | } |
| | | }; |
| | | // 保存数据 |
| | | setTimeout(() => { |
| | | if (changeSelect) { |
| | | this.saveInsContext(currentInsItemId); |
| | | } |
| | | }, 200); |
| | | }, |
| | | // 根据后端传参更新页面数据 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() { |
| | |
| | | } |
| | | } |
| | | }, |
| | | // 获取要求描述 |
| | | getTell(id) { |
| | | for (var a in this.currentSample.insProduct) { |
| | | if (this.currentSample.insProduct[a].id == id) { |
| | | return this.currentSample.insProduct[a].tell; |
| | | } |
| | | } |
| | | }, |
| | | // 动态获取单元格宽度 |
| | | handleWidth(n) { |
| | | let sum = 0; |
| | |
| | | } |
| | | } |
| | | }, |
| | | // 获取要求值 |
| | | getAsk(id) { |
| | | for (var a in this.currentSample.insProduct) { |
| | | if (this.currentSample.insProduct[a].id == id) { |
| | | return this.currentSample.insProduct[a].ask; |
| | | } |
| | | } |
| | | }, |
| | | // 获取所有设备 |
| | | getEquipOptions(e, id) { |
| | | if (e) { |
| | |
| | | }); |
| | | } |
| | | }, |
| | | // getDic(e, id) { |
| | | // if (e) { |
| | | // for (var a in this.currentSample.insProduct) { |
| | | // if (this.currentSample.insProduct[a].id == id) { |
| | | // let str = this.currentSample.insProduct[a].dic; |
| | | // this.selectEnumByCategoryOfSelect(str); |
| | | // return str; |
| | | // } |
| | | // } |
| | | // } |
| | | // }, |
| | | openAddCheck() { |
| | | this.addCheck = true; |
| | | }, |
| | |
| | | }); |
| | | return; |
| | | }, |
| | | // 统一在这里保存数据 |
| | | saveInsContext(currentInsItemIds) { |
| | | try { |
| | | if (this.param) { |
| | | const ids = (Array.isArray(currentInsItemIds) |
| | | ? currentInsItemIds |
| | | : [currentInsItemIds] |
| | | ) |
| | | .filter((id) => id != null && id !== "") |
| | | .map((id) => String(id)); |
| | | let param = this.param; |
| | | if (ids.length > 0) { |
| | | param = {}; |
| | | [...new Set(ids)].forEach((id) => { |
| | | if (this.param[id]) { |
| | | param[id] = this.param[id]; |
| | | } |
| | | }); |
| | | if (Object.keys(param).length === 0) { |
| | | return; |
| | | } |
| | | // 按“模板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; |
| | | } |
| | | saveInsContext({ |
| | | param: JSON.stringify(param), |
| | | currentTable: this.currentTable, |
| | | sampleId: this.currentSample.id, |
| | | orderId: this.orderId, |
| | | sonLaboratory: this.sonLaboratory |
| | | }).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; |
| | | } |
| | | }); |
| | | }); |
| | | const payload = { |
| | | param: JSON.stringify(param), |
| | | currentTable: this.currentTable, |
| | | sampleId: this.currentSample.id, |
| | | orderId: this.orderId, |
| | | sonLaboratory: this.sonLaboratory, |
| | | isNoTestValue: isNoTestValue |
| | | }; |
| | | const previousSave = this.saveQueue || Promise.resolve(); |
| | | this.saveQueue = previousSave |
| | | .catch(() => undefined) |
| | | .then(() => saveInsContext(payload)) |
| | | .then(() => { |
| | | this.$message.success("已保存"); |
| | | }) |
| | | .catch((error) => { |
| | | console.error("检验数据保存失败", error); |
| | | this.$message.error("检验数据保存失败,请重试"); |
| | | }); |
| | | // 向 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]; |
| | | } |
| | | } |
| | | // 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.changeType = 0; |
| | | this.currentSample.insProduct.forEach((a, j) => { |
| | | this.param[a.id] = { |
| | | insValue: [], |
| | | comValue: [], |
| | | resValue: null, |
| | | equipValue: [], |
| | | equipName: [], |
| | | insResult: null, |
| | | }; |
| | | }); |
| | | // 页面数据处理 |
| | | this.getTableLists(); |
| | | // 更新到多线程 |