Commit 287dee6a by chenwq1

feat: 增强车检功能与用户体验

- 在 index.html 中引入微信 JSSDK 和 UniApp WebView Bridge,支持小程序通信
- 更新组件类型定义,新增 VanSlider 组件支持
- 在 inspect-report.ts 中添加多个检测模板相关 API 接口,增强数据交互能力
- 优化 car-detail 页面布局,新增评分表单组件以提升用户评分体验
- 更新 home 页面路由参数,确保任务 ID 正确传递
1 parent 3bf5ceae
Pipeline #74 for 287dee6a failed in 0 seconds
......@@ -12,6 +12,10 @@
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<title>二手车</title>
<!-- 微信 JSSDK:小程序 webview 通信必需 -->
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<!-- UniApp WebView Bridge:uniapp 容器通信必需 -->
<script src="https://gitcode.com/dcloud/uni-app/raw/dev/dist/uni.webview.1.5.6.js"></script>
</head>
<body>
<div id="app"></div>
......
import { post } from "@utils/request";
import { get, post } from "@utils/request";
export interface InspectReportPageParams {
size: number;
......@@ -100,3 +100,139 @@ export function getInspectReportPage(params: InspectReportPageParams) {
return post<InspectReportPageResult>("/rest/inspect/report/page", params);
}
// 检测模板相关接口
export interface InspectionResultVO {
/** 完成标志:0 未完成,1 已完成 */
completedFlag: 0 | 1;
[key: string]: unknown;
}
export interface InspectionNode {
id: number;
templateId: number;
parentId: number;
nodeCode?: string;
nodeName: string;
nodeType: number;
showNodeName: string;
editPermission?: string;
displayMode?: number;
itemType: number;
interactionType?: string;
dataFormat?: string;
placeholder?: string;
required?: number;
optionsSourceType?: number;
options?: string;
validationRules?: string;
allowNoStructure?: number;
existsDefaultValue?: string;
defaultValue?: string;
defaultType?: number;
nodeLevel: number;
sortOrder: number;
status: number;
remark?: string;
createTime?: string;
/** 检测结果(含完成标志) */
inspectionResultVO?: InspectionResultVO;
/** 子节点列表(nodeType=2 的节点下挂 nodeType=3 的叶子节点) */
childrenNodes?: InspectionNode[];
[key: string]: unknown;
}
export interface InspectionNodeResponse {
code: string;
data: InspectionNode[];
success: boolean;
message: string;
}
/**
* 获取检测模板根节点(大项)
* @param taskId 检测工单ID
*/
export function getInspectionRootNodes(taskId: string | number) {
return get<InspectionNode[]>(`/rest/inspectionTemplate/${taskId}/rootNodes`);
}
/**
* 获取检测模板子节点(二级项)
* @param rootNodeId 根节点ID
* @param taskId 检测工单ID
*/
export function getInspectionChildren(rootNodeId: string | number, taskId: string | number) {
return get<InspectionNode[]>(`/rest/inspectionNode/${rootNodeId}/children`, {
taskId,
});
}
/**
* 获取检测模板默认值
* @param taskId 检测工单ID
*/
export function getInspectionTemplateDefault(taskId: string | number) {
return post(`/rest/inspectionTemplate/default`, {
taskId,
});
}
// ===== 检测记录保存 =====
export interface LeafNodeValue {
id: number;
valueText: string;
valueKey: string;
interactionType: string;
valueSeq: number;
remark: string;
}
export interface LeafNodeRecord {
nodeId: number;
nodeName: string;
resultStatus: number;
remark: string;
data: LeafNodeValue[];
}
export interface InspectionRecordSaveParams {
taskId: number | string;
/** 大项 nodeId */
locationModule: number | string;
/** 二级项 nodeId */
locationSubModule: number | string;
/** true = 保存并跳下一步,false = 仅保存 */
nextFlag: boolean;
leafNodes: LeafNodeRecord[];
}
/**
* 保存/下一步
*/
export function saveInspectionRecord(params: InspectionRecordSaveParams) {
return post<void>("/rest/inspectionRecord/save", params);
}
// ===== 完成检测(检测评分提交)=====
export interface CompleteInspectionParams {
taskId: number | string;
exteriorScore: number;
exteriorComment: string;
skeletonLevel: string;
skeletonComment: string;
interiorLevel: string;
interiorComment: string;
overallScore: number;
overallComment: string;
}
/**
* 完成检测(提交检测评分)
*/
export function completeInspection(params: CompleteInspectionParams) {
return post<void>("/rest/inspectionRecord/completeInspection", params);
}
......@@ -31,6 +31,7 @@ declare module 'vue' {
VanPullRefresh: typeof import('vant/es')['PullRefresh']
VanSearch: typeof import('vant/es')['Search']
VanSkeleton: typeof import('vant/es')['Skeleton']
VanSlider: typeof import('vant/es')['Slider']
VanSticky: typeof import('vant/es')['Sticky']
VanSwipe: typeof import('vant/es')['Swipe']
VanSwipeItem: typeof import('vant/es')['SwipeItem']
......
......@@ -35,11 +35,13 @@ function stripTokenFromUrl() {
}
function postToUniApp(payload: Record<string, unknown>) {
console.log('pad端postToUniApp', payload);
const w = window as unknown as {
uni?: { postMessage?: (args: { data: unknown }) => void };
parent?: Window;
};
const doPost = () => {
try {
w.uni?.postMessage?.({ data: payload });
} catch {
......@@ -52,6 +54,15 @@ function postToUniApp(payload: Record<string, unknown>) {
} catch {
// ignore
}
};
if (w.uni) {
// uni 对象已就绪,直接发送
doPost();
} else {
// 等待 UniAppJSBridgeReady 事件后再发送
document.addEventListener('UniAppJSBridgeReady', doPost, { once: true });
}
}
function postToWeChatMiniProgram(payload: Record<string, unknown>) {
......
<template>
<div class="score-form">
<!-- 外观评分 -->
<div class="score-section">
<div class="score-section-header">
<span class="score-label">外观评分<span class="required-mark">*</span></span>
<span class="score-value">{{ form.appearanceScore }} <em>分</em></span>
</div>
<div class="score-slider-wrap">
<van-slider v-model="form.appearanceScore"
active-color="#185efe"
inactive-color="#e8edf5"
:max="100"
:min="0"
:step="1" />
<div class="score-ticks">
<span>0</span>
<span>40</span>
<span>80</span>
</div>
</div>
</div>
<!-- 外观评级 -->
<div class="score-section">
<div class="score-section-header">
<span class="score-label">外观评级<span class="required-mark">*</span></span>
</div>
<div class="rating-btns">
<div v-for="opt in RATING_OPTIONS"
:key="opt"
class="rating-btn"
:class="{ active: form.appearanceRating === opt }"
@click="form.appearanceRating = opt">
{{ opt }}
</div>
</div>
<div class="score-basis-label">
评分依据<span class="required-mark">*</span>
</div>
<van-field v-model="form.appearanceBasis"
autosize
class="score-textarea"
placeholder="请查验外观主要划分级别。如:全车多处刮痕,右后侧碰撞有修复痕迹..."
:rows="3"
type="textarea" />
</div>
<!-- 骨架评级 -->
<div class="score-section">
<div class="score-section-header">
<span class="score-label">骨架评级<span class="required-mark">*</span></span>
<span class="score-ref">参考</span>
</div>
<div class="rating-btns">
<div v-for="opt in RATING_OPTIONS"
:key="opt"
class="rating-btn"
:class="{ active: form.frameRating === opt }"
@click="form.frameRating = opt">
{{ opt }}
</div>
</div>
<div class="score-basis-label">
评分依据<span class="required-mark">*</span>
</div>
<van-field v-model="form.frameBasis"
autosize
class="score-textarea"
placeholder="请查验车辆骨架相关部位和程度。如:右前翼子板头部从轻微形变影响整形..."
:rows="3"
type="textarea" />
</div>
<!-- 内饰评级 -->
<div class="score-section">
<div class="score-section-header">
<span class="score-label">内饰评级<span class="required-mark">*</span></span>
<span class="score-ref">参考</span>
</div>
<div class="rating-btns">
<div v-for="opt in RATING_OPTIONS"
:key="opt"
class="rating-btn"
:class="{ active: form.interiorRating === opt }"
@click="form.interiorRating = opt">
{{ opt }}
</div>
</div>
<div class="score-basis-label">
评分依据<span class="required-mark">*</span>
</div>
<van-field v-model="form.interiorBasis"
autosize
class="score-textarea"
placeholder="请查验车辆内饰相关部位和程度。如:右前翼子板头部从轻微形变影响整形..."
:rows="3"
type="textarea" />
</div>
<!-- 综合评分 -->
<div class="score-section">
<div class="score-section-header">
<span class="score-label">综合评分<span class="required-mark">*</span></span>
<span class="score-value">{{ form.overallScore }} <em>分</em></span>
</div>
<div class="score-slider-wrap">
<van-slider v-model="form.overallScore"
active-color="#185efe"
inactive-color="#e8edf5"
:max="100"
:min="0"
:step="1" />
<div class="score-ticks">
<span>0</span>
<span>20</span>
</div>
</div>
<div class="score-basis-label">
综合评价<span class="required-mark">*</span>
</div>
<van-field v-model="form.overallRating"
autosize
class="score-textarea"
placeholder="请对车辆综合情况进行评价..."
:rows="3"
type="textarea" />
</div>
</div>
</template>
<script setup lang="ts">
import { reactive } from "vue";
import { showToast } from "vant";
const RATING_OPTIONS = ["A", "B", "C", "D"] as const;
type RatingOption = (typeof RATING_OPTIONS)[number];
const form = reactive({
appearanceScore: 0,
appearanceRating: "" as "" | RatingOption,
appearanceBasis: "",
frameRating: "" as "" | RatingOption,
frameBasis: "",
interiorRating: "" as "" | RatingOption,
interiorBasis: "",
overallScore: 0,
overallRating: "",
});
function validate(): boolean {
const {
appearanceRating,
appearanceBasis,
frameRating,
frameBasis,
interiorRating,
interiorBasis,
overallRating,
} = form;
if (!appearanceRating || !appearanceBasis || !frameRating || !frameBasis || !interiorRating || !interiorBasis || !overallRating) {
showToast("请填完需评分必填项");
return false;
}
return true;
}
function getFormData() {
return { ...form };
}
defineExpose({ validate, getFormData });
</script>
<style lang="scss" scoped>
.score-form {
display: flex;
flex-direction: column;
padding-top: 8px;
}
.score-section {
padding: 14px 0;
border-bottom: 1px solid #f2f3f7;
&:last-child {
padding-bottom: 4px;
border-bottom: none;
}
}
.score-section-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.score-label {
font-size: 14px;
font-weight: 600;
color: #1a1a1a;
.required-mark {
margin-left: 2px;
color: #ff4d4f;
}
}
.score-value {
font-size: 20px;
font-weight: 700;
color: #185efe;
em {
font-size: 13px;
font-weight: 400;
font-style: normal;
color: #666;
}
}
.score-ref {
padding: 2px 8px;
font-size: 12px;
color: #185efe;
cursor: pointer;
border: 1px solid #185efe;
border-radius: 4px;
}
.score-slider-wrap {
padding: 0 4px;
:deep(.van-slider) {
margin-bottom: 6px;
}
:deep(.van-slider__button) {
width: 18px;
height: 18px;
border: 2px solid #185efe;
box-shadow: 0 2px 6px rgb(24 94 254 / 30%);
}
}
.score-ticks {
display: flex;
justify-content: space-between;
padding: 0 2px;
font-size: 11px;
color: #999;
}
.rating-btns {
display: flex;
gap: 10px;
margin-bottom: 14px;
}
.rating-btn {
display: flex;
flex: 1;
align-items: center;
justify-content: center;
height: 40px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
color: #999;
background: #f7f8fa;
border: 1.5px solid #e8e8e8;
border-radius: 8px;
transition: all 0.15s ease;
&.active {
color: #fff;
background: #185efe;
border-color: #185efe;
box-shadow: 0 3px 8px rgb(24 94 254 / 30%);
}
}
.score-basis-label {
margin-bottom: 8px;
font-size: 13px;
font-weight: 500;
color: #333;
.required-mark {
margin-left: 2px;
color: #ff4d4f;
}
}
.score-textarea {
padding: 10px 12px;
background: #f7f8fa;
border-radius: 8px;
:deep(.van-field__control) {
font-size: 13px;
color: #333;
}
:deep(.van-field__control::placeholder) {
color: #bbb;
}
}
</style>
......@@ -165,7 +165,7 @@ function startCheck(item: WorkOrderItem) {
function continueCheck(item: WorkOrderItem) {
showToast("继续检测");
void router.push({ name: "CarDetail", params: { id: item.id } });
void router.push({ name: "CarDetail", params: { taskId: item.id } });
}
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!