From 7e7a8e3b15df991b9c3fbd22b94534b1d1984e29 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 14 九月 2026 19:54:28 +0800
Subject: [PATCH] 新疆——新聚lims 1.检验任务详情逻辑重构,不需要判断结论逻辑,添加复杂运算逻辑
---
src/views/business/inspectionTask/inspection.vue | 906 ++++++++-----------------------------------------------
1 files changed, 140 insertions(+), 766 deletions(-)
diff --git a/src/views/business/inspectionTask/inspection.vue b/src/views/business/inspectionTask/inspection.vue
index e446166..94318dc 100644
--- a/src/views/business/inspectionTask/inspection.vue
+++ b/src/views/business/inspectionTask/inspection.vue
@@ -219,7 +219,9 @@
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 != '')
@@ -249,63 +251,8 @@
'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 === '璁惧鍚嶇О'
@@ -318,15 +265,6 @@
{{ 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 &&
@@ -946,17 +884,7 @@
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) => {
- this.param[a.id] = {
- insValue: [],
- comValue: [],
- resValue: null,
- equipValue: [],
- equipName: [],
- insResult: null,
- };
- });
+ this.param = {}; //鍒濆鍖栦紶鍒板悗绔殑鍙傛暟,鎸夆�滄ā鏉縤d + 鍗曞厓鏍煎潗鏍団�濆瓨
// 鍘婚噸妯℃澘锛岃繑鍥炴湁鍑犱釜妯℃澘
const mySet1 = new Set();
this.tableLists = this.currentSample.insProduct.filter((m) => {
@@ -1187,16 +1115,6 @@
// 鍒濆鍖栦紶閫掑埌鍚庣鐨勫弬鏁�
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;
@@ -1756,16 +1674,6 @@
// 鍒濆鍖栧悗绔紶鍙�
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;
@@ -1801,16 +1709,6 @@
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({
@@ -1919,24 +1817,6 @@
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锛堟帴鍙h繑鍥烇級": 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(
@@ -1972,255 +1852,18 @@
count++;
});
});
- // 鏈寰幆涓昏鏄帶鍒跺悎骞�,浠ュ強鎺у埗妫�楠岄」淇℃伅鏄惁灞曠ず鍑烘潵,浠ヤ究鍚庣画妫�楠�
+ // 鎸夊悗绔笅鍙戠殑鈥滄ā鏉縄D + 妯℃澘琛屽彿鈥濈洿鎺ョ粦瀹氭楠岄」锛屼笉鍋氬悕绉版瘮瀵癸紝涓嶉殣钘忎换浣曡
this.tableList.forEach((a) => {
- // 鏂拌仛璁㈠崟鐩存帴鎸夆�滄ā鏉縄D + 妯℃澘琛屽彿鈥濈粦瀹氭楠岃褰曪紝涓嶅啀鍖归厤鍒嗙被鍜屾楠屽瓙椤广��
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 = []; //鎵�鏈夋楠岄」鐨刬d
- 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) => {
- // 鑾峰彇鍒� 妫�楠岄」鍒嗙被+妫�楠岄」+妫�楠屽瓙椤圭殑鎷兼帴,濡傛灉妯℃澘閲岀殑淇℃伅璺熸帴鍙h繑鍥炵殑妫�楠岄」淇℃伅鑳藉鍖归厤鍒欏睍绀哄嚭鏉�
- 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 {
- // 濡傛灉鐩哥瓑,閭d箞璇存槑鎵惧埌浜�,骞朵笖鎶奿d瀛樿捣鏉�,鍚庣画妫�楠岄」涔熶細鍦ㄩ〉闈腑鏄剧ず鍑烘潵
- 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) {
- 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);
- }
- }
- }
- });
- // 鎿嶄綔鍒犻櫎
- 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 浠h〃鍚堝苟鐨勬暟閲�
@@ -2243,20 +1886,11 @@
}
});
});
- // 鏈寰幆涓昏鏄鍚庣浼犲弬杩涜鍒濆鍖�,鏍峰紡閫昏緫淇敼
+ // 鏈寰幆涓昏鍋氭牱寮忛�昏緫澶勭悊,鍙紪杈戝崟鍏冩牸鍒濆鍖�
this.tableList.forEach((a) => {
let arrs = [];
let set = new Set();
let count1 = 0;
- let conclusionList = []; //缁撹鍒楄〃
- let finalList = []; //鏈�缁堝�煎垪琛�
- // 缁撹涓庢渶缁堝�煎湪杩欓噷涓�涓�瀵瑰簲,浠ヤ笅涓や釜鍒楄〃闀垮害鑲畾鏄竴鏍风殑,濡傛灉鏈変笉涓�鏍�,閭d箞澶氬崐鏄ā鏉块厤缃緱闂
- 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 &&
@@ -2267,61 +1901,18 @@
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);
@@ -2349,112 +1940,56 @@
a.style.columnlen[i] === undefined ? 100 : a.style.columnlen[i];
}
});
- // 鏈寰幆涓昏鏄椤甸潰鍙婂悗绔紶鍙傝繘琛屽垵濮嬪寲璧嬪��
- this.currentSample.insProduct.forEach(async (a) => {
- // 灏氭棤妫�楠岀粨鏋滄椂锛屼繚鐣欏墠闈㈠垵濮嬪寲鐨勭┖鍊笺��
- const savedResult = a.insProductResult || {};
- try {
- // 璁$畻鍊艰祴鍊�
- let comValue = JSON.parse(savedResult.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(savedResult.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(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(savedResult.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) { }
- });
+ // 鎸夆�滄ā鏉縤d + 鍗曞厓鏍煎潗鏍�(r-c)鈥濆洖鏄惧凡淇濆瓨鐨勫��
+ this.initParamByCoordinate();
// 瀵筫xcel鍑芥暟杩涜澶勭悊
this.handleExcelMethod();
},
+ // 鎸夆�滄ā鏉縤d + 鍗曞厓鏍煎潗鏍�(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) {
@@ -2486,8 +2021,8 @@
);
// 鍏堜繚瀛樹富绾跨▼涓凡缁忚緭鍏ョ殑鍘熷鍊笺�俉orker 瀹屾垚璁$畻鍚庝細鍐嶆鍏ラ槦淇濆瓨璁$畻缁撴灉銆�
// 杩欐牱鍗充娇鐢ㄦ埛杈撳叆鍚庣珛鍗冲埛鏂般�佸垏鎹㈡垨杩斿洖锛屾渶鍚庣紪杈戠殑鍗曞厓鏍间篃涓嶄細涓㈠け銆�
- if (currentInsItemId) {
- this.saveInsContext(currentInsItemId);
+ if (n) {
+ this.saveInsContext();
}
} catch (error) {
console.log(444, error);
@@ -2501,36 +2036,13 @@
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":
@@ -2538,117 +2050,10 @@
// 鏇存柊鏁版嵁
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;
- }
- }
},
// 瀵笶XCEL鍑芥暟杩涜澶勭悊
handleExcelMethod() {
@@ -2692,14 +2097,6 @@
}
}
},
- // 鑾峰彇瑕佹眰鎻忚堪
- 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;
@@ -2740,14 +2137,6 @@
}
}
},
- // 鑾峰彇瑕佹眰鍊�
- 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) {
@@ -2766,17 +2155,6 @@
});
}
},
- // 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;
},
@@ -2970,68 +2348,86 @@
});
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;
- }
+ // 鎸夆�滄ā鏉縤d + 鍗曞厓鏍煎潗鏍�(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;
}
- let isNoTestValue = ''
- for (let key in param) {
- if (param[key]) {
- if (param[key].insValue?.length === 0) {
- isNoTestValue = 1
- } else {
- isNoTestValue = ''
- }
- }
+ if (
+ cell.v.ps.value.includes("妫�楠屽��") &&
+ (cell.v.v === "" || cell.v.v === null || cell.v.v === undefined)
+ ) {
+ return;
}
- const payload = {
- param: JSON.stringify(param),
- currentTable: this.currentTable,
- sampleId: this.currentSample.id,
- orderId: this.orderId,
- sonLaboratory: this.sonLaboratory,
- isNoTestValue: isNoTestValue
+ param[a.templateId][`${cell.r}-${cell.c}`] = {
+ v: cell.v.v,
+ u: cell.u,
};
- 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,
- })
- );
+ });
+ });
+ 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);
}
@@ -3043,21 +2439,9 @@
},
// 璁惧鏀瑰彉
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) => {
@@ -3071,8 +2455,8 @@
});
});
});
- // 閫夋嫨銆佺Щ闄ゃ�佹竻绌哄潎鐢� change 浜嬩欢瑙﹀彂锛岀珛鍗充繚瀛樺綋鍓嶆楠岄」銆�
- this.saveInsContext(n.i);
+ // 閫夋嫨銆佺Щ闄ゃ�佹竻绌哄潎鐢� change 浜嬩欢瑙﹀彂锛岀珛鍗充繚瀛樸��
+ this.saveInsContext();
},
getAuthorizedPerson() {
selectUserCondition({ type: 1 }).then((res) => {
@@ -3132,16 +2516,6 @@
// 鍒濆鍖栧悗绔紶鍙�
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();
// 鏇存柊鍒板绾跨▼
--
Gitblit v1.9.3