| | |
| | | <el-input v-model="insOrder.remark" :disabled="state != 1" clearable placeholder="请输入" size="small" |
| | | @blur="subOtherForm(insOrder.remark, 'remark')"></el-input> |
| | | </el-descriptions-item> |
| | | <el-descriptions-item v-if="isDirectTemplateOrder()" label="设备" :span="2"> |
| | | <el-select v-model="selectedDeviceIds" multiple filterable clearable size="small" placeholder="请选择设备" |
| | | :disabled="state != 1" @change="saveOverviewDevices"> |
| | | <el-option v-for="device in orderDeviceOptions" :key="device.id" :label="device.label" :value="device.id" /> |
| | | </el-select> |
| | | </el-descriptions-item> |
| | | </el-descriptions> |
| | | </div> |
| | | <div class="center"> |
| | |
| | | checkSubmitPlan, |
| | | submitPlan, |
| | | saveInsContext, |
| | | saveTemplateContext, |
| | | getOrderDevices, |
| | | saveOrderDevices, |
| | | selectUserCondition, |
| | | downFile, |
| | | getFileList, |
| | |
| | | comparisonList: [], |
| | | excelMethodList: [], |
| | | equipOptions: [], |
| | | orderDeviceOptions: [], |
| | | selectedDeviceIds: [], |
| | | reviewLoading: false, |
| | | reviewDia: false, |
| | | noReason: "", |
| | |
| | | worker0: null, |
| | | // 检验值按触发顺序串行保存,避免同一检验项的旧请求覆盖新请求。 |
| | | saveQueue: null, |
| | | calculationRevision: 0, |
| | | completedCalculationRevision: 0, |
| | | wareLength: [], |
| | | dataAcquisitionInfo: {}, |
| | | dataAcquisitionInfoNew: {}, |
| | |
| | | this.rawMaterialTag = "1"; |
| | | } |
| | | this.getEquipOptions(1); |
| | | if (this.sonLaboratory === "新聚") { |
| | | this.loadOverviewDevices(); |
| | | } |
| | | // 获取当前样品的检验项 |
| | | let list = await this.getCurrentProduct(this.currentSample.id, 0); |
| | | this.currentSample.insProduct = this.HaveJson(list); |
| | |
| | | } |
| | | } |
| | | try { |
| | | const revision = ++this.calculationRevision; |
| | | // 向 Worker 发送消息,开始处理逻辑 |
| | | this.worker.postMessage( |
| | | JSON.stringify({ |
| | |
| | | getDataTypeId: this.getDataTypeId, |
| | | modelType: this.sampleProduct[0].model, |
| | | currentInsItem: n, |
| | | revision: revision, |
| | | }) |
| | | ); |
| | | // 先保存主线程中已经输入的原始值。Worker 完成计算后会再次入队保存计算结果。 |
| | |
| | | // 监听 Worker 返回的结果 |
| | | this.worker.onmessage = (event) => { |
| | | const workerResult = JSON.parse(event.data); |
| | | if (workerResult.revision != null && workerResult.revision < this.calculationRevision) { |
| | | return; |
| | | } |
| | | this.result = workerResult; |
| | | switch (workerResult.method) { |
| | | case "saveInsContext": |
| | |
| | | ); |
| | | this.param = resultValue.param; |
| | | this.saveInsContext(); |
| | | this.completedCalculationRevision = Math.max( |
| | | this.completedCalculationRevision, |
| | | workerResult.revision || 0 |
| | | ); |
| | | }); |
| | | break; |
| | | case "tableList": |
| | |
| | | const param = {}; |
| | | this.tableList.forEach((a) => { |
| | | param[a.templateId] = {}; |
| | | a.template.forEach((cell) => { |
| | | // Worker 回传后 arr 是页面上的最新对象,template 仍可能保留计算前的旧值。 |
| | | const cells = a.arr && a.arr.length |
| | | ? a.arr.reduce((all, row) => all.concat(row), []) |
| | | : a.template; |
| | | const resultHeader = cells.find((cell) => |
| | | cell.v && String(cell.v.v || "").trim() === "检验结果" |
| | | ); |
| | | const exportRows = new Set(cells.filter((cell) => |
| | | cell.v && cell.v.ps && cell.v.ps.value === "导出值" |
| | | ).map((cell) => cell.r)); |
| | | cells.forEach((cell) => { |
| | | const isEditable = |
| | | cell.v.ps != undefined && |
| | | typeof cell.v.ps.value === "string" && |
| | |
| | | cell.v.ps.value === "计算值" || |
| | | cell.v.ps.value === "最终值" || |
| | | cell.v.ps.value === "设备名称"); |
| | | if (!isEditable) { |
| | | const isExportResult = resultHeader && exportRows.has(cell.r) && cell.c === resultHeader.c; |
| | | if (!isEditable && !isExportResult) { |
| | | return; |
| | | } |
| | | if ( |
| | | isEditable && |
| | | cell.v.ps.value.includes("检验值") && |
| | | (cell.v.v === "" || cell.v.v === null || cell.v.v === undefined) |
| | | ) { |
| | |
| | | const previousSave = this.saveQueue || Promise.resolve(); |
| | | this.saveQueue = previousSave |
| | | .catch(() => undefined) |
| | | .then(() => saveInsContext(payload)) |
| | | .then(() => this.isDirectTemplateOrder() |
| | | ? saveTemplateContext({ |
| | | orderId: this.orderId, |
| | | sampleId: this.currentSample.id, |
| | | templateId: this.currentTable, |
| | | values: param[this.currentTable] || {}, |
| | | }) |
| | | : saveInsContext(payload)) |
| | | .then(() => { |
| | | this.$message.success("已保存"); |
| | | }) |
| | |
| | | } |
| | | }, |
| | | async waitForPendingSaves() { |
| | | const targetRevision = this.calculationRevision; |
| | | if (this.completedCalculationRevision < targetRevision) { |
| | | await new Promise((resolve) => { |
| | | const startedAt = Date.now(); |
| | | const waitWorker = () => { |
| | | if (this.completedCalculationRevision >= targetRevision || Date.now() - startedAt > 5000) { |
| | | resolve(); |
| | | return; |
| | | } |
| | | setTimeout(waitWorker, 20); |
| | | }; |
| | | waitWorker(); |
| | | }); |
| | | } |
| | | if (this.saveQueue) { |
| | | await this.saveQueue; |
| | | } |
| | |
| | | // 选择、移除、清空均由 change 事件触发,立即保存。 |
| | | this.saveInsContext(); |
| | | }, |
| | | isDirectTemplateOrder() { |
| | | return this.sonLaboratory === "新聚" && this.currentSample && |
| | | (this.currentSample.insProduct || []).some((product) => product.templateRowIndex != null); |
| | | }, |
| | | loadOverviewDevices() { |
| | | Promise.all([search({ status: 0 }), getOrderDevices({ orderId: this.orderId })]).then(([devices, selected]) => { |
| | | this.orderDeviceOptions = (devices.data || []).map((device) => ({ |
| | | id: device.id, |
| | | label: `${device.deviceName}--${device.managementNumber}`, |
| | | })); |
| | | this.selectedDeviceIds = selected.data || []; |
| | | }); |
| | | }, |
| | | saveOverviewDevices() { |
| | | return saveOrderDevices({ orderId: this.orderId, deviceIds: this.selectedDeviceIds }) |
| | | .then(() => this.$message.success("设备已保存")); |
| | | }, |
| | | getAuthorizedPerson() { |
| | | selectUserCondition({ type: 1 }).then((res) => { |
| | | let data = []; |