You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dianshang-qianduan/src/views/training/taskKeyMap.js

101 lines
3.8 KiB
JavaScript

export const trainingTaskKeyByPath = {
"/foundation/new-product-survey": "new-product-survey",
"/foundation/product-development-factors": "product-development-factors",
"/foundation/product-development-process": "product-development-process",
"/demand/index": "industry-demand-analysis",
"/demand/environment": "competitive-environment-analysis",
"/demand/people": "target-user-profile",
"/demand/user": "target-user-profile",
"/demand/business-feasibility": "business-feasibility",
"/demand/consumer-behavior": "consumer-behavior",
"/demand/consumer-scenario": "consumer-scenario",
"/demand/feature-conversion": "feature-conversion",
"/product/index": "market-opportunity-selection",
"/product/differentiation": "product-value-positioning",
"/product/structure": "product-structure",
"/product/price": "product-pricing",
"/product/after-sales-service": "after-sales-service",
"/product/requirements-doc": "requirements-doc",
"/product/hardware-cost": "hardware-cost",
"/test/index": "release-channel-evaluation",
"/test/channelas": "release-channel-evaluation",
"/test/promotion": "promotion-effect-optimization",
"/test/marketing": "promotion-effect-optimization",
"/channel/index": "purchase-demand-forecast",
"/channel/purchase": "purchase-demand-forecast",
"/channel/supplier": "supplier-evaluation",
"/assessment/index": "product-diagnosis-iteration",
"/assessment/diagnosis": "product-diagnosis-iteration",
"/assessment/five": "product-diagnosis-iteration",
"/assessment/kano": "product-diagnosis-iteration",
"/assessment/market": "product-diagnosis-iteration",
"/assessment/traffic": "product-diagnosis-iteration",
"/assessment/optimization": "category-optimization",
};
// Each training page implements a fixed number of student-facing steps. Keep the
// teacher editor aligned with those page capabilities instead of the legacy
// four-step backend default.
export const studentTrainingStepCountByTaskKey = Object.freeze({
"new-product-survey": 4,
"product-development-factors": 4,
"product-development-process": 4,
"industry-demand-analysis": 4,
"competitive-environment-analysis": 4,
"market-opportunity-selection": 6,
"business-feasibility": 3,
"target-user-profile": 5,
"consumer-behavior": 4,
"consumer-scenario": 4,
"feature-conversion": 4,
"product-value-positioning": 4,
"product-structure": 4,
"after-sales-service": 3,
"requirements-doc": 3,
"hardware-cost": 4,
"supplier-evaluation": 3,
"purchase-demand-forecast": 4,
"product-pricing": 5,
"category-optimization": 5,
"release-channel-evaluation": 4,
"promotion-effect-optimization": 4,
"product-diagnosis-iteration": 3,
"comprehensive-case-training": 10,
});
export function getStudentTrainingStepCount(taskKey, fallback = 4) {
return studentTrainingStepCountByTaskKey[String(taskKey || "").trim()] || fallback;
}
export function resolveTrainingTaskKey(route, explicitTaskKey = "") {
return explicitTaskKey || route?.meta?.pageKey || trainingTaskKeyByPath[route?.path] || "";
}
export function parseTrainingArray(value, fallback = []) {
if (Array.isArray(value)) {
const result = value.map((item) => String(item?.name ?? item ?? "").trim()).filter(Boolean);
return result.length ? result : fallback;
}
if (!value) {
return fallback;
}
try {
const parsed = JSON.parse(value);
if (Array.isArray(parsed)) {
const result = parsed.map((item) => String(item?.name ?? item ?? "").trim()).filter(Boolean);
return result.length ? result : fallback;
}
} catch (error) {
// Fall through to delimiter parsing.
}
const result = String(value)
.split(/[;;||\n]/)
.map((item) => item.trim())
.filter(Boolean);
return result.length ? result : fallback;
}
export function extractTrainingStepNames(value, fallback = []) {
return parseTrainingArray(value, fallback);
}