Commit cb4805c3 by 岑成威

feat(venus-usedcar-quality): 检测评分跳转调整

1 parent 37b58bf2
Pipeline #207 for cb4805c3 failed in 0 seconds
......@@ -51,12 +51,56 @@ export interface CompleteInspectionParams {
taskId: number | string;
}
/** `completeInspection` 成功时 `data`:有未完成项时带首项节点信息(多为大项 rootNodeId) */
/** `completeInspection` 成功时 `data`:有未完成项时带分级节点信息 */
export interface CompleteInspectionResultData {
firstUncompletedLv1NodeId?: null | number | string;
firstUncompletedLv1NodeName?: null | string;
firstUncompletedLv2NodeId?: null | number | string;
firstUncompletedLv2NodeName?: null | string;
firstUncompletedLv3NodeId?: null | number | string;
firstUncompletedLv3NodeName?: null | string;
/** 旧版接口字段,兼容 */
firstUncompletedNodeId?: null | number | string;
firstUncompletedNodeName?: null | string;
}
function isNonemptyCompleteInspectionNodeId(id: unknown): id is number | string {
if (id === undefined || id === null) return false;
if (typeof id === "string" && id.trim() === "") return false;
return true;
}
/** 提交评分返回里是否仍有未完成项(存在可用于跳转的节点 id) */
export function hasCompleteInspectionUncompletedHint(data: CompleteInspectionResultData | undefined): boolean {
return getCompleteInspectionUncompletedNavigateTarget(data) !== null;
}
/**
* 未完成项:优先按二级节点跳转;无二级 id 时回退一级或旧字段。
* 提示文案优先三级名称(最细),其次二级、一级。
*/
export function getCompleteInspectionUncompletedNavigateTarget(
data: CompleteInspectionResultData | undefined
): { nodeId: number | string; toastName: string | undefined } | null {
if (!data) return null;
let nodeId: number | string | null = null;
if (isNonemptyCompleteInspectionNodeId(data.firstUncompletedLv2NodeId)) {
nodeId = data.firstUncompletedLv2NodeId;
} else if (isNonemptyCompleteInspectionNodeId(data.firstUncompletedLv1NodeId)) {
nodeId = data.firstUncompletedLv1NodeId;
} else if (isNonemptyCompleteInspectionNodeId(data.firstUncompletedNodeId)) {
nodeId = data.firstUncompletedNodeId;
}
if (nodeId === null) return null;
const toastName =
(data.firstUncompletedLv3NodeName && String(data.firstUncompletedLv3NodeName)) ||
(data.firstUncompletedLv2NodeName && String(data.firstUncompletedLv2NodeName)) ||
(data.firstUncompletedLv1NodeName && String(data.firstUncompletedLv1NodeName)) ||
(data.firstUncompletedNodeName && String(data.firstUncompletedNodeName)) ||
undefined;
return { nodeId, toastName };
}
/**
* 完成检测(提交检测评分)
*/
......
import type { BigModule, SubTab } from "@/types/views/car-detail";
import type {
CompleteInspectionResultData,
InspectionNode,
InspectionResultVO,
InspectionTemplateDefaultData,
} from "@api";
import type { InspectionNode, InspectionResultVO, InspectionTemplateDefaultData } from "@api";
import type { RouteLocationNormalizedLoaded } from "vue-router";
......@@ -64,15 +59,6 @@ function secondaryProgressOrFallback(module: BigModule): { done: number; total:
};
}
/** 提交评分返回里是否仍有未完成项(`firstUncompletedNodeId` 有有效值) */
export function hasCompleteInspectionUncompletedHint(data: CompleteInspectionResultData | undefined): boolean {
if (!data) return false;
const id = data.firstUncompletedNodeId;
if (id === undefined || id === null) return false;
if (typeof id === "string" && id.trim() === "") return false;
return true;
}
export function useInspectModules(route: RouteLocationNormalizedLoaded) {
const taskId = ref<number | string>("");
const bigModules = ref<BigModule[]>([]);
......
......@@ -11,16 +11,15 @@ import { useRouter } from "vue-router";
import customizeForm from "@/components/CustomizeForm/Index.vue";
import {
completeInspection,
getCompleteInspectionUncompletedNavigateTarget,
hasCompleteInspectionUncompletedHint,
saveInspectionRecord,
} from "@api";
import { isRequestFailureAlreadyHandled } from "@utils/request";
import { showToast } from "vant";
import ScoreForm from "../components/ScoreForm.vue";
import {
hasCompleteInspectionUncompletedHint,
SCORE_BIG_KEY,
} from "./useInspectModules";
import { SCORE_BIG_KEY } from "./useInspectModules";
/** 底部操作区:仅当前点击的按钮显示 loading */
type FooterLoadingKey = "idle" | "prev" | "next" | "score";
......@@ -213,8 +212,9 @@ export function useInspectSubmit(
inspectionScoreFormRef.value.getCompleteInspectionPayload(modules.taskId.value)
);
if (result && hasCompleteInspectionUncompletedHint(result)) {
const name = result.firstUncompletedNodeName;
const nid = result.firstUncompletedNodeId;
const target = getCompleteInspectionUncompletedNavigateTarget(result);
const name = target?.toastName;
const nid = target?.nodeId;
showToast(
name ? `检测未完成,请先完成「${name}」` : "检测未完成,请先完成未填项"
);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!