Commit bac48d50 by wangzhihui

Merge branch 'release/venus-usedcar-h5/1.0.0' of http://192.168.3.233:8090/monor…

…epo/venus into release/venus-usedcar-h5/1.0.0
2 parents 95d26196 21e9265f
Pipeline #100 for bac48d50 failed in 0 seconds
...@@ -181,12 +181,39 @@ export function getInspectionRootNodes(taskId: string | number) { ...@@ -181,12 +181,39 @@ export function getInspectionRootNodes(taskId: string | number) {
} }
/** /**
* 检测评分回显(与 `completeInspection` 字段对应,接口可能省略部分字段)
*/
export interface InspectionScoreVO {
exteriorScore?: number | string | null;
exteriorComment?: string | null;
skeletonLevel?: string | null;
skeletonComment?: string | null;
interiorLevel?: string | null;
interiorComment?: string | null;
overallScore?: number | string | null;
overallComment?: string | null;
[key: string]: unknown;
}
/**
* `getInspectionChildren` 响应:
* - 普通节点:节点数组;
* - `rootNodeId === -1`(评分回显):多为 **单元素数组**,元素上挂 `inspectionScoreVO`;少数实现也可能返回顶层带 `inspectionScoreVO` 的对象
*/
export type InspectionChildrenData =
| InspectionNode[]
| {
inspectionScoreVO?: InspectionScoreVO | null;
[key: string]: unknown;
};
/**
* 获取检测模板子节点(二级项) * 获取检测模板子节点(二级项)
* @param rootNodeId 根节点ID * @param rootNodeId 根节点ID;传 `-1` 时可拉取检测评分回显(`inspectionScoreVO`)
* @param taskId 检测工单ID * @param taskId 检测工单ID
*/ */
export function getInspectionChildren(rootNodeId: string | number, taskId: string | number) { export function getInspectionChildren(rootNodeId: string | number, taskId: string | number) {
return get<InspectionNode[]>(`/rest/inspectionNode/${rootNodeId}/children`, { return get<InspectionChildrenData>(`/rest/inspectionNode/${rootNodeId}/children`, {
taskId, taskId,
}); });
} }
...@@ -230,6 +257,29 @@ function hasDefaultValueFlag(node: InspectionNode): boolean { ...@@ -230,6 +257,29 @@ function hasDefaultValueFlag(node: InspectionNode): boolean {
return String(node.existsDefaultValue ?? "") === "1"; return String(node.existsDefaultValue ?? "") === "1";
} }
const KEYED_SELECT_INTERACTION_TYPES = new Set([
"dropdown",
"button_select",
"radio_button_select",
]);
function isKeyedSelectInteractionType(interactionType: string | undefined): boolean {
if (!interactionType) return false;
return KEYED_SELECT_INTERACTION_TYPES.has(interactionType);
}
/** 将模板默认值如 `2-私户` 按首个 `-` 拆成 key / 展示文案 */
function parseKeyedSelectDefault(raw: string): { valueKey: string; valueText: string } {
const i = raw.indexOf("-");
if (i === -1) {
return { valueKey: "", valueText: raw };
}
return {
valueKey: raw.slice(0, i),
valueText: raw.slice(i + 1),
};
}
/** /**
* 解析叶子节点默认值对应的文案列表(可多值,与 inspectionValueList 一一对应) * 解析叶子节点默认值对应的文案列表(可多值,与 inspectionValueList 一一对应)
* - defaultType 1:固定值,取 defaultValue * - defaultType 1:固定值,取 defaultValue
...@@ -266,15 +316,21 @@ export function resolveInspectionNodeInitialValueTexts( ...@@ -266,15 +316,21 @@ export function resolveInspectionNodeInitialValueTexts(
} }
function buildInspectionResultVOFromDefaults(node: InspectionNode, valueTexts: string[]): InspectionResultVO { function buildInspectionResultVOFromDefaults(node: InspectionNode, valueTexts: string[]): InspectionResultVO {
const inspectionValueList: InspectionValueItem[] = valueTexts.map((valueText, index) => ({ const keyed = isKeyedSelectInteractionType(node.interactionType);
id: 0, const inspectionValueList: InspectionValueItem[] = valueTexts.map((raw, index) => {
resultId: 0, const { valueKey, valueText } = keyed
valueKey: "", ? parseKeyedSelectDefault(raw)
valueText, : { valueKey: "", valueText: raw };
interactionType: node.interactionType ?? "", return {
valueSeq: index, id: 0,
remark: "", resultId: 0,
})); valueKey,
valueText,
interactionType: node.interactionType ?? "",
valueSeq: index,
remark: "",
};
});
return { return {
id: 0, id: 0,
recordId: 0, recordId: 0,
...@@ -318,18 +374,48 @@ export function applyResolvedInitialValuesToLeafNodes( ...@@ -318,18 +374,48 @@ export function applyResolvedInitialValuesToLeafNodes(
return { ...node }; return { ...node };
} }
const resolvedInitialValue = valueTexts.length === 1 ? valueTexts[0] : valueTexts.join(", "); const resolvedInitialValue = valueTexts.length === 1 ? valueTexts[0] : valueTexts.join(", ");
return { const inspectionResultVO = buildInspectionResultVOFromDefaults(node, valueTexts);
const list = inspectionResultVO.inspectionValueList ?? [];
const merged: InspectionNode = {
...node, ...node,
resolvedInitialValue, resolvedInitialValue,
inspectionResultVO: buildInspectionResultVOFromDefaults(node, valueTexts), inspectionResultVO,
}; };
if (!isKeyedSelectInteractionType(node.interactionType) || list.length === 0) {
return merged;
}
const first = list[0]!;
const it = node.interactionType ?? "";
const valueKey = first.valueKey ?? "";
const valueText = first.valueText ?? "";
if (it === "dropdown" || it === "radio_button_select") {
return {
...merged,
valueKey,
valueText,
value: valueKey,
};
}
if (it === "button_select") {
return {
...merged,
valueKey,
valueText,
value: JSON.stringify(
list.map((row) => ({
valueKey: row.valueKey ?? "",
valueText: row.valueText ?? "",
}))
),
};
}
return merged;
}); });
} }
// ===== 检测记录保存 ===== // ===== 检测记录保存 =====
export interface LeafNodeValue { export interface LeafNodeValue {
id: number;
valueText: string; valueText: string;
valueKey: string; valueKey: string;
interactionType: string; interactionType: string;
...@@ -349,8 +435,8 @@ export interface InspectionRecordSaveParams { ...@@ -349,8 +435,8 @@ export interface InspectionRecordSaveParams {
taskId: number | string; taskId: number | string;
/** 大项 nodeId */ /** 大项 nodeId */
locationModule: number | string; locationModule: number | string;
/** 二级项 nodeId */ /** 二级项 nodeId;无二级分组时为 null */
locationSubModule: number | string; locationSubModule: number | string | null;
/** true = 保存并跳下一步,false = 仅保存 */ /** true = 保存并跳下一步,false = 仅保存 */
nextFlag: boolean; nextFlag: boolean;
leafNodes: LeafNodeRecord[]; leafNodes: LeafNodeRecord[];
...@@ -392,10 +478,16 @@ export interface CompleteInspectionParams { ...@@ -392,10 +478,16 @@ export interface CompleteInspectionParams {
overallComment: string; overallComment: string;
} }
/** `completeInspection` 成功时 `data`:有未完成项时带首项节点信息(多为大项 rootNodeId) */
export interface CompleteInspectionResultData {
firstUncompletedNodeId?: null | number | string;
firstUncompletedNodeName?: null | string;
}
/** /**
* 完成检测(提交检测评分) * 完成检测(提交检测评分)
*/ */
export function completeInspection(params: CompleteInspectionParams) { export function completeInspection(params: CompleteInspectionParams) {
return post<void>("/rest/inspectionRecord/completeInspection", params); return post<CompleteInspectionResultData>("/rest/inspectionRecord/completeInspection", params);
} }
...@@ -9,7 +9,6 @@ import buttonSelect from "@/components/customizeForm/buttonSelect.vue"; ...@@ -9,7 +9,6 @@ import buttonSelect from "@/components/customizeForm/buttonSelect.vue";
import radioSelect from "@/components/customizeForm/radioSelect.vue"; import radioSelect from "@/components/customizeForm/radioSelect.vue";
import customizeUploadFile from "@/components/customizeForm/customizeUploadFile.vue"; import customizeUploadFile from "@/components/customizeForm/customizeUploadFile.vue";
// 获取父组件传递数据 // 获取父组件传递数据
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
...@@ -37,100 +36,70 @@ watch(() => props.leafNodes, (nodes) => { ...@@ -37,100 +36,70 @@ watch(() => props.leafNodes, (nodes) => {
// 提交数据 // 提交数据
function setSubmitData() { function setSubmitData() {
let dataList: never[] = []; let returnData: never[] = [];
columnsList.value.forEach((item: any) => { columnsList.value.forEach((item: any) => {
let itemData: any = {}; let dataList: never[] = [];
const inputList = ['text_input', 'textarea_input', 'number_input', 'date_picker']; const inputList = ['text_input', 'textarea_input', 'number_input', 'date_picker'];
const dropdownList = ['dropdown', 'radio_button_select']; const dropdownList = ['dropdown', 'radio_button_select'];
if (inputList.includes(item.interactionType)) { if (inputList.includes(item.interactionType) && item.value != null && item.value !== "") {
itemData = { const pushData = {
id: item.id, id: item.id,
valueText: item.value || '', valueText: item.value || '',
valueKey: item.value || '', valueKey: '',
interactionType: item.interactionType, interactionType: item.interactionType,
remark: item.remark || '',
} }
} else if (dropdownList.includes(item.interactionType)) { dataList.push(pushData);
itemData = { } else if (dropdownList.includes(item.interactionType) && item.valueKey) {
const pushData = {
id: item.id, id: item.id,
valueText: item.valueText || '', valueText: item.valueText || '',
valueKey: item.valueKey || '', valueKey: item.valueKey || '',
interactionType: item.interactionType, interactionType: item.interactionType,
remark: item.remark || '',
} }
dataList.push(pushData);
} else if (item.interactionType == 'button_select') { } else if (item.interactionType == 'button_select') {
const valueList = JSON.parse(item.value || '[]'); const valueList = JSON.parse(item.value || '[]');
if (valueList && valueList.length > 0) { if (valueList && valueList.length > 0) {
for (let i = 0; i < valueList.length; i++) { for (let i = 0; i < valueList.length; i++) {
const foritemData = { const pushData = {
id: item.id, id: item.id,
valueText: valueList[i].valueText || '', valueText: valueList[i].valueText || '',
valueKey: valueList[i].valueKey || '', valueKey: valueList[i].valueKey || '',
interactionType: item.interactionType, interactionType: item.interactionType,
remark: item.remark || '',
valueSeq: i + 1, valueSeq: i + 1,
} }
dataList.push(foritemData); dataList.push(pushData);
}
} else {
itemData = {
id: item.id,
valueText: item.valueText || '',
valueKey: item.valueKey || '',
interactionType: item.interactionType,
remark: item.remark || '',
} }
dataList.push(itemData);
} }
} else if (item.interactionType == 'image_upload' || item.interactionType == 'video_upload') { } else if (item.interactionType == 'image_upload' || item.interactionType == 'video_upload') {
const valueList = JSON.parse(item.value || '[]'); const valueList = JSON.parse(item.value || '[]');
if (valueList && valueList.length > 0) { if (valueList && valueList.length > 0) {
for (let i = 0; i < valueList.length; i++) { for (let i = 0; i < valueList.length; i++) {
const foritemData = { const pushData = {
id: item.id, id: item.id,
valueText: valueList[i] || '', valueText: valueList[i] || '',
valueKey: valueList[i] || '', valueKey: '',
interactionType: item.interactionType, interactionType: item.interactionType,
remark: item.remark || '',
valueSeq: i + 1, valueSeq: i + 1,
} }
dataList.push(foritemData); dataList.push(pushData);
}
} else {
itemData = {
id: item.id,
valueText: item.valueText || '',
valueKey: item.valueKey || '',
interactionType: item.interactionType,
remark: item.remark || '',
} }
dataList.push(itemData);
} }
} else {
itemData = {
id: item.id,
valueText: item.valueText || '',
valueKey: item.valueKey || '',
interactionType: item.interactionType,
remark: item.remark || '',
}
}
if (item.interactionType != 'button_select' && item.interactionType != 'image_upload' && item.interactionType != 'video_upload') {
dataList.push(itemData);
} }
// 每项都入列,便于大项/二级切换时静默保存仍能带上当前 Tab 全部叶子(未填则为空 data,仍会走保存接口)
returnData.push({
nodeId: item.id,
nodeName: item.nodeName,
resultStatus: resultStatus.value ? 3 : 1,
remark: "",
data: dataList,
});
}); });
return { return returnData;
nodeId: columnsList.value[0].parentId || '', //节点 ID(inspection_node_version.nodeId,叶子节点)
nodeName: props.subTabLabel,//节点名称(快照)
resultStatus: resultStatus.value ? 3 : 1,//结果状态:1-正常,2-故障,3-无此结构
remark: '',//备注
data: dataList,
};
} }
async function validate(): Promise<CustomizeFormValidateResult> { async function validate(): Promise<CustomizeFormValidateResult> {
const nodesData = setSubmitData(); const nodesData = setSubmitData();
console.log('validate', nodesData);
let success = true; let success = true;
let message = ''; let message = '';
columnsList.value.forEach((item: any) => { columnsList.value.forEach((item: any) => {
...@@ -149,7 +118,6 @@ async function validate(): Promise<CustomizeFormValidateResult> { ...@@ -149,7 +118,6 @@ async function validate(): Promise<CustomizeFormValidateResult> {
/** 与 `validate` 相同返回结构,不校验必填,用于静默保存 / 上一步等场景 */ /** 与 `validate` 相同返回结构,不校验必填,用于静默保存 / 上一步等场景 */
async function saveData(): Promise<CustomizeFormValidateResult> { async function saveData(): Promise<CustomizeFormValidateResult> {
const nodesData = setSubmitData(); const nodesData = setSubmitData();
console.log('saveData', nodesData);
return { return {
data: nodesData, data: nodesData,
message: "操作成功", message: "操作成功",
...@@ -172,7 +140,7 @@ defineExpose({ ...@@ -172,7 +140,7 @@ defineExpose({
<div> <div>
<van-form ref="customizeFormRef" :model="form" :rules="rules"> <van-form ref="customizeFormRef" :model="form" :rules="rules">
<div class="formTitle"> <div class="formTitle">
<div>{{ subTabLabel }}</div> <!-- <div>{{ subTabLabel }}</div> -->
<div v-if="allowNoStructure" class="formRadio" @click="resultStatus = !resultStatus"> <div v-if="allowNoStructure" class="formRadio" @click="resultStatus = !resultStatus">
<van-icon v-if="!resultStatus" name="circle" size="14" color="#666666" /> <van-icon v-if="!resultStatus" name="circle" size="14" color="#666666" />
<van-icon v-if="resultStatus" name="checked" size="14" color="#185EFE" /> <van-icon v-if="resultStatus" name="checked" size="14" color="#185EFE" />
......
...@@ -18,6 +18,8 @@ export interface BigModule { ...@@ -18,6 +18,8 @@ export interface BigModule {
key: number | string; key: number | string;
label: string; label: string;
nodeId?: number; nodeId?: number;
/** 是否存在二级分组 Tab;false 表示子节点直接为叶子(nodeType=3),不展示二级 Tab */
hasSecondaryTabs?: boolean;
subTabs: SubTab[]; subTabs: SubTab[];
} }
...@@ -30,22 +32,28 @@ export interface InspectSubContentExpose { ...@@ -30,22 +32,28 @@ export interface InspectSubContentExpose {
collectData(validate: boolean): Promise<LeafNodeRecord[] | null>; collectData(validate: boolean): Promise<LeafNodeRecord[] | null>;
} }
/** 中间表单 validate 返回体 */ /** 中间表单 validate / saveData 单列;`id` 为模板字段,仅作前端对齐,提交 saveInspectionRecord 时在 car-detail 映射中省略 */
export interface CustomizeFormValidateFieldItem {
id?: number;
interactionType?: string;
remark?: string;
valueKey?: string;
valueSeq?: number;
valueText?: string;
}
/** 中间表单 validate / saveData 下单个叶子节点(与 `setSubmitData` 一项一致) */
export interface CustomizeFormValidateNode {
nodeId: number | string;
nodeName: string;
resultStatus: number;
remark: string;
data: CustomizeFormValidateFieldItem[];
}
/** 中间表单 validate / saveData 返回体;`data` 为当前二级下多列叶子节点数组 */
export interface CustomizeFormValidateResult { export interface CustomizeFormValidateResult {
success: boolean; success: boolean;
message?: string; message?: string;
data?: { data?: CustomizeFormValidateNode[];
data: Array<{
id: number;
interactionType?: string;
remark?: string;
valueKey?: string;
valueSeq?: number;
valueText?: string;
}>;
nodeId: number | string;
nodeName: string;
remark: string;
resultStatus: number;
};
} }
<template>
<van-popup class="rating-guide-popup"
:close-on-click-overlay="true"
position="center"
round
:show="show"
@update:show="emit('update:show', $event)">
<div class="rating-guide">
<div class="rating-guide__header">
<span class="rating-guide__title">{{ config.title }}</span>
<van-icon class="rating-guide__close"
name="cross"
@click="emit('update:show', false)" />
</div>
<div class="rating-guide__scroll">
<div v-for="level in config.levels"
:key="level.grade"
class="rating-card">
<div class="rating-card__top">
<div class="rating-card__badge"
:style="{ background: gradeColor(level.grade) }">
{{ level.grade }}
</div>
<div class="rating-card__headline">
{{ level.grade }}级:{{ level.subtitle }}
</div>
</div>
<p class="rating-card__desc">
{{ level.description }}
</p>
<div class="rating-card__examples-label">
示例:
</div>
<ul class="rating-card__list">
<li v-for="(line, i) in level.examples"
:key="i"
class="rating-card__item">
{{ line }}
</li>
</ul>
</div>
</div>
</div>
</van-popup>
</template>
<script setup lang="ts">
import type { RatingGuideConfig, RatingGuideGrade } from "./rating-guide-content";
import { RATING_GUIDE_GRADE_COLORS } from "./rating-guide-content";
defineProps<{
config: RatingGuideConfig;
show: boolean;
}>();
const emit = defineEmits<{
"update:show": [value: boolean];
}>();
function gradeColor(grade: RatingGuideGrade): string {
return RATING_GUIDE_GRADE_COLORS[grade];
}
</script>
<style lang="scss" scoped>
.rating-guide-popup {
box-sizing: border-box;
width: calc(100vw - 48px);
max-width: 360px;
padding: 0;
overflow: hidden;
background: transparent;
}
.rating-guide {
display: flex;
flex-direction: column;
max-height: min(72vh, 560px);
padding: 20px 16px 16px;
background: #fff;
border-radius: 20px;
}
.rating-guide__header {
position: relative;
flex-shrink: 0;
padding: 0 28px 14px;
text-align: center;
}
.rating-guide__title {
font-size: 17px;
font-weight: 700;
color: #1a1a1a;
}
.rating-guide__close {
position: absolute;
top: 0;
right: 0;
padding: 4px;
font-size: 20px;
color: #969799;
cursor: pointer;
}
.rating-guide__scroll {
flex: 1;
min-height: 0;
padding-right: 4px;
margin-right: -4px;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
&::-webkit-scrollbar {
width: 4px;
}
&::-webkit-scrollbar-thumb {
background: rgb(0 0 0 / 15%);
border-radius: 4px;
}
}
.rating-card {
padding: 14px 12px;
margin-bottom: 12px;
background: #f2f2f7;
border-radius: 12px;
&:last-child {
margin-bottom: 0;
}
}
.rating-card__top {
display: flex;
gap: 10px;
align-items: flex-start;
margin-bottom: 8px;
}
.rating-card__badge {
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
font-size: 15px;
font-weight: 700;
color: #fff;
border-radius: 6px;
}
.rating-card__headline {
flex: 1;
padding-top: 2px;
font-size: 16px;
font-weight: 700;
line-height: 1.35;
color: #1a1a1a;
}
.rating-card__desc {
margin: 0 0 10px;
font-size: 13px;
line-height: 1.5;
color: #333;
}
.rating-card__examples-label {
margin-bottom: 6px;
font-size: 12px;
font-weight: 500;
color: #666;
}
.rating-card__list {
padding: 0;
margin: 0;
list-style: none;
}
.rating-card__item {
position: relative;
padding-left: 12px;
margin-bottom: 6px;
font-size: 12px;
line-height: 1.45;
color: #666;
&:last-child {
margin-bottom: 0;
}
&::before {
position: absolute;
top: 6px;
left: 0;
width: 4px;
height: 4px;
content: "";
background: #c8c9cc;
border-radius: 50%;
}
}
</style>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<span class="score-unit">分</span> <span class="score-unit">分</span>
</div> </div>
</div> </div>
<div class="score-slider-wrap"> <div class="score-slider-wrap mb-[14px]">
<van-slider v-model="form.appearanceScore" <van-slider v-model="form.appearanceScore"
active-color="#185efe" active-color="#185efe"
inactive-color="#e8edf5" inactive-color="#e8edf5"
...@@ -23,14 +23,15 @@ ...@@ -23,14 +23,15 @@
:step="1" /> :step="1" />
<div class="score-ticks"> <div class="score-ticks">
<span>0</span> <span>0</span>
<span>20</span>
<span>40</span> <span>40</span>
<span>60</span>
<span>80</span> <span>80</span>
<span>100</span>
</div> </div>
</div> </div>
</div> <!-- 外观评级 -->
<!-- 外观评级 -->
<div class="score-section">
<div class="score-basis-label"> <div class="score-basis-label">
评分依据<span class="required-mark">*</span> 评分依据<span class="required-mark">*</span>
</div> </div>
...@@ -40,13 +41,22 @@ ...@@ -40,13 +41,22 @@
placeholder="请查验外观主要划分级别。如:全车多处刮痕,右后侧碰撞有修复痕迹..." placeholder="请查验外观主要划分级别。如:全车多处刮痕,右后侧碰撞有修复痕迹..."
:rows="3" :rows="3"
type="textarea" /> type="textarea" />
</div> </div>
<!-- 骨架评级 --> <!-- 骨架评级 -->
<div class="score-section"> <div class="score-section">
<div class="score-section-header"> <div class="score-section-header">
<span class="score-label">骨架评级<span class="required-mark">*</span></span> <span class="score-label">骨架评级<span class="required-mark">*</span></span>
<span class="score-ref">参考</span> <span class="score-ref"
role="button"
tabindex="0"
@click="openRatingGuide('frame')"
@keydown.enter.prevent="openRatingGuide('frame')"
@keydown.space.prevent="openRatingGuide('frame')">
参考
</span>
</div> </div>
<div class="rating-btns"> <div class="rating-btns">
<div v-for="opt in RATING_OPTIONS" <div v-for="opt in RATING_OPTIONS"
...@@ -54,6 +64,11 @@ ...@@ -54,6 +64,11 @@
class="rating-btn" class="rating-btn"
:class="{ active: form.frameRating === opt }" :class="{ active: form.frameRating === opt }"
@click="form.frameRating = opt"> @click="form.frameRating = opt">
<span v-if="form.frameRating === opt"
aria-hidden="true"
class="rating-btn-check">
☑️
</span>
{{ opt }} {{ opt }}
</div> </div>
</div> </div>
...@@ -72,7 +87,14 @@ ...@@ -72,7 +87,14 @@
<div class="score-section"> <div class="score-section">
<div class="score-section-header"> <div class="score-section-header">
<span class="score-label">内饰评级<span class="required-mark">*</span></span> <span class="score-label">内饰评级<span class="required-mark">*</span></span>
<span class="score-ref">参考</span> <span class="score-ref"
role="button"
tabindex="0"
@click="openRatingGuide('interior')"
@keydown.enter.prevent="openRatingGuide('interior')"
@keydown.space.prevent="openRatingGuide('interior')">
参考
</span>
</div> </div>
<div class="rating-btns"> <div class="rating-btns">
<div v-for="opt in RATING_OPTIONS" <div v-for="opt in RATING_OPTIONS"
...@@ -80,6 +102,11 @@ ...@@ -80,6 +102,11 @@
class="rating-btn" class="rating-btn"
:class="{ active: form.interiorRating === opt }" :class="{ active: form.interiorRating === opt }"
@click="form.interiorRating = opt"> @click="form.interiorRating = opt">
<span v-if="form.interiorRating === opt"
aria-hidden="true"
class="rating-btn-check">
☑️
</span>
{{ opt }} {{ opt }}
</div> </div>
</div> </div>
...@@ -108,7 +135,7 @@ ...@@ -108,7 +135,7 @@
<span class="score-unit">分</span> <span class="score-unit">分</span>
</div> </div>
</div> </div>
<div class="score-slider-wrap"> <div class="score-slider-wrap mb-[14px]">
<van-slider v-model="form.overallScore" <van-slider v-model="form.overallScore"
active-color="#185efe" active-color="#185efe"
inactive-color="#e8edf5" inactive-color="#e8edf5"
...@@ -118,6 +145,10 @@ ...@@ -118,6 +145,10 @@
<div class="score-ticks"> <div class="score-ticks">
<span>0</span> <span>0</span>
<span>20</span> <span>20</span>
<span>40</span>
<span>60</span>
<span>80</span>
<span>100</span>
</div> </div>
</div> </div>
<div class="score-basis-label"> <div class="score-basis-label">
...@@ -130,17 +161,40 @@ ...@@ -130,17 +161,40 @@
:rows="3" :rows="3"
type="textarea" /> type="textarea" />
</div> </div>
<RatingGuideModal :config="ratingGuideConfig"
:show="ratingGuideOpen"
@update:show="onRatingGuideShow" />
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type { CompleteInspectionParams } from "@api"; import type { ScoreRatingOption } from "@/types/views/car-detail";
import type {
CompleteInspectionParams,
InspectionChildrenData,
InspectionScoreVO,
} from "@api";
import type { RatingGuideConfig } from "./rating-guide-content";
import { reactive } from "vue"; import { reactive, ref, watch } from "vue";
import { SCORE_RATING_OPTIONS as RATING_OPTIONS, type ScoreRatingOption } from "@/types/views/car-detail"; import { SCORE_RATING_OPTIONS as RATING_OPTIONS } from "@/types/views/car-detail";
import { getInspectionChildren } from "@api";
import { isRequestFailureAlreadyHandled } from "@utils/request";
import { showToast } from "vant"; import { showToast } from "vant";
import { FRAME_RATING_GUIDE, INTERIOR_RATING_GUIDE } from "./rating-guide-content";
import RatingGuideModal from "./RatingGuideModal.vue";
const props = defineProps<{
/** 检测工单 ID,用于 `getInspectionChildren(-1)` 回显评分 */
taskId?: number | string;
}>();
const RATING_SET = new Set<string>(RATING_OPTIONS);
const form = reactive({ const form = reactive({
appearanceScore: 0, appearanceScore: 0,
appearanceBasis: "", appearanceBasis: "",
...@@ -152,6 +206,99 @@ const form = reactive({ ...@@ -152,6 +206,99 @@ const form = reactive({
overallRating: "", overallRating: "",
}); });
const ratingGuideOpen = ref(false);
const ratingGuideConfig = ref<RatingGuideConfig>(FRAME_RATING_GUIDE);
function openRatingGuide(kind: "frame" | "interior") {
ratingGuideConfig.value = kind === "frame" ? FRAME_RATING_GUIDE : INTERIOR_RATING_GUIDE;
ratingGuideOpen.value = true;
}
function onRatingGuideShow(v: boolean) {
ratingGuideOpen.value = v;
}
function extractInspectionScoreVO(raw: InspectionChildrenData): InspectionScoreVO | null {
if (!raw || typeof raw !== "object") {
return null;
}
/** `rootNodeId === -1` 时接口常返回 `[{ id: -1, inspectionScoreVO: {...}, ... }]`,与单对象两种形态 */
if (Array.isArray(raw)) {
for (const item of raw) {
if (!item || typeof item !== "object") continue;
const vo = (item as { inspectionScoreVO?: unknown }).inspectionScoreVO;
if (vo && typeof vo === "object") {
return vo as InspectionScoreVO;
}
}
return null;
}
const vo = raw.inspectionScoreVO;
if (!vo || typeof vo !== "object") {
return null;
}
return vo;
}
function scoreFieldToNumber(value: unknown, fallback = 0): number {
if (value === null || value === undefined || value === "") {
return fallback;
}
const n = Number(value);
if (Number.isNaN(n)) {
return fallback;
}
return Math.min(100, Math.max(0, n));
}
function normalizeRatingLevel(value: unknown): "" | ScoreRatingOption {
const s = String(value ?? "")
.trim()
.toUpperCase();
if (RATING_SET.has(s)) {
return s as ScoreRatingOption;
}
return "";
}
function applyInspectionScoreVO(vo: InspectionScoreVO) {
form.appearanceScore = scoreFieldToNumber(vo.exteriorScore);
form.appearanceBasis = String(vo.exteriorComment ?? "").trim();
form.frameRating = normalizeRatingLevel(vo.skeletonLevel);
form.frameBasis = String(vo.skeletonComment ?? "").trim();
form.interiorRating = normalizeRatingLevel(vo.interiorLevel);
form.interiorBasis = String(vo.interiorComment ?? "").trim();
form.overallScore = scoreFieldToNumber(vo.overallScore);
form.overallRating = String(vo.overallComment ?? "").trim();
}
async function loadSavedInspectionScore() {
const tid = props.taskId;
if (tid === undefined || tid === null || tid === "") {
return;
}
try {
const raw = await getInspectionChildren(-1, tid);
const vo = extractInspectionScoreVO(raw);
if (vo) {
applyInspectionScoreVO(vo);
}
} catch (error) {
console.error("加载检测评分回显失败:", error);
if (!isRequestFailureAlreadyHandled(error)) {
showToast("加载历史评分失败");
}
}
}
watch(
() => props.taskId,
() => {
void loadSavedInspectionScore();
},
{ immediate: true },
);
function clampScoreFromInput(raw: string): number { function clampScoreFromInput(raw: string): number {
const digits = (raw.match(/\d/g) ?? []).join(""); const digits = (raw.match(/\d/g) ?? []).join("");
if (digits === "") { if (digits === "") {
...@@ -210,17 +357,16 @@ defineExpose({ validate, getCompleteInspectionPayload }); ...@@ -210,17 +357,16 @@ defineExpose({ validate, getCompleteInspectionPayload });
.score-form { .score-form {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding-top: 8px; gap: 10px;
padding-bottom: 4px;
} }
.score-section { .score-section {
padding: 14px 0; box-sizing: border-box;
border-bottom: 1px solid #f2f3f7; padding: 14px 16px;
background: #ffffff;
&:last-child { border-radius: 8px;
padding-bottom: 4px; opacity: 1;
border-bottom: none;
}
} }
.score-section-header { .score-section-header {
...@@ -314,6 +460,7 @@ defineExpose({ validate, getCompleteInspectionPayload }); ...@@ -314,6 +460,7 @@ defineExpose({ validate, getCompleteInspectionPayload });
} }
.rating-btn { .rating-btn {
position: relative;
display: flex; display: flex;
flex: 1; flex: 1;
align-items: center; align-items: center;
...@@ -324,15 +471,23 @@ defineExpose({ validate, getCompleteInspectionPayload }); ...@@ -324,15 +471,23 @@ defineExpose({ validate, getCompleteInspectionPayload });
cursor: pointer; cursor: pointer;
color: #999; color: #999;
background: #f7f8fa; background: #f7f8fa;
border: 1.5px solid #e8e8e8; border: 1px solid #e8e8e8;
border-radius: 8px; border-radius: 8px;
transition: all 0.15s ease; transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
&.active { &.active {
color: #fff; color: #185efe;
background: #185efe; background: #f7f8fa;
border-color: #185efe; border: 1px solid #185efe;
box-shadow: 0 3px 8px rgb(24 94 254 / 30%); }
.rating-btn-check {
position: absolute;
top: 2px;
right: 2px;
font-size: 10px;
line-height: 1;
pointer-events: none;
} }
} }
......
/** 检测评分:骨架 / 内饰评级指引文案(弹窗展示) */
export type RatingGuideGrade = "A" | "B" | "C" | "D";
export interface RatingGuideLevel {
grade: RatingGuideGrade;
/** 标题中「级」后的说明,如「无损伤」→ 展示为「A级:无损伤」 */
subtitle: string;
description: string;
examples: string[];
}
export interface RatingGuideConfig {
title: string;
levels: RatingGuideLevel[];
}
/** 各级徽章背景色(与设计稿一致) */
export const RATING_GUIDE_GRADE_COLORS: Record<RatingGuideGrade, string> = {
A: "#4CD964",
B: "#FFCC00",
C: "#FF9500",
D: "#FF3B30",
};
export const FRAME_RATING_GUIDE: RatingGuideConfig = {
title: "骨架评级指引",
levels: [
{
grade: "A",
subtitle: "无损伤",
description: "全车骨架无任何损伤、变形、切割或修复痕迹",
examples: ["所有结构件完整无缺", "无钣金修复痕迹", "无胶体异常", "无漆面异常"],
},
{
grade: "B",
subtitle: "轻微损伤",
description: "非关键部位有轻微变形或修复,主体结构完好",
examples: [
"翼子板骨架轻微变形",
"门板内侧小范围钣金修复",
"减震器支座轻微胶体异常",
"不影响安全性的小修复",
],
},
{
grade: "C",
subtitle: "中度损伤",
description: "关键部位有明显修复痕迹,但未伤及主体框架",
examples: [
"纵梁头部有钣金修复",
"A/B/C柱有喷漆痕迹",
"防火墙有变形修复",
"减震器支座有明显修复",
],
},
{
grade: "D",
subtitle: "重度损伤",
description: "主要结构件有切割、焊接、严重变形等重大修复",
examples: [
"纵梁切割或更换",
"A/B/C柱切割或严重变形",
"防火墙严重变形或切割",
"车身骨架整体修复",
],
},
],
};
export const INTERIOR_RATING_GUIDE: RatingGuideConfig = {
title: "内饰评级指引",
levels: [
{
grade: "A",
subtitle: "优秀",
description: "内饰整体状况优秀,无明显瑕疵",
examples: ["座椅、地毯、顶棚无污渍", "中控、仪表台无破损", "功能件全部正常", "无异味"],
},
{
grade: "B",
subtitle: "良好",
description: "内饰整体良好,有轻微使用痕迹",
examples: ["座椅有轻微磨损", "地毯有小范围污渍", "方向盘有轻微磨损", "无破损,功能正常"],
},
{
grade: "C",
subtitle: "一般",
description: "内饰有明显使用痕迹或局部破损",
examples: [
"座椅有明显磨损或污渍",
"顶棚有下垂或水渍",
"中控有破损或部件缺失",
"有轻微异味",
],
},
{
grade: "D",
subtitle: "较差",
description: "内饰状况较差,有严重破损或污损",
examples: ["座椅破损或塌陷", "顶棚严重下垂", "大面积烧烫或水渍", "有明显异味"],
},
],
};
<script setup lang="ts"> <script setup lang="ts">
import type { CardAction, WorkOrderItem } from "@/types/views/home";
import type { AuditStatus, WorkOrderStatus } from "@/types/views/work-order-common";
import { computed, ref, watch } from "vue"; import { computed, ref, watch } from "vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { getWorkOrderCountByStatus, getWorkOrderPage } from "@/api/modules/work-order"; import { getWorkOrderCountByStatus, getWorkOrderPage } from "@/api/modules/work-order";
import PageTop from "@/components/PageTop.vue"; import PageTop from "@/components/PageTop.vue";
import WorkOrderStatusTags from "@/components/WorkOrderStatusTags.vue"; import WorkOrderStatusTags from "@/components/WorkOrderStatusTags.vue";
import type { CardAction, WorkOrderItem } from "@/types/views/home";
import type { AuditStatus, WorkOrderStatus } from "@/types/views/work-order-common";
import { showToast } from "vant"; import { showToast } from "vant";
const keyword = ref(""); const keyword = ref("");
...@@ -135,7 +136,7 @@ function startCheck(item: WorkOrderItem) { ...@@ -135,7 +136,7 @@ function startCheck(item: WorkOrderItem) {
} }
function continueCheck(item: WorkOrderItem) { function continueCheck(item: WorkOrderItem) {
void router.push({ name: "CarDetail", params: { taskId: item.id } }); void router.push({ name: "CarDetail", params: { id: item.id } });
} }
function editCheck(item: WorkOrderItem) { function editCheck(item: WorkOrderItem) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!