From cb40d1644acc5a49a3997d8fd5ef97f7b4bc7888 Mon Sep 17 00:00:00 2001 From: chenyuan Date: Wed, 2 Sep 2026 21:02:27 +0800 Subject: [PATCH] fix: pass supplier task key when saving --- src/views/channel/supplier.vue | 6 +++--- tests/supplier-evaluation-step1.static.test.cjs | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/views/channel/supplier.vue b/src/views/channel/supplier.vue index a5a2898..74ad669 100644 --- a/src/views/channel/supplier.vue +++ b/src/views/channel/supplier.vue @@ -429,7 +429,7 @@ async function saveStepOne(showMessage = true) { try { const result = (await validateSupplierEvaluationStepOne(buildStepOnePayload()))?.data || {}; if (!result?.valid) throw new Error(result?.message || "权重校验未通过"); - await saveStudentTrainingAnswer({ taskKey: TASK_KEY, currentStep: 1, saveAction: "SAVE", progressStatus: "IN_PROGRESS", step1Answer: JSON.stringify({ items: result.items }) }); + await saveStudentTrainingAnswer(TASK_KEY, { currentStep: 1, saveAction: "SAVE", progressStatus: "IN_PROGRESS", step1Answer: JSON.stringify({ items: result.items }) }); stepOneSaved.value = true; if (showMessage) ElMessage.success("当前步骤已保存"); return true; @@ -446,7 +446,7 @@ async function saveStepTwo(showMessage = true) { if (!result?.valid) throw new Error(result?.message || "渠道评分校验未通过"); smallBatchRows.value = createScoreRows(result.smallBatchChannels); largeBatchRows.value = createScoreRows(result.largeBatchChannels); - await saveStudentTrainingAnswer({ taskKey: TASK_KEY, currentStep: 2, saveAction: "SAVE", progressStatus: "IN_PROGRESS", step2Answer: JSON.stringify({ weights: result.weights, smallBatchChannels: result.smallBatchChannels, largeBatchChannels: result.largeBatchChannels }) }); + await saveStudentTrainingAnswer(TASK_KEY, { currentStep: 2, saveAction: "SAVE", progressStatus: "IN_PROGRESS", step2Answer: JSON.stringify({ weights: result.weights, smallBatchChannels: result.smallBatchChannels, largeBatchChannels: result.largeBatchChannels }) }); stepTwoSaved.value = true; syncChannelNames(); if (showMessage) ElMessage.success("当前步骤已保存"); @@ -462,7 +462,7 @@ async function saveStepThree(showMessage = true) { const result = (await validateSupplierEvaluationStepThree(buildStepThreePayload()))?.data || {}; if (!result?.valid) throw new Error(result?.message || "第 3 步校验未通过"); const step3Answer = { scenarioAnalyses: result.scenarioAnalyses, procurementRecommendation: result.procurementRecommendation, risks: result.risks }; - await saveStudentTrainingAnswer({ taskKey: TASK_KEY, currentStep: 3, saveAction: "SAVE", progressStatus: "IN_PROGRESS", step3Answer: JSON.stringify(step3Answer) }); + await saveStudentTrainingAnswer(TASK_KEY, { currentStep: 3, saveAction: "SAVE", progressStatus: "IN_PROGRESS", step3Answer: JSON.stringify(step3Answer) }); applyStepThree({ step3Answer }); if (showMessage) ElMessage.success("当前步骤已保存"); return true; diff --git a/tests/supplier-evaluation-step1.static.test.cjs b/tests/supplier-evaluation-step1.static.test.cjs index 041a91f..02a000e 100644 --- a/tests/supplier-evaluation-step1.static.test.cjs +++ b/tests/supplier-evaluation-step1.static.test.cjs @@ -19,3 +19,8 @@ test("供应渠道评估使用接口 data 中的校验结果和学生答案", () assert.match(source, /const result = \(await validateSupplierEvaluationStepThree\(buildStepThreePayload\(\)\)\)\?\.data \|\| \{\};/); assert.match(source, /const answer = \(await getStudentTrainingAnswer\(TASK_KEY\)\)\?\.data \|\| \{\};/); }); + +test("供应渠道评估保存时将任务标识和答案作为两个参数传入", () => { + assert.equal((source.match(/saveStudentTrainingAnswer\(TASK_KEY,\s*\{/g) || []).length, 3); + assert.doesNotMatch(source, /saveStudentTrainingAnswer\(\{\s*taskKey:/); +});