| | |
| | | |
| | | // 监听 Worker 返回的结果 |
| | | this.worker.onmessage = (event) => { |
| | | this.result = JSON.parse(event.data); |
| | | switch (this.result.method) { |
| | | const workerResult = JSON.parse(event.data); |
| | | this.result = workerResult; |
| | | switch (workerResult.method) { |
| | | case "saveInsContext": |
| | | this.$nextTick(() => { |
| | | const resultValue = workerResult.value; |
| | | // this.$delete(this.tableList[0],'arr') |
| | | this.$set( |
| | | this.tableList[0], |
| | | "arr", |
| | | this.result.value.tableList[0].arr |
| | | resultValue.tableList[0].arr |
| | | ); |
| | | this.param = this.result.value.param; |
| | | if (this.result.value.currentInsItemId) { |
| | | currentInsItemId = this.result.value.currentInsItemId; |
| | | } |
| | | this.param = resultValue.param; |
| | | // 特殊处理一下结论,会有这种特殊情况 |
| | | for (var i in this.param) { |
| | | if ( |
| | |
| | | } |
| | | } |
| | | } |
| | | this.saveInsContext(currentInsItemId); |
| | | const sourceInsItemId = |
| | | resultValue.sourceInsItemId != null && |
| | | resultValue.sourceInsItemId !== "" |
| | | ? resultValue.sourceInsItemId |
| | | : currentInsItemId; |
| | | this.saveInsContext([ |
| | | sourceInsItemId, |
| | | resultValue.currentInsItemId, |
| | | ]); |
| | | }); |
| | | break; |
| | | case "tableList": |
| | | this.$nextTick(() => { |
| | | // 更新数据 |
| | | this.$delete(this.tableList[0], "arr"); |
| | | this.$set(this.tableList[0], "arr", this.result.value[0].arr); |
| | | this.$set(this.tableList[0], "arr", workerResult.value[0].arr); |
| | | // this.param = this.result.value.param |
| | | if (this.result.value.currentInsItem) { |
| | | currentInsItemId = this.result.value.currentInsItem.i; |
| | | } |
| | | }); |
| | | break; |
| | | case "getCurrentInsProduct": |
| | | // 更新页面数据 |
| | | this.getCurrentInsProduct(this.result.value); |
| | | this.getCurrentInsProduct(workerResult.value); |
| | | break; |
| | | } |
| | | }; |
| | |
| | | return; |
| | | }, |
| | | // 统一在这里保存数据 |
| | | saveInsContext(currentInsItemId) { |
| | | saveInsContext(currentInsItemIds) { |
| | | try { |
| | | if (this.param) { |
| | | let param = null; |
| | | if (currentInsItemId) { |
| | | param = { [currentInsItemId]: this.param[currentInsItemId] }; |
| | | } else { |
| | | param = this.param; |
| | | const ids = (Array.isArray(currentInsItemIds) |
| | | ? currentInsItemIds |
| | | : [currentInsItemIds] |
| | | ) |
| | | .filter((id) => id != null && id !== "") |
| | | .map((id) => String(id)); |
| | | let param = this.param; |
| | | if (ids.length > 0) { |
| | | param = {}; |
| | | [...new Set(ids)].forEach((id) => { |
| | | if (this.param[id]) { |
| | | param[id] = this.param[id]; |
| | | } |
| | | }); |
| | | if (Object.keys(param).length === 0) { |
| | | return; |
| | | } |
| | | } |
| | | saveInsContext({ |
| | | param: JSON.stringify(param), |