diff --git a/src/views/channel/supplier.vue b/src/views/channel/supplier.vue index ec5534a..cf1de1c 100644 --- a/src/views/channel/supplier.vue +++ b/src/views/channel/supplier.vue @@ -235,11 +235,11 @@ const progressItems = computed(() => [ ]); const rows = ref([ - { key: "procurementCost", name: "采购成本", description: "元器件/模组的单台采购总成本,含运费、税费", smallBatchWeight: 20, largeBatchWeight: 35 }, - { key: "deliveryCycle", name: "交货周期", description: "从下单到收货的时间,影响试产/生产进度", smallBatchWeight: 30, largeBatchWeight: 15 }, - { key: "qualityReliability", name: "品质可靠性", description: "元器件是否为正品,有无翻新/故障,规格匹配度", smallBatchWeight: 20, largeBatchWeight: 30 }, - { key: "procurementFlexibility", name: "采购灵活性", description: "是否支持小批量拆卖、零散采购、退换货", smallBatchWeight: 20, largeBatchWeight: 10 }, - { key: "serviceSupport", name: "服务支持", description: "是否提供技术文档、售后支持,退换货是否方便", smallBatchWeight: 10, largeBatchWeight: 10 }, + { key: "procurementCost", name: "采购成本", description: "元器件/模组的单台采购总成本,含运费、税费", smallBatchWeight: null, largeBatchWeight: null }, + { key: "deliveryCycle", name: "交货周期", description: "从下单到收货的时间,影响试产/生产进度", smallBatchWeight: null, largeBatchWeight: null }, + { key: "qualityReliability", name: "品质可靠性", description: "元器件是否为正品,有无翻新/故障,规格匹配度", smallBatchWeight: null, largeBatchWeight: null }, + { key: "procurementFlexibility", name: "采购灵活性", description: "是否支持小批量拆卖、零散采购、退换货", smallBatchWeight: null, largeBatchWeight: null }, + { key: "serviceSupport", name: "服务支持", description: "是否提供技术文档、售后支持,退换货是否方便", smallBatchWeight: null, largeBatchWeight: null }, ]); const DEFAULT_RISKS = [ @@ -429,7 +429,7 @@ function applyStepThree(answer) { async function saveStepOne() { try { - const result = await validateSupplierEvaluationStepOne(buildStepOnePayload()); + 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 }) }); stepOneSaved.value = true; @@ -443,7 +443,7 @@ async function saveStepOne() { async function saveStepTwo() { try { syncChannelNames(); - const result = await validateSupplierEvaluationStepTwo(buildStepTwoPayload()); + const result = (await validateSupplierEvaluationStepTwo(buildStepTwoPayload()))?.data || {}; if (!result?.valid) throw new Error(result?.message || "渠道评分校验未通过"); smallBatchRows.value = createScoreRows(result.smallBatchChannels); largeBatchRows.value = createScoreRows(result.largeBatchChannels); @@ -458,7 +458,7 @@ async function saveStepTwo() { async function saveStepThree() { try { - const result = await validateSupplierEvaluationStepThree(buildStepThreePayload()); + 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) }); @@ -510,7 +510,7 @@ onMounted(async () => { taskConfig.value = {}; } try { - const answer = await getStudentTrainingAnswer(TASK_KEY); + const answer = (await getStudentTrainingAnswer(TASK_KEY))?.data || {}; stepOneSaved.value = applyStepOne(answer); stepTwoSaved.value = applyStepTwo(answer); applyStepThree(answer); diff --git a/tests/supplier-evaluation-step1.static.test.cjs b/tests/supplier-evaluation-step1.static.test.cjs new file mode 100644 index 0000000..041a91f --- /dev/null +++ b/tests/supplier-evaluation-step1.static.test.cjs @@ -0,0 +1,21 @@ +const assert = require("node:assert/strict"); +const fs = require("node:fs"); +const path = require("node:path"); +const test = require("node:test"); + +const source = fs.readFileSync( + path.resolve(__dirname, "../src/views/channel/supplier.vue"), + "utf8", +); + +test("供应渠道评估第一步首次进入不预填场景权重", () => { + assert.match(source, /smallBatchWeight:\s*null,\s*largeBatchWeight:\s*null/); + assert.doesNotMatch(source, /smallBatchWeight:\s*20,\s*largeBatchWeight:\s*35/); +}); + +test("供应渠道评估使用接口 data 中的校验结果和学生答案", () => { + assert.match(source, /const result = \(await validateSupplierEvaluationStepOne\(buildStepOnePayload\(\)\)\)\?\.data \|\| \{\};/); + assert.match(source, /const result = \(await validateSupplierEvaluationStepTwo\(buildStepTwoPayload\(\)\)\)\?\.data \|\| \{\};/); + assert.match(source, /const result = \(await validateSupplierEvaluationStepThree\(buildStepThreePayload\(\)\)\)\?\.data \|\| \{\};/); + assert.match(source, /const answer = \(await getStudentTrainingAnswer\(TASK_KEY\)\)\?\.data \|\| \{\};/); +});