Commit 8c74592b 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 773efea5 03a7391f
Pipeline #117 for 8c74592b failed in 0 seconds
Showing 54 changed files with 1791 additions and 645 deletions
...@@ -7,15 +7,16 @@ ...@@ -7,15 +7,16 @@
- **框架**: Vue 3、Vue Router、Pinia - **框架**: Vue 3、Vue Router、Pinia
- **UI**: Vant 4(按需引入) - **UI**: Vant 4(按需引入)
- **工具**: VueUse、dayjs、glsk-toolkit - **工具**: VueUse、dayjs、glsk-toolkit
- **构建**: Vite、TypeScript、SCSS、postcss-px-to-viewport(375 设计稿) - **构建**: Vite、TypeScript、SCSS、Tailwind CSS
- **适配**: `lib-flexible` + `postcss-pxtorem`(设计稿以 375 宽为基准,`rootValue` 与 `flexible` 中基准字号一致)
## 已完成的配置 ## 已完成的配置
- **环境变量**: `.env` / `.env.development` / `.env.production`,支持 `VITE_APP_TITLE`、`VITE_API_BASE_URL`、`VITE_APP_ENV` - **环境变量**: `.env` / `.env.development` / `.env.production`,支持 `VITE_APP_TITLE`、`VITE_API_BASE_URL`、`VITE_APP_ENV`
- **路径别名**: `@`、`@assets`、`@views`、`@components`、`@stores`、`@utils`、`@api`、`@composables` - **路径别名**: `@`、`@assets`、`@views`、`@components`、`@stores`、`@utils`、`@api`、`@composables`
- **自动导入**: vue / vue-router / pinia / @vueuse/core;Vant 组件与 `src/components`、`src/layouts` 自动注册 - **自动导入**: vue / vue-router / pinia / @vueuse/core;Vant 组件与 `src/components`、`src/layouts` 自动注册
- **配置中心**: 远程拉取配置(`venus-usedcar-config`),本地缓存,动态设置 API baseURL;集成 glsk-toolkit Request,请求拦截器统一注入 `Authorization`,401/403/500 统一 Toast 提示 - **配置中心**: 远程拉取配置(`venus-usedcar-config`),本地缓存,动态设置 API baseURL;集成 glsk-toolkit Request 实例(与业务请求层并行时可统一收敛)
- **请求封装**: `src/utils/request.ts` 基于配置中心 Request 实例,提供 `get`/`post`,统一解析 `code === 200 | 0` 的 `data`,类型 `ApiResponse<T>`、`PageData<T>` - **请求封装**: `src/utils/request.ts` 基于 axios,提供 `get`/`post`,统一解析业务 `code === 200` 的 `data`,类型 `ApiResponse<T>`、`PageData<T>`
- **开发代理**: `/api` 代理到 `VITE_API_BASE_URL`,端口 8082 - **开发代理**: `/api` 代理到 `VITE_API_BASE_URL`,端口 8082
## 已完成的功能 ## 已完成的功能
......
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
"type-check": "vue-tsc --noEmit" "type-check": "vue-tsc --noEmit"
}, },
"dependencies": { "dependencies": {
"axios": "^1.12.2",
"@vueuse/core": "catalog:", "@vueuse/core": "catalog:",
"axios": "^1.12.2",
"dayjs": "catalog:", "dayjs": "catalog:",
"glsk-toolkit": "catalog:",
"glsk-oss-jssdk": "catalog:", "glsk-oss-jssdk": "catalog:",
"glsk-toolkit": "catalog:",
"pinia": "catalog:", "pinia": "catalog:",
"pinia-plugin-persistedstate": "catalog:", "pinia-plugin-persistedstate": "catalog:",
"tailwindcss": "catalog:", "tailwindcss": "catalog:",
......
...@@ -54,9 +54,9 @@ export function getRecommendedCars(limit = 10) { ...@@ -54,9 +54,9 @@ export function getRecommendedCars(limit = 10) {
} }
export function collectCar(carId: number) { export function collectCar(carId: number) {
return post<void>(`/api/cars/${carId}/collect`); return post(`/api/cars/${carId}/collect`);
} }
export function uncollectCar(carId: number) { export function uncollectCar(carId: number) {
return post<void>(`/api/cars/${carId}/uncollect`); return post(`/api/cars/${carId}/uncollect`);
} }
export * from "./inspect-report";
export * from "./page";
export * from "./record";
export * from "./template";
import { get } from "@utils/request";
export interface FileInfo {
uid?: string;
name?: string;
status?: string;
response?: string;
filePath?: string;
url?: string;
thumbPath?: string;
thumbUrl?: string;
percent?: number;
size?: number;
lastModified?: string;
lastModifiedDate?: string;
linkProps?: Record<string, unknown>;
}
/** 检测记录详情里的单项值(与详情接口结构对齐;与模板侧的 `InspectionValueItem` 区分) */
export interface InspectionDetailValueItem {
id: number;
resultId: number;
nodeId: number;
/** 交互类型,与叶子节点 interactionType 一致 */
interactionType: string;
/** 值内容:图片时为 URL,文字时为文本,按钮选择时为选项 key */
valueText: null | string;
valueKey: null | string;
valueSeq: number;
remark: null | string;
}
export interface InspectionDetailResultVO {
id: number;
recordId: number;
nodeId: number;
nodeName: string;
/** 完成标志:"0"-未完成,"1"-已完成 */
completedFlag: string;
/** 结果状态:1-正常,2-故障,3-无此结构 */
resultStatus: 1 | 2 | 3;
remark: null | string;
inspectionValueList: InspectionDetailValueItem[];
}
export interface InspectionNodeDetail {
id: number;
templateId: number;
/** 父节点 ID,0 表示根节点 */
parentId: number;
nodeName: string;
/** 节点类型:1-模块,2-分组,3-叶子节点 */
nodeType: 1 | 2 | 3;
/** 展示节点名称:1-展示 0-不展示 */
showNodeName: string;
/** 编辑权限,0 不可编辑,1 可编辑 */
editPermission: string;
/** 展现模式:1-列表表单,2-网格检测,3-区域分组,4-图片上传,5-基础信息,6-视频录制 */
displayMode: number;
/** 检测项类型:1-基础字段,2-故障检测 */
itemType: number;
interactionType: string;
dataFormat: string;
datePattern: string;
reserved: string;
placeholder: string;
suffix: string;
/** 是否必填:0-选填,1-必填 */
required: number;
optionsJson: string;
optionsSourceType: number;
validationRules: string;
options: string;
/** 是否支持"无此结构":0-否,1-是 */
allowNoStructure: number;
/** 是否存在默认值:1-存在 0-不存在 */
existsDefaultValue: string;
defaultValue: string;
defaultField: string;
defaultExpr: string;
/** 默认值类型:1-固定值,2-接口获取,3-表达式 */
defaultType: number;
defaultConfig: string;
maxCount: number;
captureRequirement: string;
maxKb: number;
nodePath: string;
/** 节点层级,根节点为 0 */
nodeLevel: number;
sortOrder: number;
/** 状态:0-禁用,1-启用 */
status: number;
remark: string;
createTime: string;
updateTime: string;
/** 失败数(异常) */
failNum: number;
/** 成功数(正常) */
successNum: number;
/** 无此结构数 */
noStructureNum: number;
/** 嵌套子节点(nodeType=1→2→3 层级) */
childrenNodes: InspectionNodeDetail[];
/** 叶子节点(nodeType=3)的检测结果,其他层级为 null */
inspectionResultVO: InspectionDetailResultVO | null;
}
/** 详情接口中的评分结构(与模板侧 `InspectionScoreVO` 区分,避免 barrel 重导出同名冲突) */
export interface InspectionDetailScoreVO {
/** 外观评分 */
exteriorScore?: number;
/** 外观评分依据 */
exteriorComment?: string;
/** 骨架评级(A/B/C/D) */
skeletonLevel?: string;
/** 骨架评级依据 */
skeletonComment?: string;
/** 内饰评级(A/B/C/D) */
interiorLevel?: string;
/** 内饰评级依据 */
interiorComment?: string;
/** 综合评分 */
overallScore?: number;
/** 综合评价 */
overallComment?: string;
}
export interface DetailRes {
id?: number;
taskId?: number;
cover?: FileInfo;
albums?: FileInfo[];
carSeriesId?: number;
carSeriesName?: string;
carTypeId?: number;
carTypeName?: string;
licensePlate?: string;
registrationDate?: string;
/** 表显里程,单位万公里 */
mileage?: string;
emissionStandard?: string;
displacement?: string;
inspectionScoreVO?: InspectionDetailScoreVO;
inspectionNodeList: InspectionNodeDetail[];
/** 整车外观视频 */
wholeCarAppearanceVideo?: string;
/** 发动机工况视频 */
engineConditionVideo?: string;
/** 尾气工况视频 */
tailGasConditionVideo?: string;
/** 检测完成时间 */
inspectionCompletedTime?: string;
}
/**
* 详情
* @param recordId 检测记录 id
*/
export function detail(recordId: number) {
return get<DetailRes>(`/rest/inspectionRecord/${recordId}/detail`);
}
import { post } from "@utils/request";
export interface InspectReportPageParams {
size: number;
page: number;
keyword?: string;
}
export interface PageSort {
empty: boolean;
sorted: boolean;
unsorted: boolean;
}
export interface InspectReportPageData<T> {
size: number;
number: number;
totalElements: number;
last: boolean;
totalPages: number;
sort: PageSort;
first: boolean;
numberOfElements: number;
content: T[];
}
export interface InspectReportVehicleCover {
uid?: number | string;
name?: string;
status?: string;
url?: string;
filePath?: string;
thumbPath?: null | string;
thumbUrl?: null | string;
size?: number;
lastModified?: number;
lastModifiedDate?: string;
[key: string]: unknown;
}
export interface InspectReportVehicleBaseInfo {
carBrandId?: number;
carBrand?: string;
carChildsBrandId?: number;
carChildsBrandName?: string;
carSeriesId?: number;
carSeriesName?: string;
carTypeId?: number;
carTypeName?: string;
mileage?: number;
vin?: string;
engineNumber?: string;
licensePlate?: string;
sourceNo?: string;
tags?: string[];
guidePrice?: number;
[key: string]: unknown;
}
export interface InspectReportVehicle {
createTime?: string;
updateTime?: string;
updateBy?: string;
createBy?: string;
vehicleId?: number;
baseInfo?: InspectReportVehicleBaseInfo;
coreSpecs?: Record<string, unknown>;
ownership?: Record<string, unknown>;
licenseInfo?: Record<string, unknown>;
historyCondition?: Record<string, unknown>;
evaluationTransaction?: Record<string, unknown>;
custodianInfo?: Record<string, unknown>;
ownerInfo?: Record<string, unknown>;
venue?: Record<string, unknown>;
area?: Record<string, unknown>;
parkingSpace?: string;
cover?: InspectReportVehicleCover;
albums?: InspectReportVehicleCover[];
[key: string]: unknown;
}
export interface InspectReportItem {
id: number;
reportNo: string;
woId: string;
vehicle?: InspectReportVehicle;
score?: number;
scoreLevel?: string;
bindStatus?: number;
h5Url?: string;
createTime?: string;
updateTime?: string;
[key: string]: unknown;
}
export type InspectReportPageResult = InspectReportPageData<InspectReportItem>;
export function getInspectReportPage(params: InspectReportPageParams) {
return post<InspectReportPageResult>("/rest/inspect/report/page", params);
}
import { post } from "@utils/request";
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;无二级分组时为 null */
locationSubModule: null | number | string;
/** true = 保存并跳下一步,false = 仅保存 */
nextFlag: boolean;
leafNodes: LeafNodeRecord[];
}
/**
* 保存/下一步
*/
export function saveInspectionRecord(params: InspectionRecordSaveParams) {
return post("/rest/inspectionRecord/save", params);
}
/**
* POST `/rest/inspectionRecord/completeInspection` 请求体
*/
export interface CompleteInspectionParams {
taskId: number | string;
exteriorScore: number;
exteriorComment: string;
skeletonLevel: string;
skeletonComment: string;
interiorLevel: string;
interiorComment: string;
overallScore: number;
overallComment: string;
}
/** `completeInspection` 成功时 `data`:有未完成项时带首项节点信息(多为大项 rootNodeId) */
export interface CompleteInspectionResultData {
firstUncompletedNodeId?: null | number | string;
firstUncompletedNodeName?: null | string;
}
/**
* 完成检测(提交检测评分)
*/
export function completeInspection(params: CompleteInspectionParams) {
return post<CompleteInspectionResultData>("/rest/inspectionRecord/completeInspection", params);
}
import { get, post } from "@utils/request"; import { get, post } from "@utils/request";
export interface InspectReportPageParams {
size: number;
page: number;
keyword?: string;
}
export interface PageSort {
empty: boolean;
sorted: boolean;
unsorted: boolean;
}
export interface InspectReportPageData<T> {
size: number;
number: number;
totalElements: number;
last: boolean;
totalPages: number;
sort: PageSort;
first: boolean;
numberOfElements: number;
content: T[];
}
export interface InspectReportVehicleCover {
uid?: string | number;
name?: string;
status?: string;
url?: string;
filePath?: string;
thumbPath?: string | null;
thumbUrl?: string | null;
size?: number;
lastModified?: number;
lastModifiedDate?: string;
// 后端字段较多,允许拓展
[key: string]: unknown;
}
export interface InspectReportVehicleBaseInfo {
carBrandId?: number;
carBrand?: string;
carChildsBrandId?: number;
carChildsBrandName?: string;
carSeriesId?: number;
carSeriesName?: string;
carTypeId?: number;
carTypeName?: string;
mileage?: number;
vin?: string;
engineNumber?: string;
licensePlate?: string;
sourceNo?: string;
tags?: string[];
guidePrice?: number;
[key: string]: unknown;
}
export interface InspectReportVehicle {
createTime?: string;
updateTime?: string;
updateBy?: string;
createBy?: string;
vehicleId?: number;
baseInfo?: InspectReportVehicleBaseInfo;
coreSpecs?: Record<string, unknown>;
ownership?: Record<string, unknown>;
licenseInfo?: Record<string, unknown>;
historyCondition?: Record<string, unknown>;
evaluationTransaction?: Record<string, unknown>;
custodianInfo?: Record<string, unknown>;
ownerInfo?: Record<string, unknown>;
venue?: Record<string, unknown>;
area?: Record<string, unknown>;
parkingSpace?: string;
cover?: InspectReportVehicleCover;
albums?: InspectReportVehicleCover[];
[key: string]: unknown;
}
export interface InspectReportItem {
id: number;
reportNo: string;
woId: string;
vehicle?: InspectReportVehicle;
score?: number;
scoreLevel?: string;
bindStatus?: number;
h5Url?: string;
createTime?: string;
updateTime?: string;
[key: string]: unknown;
}
export type InspectReportPageResult = InspectReportPageData<InspectReportItem>;
export function getInspectReportPage(params: InspectReportPageParams) {
return post<InspectReportPageResult>("/rest/inspect/report/page", params);
}
// 检测模板相关接口
/** 检测结果单项值(与落库结构对齐) */ /** 检测结果单项值(与落库结构对齐) */
export interface InspectionValueItem { export interface InspectionValueItem {
id?: number; id?: number;
...@@ -145,7 +43,7 @@ export interface InspectionNode { ...@@ -145,7 +43,7 @@ export interface InspectionNode {
options?: string; options?: string;
validationRules?: string; validationRules?: string;
allowNoStructure?: number; allowNoStructure?: number;
existsDefaultValue?: string | number; existsDefaultValue?: number | string;
defaultValue?: string; defaultValue?: string;
defaultType?: number; defaultType?: number;
nodeLevel: number; nodeLevel: number;
...@@ -165,18 +63,11 @@ export interface InspectionNode { ...@@ -165,18 +63,11 @@ export interface InspectionNode {
[key: string]: unknown; [key: string]: unknown;
} }
export interface InspectionNodeResponse {
code: string;
data: InspectionNode[];
success: boolean;
message: string;
}
/** /**
* 获取检测模板根节点(大项) * 获取检测模板根节点(大项)
* @param taskId 检测工单ID * @param taskId 检测工单ID
*/ */
export function getInspectionRootNodes(taskId: string | number) { export function getInspectionRootNodes(taskId: number | string) {
return get<InspectionNode[]>(`/rest/inspectionTemplate/${taskId}/rootNodes`); return get<InspectionNode[]>(`/rest/inspectionTemplate/${taskId}/rootNodes`);
} }
...@@ -184,14 +75,14 @@ export function getInspectionRootNodes(taskId: string | number) { ...@@ -184,14 +75,14 @@ export function getInspectionRootNodes(taskId: string | number) {
* 检测评分回显(与 `completeInspection` 字段对应,接口可能省略部分字段) * 检测评分回显(与 `completeInspection` 字段对应,接口可能省略部分字段)
*/ */
export interface InspectionScoreVO { export interface InspectionScoreVO {
exteriorScore?: number | string | null; exteriorScore?: null | number | string;
exteriorComment?: string | null; exteriorComment?: null | string;
skeletonLevel?: string | null; skeletonLevel?: null | string;
skeletonComment?: string | null; skeletonComment?: null | string;
interiorLevel?: string | null; interiorLevel?: null | string;
interiorComment?: string | null; interiorComment?: null | string;
overallScore?: number | string | null; overallScore?: null | number | string;
overallComment?: string | null; overallComment?: null | string;
[key: string]: unknown; [key: string]: unknown;
} }
...@@ -203,8 +94,8 @@ export interface InspectionScoreVO { ...@@ -203,8 +94,8 @@ export interface InspectionScoreVO {
export type InspectionChildrenData = export type InspectionChildrenData =
| InspectionNode[] | InspectionNode[]
| { | {
inspectionScoreVO?: InspectionScoreVO | null;
[key: string]: unknown; [key: string]: unknown;
inspectionScoreVO?: InspectionScoreVO | null;
}; };
/** /**
...@@ -212,7 +103,7 @@ export type InspectionChildrenData = ...@@ -212,7 +103,7 @@ export type InspectionChildrenData =
* @param rootNodeId 根节点ID;传 `-1` 时可拉取检测评分回显(`inspectionScoreVO`) * @param rootNodeId 根节点ID;传 `-1` 时可拉取检测评分回显(`inspectionScoreVO`)
* @param taskId 检测工单ID * @param taskId 检测工单ID
*/ */
export function getInspectionChildren(rootNodeId: string | number, taskId: string | number) { export function getInspectionChildren(rootNodeId: number | string, taskId: number | string) {
return get<InspectionChildrenData>(`/rest/inspectionNode/${rootNodeId}/children`, { return get<InspectionChildrenData>(`/rest/inspectionNode/${rootNodeId}/children`, {
taskId, taskId,
}); });
...@@ -246,7 +137,7 @@ export interface InspectionTemplateDefaultData { ...@@ -246,7 +137,7 @@ export interface InspectionTemplateDefaultData {
* 获取检测模板默认值(业务层已解包为 data 对象) * 获取检测模板默认值(业务层已解包为 data 对象)
* @param taskId 检测工单ID * @param taskId 检测工单ID
*/ */
export function getInspectionTemplateDefault(taskId: string | number) { export function getInspectionTemplateDefault(taskId: number | string) {
return post<InspectionTemplateDefaultData>(`/rest/inspectionTemplate/default`, { return post<InspectionTemplateDefaultData>(`/rest/inspectionTemplate/default`, {
taskId, taskId,
}); });
...@@ -258,8 +149,8 @@ function hasDefaultValueFlag(node: InspectionNode): boolean { ...@@ -258,8 +149,8 @@ function hasDefaultValueFlag(node: InspectionNode): boolean {
} }
const KEYED_SELECT_INTERACTION_TYPES = new Set([ const KEYED_SELECT_INTERACTION_TYPES = new Set([
"dropdown",
"button_select", "button_select",
"dropdown",
"radio_button_select", "radio_button_select",
]); ]);
...@@ -366,7 +257,7 @@ export function applyResolvedInitialValuesToLeafNodes( ...@@ -366,7 +257,7 @@ export function applyResolvedInitialValuesToLeafNodes(
): InspectionNode[] { ): InspectionNode[] {
if (!leafNodes?.length) return []; if (!leafNodes?.length) return [];
return leafNodes.map((node) => { return leafNodes.map((node) => {
if (node.inspectionResultVO != null) { if (node.inspectionResultVO !== null && node.inspectionResultVO !== undefined) {
return { ...node }; return { ...node };
} }
const valueTexts = resolveInspectionNodeInitialValueTexts(node, templateDefaultData); const valueTexts = resolveInspectionNodeInitialValueTexts(node, templateDefaultData);
...@@ -384,7 +275,10 @@ export function applyResolvedInitialValuesToLeafNodes( ...@@ -384,7 +275,10 @@ export function applyResolvedInitialValuesToLeafNodes(
if (!isKeyedSelectInteractionType(node.interactionType) || list.length === 0) { if (!isKeyedSelectInteractionType(node.interactionType) || list.length === 0) {
return merged; return merged;
} }
const first = list[0]!; const first = list[0];
if (first === undefined) {
return merged;
}
const it = node.interactionType ?? ""; const it = node.interactionType ?? "";
const valueKey = first.valueKey ?? ""; const valueKey = first.valueKey ?? "";
const valueText = first.valueText ?? ""; const valueText = first.valueText ?? "";
...@@ -412,82 +306,3 @@ export function applyResolvedInitialValuesToLeafNodes( ...@@ -412,82 +306,3 @@ export function applyResolvedInitialValuesToLeafNodes(
return merged; return merged;
}); });
} }
// ===== 检测记录保存 =====
export interface LeafNodeValue {
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;无二级分组时为 null */
locationSubModule: number | string | null;
/** true = 保存并跳下一步,false = 仅保存 */
nextFlag: boolean;
leafNodes: LeafNodeRecord[];
}
/**
* 保存/下一步
*/
export function saveInspectionRecord(params: InspectionRecordSaveParams) {
return post<void>("/rest/inspectionRecord/save", params);
}
// ===== 完成检测(检测评分提交)=====
/**
* POST `/rest/inspectionRecord/completeInspection` 请求体
* @example
* {
* "taskId": 0,
* "exteriorScore": 0,
* "exteriorComment": "",
* "skeletonLevel": "",
* "skeletonComment": "",
* "interiorLevel": "",
* "interiorComment": "",
* "overallScore": 0,
* "overallComment": ""
* }
*/
export interface CompleteInspectionParams {
taskId: number | string;
exteriorScore: number;
exteriorComment: string;
skeletonLevel: string;
skeletonComment: string;
interiorLevel: string;
interiorComment: string;
overallScore: number;
overallComment: string;
}
/** `completeInspection` 成功时 `data`:有未完成项时带首项节点信息(多为大项 rootNodeId) */
export interface CompleteInspectionResultData {
firstUncompletedNodeId?: null | number | string;
firstUncompletedNodeName?: null | string;
}
/**
* 完成检测(提交检测评分)
*/
export function completeInspection(params: CompleteInspectionParams) {
return post<CompleteInspectionResultData>("/rest/inspectionRecord/completeInspection", params);
}
...@@ -68,7 +68,7 @@ export function login(params: LoginParams) { ...@@ -68,7 +68,7 @@ export function login(params: LoginParams) {
} }
export function logout() { export function logout() {
return post<void>("/api/user/logout"); return post("/rest/auth/logout", {});
} }
export function getUserInfo() { export function getUserInfo() {
......
...@@ -28,10 +28,10 @@ body { ...@@ -28,10 +28,10 @@ body {
// rem 根字号上限与 utils/flexible.ts 中 LAYOUT_MAX_WIDTH 保持一致 // rem 根字号上限与 utils/flexible.ts 中 LAYOUT_MAX_WIDTH 保持一致
// #app 已加入 postcss-pxtorem selectorBlackList,px 不会被转 rem // #app 已加入 postcss-pxtorem selectorBlackList,px 不会被转 rem
#app { #app {
position: relative;
max-width: 430px; max-width: 430px;
min-height: 100vh; min-height: 100vh;
margin: 0 auto; margin: 0 auto;
position: relative;
background-color: #f7f8fa; background-color: #f7f8fa;
} }
......
...@@ -11,6 +11,7 @@ declare module 'vue' { ...@@ -11,6 +11,7 @@ declare module 'vue' {
CustomizeUploadFile: typeof import('./components/CustomizeForm/customizeUploadFile.vue')['default'] CustomizeUploadFile: typeof import('./components/CustomizeForm/customizeUploadFile.vue')['default']
Index: typeof import('./components/CustomizeForm/Index.vue')['default'] Index: typeof import('./components/CustomizeForm/Index.vue')['default']
Layouts: typeof import('./layouts/index.vue')['default'] Layouts: typeof import('./layouts/index.vue')['default']
LogoutConfirmModal: typeof import('./components/LogoutConfirmModal.vue')['default']
PageTitle: typeof import('./components/PageTitle.vue')['default'] PageTitle: typeof import('./components/PageTitle.vue')['default']
PageTop: typeof import('./components/PageTop.vue')['default'] PageTop: typeof import('./components/PageTop.vue')['default']
RadioSelect: typeof import('./components/CustomizeForm/radioSelect.vue')['default'] RadioSelect: typeof import('./components/CustomizeForm/radioSelect.vue')['default']
...@@ -27,8 +28,10 @@ declare module 'vue' { ...@@ -27,8 +28,10 @@ declare module 'vue' {
VanForm: typeof import('vant/es')['Form'] VanForm: typeof import('vant/es')['Form']
VanIcon: typeof import('vant/es')['Icon'] VanIcon: typeof import('vant/es')['Icon']
VanImage: typeof import('vant/es')['Image'] VanImage: typeof import('vant/es')['Image']
VanImagePreview: typeof import('vant/es')['ImagePreview']
VanList: typeof import('vant/es')['List'] VanList: typeof import('vant/es')['List']
VanLoading: typeof import('vant/es')['Loading'] VanLoading: typeof import('vant/es')['Loading']
VanOverlay: typeof import('vant/es')['Overlay']
VanPicker: typeof import('vant/es')['Picker'] VanPicker: typeof import('vant/es')['Picker']
VanPopup: typeof import('vant/es')['Popup'] VanPopup: typeof import('vant/es')['Popup']
VanProgress: typeof import('vant/es')['Progress'] VanProgress: typeof import('vant/es')['Progress']
...@@ -38,10 +41,13 @@ declare module 'vue' { ...@@ -38,10 +41,13 @@ declare module 'vue' {
VanSearch: typeof import('vant/es')['Search'] VanSearch: typeof import('vant/es')['Search']
VanSkeleton: typeof import('vant/es')['Skeleton'] VanSkeleton: typeof import('vant/es')['Skeleton']
VanSlider: typeof import('vant/es')['Slider'] VanSlider: typeof import('vant/es')['Slider']
VanSwipe: typeof import('vant/es')['Swipe']
VanSwipeItem: typeof import('vant/es')['SwipeItem']
VanTab: typeof import('vant/es')['Tab']
VanTabbar: typeof import('vant/es')['Tabbar'] VanTabbar: typeof import('vant/es')['Tabbar']
VanTabbarItem: typeof import('vant/es')['TabbarItem'] VanTabbarItem: typeof import('vant/es')['TabbarItem']
VanTabs: typeof import('vant/es')['Tabs']
VanTag: typeof import('vant/es')['Tag'] VanTag: typeof import('vant/es')['Tag']
VanUploader: typeof import('vant/es')['Uploader']
WorkOrderStatusTags: typeof import('./components/WorkOrderStatusTags.vue')['default'] WorkOrderStatusTags: typeof import('./components/WorkOrderStatusTags.vue')['default']
} }
} }
<script setup lang="ts"> <script setup lang="ts">
import type { CustomizeFormValidateResult } from "@/types/views/car-detail";
import { ref, watch } from "vue"; import { ref, watch } from "vue";
import type { InspectionNode } from "@api";
import type { CustomizeFormValidateResult } from "@/types/views/car-detail";
import selectDatePicker from "@/components/CustomizeForm/selectDatePicker.vue";
import selectDropdown from "@/components/CustomizeForm/selectDropdown.vue";
import buttonSelect from "@/components/CustomizeForm/buttonSelect.vue";
import radioSelect from "@/components/CustomizeForm/radioSelect.vue";
import customizeUploadFile from "@/components/CustomizeForm/customizeUploadFile.vue";
import buttonSelectAndImageUpload from "@/components/CustomizeForm/buttonSelectAndImageUpload.vue";
import selectDatePicker from "@/components/customizeForm/selectDatePicker.vue";
import selectDropdown from "@/components/customizeForm/selectDropdown.vue";
import buttonSelect from "@/components/customizeForm/buttonSelect.vue";
import radioSelect from "@/components/customizeForm/radioSelect.vue";
import customizeUploadFile from "@/components/customizeForm/customizeUploadFile.vue";
// 获取父组件传递数据 // 获取父组件传递数据
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
leafNodes?: []; leafNodes?: InspectionNode[];
bigModuleLabel?: string; bigModuleLabel?: string;
subTabLabel?: string; subTabLabel?: string;
allowNoStructure?: boolean; allowNoStructure?: boolean;
...@@ -23,22 +24,59 @@ const props = withDefaults( ...@@ -23,22 +24,59 @@ const props = withDefaults(
allowNoStructure: false, allowNoStructure: false,
}); });
const columnsList = ref([]); type InspectionColumnRow = InspectionNode & {
value?: string | number;
valueKey?: string;
valueText?: string;
};
/** 叶子列(含展示用 value 等扩展字段) */
const columnsList = ref<InspectionColumnRow[]>([]);
const resultStatus = ref(false); const resultStatus = ref(false);
const form = ref({}); const form = ref({});
const rules = ref({}); const rules = ref({});
//加载中
const pageLoading = ref(false);
watch(() => props.leafNodes, (nodes) => { watch(() => props.leafNodes, (nodes) => {
columnsList.value = nodes || []; pageLoading.value = true;
columnsList.value = (nodes || []).map((item) => ({
...item,
value: getValueText(item),
})) as InspectionColumnRow[];
console.log('watchLeafNodes', columnsList.value); console.log('watchLeafNodes', columnsList.value);
setTimeout(() => {
pageLoading.value = false;
}, 1200);
}, { immediate: true, deep: true }); }, { immediate: true, deep: true });
function getValueText(item: any) {
let valueText = '';
if (item?.inspectionResultVO) {
const inspectionValueList = item?.inspectionResultVO?.inspectionValueList || [];
if (inspectionValueList && inspectionValueList.length > 0) {
const inputList = ['text_input', 'textarea_input', 'number_input', 'date_picker'];
if (inputList.includes(item.interactionType)) {
valueText = inspectionValueList[0].valueText || '';
}
}
}
return valueText;
}
// 提交数据 // 提交数据
function setSubmitData() { function setSubmitData() {
let returnData: never[] = []; const returnData: {
nodeId: number;
nodeName: string;
resultStatus: number;
remark: string;
data: Record<string, unknown>[];
}[] = [];
columnsList.value.forEach((item: any) => { columnsList.value.forEach((item: any) => {
let dataList: never[] = []; const dataList: Record<string, unknown>[] = [];
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) && item.value != null && item.value !== "") { if (inputList.includes(item.interactionType) && item.value != null && item.value !== "") {
...@@ -85,7 +123,36 @@ function setSubmitData() { ...@@ -85,7 +123,36 @@ function setSubmitData() {
dataList.push(pushData); dataList.push(pushData);
} }
} }
} else if (item.interactionType == 'image_upload_and_button_select') {
const valueList = JSON.parse(item.value || '[]');
if (valueList && valueList.length > 0) {
for (let i = 0; i < valueList.length; i++) {
const pushData = {
id: item.id,
valueText: valueList[i].valueText || '',
valueKey: valueList[i].valueKey || '',
interactionType: 'button_select',
valueSeq: i + 1,
}
dataList.push(pushData);
}
}
const uploadValueList = JSON.parse(item.uploadValue || '[]');
if (uploadValueList && uploadValueList.length > 0) {
for (let i = 0; i < uploadValueList.length; i++) {
const pushData = {
id: item.id,
valueText: uploadValueList[i] || '',
valueKey: '',
interactionType: 'image_upload',
valueSeq: i + 1,
}
dataList.push(pushData);
}
}
} }
// 每项都入列,便于大项/二级切换时静默保存仍能带上当前 Tab 全部叶子(未填则为空 data,仍会走保存接口) // 每项都入列,便于大项/二级切换时静默保存仍能带上当前 Tab 全部叶子(未填则为空 data,仍会走保存接口)
returnData.push({ returnData.push({
nodeId: item.id, nodeId: item.id,
...@@ -95,6 +162,7 @@ function setSubmitData() { ...@@ -95,6 +162,7 @@ function setSubmitData() {
data: dataList, data: dataList,
}); });
}); });
console.log('validate', returnData);
return returnData; return returnData;
} }
...@@ -104,9 +172,24 @@ async function validate(): Promise<CustomizeFormValidateResult> { ...@@ -104,9 +172,24 @@ async function validate(): Promise<CustomizeFormValidateResult> {
let message = ''; let message = '';
columnsList.value.forEach((item: any) => { columnsList.value.forEach((item: any) => {
if (item.required == 1 && !item.value) { if (item.required == 1 && !item.value) {
let title = '请选择';
const inputList = ['text_input', 'textarea_input', 'number_input'];
const dropdownList = ['image_upload', 'video_upload'];
if (inputList.includes(item.interactionType)) {
title = '请输入';
}
if (dropdownList.includes(item.interactionType)) {
title = '请上传';
}
success = false;
message = message ? message : title + item.nodeName;
}
if (item.interactionType == 'image_upload_and_button_select' && !item.uploadValue) {
success = false; success = false;
message = message ? message : item.nodeName; message = message ? message : '请上传图片';
} }
}); });
return { return {
data: nodesData, data: nodesData,
...@@ -129,6 +212,17 @@ function getValidationRules(item: any) { ...@@ -129,6 +212,17 @@ function getValidationRules(item: any) {
return JSON.parse(item.validationRules || '{}'); return JSON.parse(item.validationRules || '{}');
} }
function setImgWidth(item: any) {
let resultStatus = false;
if (item.interactionType == 'image_upload' || item.interactionType == 'video_upload') {
const validationRules = JSON.parse(item.validationRules || '{}');
if (validationRules.maxCount && validationRules.maxCount == 1) {
resultStatus = true;
}
}
return resultStatus
}
defineExpose({ defineExpose({
validate, validate,
saveData, saveData,
...@@ -138,18 +232,25 @@ defineExpose({ ...@@ -138,18 +232,25 @@ defineExpose({
<template> <template>
<div> <div>
<van-overlay :show="pageLoading">
<div class="loadingBox">
<van-loading size="24px" color="#1989fa" vertical>加载中...</van-loading>
</div>
</van-overlay>
<div v-if="!pageLoading">
<van-form ref="customizeFormRef" :model="form" :rules="rules"> <van-form ref="customizeFormRef" :model="form" :rules="rules">
<div class="formTitle"> <div v-if="allowNoStructure" class="formTitle">
<!-- <div>{{ subTabLabel }}</div> --> <div @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" />
<span class="radioText">无此结构</span> <span class="radioText">无此结构</span>
</div> </div>
</div> </div>
<div v-for="(item, index) in columnsList" :key="index" class="customizeList" <div v-for="(item, index) in columnsList" :key="index" class="customizeList" :class="{
:class="{ 'border-bottom': index < columnsList.length - 1 && item.interactionType != 'image_upload' }"> 'border-bottom': index < columnsList.length - 1 && item.interactionType != 'image_upload',
'customizeList50': setImgWidth(item)
}">
<!-- 文本输入框 --> <!-- 文本输入框 -->
<div v-if="item.interactionType == 'text_input'"> <div v-if="item.interactionType == 'text_input'">
...@@ -161,15 +262,18 @@ defineExpose({ ...@@ -161,15 +262,18 @@ defineExpose({
<!-- 长文本输入框 --> <!-- 长文本输入框 -->
<div v-if="item.interactionType == 'textarea_input'"> <div v-if="item.interactionType == 'textarea_input'">
<van-field v-model="item.value" autosize :label="item.nodeName" <van-field v-model="item.value" autosize :label="item.nodeName"
:maxlength="getValidationRules(item).maxLength || 120" clearable :placeholder="item.placeholder" :maxlength="getValidationRules(item).maxLength || 120" clearable
:required="item.required === 1" rows="2" show-word-limit type="textarea" /> :placeholder="item.placeholder" :required="item.required === 1" rows="2" show-word-limit
type="textarea" />
</div> </div>
<!-- 数字输入框 --> <!-- 数字输入框 -->
<div v-if="item.interactionType == 'number_input'"> <div v-if="item.interactionType == 'number_input'">
<van-field v-model="item.value" :label="item.nodeName" clearable <van-field v-model="item.value" :label="item.nodeName" clearable
:maxlength="getValidationRules(item).maxLength || 120" :placeholder="item.placeholder" :maxlength="getValidationRules(item).maxLength || 120"
:required="item.required === 1" type="number" /> :min="getValidationRules(item).min || 0" :max="getValidationRules(item).max || 100000"
:placeholder="item.placeholder" :required="item.required === 1" type="number" step="0.01"
@input="(e) => { item.value = parseFloat(item.value)?.toFixed(getValidationRules(item).decimalDigits || 2) || '' }" />
</div> </div>
<!-- 单选框 --> <!-- 单选框 -->
...@@ -197,27 +301,29 @@ defineExpose({ ...@@ -197,27 +301,29 @@ defineExpose({
<customizeUploadFile :item="item" :value="item.value" @update="item.value = $event" /> <customizeUploadFile :item="item" :value="item.value" @update="item.value = $event" />
</div> </div>
<!-- image_upload_and_button_select -->
<div v-if="item.interactionType == 'image_upload_and_button_select'">
<buttonSelect :item="item" :value="item.value" @update="item.value = $event" />
<div v-if="item.value">
<buttonSelectAndImageUpload :item="item" @update="item.uploadValue = $event" />
</div>
</div>
</div> </div>
</van-form> </van-form>
</div> </div>
</div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.formTitle { .formTitle {
width: 100%; width: 100%;
float: left; float: left;
color: #333333;
font-size: 18px;
line-height: 24px;
background: #ffffff; background: #ffffff;
padding: 16px 12px; padding: 16px 12px;
display: flex; display: flex;
} }
.formRadio {
margin-left: 14px;
}
.radioText { .radioText {
color: #666666; color: #666666;
font-size: 12px; font-size: 12px;
...@@ -230,11 +336,20 @@ defineExpose({ ...@@ -230,11 +336,20 @@ defineExpose({
} }
.customizeList50 { .customizeList50 {
width: 50%; width: 50% !important;
float: left; float: left;
} }
.border-bottom { .border-bottom {
border-bottom: 1px solid #e6ebf5; border-bottom: 1px solid #e6ebf5;
} }
.loadingBox {
width: 80px;
height: 80px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style> </style>
...@@ -10,13 +10,31 @@ const props = defineProps({ ...@@ -10,13 +10,31 @@ const props = defineProps({
const emit = defineEmits(["update"]); const emit = defineEmits(["update"]);
const pickerValue = ref([]); const pickerValue = ref([]);
// 页面加载时初始化数据
onMounted(() => {
initData();
});
// 初始化数据
function initData() {
pickerValue.value = [];
if (props?.item?.inspectionResultVO) {
const inspectionValueList = props?.item?.inspectionResultVO?.inspectionValueList || [];
for (const i of inspectionValueList) {
if (i.valueText && i.interactionType == "button_select") { pickerValue.value.push(i.valueKey) }
}
}
setupdate();
}
// 计算属性 // 计算属性
const columnsList = computed(() => { const columnsList = computed(() => {
const optionsList = JSON.parse(props.item.options || '[]').map(item => { const optionsList = JSON.parse(props.item.options || "[]").map(item => {
const valueList = (item || '').split('-'); const valueList = (item || "").split("-");
return { return {
text: valueList[1] || '', text: valueList[1] || "",
value: valueList[0] || '', value: valueList[0] || "",
}; };
}); });
return optionsList; return optionsList;
...@@ -29,15 +47,22 @@ function handleBut(item: { value: string }) { ...@@ -29,15 +47,22 @@ function handleBut(item: { value: string }) {
} else { } else {
pickerValue.value.push(item.value); pickerValue.value.push(item.value);
} }
setupdate();
}
function setupdate() {
const valueList = (pickerValue.value || []).map(item => { const valueList = (pickerValue.value || []).map(item => {
const object = (columnsList.value || []).find(finditem => finditem.value == item) || {}; const object = (columnsList.value || []).find(finditem => finditem.value == item) || {};
return { return {
valueText: object.text || '', valueText: object.text || "",
valueKey: item || '', valueKey: item || "",
}; };
}); });
props.item.value = JSON.stringify(valueList || []); if (valueList.length > 0) {
emit("update", JSON.stringify(valueList || [])); emit("update", JSON.stringify(valueList || []));
} else {
emit("update", "");
}
} }
</script> </script>
...@@ -49,10 +74,10 @@ function handleBut(item: { value: string }) { ...@@ -49,10 +74,10 @@ function handleBut(item: { value: string }) {
<span>{{ item.nodeName }}</span> <span>{{ item.nodeName }}</span>
</div> </div>
<div class="selectList"> <div class="selectList">
<div v-for="(item, index) in columnsList" :key="index" @click="handleBut(item)" class="selectBut" <div v-for="(col, index) in columnsList" :key="index" class="selectBut"
:class="{ 'pitchOn': pickerValue.includes(item.value) }"> :class="{ 'pitchOn': pickerValue.includes(col.value) }" @click="handleBut(col)">
{{ item.text }} {{ col.text }}
<div v-if="pickerValue.includes(item.value)" class="pitchImg"></div> <div v-if="pickerValue.includes(col.value)" class="pitchImg"></div>
</div> </div>
</div> </div>
</div> </div>
...@@ -60,27 +85,27 @@ function handleBut(item: { value: string }) { ...@@ -60,27 +85,27 @@ function handleBut(item: { value: string }) {
<style lang="scss" scoped> <style lang="scss" scoped>
.buttonSelect { .buttonSelect {
width: 100%;
background: #ffffff;
float: left; float: left;
width: 100%;
background: #fff;
} }
.title { .title {
float: left;
width: 100%; width: 100%;
height: 24px; height: 24px;
color: #141e34; padding-left: 16px;
font-size: 14px;
line-height: 24px;
float: left;
margin-top: 16px; margin-top: 16px;
margin-bottom: 10px; margin-bottom: 10px;
padding-left: 16px; font-size: 14px;
line-height: 24px;
color: #141e34;
} }
.isRequired { .isRequired {
color: #ee3040;
font-size: 14px;
padding-right: 2px; padding-right: 2px;
font-size: 14px;
color: #ee3040;
} }
.selectList { .selectList {
...@@ -88,29 +113,27 @@ function handleBut(item: { value: string }) { ...@@ -88,29 +113,27 @@ function handleBut(item: { value: string }) {
} }
.selectBut { .selectBut {
width: -webkit-calc(33.333% - 12px); position: relative;
width: -moz-calc(33.333% - 12px); float: left;
width: calc(33.333% - 12px); width: calc(33.333% - 12px);
height: 36px; height: 36px;
line-height: 36px; margin-right: 6px;
border-radius: 6px; margin-bottom: 12px;
background: #f9f9f9; margin-left: 6px;
font-size: 14px; font-size: 14px;
font-weight: 400; font-weight: 400;
line-height: 36px;
color: #333;
text-align: center; text-align: center;
color: #333333;
float: left;
cursor: pointer; cursor: pointer;
position: relative; background: #f9f9f9;
margin-bottom: 12px;
margin-left: 6px;
margin-right: 6px;
border: 1px solid #f9f9f9; border: 1px solid #f9f9f9;
border-radius: 6px;
} }
.pitchOn { .pitchOn {
background: #ecf1ff !important;
color: #185EFE !important; color: #185EFE !important;
background: #ecf1ff !important;
border: 1px solid #185efe !important; border: 1px solid #185efe !important;
} }
...@@ -118,9 +141,9 @@ function handleBut(item: { value: string }) { ...@@ -118,9 +141,9 @@ function handleBut(item: { value: string }) {
position: absolute; position: absolute;
top: 0; top: 0;
right: 0; right: 0;
z-index: 99;
width: 16px; width: 16px;
height: 16px; height: 16px;
z-index: 99;
background-image: url("https://img02.glsx.com.cn/aus/images/preference/pitchOn.png"); background-image: url("https://img02.glsx.com.cn/aus/images/preference/pitchOn.png");
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: 100%; background-size: 100%;
......
<script setup lang="ts">
import { ref } from "vue";
import { uploadFile } from "@/utils/upload.js";
import { showToast } from "vant";
const props = defineProps({
item: {
type: Object,
default: () => { },
},
});
const emit = defineEmits(["update"]);
const uploading = ref(false);
const pickerValue = ref([]);
const fileInputRef = ref<HTMLInputElement | null>(null);
function pickFile() {
fileInputRef.value?.click();
}
// 页面加载时初始化数据
onMounted(() => {
initData();
});
// 初始化数据
function initData() {
pickerValue.value = [];
if (props?.item?.inspectionResultVO) {
const inspectionValueList = props?.item?.inspectionResultVO?.inspectionValueList || [];
for (const i of inspectionValueList) {
if (i.valueText && i.interactionType == "image_upload") { pickerValue.value.push(i.valueText) }
}
}
updateData();
}
// 计算属性
const validationRules = computed(() => {
return JSON.parse(props.item.validationRules || "{}");
});
async function onFileChange(ev: Event) {
const input = ev.target as HTMLInputElement;
const file = input.files?.[0];
input.value = "";
if (!file) return;
uploading.value = true;
try {
const res = await uploadFile(file);
const url = (typeof res.aliyunAddress === "string" && res.aliyunAddress) || (typeof res.url === "string" && res.url) || "";
showToast("上传成功");
pickerValue.value.push(url);
updateData();
} catch (error: unknown) {
const msg = error instanceof Error ? error.message : String(error);
showToast(`上传失败:${msg}`);
} finally {
uploading.value = false;
}
}
function handleDelete(item: string) {
pickerValue.value = pickerValue.value.filter((i) => i !== item);
updateData();
}
function updateData() {
if (pickerValue.value.length > 0) {
emit("update", JSON.stringify(pickerValue.value));
} else {
emit("update", "");
}
}
</script>
<template>
<div class="buttonSelect">
<div class="title">
<div class="titleContent">
<span class="isRequired">*</span>
<span>异常图片</span>
</div>
<div class="titleTip">
有损伤请拍摄图片,无损伤请忽略
</div>
</div>
<input ref="fileInputRef" accept="image/*" class="hidden-input" type="file" @change="onFileChange">
<div class="uploadPage">
<div v-if="(validationRules.maxCount || 3) > pickerValue.length" class="uploadBox" @click="pickFile">
<van-icon class="plusBox" color="#999999" name="plus" size="24" />
<div class="uploadTxt">
添加照片
</div>
</div>
<div v-for="(url, index) in pickerValue" :key="index" class="uploadBox">
<div class="deleteBox" @click="handleDelete(url)">
<van-icon color="#999999" name="clear" size="20" />
</div>
<van-image height="96" :src="url" style="border-radius: 8px;" width="96" />
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
.buttonSelect {
float: left;
width: 100%;
background: #fff;
}
.title {
float: left;
width: 100%;
padding-left: 16px;
margin-top: 16px;
margin-bottom: 10px;
}
.titleContent {
float: left;
width: 100%;
height: 24px;
font-size: 14px;
line-height: 24px;
color: #141e34;
}
.titleTip {
float: left;
width: 100%;
height: 16px;
font-size: 12px;
font-weight: 400;
line-height: 16px;
color: #999;
}
.isRequired {
padding-right: 2px;
font-size: 14px;
color: #ee3040;
}
.hidden-input {
position: absolute;
width: 0;
height: 0;
pointer-events: none;
opacity: 0;
}
.uploadPage {
float: left;
width: calc(100% - 24px);
margin-left: 12px;
}
.uploadBox {
position: relative;
float: left;
width: 96px;
height: 96px;
margin-right: 12px;
margin-bottom: 16px;
background: #f9f9f9;
border: 1px solid #ddd;
border-radius: 8px;
}
.plusBox {
float: left;
margin-top: 22px;
margin-right: 36px;
margin-left: 36px;
}
.uploadTxt {
float: left;
width: 100%;
height: 20px;
margin-top: 8px;
font-size: 12px;
font-weight: 400;
line-height: 20px;
color: #999;
text-align: center;
}
.deleteBox {
position: absolute;
top: 2px;
right: 2px;
z-index: 99;
width: 20px;
height: 20px;
cursor: pointer;
}
</style>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue"; import { ref } from "vue";
import { uploadFile } from "@/utils/upload.js";
const uploading = ref(false);
import { uploadFile } from "@/utils/upload.js";
import { showToast } from "vant"; import { showToast } from "vant";
const props = defineProps({ const props = defineProps({
item: { item: {
type: Object, type: Object,
default: () => { }, default: () => {},
}, },
}); });
const emit = defineEmits(["update"]); const emit = defineEmits(["update"]);
const pickerValue = ref([]); const uploading = ref(false);
const pickerValue = ref([]);
const fileInputRef = ref<HTMLInputElement | null>(null); const fileInputRef = ref<HTMLInputElement | null>(null);
function pickFile() { function pickFile() {
fileInputRef.value?.click(); fileInputRef.value?.click();
} }
// 页面加载时初始化数据
onMounted(() => {
initData();
});
// 初始化数据
function initData() {
pickerValue.value = [];
if (props?.item?.inspectionResultVO) {
const inspectionValueList = props?.item?.inspectionResultVO?.inspectionValueList || [];
for (const i of inspectionValueList) {
if (i.valueText) { pickerValue.value.push(i.valueText); }
}
}
updateData();
}
// 计算属性 // 计算属性
const validationRules = computed(() => { const validationRules = computed(() => {
return JSON.parse(props.item.validationRules || '{}'); return JSON.parse(props.item.validationRules || "{}");
}); });
async function onFileChange(ev: Event) { async function onFileChange(ev: Event) {
...@@ -39,11 +56,11 @@ async function onFileChange(ev: Event) { ...@@ -39,11 +56,11 @@ async function onFileChange(ev: Event) {
showToast("上传成功"); showToast("上传成功");
pickerValue.value.push(url); pickerValue.value.push(url);
console.log('pickerValue.value', pickerValue.value); console.log("pickerValue.value", pickerValue.value);
updateData(); updateData();
} catch (e: unknown) { } catch (error: unknown) {
const msg = e instanceof Error ? e.message : String(e); const msg = error instanceof Error ? error.message : String(error);
showToast(`上传失败:${msg}`); showToast(`上传失败:${msg}`);
} finally { } finally {
uploading.value = false; uploading.value = false;
...@@ -56,8 +73,11 @@ function handleDelete(item: string) { ...@@ -56,8 +73,11 @@ function handleDelete(item: string) {
} }
function updateData() { function updateData() {
props.item.value = JSON.stringify(pickerValue.value); if (pickerValue.value.length > 0) {
emit("update", JSON.stringify(pickerValue.value)); emit("update", JSON.stringify(pickerValue.value));
} else {
emit("update", "");
}
} }
</script> </script>
...@@ -74,18 +94,35 @@ function updateData() { ...@@ -74,18 +94,35 @@ function updateData() {
有损伤请拍摄图片,无损伤请忽略 有损伤请拍摄图片,无损伤请忽略
</div> </div>
</div> </div>
<input ref="fileInputRef" :accept="item.interactionType == 'image_upload' ? 'image/*' : 'video/*'" <input ref="fileInputRef"
class="hidden-input" type="file" @change="onFileChange"> :accept="item.interactionType == 'image_upload' ? 'image/*' : 'video/*'"
class="hidden-input"
type="file"
@change="onFileChange">
<div class="uploadPage"> <div class="uploadPage">
<div v-if="(validationRules.maxCount || 3) > pickerValue.length" class="uploadBox" @click="pickFile"> <div v-if="(validationRules.maxCount || 3) > pickerValue.length"
<van-icon name="plus" size="24" color="#999999" class="plusBox" /> class="uploadBox"
<div class="uploadTxt"> {{ item.interactionType == 'image_upload' ? '添加照片' : '添加视频' }}</div> @click="pickFile">
<van-icon class="plusBox"
color="#999999"
name="plus"
size="24" />
<div class="uploadTxt">
{{ item.interactionType == 'image_upload' ? '添加照片' : '添加视频' }}
</div> </div>
<div v-if="pickerValue.length" v-for="(item, index) in pickerValue" :key="index" class="uploadBox">
<div class="deleteBox" @click="handleDelete(item)">
<van-icon name="clear" size="20" color="#999999" />
</div> </div>
<van-image width="96" height="96" style="border-radius: 8px;" :src="item" /> <div v-for="(url, index) in pickerValue"
:key="index"
class="uploadBox">
<div class="deleteBox" @click="handleDelete(url)">
<van-icon color="#999999"
name="clear"
size="20" />
</div>
<van-image height="96"
:src="url"
style="border-radius: 8px;"
width="96" />
</div> </div>
</div> </div>
</div> </div>
...@@ -93,88 +130,86 @@ function updateData() { ...@@ -93,88 +130,86 @@ function updateData() {
<style lang="scss" scoped> <style lang="scss" scoped>
.buttonSelect { .buttonSelect {
width: 100%;
background: #ffffff;
float: left; float: left;
width: 100%;
background: #fff;
} }
.title { .title {
width: 100%;
float: left; float: left;
width: 100%;
padding-left: 16px;
margin-top: 16px; margin-top: 16px;
margin-bottom: 10px; margin-bottom: 10px;
padding-left: 16px;
} }
.titleContent { .titleContent {
float: left;
width: 100%; width: 100%;
height: 24px; height: 24px;
float: left;
color: #141e34;
font-size: 14px; font-size: 14px;
line-height: 24px; line-height: 24px;
color: #141e34;
} }
.titleTip { .titleTip {
float: left;
width: 100%; width: 100%;
height: 16px; height: 16px;
line-height: 16px;
float: left;
color: #999999;
font-size: 12px; font-size: 12px;
font-weight: 400; font-weight: 400;
line-height: 16px;
color: #999;
} }
.isRequired { .isRequired {
color: #ee3040;
font-size: 14px;
padding-right: 2px; padding-right: 2px;
font-size: 14px;
color: #ee3040;
} }
.hidden-input { .hidden-input {
position: absolute; position: absolute;
width: 0; width: 0;
height: 0; height: 0;
opacity: 0;
pointer-events: none; pointer-events: none;
opacity: 0;
} }
.uploadPage { .uploadPage {
width: -webkit-calc(100% - 24px);
width: -moz-calc(100% - 24px);
width: calc(100% - 24px);
float: left; float: left;
width: calc(100% - 24px);
margin-left: 12px; margin-left: 12px;
} }
.uploadBox { .uploadBox {
position: relative;
float: left;
width: 96px; width: 96px;
height: 96px; height: 96px;
border-radius: 8px;
border: 1px solid #dddddd;
background: #f9f9f9;
float: left;
margin-bottom: 16px;
margin-right: 12px; margin-right: 12px;
position: relative; margin-bottom: 16px;
background: #f9f9f9;
border: 1px solid #ddd;
border-radius: 8px;
} }
.plusBox { .plusBox {
float: left; float: left;
margin-top: 22px; margin-top: 22px;
margin-left: 36px;
margin-right: 36px; margin-right: 36px;
margin-left: 36px;
} }
.uploadTxt { .uploadTxt {
float: left;
width: 100%; width: 100%;
height: 20px; height: 20px;
float: left;
margin-top: 8px; margin-top: 8px;
line-height: 20px;
color: #999999;
font-size: 12px; font-size: 12px;
font-weight: 400; font-weight: 400;
line-height: 20px;
color: #999;
text-align: center; text-align: center;
} }
...@@ -182,9 +217,9 @@ function updateData() { ...@@ -182,9 +217,9 @@ function updateData() {
position: absolute; position: absolute;
top: 2px; top: 2px;
right: 2px; right: 2px;
z-index: 99;
width: 20px; width: 20px;
height: 20px; height: 20px;
z-index: 99;
cursor: pointer; cursor: pointer;
} }
</style> </style>
...@@ -4,42 +4,72 @@ import { computed, ref } from "vue"; ...@@ -4,42 +4,72 @@ import { computed, ref } from "vue";
const props = defineProps({ const props = defineProps({
item: { item: {
type: Object, type: Object,
default: () => { }, default: () => {},
}, },
}); });
const emit = defineEmits(["update"]); const emit = defineEmits(["update"]);
const pickerValue = ref(''); const pickerValue = ref("");
// 页面加载时初始化数据
onMounted(() => {
initData();
});
// 初始化数据
function initData() {
pickerValue.value = "";
if (props?.item?.inspectionResultVO) {
const inspectionValueList = props?.item?.inspectionResultVO?.inspectionValueList || [];
if (inspectionValueList && inspectionValueList.length > 0) {
pickerValue.value = inspectionValueList[0].valueKey || "";
}
}
}
// 计算属性 // 计算属性
const columnsList = computed(() => { const columnsList = computed(() => {
const optionsList = JSON.parse(props.item.options || '[]').map(item => { const optionsList = JSON.parse(props.item.options || "[]").map(item => {
const valueList = (item || '').split('-'); const valueList = (item || "").split("-");
return { return {
text: valueList[1] || '', text: valueList[1] || "",
value: valueList[0] || '', value: valueList[0] || "",
}; };
}); });
return optionsList; return optionsList;
}); });
function handleBut() { function handleBut() {
const ObjectItem = columnsList.value.find(item => item.value == pickerValue.value); const selected = columnsList.value.find((col) => col.value === pickerValue.value);
props.item.valueText = ObjectItem.text || ''; const value = pickerValue.value || "";
props.item.valueKey = ObjectItem.value || ''; props.item.value = selected?.value || "";
props.item.value = pickerValue.value || ''; props.item.valueText = selected?.text || "";
emit("update", pickerValue.value); props.item.valueKey = selected?.value || "";
emit("update", {
value,
valueText: selected?.text || "",
valueKey: selected?.value || "",
});
} }
</script> </script>
<template> <template>
<van-field name="radio" v-model="pickerValue" :required="item.required === 1" :label="item.nodeName"> <van-field v-model="pickerValue"
:label="item.nodeName"
name="radio"
:required="item.required === 1">
<template #input> <template #input>
<div class="templateBox"> <div class="templateBox">
<van-radio-group style="float: right;" v-model="pickerValue" @change="handleBut" direction="horizontal"> <van-radio-group v-model="pickerValue"
<van-radio v-for="item in columnsList" :key="item.value" :name="item.value" icon-size="14px"> direction="horizontal"
{{ item.text }} style="float: right;"
@change="handleBut">
<van-radio v-for="col in columnsList"
:key="col.value"
icon-size="14px"
:name="col.value">
{{ col.text }}
</van-radio> </van-radio>
</van-radio-group> </van-radio-group>
</div> </div>
......
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue"; import { computed, ref } from "vue";
const props = defineProps({ const props = defineProps({
item: { item: {
type: Object, type: Object,
default: () => { }, default: () => {},
}, },
}); });
const emit = defineEmits(["update"]); const emit = defineEmits(["update"]);
const displayValue = computed({
get: () => String(props.item.value ?? ""),
set: (v: string) => emit("update", v),
});
const columnsType = ref(["year", "month", "day"]);
const showPicker = ref(false); const showPicker = ref(false);
const pickerValue = ref([]); const pickerValue = ref([]);
// 页面加载时初始化数据
onMounted(() => {
initData();
});
// 初始化数据
function initData() {
const validationRules = JSON.parse(props.item.validationRules || "{}");
if (validationRules.datePattern && validationRules.datePattern === "YYYY-MM") {
columnsType.value = ["year", "month"];
} else {
columnsType.value = ["year", "month", "day"];
}
}
function handleShowPicker() { function handleShowPicker() {
showPicker.value = true; showPicker.value = true;
if (!props.item.value) { if (!props.item.value) {
const date = new Date(); const date = new Date();
if (columnsType.value.length === 2) {
pickerValue.value = [date.getFullYear(), date.getMonth() + 1];
} else {
pickerValue.value = [date.getFullYear(), date.getMonth() + 1, date.getDate()]; pickerValue.value = [date.getFullYear(), date.getMonth() + 1, date.getDate()];
} }
}
} }
function onConfirm() { function onConfirm() {
...@@ -26,7 +51,6 @@ function onConfirm() { ...@@ -26,7 +51,6 @@ function onConfirm() {
picker = pickerValue.value.join("-"); picker = pickerValue.value.join("-");
} }
showPicker.value = false; showPicker.value = false;
props.item.value = picker;
emit("update", picker); emit("update", picker);
} }
...@@ -34,10 +58,22 @@ function onConfirm() { ...@@ -34,10 +58,22 @@ function onConfirm() {
<template> <template>
<div> <div>
<van-field v-model="item.value" clearable is-link :label="item.nodeName" name="datePicker" <van-field v-model="displayValue"
:placeholder="item.placeholder" readonly :required="item.required === 1" @click="handleShowPicker" /> clearable
<van-popup v-model:show="showPicker" destroy-on-close position="bottom"> is-link
<van-date-picker v-model="pickerValue" :title="item.nodeName" @cancel="showPicker = false" :label="item.nodeName"
name="datePicker"
:placeholder="item.placeholder"
readonly
:required="item.required === 1"
@click="handleShowPicker" />
<van-popup v-model:show="showPicker"
destroy-on-close
position="bottom">
<van-date-picker v-model="pickerValue"
:columns-type="columnsType"
:title="item.nodeName"
@cancel="showPicker = false"
@confirm="onConfirm" /> @confirm="onConfirm" />
</van-popup> </van-popup>
</div> </div>
......
...@@ -12,13 +12,47 @@ const emit = defineEmits(["update"]); ...@@ -12,13 +12,47 @@ const emit = defineEmits(["update"]);
const showPicker = ref(false); const showPicker = ref(false);
const pickerValue = ref([]); const pickerValue = ref([]);
const displayValueText = computed({
get: () => String(props.item.valueText ?? ""),
set: (v: string) => {
if (!v) {
emit("update", { value: "", valueText: "", valueKey: "" });
return;
}
emit("update", {
value: String(props.item.value ?? ""),
valueText: v,
valueKey: String(props.item.valueKey ?? ""),
});
},
});
// 页面加载时初始化数据
onMounted(() => {
initData();
});
// 初始化数据
function initData() {
pickerValue.value = [];
if (props?.item?.inspectionResultVO) {
const inspectionValueList = props?.item?.inspectionResultVO?.inspectionValueList || [];
if (inspectionValueList && inspectionValueList.length > 0 && inspectionValueList[0].valueKey) {
pickerValue.value = [inspectionValueList[0].valueKey];
}
}
onConfirm();
console.log('pickerValue.value2222222222222222222', pickerValue.value);
}
// 计算属性 // 计算属性
const columnsList = computed(() => { const columnsList = computed(() => {
const optionsList = JSON.parse(props.item.options || '[]').map(item => { const optionsList = JSON.parse(props.item.options || "[]").map(item => {
const valueList = (item || '').split('-'); const valueList = (item || "").split("-");
return { return {
text: valueList[1] || '', text: valueList[1] || "",
value: valueList[0] || '', value: valueList[0] || "",
}; };
}); });
return optionsList; return optionsList;
...@@ -27,18 +61,22 @@ const columnsList = computed(() => { ...@@ -27,18 +61,22 @@ const columnsList = computed(() => {
function onConfirm() { function onConfirm() {
const picker = pickerValue.value && pickerValue.value.length > 0 ? pickerValue.value[0] : ""; const picker = pickerValue.value && pickerValue.value.length > 0 ? pickerValue.value[0] : "";
showPicker.value = false; showPicker.value = false;
const ObjectItem = columnsList.value.find(item => item.value == picker); const selected = columnsList.value.find((col) => col.value === picker) || {};
props.item.valueText = ObjectItem.text || ''; props.item.value = selected.value || "";
props.item.valueKey = ObjectItem.value || ''; props.item.valueText = selected.text || "";
props.item.value = picker || ''; props.item.valueKey = selected.value || "";
emit("update", picker); emit("update", {
value: selected.value || "",
valueText: selected.text || "",
valueKey: selected.value || "",
});
} }
</script> </script>
<template> <template>
<div> <div>
<van-field v-model="item.valueText" clearable is-link :label="item.nodeName" name="datePicker" <van-field v-model="displayValueText" clearable is-link :label="item.nodeName" name="datePicker"
:placeholder="item.placeholder" readonly :required="item.required === 1" @click="showPicker = true" /> :placeholder="item.placeholder" readonly :required="item.required === 1" @click="showPicker = true" />
<van-popup v-model:show="showPicker" destroy-on-close position="bottom"> <van-popup v-model:show="showPicker" destroy-on-close position="bottom">
<van-picker v-model="pickerValue" :columns="columnsList" :title="item.nodeName" @cancel="showPicker = false" <van-picker v-model="pickerValue" :columns="columnsList" :title="item.nodeName" @cancel="showPicker = false"
......
<template>
<van-popup class="logout-confirm-popup"
:close-on-click-overlay="true"
position="center"
round
:show="show"
@update:show="emit('update:show', $event)">
<div class="logout-confirm">
<van-icon class="logout-confirm__close"
name="cross"
@click="close" />
<div class="logout-confirm__top">
<img alt=""
class="logout-confirm__bg"
:src="popupBg" />
<div class="logout-confirm__hero">
<img alt=""
class="logout-confirm__icon"
:src="logoutWarningIcon" />
</div>
<h2 class="logout-confirm__title">
退出登录
</h2>
<p class="logout-confirm__desc">
是否确认退出登录?
</p>
</div>
<div class="logout-confirm__actions">
<button class="logout-confirm__btn logout-confirm__btn--cancel"
type="button"
@click="close">
取消
</button>
<button class="logout-confirm__btn logout-confirm__btn--confirm"
type="button"
@click="onConfirm">
确认
</button>
</div>
</div>
</van-popup>
</template>
<script setup lang="ts">
import logoutWarningIcon from "@/assets/image/logout-warning-icon.png";
import popupBg from "@/assets/image/popup-bg.png";
defineProps<{
show: boolean;
}>();
const emit = defineEmits<{
confirm: [];
"update:show": [value: boolean];
}>();
function close() {
emit("update:show", false);
}
function onConfirm() {
emit("confirm");
}
</script>
<style lang="scss" scoped>
@use "@assets/styles/variables" as *;
.logout-confirm-popup {
box-sizing: border-box;
width: calc(100vw - 48px);
max-width: 320px;
padding: 0;
overflow: visible;
background: transparent;
}
.logout-confirm {
position: relative;
padding: 0 0 20px;
overflow: hidden;
background: #fff;
border-radius: 18px;
box-shadow: $shadow-lg;
}
.logout-confirm__close {
position: absolute;
top: 12px;
right: 12px;
z-index: 3;
padding: 4px;
font-size: 20px;
color: #969799;
}
.logout-confirm__top {
position: relative;
z-index: 0;
padding-bottom: 4px;
overflow: hidden;
border-radius: 18px 18px 0 0;
}
.logout-confirm__bg {
position: absolute;
inset: 0;
z-index: 0;
display: block;
width: 100%;
height: 100%;
pointer-events: none;
object-fit: cover;
object-position: top center;
}
.logout-confirm__hero {
position: relative;
z-index: 1;
display: flex;
align-items: flex-end;
justify-content: center;
min-height: 132px;
padding: 28px 24px 0;
}
.logout-confirm__icon {
width: 88px;
height: auto;
margin-bottom: 4px;
}
.logout-confirm__title {
position: relative;
z-index: 1;
margin: 8px 20px 0;
font-size: 18px;
font-weight: 700;
line-height: 1.3;
color: #1a2744;
text-align: center;
}
.logout-confirm__desc {
position: relative;
z-index: 1;
margin: 10px 24px 0;
font-size: 14px;
line-height: 1.45;
color: $color-text-secondary;
text-align: center;
}
.logout-confirm__actions {
position: relative;
z-index: 1;
display: flex;
gap: 12px;
padding: 24px 20px 4px;
background: #fff;
border-radius: 0 0 18px 18px;
}
.logout-confirm__btn {
flex: 1;
height: 44px;
padding: 0 16px;
font-size: 16px;
line-height: 44px;
text-align: center;
cursor: pointer;
border: none;
border-radius: $radius-full;
transition: $transition-fast;
&:active {
opacity: 0.88;
}
}
.logout-confirm__btn--cancel {
font-weight: 400;
color: $color-text-secondary;
background: #f2f3f5;
}
.logout-confirm__btn--confirm {
font-weight: 500;
color: #fff;
background: $color-primary;
}
</style>
...@@ -20,7 +20,6 @@ const checkTag = computed(() => { ...@@ -20,7 +20,6 @@ const checkTag = computed(() => {
case 3: { case 3: {
return { text: "检测完成", bg: "#e9f9f1", color: "#2cca74" }; return { text: "检测完成", bg: "#e9f9f1", color: "#2cca74" };
} }
case 4:
default: { default: {
return { text: "已取消", bg: "#f2f3f5", color: "#969799" }; return { text: "已取消", bg: "#f2f3f5", color: "#969799" };
} }
...@@ -31,7 +30,9 @@ const auditTag = computed(() => { ...@@ -31,7 +30,9 @@ const auditTag = computed(() => {
if (props.auditStatus === undefined) return null; if (props.auditStatus === undefined) return null;
if (props.status !== 2 && props.status !== 3) return null; if (props.status !== 2 && props.status !== 3) return null;
// auditStatus: 1待审批;2审批中;3审批通过;4审批驳回 // auditStatus: 1待审批;2审批中;3审批通过;4审批驳回
// 待审核(待审批/审批中)仅在「检测完成」Tab 展示,检测中不显示
if (props.auditStatus === 1 || props.auditStatus === 2) { if (props.auditStatus === 1 || props.auditStatus === 2) {
if (props.status !== 3) return null;
return { text: "待审核", bg: "#f0eefd", color: "#6A56F0", icon: "clock" as const }; return { text: "待审核", bg: "#f0eefd", color: "#6A56F0", icon: "clock" as const };
} }
if (props.auditStatus === 3) { if (props.auditStatus === 3) {
...@@ -54,7 +55,9 @@ const auditTag = computed(() => { ...@@ -54,7 +55,9 @@ const auditTag = computed(() => {
<van-tag v-if="auditTag" <van-tag v-if="auditTag"
class="wo-tag" class="wo-tag"
:style="{ background: auditTag.bg, color: auditTag.color }"> :style="{ background: auditTag.bg, color: auditTag.color }">
<van-icon class="wo-tag__icon" :color="auditTag.color" :name="auditTag.icon" /> <van-icon class="wo-tag__icon"
:color="auditTag.color"
:name="auditTag.icon" />
{{ auditTag.text }} {{ auditTag.text }}
</van-tag> </van-tag>
</div> </div>
......
...@@ -5,9 +5,8 @@ ...@@ -5,9 +5,8 @@
import { Defaults, Request } from "glsk-toolkit"; import { Defaults, Request } from "glsk-toolkit";
import { showToast } from "vant"; import { showToast } from "vant";
import { CONFIG_CACHE_KEY, CONFIG_CENTER_URL } from "./constants"; import { CONFIG_CACHE_KEY, CONFIG_CENTER_URL, TOKEN_KEY } from "./constants";
const TOKEN_KEY = "venus_usedcar_token";
const defaultBaseURL = import.meta.env.VITE_API_BASE_URL ?? ""; const defaultBaseURL = import.meta.env.VITE_API_BASE_URL ?? "";
let config: Record<string, unknown> = {}; let config: Record<string, unknown> = {};
...@@ -47,11 +46,11 @@ export function getRequestApi(): null | Request { ...@@ -47,11 +46,11 @@ export function getRequestApi(): null | Request {
*/ */
function initRequestInstance(cfg: Record<string, unknown>): void { function initRequestInstance(cfg: Record<string, unknown>): void {
const apiBaseUrl = (( const apiBaseUrl = ((
(cfg.apiEnv as { baseURL?: string; baseUrl?: string } | undefined)?.baseURL ?? (cfg.apiEnv as undefined | { baseURL?: string; baseUrl?: string })?.baseURL ??
(cfg.apiEnv as { baseURL?: string; baseUrl?: string } | undefined)?.baseUrl ?? (cfg.apiEnv as undefined | { baseURL?: string; baseUrl?: string })?.baseUrl ??
cfg.apiBaseUrl ?? cfg.apiBaseUrl ??
(cfg.gsc as { baseUrl?: string; baseURL?: string } | undefined)?.baseUrl ?? (cfg.gsc as undefined | { baseUrl?: string; baseURL?: string })?.baseUrl ??
(cfg.gsc as { baseUrl?: string; baseURL?: string } | undefined)?.baseURL (cfg.gsc as undefined | { baseUrl?: string; baseURL?: string })?.baseURL
) as string | undefined); ) as string | undefined);
const baseUrl = apiBaseUrl || defaultBaseURL; const baseUrl = apiBaseUrl || defaultBaseURL;
......
/** /**
* 配置中心常量 * 应用级常量(配置中心、鉴权存储 key 等)
*/ */
/** 二手车 H5 配置请求 URL */ /** 二手车 H5 配置请求 URL */
export const CONFIG_CENTER_URL = export const CONFIG_CENTER_URL =
"https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=venus-usedcar-config&env=develop"; "https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=venus-usedcar-config&env=develop";
/** 配置缓存 key */ /** 配置缓存 key */
export const CONFIG_CACHE_KEY = "venus_usedcar_config"; export const CONFIG_CACHE_KEY = "venus_usedcar_config";
/** localStorage:登录 token(存裸 token,请求头由封装层加 Bearer) */
export const TOKEN_KEY = "venus_usedcar_token";
/** sessionStorage:未登录时记录目标路径,登录成功后回跳 */
export const LOGIN_REDIRECT_KEY = "venus_usedcar_login_redirect";
...@@ -4,4 +4,9 @@ export { ...@@ -4,4 +4,9 @@ export {
getConfig, getConfig,
getRequestApi, getRequestApi,
} from "./center.ts"; } from "./center.ts";
export { CONFIG_CACHE_KEY, CONFIG_CENTER_URL } from "./constants.ts"; export {
CONFIG_CACHE_KEY,
CONFIG_CENTER_URL,
LOGIN_REDIRECT_KEY,
TOKEN_KEY,
} from "./constants.ts";
import { createRouter, createWebHistory } from "vue-router"; import { createRouter, createWebHistory } from "vue-router";
import { LOGIN_REDIRECT_KEY } from "@/config/constants";
import { useUserStore } from "@stores/modules/user.ts";
import { closeToast, showLoadingToast } from "vant"; import { closeToast, showLoadingToast } from "vant";
import routes from "./routes.ts"; import routes from "./routes.ts";
import { useUserStore } from "@stores/modules/user.ts";
const LOGIN_REDIRECT_KEY = "venus_usedcar_login_redirect"; const ROUTE_LOADING_DELAY_MS = 200;
let routeLoadingTimer: ReturnType<typeof setTimeout> | undefined;
const router = createRouter({ const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL), history: createWebHistory(import.meta.env.BASE_URL),
...@@ -19,17 +21,27 @@ const router = createRouter({ ...@@ -19,17 +21,27 @@ const router = createRouter({
}); });
// 不需要登录的白名单路由 // 不需要登录的白名单路由
const WHITE_LIST: string[] = ["/login"]; const WHITE_LIST = new Set(["/inspect-detail", "/inspect-report", "/login"]);
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
const userStore = useUserStore(); const userStore = useUserStore();
if (routeLoadingTimer !== undefined) {
clearTimeout(routeLoadingTimer);
routeLoadingTimer = undefined;
}
if (!to.meta.hideRouteLoading) {
routeLoadingTimer = window.setTimeout(() => {
routeLoadingTimer = undefined;
showLoadingToast({ showLoadingToast({
message: "加载中...", message: "加载中...",
forbidClick: true, forbidClick: true,
duration: 0, duration: 0,
loadingType: "spinner", loadingType: "spinner",
}); });
}, ROUTE_LOADING_DELAY_MS);
}
if (to.meta.title) { if (to.meta.title) {
document.title = `${to.meta.title} - ${import.meta.env.VITE_APP_TITLE}`; document.title = `${to.meta.title} - ${import.meta.env.VITE_APP_TITLE}`;
...@@ -50,7 +62,7 @@ router.beforeEach((to, from, next) => { ...@@ -50,7 +62,7 @@ router.beforeEach((to, from, next) => {
} }
// 2. 没有 token 的情况 // 2. 没有 token 的情况
if (WHITE_LIST.includes(to.path)) { if (WHITE_LIST.has(to.path)) {
next(); next();
return; return;
} }
...@@ -61,6 +73,10 @@ router.beforeEach((to, from, next) => { ...@@ -61,6 +73,10 @@ router.beforeEach((to, from, next) => {
}); });
router.afterEach(() => { router.afterEach(() => {
if (routeLoadingTimer !== undefined) {
clearTimeout(routeLoadingTimer);
routeLoadingTimer = undefined;
}
closeToast(); closeToast();
}); });
......
/*
* @Author: cen
* @Date: 2026-03-24 17:37:44
* @Description:
* @FilePath: /venus-usedcar-h5/apps/web/venus-usedcar-quality/src/router/routes.ts
* @LastEditTime: 2026-03-25 19:41:22
* @LastEditors: cenchengwei@foreverht.com
* 可以输入预定的版权声明、个性签名、空行等
*/
import type { RouteRecordRaw } from "vue-router"; import type { RouteRecordRaw } from "vue-router";
const routes: RouteRecordRaw[] = [ const routes: RouteRecordRaw[] = [
...@@ -8,6 +17,7 @@ const routes: RouteRecordRaw[] = [ ...@@ -8,6 +17,7 @@ const routes: RouteRecordRaw[] = [
meta: { meta: {
title: "登录", title: "登录",
showTabBar: false, showTabBar: false,
hideRouteLoading: true,
}, },
}, },
{ {
...@@ -48,6 +58,33 @@ const routes: RouteRecordRaw[] = [ ...@@ -48,6 +58,33 @@ const routes: RouteRecordRaw[] = [
showTabBar: true, showTabBar: true,
}, },
}, },
{
path: "car-detail/:id",
name: "CarDetail",
component: () => import("@views/car-detail/index.vue"),
meta: {
title: "车辆详情",
keepAlive: false,
showTabBar: false,
},
},
{
path: "work-order-detail/:id",
name: "WorkOrderDetail",
component: () => import("@views/work-order-detail/index.vue"),
meta: {
title: "工单详情",
keepAlive: false,
showTabBar: false,
},
},
{
path: "word-order-detail/:id",
redirect: (to) => ({
name: "WorkOrderDetail",
params: { id: to.params.id },
}),
},
], ],
}, },
{ {
...@@ -59,22 +96,21 @@ const routes: RouteRecordRaw[] = [ ...@@ -59,22 +96,21 @@ const routes: RouteRecordRaw[] = [
showTabBar: false, showTabBar: false,
}, },
}, },
/** 开发自测:OSS 分片上传 */
{ {
path: "/upload-demo", path: "/inspect-report",
name: "UploadDemo", name: "InspectReport",
component: () => import("@views/upload-demo/index.vue"), component: () => import("@views/inspect-report/index.vue"),
meta: { meta: {
title: "OSS 上传 Demo", title: "检测报告",
showTabBar: false, showTabBar: false,
}, },
}, },
{ {
path: "/word-order-detail/:id", path: "/inspect-detail",
name: "WorkOrderDetail", name: "InspectDetail",
component: () => import("@views/word-order-detail/index.vue"), component: () => import("@views/inspect-detail/index.vue"),
meta: { meta: {
title: "工单详情", title: "检测详情",
showTabBar: false, showTabBar: false,
}, },
}, },
...@@ -84,6 +120,7 @@ const routes: RouteRecordRaw[] = [ ...@@ -84,6 +120,7 @@ const routes: RouteRecordRaw[] = [
component: () => import("@views/404/index.vue"), component: () => import("@views/404/index.vue"),
meta: { meta: {
title: "页面不存在", title: "页面不存在",
hideRouteLoading: true,
}, },
}, },
]; ];
......
import { defineStore } from "pinia"; import { computed, ref } from "vue";
import { ref, computed } from "vue";
const TOKEN_KEY = "venus_usedcar_token"; import { logout as requestAuthLogout } from "@/api/modules/user";
import { LOGIN_REDIRECT_KEY, TOKEN_KEY } from "@/config/constants";
import { notifyHostLogout } from "@/utils/webviewBridge";
import { defineStore } from "pinia";
export interface UserInfo { export interface UserInfo {
id: number; id: number;
...@@ -14,7 +16,7 @@ export const useUserStore = defineStore( ...@@ -14,7 +16,7 @@ export const useUserStore = defineStore(
"user", "user",
() => { () => {
const token = ref<string>(""); const token = ref<string>("");
const userInfo = ref<UserInfo | null>(null); const userInfo = ref<null | UserInfo>(null);
const isLoggedIn = computed(() => !!token.value); const isLoggedIn = computed(() => !!token.value);
const username = computed(() => userInfo.value?.nickname ?? ""); const username = computed(() => userInfo.value?.nickname ?? "");
...@@ -32,10 +34,23 @@ export const useUserStore = defineStore( ...@@ -32,10 +34,23 @@ export const useUserStore = defineStore(
userInfo.value = info; userInfo.value = info;
} }
function logout() { /** 调服务端登出后清空 token、用户信息、本地缓存,并通知宿主 WebView */
async function logout() {
try {
if (token.value) {
await requestAuthLogout();
}
} catch {
// 接口失败仍执行本地登出
} finally {
token.value = ""; token.value = "";
userInfo.value = null; userInfo.value = null;
localStorage.removeItem(TOKEN_KEY); localStorage.removeItem(TOKEN_KEY);
notifyHostLogout();
}
sessionStorage.removeItem(LOGIN_REDIRECT_KEY);
const { default: router } = await import("@/router");
await router.replace({ path: "/login" });
} }
return { return {
......
import type { RouteMeta } from "vue-router";
declare module "vue-router" { declare module "vue-router" {
interface RouteMeta { interface RouteMeta {
...@@ -6,14 +5,16 @@ declare module "vue-router" { ...@@ -6,14 +5,16 @@ declare module "vue-router" {
keepAlive?: boolean; keepAlive?: boolean;
showTabBar?: boolean; showTabBar?: boolean;
requiresAuth?: boolean; requiresAuth?: boolean;
/** 为 true 时不展示全局路由 Loading、不参与延迟 Toast */
hideRouteLoading?: boolean;
} }
} }
declare global { declare global {
interface Window { interface Window {
__APP_INFO__: { __APP_INFO__: {
version: string;
buildTime: string; buildTime: string;
version: string;
}; };
} }
} }
......
import type { InspectionNode, LeafNodeRecord } from "@/api"; import type { InspectionNode, InspectionResultVO, LeafNodeRecord } from "@/api";
/** 检测评分:骨架/内饰等级选项(与 ScoreForm 共用) */ /** 检测评分:骨架/内饰等级选项(与 ScoreForm 共用) */
export const SCORE_RATING_OPTIONS = ["A", "B", "C", "D"] as const; export const SCORE_RATING_OPTIONS = ["A", "B", "C", "D"] as const;
...@@ -10,6 +10,8 @@ export interface SubTab { ...@@ -10,6 +10,8 @@ export interface SubTab {
nodeId?: number; nodeId?: number;
/** 该二级项下的叶子节点列表(nodeType=3) */ /** 该二级项下的叶子节点列表(nodeType=3) */
leafNodes?: InspectionNode[]; leafNodes?: InspectionNode[];
/** 二级项节点上的检测结果(与接口一致,进度/勾选优先据此判断) */
inspectionResultVO?: InspectionResultVO;
/** 二级项自身的完成标志:0 未完成,1 已完成 */ /** 二级项自身的完成标志:0 未完成,1 已完成 */
completedFlag?: 0 | 1; completedFlag?: 0 | 1;
} }
...@@ -21,6 +23,11 @@ export interface BigModule { ...@@ -21,6 +23,11 @@ export interface BigModule {
/** 是否存在二级分组 Tab;false 表示子节点直接为叶子(nodeType=3),不展示二级 Tab */ /** 是否存在二级分组 Tab;false 表示子节点直接为叶子(nodeType=3),不展示二级 Tab */
hasSecondaryTabs?: boolean; hasSecondaryTabs?: boolean;
subTabs: SubTab[]; subTabs: SubTab[];
/**
* 当前大项下二级接口列表维度:total = 列表长度,done = 各节点 inspectionResultVO.completedFlag 统计
* (无二级 Tab、叶子直挂大项时按同一接口返回的叶子条数统计)
*/
secondaryProgress?: { done: number; total: number; };
} }
/** /**
......
import { TOKEN_KEY } from "@/config/constants";
import axios, { AxiosInstance, AxiosResponse } from "axios"; import axios, { AxiosInstance, AxiosResponse } from "axios";
import { showToast } from "vant"; import { showToast } from "vant";
...@@ -48,7 +49,6 @@ export interface RequestConfig { ...@@ -48,7 +49,6 @@ export interface RequestConfig {
[key: string]: unknown; [key: string]: unknown;
} }
const TOKEN_KEY = "venus_usedcar_token";
const defaultBaseURL = import.meta.env.VITE_API_BASE_URL ?? ""; const defaultBaseURL = import.meta.env.VITE_API_BASE_URL ?? "";
/** 业务成功码 */ /** 业务成功码 */
...@@ -58,7 +58,7 @@ const BIZ_CODES_NO_GLOBAL_TOAST = new Set([1000, 1002, 1003, 1010]); ...@@ -58,7 +58,7 @@ const BIZ_CODES_NO_GLOBAL_TOAST = new Set([1000, 1002, 1003, 1010]);
/** 未登录或登录过期 */ /** 未登录或登录过期 */
const BIZ_CODE_UNAUTHORIZED = 1006; const BIZ_CODE_UNAUTHORIZED = 1006;
function normalizeBizCode(code: unknown): number | null { function normalizeBizCode(code: unknown): null | number {
if (code === null || code === undefined || code === "") { if (code === null || code === undefined || code === "") {
return null; return null;
} }
...@@ -82,11 +82,11 @@ function getToken(): string { ...@@ -82,11 +82,11 @@ function getToken(): string {
function resolveBaseURL(): string { function resolveBaseURL(): string {
const cfg = getConfig() as Record<string, unknown>; const cfg = getConfig() as Record<string, unknown>;
const apiBaseUrl = const apiBaseUrl =
((cfg.apiEnv as { baseURL?: string; baseUrl?: string } | undefined)?.baseURL ?? ((cfg.apiEnv as undefined | { baseURL?: string; baseUrl?: string })?.baseURL ??
(cfg.apiEnv as { baseURL?: string; baseUrl?: string } | undefined)?.baseUrl ?? (cfg.apiEnv as undefined | { baseURL?: string; baseUrl?: string })?.baseUrl ??
(cfg.apiBaseUrl as string | undefined) ?? (cfg.apiBaseUrl as string | undefined) ??
(cfg.gsc as { baseUrl?: string; baseURL?: string } | undefined)?.baseUrl ?? (cfg.gsc as undefined | { baseUrl?: string; baseURL?: string })?.baseUrl ??
(cfg.gsc as { baseUrl?: string; baseURL?: string } | undefined)?.baseURL) as (cfg.gsc as undefined | { baseUrl?: string; baseURL?: string })?.baseURL) as
| string | string
| undefined; | undefined;
...@@ -112,7 +112,7 @@ function getInstance(): AxiosInstance { ...@@ -112,7 +112,7 @@ function getInstance(): AxiosInstance {
const token = getToken(); const token = getToken();
if (token) { if (token) {
config.headers = { config.headers = {
...(config.headers || {}), ...config.headers,
Authorization: token, Authorization: token,
} as typeof config.headers; } as typeof config.headers;
} }
......
import { useUserStore } from "@stores/modules/user"; import { useUserStore } from "@stores/modules/user";
type HostMessage = type HostMessage =
| { type: "INIT_TOKEN"; token?: string } | Record<string, unknown>
| { type: "AUTH_TOKEN"; token?: string } | { token?: string; type: "AUTH_TOKEN"; }
| { type: "LOGOUT" } | { token?: string; type: "INIT_TOKEN"; }
| Record<string, unknown>; | { type: "LOGOUT" };
function safeJsonParse(input: unknown): unknown { function safeJsonParse(input: unknown): unknown {
if (typeof input !== "string") return input; if (typeof input !== "string") return input;
...@@ -35,10 +35,10 @@ function stripTokenFromUrl() { ...@@ -35,10 +35,10 @@ function stripTokenFromUrl() {
} }
function postToUniApp(payload: Record<string, unknown>) { function postToUniApp(payload: Record<string, unknown>) {
console.log('pad端postToUniApp', payload); console.log("pad端postToUniApp", payload);
const w = window as unknown as { const w = window as unknown as {
uni?: { postMessage?: (args: { data: unknown }) => void };
parent?: Window; parent?: Window;
uni?: { postMessage?: (args: { data: unknown }) => void };
}; };
const doPost = () => { const doPost = () => {
...@@ -61,7 +61,7 @@ function postToUniApp(payload: Record<string, unknown>) { ...@@ -61,7 +61,7 @@ function postToUniApp(payload: Record<string, unknown>) {
doPost(); doPost();
} else { } else {
// 等待 UniAppJSBridgeReady 事件后再发送 // 等待 UniAppJSBridgeReady 事件后再发送
document.addEventListener('UniAppJSBridgeReady', doPost, { once: true }); document.addEventListener("UniAppJSBridgeReady", doPost, { once: true });
} }
} }
...@@ -109,7 +109,7 @@ export function initTokenBridge() { ...@@ -109,7 +109,7 @@ export function initTokenBridge() {
} }
} }
if (type === "LOGOUT") { if (type === "LOGOUT") {
userStore.logout(); void userStore.logout();
} }
}); });
} }
......
...@@ -8,9 +8,11 @@ ...@@ -8,9 +8,11 @@
<input class="score-input" <input class="score-input"
inputmode="numeric" inputmode="numeric"
maxlength="3" maxlength="3"
pattern="[0-9]*"
type="text" type="text"
:value="String(form.appearanceScore)" :value="String(form.appearanceScore)"
@input="onAppearanceScoreInput" /> @input="onAppearanceScoreInput"
@keydown="onScoreInputKeydown" />
<span class="score-unit">分</span> <span class="score-unit">分</span>
</div> </div>
</div> </div>
...@@ -55,7 +57,9 @@ ...@@ -55,7 +57,9 @@
@click="openRatingGuide('frame')" @click="openRatingGuide('frame')"
@keydown.enter.prevent="openRatingGuide('frame')" @keydown.enter.prevent="openRatingGuide('frame')"
@keydown.space.prevent="openRatingGuide('frame')"> @keydown.space.prevent="openRatingGuide('frame')">
参考 <img alt="指引"
class="score-ref-icon"
:src="systemTipImg" />
</span> </span>
</div> </div>
<div class="rating-btns"> <div class="rating-btns">
...@@ -64,11 +68,11 @@ ...@@ -64,11 +68,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" <img v-if="form.frameRating === opt"
alt=""
aria-hidden="true" aria-hidden="true"
class="rating-btn-check"> class="rating-btn-check"
☑️ :src="ratingSelectedCheckImg" />
</span>
{{ opt }} {{ opt }}
</div> </div>
</div> </div>
...@@ -93,7 +97,9 @@ ...@@ -93,7 +97,9 @@
@click="openRatingGuide('interior')" @click="openRatingGuide('interior')"
@keydown.enter.prevent="openRatingGuide('interior')" @keydown.enter.prevent="openRatingGuide('interior')"
@keydown.space.prevent="openRatingGuide('interior')"> @keydown.space.prevent="openRatingGuide('interior')">
参考 <img alt="指引"
class="score-ref-icon"
:src="systemTipImg" />
</span> </span>
</div> </div>
<div class="rating-btns"> <div class="rating-btns">
...@@ -102,11 +108,11 @@ ...@@ -102,11 +108,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" <img v-if="form.interiorRating === opt"
alt=""
aria-hidden="true" aria-hidden="true"
class="rating-btn-check"> class="rating-btn-check"
☑️ :src="ratingSelectedCheckImg" />
</span>
{{ opt }} {{ opt }}
</div> </div>
</div> </div>
...@@ -129,9 +135,11 @@ ...@@ -129,9 +135,11 @@
<input class="score-input" <input class="score-input"
inputmode="numeric" inputmode="numeric"
maxlength="3" maxlength="3"
pattern="[0-9]*"
type="text" type="text"
:value="String(form.overallScore)" :value="String(form.overallScore)"
@input="onOverallScoreInput" /> @input="onOverallScoreInput"
@keydown="onScoreInputKeydown" />
<span class="score-unit">分</span> <span class="score-unit">分</span>
</div> </div>
</div> </div>
...@@ -180,6 +188,8 @@ import type { RatingGuideConfig } from "./rating-guide-content"; ...@@ -180,6 +188,8 @@ import type { RatingGuideConfig } from "./rating-guide-content";
import { reactive, ref, watch } from "vue"; import { reactive, ref, watch } from "vue";
import ratingSelectedCheckImg from "@/assets/image/rating-selected-check.png";
import systemTipImg from "@/assets/image/system-tip.png";
import { SCORE_RATING_OPTIONS as RATING_OPTIONS } from "@/types/views/car-detail"; import { SCORE_RATING_OPTIONS as RATING_OPTIONS } from "@/types/views/car-detail";
import { getInspectionChildren } from "@api"; import { getInspectionChildren } from "@api";
import { isRequestFailureAlreadyHandled } from "@utils/request"; import { isRequestFailureAlreadyHandled } from "@utils/request";
...@@ -311,6 +321,28 @@ function clampScoreFromInput(raw: string): number { ...@@ -311,6 +321,28 @@ function clampScoreFromInput(raw: string): number {
return Math.min(100, Math.max(0, n)); return Math.min(100, Math.max(0, n));
} }
/** 阻止键入非数字;粘贴仍走 @input + clampScoreFromInput */
function onScoreInputKeydown(e: KeyboardEvent) {
if (e.isComposing) return;
if (e.ctrlKey || e.metaKey || e.altKey) return;
const navKeys = new Set([
"ArrowDown",
"ArrowLeft",
"ArrowRight",
"ArrowUp",
"Backspace",
"Delete",
"End",
"Enter",
"Escape",
"Home",
"Tab",
]);
if (navKeys.has(e.key)) return;
if (/^\d$/.test(e.key)) return;
e.preventDefault();
}
function onAppearanceScoreInput(e: Event) { function onAppearanceScoreInput(e: Event) {
form.appearanceScore = clampScoreFromInput((e.target as HTMLInputElement).value); form.appearanceScore = clampScoreFromInput((e.target as HTMLInputElement).value);
} }
...@@ -364,7 +396,7 @@ defineExpose({ validate, getCompleteInspectionPayload }); ...@@ -364,7 +396,7 @@ defineExpose({ validate, getCompleteInspectionPayload });
.score-section { .score-section {
box-sizing: border-box; box-sizing: border-box;
padding: 14px 16px; padding: 14px 16px;
background: #ffffff; background: #fff;
border-radius: 8px; border-radius: 8px;
opacity: 1; opacity: 1;
} }
...@@ -401,7 +433,7 @@ defineExpose({ validate, getCompleteInspectionPayload }); ...@@ -401,7 +433,7 @@ defineExpose({ validate, getCompleteInspectionPayload });
padding: 0 6px; padding: 0 6px;
font-size: 16px; font-size: 16px;
font-weight: 500; font-weight: 500;
color: #333333; color: #333;
text-align: center; text-align: center;
appearance: none; appearance: none;
background: #fff; background: #fff;
...@@ -422,12 +454,16 @@ defineExpose({ validate, getCompleteInspectionPayload }); ...@@ -422,12 +454,16 @@ defineExpose({ validate, getCompleteInspectionPayload });
} }
.score-ref { .score-ref {
padding: 2px 8px; display: inline-flex;
font-size: 12px; align-items: center;
color: #185efe; justify-content: center;
cursor: pointer; cursor: pointer;
border: 1px solid #185efe; }
border-radius: 4px;
.score-ref-icon {
display: block;
width: auto;
height: 16px;
} }
.score-slider-wrap { .score-slider-wrap {
...@@ -468,8 +504,8 @@ defineExpose({ validate, getCompleteInspectionPayload }); ...@@ -468,8 +504,8 @@ defineExpose({ validate, getCompleteInspectionPayload });
height: 40px; height: 40px;
font-size: 16px; font-size: 16px;
font-weight: 600; font-weight: 600;
cursor: pointer;
color: #999; color: #999;
cursor: pointer;
background: #f7f8fa; background: #f7f8fa;
border: 1px solid #e8e8e8; border: 1px solid #e8e8e8;
border-radius: 8px; border-radius: 8px;
...@@ -483,11 +519,12 @@ defineExpose({ validate, getCompleteInspectionPayload }); ...@@ -483,11 +519,12 @@ defineExpose({ validate, getCompleteInspectionPayload });
.rating-btn-check { .rating-btn-check {
position: absolute; position: absolute;
top: 2px; top: -3px;
right: 2px; right: 0;
font-size: 10px; width: 14px;
line-height: 1; height: 14px;
pointer-events: none; pointer-events: none;
object-fit: contain;
} }
} }
......
import type { BigModule, CustomizeFormValidateNode, CustomizeFormValidateResult } from "@/types/views/car-detail";
import type { LeafNodeRecord } from "@api";
import type { Ref } from "vue";
import type { InspectModulesReturn } from "./useInspectModules";
import { ref } from "vue";
import { useRouter } from "vue-router";
import customizeForm from "@/components/CustomizeForm/Index.vue";
import {
completeInspection,
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";
function buildInspectionSavePayload(
modules: InspectModulesReturn,
leafNodes: LeafNodeRecord[],
nextFlag: boolean
) {
const { taskId, activeBigModule, activeSubTab } = modules;
const hasSecondaryTabs = activeBigModule.value?.hasSecondaryTabs === true;
return {
taskId: taskId.value,
locationModule: activeBigModule.value?.nodeId ?? 0,
locationSubModule: hasSecondaryTabs ? (activeSubTab.value?.nodeId ?? 0) : null,
nextFlag,
leafNodes,
};
}
function leafRecordFromValidateNode(raw: CustomizeFormValidateNode): LeafNodeRecord {
return {
data: (raw.data ?? []).map((item) => ({
interactionType: item.interactionType ?? "",
remark: item.remark ?? "",
valueKey: item.valueKey ?? "",
valueSeq: item.valueSeq ?? 0,
valueText: item.valueText ?? "",
})),
nodeId: Number(raw.nodeId),
nodeName: String(raw.nodeName ?? ""),
remark: String(raw.remark ?? ""),
resultStatus: Number(raw.resultStatus),
};
}
export function useInspectSubmit(
modules: InspectModulesReturn,
customizeFormRef: Ref<InstanceType<typeof customizeForm> | null>,
inspectionScoreFormRef: Ref<InstanceType<typeof ScoreForm> | null>
) {
const router = useRouter();
const submitting = ref(false);
async function saveCurrentLeafInspectionRecord(nextFlag: boolean): Promise<boolean> {
const saved = (await customizeFormRef.value?.saveData?.()) as CustomizeFormValidateResult | undefined;
const rows = saved?.data;
if (!rows?.length) return false;
const leafNodes = rows.map((row) => leafRecordFromValidateNode(row));
await saveInspectionRecord(buildInspectionSavePayload(modules, leafNodes, nextFlag));
return true;
}
async function persistCurrentSubTabSilently() {
if (modules.activeBigKey.value === SCORE_BIG_KEY) return;
try {
await saveCurrentLeafInspectionRecord(false);
} catch {
/* 静默失败,不阻断切换 */
}
}
async function onSelectBigModule(selectedBigModule: BigModule) {
modules.showModulePicker.value = false;
if (selectedBigModule.key === modules.activeBigKey.value) return;
await persistCurrentSubTabSilently();
modules.activeBigKey.value = selectedBigModule.key;
modules.activeSubKey.value = "";
if (selectedBigModule.key !== SCORE_BIG_KEY) {
await modules.loadSubTabsForBigModule(selectedBigModule.key, true, true);
}
}
async function onSelectSubTab(subTabKey: number | string) {
if (subTabKey === modules.activeSubKey.value) return;
await persistCurrentSubTabSilently();
const bigKey = modules.activeBigKey.value;
if (bigKey !== SCORE_BIG_KEY) {
await modules.loadSubTabsForBigModule(bigKey, false, true);
}
modules.activeSubKey.value = subTabKey;
}
async function onNext() {
if (submitting.value) return;
try {
submitting.value = true;
const res = (await customizeFormRef.value?.validate?.()) as CustomizeFormValidateResult | undefined;
if (!res?.success) {
showToast(res?.message ?? "校验失败");
return;
}
const savedOk = await saveCurrentLeafInspectionRecord(true);
if (!savedOk) {
showToast("未获取到表单数据");
return;
}
if (modules.activeBigKey.value !== SCORE_BIG_KEY) {
await modules.loadSubTabsForBigModule(modules.activeBigKey.value, false, true);
}
await modules.advanceInspectionStep();
} catch (error) {
if (!isRequestFailureAlreadyHandled(error)) {
showToast("保存失败,请重试");
}
} finally {
submitting.value = false;
}
}
function onBack() {
router.back();
}
async function onPrev() {
if (submitting.value) return;
try {
submitting.value = true;
if (modules.activeBigKey.value === SCORE_BIG_KEY) {
const mains = modules.mainInspectionBigModules.value;
const lastMain = mains[mains.length - 1];
if (lastMain) {
modules.activeBigKey.value = lastMain.key;
await modules.loadSubTabsForBigModule(lastMain.key, true, true);
modules.activeSubKey.value = lastMain.subTabs[lastMain.subTabs.length - 1]?.key ?? "";
}
return;
}
await saveCurrentLeafInspectionRecord(false);
const subTabsOfActive = modules.activeBigModule.value?.subTabs ?? [];
const activeSubIndex = subTabsOfActive.findIndex(
(subTab) => subTab.key === modules.activeSubKey.value
);
if (activeSubIndex > 0) {
const prevSub = subTabsOfActive[activeSubIndex - 1];
const prevSubKey = prevSub?.key ?? "";
await modules.loadSubTabsForBigModule(modules.activeBigKey.value, false, true);
modules.activeSubKey.value = prevSubKey;
} else {
const mains = modules.mainInspectionBigModules.value;
const activeMainIndex = mains.findIndex((m) => m.key === modules.activeBigKey.value);
if (activeMainIndex > 0) {
const previousMain = mains[activeMainIndex - 1];
if (!previousMain) {
return;
}
modules.activeBigKey.value = previousMain.key;
await modules.loadSubTabsForBigModule(previousMain.key, true, true);
modules.activeSubKey.value =
previousMain.subTabs[previousMain.subTabs.length - 1]?.key ?? "";
}
}
} catch (error) {
if (!isRequestFailureAlreadyHandled(error)) {
showToast("保存失败,请重试");
}
} finally {
submitting.value = false;
}
}
async function onSubmitScore() {
if (!inspectionScoreFormRef.value?.validate()) return;
if (submitting.value) return;
try {
submitting.value = true;
const result = await completeInspection(
inspectionScoreFormRef.value.getCompleteInspectionPayload(modules.taskId.value)
);
if (result && hasCompleteInspectionUncompletedHint(result)) {
const name = result.firstUncompletedNodeName;
const nid = result.firstUncompletedNodeId;
showToast(
name ? `检测未完成,请先完成「${name}」` : "检测未完成,请先完成未填项"
);
const switched =
nid !== undefined && nid !== null && (await modules.switchToUncompletedInspectionNode(nid));
if (!switched) {
showToast("未找到对应检测模块,请手动切换大项");
}
return;
}
showToast("评分已提交");
} catch (error) {
if (!isRequestFailureAlreadyHandled(error)) {
showToast("提交失败,请重试");
}
} finally {
submitting.value = false;
}
}
return {
submitting,
onSelectBigModule,
onSelectSubTab,
onNext,
onPrev,
onSubmitScore,
onBack,
};
}
<script setup lang="ts"> <script setup lang="ts">
import { onActivated, ref, watch } from "vue"; import type { ReportItem } from "@/types/views/car-list";
import { computed, onActivated, ref, watch } from "vue";
import { useRouter } from "vue-router";
import { getInspectReportPage } from "@/api/modules/inspect-report.ts"; import { getInspectReportPage } from "@/api/modules/inspect-report";
import PageTop from "@/components/PageTop.vue"; import PageTop from "@/components/PageTop.vue";
import type { ReportItem } from "@/types/views/car-list";
import { showToast } from "vant"; const router = useRouter();
const keyword = ref(""); const keyword = ref("");
const refreshing = ref(false); const refreshing = ref(false);
...@@ -15,6 +18,14 @@ const currentPage = ref(1); ...@@ -15,6 +18,14 @@ const currentPage = ref(1);
const displayList = ref<ReportItem[]>([]); const displayList = ref<ReportItem[]>([]);
const scroller = ref<Element | undefined>(undefined); const scroller = ref<Element | undefined>(undefined);
const listEmpty = computed(
() =>
!refreshing.value &&
!loading.value &&
displayList.value.length === 0 &&
finished.value,
);
function resetList() { function resetList() {
currentPage.value = 1; currentPage.value = 1;
finished.value = false; finished.value = false;
...@@ -89,7 +100,7 @@ async function onRefresh() { ...@@ -89,7 +100,7 @@ async function onRefresh() {
} }
function onViewReport(item: ReportItem) { function onViewReport(item: ReportItem) {
showToast(`查看报告:${item.reportNo}`); void router.push({ name: "CarDetail", params: { id: String(item.id) } });
} }
watch([keyword], () => { watch([keyword], () => {
...@@ -116,9 +127,14 @@ void onRefresh(); ...@@ -116,9 +127,14 @@ void onRefresh();
<div ref="scroller" class="list-wrap"> <div ref="scroller" class="list-wrap">
<van-pull-refresh v-model="refreshing" @refresh="onRefresh"> <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
<van-list v-model:loading="loading" <div v-if="listEmpty"
class="list-empty">
<van-empty description="暂无数据" />
</div>
<van-list v-else
v-model:loading="loading"
:finished="finished" :finished="finished"
finished-text="没有更多了" finished-text="到底了"
:scroller="scroller" :scroller="scroller"
@load="onLoad"> @load="onLoad">
<div v-for="item in displayList" <div v-for="item in displayList"
...@@ -187,16 +203,33 @@ void onRefresh(); ...@@ -187,16 +203,33 @@ void onRefresh();
.search-wrap { .search-wrap {
padding: 0 12px; padding: 0 12px;
:deep(.van-search) {
padding: 0;
background: transparent;
}
:deep(.van-search__content) {
background: #fff;
}
} }
.list-wrap { .list-wrap {
flex: 1; flex: 1;
padding: 12px 12px calc(12px + env(safe-area-inset-bottom)) 12px; padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
overflow: auto; overflow: auto;
overscroll-behavior: contain; overscroll-behavior: contain;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
} }
.list-empty {
display: flex;
align-items: center;
justify-content: center;
min-height: 220px;
padding: 32px 0;
}
.report-card { .report-card {
padding: 12px; padding: 12px;
margin-bottom: 12px; margin-bottom: 12px;
......
...@@ -28,11 +28,20 @@ const tabCounts = ref({ ...@@ -28,11 +28,20 @@ const tabCounts = ref({
}); });
const statusTabs = computed(() => [ const statusTabs = computed(() => [
{ status: 1 as const, label: "待检测", count: tabCounts.value.dispatchedCount }, { status: 1 as const, label: "待检测 ·", count: tabCounts.value.dispatchedCount },
{ status: 2 as const, label: "检测中", count: tabCounts.value.inProgressCount }, { status: 2 as const, label: "检测中 ·", count: tabCounts.value.inProgressCount },
{ status: 3 as const, label: "检测完成", count: tabCounts.value.completedCount }, { status: 3 as const, label: "检测完成 ·", count: tabCounts.value.completedCount },
]); ]);
/** 首屏/刷新结束后仍无数据 */
const listEmpty = computed(
() =>
!refreshing.value &&
!loading.value &&
displayList.value.length === 0 &&
finished.value,
);
// tag 样式与映射由 WorkOrderStatusTags 统一处理 // tag 样式与映射由 WorkOrderStatusTags 统一处理
function resetList() { function resetList() {
...@@ -106,9 +115,15 @@ async function fillMore() { ...@@ -106,9 +115,15 @@ async function fillMore() {
finished.value = !!res.last || next.length === 0; finished.value = !!res.last || next.length === 0;
} }
/**
* van-list 在 emit load 前会先 `update:loading` 为 true,若此处再判断 `loading` 会直接 return,
* 且不会走 finally,导致 loading 一直为 true,`listEmpty` 永远为 false,空列表不显示「暂无数据」。
*/
async function onLoad() { async function onLoad() {
if (loading.value || finished.value) return; if (refreshing.value || finished.value) {
loading.value = true; loading.value = false;
return;
}
try { try {
await fillMore(); await fillMore();
} finally { } finally {
...@@ -128,6 +143,7 @@ async function onRefresh() { ...@@ -128,6 +143,7 @@ async function onRefresh() {
function onStatusChange(status: WorkOrderStatus) { function onStatusChange(status: WorkOrderStatus) {
activeStatus.value = status; activeStatus.value = status;
keyword.value = "";
} }
function startCheck(item: WorkOrderItem) { function startCheck(item: WorkOrderItem) {
...@@ -148,8 +164,11 @@ function viewWorkOrder(item: WorkOrderItem) :void{ ...@@ -148,8 +164,11 @@ function viewWorkOrder(item: WorkOrderItem) :void{
router.push({ name: "WorkOrderDetail", params: { id: item.id } }); router.push({ name: "WorkOrderDetail", params: { id: item.id } });
} }
function viewReport(_item: WorkOrderItem) { function viewReport(item: WorkOrderItem) {
void router.push({ name: "CarList" }); void router.push({
name: "InspectReport",
query: { recordId: item.id },
});
} }
function showRejectReason(_item: WorkOrderItem) { function showRejectReason(_item: WorkOrderItem) {
...@@ -257,9 +276,14 @@ void onRefresh(); ...@@ -257,9 +276,14 @@ void onRefresh();
<!-- 列表(独立滚动区域) --> <!-- 列表(独立滚动区域) -->
<div ref="scroller" class="list-wrap"> <div ref="scroller" class="list-wrap">
<van-pull-refresh v-model="refreshing" @refresh="onRefresh"> <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
<van-list v-model:loading="loading" <div v-if="listEmpty"
class="list-empty">
<van-empty description="暂无数据" />
</div>
<van-list v-else
v-model:loading="loading"
:finished="finished" :finished="finished"
finished-text="没有更多了" finished-text="到底了"
:scroller="scroller" :scroller="scroller"
@load="onLoad"> @load="onLoad">
<div v-for="item in displayList" <div v-for="item in displayList"
...@@ -303,7 +327,7 @@ void onRefresh(); ...@@ -303,7 +327,7 @@ void onRefresh();
<div class="card-footer"> <div class="card-footer">
<div class="card-bottom"> <div class="card-bottom">
派单于 {{ item.dispatchTime }} <span class="k">派单于</span> <span class="v">{{ item.dispatchTime }}</span>
</div> </div>
<div class="card-actions" <div class="card-actions"
@click.stop="stopCardFooterBubbling"> @click.stop="stopCardFooterBubbling">
...@@ -405,6 +429,14 @@ void onRefresh(); ...@@ -405,6 +429,14 @@ void onRefresh();
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
} }
.list-empty {
display: flex;
align-items: center;
justify-content: center;
min-height: 220px;
padding: 32px 0;
}
.order-card { .order-card {
padding: 12px; padding: 12px;
margin-bottom: 12px; margin-bottom: 12px;
...@@ -476,8 +508,16 @@ void onRefresh(); ...@@ -476,8 +508,16 @@ void onRefresh();
.card-bottom { .card-bottom {
min-width: 0; min-width: 0;
font-size: $font-size-xs; font-size: 12px;
color: $color-text-disabled;
.k {
margin-right: 6px;
color: #999ea8;
}
.v {
color: #666;
}
} }
.card-actions { .card-actions {
...@@ -499,7 +539,7 @@ void onRefresh(); ...@@ -499,7 +539,7 @@ void onRefresh();
:deep(.wo-btn) { :deep(.wo-btn) {
height: auto; height: auto;
padding: 6px 12px; padding: 10px 12px;
font-size: 13px; font-size: 13px;
font-weight: 400; font-weight: 400;
line-height: 1; line-height: 1;
......
...@@ -32,18 +32,20 @@ const { ...@@ -32,18 +32,20 @@ const {
<van-field v-model="phone" <van-field v-model="phone"
class="rounded-full login-input" class="rounded-full login-input"
clearable clearable
inputmode="numeric"
label="手机号" label="手机号"
maxlength="11" maxlength="11"
placeholder="请输入手机号" placeholder="请输入手机号"
type="tel" /> type="digit" />
<van-field v-model="code" <van-field v-model="code"
class="rounded-full login-input" class="rounded-full login-input"
clearable clearable
inputmode="numeric"
label="验证码" label="验证码"
maxlength="6" maxlength="6"
placeholder="请输入验证码" placeholder="请输入验证码"
type="tel"> type="digit">
<template #button> <template #button>
<van-button class="login-send-code-btn p-0 text-[13px] leading-[1.25]" <van-button class="login-send-code-btn p-0 text-[13px] leading-[1.25]"
:class="countdown > 0 ? '!text-[#CCCCCC]' : '!text-[#185EFE]'" :class="countdown > 0 ? '!text-[#CCCCCC]' : '!text-[#185EFE]'"
...@@ -121,13 +123,13 @@ const { ...@@ -121,13 +123,13 @@ const {
min-height: 0 !important; min-height: 0 !important;
padding: 0 !important; padding: 0 !important;
line-height: 1.25 !important; line-height: 1.25 !important;
border: none !important;
background: transparent !important; background: transparent !important;
border: none !important;
} }
&:deep(.login-send-code-btn.van-button--disabled) { &:deep(.login-send-code-btn.van-button--disabled) {
opacity: 1;
background: transparent !important; background: transparent !important;
opacity: 1;
} }
} }
</style> </style>
......
...@@ -28,18 +28,20 @@ const { ...@@ -28,18 +28,20 @@ const {
<van-field v-model="phone" <van-field v-model="phone"
class="rounded-full login-input" class="rounded-full login-input"
clearable clearable
inputmode="numeric"
label="手机号" label="手机号"
maxlength="11" maxlength="11"
placeholder="请输入手机号" placeholder="请输入手机号"
type="tel" /> type="digit" />
<van-field v-model="code" <van-field v-model="code"
class="rounded-full login-input" class="rounded-full login-input"
clearable clearable
inputmode="numeric"
label="验证码" label="验证码"
maxlength="6" maxlength="6"
placeholder="请输入验证码" placeholder="请输入验证码"
type="tel"> type="digit">
<template #button> <template #button>
<van-button class="p-0 text-[13px]" <van-button class="p-0 text-[13px]"
:class="countdown > 0 ? '!text-[#CCCCCC]' : '!text-[#185EFE]'" :class="countdown > 0 ? '!text-[#CCCCCC]' : '!text-[#185EFE]'"
......
import { ref } from "vue"; import { ref, watch } from "vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { showFailToast, showSuccessToast } from "vant";
import { login, sendSmsCode } from "@/api/modules/user.ts"; import { login, sendSmsCode } from "@/api/modules/user.ts";
import { LOGIN_REDIRECT_KEY } from "@/config/constants";
import { useUserStore } from "@/stores/modules/user.ts"; import { useUserStore } from "@/stores/modules/user.ts";
import { notifyHostToken } from "@/utils/webviewBridge"; import { notifyHostToken } from "@/utils/webviewBridge";
import { showFailToast, showSuccessToast } from "vant";
const LOGIN_REDIRECT_KEY = "venus_usedcar_login_redirect";
export function useLogin() { export function useLogin() {
const router = useRouter(); const router = useRouter();
...@@ -17,10 +15,20 @@ export function useLogin() { ...@@ -17,10 +15,20 @@ export function useLogin() {
const code = ref(""); const code = ref("");
const agreed = ref(false); const agreed = ref(false);
/** 仅数字 + 长度上限;配合 Field type=digit,并兜底粘贴等非数字字符 */
watch(phone, (v) => {
const n = v.replaceAll(/\D/g, "").slice(0, 11);
if (n !== v) phone.value = n;
});
watch(code, (v) => {
const n = v.replaceAll(/\D/g, "").slice(0, 6);
if (n !== v) code.value = n;
});
const sending = ref(false); const sending = ref(false);
const countdown = ref(0); const countdown = ref(0);
const hasSent = ref(false); const hasSent = ref(false);
let timer: number | null = null; let timer: null | number = null;
const validPhone = (value: string) => /^1\d{10}$/.test(value); const validPhone = (value: string) => /^1\d{10}$/.test(value);
...@@ -41,7 +49,9 @@ export function useLogin() { ...@@ -41,7 +49,9 @@ export function useLogin() {
timer && window.clearInterval(timer); timer && window.clearInterval(timer);
timer = window.setInterval(() => { timer = window.setInterval(() => {
if (countdown.value <= 1) { if (countdown.value <= 1) {
window.clearInterval(timer!); if (timer !== null) {
window.clearInterval(timer);
}
timer = null; timer = null;
countdown.value = 0; countdown.value = 0;
} else { } else {
......
<script setup lang="ts"> <script setup lang="ts">
import type { InspectDetailAccount } from "@/api/modules/user";
import { computed, onActivated, onMounted, ref, watch } from "vue"; import { computed, onActivated, onMounted, ref, watch } from "vue";
import type { InspectDetailAccount } from "@/api/modules/user";
import { getInspectDetail } from "@/api/modules/user"; import { getInspectDetail } from "@/api/modules/user";
import LogoutConfirmModal from "@/components/LogoutConfirmModal.vue";
import PageTop from "@/components/PageTop.vue"; import PageTop from "@/components/PageTop.vue";
import { useUserStore } from "@/stores"; import { useUserStore } from "@/stores";
import avatarDefault from "@assets/image/avatar.png";
import { showToast } from "vant"; import { showToast } from "vant";
const userStore = useUserStore(); const userStore = useUserStore();
const showLogoutConfirm = ref(false);
const avgInspectCost = ref<number>(0); const avgInspectCost = ref<number>(0);
const inspectAccount = ref<InspectDetailAccount | null>(null); const inspectAccount = ref<InspectDetailAccount | null>(null);
const avgInspectCostText = computed(() => `${avgInspectCost.value || 0}秒`); /** 接口 `avgInspectCost` 为秒,展示为「X小时Y分」;不足 1 分钟且大于 0 时显示「不足1分」 */
function formatAvgInspectCostSeconds(totalSeconds: number): string {
const s = Math.max(0, Math.floor(Number(totalSeconds) || 0));
const h = Math.floor(s / 3600);
const m = Math.floor((s % 3600) / 60);
if (h > 0 && m > 0) return `${h}小时${m}分`;
if (h > 0) return `${h}小时`;
if (m > 0) return `${m}分`;
if (s > 0) return "不足1分";
return "0分";
}
const avgInspectCostText = computed(() => formatAvgInspectCostSeconds(avgInspectCost.value));
const displayName = computed(() => const displayName = computed(() =>
userStore.isLoggedIn ? inspectAccount.value?.name || userStore.username : "" userStore.isLoggedIn ? inspectAccount.value?.name || userStore.username : ""
...@@ -24,8 +40,8 @@ const displayPhone = computed(() => ...@@ -24,8 +40,8 @@ const displayPhone = computed(() =>
const displayAvatar = computed(() => const displayAvatar = computed(() =>
userStore.isLoggedIn userStore.isLoggedIn
? inspectAccount.value?.avatar || userStore.userInfo?.avatar || "" ? inspectAccount.value?.avatar || userStore.userInfo?.avatar || avatarDefault
: "" : avatarDefault
); );
async function fetchInspectDetail() { async function fetchInspectDetail() {
...@@ -50,8 +66,14 @@ function onLogin() { ...@@ -50,8 +66,14 @@ function onLogin() {
showToast("登录功能开发中"); showToast("登录功能开发中");
} }
async function onLogout() { function onLogoutTap() {
userStore.logout(); if (!userStore.isLoggedIn) return;
showLogoutConfirm.value = true;
}
async function onLogoutConfirm() {
showLogoutConfirm.value = false;
await userStore.logout();
avgInspectCost.value = 0; avgInspectCost.value = 0;
inspectAccount.value = null; inspectAccount.value = null;
showToast("已退出登录"); showToast("已退出登录");
...@@ -72,7 +94,7 @@ watch( ...@@ -72,7 +94,7 @@ watch(
<template> <template>
<div class="mine-page"> <div class="mine-page">
<PageTop title="我的"> <PageTop title="我的">
<div class="mine-header"> <div class="mine-header !pb-[24px]">
<div class="user-row"> <div class="user-row">
<van-image class="avatar" <van-image class="avatar"
fit="cover" fit="cover"
...@@ -119,32 +141,28 @@ watch( ...@@ -119,32 +141,28 @@ watch(
<div class="logout-wrap"> <div class="logout-wrap">
<van-button block <van-button block
class="logout-btn" class="logout-btn"
round @click="onLogoutTap">
@click="onLogout">
退出登录 退出登录
</van-button> </van-button>
</div> </div>
<!-- 版本号 -->
<div class="app-version">
当前版本 v{{ __APP_VERSION__ ?? '1.0.0' }}
</div>
</div> </div>
<LogoutConfirmModal :show="showLogoutConfirm"
@confirm="onLogoutConfirm"
@update:show="showLogoutConfirm = $event" />
</div> </div>
</template> </template>
<script lang="ts">
const __APP_VERSION__ = "1.0.0";
</script>
<style lang="scss" scoped> <style lang="scss" scoped>
@use "@assets/styles/variables" as *; @use "@assets/styles/variables" as *;
.mine-page { .mine-page {
height: calc(100vh - var(--tabbar-height) - env(safe-area-inset-bottom));
overflow: hidden;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: calc(100vh - var(--tabbar-height) - env(safe-area-inset-bottom));
overflow: hidden;
background: #f2f6fb; background: #f2f6fb;
:deep(.page-top) { :deep(.page-top) {
...@@ -153,12 +171,13 @@ const __APP_VERSION__ = "1.0.0"; ...@@ -153,12 +171,13 @@ const __APP_VERSION__ = "1.0.0";
} }
.mine-content { .mine-content {
display: flex;
flex: 1; flex: 1;
flex-direction: column;
overflow: auto; overflow: auto;
overscroll-behavior: contain; overscroll-behavior: contain;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
display: flex;
flex-direction: column;
} }
.mine-header { .mine-header {
...@@ -175,8 +194,6 @@ const __APP_VERSION__ = "1.0.0"; ...@@ -175,8 +194,6 @@ const __APP_VERSION__ = "1.0.0";
flex-shrink: 0; flex-shrink: 0;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
background-color: rgb(25 137 250 / 15%);
border: 2px solid rgb(25 137 250 / 25%);
border-radius: 50%; border-radius: 50%;
} }
...@@ -199,8 +216,10 @@ const __APP_VERSION__ = "1.0.0"; ...@@ -199,8 +216,10 @@ const __APP_VERSION__ = "1.0.0";
.avg-card { .avg-card {
padding: 16px; padding: 16px;
margin: 6px 12px 0; margin: 0 12px;
border-radius: 10px; background: linear-gradient(180deg, #1874fe1a 0%, #1883fe00 50%);
border: 1px solid #fff;
border-radius: 12px;
.avg-label { .avg-label {
margin-bottom: 8px; margin-bottom: 8px;
...@@ -217,16 +236,23 @@ const __APP_VERSION__ = "1.0.0"; ...@@ -217,16 +236,23 @@ const __APP_VERSION__ = "1.0.0";
} }
.logout-wrap { .logout-wrap {
padding: 0 12px; padding: 0 12px 40px;
margin-top: auto; margin-top: auto;
} }
.logout-btn { .logout-btn {
height: 44px; height: 44px;
color: $color-text-primary; font-size: 16px;
font-weight: 400;
color: #222;
background: #fff; background: #fff;
border: 0; border-radius: 8px;
box-shadow: 0 1px 0 rgb(0 0 0 / 4%); box-shadow: none;
opacity: 1;
&:active::before {
opacity: 0;
}
} }
.app-version { .app-version {
......
<script setup lang="ts">
import { ref } from "vue";
import PageTop from "@/components/PageTop.vue";
import { OSS_CONFIG } from "@/config/oss";
import { uploadFile } from "@/utils/upload.js";
import { showToast } from "vant";
const fileInputRef = ref<HTMLInputElement | null>(null);
const uploading = ref(false);
const lastResult = ref<Record<string, unknown> | null>(null);
const lastError = ref<string>("");
function pickFile() {
lastError.value = "";
lastResult.value = null;
fileInputRef.value?.click();
}
async function onFileChange(ev: Event) {
const input = ev.target as HTMLInputElement;
const file = input.files?.[0];
input.value = "";
if (!file) return;
uploading.value = true;
lastError.value = "";
lastResult.value = null;
try {
const res = (await uploadFile(file)) as Record<string, unknown>;
lastResult.value = res;
const url =
(typeof res.aliyunAddress === "string" && res.aliyunAddress) ||
(typeof res.url === "string" && res.url) ||
"";
showToast(url ? "上传成功" : "上传完成(无 URL 字段)");
} catch (e: unknown) {
const msg = e instanceof Error ? e.message : String(e);
lastError.value = msg;
showToast(`上传失败:${msg}`);
} finally {
uploading.value = false;
}
}
</script>
<template>
<div class="upload-demo">
<PageTop title="OSS 上传 Demo" />
<div class="card">
<p class="hint">
使用 <code>utils/upload.js</code> 的 <code>uploadFile</code>,桶 <code>{{ OSS_CONFIG.BUCKET_NAME }}</code>,目录
<code>{{ OSS_CONFIG.FOLDER }}</code>
</p>
<input ref="fileInputRef"
accept="image/*"
class="hidden-input"
type="file"
@change="onFileChange">
<van-button :loading="uploading"
block
type="primary"
@click="pickFile">
{{ uploading ? "上传中…" : "选择图片并上传" }}
</van-button>
<div v-if="lastError" class="block error">
<div class="label">错误</div>
<pre>{{ lastError }}</pre>
</div>
<div v-if="lastResult" class="block ok">
<div class="label">返回(JSON)</div>
<pre>{{ JSON.stringify(lastResult, null, 2) }}</pre>
</div>
</div>
</div>
</template>
<style scoped lang="scss">
.upload-demo {
min-height: 100vh;
background: #f5f6f7;
}
.card {
margin: 12px;
padding: 16px;
background: #fff;
border-radius: 8px;
}
.hint {
margin: 0 0 16px;
font-size: 12px;
color: #646566;
line-height: 1.5;
code {
padding: 0 4px;
font-size: 11px;
background: #f2f3f5;
border-radius: 2px;
}
}
.hidden-input {
position: absolute;
width: 0;
height: 0;
opacity: 0;
pointer-events: none;
}
.block {
margin-top: 16px;
padding: 12px;
border-radius: 6px;
font-size: 12px;
.label {
margin-bottom: 8px;
font-weight: 600;
color: #323233;
}
pre {
margin: 0;
white-space: pre-wrap;
word-break: break-all;
font-size: 11px;
line-height: 1.4;
}
}
.block.error {
background: #fff1f0;
color: #cf1322;
}
.block.ok {
background: #f6ffed;
color: #389e0d;
}
</style>
<script setup lang="ts"> <script setup lang="ts">
import type { WorkOrderStatus } from "@/types/views/work-order-common";
import type { import type {
InspectionWORespVO, InspectionWORespVO,
NodeVO, NodeVO,
...@@ -6,8 +7,7 @@ import type { ...@@ -6,8 +7,7 @@ import type {
WorkOrderBaseInfo, WorkOrderBaseInfo,
WorkOrderDetailRemote, WorkOrderDetailRemote,
WorkOrderVehicle, WorkOrderVehicle,
} from "@/types/views/word-order-detail"; } from "@/types/views/work-order-detail";
import type { WorkOrderStatus } from "@/types/views/work-order-common";
import { computed, onMounted, ref } from "vue"; import { computed, onMounted, ref } from "vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
...@@ -63,8 +63,14 @@ function fmtTime(v?: string) { ...@@ -63,8 +63,14 @@ function fmtTime(v?: string) {
} }
function continueCheck():void { function continueCheck():void {
const id = route.params.id as string; const id = route.params.id as string;
router.push({ name: "CarDetail", params: { taskId: id } }); router.push({ name: "CarDetail", params: { id } });
} }
/** 检测项目项点击:当前与「编辑工单」一致进入车辆检测页 */
function onNodeClick(_n: NodeVO) {
continueCheck();
}
const onBack=()=>{ const onBack=()=>{
router.back(); router.back();
}; };
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
"@composables/*": ["src/composables/*"] "@composables/*": ["src/composables/*"]
}, },
"resolveJsonModule": true, "resolveJsonModule": true,
"types": ["vite/client"],
"allowImportingTsExtensions": true, "allowImportingTsExtensions": true,
"allowJs": true, "allowJs": true,
"strict": true, "strict": true,
...@@ -28,8 +29,7 @@ ...@@ -28,8 +29,7 @@
"noUnusedParameters": true, "noUnusedParameters": true,
"noEmit": true, "noEmit": true,
"isolatedModules": true, "isolatedModules": true,
"skipLibCheck": true, "skipLibCheck": true
"types": ["vite/client"]
}, },
"references": [{ "path": "./tsconfig.node.json"}], "references": [{ "path": "./tsconfig.node.json"}],
"include": [ "include": [
......
import { dirname, resolve } from "node:path"; import { dirname, resolve } from "node:path";
import process from "node:process";
import { fileURLToPath } from "node:url"; import { fileURLToPath } from "node:url";
import vue from "@vitejs/plugin-vue"; import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite"; import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { VantResolver } from "unplugin-vue-components/resolvers"; import { VantResolver } from "unplugin-vue-components/resolvers";
import Components from "unplugin-vue-components/vite";
import { defineConfig, loadEnv } from "vite"; import { defineConfig, loadEnv } from "vite";
// @ts-expect-error - no types provided
import pxToViewport from "postcss-px-to-viewport-8-plugin";
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename); const __dirname = dirname(__filename);
...@@ -75,7 +73,7 @@ export default defineConfig(({ mode }) => { ...@@ -75,7 +73,7 @@ export default defineConfig(({ mode }) => {
chunkFileNames: "assets/js/[name]-[hash].js", chunkFileNames: "assets/js/[name]-[hash].js",
entryFileNames: "assets/js/[name]-[hash].js", entryFileNames: "assets/js/[name]-[hash].js",
assetFileNames: ({ name = "" }) => { assetFileNames: ({ name = "" }) => {
if (/\.(png|jpe?g|gif|svg|webp|ico)$/.test(name)) { if (/\.(?:png|jpe?g|gif|svg|webp|ico)$/.test(name)) {
return "assets/images/[name]-[hash].[ext]"; return "assets/images/[name]-[hash].[ext]";
} }
if (/\.css$/.test(name)) { if (/\.css$/.test(name)) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!