From 2beadb3879986120cb8ddf9ec660175d5b17911e Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期四, 20 二月 2025 14:42:35 +0800 Subject: [PATCH] 检验任务搬迁40% --- src/components/Table/lims-table.vue | 233 +-- src/utils/request.js | 250 ++- src/InspectionWorker.worker.js | 2352 +++++++++++++++++++++++++++++++++++++ src/api/business/inspectionTask.js | 9 vue.config.js | 15 src/DataWorker.worker.js | 160 ++ package.json | 3 src/views/business/inspectionTask/inspection.vue | 645 ++++----- src/router/index.js | 20 9 files changed, 3,043 insertions(+), 644 deletions(-) diff --git a/package.json b/package.json index 823e179..ec535d5 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,8 @@ "sass-loader": "10.1.1", "script-ext-html-webpack-plugin": "2.1.5", "svg-sprite-loader": "5.1.1", - "vue-template-compiler": "2.6.12" + "vue-template-compiler": "2.6.12", + "worker-loader": "^3.0.8" }, "engines": { "node": ">=8.9", diff --git a/src/DataWorker.worker.js b/src/DataWorker.worker.js new file mode 100644 index 0000000..b2e99c1 --- /dev/null +++ b/src/DataWorker.worker.js @@ -0,0 +1,160 @@ +// 姝ょ嚎绋嬩负鏁版嵁閲囬泦绾跨▼ + +// 淇濆瓨鏁版嵁 +// 鏁版嵁閲囬泦淇℃伅 +let dataAcquisitionInfo = null; +// 鏁版嵁鍒楄〃 +let list = null; +// 浼犻�掑埌涓荤嚎绋嬬殑鏁版嵁 +let result = { + method:'', + value:null +} +// 浼樺寲鏁伴噰杈冨鏁版嵁鏃�--璁板綍鏁伴噰椤圭洰鐨処d鏁扮粍锛岀洰鐨勬槸鍙栨渶鍚庝竴涓暟閲囬」鐩紝浼犲埌涓荤嚎绋嬭繘琛屾壒閲忕殑鏁版嵁閲囬泦淇濆瓨 +let arrSpecial = [] +// 鎺ユ敹涓荤嚎绋嬩紶閫掕繃鏉ョ殑鏁版嵁 +self.onmessage = function(event) { + const data = JSON.parse(event.data); + dataAcquisitionInfo = data.dataAcquisitionInfo; + list = data.list; + // console.log(111,dataAcquisitionInfo) + arrSpecial = [] + // 澶勭悊鏁版嵁 + handleData() +} + +function handleData(){ + // 閬嶅巻鏁版嵁鍒楄〃 + list.forEach((item,index)=>{ + let num = 0; + let str = '' + item.forEach(m=>{ + if(m.v.ps&&(m.v.ps.value=='妫�楠屽瓙椤�'||m.v.ps.value=='妫�楠岄」'||m.v.ps.value=='妫�楠岄」鍒嗙被')){ + if(m.v.ps&&m.v.ps.value=='妫�楠岄」鍒嗙被'){ + if(num==0){ + num++ + str = m.v.v+',' + } + } + if(m.v.ps&&m.v.ps.value=='妫�楠岄」'){ + if(num==1){ + str = str+m.v.v + ',' + num++ + } else { + str = m.v.v+',' + num++ + } + } + if(m.v.ps&&m.v.ps.value=='妫�楠屽瓙椤�'){ + str = str+m.v.v + } + // 涓婇潰鍦ㄨ褰曟楠岄」+妫�楠屽瓙椤圭殑鍚嶇О锛屽鏋滄暟閲囧寘鍚楠岄」+妫�楠屽瓙椤圭殑鏁版嵁锛屽垯鎵ц + if(dataAcquisitionInfo[str]){ + let num = 0;//璇ユ楠岄」瀵瑰簲妫�楠屽�肩殑涓暟锛岀敤鐢ㄥ垽鏂渶澶氭湁澶氬皯涓楠屽�硷紝濡傛灉澶氭閲囬泦瓒呰繃浜嗚涓暟锛屽垯璧嬪�肩粰鏈�鍚庝竴涓楠屽�� + list[index].forEach(n=>{ + if(n.v.ps&&n.v.ps.value&&typeof n.v.ps.value == 'string'&&n.v.ps.value.includes('妫�楠屽��')){ + num++ + } + }) + list[index].forEach((n,i)=>{ + if(n.v.ps&&n.v.ps.value&&typeof n.v.ps.value == 'string'&&n.v.ps.value.includes('妫�楠屽��')){ + let arr = n.v.ps.value.split('鍊�') + if(Array.isArray(dataAcquisitionInfo[str].value)){ + // 濡傛灉鏁版嵁婧愪负鏁扮粍锛屽垯鎵ц + for (let i = 0; i < dataAcquisitionInfo[str].value.length; i++) { + if(i+1==arr[1]){ + // 璧嬪�兼暟閲囦紭鍖栨楠岄」鍒楄〃 + arrSpecial.push(n.i) + setTimeout(()=>{ + let num0 = 0 + if(n.v.ct&&n.v.ct.fa&&typeof n.v.ct.fa == 'string'&&n.v.ct.fa.includes('.')){ + // 淇濈暀妯℃澘閰嶇疆鐨勫皬鏁扮偣浣嶆暟 + let str0 = n.v.ct.fa.split('.')[1] + num0 = str0.length + n.v.v = dataAcquisitionInfo[str].value[i]?Number(dataAcquisitionInfo[str].value[i]).toFixed(num0):dataAcquisitionInfo[str].value[i] + }else{ + // 鐩存帴璧嬪�� + n.v.v = dataAcquisitionInfo[str].value[i] + } + // 浼犻�掔粰涓荤嚎绋� + result = { + method:'changeInput', + value:{ + list:list, + n:n + } + } + self.postMessage(JSON.stringify(result)) + },2000) + } + } + }else{ + // 濡傛灉鏁版嵁婧愪负瀛楃鎴栨暟瀛楋紝鍒欐墽琛� + if(arr[1] ==dataAcquisitionInfo[str].frequency){ + // 濡傛灉鏁伴噰娆℃暟绛変簬妫�楠屽�煎簭鍙凤紝鍒欒祴鍊肩粰褰撳墠妫�楠屽�� + arrSpecial.push(n.i) + setTimeout(()=>{ + let num0 = 0 + if(n.v.ct&&n.v.ct.fa&&typeof n.v.ct.fa == 'string'&&n.v.ct.fa.includes('.')){ + // 淇濈暀妯℃澘閰嶇疆鐨勫皬鏁扮偣浣嶆暟 + let str0 = n.v.ct.fa.split('.')[1] + num0 = str0.length + n.v.v = dataAcquisitionInfo[str].value?Number(dataAcquisitionInfo[str].value).toFixed(num0):dataAcquisitionInfo[str].value + }else{ + // 鐩存帴璧嬪�� + n.v.v = dataAcquisitionInfo[str].value + } + // 浼犻�掔粰涓荤嚎绋� + result = { + method:'changeInput', + value:{ + list:list, + n:n + } + } + self.postMessage(JSON.stringify(result)) + },2000) + }else if(Number(dataAcquisitionInfo[str].frequency)>num){ + // 濡傛灉鏁伴噰娆℃暟澶т簬妫�楠屽�煎簭鍙凤紝鍒欒祴鍊肩粰鏈�鍚庝竴涓楠屽�� + if(n.v.ps.value.includes(num)){ + arrSpecial.push(n.i) + setTimeout(()=>{ + let num0 = 0 + if(n.v.ct&&n.v.ct.fa&&typeof n.v.ct.fa == 'string'&&n.v.ct.fa.includes('.')){ + // 淇濈暀妯℃澘閰嶇疆鐨勫皬鏁扮偣浣嶆暟 + let str0 = n.v.ct.fa.split('.')[1] + num0 = str0.length + n.v.v = dataAcquisitionInfo[str].value?Number(dataAcquisitionInfo[str].value).toFixed(num0):dataAcquisitionInfo[str].value + }else{ + // 鐩存帴璧嬪�� + n.v.v = dataAcquisitionInfo[str].value + } + // 浼犻�掔粰涓荤嚎绋� + result = { + method:'changeInput', + value:{ + list:list, + n:n + } + } + self.postMessage(JSON.stringify(result)) + },2000) + } + } + } + } + }) + } + } + }) + }) + // if(arrSpecial[arrSpecial.length-1]){ + // //浼樺寲鏁伴噰杈冨鏁版嵁鏃�-璁板綍鏈�鍚庝竴涓楠岄」鐨刬d锛岀敤浜庡悗缁鐞� + // setTimeout(()=>{ + // result = { + // getDataTypeId:arrSpecial[arrSpecial.length-1], + // } + // self.postMessage(JSON.stringify(result)) + // },0) + // } +} diff --git a/src/InspectionWorker.worker.js b/src/InspectionWorker.worker.js new file mode 100644 index 0000000..c8e0764 --- /dev/null +++ b/src/InspectionWorker.worker.js @@ -0,0 +1,2352 @@ +// 澶氱嚎绋嬮噷闈㈤渶瑕佷繚瀛樼殑鏁版嵁 +let code = ""; +// 琛ㄦ牸鏁版嵁锛堟覆鏌擄級 +let tableList = null; +// 鏂规硶鍒楄〃 +let excelMethodList = []; +// excel鍧愭爣姣旇緝鍒楄〃 +let comparisonList = []; +// 褰撳墠鏍峰搧淇℃伅 +let currentSample = {}; +// 褰撳墠椤圭洰锛氭娴嬩腑蹇冦�佽澶囩數缂� +let PROJECT = ""; +// 濂楃 +let bushing = ""; +// 澶氱嚎绋嬩紶閫掑埌涓荤嚎绋嬬殑鏁版嵁 +let result = { + method: "", + value: null, +}; + +let modelType = ""; + +// 淇濆瓨鏃朵紶鍒板悗绔弬鏁� +let param = null; +// 褰撳墠鐨勬ā鏉� +let currentTable = ""; +// 浼樺寲鏁伴噰杈冨鏁版嵁鏃�-璁板綍鏈�鍚庝竴涓楠岄」鐨刬d +let getDataTypeId = null; +//褰撳墠妫�楠岄」 +let currentInsItem = null; +// 鎺ユ敹鍒颁富绾跨▼澶勭悊閫昏緫鐨勬秷鎭� +self.onmessage = function (event) { + console.log(2222, event); + // 淇濆瓨涓荤嚎绋嬩紶杩囨潵鐨勫�� + const data = JSON.parse(event.data); + if (currentTable != data.currentTable) { + // 妫�楠屾ā鏉挎敼鍙樺悗闇�瑕佸埛鏂拌〃鏍� + tableList = data.tableList; + } + currentTable = data.currentTable; + if (data.type && data.type == "saveData") { + // 鏇存柊琛ㄦ牸鏁版嵁鍜屼紶閫掑埌鍚庣鐨勫弬鏁� + tableList = data.tableList; + param = data.param; + return; + } + if (data.bushing && data.bushing != bushing && data.type == "saveData") { + // 鏇存柊琛ㄦ牸鏁版嵁銆佷紶閫掑埌鍚庣鐨勫弬鏁板拰濂楃鏁版嵁 + tableList = data.tableList; + param = data.param; + bushing = data.bushing; + return; + } + modelType = data.modelType; + code = data.code; + if (data.getDataTypeId) { + // 璁板綍 浼樺寲鏁伴噰杈冨鏁版嵁鏃�-璁板綍鏈�鍚庝竴涓楠岄」鐨刬d + getDataTypeId = data.getDataTypeId; + } else { + getDataTypeId = null; + } + if (tableList) { + // 濡傛灉琛ㄦ牸鏁版嵁瀛樺湪锛屽垯鏇存柊褰撳墠淇敼妫�楠岄」鐨勮〃鏍兼暟鎹� + let str = code.split("-"); + let r = str[1]; + let c = str[2]; + tableList[0].arr.forEach((item, index) => { + item.forEach((m, i) => { + if (m.c == c && m.r == r) { + tableList[0].arr[index] = data.tableList[0].arr[index]; + } + }); + }); + } else { + // 濡傛灉鍒濆鍖栬〃鏍兼暟鎹笉瀛樺湪锛岀洿鎺ヨ祴鍊� + tableList = data.tableList; + } + if (param) { + // 濡傛灉浼犻�掑埌鍚庣鐨勫弬鏁板瓨鍦紝鍒欐洿鏂板綋鍓嶄慨鏀规楠岄」鐨勪紶閫掑埌鍚庣鐨勫弬鏁� + let str = code.split("-"); + let pId = str[3]; + param[pId] = data.param[pId]; + } else { + // 鍒濆鍖栦紶閫掑埌鍚庣鐨勫弬鏁� + param = data.param; + } + if (data.currentInsItem) { + currentInsItem = data.currentInsItem; + } + // 鏇存柊鏂规硶鍒楄〃銆佸潗鏍囨瘮杈冨垪琛ㄣ�佸綋鍓嶆牱鍝佷俊鎭�侀」鐩� + excelMethodList = JSON.parse(JSON.stringify(data.excelMethodList)); + comparisonList = JSON.parse(JSON.stringify(data.comparisonList)); + currentSample = JSON.parse(JSON.stringify(data.currentSample)); + PROJECT = data.PROJECT; + // 鎵ц璁$畻鏂规硶 + changeInput("", code); +}; + +function changeInput(m, code) { + let str = code.split("-"); + let r = str[1]; //褰撳墠琛� + let c = str[2]; //褰撳墠鍒� + let id = str[0]; + let pId = str[3]; //褰撳墠妫�楠岄」id锛宲aram[pId]涓哄綋鍓嶆楠岄」鐨勬墍鏈夊�硷紝鍖呭惈锛氳繃绋嬪�糹nsValue銆佽绠楀�糲omValue銆佽澶囩紪鐮乪quipValue銆佽澶囧悕绉癳quipName銆佹渶缁堝�紃esValue銆佺粨璁篿nsResult + var list = []; //涓�涓弻灞傛暟缁勶紝閲岄潰淇濆瓨鏈夊綋鍓嶉〉闈㈡覆鏌撶殑鎵�鏈夋暟鎹� + // 璧嬪�煎綋鍓嶆ā鏉跨殑琛ㄦ牸鏁版嵁 + for (let a in tableList) { + if (tableList[a].templateId == id) { + list = tableList[a].arr; + break; + } + } + let isToExponential = ""; //鏄惁涓虹瀛﹁鏁版硶 + let list2 = []; //涓�涓暟缁勶紝閲岄潰淇濆瓨鏈夊綋鍓嶆楠岄」鐨勬墍鏈夊弬鏁板�� + let isPoint = ""; //鏄惁涓哄皬鏁扮偣 + let inputType = null; + let currentInsItemId = ""; + let isSave = "true"; + // 寰幆鎵�鏈塭xcel鏂规硶锛屾壘鍒板綋鍓嶈銆佸垪鐨勬楠岄」锛屽鏋滄鍗曞厓鏍硷紙r,c锛夋槸鏌愪釜excel鏂规硶閲岄潰鐨勫弬鏁帮紝鍒欐墽琛屾鏂规硶 + const index = excelMethodList.findIndex((item) => item.r == r); + excelMethodList.forEach((item) => { + inputType = + item.valueList && + item.valueList.length > 0 && + item.valueList.find((m) => m.r == r && m.c == c); + // item.valueList 鏄綋鍓峞xcel鏂规硶鐨勫弬鏁板垪琛紝鎵惧埌褰撳墠濉叆鐨勫�兼槸鍚︽槸鍙傛暟 + if ( + item.valueList && + item.valueList.length > 0 && + item.valueList.find((m) => m.r == r && m.c == c) + ) { + isSave = "false"; + // 濡傛灉鏄紝鍒欏畾涔変竴涓弬鏁扮殑瀵硅薄闆嗗悎锛岀敤浜庝繚瀛樺綋鍓峞xcel鏂规硶鍙傛暟鐨勫�� + var comValue = {}; + item.valueList.forEach((a) => { + list.forEach((b) => { + if (b[0].r == a.r) { + b.forEach((c) => { + if (c.c == a.c) { + // 鑾峰彇褰撳墠鍙傛暟鐨凟xecl琛屽潗鏍�(ABCD)绛夌瓑 + var tableCode = ""; + for (var d in comparisonList) { + if (c.c == comparisonList[d].value) { + tableCode = comparisonList[d].label; + break; + } + } + list2.push(c.v.v); + // 缁勮鍙傛暟鐨勫璞¢泦鍚堝苟璧嬪�硷紝鍒楀{A3:12,B4:15} + if ( + getInspectionValueType(item.i) == 1 && + !isNaN(parseFloat(c.v.v)) + ) { + // 濡傛灉鏄暟瀛楄緭鍏ユ + let n = String(c.v.v); + if (n.includes("/")) { + // 濡傛灉鏄垎鏁帮紝鍒欒祴鍊� + comValue[tableCode + (c.r + 1)] = c.v.v; + } else { + comValue[tableCode + (c.r + 1)] = parseFloat(c.v.v); + } + } else { + // 濡傛灉鏄枃鏈�佷笅鎷夋绛夌瓑 + comValue[tableCode + (c.r + 1)] = c.v.v; + } + } + }); + } + }); + }); + // 濡傛灉姝xcel鏂规硶鏄粨璁哄垽鏂柟娉曪紝鍒欐墽琛屾鏂规硶 + // console.log('item.v.ps.value---', item.v.ps.value) + if (item.v.ps != undefined && item.v.ps.value == "缁撹") { + try { + if (currentSample.insProduct.find((m) => m.id == item.i)) { + // 濡傛灉褰撳墠妫�楠岄」鏄骇鍝佹楠岄」锛屽垯鎵ц姝ゆ柟娉曪紝鎵惧埌姝ゆ楠岄」鐨勮姹傚�� + let ask = currentSample.insProduct.find((m) => m.id == item.i).ask + ? currentSample.insProduct + .find((m) => m.id == item.i) + .ask.split("&") + : null; + // 鑾峰彇褰撳墠缁撹鐨勫弬鏁帮紝涔熷氨鏄綋鍓嶆楠岄」鐨勬渶缁堝�� + let res = Object.values(comValue)[0]; + if (typeof res == "string" && res.includes(">")) { + res = res.replace(">", ""); + } + if (typeof res == "string" && res.includes("鈮�")) { + res = res.replace("鈮�", ""); + } + if (typeof res == "string" && res.includes("鈮�")) { + res = res.replace("鈮�", ""); + } + if (typeof res == "string" && res.includes("<")) { + res = res.replace("<", ""); + } + if (typeof res == "string" && res.includes("锛�")) { + res = res.replace("锛�", ""); + } + if (typeof res == "string" && res.includes("锛�")) { + res = res.replace("锛�", ""); + } + if ( + typeof res == "string" && + (res === "鏂" || res === "鑴嗗寲" || res === "鏂鑴嗗寲") + ) { + item.v.v = 0; + list.forEach((a) => { + if (a[0].r == item.r) { + for (let b = 0; b < a.length; b++) { + if (a[b].c == item.c) { + a[b].v.v = 0; + break; + } + } + } + }); + } + let comp = []; + // 鍒ゆ柇褰撳墠缁撹鐨勫弬鏁帮紙褰撳墠妫�楠岄」鐨勬渶缁堝�硷級鏄惁涓虹┖锛屽鏋滀负绌猴紝鍒欑洿鎺ヨ祴鍊� + if ( + res === "" || + res === null || + res === undefined || + res === "Infinity" + ) { + item.v.v = null; + list.forEach((a) => { + if (a[0].r == item.r) { + for (let b = 0; b < a.length; b++) { + if (a[b].c == item.c) { + a[b].v.v = null; + break; + } + } + } + }); + } else { + // 濡傛灉涓嶄负绌猴紝鍒欏垽鏂綋鍓嶇粨璁哄氨闇�瑕佽繘琛屽垽鏂� + //瑕佹眰鍊间负-锛�/锛屸�旓紝鍒欑粨璁鸿缃负涓嶅垽瀹氾紝缁撹璧嬪�间负3 + if ( + ask == null || + ask[0] == "-" || + ask[0] == "/" || + ask[0] == "鈥�" + ) { + item.v.v = 3; + list.forEach((a) => { + if (a[0].r == item.r) { + for (let b = 0; b < a.length; b++) { + if (a[b].c == item.c) { + a[b].v.v = 3; + break; + } + } + } + }); + } else { + // 瑕佹眰鍊间笉涓�-锛�/锛屸�旓紝鍒欒繘琛屽垽鏂� + if (ask) { + // 寰幆瑕佹眰鍊煎垪琛紝鍒ゆ柇褰撳墠缁撹鐨勫弬鏁版槸鍚︾鍚堣姹� + comp = ask.map((m, i) => { + // 濡傛灉瑕佹眰鍊煎寘鍚�=锛屽垯鍒ゆ柇褰撳墠缁撹鐨勫弬鏁版槸鍚︾瓑浜庤姹傚�硷紝 + // 浠ヤ笅鍒ゆ柇鍩烘湰涓�鑷达紝鍙槸鍒ゆ柇绫诲瀷涓嶄竴鏍凤紝灏变笉鍋氭敞閲婁簡 + if (m.includes("=")) { + // 澶勭悊瑕佹眰鍊� + let str = handleFraction(m.split("=")[1]); + if (typeof res == "string" && typeof str == "string") { + // 濡傛灉瑕佹眰鍊煎拰褰撳墠缁撹鐨勫弬鏁伴兘鏄瓧绗︿覆锛屽垯鎵ц + if (res.includes("/")) { + // 濡傛灉缁撹鐨勫弬鏁版槸鍒嗘暟锛屽垯鍒ゆ柇 + if (m.includes("/")) { + // 濡傛灉瑕佹眰鍊兼槸鍒嗘暟锛屽垯鍒ゆ柇 + return eval(res) == eval(str); + } else { + // 濡傛灉瑕佹眰鍊间笉鏄垎鏁帮紝鍒欏垽鏂� + return handleMoreParam(res, m.split("=")[1], "="); + } + } else { + // 濡傛灉缁撹鐨勫弬鏁颁笉鏄垎鏁帮紝鍒欏垽鏂� + return ( + res.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, "") == + str.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, "") + ); + } + } else { + // 濡傛灉瑕佹眰鍊煎拰褰撳墠缁撹鐨勫弬鏁版湁涓�涓槸鏁板瓧锛屽垯鎵ц + return eval(res) == eval(str); + } + } else if (m.includes("鈮�")) { + if (typeof res == "string" && res.includes("/")) { + if (m.includes("/")) { + let str = handleFraction(m.split("鈮�")[1]); + return eval(res) >= eval(str); + } else { + return handleMoreParam(res, m.split("鈮�")[1], "鈮�"); + } + } else { + let str = handleFraction(m.split("鈮�")[1]); + return eval(res) >= eval(str); + } + } else if (m.includes("鈮�")) { + if (typeof res == "string" && res.includes("/")) { + if (m.includes("/")) { + let str = handleFraction(m.split("鈮�")[1]); + return eval(res) <= eval(str); + } else { + return handleMoreParam(res, m.split("鈮�")[1], "鈮�"); + } + } else { + let str = handleFraction(m.split("鈮�")[1]); + if (typeof str == "string" && str.includes("A")) { + str = str.replace("A", ""); + } + if (typeof str == "string" && str.includes("D")) { + str = str.replace("D", ""); + } + if (typeof res == "string" && res.includes("A")) { + res = res.replace("A", ""); + } + if (typeof res == "string" && res.includes("D")) { + res = res.replace("D", ""); + } + return eval(res) <= eval(str); + } + } else if (m.includes("<")) { + if (typeof res == "string" && res.includes("/")) { + if (m.includes("/")) { + let str = handleFraction(m.split("<")[1]); + return eval(res) < eval(str); + } else { + return handleMoreParam(res, m.split("<")[1], "<"); + } + } else { + let str = handleFraction(m.split("<")[1]); + return eval(res) < eval(str); + } + } else if (m.includes(">")) { + if (typeof res == "string" && res.includes("/")) { + if (m.includes("/")) { + let str = handleFraction(m.split(">")[1]); + return eval(res) > eval(str); + } else { + return handleMoreParam(res, m.split(">")[1], ">"); + } + } else { + let str = handleFraction(m.split(">")[1]); + return eval(res) > eval(str); + } + } else if (m.includes("~")) { + if (typeof res == "string" && res.includes("/")) { + if (m.includes("/")) { + let k = m.split("~"); + return ( + eval(res) >= eval(handleFraction(k[0])) && + eval(res) <= eval(handleFraction(k[1])) + ); + } else { + return handleMoreParam(res, m, "~"); + } + } else { + let k = m.split("~"); + return ( + eval(res) >= eval(handleFraction(k[0])) && + eval(res) <= eval(handleFraction(k[1])) + ); + } + } else if (m.includes("-")) { + if (typeof res == "string" && res.includes("/")) { + if (m.includes("/")) { + let k = m.split("-"); + return ( + eval(res) >= eval(handleFraction(k[0])) && + eval(res) <= eval(handleFraction(k[1])) + ); + } else { + return handleMoreParam(res, m, "-"); + } + } else { + let k = m.split("-"); + return ( + eval(res) >= eval(handleFraction(k[0])) && + eval(res) <= eval(handleFraction(k[1])) + ); + } + } else if (m.includes("卤")) { + if (modelType.includes("蠁-")) { + if (m.indexOf("卤") == 0) { + m = + modelType.substring(modelType.indexOf("-") + 1) + m; + } + } + if (typeof res == "string" && res.includes("/")) { + if (m.includes("/")) { + let k = m.split("卤"); + return ( + eval(res) >= + eval( + handleFraction(k[0]) - handleFraction(k[1]) + ) && + eval(res) <= + eval( + Number(handleFraction(k[0])) + + Number(handleFraction(k[1])) + ) + ); + } else { + return handleMoreParam(res, m, "卤"); + } + } else { + let k = m.split("卤"); + return ( + eval(res) >= + eval(handleFraction(k[0]) - handleFraction(k[1])) && + eval(res) <= + eval( + Number(handleFraction(k[0])) + + Number(handleFraction(k[1])) + ) + ); + } + } else if (m.includes("锛�")) { + if (typeof res == "string" && res.includes("/")) { + if (m.includes("/")) { + let str = handleFraction(m.split("锛�")[1]); + return eval(res) > eval(str); + } else { + return handleMoreParam(res, m.split("锛�")[1], ">"); + } + } else { + let str = handleFraction(m.split("锛�")[1]); + return eval(res) > eval(str); + } + } else if (m.includes("锛�")) { + if (typeof res == "string" && res.includes("/")) { + if (m.includes("/")) { + let str = handleFraction(m.split("锛�")[1]); + return eval(res) < eval(str); + } else { + return handleMoreParam(res, m.split("锛�")[1], "<"); + } + } else { + let str = handleFraction(m.split("锛�")[1]); + return eval(res) < eval(str); + } + } + }); + } + // 濡傛灉瑕佹眰鍊肩殑姣忎釜鏉′欢閮界鍚堬紝鍒欑粰缁撹璧嬪�间负1锛屽悎鏍� + if (comp.every((m) => m)) { + item.v.v = 1; + list.forEach((a) => { + if (a[0].r == item.r) { + for (let b = 0; b < a.length; b++) { + if (a[b].c == item.c) { + a[b].v.v = 1; + break; + } + } + } + }); + } else { + // 鍚﹀垯缁欑粨璁鸿祴鍊间负0锛屼笉鍚堟牸 + item.v.v = 0; + list.forEach((a) => { + if (a[0].r == item.r) { + for (let b = 0; b < a.length; b++) { + if (a[b].c == item.c) { + a[b].v.v = 0; + break; + } + } + } + }); + } + } + } + let getDataType0 = false; + // 浼樺寲鏁伴噰杈冨鏁版嵁鏃�-璁板綍鏈�鍚庝竴涓楠岄」鐨刬d锛屽鏋滃綋鍓嶆楠岄」鐨刬d涓庤褰曠殑id鐩稿悓锛屽垯澶氫紶涓�涓弬鏁板埌涓荤嚎绋嬶紝杩涜鏁版嵁淇濆瓨锛屽惁鍒欐暟閲囧氨涓嶈繘琛屼繚瀛� + if (item.i == getDataTypeId) { + getDataType0 = true; + } + // 璧嬪�间紶閫掑埌涓荤嚎绋嬬殑鏁版嵁锛宮ethod锛歴aveInsContext琛ㄧず姝ゆ秷鎭渶瑕佷繚瀛樻暟鎹� + currentInsItemId = item.i; + // 璧嬪�间紶閫掑埌涓荤嚎绋嬬殑鏁版嵁锛宮ethod锛歴aveInsContext琛ㄧず姝ゆ秷鎭渶瑕佷繚瀛樻暟鎹� + result = { + method: "saveInsContext", + value: { + tableList, // 琛ㄦ牸鏁版嵁 + param: getParam(), //浼犵粰鍚庣鐨勫弬鏁� + getDataTypeId: getDataTypeId, + currentInsItemId: item.i, + }, + }; + // 鍙戞秷鎭粰涓荤嚎绋� + self.postMessage(JSON.stringify(result)); + } + } catch (error) { + console.log("error---", error); + } + } else { + // 濡傛灉鏄嚱鏁版柟娉曪紝鍒欐墽琛屾鏂规硶 + let comResult = ""; //鍒濆鍖栬绠楃粨鏋� + try { + if (getInspectionValueType(item.i) == 1) { + // 濡傛灉妫�楠屽�肩被鍨嬫槸鏁板瓧杈撳叆妗� + let tell = currentSample.insProduct.find((m) => m.id == item.i).tell + ? currentSample.insProduct + .find((m) => m.id == item.i) + .tell.split("&") + : null; + isPoint = + tell && + tell.length > 0 && + typeof tell[0] == "string" && + tell[0].includes("/") && + tell[0] !== "/"; // 瑁呭鐢电紗--鍒ゆ柇瑕佹眰鍊兼槸鍚︿负鍒嗘暟 + const inspectionItemClass = currentSample.insProduct.find( + (m) => m.id == item.i + ).inspectionItemClass; // 妫�楠岄」鍒嗙被 + const inspectionItem = currentSample.insProduct.find( + (m) => m.id == item.i + ).inspectionItem; // 妫�楠岄」 + const inspectionItemSubclass = currentSample.insProduct.find( + (m) => m.id == item.i + ).inspectionItemSubclass; // 妫�楠屽瓙椤� + let isHaveSymbol = false; + let symbol = ""; + for (var a in comValue) { + if ( + typeof comValue[a] == "string" && + (comValue[a].includes(">") || + comValue[a].includes("鈮�") || + comValue[a].includes("<") || + comValue[a].includes("鈮�") || + comValue[a].includes("锛�") || + comValue[a].includes("锛�")) + ) { + if (comValue[a].includes(">")) { + symbol = ">"; + } else if (comValue[a].includes("鈮�")) { + symbol = "鈮�"; + } else if (comValue[a].includes("鈮�")) { + symbol = "鈮�"; + } else if (comValue[a].includes("锛�")) { + symbol = "锛�"; + } else if (comValue[a].includes("锛�")) { + symbol = "锛�"; + } else { + symbol = "<"; + } + isHaveSymbol = true; + break; + } + } + // 鏍规嵁杈撳叆鐨勬暟鍊硷紝杩涜璁$畻 + comResult = compute(item.v.f.replace(/=/g, " "), comValue, isPoint); + // 妫�楠岄」涓哄瘑搴︽椂锛屾牴鎹姹傚�肩殑灏忔暟浣嶆敼鍙樻渶缁堝�肩殑灏忔暟浣� + if (inspectionItem == "瀵嗗害") { + const str = "" + tell; + const indexOfDecimal = str.indexOf("."); + if (indexOfDecimal > -1) { + const length = str.length - indexOfDecimal - 1; + comResult = comResult.toFixed(length); + } + } else if ( + inspectionItemClass == "澶栨姢濂楁満姊扮墿鐞嗘�ц兘" && + inspectionItem == "鍦↖RM 902鐭跨墿娌逛腑娴告场鍚�" && + (inspectionItemSubclass == "鏂浼搁暱鐜囧彉鍖栫巼" || + inspectionItemSubclass == "鎶楀紶寮哄害鍙樺寲鐜�") + ) { + comResult = Math.round(comResult).toFixed(0); + } else if ( + typeof comResult == "string" && + (comResult.includes("鏂") || comResult.includes("鑴嗗寲")) + ) { + comResult = comResult + ""; + } + if (inspectionItem === "閭垫皬纭害" && tell[0].includes("A")) { + // 瑕佹眰鍊煎鏋滄湁鍖呭惈瀛楁瘝锛屾渶缁堢粨鏋滆灞曠ず鍑哄瓧姣� + comResult = comResult + "A"; + } + if ( + inspectionItemClass === "缁濈紭鏈烘鐗╃悊鎬ц兘" && + inspectionItem === "寮洸鎬ц兘" && + inspectionItemSubclass === "鏈�灏忓集鏇插崐寰�" && + tell[0].includes("D") + ) { + // 瑕佹眰鍊煎鏋滄湁鍖呭惈瀛楁瘝锛屾渶缁堢粨鏋滆灞曠ず鍑哄瓧姣� + comResult = comResult + "D"; + } + if (isHaveSymbol) { + comResult = symbol + comResult; + } + let list3 = list2.map((item) => item + ""); + // 鍒ゆ柇濉殑妫�楠屽�兼槸鍚︿负绉戝璁℃暟娉曪紝濡傛灉涓虹瀛﹁鏁版硶锛屽垯杩涜杞寲 + isToExponential = list3.some( + (val) => val.includes("e+") || val.includes("e-") + ); + if (isToExponential) { + let num2 = new Big(comResult); + comResult = num2.toExponential(1); + } + } else { + // 濡傛灉妫�楠屽�肩被鍨嬫槸鏂囨湰杈撳叆妗嗐�佷笅鎷夋 + let valueList = []; + // 澶勭悊excel鍑芥暟鍙傛暟鍒楄〃 + item.valueList.forEach((a) => { + valueList.push({ + name: `${comparisonList.find((e) => e.value == a.c).label}${ + a.r + 1 + }`, + value: 0, + }); + }); + // 缁檈xcel鍑芥暟鍙傛暟璧嬫枃鏈�� + for (var a in comValue) { + valueList.forEach((b) => { + if (b.name == a) { + b.value = comValue[a]; + } + }); + } + // 璁$畻鍏紡锛屽幓鎺塭xcel鍑芥暟鐨勭瓑鍙凤紝骞舵浛鎹㈠弬鏁帮紝鍒楀锛�=A1 鍙樻垚 A1 鍙樻垚 鈥樻枃鏈緭鍏ョ殑鍊尖�� + let str = item.v.f.replace(/=/g, " "); + valueList.forEach((b) => { + str = str.replace(b.name, b.value); + }); + // 璁$畻缁撴灉璧嬪�� + comResult = str; + } + } catch (error) { + console.log("error---", error); + } + try { + // 寰幆琛ㄦ牸鏁版嵁锛岀粰琛ㄦ牸鏁版嵁杩涜璧嬪�� + list.forEach((a) => { + if (a[0].r == item.r && comResult !== "") { + // 鍒ゆ柇褰撳墠琛屾槸鍚︿负褰撳墠妫�楠岄」鎵�鍦ㄨ锛屽鏋滀负褰撳墠琛岋紝鍒欑粰琛ㄦ牸鏁版嵁璧嬪�� + for (var b in a) { + if (a[b].c == item.c) { + try { + if (comResult == 0) { + // 鍒ゆ柇璁$畻缁撴灉鏄惁涓�0锛屽鏋滀负0锛屽垯缁欒〃鏍兼暟鎹祴鍊间负0 + a[b].v.v = 0; + } else if ( + a[b].v.ct && + a[b].v.ct.fa && + typeof a[b].v.ct.fa == "string" && + a[b].v.ct.fa.includes(".") + ) { + // 鍒ゆ柇褰撳墠鍗曞厓鏍兼槸鍚︿繚鐣欏皬鏁扮偣锛屽鏋滀负淇濈暀灏忔暟鐐癸紝鍒欑粰琛ㄦ牸鏁版嵁璧嬪�间负淇濈暀灏忔暟鐐癸紝杩欎釜鏄牴鎹ā鏉块厤缃皬鏁扮偣鏉ョ殑 + let num = 0; + let str = a[b].v.ct.fa.split(".")[1]; + num = str.length; + a[b].v.v = comResult + ? Number(comResult).toFixed(num) + : comResult; + } else if ( + typeof comResult == "string" && + (comResult.includes("e+") || comResult.includes("e-")) + ) { + // 鍒ゆ柇璁$畻缁撴灉鏄惁涓虹瀛﹁鏁版硶锛屽鏋滀负绉戝璁℃暟娉曪紝鍒欑粰琛ㄦ牸鏁版嵁璧嬪�间负绉戝璁℃暟娉� + a[b].v.v = comResult; + } else { + const inspectionItem = currentSample.insProduct.find( + (m) => m.id == item.i + ).inspectionItem; + // 鍒ゆ柇璁$畻缁撴灉鏄惁涓烘暟瀛楋紝濡傛灉涓烘暟瀛楋紝鍒欑粰琛ㄦ牸鏁版嵁璧嬪�间负鏁板瓧 + if (inspectionItem == "閾滅嚎鐢甸樆鐜囅�20鏈�澶у��") { + let val = parseFloat(Number(comResult).toFixed(5)); + a[b].v.v = isNaN(val) ? comResult : val; + } else { + let val = parseFloat(Number(comResult).toFixed(3)); + a[b].v.v = isNaN(val) ? comResult : val; + } + } + } catch (error) { + // 濡傛灉浠ヤ笂鍒ゆ柇閮戒笉鏀寔锛屽垯鐩存帴璧嬪�� + a[b].v.v = comResult; + console.log("error---", error); + } + break; + } + } + } + }); + // 濡傛灉姝よ绠楃粨鏋滄墍灞炲崟鍏冩牸锛屽悓鏃朵篃鏄彟涓�涓猠xcel鍑芥暟鐨勫弬鏁帮紝閭d箞灏遍渶瑕侀�掑綊杩涜璁$畻 + changeInput(comResult, `${id}-${item.r}-${item.c}-${pId}`); //鏀瑰彉鏈�缁堝�� + currentInsItemId = item.i; + } catch (error) { + console.log("error---", error); + } + } + } + }); + if (index === -1 || (inputType === undefined && isSave === "true")) { + // 璧嬪�间紶閫掑埌涓荤嚎绋嬬殑鏁版嵁锛宮ethod锛歴aveInsContext琛ㄧず姝ゆ秷鎭渶瑕佷繚瀛樻暟鎹� + result = { + method: "saveInsContext", + value: { + tableList, // 琛ㄦ牸鏁版嵁 + param: getParam(), //浼犵粰鍚庣鐨勫弬鏁� + getDataTypeId: getDataTypeId, + currentInsItemId: currentInsItemId, + }, + }; + // 鍙戞秷鎭粰涓荤嚎绋� + self.postMessage(JSON.stringify(result)); + } + + // 璧嬪�煎绾跨▼浼犺緭鏁版嵁 + result = { + method: "tableList", + value: tableList, + }; + // 鍙戦�佷富绾跨▼鏁版嵁 + self.postMessage(JSON.stringify(result)); + try { + // 璧嬪�煎绾跨▼浼犺緭鏁版嵁 + result = { + method: "getCurrentInsProduct", + value: pId, + }; + // 鍙戦�佷富绾跨▼鏁版嵁 + self.postMessage(JSON.stringify(result)); + } catch (error) { + console.log("error---", error); + } +} +/** + * 鑾峰彇妫�娴嬪�肩被鍨� + * + * @param id 妫�娴嬪�肩被鍨嬪搴旂殑id + * @returns 杩斿洖妫�娴嬪�肩被鍨� + */ +function getInspectionValueType(id) { + for (var a in currentSample.insProduct) { + if (currentSample.insProduct[a].id == id) { + return currentSample.insProduct[a].inspectionValueType; + } + } +} +/** + * 澶勭悊鍒嗘暟鎴栧甫鏈変箻娉曞拰涔樻柟鐨勫瓧绗︿覆 + * + * @param str 瀛楃涓茬被鍨嬶紝琛ㄧず瑕佸鐞嗙殑鍒嗘暟鎴栦箻鏂硅〃杈惧紡 + * @returns 杩斿洖涓�涓暟瀛楁垨鍘熷瓧绗︿覆锛屽鏋滃瓧绗︿覆涓烘湁鏁堢殑鍒嗘暟鎴栦箻鏂硅〃杈惧紡锛屽垯杩斿洖璁$畻缁撴灉锛涘惁鍒欒繑鍥炲師瀛楃涓� + */ +function handleFraction(str) { + if (str && typeof str == "string" && str.includes("/")) { + // 澶勭悊鍒嗘暟 + return eval(str.split("/")[0] / str.split("/")[1]); + } else if ( + str && + typeof str == "string" && + str.includes("*") && + str.includes("^") + ) { + // 璁$畻涔樻柟 + const num1 = str.split("*"); + const num2 = num1[1].split("^"); + let num3 = new Big(num2[0]); + let num4 = new Big(num2[1]); + let num5 = Math.pow(num3, num4); // 璁$畻娆℃柟 + return num1[0] * num5; // 鏈�鍚庤绠椾箻娉� + } else { + return str; + } +} + +/** + * 澶勭悊甯︽湁澶氫釜鍙傛暟鐨勫嚱鏁� + * + * @param res 瀛楃涓诧紝闇�瑕佽鍒嗗壊骞跺鐞嗙殑瀛楃涓� + * @param str 瀛楃涓诧紝涓巖es涓殑姣忎竴椤硅繘琛屾瘮杈冪殑瀛楃涓诧紝鍙兘鏄垎鏁版垨鑰呭甫鏈夋瘮杈冪鍙风殑瀛楃涓� + * @param comp 瀛楃涓诧紝琛ㄧず姣旇緝绫诲瀷鐨勫瓧绗︼紙濡� '>'銆�'<'銆�'='銆�'鈮�'銆�'鈮�'銆�'卤'銆�'~'銆�'-'锛� + * @returns 杩斿洖甯冨皵鍊硷紝濡傛灉res涓瘡涓�椤归兘婊¤冻涓巗tr鐨勬瘮杈冩潯浠讹紝鍒欒繑鍥瀟rue锛屽惁鍒欒繑鍥瀎alse + */ +function handleMoreParam(res, str, comp) { + let arr = res.split("/"); + let arr0 = arr.every((item) => { + switch (comp) { + case ">": + return item > handleFraction(str); + case "<": + return item < handleFraction(str); + case "=": + return item == handleFraction(str); + case "鈮�": + return item >= handleFraction(str); + case "鈮�": + return item <= handleFraction(str); + case "卤": + let k = str.split("卤"); + return ( + item >= eval(handleFraction(k[0]) - handleFraction(k[1])) && + item <= + eval(Number(handleFraction(k[0])) + Number(handleFraction(k[1]))) + ); + case "~": + let j = str.split("~"); + return ( + item >= eval(handleFraction(j[0])) && + item <= eval(handleFraction(j[1])) + ); + case "-": + let o = str.split("-"); + return ( + item >= eval(handleFraction(o[0])) && + item <= eval(handleFraction(o[1])) + ); + } + }); + if (arr0) { + return true; + } else { + return false; + } +} + +/** + * 鑾峰彇鍙傛暟 + * + * @returns 杩斿洖澶勭悊鍚庣殑鍙傛暟瀵硅薄 + */ +function getParam() { + tableList[0].arr.forEach((a) => { + a.forEach((b) => { + // 鍒濆鍖栦紶閫掑埌鍚庣鐨勫弬鏁� + if (param[b.i]) { + param[b.i].insValue = []; + param[b.i].comValue = []; + param[b.i].equipValue = []; + param[b.i].equipName = []; + param[b.i].resValue = null; + param[b.i].insResult = null; + } + }); + }); + tableList[0].arr.forEach((a) => { + a.forEach((b) => { + // 鏍规嵁琛ㄦ牸鏁版嵁锛岃祴鍊间紶閫掑埌鍚庣鐨勫弬鏁� + if ( + b.v.ps != undefined && + typeof b.v.ps.value == "string" && + b.v.ps.value.includes("妫�楠屽��") + ) { + // 璧嬪�兼楠屽�� + b.i && b.v.v && param[b.i].insValue.push(b); + } + if (b.v.ps != undefined && b.v.ps.value === "璁$畻鍊�") { + // 璧嬪�艰绠楀�� + b.i && + b.v.v && + b.valueList && + b.valueList.length > 0 && + param[b.i].comValue.push(b); + } + if (b.v.ps != undefined && b.v.ps.value === "璁惧缂栫爜") { + // 璧嬪�艰澶囩紪鐮� + b.i && b.v && param[b.i].equipValue.push(b); + } + if (b.v.ps != undefined && b.v.ps.value === "璁惧鍚嶇О") { + // 璧嬪�艰澶囧悕绉� + b.i && b.v && param[b.i].equipName.push(b); + } + if (b.v.ps != undefined && b.v.ps.value === "鏈�缁堝��") { + // 璧嬪�兼渶缁堝�� + b.i && + b.v && + b.valueList && + b.valueList.length > 0 && + (param[b.i].resValue = b); + } + if (b.v.ps != undefined && b.v.ps.value === "缁撹") { + if (b.i && (b.v.v || b.v.v === 0 || b.v.v === "0")) { + if (b.v.v != "鍚堟牸" && b.v.v != "涓嶅悎鏍�") { + // 璧嬪�肩粨璁� + param[b.i].insResult = b; + } + } + } + }); + }); + return param; +} + +/** + * 璁$畻澶氫釜鏁板�肩殑鍜� + * + * @param val 鏁板�煎瀷鍙傛暟锛屽彲鍙橀暱鍙傛暟鍒楄〃 + * @returns 杩斿洖鎵�鏈夊弬鏁扮殑鍜岋紝濡傛灉鍙傛暟鍒楄〃涓虹┖鎴栧弬鏁扮被鍨嬮潪鏁板�煎瀷锛屽垯杩斿洖null + */ +function SUM(...val) { + try { + let num = null; + if ( + val != null && + val != undefined && + val != "undefined" && + val != "NaN" && + val.length > 0 + ) { + val.forEach((item) => { + num += item; + }); + } + return num; + } catch (error) { + console.log("error---", error); + } +} +/** + * 璁$畻浼犲叆鍙傛暟涓殑鏈�澶у�� + * + * @param ...val 鍙彉鍙傛暟鍒楄〃锛岀敤浜庤绠楁渶澶у�肩殑鏁板�兼垨鍙浆鎹负鏁板�肩殑绫诲瀷 + * @returns 杩斿洖鏈�澶у�硷紝濡傛灉鍙傛暟鍒楄〃涓虹┖鎴栦负null/undefined/''锛屽垯杩斿洖null + */ +function MAX(...val) { + try { + let max = null; + if ( + val != null && + val != undefined && + val != "undefined" && + val != "NaN" && + val.length > 0 + ) { + val = val.filter((item) => item != null && item !== ""); + if (val.length > 0) { + max = Math.max(...val); + } else { + max = null; + } + } + return max; + } catch (error) { + console.log("error---", error); + } +} +/** + * IF鍒ゆ柇 + * + * + * + */ +function IF(...val) { + try { + let ifNUm = null; + if ( + val != null && + val != undefined && + val != "undefined" && + val != "NaN" && + val.length > 0 + ) { + if (val[0] === "" || val[0] == 0 || val[0] === " ") { + ifNUm = val[1]; + } else { + ifNUm = val[0]; + } + } + return ifNUm; + } catch (error) { + console.log("IFerror---", error); + } +} +/** + * 璁$畻浼犲叆鍙傛暟涓殑鏈�灏忓�� + * + * @param val 鍙彉鍙傛暟锛岀敤浜庤绠楁渶灏忓�肩殑鏁板�兼暟缁� + * @returns 杩斿洖浼犲叆鍙傛暟涓殑鏈�灏忓�硷紝濡傛灉浼犲叆鍙傛暟涓虹┖鎴栨墍鏈夊�煎潎涓簄ull鎴栫┖瀛楃涓诧紝鍒欒繑鍥瀗ull + */ +function MIN(...val) { + try { + let min = null; + if ( + val != null && + val != undefined && + val != "undefined" && + val != "NaN" && + val.length > 0 + ) { + val = val.filter((item) => item != null && item !== ""); + if (val.length > 0) { + min = Math.min(...val); + } + } + return min; + } catch (error) { + console.log("error---", error); + } +} +/** + * 璁$畻缁欏畾鏁板�肩殑骞冲潎鍊� + * + * @param val 鏁板�煎垪琛紝鍙寘鍚换鎰忎釜鍙傛暟 + * @returns 杩斿洖骞冲潎鍊硷紝濡傛灉鏁板�煎垪琛ㄤ负绌烘垨鍖呭惈闈炴暟鍊奸」锛屽垯杩斿洖null + */ +function AVERAGE(...val) { + try { + let num = null; + let arr = []; + if ( + val != null && + val != undefined && + val != "undefined" && + val != "NaN" && + val.length > 0 + ) { + arr = val.filter( + (item) => item !== null && item !== "" && item != undefined + ); + arr.forEach((item) => { + num += item; + }); + if (arr.length > 0) { + return num / arr.length; + } else { + return null; + } + } else { + return null; + } + } catch (error) { + console.log("error---", error); + } +} +/** + * 鍙栨暣鏁� + * + * @param val 浠绘剰鏁板�� + * @returns 杩斿洖璇ユ暟鍊肩殑鏁存暟 + */ +function INT(val) { + try { + return Math.round(val); + } catch (error) { + console.log("error---", error); + } +} +/** + * 璁$畻涓�涓暟鐨勭粷瀵瑰�� + * + * @param val 浠绘剰鏁板�� + * @returns 杩斿洖璇ユ暟鍊肩殑缁濆鍊� + */ +function ABS(val) { + try { + return Math.abs(val); + } catch (error) { + console.log("error---", error); + } +} +/** + * 璁$畻涓�缁勬暟瀛楃殑涓綅鏁� + * + * @param val 浠绘剰涓弬鏁帮紝闇�瑕佽绠椾腑浣嶆暟鐨勬暟瀛� + * @returns 濡傛灉鍙傛暟涓湁鏈夋晥鐨勬暟瀛楋紝鍒欒繑鍥炶绠楀嚭鐨勪腑浣嶆暟锛涘惁鍒欒繑鍥瀗ull + */ +function MEDIAN(...val) { + try { + let arr = []; + if (val && val.length > 0) { + arr = val.filter((item) => item != null && item !== ""); + const sortedArr = arr.sort((a, b) => a - b); + // 璁$畻涓綅鏁� + const half = Math.floor(sortedArr.length / 2); + if (arr.length > 0) { + // 濡傛灉鏁扮粍闀垮害鏄鏁帮紝鐩存帴鍙栦腑闂寸殑鍏冪礌 + if (sortedArr.length % 2 === 1) { + return sortedArr[half]; + } else { + // 濡傛灉鏁扮粍闀垮害鏄伓鏁帮紝鍙栦腑闂翠袱涓厓绱犵殑骞冲潎鍊� + return (sortedArr[half - 1] + sortedArr[half]) / 2; + } + } else { + return null; + } + } else { + return null; + } + } catch (error) { + console.log("error---", error); + } +} + +/** + * 璁$畻骞� + * + * @param str 瀛楃涓插舰寮忕殑骞傝〃杈惧紡锛屼緥濡�"2^3" + * @returns 杩斿洖璁$畻鍚庣殑骞傚�硷紝濡傛灉琛ㄨ揪寮忔棤鏁堝垯杩斿洖null + */ +function CalculatePower(str) { + try { + if (str && str.includes("^")) { + let arr = str.split("^"); + if (arr && arr.length > 1) { + return Math.pow(arr[0], arr[1]); + } else { + return null; + } + } + } catch (error) { + console.log("error---", error); + } +} +/** + * 杞崲蟺 + * + * + * + */ +function PI() { + try { + return 3.1415926; + } catch (error) { + console.log("error---", error); + } +} +/** + * 璁$畻LOG + * + * + * + */ +function LOG(...val) { + try { + let LOGNUm = null; + if ( + val != null && + val != undefined && + val != "undefined" && + val != "NaN" && + val.length > 0 + ) { + val = val.filter((item) => item != null && item !== ""); + if (val.length > 0) { + LOGNUm = Math.log(val[0]); + } + } + // console.log(LOGNUm); + return LOGNUm; + } catch (error) { + console.log("error---", error); + } +} + +/** + * 鏍规嵁鍧愭爣鑾峰彇鍒楀悕 + * @param {Object} cellId + */ +function getColumnNameFromId(cellId) { + try { + if (!Array.isArray(cellId)) { + cellId = cellId.split("-"); + } + var i = cellId[0]; + var letter = ""; + if (i > 701) { + letter += String.fromCharCode(64 + parseInt(i / 676)); + letter += String.fromCharCode(64 + parseInt((i % 676) / 26)); + } else if (i > 25) { + letter += String.fromCharCode(64 + parseInt(i / 26)); + } + letter += String.fromCharCode(65 + (i % 26)); + return letter + (parseInt(cellId[1]) + 1); + } catch (e) { + console.log("error", e); + } +} +/** + * 鏍规嵁鍒楀悕鑾峰彇鍧愭爣 + * @param {Object} id + * @param {Object} arr + */ +function getIdFromColumnName(id, arr) { + try { + // Get the letters + var t = /^[a-zA-Z]+/.exec(id); + if (t) { + // Base 26 calculation + var code = 0; + for (var i = 0; i < t[0].length; i++) { + code += + parseInt(t[0].charCodeAt(i) - 64) * Math.pow(26, t[0].length - 1 - i); + } + code--; + // Make sure jexcel starts on zero + if (code < 0) { + code = 0; + } + + // Number + var number = parseInt(/[0-9]+$/.exec(id)); + if (number > 0) { + number--; + } + + if (arr == true) { + id = [code, number]; + } else { + // id = code + '-' + number; + id = { + c: code, + r: number, + }; + } + } + return id; + } catch (e) { + console.log("error", e); + } +} + +/** + * 鏇存敼鍙傛暟 + * + * @param f 鍙傛暟鍒楄〃 + * @returns 杩斿洖涓�涓寘鍚潗鏍囦俊鎭殑鏁扮粍 + */ +function changeParameter(f) { + try { + let arr = getABCList(f); + let arr2 = []; + arr.forEach((item) => { + // 鍒ゆ柇鏄惁涓鸿寖鍥达紝鍒楀MAX(A1:B2) + if (item.includes(":")) { + let r0 = getIdFromColumnName(item.split(":")[0]).r; + let c0 = getIdFromColumnName(item.split(":")[0]).c; + let r1 = getIdFromColumnName(item.split(":")[1]).r; + let c1 = getIdFromColumnName(item.split(":")[1]).c; + for (let i = Number(r0); i <= Number(r1); i++) { + for (let u = Number(c0); u <= Number(c1); u++) { + arr2.push({ + r: i, + c: u, + }); + } + } + } else { + // 娌℃湁鍒欑洿鎺ヨ幏鍙� + arr2.push(getIdFromColumnName(item)); + } + }); + return arr2; + } catch (error) { + console.log("error", error); + } +} +/** + * 鑾峰彇鍖呭惈 ABC 瀛楃鐨勫垪琛� + * + * @param f 瀛楃涓诧紝鍖呭惈闇�瑕佽В鏋愮殑鍏紡鎴栬〃杈惧紡 + * @returns 鍖呭惈 ABC 瀛楃鐨勬暟缁勫垪琛� + */ +function getABCList(f) { + try { + let regex = /[=\+\-\*\%\(\)\/\^\s]/g; + // 涓婇潰璁$畻鍑芥暟鏂板鍚庯紝杩欓噷涔熻鍚屾澧炲姞 + let fouList = [ + "SUM", + "MAX", + "MIN", + "AVERAGE", + "ABS", + "PI", + "INT", + "IF", + "LOG", + ]; + // 鏇挎崲鐗规畩瀛楃 + f = f + .replace(regex, ",") + .replace(new RegExp('"&', "g"), "") + .replace(new RegExp('&"', "g"), ""); + fouList.forEach((item) => { + f = f.replace(new RegExp(item, "g"), ","); + }); + let arr = f.split(",").filter((item) => { + return ( + item && /[a-zA-Z]/.test(item) && item != "undefined" && item != "null" + ); + }); + return arr; + } catch (error) { + console.log("error", error); + } +} +/** + * 鑾峰彇鎵�鏈夊崟鍏冩牸 + * + * @param f 琛ㄦ牸鏁版嵁鎴栫浉鍏冲弬鏁� + * @returns 杩斿洖涓�涓璞★紝鍏堕敭涓哄崟鍏冩牸鐨勫敮涓�鏍囪瘑绗︼紙鐢卞垪鍜岃ID鎷兼帴鑰屾垚锛夛紝鍊间负null + */ +function getAllCell(f) { + try { + let arr = changeParameter(f); + let arr0 = {}; + arr.forEach((item) => { + arr0[getColumnNameFromId(`${item.c}` + "-" + `${item.r}`)] = null; + }); + return arr0; + } catch (error) { + console.log("error", error); + } +} + +/** + * 璁$畻鍑芥暟 + * + * @param f 瀛楃涓茬被鍨嬶紝琛ㄧず寰呰绠楃殑鍏紡 + * @param comValue 瀵硅薄绫诲瀷锛岃〃绀鸿鏇挎崲鐨勫崟鍏冩牸鍊硷紝閿负鍗曞厓鏍煎悕绉帮紝鍊间负鏇挎崲鍚庣殑鍊� + * @returns 杩斿洖璁$畻鍚庣殑缁撴灉锛屽鏋滆绠楀け璐ュ垯杩斿洖0 + */ +function compute(f, comValue, isPoint) { + try { + let str = f; + // 鑾峰彇鍗曞厓鏍煎搴斿�� + let arr = getAllCell(f); + for (var a in comValue) { + if (typeof comValue[a] == "string" && comValue[a].includes(">")) { + comValue[a] = comValue[a].replace(">", ""); + } + if (typeof comValue[a] == "string" && comValue[a].includes("鈮�")) { + comValue[a] = comValue[a].replace("鈮�", ""); + } + if (typeof comValue[a] == "string" && comValue[a].includes("鈮�")) { + comValue[a] = comValue[a].replace("鈮�", ""); + } + if (typeof comValue[a] == "string" && comValue[a].includes("<")) { + comValue[a] = comValue[a].replace("<", ""); + } + if (typeof comValue[a] == "string" && comValue[a].includes("锛�")) { + comValue[a] = comValue[a].replace("锛�", ""); + } + if (typeof comValue[a] == "string" && comValue[a].includes("锛�")) { + comValue[a] = comValue[a].replace("锛�", ""); + } + if ( + comValue[a] !== "undefined" && + comValue[a] !== "null" && + comValue[a] !== undefined + ) { + if (typeof comValue[a] == "string" && comValue[a].includes("^")) { + // 璁$畻骞傛 + arr[a] = CalculatePower(comValue[a]); + } else { + arr[a] = comValue[a]; + } + } + } + // 瑙f瀽鍏紡鍙傛暟锛岀壒鍒槸甯︼細鐨� + let arr0 = getABCList(f); + let obj = {}; + arr0.forEach((item) => { + if (item.includes(":")) { + let arr1 = []; + let r0 = getIdFromColumnName(item.split(":")[0]).r; + let c0 = getIdFromColumnName(item.split(":")[0]).c; + let r1 = getIdFromColumnName(item.split(":")[1]).r; + let c1 = getIdFromColumnName(item.split(":")[1]).c; + for (let i = Number(r0); i <= Number(r1); i++) { + for (let u = Number(c0); u <= Number(c1); u++) { + arr1.push({ + r: i, + c: u, + }); + } + } + let arr2 = []; + arr1.forEach((m) => { + arr2.push(getColumnNameFromId(`${m.c}` + "-" + `${m.r}`)); + }); + obj[item.split(":").join("-")] = arr2.join(","); + } else { + obj[item] = item; + } + }); + str = str.replace(new RegExp(":", "g"), "-"); + // 鏇挎崲鍙傛暟 + for (var a in obj) { + str = str.replace(new RegExp(a, "g"), obj[a]); + } + // 璁$畻 + for (var a in arr) { + str = str.replace(new RegExp(a, "g"), arr[a]); + } + if (str.includes(",,")) { + str = str.replace(new RegExp(",,", "g"), ","); + } + if (str.includes(",,")) { + str = str.replace(new RegExp(",,", "g"), ","); + } + if (str.includes(",,")) { + str = str.replace(new RegExp(",,", "g"), ","); + } + if (str.includes(",,")) { + str = str.replace(new RegExp(",,", "g"), ","); + } + if (str.includes(",,")) { + str = str.replace(new RegExp(",,", "g"), ","); + } + if (str.includes('&"/"&')) { + // 璁$畻甯︽枩鏉犵殑 + return str + .replace(new RegExp('&"/"&', "g"), "/") + .replace(new RegExp("//", "g"), ""); + } else if (isPoint) { + // 璁$畻甯﹀皬鏁扮偣鐨� + return str.replace("ABS", "").replace(/\(|\)/g, ""); + } else { + if (str.includes("IF")) { + str = str.replace("IF", "").replace(/\(|\)/g, ""); + const str1 = str.split(","); + if (str1[0] === " " || str1[0] === "") { + str1[0] = 0; + } + if (str1[2] === " " || str1[2] === "") { + str1[2] = 0; + } + const str2 = str1.join(","); + str = "IF(" + str2 + ")"; + } + // console.log('str---', str) + if (str.includes("鏂") || str.includes("鑴嗗寲")) { + const result = str.replace(/[^\u4e00-\u9fa5]/g, ""); + if (result.includes("鏂") && !result.includes("鑴嗗寲")) { + return "鏂"; + } else if (!result.includes("鏂") && result.includes("鑴嗗寲")) { + return "鑴嗗寲"; + } else if (result.includes("鏂") && result.includes("鑴嗗寲")) { + return "鏂鑴嗗寲"; + } + } + // 璁$畻甯歌鐨� + return eval(str); + } + } catch (error) { + console.log("error", error); + } +} + +/* + * big.js v5.2.2 + * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic. + * Copyright (c) 2018 Michael Mclaughlin <M8ch88l@gmail.com> + * https://github.com/MikeMcl/big.js/LICENCE + */ +(function (GLOBAL) { + "use strict"; + var Big, + /************************************** EDITABLE DEFAULTS *****************************************/ + + // The default values below must be integers within the stated ranges. + + /* + * The maximum number of decimal places (DP) of the results of operations involving division: + * div and sqrt, and pow with negative exponents. + */ + DP = 20, // 0 to MAX_DP + /* + * The rounding mode (RM) used when rounding to the above decimal places. + * + * 0 Towards zero (i.e. truncate, no rounding). (ROUND_DOWN) + * 1 To nearest neighbour. If equidistant, round up. (ROUND_HALF_UP) + * 2 To nearest neighbour. If equidistant, to even. (ROUND_HALF_EVEN) + * 3 Away from zero. (ROUND_UP) + */ + RM = 1, // 0, 1, 2 or 3 + // The maximum value of DP and Big.DP. + MAX_DP = 1e6, // 0 to 1000000 + // The maximum magnitude of the exponent argument to the pow method. + MAX_POWER = 1e6, // 1 to 1000000 + /* + * The negative exponent (NE) at and beneath which toString returns exponential notation. + * (JavaScript numbers: -7) + * -1000000 is the minimum recommended exponent value of a Big. + */ + NE = -7, // 0 to -1000000 + /* + * The positive exponent (PE) at and above which toString returns exponential notation. + * (JavaScript numbers: 21) + * 1000000 is the maximum recommended exponent value of a Big. + * (This limit is not enforced or checked.) + */ + PE = 21, // 0 to 1000000 + /**************************************************************************************************/ + + // Error messages. + NAME = "[big.js] ", + INVALID = NAME + "Invalid ", + INVALID_DP = INVALID + "decimal places", + INVALID_RM = INVALID + "rounding mode", + DIV_BY_ZERO = NAME + "Division by zero", + // The shared prototype object. + P = {}, + UNDEFINED = void 0, + NUMERIC = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i; + + /* + * Create and return a Big constructor. + * + */ + function _Big_() { + /* + * The Big constructor and exported function. + * Create and return a new instance of a Big number object. + * + * n {number|string|Big} A numeric value. + */ + function Big(n) { + var x = this; + + // Enable constructor usage without new. + if (!(x instanceof Big)) return n === UNDEFINED ? _Big_() : new Big(n); + + // Duplicate. + if (n instanceof Big) { + x.s = n.s; + x.e = n.e; + x.c = n.c.slice(); + } else { + parse(x, n); + } + + /* + * Retain a reference to this Big constructor, and shadow Big.prototype.constructor which + * points to Object. + */ + x.constructor = Big; + } + + Big.prototype = P; + Big.DP = DP; + Big.RM = RM; + Big.NE = NE; + Big.PE = PE; + Big.version = "5.2.2"; + + return Big; + } + + /* + * Parse the number or string value passed to a Big constructor. + * + * x {Big} A Big number instance. + * n {number|string} A numeric value. + */ + function parse(x, n) { + var e, i, nl; + + // Minus zero? + if (n === 0 && 1 / n < 0) n = "-0"; + else if (!NUMERIC.test((n += ""))) throw Error(INVALID + "number"); + + // Determine sign. + x.s = n.charAt(0) == "-" ? ((n = n.slice(1)), -1) : 1; + + // Decimal point? + if ((e = n.indexOf(".")) > -1) n = n.replace(".", ""); + + // Exponential form? + if ((i = n.search(/e/i)) > 0) { + // Determine exponent. + if (e < 0) e = i; + e += +n.slice(i + 1); + n = n.substring(0, i); + } else if (e < 0) { + // Integer. + e = n.length; + } + + nl = n.length; + + // Determine leading zeros. + for (i = 0; i < nl && n.charAt(i) == "0"; ) ++i; + + if (i == nl) { + // Zero. + x.c = [(x.e = 0)]; + } else { + // Determine trailing zeros. + for (; nl > 0 && n.charAt(--nl) == "0"; ); + x.e = e - i - 1; + x.c = []; + + // Convert string to array of digits without leading/trailing zeros. + for (e = 0; i <= nl; ) x.c[e++] = +n.charAt(i++); + } + + return x; + } + + /* + * Round Big x to a maximum of dp decimal places using rounding mode rm. + * Called by stringify, P.div, P.round and P.sqrt. + * + * x {Big} The Big to round. + * dp {number} Integer, 0 to MAX_DP inclusive. + * rm {number} 0, 1, 2 or 3 (DOWN, HALF_UP, HALF_EVEN, UP) + * [more] {boolean} Whether the result of division was truncated. + */ + function round(x, dp, rm, more) { + var xc = x.c, + i = x.e + dp + 1; + + if (i < xc.length) { + if (rm === 1) { + // xc[i] is the digit after the digit that may be rounded up. + more = xc[i] >= 5; + } else if (rm === 2) { + more = + xc[i] > 5 || + (xc[i] == 5 && + (more || i < 0 || xc[i + 1] !== UNDEFINED || xc[i - 1] & 1)); + } else if (rm === 3) { + more = more || !!xc[0]; + } else { + more = false; + if (rm !== 0) throw Error(INVALID_RM); + } + + if (i < 1) { + xc.length = 1; + + if (more) { + // 1, 0.1, 0.01, 0.001, 0.0001 etc. + x.e = -dp; + xc[0] = 1; + } else { + // Zero. + xc[0] = x.e = 0; + } + } else { + // Remove any digits after the required decimal places. + xc.length = i--; + + // Round up? + if (more) { + // Rounding up may mean the previous digit has to be rounded up. + for (; ++xc[i] > 9; ) { + xc[i] = 0; + if (!i--) { + ++x.e; + xc.unshift(1); + } + } + } + + // Remove trailing zeros. + for (i = xc.length; !xc[--i]; ) xc.pop(); + } + } else if (rm < 0 || rm > 3 || rm !== ~~rm) { + throw Error(INVALID_RM); + } + + return x; + } + + /* + * Return a string representing the value of Big x in normal or exponential notation. + * Handles P.toExponential, P.toFixed, P.toJSON, P.toPrecision, P.toString and P.valueOf. + * + * x {Big} + * id? {number} Caller id. + * 1 toExponential + * 2 toFixed + * 3 toPrecision + * 4 valueOf + * n? {number|undefined} Caller's argument. + * k? {number|undefined} + */ + function stringify(x, id, n, k) { + var e, + s, + Big = x.constructor, + z = !x.c[0]; + + if (n !== UNDEFINED) { + if (n !== ~~n || n < (id == 3) || n > MAX_DP) { + throw Error(id == 3 ? INVALID + "precision" : INVALID_DP); + } + + x = new Big(x); + + // The index of the digit that may be rounded up. + n = k - x.e; + + // Round? + if (x.c.length > ++k) round(x, n, Big.RM); + + // toFixed: recalculate k as x.e may have changed if value rounded up. + if (id == 2) k = x.e + n + 1; + + // Append zeros? + for (; x.c.length < k; ) x.c.push(0); + } + + e = x.e; + s = x.c.join(""); + n = s.length; + + // Exponential notation? + if ( + id != 2 && + (id == 1 || (id == 3 && k <= e) || e <= Big.NE || e >= Big.PE) + ) { + s = + s.charAt(0) + + (n > 1 ? "." + s.slice(1) : "") + + (e < 0 ? "e" : "e+") + + e; + + // Normal notation. + } else if (e < 0) { + for (; ++e; ) s = "0" + s; + s = "0." + s; + } else if (e > 0) { + if (++e > n) for (e -= n; e--; ) s += "0"; + else if (e < n) s = s.slice(0, e) + "." + s.slice(e); + } else if (n > 1) { + s = s.charAt(0) + "." + s.slice(1); + } + + return x.s < 0 && (!z || id == 4) ? "-" + s : s; + } + + // Prototype/instance methods + + /* + * Return a new Big whose value is the absolute value of this Big. + */ + P.abs = function () { + var x = new this.constructor(this); + x.s = 1; + return x; + }; + + /* + * Return 1 if the value of this Big is greater than the value of Big y, + * -1 if the value of this Big is less than the value of Big y, or + * 0 if they have the same value. + */ + P.cmp = function (y) { + var isneg, + x = this, + xc = x.c, + yc = (y = new x.constructor(y)).c, + i = x.s, + j = y.s, + k = x.e, + l = y.e; + + // Either zero? + if (!xc[0] || !yc[0]) return !xc[0] ? (!yc[0] ? 0 : -j) : i; + + // Signs differ? + if (i != j) return i; + + isneg = i < 0; + + // Compare exponents. + if (k != l) return (k > l) ^ isneg ? 1 : -1; + + j = (k = xc.length) < (l = yc.length) ? k : l; + + // Compare digit by digit. + for (i = -1; ++i < j; ) { + if (xc[i] != yc[i]) return (xc[i] > yc[i]) ^ isneg ? 1 : -1; + } + + // Compare lengths. + return k == l ? 0 : (k > l) ^ isneg ? 1 : -1; + }; + + /* + * Return a new Big whose value is the value of this Big divided by the value of Big y, rounded, + * if necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM. + */ + P.div = function (y) { + var x = this, + Big = x.constructor, + a = x.c, // dividend + b = (y = new Big(y)).c, // divisor + k = x.s == y.s ? 1 : -1, + dp = Big.DP; + + if (dp !== ~~dp || dp < 0 || dp > MAX_DP) throw Error(INVALID_DP); + + // Divisor is zero? + if (!b[0]) throw Error(DIV_BY_ZERO); + + // Dividend is 0? Return +-0. + if (!a[0]) return new Big(k * 0); + + var bl, + bt, + n, + cmp, + ri, + bz = b.slice(), + ai = (bl = b.length), + al = a.length, + r = a.slice(0, bl), // remainder + rl = r.length, + q = y, // quotient + qc = (q.c = []), + qi = 0, + d = dp + (q.e = x.e - y.e) + 1; // number of digits of the result + + q.s = k; + k = d < 0 ? 0 : d; + + // Create version of divisor with leading zero. + bz.unshift(0); + + // Add zeros to make remainder as long as divisor. + for (; rl++ < bl; ) r.push(0); + + do { + // n is how many times the divisor goes into current remainder. + for (n = 0; n < 10; n++) { + // Compare divisor and remainder. + if (bl != (rl = r.length)) { + cmp = bl > rl ? 1 : -1; + } else { + for (ri = -1, cmp = 0; ++ri < bl; ) { + if (b[ri] != r[ri]) { + cmp = b[ri] > r[ri] ? 1 : -1; + break; + } + } + } + + // If divisor < remainder, subtract divisor from remainder. + if (cmp < 0) { + // Remainder can't be more than 1 digit longer than divisor. + // Equalise lengths using divisor with extra leading zero? + for (bt = rl == bl ? b : bz; rl; ) { + if (r[--rl] < bt[rl]) { + ri = rl; + for (; ri && !r[--ri]; ) r[ri] = 9; + --r[ri]; + r[rl] += 10; + } + r[rl] -= bt[rl]; + } + + for (; !r[0]; ) r.shift(); + } else { + break; + } + } + + // Add the digit n to the result array. + qc[qi++] = cmp ? n : ++n; + + // Update the remainder. + if (r[0] && cmp) r[rl] = a[ai] || 0; + else r = [a[ai]]; + } while ((ai++ < al || r[0] !== UNDEFINED) && k--); + + // Leading zero? Do not remove if result is simply zero (qi == 1). + if (!qc[0] && qi != 1) { + // There can't be more than one zero. + qc.shift(); + q.e--; + } + + // Round? + if (qi > d) round(q, dp, Big.RM, r[0] !== UNDEFINED); + + return q; + }; + + /* + * Return true if the value of this Big is equal to the value of Big y, otherwise return false. + */ + P.eq = function (y) { + return !this.cmp(y); + }; + + /* + * Return true if the value of this Big is greater than the value of Big y, otherwise return + * false. + */ + P.gt = function (y) { + return this.cmp(y) > 0; + }; + + /* + * Return true if the value of this Big is greater than or equal to the value of Big y, otherwise + * return false. + */ + P.gte = function (y) { + return this.cmp(y) > -1; + }; + + /* + * Return true if the value of this Big is less than the value of Big y, otherwise return false. + */ + P.lt = function (y) { + return this.cmp(y) < 0; + }; + + /* + * Return true if the value of this Big is less than or equal to the value of Big y, otherwise + * return false. + */ + P.lte = function (y) { + return this.cmp(y) < 1; + }; + + /* + * Return a new Big whose value is the value of this Big minus the value of Big y. + */ + P.minus = P.sub = function (y) { + var i, + j, + t, + xlty, + x = this, + Big = x.constructor, + a = x.s, + b = (y = new Big(y)).s; + + // Signs differ? + if (a != b) { + y.s = -b; + return x.plus(y); + } + + var xc = x.c.slice(), + xe = x.e, + yc = y.c, + ye = y.e; + + // Either zero? + if (!xc[0] || !yc[0]) { + // y is non-zero? x is non-zero? Or both are zero. + return yc[0] ? ((y.s = -b), y) : new Big(xc[0] ? x : 0); + } + + // Determine which is the bigger number. Prepend zeros to equalise exponents. + if ((a = xe - ye)) { + if ((xlty = a < 0)) { + a = -a; + t = xc; + } else { + ye = xe; + t = yc; + } + + t.reverse(); + for (b = a; b--; ) t.push(0); + t.reverse(); + } else { + // Exponents equal. Check digit by digit. + j = ((xlty = xc.length < yc.length) ? xc : yc).length; + + for (a = b = 0; b < j; b++) { + if (xc[b] != yc[b]) { + xlty = xc[b] < yc[b]; + break; + } + } + } + + // x < y? Point xc to the array of the bigger number. + if (xlty) { + t = xc; + xc = yc; + yc = t; + y.s = -y.s; + } + + /* + * Append zeros to xc if shorter. No need to add zeros to yc if shorter as subtraction only + * needs to start at yc.length. + */ + if ((b = (j = yc.length) - (i = xc.length)) > 0) for (; b--; ) xc[i++] = 0; + + // Subtract yc from xc. + for (b = i; j > a; ) { + if (xc[--j] < yc[j]) { + for (i = j; i && !xc[--i]; ) xc[i] = 9; + --xc[i]; + xc[j] += 10; + } + + xc[j] -= yc[j]; + } + + // Remove trailing zeros. + for (; xc[--b] === 0; ) xc.pop(); + + // Remove leading zeros and adjust exponent accordingly. + for (; xc[0] === 0; ) { + xc.shift(); + --ye; + } + + if (!xc[0]) { + // n - n = +0 + y.s = 1; + + // Result must be zero. + xc = [(ye = 0)]; + } + + y.c = xc; + y.e = ye; + + return y; + }; + + /* + * Return a new Big whose value is the value of this Big modulo the value of Big y. + */ + P.mod = function (y) { + var ygtx, + x = this, + Big = x.constructor, + a = x.s, + b = (y = new Big(y)).s; + + if (!y.c[0]) throw Error(DIV_BY_ZERO); + + x.s = y.s = 1; + ygtx = y.cmp(x) == 1; + x.s = a; + y.s = b; + + if (ygtx) return new Big(x); + + a = Big.DP; + b = Big.RM; + Big.DP = Big.RM = 0; + x = x.div(y); + Big.DP = a; + Big.RM = b; + + return this.minus(x.times(y)); + }; + + /* + * Return a new Big whose value is the value of this Big plus the value of Big y. + */ + P.plus = P.add = function (y) { + var t, + x = this, + Big = x.constructor, + a = x.s, + b = (y = new Big(y)).s; + + // Signs differ? + if (a != b) { + y.s = -b; + return x.minus(y); + } + + var xe = x.e, + xc = x.c, + ye = y.e, + yc = y.c; + + // Either zero? y is non-zero? x is non-zero? Or both are zero. + if (!xc[0] || !yc[0]) return yc[0] ? y : new Big(xc[0] ? x : a * 0); + + xc = xc.slice(); + + // Prepend zeros to equalise exponents. + // Note: reverse faster than unshifts. + if ((a = xe - ye)) { + if (a > 0) { + ye = xe; + t = yc; + } else { + a = -a; + t = xc; + } + + t.reverse(); + for (; a--; ) t.push(0); + t.reverse(); + } + + // Point xc to the longer array. + if (xc.length - yc.length < 0) { + t = yc; + yc = xc; + xc = t; + } + + a = yc.length; + + // Only start adding at yc.length - 1 as the further digits of xc can be left as they are. + for (b = 0; a; xc[a] %= 10) b = ((xc[--a] = xc[a] + yc[a] + b) / 10) | 0; + + // No need to check for zero, as +x + +y != 0 && -x + -y != 0 + + if (b) { + xc.unshift(b); + ++ye; + } + + // Remove trailing zeros. + for (a = xc.length; xc[--a] === 0; ) xc.pop(); + + y.c = xc; + y.e = ye; + + return y; + }; + + /* + * Return a Big whose value is the value of this Big raised to the power n. + * If n is negative, round to a maximum of Big.DP decimal places using rounding + * mode Big.RM. + * + * n {number} Integer, -MAX_POWER to MAX_POWER inclusive. + */ + P.pow = function (n) { + var x = this, + one = new x.constructor(1), + y = one, + isneg = n < 0; + + if (n !== ~~n || n < -MAX_POWER || n > MAX_POWER) + throw Error(INVALID + "exponent"); + if (isneg) n = -n; + + for (;;) { + if (n & 1) y = y.times(x); + n >>= 1; + if (!n) break; + x = x.times(x); + } + + return isneg ? one.div(y) : y; + }; + + /* + * Return a new Big whose value is the value of this Big rounded using rounding mode rm + * to a maximum of dp decimal places, or, if dp is negative, to an integer which is a + * multiple of 10**-dp. + * If dp is not specified, round to 0 decimal places. + * If rm is not specified, use Big.RM. + * + * dp? {number} Integer, -MAX_DP to MAX_DP inclusive. + * rm? 0, 1, 2 or 3 (ROUND_DOWN, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_UP) + */ + P.round = function (dp, rm) { + var Big = this.constructor; + if (dp === UNDEFINED) dp = 0; + else if (dp !== ~~dp || dp < -MAX_DP || dp > MAX_DP) + throw Error(INVALID_DP); + return round(new Big(this), dp, rm === UNDEFINED ? Big.RM : rm); + }; + + /* + * Return a new Big whose value is the square root of the value of this Big, rounded, if + * necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM. + */ + P.sqrt = function () { + var r, + c, + t, + x = this, + Big = x.constructor, + s = x.s, + e = x.e, + half = new Big(0.5); + + // Zero? + if (!x.c[0]) return new Big(x); + + // Negative? + if (s < 0) throw Error(NAME + "No square root"); + + // Estimate. + s = Math.sqrt(x + ""); + + // Math.sqrt underflow/overflow? + // Re-estimate: pass x coefficient to Math.sqrt as integer, then adjust the result exponent. + if (s === 0 || s === 1 / 0) { + c = x.c.join(""); + if (!((c.length + e) & 1)) c += "0"; + s = Math.sqrt(c); + e = (((e + 1) / 2) | 0) - (e < 0 || e & 1); + r = new Big( + (s == 1 / 0 + ? "1e" + : (s = s.toExponential()).slice(0, s.indexOf("e") + 1)) + e + ); + } else { + r = new Big(s); + } + + e = r.e + (Big.DP += 4); + + // Newton-Raphson iteration. + do { + t = r; + r = half.times(t.plus(x.div(t))); + } while (t.c.slice(0, e).join("") !== r.c.slice(0, e).join("")); + + return round(r, (Big.DP -= 4), Big.RM); + }; + + /* + * Return a new Big whose value is the value of this Big times the value of Big y. + */ + P.times = P.mul = function (y) { + var c, + x = this, + Big = x.constructor, + xc = x.c, + yc = (y = new Big(y)).c, + a = xc.length, + b = yc.length, + i = x.e, + j = y.e; + + // Determine sign of result. + y.s = x.s == y.s ? 1 : -1; + + // Return signed 0 if either 0. + if (!xc[0] || !yc[0]) return new Big(y.s * 0); + + // Initialise exponent of result as x.e + y.e. + y.e = i + j; + + // If array xc has fewer digits than yc, swap xc and yc, and lengths. + if (a < b) { + c = xc; + xc = yc; + yc = c; + j = a; + a = b; + b = j; + } + + // Initialise coefficient array of result with zeros. + for (c = new Array((j = a + b)); j--; ) c[j] = 0; + + // Multiply. + + // i is initially xc.length. + for (i = b; i--; ) { + b = 0; + + // a is yc.length. + for (j = a + i; j > i; ) { + // Current sum of products at this digit position, plus carry. + b = c[j] + yc[i] * xc[j - i - 1] + b; + c[j--] = b % 10; + + // carry + b = (b / 10) | 0; + } + + c[j] = (c[j] + b) % 10; + } + + // Increment result exponent if there is a final carry, otherwise remove leading zero. + if (b) ++y.e; + else c.shift(); + + // Remove trailing zeros. + for (i = c.length; !c[--i]; ) c.pop(); + y.c = c; + + return y; + }; + + /* + * Return a string representing the value of this Big in exponential notation to dp fixed decimal + * places and rounded using Big.RM. + * + * dp? {number} Integer, 0 to MAX_DP inclusive. + */ + P.toExponential = function (dp) { + return stringify(this, 1, dp, dp); + }; + + /* + * Return a string representing the value of this Big in normal notation to dp fixed decimal + * places and rounded using Big.RM. + * + * dp? {number} Integer, 0 to MAX_DP inclusive. + * + * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'. + * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'. + */ + P.toFixed = function (dp) { + return stringify(this, 2, dp, this.e + dp); + }; + + /* + * Return a string representing the value of this Big rounded to sd significant digits using + * Big.RM. Use exponential notation if sd is less than the number of digits necessary to represent + * the integer part of the value in normal notation. + * + * sd {number} Integer, 1 to MAX_DP inclusive. + */ + P.toPrecision = function (sd) { + return stringify(this, 3, sd, sd - 1); + }; + + /* + * Return a string representing the value of this Big. + * Return exponential notation if this Big has a positive exponent equal to or greater than + * Big.PE, or a negative exponent equal to or less than Big.NE. + * Omit the sign for negative zero. + */ + P.toString = function () { + return stringify(this); + }; + + /* + * Return a string representing the value of this Big. + * Return exponential notation if this Big has a positive exponent equal to or greater than + * Big.PE, or a negative exponent equal to or less than Big.NE. + * Include the sign for negative zero. + */ + P.valueOf = P.toJSON = function () { + return stringify(this, 4); + }; + + // Export + + Big = _Big_(); + + Big["default"] = Big.Big = Big; + + //AMD. + if (typeof define === "function" && define.amd) { + define(function () { + return Big; + }); + + // Node and other CommonJS-like environments that support module.exports. + } else if (typeof module !== "undefined" && module.exports) { + module.exports = Big; + + //Browser. + } else { + GLOBAL.Big = Big; + } +})(this); diff --git a/src/api/business/inspectionTask.js b/src/api/business/inspectionTask.js index d8704f6..c3dab1e 100644 --- a/src/api/business/inspectionTask.js +++ b/src/api/business/inspectionTask.js @@ -269,3 +269,12 @@ params: query, }); } + +// 妫�楠屽崟璇︽儏-浠诲姟鍒囨崲 +export function inspectionOrderDetailsTaskSwitching(query) { + return request({ + url: "/insOrderPlan/inspectionOrderDetailsTaskSwitching", + method: "get", + params: query, + }); +} diff --git a/src/components/Table/lims-table.vue b/src/components/Table/lims-table.vue index 2f12565..725f320 100644 --- a/src/components/Table/lims-table.vue +++ b/src/components/Table/lims-table.vue @@ -1,82 +1,29 @@ <template> <div> <!-- 琛ㄦ牸 --> - <el-table - ref="multipleTable" - v-loading="tableLoading" - :border="border" - :data="tableData" - :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" - :height="height" - :highlight-current-row="highlightCurrentRow" - :row-class-name="rowClassName" - :row-style="rowStyle" - :row-key="rowKey" - :span-method="spanMethod" - stripe - style="width: 100%" - tooltip-effect="dark" - @row-click="rowClick" - @current-change="currentChange" - @selection-change="handleSelectionChange" - > - <el-table-column - align="center" - type="selection" - width="55" - v-if="isSelection" - /> - <el-table-column - align="center" - label="搴忓彿" - type="index" - width="60" - :index="indexMethod" - /> + <el-table ref="multipleTable" v-loading="tableLoading" :border="border" :data="tableData" + :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" :height="height" + :highlight-current-row="highlightCurrentRow" :row-class-name="rowClassName" :row-style="rowStyle" + :row-key="rowKey" :span-method="spanMethod" stripe style="width: 100%" tooltip-effect="dark" @row-click="rowClick" + @current-change="currentChange" @selection-change="handleSelectionChange"> + <el-table-column align="center" type="selection" width="55" v-if="isSelection" /> + <el-table-column align="center" label="搴忓彿" type="index" width="60" :index="indexMethod" /> - <el-table-column - v-for="(item, index) in column" - :key="index" - :column-key="item.columnKey" - :filter-method="item.filterHandler" - :filter-multiple="item.filterMultiple" - :filtered-value="item.filteredValue" - :filters="item.filters" - :fixed="item.fixed" - :label="item.label" - :min-width="item.minWidth" - :prop="item.prop" - :show-overflow-tooltip="item.dataType === 'action' ? false : true" - :sortable="item.sortable ? true : false" - :type="item.type" - :width=" - item.dataType === 'action' ? getWidth(item.operation) : item.width - " - align="center" - > + <el-table-column v-for="(item, index) in column" :key="index" :column-key="item.columnKey" + :filter-method="item.filterHandler" :filter-multiple="item.filterMultiple" :filtered-value="item.filteredValue" + :filters="item.filters" :fixed="item.fixed" :label="item.label" :min-width="item.minWidth" :prop="item.prop" + :show-overflow-tooltip="item.dataType === 'action' ? false : true" :sortable="item.sortable ? true : false" + :type="item.type" :width="item.dataType === 'action' ? getWidth(item.operation) : item.width + " align="center"> <!-- <div class="123" v-if="item.type == ''"> --> - <template - v-if="item.hasOwnProperty('colunmTemplate')" - :slot="item.colunmTemplate" - slot-scope="scope" - > - <slot - v-if="item.theadSlot" - :index="index" - :name="item.theadSlot" - :row="scope.row" - /> + <template v-if="item.hasOwnProperty('colunmTemplate')" :slot="item.colunmTemplate" slot-scope="scope"> + <slot v-if="item.theadSlot" :index="index" :name="item.theadSlot" :row="scope.row" /> </template> <template slot-scope="scope"> <!-- 鎻掓Ы --> <div v-if="item.dataType == 'slot'"> - <slot - v-if="item.slot" - :index="scope.$index" - :name="item.slot" - :row="scope.row" - /> + <slot v-if="item.slot" :index="scope.$index" :name="item.slot" :row="scope.row" /> </div> <!-- 杩涘害鏉� --> <div v-else-if="item.dataType == 'progress'"> @@ -84,107 +31,61 @@ </div> <!-- 鍥剧墖 --> <div v-else-if="item.dataType == 'image'"> - <img - :src="javaApi + '/img/' + item.prop" - alt="" - style="width: 40px; height: 40px; margin-top: 10px" - /> + <img :src="javaApi + '/img/' + item.prop" alt="" style="width: 40px; height: 40px; margin-top: 10px" /> </div> <!-- tag --> <div v-else-if="item.dataType == 'tag'"> - <el-tag - v-if=" - typeof dataTypeFn(scope.row[item.prop], item.formatData) == - 'string' - " - :title="scope.row[item.prop] | formatters(item.formatData)" - :type="formatType(scope.row[item.prop], item.formatType)" - >{{ scope.row[item.prop] | formatters(item.formatData) }}</el-tag - > - <el-tag - v-for="(tag, index) in dataTypeFn( - scope.row[item.prop], - item.formatData - )" - v-else-if=" - typeof dataTypeFn(scope.row[item.prop], item.formatData) == - 'object' - " - :key="index" - :title="scope.row[item.prop] | formatters(item.formatData)" - :type="formatType(tag, item.formatType)" - >{{ + <el-tag v-if=" + typeof dataTypeFn(scope.row[item.prop], item.formatData) == + 'string' + " :title="scope.row[item.prop] | formatters(item.formatData)" + :type="formatType(scope.row[item.prop], item.formatType)">{{ scope.row[item.prop] | + formatters(item.formatData) }}</el-tag> + <el-tag v-for="(tag, index) in dataTypeFn( + scope.row[item.prop], + item.formatData + )" v-else-if=" + typeof dataTypeFn(scope.row[item.prop], item.formatData) == + 'object' + " :key="index" :title="scope.row[item.prop] | formatters(item.formatData)" + :type="formatType(tag, item.formatType)">{{ item.tagGroup ? tag[item.tagGroup.label] ? tag[item.tagGroup.label] : tag : tag - }}</el-tag - > - <el-tag - v-else - :title="scope.row[item.prop] | formatters(item.formatData)" - :type="formatType(scope.row[item.prop], item.formatType)" - >{{ scope.row[item.prop] | formatters(item.formatData) }}</el-tag - > + }}</el-tag> + <el-tag v-else :title="scope.row[item.prop] | formatters(item.formatData)" + :type="formatType(scope.row[item.prop], item.formatType)">{{ scope.row[item.prop] | + formatters(item.formatData) }}</el-tag> </div> <!-- 鎸夐挳 --> <div v-else-if="item.dataType == 'action'"> <template v-for="(o, key) in item.operation"> - <el-button - v-if="o.type != 'upload'" - size="mini" - v-show="o.showHide ? o.showHide(scope.row) : true" - :disabled="o.disabled ? o.disabled(scope.row) : false" - :icon="iconFn(o)" - :plain="o.plain" - :style="{ color: o.name === '鍒犻櫎' ? '#f56c6c' : o.color }" - :type="o.type | typeFn(scope.row)" - @click="o.clickFun(scope.row)" - :key="key" - > + <el-button v-if="o.type != 'upload'" size="mini" v-show="o.showHide ? o.showHide(scope.row) : true" + :disabled="o.disabled ? o.disabled(scope.row) : false" :icon="iconFn(o)" :plain="o.plain" + :style="{ color: o.name === '鍒犻櫎' ? '#f56c6c' : o.color }" :type="o.type | typeFn(scope.row)" + @click="o.clickFun(scope.row)" :key="key"> {{ o.name }} </el-button> - <el-upload - action="#" - size="mini" - :on-change=" - (file, fileList) => o.clickFun(scope.row, file, fileList) - " - :multiple="o.multiple ? o.multiple : false" - :limit="o.limit ? o.limit : 1" - :disabled="o.disabled ? o.disabled(scope.row) : false" - :accept=" - o.accept - ? o.accept - : '.jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar' - " - v-if="o.type == 'upload'" - style="display: inline-block; width: 50px" - v-show="o.showHide ? o.showHide(scope.row) : true" - :auto-upload="false" - :on-exceed="onExceed" - :show-file-list="false" - :key="key" - > - <el-button - :size="o.size ? o.size : 'small'" - type="text" - :disabled="o.disabled ? o.disabled(scope.row) : false" - >{{ o.name }}</el-button - > + <el-upload action="#" size="mini" :on-change="(file, fileList) => o.clickFun(scope.row, file, fileList) + " :multiple="o.multiple ? o.multiple : false" :limit="o.limit ? o.limit : 1" + :disabled="o.disabled ? o.disabled(scope.row) : false" :accept="o.accept + ? o.accept + : '.jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar' + " v-if="o.type == 'upload'" style="display: inline-block; width: 50px" + v-show="o.showHide ? o.showHide(scope.row) : true" :auto-upload="false" :on-exceed="onExceed" + :show-file-list="false" :key="key"> + <el-button :size="o.size ? o.size : 'small'" type="text" + :disabled="o.disabled ? o.disabled(scope.row) : false">{{ o.name }}</el-button> </el-upload> </template> </div> <!-- 鍙偣鍑荤殑鏂囧瓧 --> - <div - v-else-if="item.dataType == 'link'" - class="cell link" - style="width: 100%" - @click="goLink(scope.row, item.linkMethod)" - > + <div v-else-if="item.dataType == 'link'" class="cell link" style="width: 100%" + @click="goLink(scope.row, item.linkMethod)"> <span v-if="!item.formatData">{{ scope.row[item.prop] }}</span> </div> <!-- 榛樿绾睍绀烘暟鎹� --> @@ -197,14 +98,8 @@ </template> </el-table-column> </el-table> - <pagination - v-show="page.total > 0" - :total="page.total" - :layout="page.layout" - :page.sync="page.current" - :limit.sync="page.size" - @pagination="pagination" - /> + <pagination v-show="page.total > 0" :total="page.total" :layout="page.layout" :page.sync="page.current" + :limit.sync="page.size" @pagination="pagination" /> </div> </template> @@ -294,19 +189,19 @@ handleSelectionChange: { type: Function, default: () => { - return () => {}; + return () => { }; }, }, rowClick: { type: Function, default: () => { - return () => {}; + return () => { }; }, }, currentChange: { type: Function, default: () => { - return () => {}; + return () => { }; }, }, border: { @@ -331,11 +226,11 @@ }, rowClassName: { type: Function, - default: () => {}, + default: () => { }, }, rowStyle: { type: Object || Function, - default: () => {}, + default: () => { }, }, tableData: { type: Array, @@ -506,13 +401,14 @@ </script> <style scoped> -.el-table >>> .el-table__empty-text { +.el-table>>>.el-table__empty-text { text-align: center; } ->>> .cell { +>>>.cell { padding: 0 !important; } + .cell { white-space: nowrap; overflow: hidden; @@ -520,11 +416,14 @@ padding-right: 4px !important; padding-left: 10px !important; } + .link { color: rgb(64, 158, 255); cursor: pointer; } ->>> .el-table__body-wrapper::-webkit-scrollbar { - height: 14px; /* 璁剧疆婊氬姩鏉″搴� */ + +>>>.el-table__body-wrapper::-webkit-scrollbar { + height: 14px; + /* 璁剧疆婊氬姩鏉″搴� */ } </style> diff --git a/src/router/index.js b/src/router/index.js index 298860f..f6b55c0 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -101,17 +101,21 @@ children: [ { // 鍘熸潗鏂欎笅鍗� - path: 'customsInspection', - component: () => import('@/views/business/materialOrder/customsInspection'), - name: 'customsInspection', - meta: { title: '鍘熸潗鏂欎笅鍗曡鎯�', activeMenu: '/business/materialOrder' } + path: "customsInspection", + component: () => + import("@/views/business/materialOrder/customsInspection"), + name: "customsInspection", + meta: { + title: "鍘熸潗鏂欎笅鍗曡鎯�", + activeMenu: "/business/materialOrder", + }, }, { // 閾滄潗鏂欎笅鍗� - path: 'copperOrder', - component: () => import('@/views/business/materialOrder/copperOrder'), - name: 'copperOrder', - meta: { title: '閾滄潗鏂欎笅鍗�', activeMenu: '/business/materialOrder' } + path: "copperOrder", + component: () => import("@/views/business/materialOrder/copperOrder"), + name: "copperOrder", + meta: { title: "閾滄潗鏂欎笅鍗�", activeMenu: "/business/materialOrder" }, }, ], }, diff --git a/src/utils/request.js b/src/utils/request.js index ffb0d21..1a89ee8 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,114 +1,148 @@ -import axios from 'axios' -import { Notification, MessageBox, Message, Loading } from 'element-ui' -import store from '@/store' -import { getToken } from '@/utils/auth' -import errorCode from '@/utils/errorCode' +import axios from "axios"; +import { Notification, MessageBox, Message, Loading } from "element-ui"; +import store from "@/store"; +import { getToken } from "@/utils/auth"; +import errorCode from "@/utils/errorCode"; import { tansParams, blobValidate } from "@/utils/ruoyi"; -import cache from '@/plugins/cache' -import { saveAs } from 'file-saver' +import cache from "@/plugins/cache"; +import { saveAs } from "file-saver"; let downloadLoadingInstance; // 鏄惁鏄剧ず閲嶆柊鐧诲綍 export let isRelogin = { show: false }; -axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' +axios.defaults.headers["Content-Type"] = "application/json;charset=utf-8"; // 鍒涘缓axios瀹炰緥 const service = axios.create({ // axios涓姹傞厤缃湁baseURL閫夐」锛岃〃绀鸿姹俇RL鍏叡閮ㄥ垎 baseURL: process.env.VUE_APP_BASE_API, // 瓒呮椂 - timeout: 10000 -}) + timeout: 10000 * 60, +}); // request鎷︽埅鍣� -service.interceptors.request.use(config => { - // 鏄惁闇�瑕佽缃� token - const isToken = (config.headers || {}).isToken === false - // 鏄惁闇�瑕侀槻姝㈡暟鎹噸澶嶆彁浜� - const isRepeatSubmit = (config.headers || {}).repeatSubmit === false - if (getToken() && !isToken) { - config.headers['Authorization'] = 'Bearer ' + getToken() // 璁╂瘡涓姹傛惡甯﹁嚜瀹氫箟token 璇锋牴鎹疄闄呮儏鍐佃嚜琛屼慨鏀� - } - // get璇锋眰鏄犲皠params鍙傛暟 - if (config.method === 'get' && config.params) { - let url = config.url + '?' + tansParams(config.params); - url = url.slice(0, -1); - config.params = {}; - config.url = url; - } - if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) { - const requestObj = { - url: config.url, - data: typeof config.data === 'object' ? JSON.stringify(config.data) : config.data, - time: new Date().getTime() +service.interceptors.request.use( + (config) => { + // 鏄惁闇�瑕佽缃� token + const isToken = (config.headers || {}).isToken === false; + // 鏄惁闇�瑕侀槻姝㈡暟鎹噸澶嶆彁浜� + const isRepeatSubmit = (config.headers || {}).repeatSubmit === false; + if (getToken() && !isToken) { + config.headers["Authorization"] = "Bearer " + getToken(); // 璁╂瘡涓姹傛惡甯﹁嚜瀹氫箟token 璇锋牴鎹疄闄呮儏鍐佃嚜琛屼慨鏀� } - const requestSize = Object.keys(JSON.stringify(requestObj)).length; // 璇锋眰鏁版嵁澶у皬 - const limitSize = 5 * 1024 * 1024; // 闄愬埗瀛樻斁鏁版嵁5M - if (requestSize >= limitSize) { - console.warn(`[${config.url}]: ` + '璇锋眰鏁版嵁澶у皬瓒呭嚭鍏佽鐨�5M闄愬埗锛屾棤娉曡繘琛岄槻閲嶅鎻愪氦楠岃瘉銆�') - return config; + // get璇锋眰鏄犲皠params鍙傛暟 + if (config.method === "get" && config.params) { + let url = config.url + "?" + tansParams(config.params); + url = url.slice(0, -1); + config.params = {}; + config.url = url; } - const sessionObj = cache.session.getJSON('sessionObj') - if (sessionObj === undefined || sessionObj === null || sessionObj === '') { - cache.session.setJSON('sessionObj', requestObj) - } else { - const s_url = sessionObj.url; // 璇锋眰鍦板潃 - const s_data = sessionObj.data; // 璇锋眰鏁版嵁 - const s_time = sessionObj.time; // 璇锋眰鏃堕棿 - const interval = 1000; // 闂撮殧鏃堕棿(ms)锛屽皬浜庢鏃堕棿瑙嗕负閲嶅鎻愪氦 - if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) { - const message = '鏁版嵁姝e湪澶勭悊锛岃鍕块噸澶嶆彁浜�'; - console.warn(`[${s_url}]: ` + message) - return Promise.reject(new Error(message)) + if ( + !isRepeatSubmit && + (config.method === "post" || config.method === "put") + ) { + const requestObj = { + url: config.url, + data: + typeof config.data === "object" + ? JSON.stringify(config.data) + : config.data, + time: new Date().getTime(), + }; + const requestSize = Object.keys(JSON.stringify(requestObj)).length; // 璇锋眰鏁版嵁澶у皬 + const limitSize = 5 * 1024 * 1024; // 闄愬埗瀛樻斁鏁版嵁5M + if (requestSize >= limitSize) { + console.warn( + `[${config.url}]: ` + + "璇锋眰鏁版嵁澶у皬瓒呭嚭鍏佽鐨�5M闄愬埗锛屾棤娉曡繘琛岄槻閲嶅鎻愪氦楠岃瘉銆�" + ); + return config; + } + const sessionObj = cache.session.getJSON("sessionObj"); + if ( + sessionObj === undefined || + sessionObj === null || + sessionObj === "" + ) { + cache.session.setJSON("sessionObj", requestObj); } else { - cache.session.setJSON('sessionObj', requestObj) + const s_url = sessionObj.url; // 璇锋眰鍦板潃 + const s_data = sessionObj.data; // 璇锋眰鏁版嵁 + const s_time = sessionObj.time; // 璇锋眰鏃堕棿 + const interval = 1000; // 闂撮殧鏃堕棿(ms)锛屽皬浜庢鏃堕棿瑙嗕负閲嶅鎻愪氦 + if ( + s_data === requestObj.data && + requestObj.time - s_time < interval && + s_url === requestObj.url + ) { + const message = "鏁版嵁姝e湪澶勭悊锛岃鍕块噸澶嶆彁浜�"; + console.warn(`[${s_url}]: ` + message); + return Promise.reject(new Error(message)); + } else { + cache.session.setJSON("sessionObj", requestObj); + } } } + return config; + }, + (error) => { + console.log(error); + Promise.reject(error); } - return config -}, error => { - console.log(error) - Promise.reject(error) -}) +); // 鍝嶅簲鎷︽埅鍣� -service.interceptors.response.use(res => { +service.interceptors.response.use( + (res) => { // 鏈缃姸鎬佺爜鍒欓粯璁ゆ垚鍔熺姸鎬� const code = res.data.code || 200; // 鑾峰彇閿欒淇℃伅 - const msg = errorCode[code] || res.data.msg || errorCode['default'] + const msg = errorCode[code] || res.data.msg || errorCode["default"]; // 浜岃繘鍒舵暟鎹垯鐩存帴杩斿洖 - if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') { - return res.data + if ( + res.request.responseType === "blob" || + res.request.responseType === "arraybuffer" + ) { + return res.data; } if (code === 401) { if (!isRelogin.show) { isRelogin.show = true; - MessageBox.confirm('鐧诲綍鐘舵�佸凡杩囨湡锛屾偍鍙互缁х画鐣欏湪璇ラ〉闈紝鎴栬�呴噸鏂扮櫥褰�', '绯荤粺鎻愮ず', { confirmButtonText: '閲嶆柊鐧诲綍', cancelButtonText: '鍙栨秷', type: 'warning' }).then(() => { - isRelogin.show = false; - store.dispatch('LogOut').then(() => { - location.href = '/index'; + MessageBox.confirm( + "鐧诲綍鐘舵�佸凡杩囨湡锛屾偍鍙互缁х画鐣欏湪璇ラ〉闈紝鎴栬�呴噸鏂扮櫥褰�", + "绯荤粺鎻愮ず", + { + confirmButtonText: "閲嶆柊鐧诲綍", + cancelButtonText: "鍙栨秷", + type: "warning", + } + ) + .then(() => { + isRelogin.show = false; + store.dispatch("LogOut").then(() => { + location.href = "/index"; + }); }) - }).catch(() => { - isRelogin.show = false; - }); - } - return Promise.reject('鏃犳晥鐨勪細璇濓紝鎴栬�呬細璇濆凡杩囨湡锛岃閲嶆柊鐧诲綍銆�') + .catch(() => { + isRelogin.show = false; + }); + } + return Promise.reject("鏃犳晥鐨勪細璇濓紝鎴栬�呬細璇濆凡杩囨湡锛岃閲嶆柊鐧诲綍銆�"); } else if (code === 500) { - Message({ message: msg, type: 'error' }) - return Promise.reject(new Error(msg)) + Message({ message: msg, type: "error" }); + return Promise.reject(new Error(msg)); } else if (code === 601) { - Message({ message: msg, type: 'warning' }) - return Promise.reject('error') + Message({ message: msg, type: "warning" }); + return Promise.reject("error"); } else if (code !== 200) { - Notification.error({ title: msg }) - return Promise.reject('error') + Notification.error({ title: msg }); + return Promise.reject("error"); } else { - return res.data + return res.data; } }, - error => { - console.log('err' + error) + (error) => { + console.log("err" + error); let { message } = error; if (message == "Network Error") { message = "鍚庣鎺ュ彛杩炴帴寮傚父"; @@ -117,36 +151,48 @@ } else if (message.includes("Request failed with status code")) { message = "绯荤粺鎺ュ彛" + message.substr(message.length - 3) + "寮傚父"; } - Message({ message: message, type: 'error', duration: 5 * 1000 }) - return Promise.reject(error) + Message({ message: message, type: "error", duration: 5 * 1000 }); + return Promise.reject(error); } -) +); // 閫氱敤涓嬭浇鏂规硶 export function download(url, params, filename, config) { - downloadLoadingInstance = Loading.service({ text: "姝e湪涓嬭浇鏁版嵁锛岃绋嶅��", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }) - return service.post(url, params, { - transformRequest: [(params) => { return tansParams(params) }], - headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, - responseType: 'blob', - ...config - }).then(async (data) => { - const isBlob = blobValidate(data); - if (isBlob) { - const blob = new Blob([data]) - saveAs(blob, filename) - } else { - const resText = await data.text(); - const rspObj = JSON.parse(resText); - const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default'] - Message.error(errMsg); - } - downloadLoadingInstance.close(); - }).catch((r) => { - console.error(r) - Message.error('涓嬭浇鏂囦欢鍑虹幇閿欒锛岃鑱旂郴绠$悊鍛橈紒') - downloadLoadingInstance.close(); - }) + downloadLoadingInstance = Loading.service({ + text: "姝e湪涓嬭浇鏁版嵁锛岃绋嶅��", + spinner: "el-icon-loading", + background: "rgba(0, 0, 0, 0.7)", + }); + return service + .post(url, params, { + transformRequest: [ + (params) => { + return tansParams(params); + }, + ], + headers: { "Content-Type": "application/x-www-form-urlencoded" }, + responseType: "blob", + ...config, + }) + .then(async (data) => { + const isBlob = blobValidate(data); + if (isBlob) { + const blob = new Blob([data]); + saveAs(blob, filename); + } else { + const resText = await data.text(); + const rspObj = JSON.parse(resText); + const errMsg = + errorCode[rspObj.code] || rspObj.msg || errorCode["default"]; + Message.error(errMsg); + } + downloadLoadingInstance.close(); + }) + .catch((r) => { + console.error(r); + Message.error("涓嬭浇鏂囦欢鍑虹幇閿欒锛岃鑱旂郴绠$悊鍛橈紒"); + downloadLoadingInstance.close(); + }); } -export default service +export default service; diff --git a/src/views/business/inspectionTask/inspection.vue b/src/views/business/inspectionTask/inspection.vue index f6c7d33..6ae2972 100644 --- a/src/views/business/inspectionTask/inspection.vue +++ b/src/views/business/inspectionTask/inspection.vue @@ -1,9 +1,7 @@ <template> <div v-loading="loading" class="inspection"> <el-row class="title"> - <el-col :span="4" style="padding-left: 20px; text-align: left">妫�楠屽崟璇︽儏 - </el-col> - <el-col :span="20" style="text-align: right"> + <el-col :span="8" style="text-align: left"> <el-form :inline="true" :model="otherForm" class="form-inline" label-width="50px" style="text-align: right; padding-top: 0; display: inline"> <el-form-item label="娓╁害:" style="margin-bottom: 0"> @@ -17,7 +15,9 @@ <span style="margin-left: 4px">%</span> </el-form-item> </el-form> - <el-button size="small" type="primary" @click="refreshView">鍒锋柊</el-button> + </el-col> + <el-col :span="16" style="text-align: right"> + <!-- <el-button size="small" type="primary" @click="refreshView">鍒锋柊</el-button> --> <el-button v-if="typeSource === 1" size="small" type="primary" @click="openPurchase">杩涜揣楠岃瘉</el-button> <el-button v-if="state === 1 && typeSource === 1" size="small" type="primary" @click="openUnPassDialog('add')">涓嶅悎鏍煎鐞�</el-button> @@ -68,7 +68,7 @@ <el-form-item v-if="typeSource === 1" label="鍘傚瀵嗗害:"> <el-input v-model="supplierDensity" clearable disabled placeholder="璇疯緭鍏�" size="small"></el-input> </el-form-item> - <el-form-item label="褰撳墠鏍峰搧浣嶆暟:"> + <el-form-item label="褰撳墠鏍峰搧浣嶆暟:" label-width="120px"> <el-tag v-if="currentKey">{{ `NO.${currentKey}` }}</el-tag> </el-form-item> <el-form-item label="澶囨敞:"> @@ -78,6 +78,7 @@ <!-- <el-tag v-if="currentKey">{{ insOrder.remark }}</el-tag> --> </el-form-item> </el-form> + <el-divider></el-divider> </div> <div class="center"> <div class="search" style=" @@ -149,74 +150,64 @@ </div> </div> <!-- 甯歌妫�楠屽師濮嬭褰� --> - <div v-if=" - !tableLists.find((m) => m.templateId == currentTable) || - (tableLists.find((m) => m.templateId == currentTable).templateName != - '娓╁害寰幆妫�楠屽師濮嬭褰�' && - !tableLists - .find((m) => m.templateId == currentTable) - .templateName.includes('鐑惊鐜�') && - !tableLists - .find((m) => m.templateId == currentTable) - .templateName.includes('娓╁崌璇曢獙') && - tableLists.find((m) => m.templateId == currentTable).templateName != - '寮у瀭鐗规�ф楠屽師濮嬭褰�') - " id="nav" v-loading="tableLoading" class="center-box"> - <table v-for="(item, index) in tableList" :key="index + currentTable + currentSample.id" border="1" - cellpadding="10" class="tables" id="myTable"> - <tbody> - <tr style="white-space: nowrap"> - 濮旀墭缂栧彿锛歿{ - insOrder.entrustCode - }} - </tr> - <tr v-for="(m, i) in item.arr" :key="i"> - <td v-for="(n, j) in m" v-if="n.v.mc == undefined || Object.keys(n.v.mc).length === 4" - :id="item.templateId + '-' + n.i + '-' + n.r + '-' + n.c" :key="j" - :colspan="n.v.mc && n.v.mc.cs ? n.v.mc.cs : 1" :rowspan="n.v.mc && n.v.mc.rs ? n.v.mc.rs : 1" :style="`background:${n.v.bg ? n.v.bg : ''};color:${n.v.fc - };font-size:${n.v.fs}px;width:${handleWidth( - n - )}px !important;height:${item.style.rowlen[n.r]}px;font-wight:${n.v.bl ? 'bold' : '' - };`"> - <div :class="`content-h-${n.v.ht} content-v-${n.v.vt}`" :style="`width:${handleWidth(n)}px !important;min-height:${item.style.rowlen[n.r] - }px;`" 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" - :key="'abc-' + '000' + index + '000' + i + '000' + j" v-model="n.v.v" :disabled="(getInspectionItemType(n.i) == 1 && - !dataAcquisitionEidtAble) || + <div id="nav" v-loading="tableLoading" class="center-box"> + <template v-if=" + tableLists.find((m) => m.templateId == currentTable)"> + <table v-for="(item, index) in tableList" :key="index + currentTable + currentSample.id" border="1" + cellpadding="10" class="tables" id="myTable"> + <tbody> + <tr style="white-space: nowrap"> + 濮旀墭缂栧彿锛歿{ + insOrder.entrustCode + }} + </tr> + <tr v-for="(m, i) in item.arr" :key="i"> + <td v-for="(n, j) in m" v-if="n.v.mc == undefined || Object.keys(n.v.mc).length === 4" + :id="item.templateId + '-' + n.i + '-' + n.r + '-' + n.c" :key="j" + :colspan="n.v.mc && n.v.mc.cs ? n.v.mc.cs : 1" :rowspan="n.v.mc && n.v.mc.rs ? n.v.mc.rs : 1" :style="`background:${n.v.bg ? n.v.bg : ''};color:${n.v.fc + };font-size:${n.v.fs}px;width:${handleWidth( + n + )}px !important;height:${item.style.rowlen[n.r]}px;font-wight:${n.v.bl ? 'bold' : '' + };`"> + <div :class="`content-h-${n.v.ht} content-v-${n.v.vt}`" :style="`width:${handleWidth(n)}px !important;min-height:${item.style.rowlen[n.r] + }px;`" 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" + :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" @change="(m) => + changeInput( + m, + `${item.templateId}-${n.r}-${n.c}-${n.i}`, + n, + 'getDataType' + ) + " @input="handleInput(n)" @mousewheel.native.prevent @keydown.enter=" + changeInput( + '', + `${item.templateId}-${n.r}-${n.c}-${n.i}`, + n, + 'getDataType' + ) + "> + </el-input> + <el-input v-else-if="getInspectionValueType(n.i) == 2" v-model="n.v.v" :disabled="getInspectionItemType(n.i) == 1 || (n.u != userId && n.u != undefined && n.u != '') - " class="table_input" @change="(m) => + " class="table_input" type="textarea" @change="(m) => changeInput( m, `${item.templateId}-${n.r}-${n.c}-${n.i}`, n, 'getDataType' ) - " @input="handleInput(n)" @mousewheel.native.prevent @keydown.enter=" - changeInput( - '', - `${item.templateId}-${n.r}-${n.c}-${n.i}`, - n, - 'getDataType' - ) - "> - </el-input> - <el-input v-else-if="getInspectionValueType(n.i) == 2" v-model="n.v.v" :disabled="getInspectionItemType(n.i) == 1 || - (n.u != userId && n.u != undefined && n.u != '') - " class="table_input" type="textarea" @change="(m) => - changeInput( - m, - `${item.templateId}-${n.r}-${n.c}-${n.i}`, - n, - 'getDataType' - ) - " /> - <!-- <el-select v-else-if="getInspectionValueType(n.i) == 5" v-model="n.v.v" :disabled="state > 1 || + " /> + <!-- <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) => @@ -229,136 +220,131 @@ " @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) && + <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 - " 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=" - PROJECT == '妫�娴嬩腑蹇�' || - (PROJECT == '瑁呭鐢电紗' && - 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> + <span>{{ n.v.v }}</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)" - @visible-change="(e) => getEquipOptions(e, n.i)"> - <el-option v-for="item in equipOptions" :key="item.value" :label="item.label" :value="item.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 && - n.v.ps.value === '璁$畻鍊�' && - state == 1 - "><span :style="`font-family:${n.v.ff} !important;`">{{ - toFixed(n.v.v, n.v.ct) - }}</span></template> - <template v-else-if=" - n.v.ps != undefined && - n.v.ps.value === '鏈�缁堝��' && - state == 1 - "> - <span :style="`font-family:${n.v.ff} !important;`">{{ + <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)" + @visible-change="(e) => getEquipOptions(e, n.i)"> + <el-option v-for="item in equipOptions" :key="item.value" :label="item.label" + :value="item.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 && + n.v.ps.value === '璁$畻鍊�' && + state == 1 + "><span :style="`font-family:${n.v.ff} !important;`">{{ toFixed(n.v.v, n.v.ct) - }}</span> - </template> - <template v-else-if=" - n.v.ps != undefined && n.v.ps.value === '鏍峰搧缂栧彿' - "> - <div :title="currentSample.sampleCode" style=" + }}</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> + <template v-else-if=" + n.v.ps != undefined && n.v.ps.value === '鏍峰搧缂栧彿' + "> + <div :title="currentSample.sampleCode" style=" display: flex; flex-wrap: nowrap; align-items: center; width: 100%; "> - <i v-if="!currentFiberOpticTape && !currentFiberOptic" class="el-icon-caret-left table_caret" - style="width: 16px" @click="caretSample(-1)"></i> - <div - :style="`font-family:${n.v.ff} !important;overflow: hidden;white-space: nowrap;width: calc(100% - 32px);`"> - {{ currentSample.sampleCode }} + <i class="el-icon-caret-left table_caret" style="width: 16px" @click="caretSample(-1)"></i> + <div + :style="`font-family:${n.v.ff} !important;overflow: hidden;white-space: nowrap;width: calc(100% - 32px);`"> + {{ currentSample.sampleCode }} + </div> + <i class="el-icon-caret-right table_caret" style="width: 16px" @click="caretSample(1)"></i> </div> - <i v-if="!currentFiberOpticTape && !currentFiberOptic" class="el-icon-caret-right table_caret" - style="width: 16px" @click="caretSample(1)"></i> - </div> - </template> - <template v-else-if=" - n.v.ps != undefined && n.v.ps.value === '鏍峰搧鍨嬪彿' - "> - <div v-if=" - currentSample.model !== undefined && - currentSample.model !== null - " :style="`font-family:${n.v.ff} !important;`"> - {{ currentSample.model }} - </div> - </template> - <span v-else :style="`font-family:${n.v.ff} !important;`" v-html="getValue(n.v)"></span> - </div> - </td> - </tr> - </tbody> - </table> + </template> + <template v-else-if=" + n.v.ps != undefined && n.v.ps.value === '鏍峰搧鍨嬪彿' + "> + <div v-if=" + currentSample.model !== undefined && + currentSample.model !== null + " :style="`font-family:${n.v.ff} !important;`"> + {{ currentSample.model }} + </div> + </template> + <span v-else :style="`font-family:${n.v.ff} !important;`" v-html="getValue(n.v)"></span> + </div> + </td> + </tr> + </tbody> + </table> + </template> </div> <el-upload v-if="state == 1" ref="upload" :action="action" :before-upload="beforeUpload" :data="{ orderId: id, }" :headers="headers" :on-error="onError" :on-success="handleSuccessUp" :show-file-list="false" - accept=".jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar" style="width: 80px !important"> + accept=".jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar" + style="width: 80px !important;margin-top: 10px;"> <el-button v-if="state == 1" size="small" type="primary">闄勪欢涓婁紶</el-button></el-upload> <lims-table :tableData="tableData" :column="column" :page="page" :tableLoading="tableLoading" - :height="'calc(100vh - 290px)'" @pagination="pagination"></lims-table> - <!-- <ValueTable :key="upIndex" ref="fileList" :componentData="componentData0" :delUrl="$api.insOrderPlan.delfile" - :url="$api.insOrderPlan.getFileList" class="value-table" style="height: 100%; margin-top: 16px" /> --> + :height="'calc(100vh - 290px)'" @pagination="pagination" style="height: 100%; margin-top: 16px"></lims-table> </div> <el-drawer :size="550" :visible.sync="sampleVisible" title="鏍峰搧鍒囨崲"> <el-table v-if="sampleVisible" ref="productTable" :current-row-key="currentKey" :data="sampleProduct" @@ -390,8 +376,8 @@ </el-table> </el-drawer> <el-drawer :size="500" :visible.sync="taskVisible" title="浠诲姟鍒囨崲"> - <!-- <ValueTable :key="upIndex" ref="insOrderPlan" :componentData="componentData" - :url="$api.insOrderPlan.inspectionOrderDetailsTaskSwitching" class="value-table" style="height: 100%" /> --> + <lims-table :tableData="tableData0" :column="column0" :page="page0" :tableLoading="tableLoading0" + :height="'calc(100vh - 90px)'" :currentChange="handleChangeTask"></lims-table> </el-drawer> <el-dialog :visible.sync="reviewDia" title="妫�楠屽鏍�" width="500px"> <div v-if="reviewDia" class="body" style="display: flex; padding: 10px"> @@ -519,8 +505,8 @@ <el-button :loading="reviewLoading" type="primary" @click="upInsReview(1)">纭� 瀹�</el-button> </span> </el-dialog> - <add-un-pass v-if="addUnPassDialog" ref="addUnPassDialog" :addUnPassDialog="addUnPassDialog" - @resetAddUnPass="resetAddUnPass"></add-un-pass> + <!-- <add-un-pass v-if="addUnPassDialog" ref="addUnPassDialog" :addUnPassDialog="addUnPassDialog" + @resetAddUnPass="resetAddUnPass"></add-un-pass> --> <!-- <UnPassDialog v-if="unPassDialog" ref="unPassDialog" @@ -565,8 +551,6 @@ dataCollection, write, getInsProduct, - getReportModel, - determineWhetherToCollectData, search, verifyPlan, checkSubmitPlan, @@ -575,8 +559,11 @@ selectUserCondition, downFile, getFileList, - delfile + delfile, + inspectionOrderDetailsTaskSwitching } from "@/api/business/inspectionTask.js"; +import InspectionWorker from '../../../InspectionWorker.worker'; +import DataWorker from '../../../DataWorker.worker'; import html2canvas from "html2canvas"; import { mapGetters } from "vuex"; export default { @@ -606,7 +593,6 @@ load: null, }, dataGetDia: false, - wareTableDataLoading: false, fileAdd: false, sampleVisible: false, taskVisible: false, @@ -616,34 +602,7 @@ state: null, }, id: null, - componentData: { - entity: { - sonLaboratory: null, - userId: 0, - }, - isIndex: false, - showSelect: false, - select: false, - selectMethod: "handleChangeTask", - sort: false, - do: [], - isPage: false, - linkEvent: {}, - tagField: { - type: { - select: [], - }, - insState: { - select: [], - }, - }, - currentId: "", - selectField: {}, - requiredAdd: [], - requiredUp: [], - }, changeType: null, - getReportModelLoading: false, insOrder: {}, sampleProduct: [], supplierDensity: "", // 鍘傚瀵嗗害 @@ -672,30 +631,14 @@ verifyUser: null, personList: [], enumList: [], - fiberOpticVisible: false, - fiberOpticTapeVisible: false, - bushingVisible: false, - fiberOpticTape: [], //鍏夌氦甯﹀垪琛� - fiberOptic: [], //鍏夌氦鍒楄〃 - bushing: [], //濂楃鍒楄〃 - currentFiberOpticTape: null, //褰撳墠鍏夌氦甯� - currentFiberOptic: null, //褰撳墠鍏夌氦 - currentBushing: null, //褰撳墠濂楃 tableLoading: false, upLoading: false, temptList: null, - fiber: [], - fibers: [], - casing: [], currentTab: null, wareForm: { inspectionItem: 1, inspectionItemSubclass: "20(甯告俯)", }, - wareForm0: {}, - numOptions: [], - temperatureOptions: [], - wareTableData: [], otherForm: { humidity: null, temperature: null, @@ -713,18 +656,8 @@ dataAcquisitionInfo: {}, dataAcquisitionInfoNew: {}, dataAcquisitionEidtAble: false, - isGet: false, dataAcquisitionLoading: false, collected: false, - // 鐑惊鐜�---寮�濮� - thermalCyclingInfo: { - max: 0, - inspectionItem: 1, - arr: [], - length: 1, - inspectionItemClass: null, - }, - thermalCyclingLoading: false, temDataAcquisition: false, getData: [ { @@ -781,7 +714,7 @@ } else { return '鏂囦欢' } - }, + } }, { label: "闄勪欢鍚嶇О", prop: "fileName" }, { label: "涓婁紶浜�", prop: "name" }, @@ -818,6 +751,39 @@ }, tableLoading: false, // 鏂囦欢鍒楄〃鐩稿叧--缁撴潫 + // 浠诲姟鍒囨崲鍒楄〃--寮�濮� + tableData0: [], + column0: [ + { label: "濮旀墭缂栧彿", prop: "entrustCode", width: '160px' }, + { label: "妫�楠屽璞�", prop: "sampleType", width: '140px' }, + { + label: "绱ф�ョ▼搴�", prop: "type", dataType: "tag", + formatData: (params) => { + return this.urgentList.find(m => m.value == params).label + }, + formatType: (params) => { + return this.urgentList.find(m => m.value == params).type + } + }, + { + label: "鐘舵��", prop: "insState", dataType: "tag", + formatData: (params) => { + return this.typeList.find(m => m.value == params).label + }, + formatType: (params) => { + return this.typeList.find(m => m.value == params).type + } + }, + { label: "绾﹀畾鏃堕棿", prop: "appointed", width: '140px' }, + { label: "涓嬪彂鏃堕棿", prop: "sendTime", width: '140px' }, + ], + page0: { + total: 0, + size: -1, + current: -1, + }, + tableLoading0: false, + // 浠诲姟鍒囨崲鍒楄〃--缁撴潫 }; }, // 鐢ㄤ簬涓婁紶鏂囦欢鐨勪俊鎭� @@ -833,8 +799,6 @@ }, }, created() { - this.componentData.entity.sonLaboratory = this.sonLaboratory; - this.getUserInfo(); let { sonLaboratory, orderId, state, inspectorList, typeSource } = this.$route.query; this.sonLaboratory = sonLaboratory; @@ -849,9 +813,10 @@ this.getInsStateDicts(); this.getComparisonList(); this.getAuthorizedPerson(); - this.scrollInit(); // this.getPower(); this.startWorker(); + this.getList0() + this.scrollInit(); }, watch: { // 鐩戝惉浠诲姟id锛岃幏鍙栦换鍔′俊鎭� @@ -897,40 +862,23 @@ 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, - }; - } + this.param[a.id] = { + insValue: [], + comValue: [], + resValue: null, + equipValue: [], + equipName: [], + insResult: null, + }; }); - this.determineWhetherToCollectData(); //鏄惁闇�瑕佹暟閲� - this.getReportModel(this.currentSample.id); //鑾峰彇濂楃銆佸厜绾ゅ甫銆佸厜绾や俊鎭� if (this.currentSample.index == undefined) this.currentSample["index"] = 1; let bushing = this.currentSample.bushing; this.getTableLists(); //澶勭悊妯℃澘鍒楄〃淇℃伅 - this.componentData.currentId = val; this.currentKey = 1; this.getCableTag(this.currentSample.id); // 鏌ヨ鏄惁鏈夎澶氭妫�楠岀殑鐢电紗閰嶇疆 this.getRepetitionTag(this.currentSample.id); // 鏌ヨ鏄惁鏈夎閲嶅妫�楠岄」 - // 娓呯┖鍏夌氦閰嶇疆鐩稿叧鏁版嵁---涓嬮潰淇℃伅鏆傛椂鍙拷鐣� - this.fiberOpticTape = []; - this.currentFiberOpticTape = null; - this.fiberOptic = []; - this.currentFiberOptic = null; - this.bushing = []; - this.currentBushing = null; - this.currentTab = null; - if (bushing && bushing.length > 0) { - this.bushing = bushing; - } }); }, // 鐩戝惉褰撳墠妯℃澘鍙樺寲 @@ -946,18 +894,15 @@ 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[a.id] = { + insValue: [], + comValue: [], + resValue: null, + equipValue: [], + equipName: [], + insResult: null, + }; }); - this.getReportModel(this.currentSample.id); //鑾峰彇濂楃銆佸厜绾ゅ甫銆佸厜绾や俊鎭� // 鍘婚噸妯℃澘锛岃繑鍥炴湁鍑犱釜妯℃澘 const mySet1 = new Set(); this.tableLists = this.currentSample.insProduct.filter((m) => { @@ -1041,14 +986,32 @@ }, // 鏂囦欢绠$悊--缁撴潫 + // 浠诲姟鍒囨崲--寮�濮� + getList0() { + this.tableLoading0 = true; + let param = { userId: this.userId, sonLaboratory: this.sonLaboratory, ...this.page0 }; + delete param.total; + inspectionOrderDetailsTaskSwitching({ ...param }) + .then((res) => { + this.tableLoading0 = false; + if (res.code === 200) { + this.tableData0 = res.data.records; + } + }) + .catch((err) => { + this.tableLoading0 = false; + }); + }, + // 浠诲姟鍒囨崲--缁撴潫 + closeAddVerifyDia() { this.addCheck = false; this.checkUser = ""; }, // 鍒锋柊椤甸潰 - refreshView() { - this.$emit("refreshView"); - }, + // refreshView() { + // this.$emit("refreshView"); + // }, closeUnPassCheckDialog() { this.unPassCheck = false; }, @@ -1336,11 +1299,11 @@ n.v.ps.value.includes("妫�楠屽��") ) { num++; + if (str0 == str) { + maxNum = num; + } } }); - if (str0 == str) { - maxNum = num; - } } // 缁戝畾璁惧 if ( @@ -1510,12 +1473,12 @@ this.stopWorker(); // 纭繚涔嬪墠鐨� Worker 宸插仠姝� } // 鍒涘缓 Worker 瀹炰緥 - this.worker = new Worker("/static/js/worker.js"); + this.worker = new InspectionWorker(); if (this.worker0) { this.stopWorker(); // 纭繚涔嬪墠鐨� Worker 宸插仠姝� } // 鍒涘缓 Worker 瀹炰緥 - this.worker0 = new Worker("/static/js/worker0.js"); + this.worker0 = new DataWorker(); }, // 鍋滄澶氱嚎绋� stopWorker() { @@ -1528,7 +1491,6 @@ this.worker0 = null; } }, - // 鐑惊鐜�---缁撴潫 // 淇濆瓨婀垮害銆佹俯搴︽暟鎹� subOtherForm(m, type) { console.log("m---", m); @@ -1617,13 +1579,6 @@ async handleChangeSample(row, column, event) { // 鍒濆鍖栨暟鎹� this.param = {}; - // 娓呯┖鍏夌氦閰嶇疆鐩稿叧鏁版嵁 - this.fiberOpticTape = []; - this.currentFiberOpticTape = null; - this.fiberOptic = []; - this.currentFiberOptic = null; - this.bushing = []; - this.currentBushing = null; this.sampleVisible = false; // 璧嬪�兼牱鍝� this.currentSample = this.HaveJson(row); @@ -1634,23 +1589,15 @@ this.param = {}; this.changeType = 0; 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[a.id] = { + insValue: [], + comValue: [], + resValue: null, + equipValue: [], + equipName: [], + insResult: null, + }; }); - // 鑾峰彇濂楃,鍏夌氦甯�,鍏夌氦鏁版嵁 - this.getReportModel(row.id); - let bushing = this.currentSample.bushing; - if (bushing && bushing.length > 0) { - this.bushing = bushing; - } // 澶勭悊椤甸潰鍒楄〃鏁版嵁 this.getTableLists(); this.currentKey = row.index; @@ -1665,33 +1612,6 @@ currentTable: this.currentTable, }) ); - }, - // 鏉惧绠$殑鍒ゆ柇\濡傛灉changeType涓嶇瓑浜�3閭d箞椤甸潰涓嶅睍绀烘澗濂楃妫�楠岄」 - handleCasing(inspectionItem) { - if (this.changeType != 3) { - if (inspectionItem.includes("鏉惧绠�")) { - return false; - } else { - return true; - } - } else { - return true; - } - }, - // 鑾峰彇濂楃,鍏夌氦甯�,鍏夌氦鏁版嵁 - getReportModel(id) { - if (this.PROJECT != "妫�娴嬩腑蹇�") { - return; - } - this.getReportModelLoading = true; - getReportModel({ - sampleId: id - }).then((res) => { - this.getReportModelLoading = false; - this.fibers = res.data["鍏夌氦甯�"]; - this.fiber = res.data["鍏夌氦"]; - this.casing = res.data["濂楃"]; - }); }, async handleChangeCableTag(m, type, num, m2) { let cableTag = ""; @@ -1724,7 +1644,6 @@ }; }); this.getTableLists0(list); - this.getReportModel(this.currentSample.id); this.worker.postMessage( JSON.stringify({ type: "saveData", @@ -1743,21 +1662,19 @@ }, // 鏀瑰彉浠诲姟 handleChangeTask(row) { - if (row.length > 0) this.id = row[0].id; + if (row) this.id = row.id; this.taskVisible = false; }, // 瀛楀吀鑾峰彇淇℃伅 getTypeDicts() { this.getDicts("urgency_level").then((response) => { this.urgentList = this.dictToValue(response.data); - this.componentData.tagField.type.select = this.urgentList; }); }, // 瀛楀吀鑾峰彇淇℃伅 getInsStateDicts() { this.getDicts("inspection_task_state").then((response) => { this.typeList = this.dictToValue(response.data); - this.componentData.tagField.insState.select = this.typeList; }); }, // 瀛楀吀鑾峰彇淇℃伅 @@ -2196,7 +2113,8 @@ } }); // 浠ヤ笅鏄牱寮忓鐞嗛�昏緫 - set = Array.sort(set); + set = [...set] + // set = set.sort(); set.forEach((b) => { let arr = []; a.template.forEach((c) => { @@ -2406,11 +2324,6 @@ this.saveInsContext(currentInsItemId); } }, 200); - }, - // 鏄惁闇�瑕佹暟閲� - async determineWhetherToCollectData() { - let res = await determineWhetherToCollectData({ managementNumber: '' }) - this.isGet = res.data; }, // 鏍规嵁鍚庣浼犲弬鏇存柊椤甸潰鏁版嵁 param => this.tableList[0].insProductResult getCurrentInsProduct(pId) { @@ -2635,9 +2548,6 @@ // } // } // }, - getUserInfo() { - this.componentData.entity.userId = this.userId; - }, openAddCheck() { this.addCheck = true; }, @@ -2806,6 +2716,8 @@ param: JSON.stringify(param), currentTable: this.currentTable, sampleId: this.currentSample.id, + orderId: this.orderId, + sonLaboratory: this.sonLaboratory }).then((res) => { if (res.code == 201) { this.$message.error("淇濆瓨澶辫触"); @@ -2936,16 +2848,14 @@ this.param = {}; this.changeType = 0; 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[a.id] = { + insValue: [], + comValue: [], + resValue: null, + equipValue: [], + equipName: [], + insResult: null, + }; }); // 椤甸潰鏁版嵁澶勭悊 this.getTableLists(); @@ -3020,6 +2930,10 @@ }; </script> <style scoped> +>>>.el-divider { + margin: 0 !important; +} + .custom-table .el-table__header-wrapper th { background-color: #87ceeb; /* 鍙甯︽湁my-custom-table绫荤殑琛ㄦ牸鐢熸晥 */ @@ -3048,11 +2962,11 @@ .title { height: 60px; line-height: 60px; + padding: 0 16px; } .search { width: 100%; - margin-bottom: 10px; background-color: #fff; border-radius: 3px; } @@ -3064,7 +2978,7 @@ } .center { - width: calc(100% - 40px); + width: 100%; /* max-height: 580px; */ background-color: #fff; border-radius: 3px; @@ -3091,6 +3005,7 @@ .tables { table-layout: fixed; margin: 5px 5px 16px; + border-collapse: collapse; } .tables td { diff --git a/vue.config.js b/vue.config.js index 14e2478..dbf0bfc 100644 --- a/vue.config.js +++ b/vue.config.js @@ -36,7 +36,7 @@ proxy: { // detail: https://cli.vuejs.org/config/#devserver-proxy [process.env.VUE_APP_BASE_API]: { - target: `http://192.168.0.170:8002`, + target: `http://192.168.0.104:8002`, changeOrigin: true, pathRewrite: { ["^" + process.env.VUE_APP_BASE_API]: "", @@ -59,6 +59,19 @@ "@": resolve("src"), }, }, + module: { + rules: [ + { + test: /\.worker\.js$/, + use: { + loader: "worker-loader", + options: { + inline: "fallback", + }, + }, + }, + ], + }, plugins: [ // http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#浣跨敤gzip瑙e帇缂╅潤鎬佹枃浠� new CompressionPlugin({ -- Gitblit v1.9.3