| | |
| | | <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 |
| | | <el-select v-model="n.v.v" :disabled="state > 1" class="table_input" filterable multiple clearable |
| | | placeholder="设备" remote @change="(val) => changeEquip(val, n)" |
| | | @visible-change="(e) => getEquipOptions(e, n.i)"> |
| | | <el-option v-for="item in equipOptions" :key="item.value" :label="item.label" |
| | |
| | | handleTableData() { |
| | | this.excelMethodList = []; //excel函数列表 |
| | | this.widthList = this.tableList[0].style.columnlen; //页面宽度--根据模板来的 |
| | | // 对照接口返回的检验项模板 ID 与页面实际参与匹配的模板 ID。 |
| | | this.tableList.forEach((template) => { |
| | | console.log("[templateId核对]", { |
| | | sampleId: this.currentSample.id, |
| | | currentTable: this.currentTable, |
| | | templateName: template.templateName, |
| | | }); |
| | | console.table(this.currentSample.insProduct.map((product) => ({ |
| | | 检验项ID: product.id, |
| | | 检验项: product.inspectionItem, |
| | | 检验子项: product.inspectionItemSubclass, |
| | | "检验项templateId(接口返回)": product.templateId, |
| | | 检验项ID类型: typeof product.templateId, |
| | | "当前模板templateId": template.templateId, |
| | | 模板ID类型: typeof template.templateId, |
| | | "是否一致(严格比较)": product.templateId === template.templateId, |
| | | }))); |
| | | }); |
| | | // 本次循环主要做页面渲染层面的处理--单元格合并预处理 |
| | | this.tableList.forEach((a) => { |
| | | let mcList = a.template.filter( |
| | |
| | | count2++; |
| | | } |
| | | if (count2 == this.currentSample.insProduct.length) { |
| | | console.warn("[模板行未匹配] 即将隐藏该行", { |
| | | sampleId: this.currentSample.id, |
| | | templateId: a.templateId, |
| | | templateName: a.templateName, |
| | | 模板行号: b.r + 1, |
| | | 模板拼接名称: str, |
| | | 模板标记单元格: a.template |
| | | .filter((cell) => cell.r === b.r && cell.v.ps != undefined) |
| | | .map((cell) => ({ |
| | | 列号: cell.c + 1, |
| | | 标记: cell.v.ps.value, |
| | | 文字: cell.v.v, |
| | | })), |
| | | }); |
| | | console.table(this.currentSample.insProduct |
| | | .filter((product) => product.templateId === a.templateId) |
| | | .map((product) => { |
| | | const name = [product.inspectionItemClass, product.inspectionItem, |
| | | product.inspectionItemSubclass] |
| | | .map((value) => value == null ? "" : value.replace(/\s*/g, "")) |
| | | .join(""); |
| | | return { |
| | | 检验项ID: product.id, |
| | | 检验项分类: product.inspectionItemClass, |
| | | 检验项: product.inspectionItem, |
| | | 检验子项: product.inspectionItemSubclass, |
| | | 接口拼接名称: name, |
| | | 模板拼接名称: str, |
| | | 名称是否一致: name === str, |
| | | }; |
| | | })); |
| | | dels.add(b.r); |
| | | } |
| | | } |
| | |
| | | }); |
| | | // 本次循环主要是对页面及后端传参进行初始化赋值 |
| | | this.currentSample.insProduct.forEach(async (a) => { |
| | | // 尚无检验结果时,保留前面初始化的空值。 |
| | | const savedResult = a.insProductResult || {}; |
| | | try { |
| | | // 计算值赋值 |
| | | let comValue = JSON.parse(a.insProductResult.comValue); |
| | | let comValue = JSON.parse(savedResult.comValue || "[]"); |
| | | for (var i = 0; i < comValue.length; i++) { |
| | | if ( |
| | | this.param[a.id].comValue.find( |
| | |
| | | } catch (e) { } |
| | | try { |
| | | // 检验值赋值 |
| | | let insValue = JSON.parse(a.insProductResult.insValue); |
| | | let insValue = JSON.parse(savedResult.insValue || "[]"); |
| | | for (let i = 0; i < insValue.length; i++) { |
| | | if ( |
| | | this.param[a.id].insValue.find( |
| | |
| | | } catch (e) { } |
| | | try { |
| | | // 设备编号赋值 |
| | | let equipValue = JSON.parse(a.insProductResult.equipValue); |
| | | let equipValue = JSON.parse(savedResult.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); |
| | | let equipName = JSON.parse(savedResult.equipName || "[]"); |
| | | for (let i = 0; i < equipName.length; i++) { |
| | | equipName[i].v !== "" && |
| | | equipName[i].v.map((val) => { |
| | |
| | | } |
| | | }, |
| | | // 设备改变 |
| | | 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 itemParam = this.param[n.i]; |
| | | if (!itemParam) { |
| | | this.$message.error("设备未关联检验项,请刷新页面后重试"); |
| | | return; |
| | | } |
| | | const selectedDevices = Array.isArray(val) ? [...val] : []; |
| | | const deviceCodes = selectedDevices.join(","); |
| | | this.$set(n.v, "v", selectedDevices); |
| | | // 名称与编码单元格可能数量不同,分别更新,避免下标越界中断保存。 |
| | | (itemParam.equipName || []).forEach((cell) => { |
| | | this.$set(cell.v, "v", [...selectedDevices]); |
| | | }); |
| | | (itemParam.equipValue || []).forEach((cell) => { |
| | | this.$set(cell.v, "v", deviceCodes); |
| | | }); |
| | | 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(n.i); |
| | | }, |
| | | getAuthorizedPerson() { |
| | | selectUserCondition({ type: 1 }).then((res) => { |