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 1799 additions and 768 deletions
......@@ -7,15 +7,16 @@
- **框架**: Vue 3、Vue Router、Pinia
- **UI**: Vant 4(按需引入)
- **工具**: 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`
- **路径别名**: `@`、`@assets`、`@views`、`@components`、`@stores`、`@utils`、`@api`、`@composables`
- **自动导入**: vue / vue-router / pinia / @vueuse/core;Vant 组件与 `src/components`、`src/layouts` 自动注册
- **配置中心**: 远程拉取配置(`venus-usedcar-config`),本地缓存,动态设置 API baseURL;集成 glsk-toolkit Request,请求拦截器统一注入 `Authorization`,401/403/500 统一 Toast 提示
- **请求封装**: `src/utils/request.ts` 基于配置中心 Request 实例,提供 `get`/`post`,统一解析 `code === 200 | 0` 的 `data`,类型 `ApiResponse<T>`、`PageData<T>`
- **配置中心**: 远程拉取配置(`venus-usedcar-config`),本地缓存,动态设置 API baseURL;集成 glsk-toolkit Request 实例(与业务请求层并行时可统一收敛)
- **请求封装**: `src/utils/request.ts` 基于 axios,提供 `get`/`post`,统一解析业务 `code === 200` 的 `data`,类型 `ApiResponse<T>`、`PageData<T>`
- **开发代理**: `/api` 代理到 `VITE_API_BASE_URL`,端口 8082
## 已完成的功能
......
......@@ -11,11 +11,11 @@
"type-check": "vue-tsc --noEmit"
},
"dependencies": {
"axios": "^1.12.2",
"@vueuse/core": "catalog:",
"axios": "^1.12.2",
"dayjs": "catalog:",
"glsk-toolkit": "catalog:",
"glsk-oss-jssdk": "catalog:",
"glsk-toolkit": "catalog:",
"pinia": "catalog:",
"pinia-plugin-persistedstate": "catalog:",
"tailwindcss": "catalog:",
......
......@@ -54,9 +54,9 @@ export function getRecommendedCars(limit = 10) {
}
export function collectCar(carId: number) {
return post<void>(`/api/cars/${carId}/collect`);
return post(`/api/cars/${carId}/collect`);
}
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";
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 {
id?: number;
......@@ -145,7 +43,7 @@ export interface InspectionNode {
options?: string;
validationRules?: string;
allowNoStructure?: number;
existsDefaultValue?: string | number;
existsDefaultValue?: number | string;
defaultValue?: string;
defaultType?: number;
nodeLevel: number;
......@@ -165,18 +63,11 @@ export interface InspectionNode {
[key: string]: unknown;
}
export interface InspectionNodeResponse {
code: string;
data: InspectionNode[];
success: boolean;
message: string;
}
/**
* 获取检测模板根节点(大项)
* @param taskId 检测工单ID
*/
export function getInspectionRootNodes(taskId: string | number) {
export function getInspectionRootNodes(taskId: number | string) {
return get<InspectionNode[]>(`/rest/inspectionTemplate/${taskId}/rootNodes`);
}
......@@ -184,14 +75,14 @@ export function getInspectionRootNodes(taskId: string | number) {
* 检测评分回显(与 `completeInspection` 字段对应,接口可能省略部分字段)
*/
export interface InspectionScoreVO {
exteriorScore?: number | string | null;
exteriorComment?: string | null;
skeletonLevel?: string | null;
skeletonComment?: string | null;
interiorLevel?: string | null;
interiorComment?: string | null;
overallScore?: number | string | null;
overallComment?: string | null;
exteriorScore?: null | number | string;
exteriorComment?: null | string;
skeletonLevel?: null | string;
skeletonComment?: null | string;
interiorLevel?: null | string;
interiorComment?: null | string;
overallScore?: null | number | string;
overallComment?: null | string;
[key: string]: unknown;
}
......@@ -203,8 +94,8 @@ export interface InspectionScoreVO {
export type InspectionChildrenData =
| InspectionNode[]
| {
inspectionScoreVO?: InspectionScoreVO | null;
[key: string]: unknown;
inspectionScoreVO?: InspectionScoreVO | null;
};
/**
......@@ -212,7 +103,7 @@ export type InspectionChildrenData =
* @param rootNodeId 根节点ID;传 `-1` 时可拉取检测评分回显(`inspectionScoreVO`)
* @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`, {
taskId,
});
......@@ -246,7 +137,7 @@ export interface InspectionTemplateDefaultData {
* 获取检测模板默认值(业务层已解包为 data 对象)
* @param taskId 检测工单ID
*/
export function getInspectionTemplateDefault(taskId: string | number) {
export function getInspectionTemplateDefault(taskId: number | string) {
return post<InspectionTemplateDefaultData>(`/rest/inspectionTemplate/default`, {
taskId,
});
......@@ -258,8 +149,8 @@ function hasDefaultValueFlag(node: InspectionNode): boolean {
}
const KEYED_SELECT_INTERACTION_TYPES = new Set([
"dropdown",
"button_select",
"dropdown",
"radio_button_select",
]);
......@@ -366,7 +257,7 @@ export function applyResolvedInitialValuesToLeafNodes(
): InspectionNode[] {
if (!leafNodes?.length) return [];
return leafNodes.map((node) => {
if (node.inspectionResultVO != null) {
if (node.inspectionResultVO !== null && node.inspectionResultVO !== undefined) {
return { ...node };
}
const valueTexts = resolveInspectionNodeInitialValueTexts(node, templateDefaultData);
......@@ -384,7 +275,10 @@ export function applyResolvedInitialValuesToLeafNodes(
if (!isKeyedSelectInteractionType(node.interactionType) || list.length === 0) {
return merged;
}
const first = list[0]!;
const first = list[0];
if (first === undefined) {
return merged;
}
const it = node.interactionType ?? "";
const valueKey = first.valueKey ?? "";
const valueText = first.valueText ?? "";
......@@ -412,82 +306,3 @@ export function applyResolvedInitialValuesToLeafNodes(
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) {
}
export function logout() {
return post<void>("/api/user/logout");
return post("/rest/auth/logout", {});
}
export function getUserInfo() {
......
......@@ -28,10 +28,10 @@ body {
// rem 根字号上限与 utils/flexible.ts 中 LAYOUT_MAX_WIDTH 保持一致
// #app 已加入 postcss-pxtorem selectorBlackList,px 不会被转 rem
#app {
position: relative;
max-width: 430px;
min-height: 100vh;
margin: 0 auto;
position: relative;
background-color: #f7f8fa;
}
......
......@@ -11,6 +11,7 @@ declare module 'vue' {
CustomizeUploadFile: typeof import('./components/CustomizeForm/customizeUploadFile.vue')['default']
Index: typeof import('./components/CustomizeForm/Index.vue')['default']
Layouts: typeof import('./layouts/index.vue')['default']
LogoutConfirmModal: typeof import('./components/LogoutConfirmModal.vue')['default']
PageTitle: typeof import('./components/PageTitle.vue')['default']
PageTop: typeof import('./components/PageTop.vue')['default']
RadioSelect: typeof import('./components/CustomizeForm/radioSelect.vue')['default']
......@@ -27,8 +28,10 @@ declare module 'vue' {
VanForm: typeof import('vant/es')['Form']
VanIcon: typeof import('vant/es')['Icon']
VanImage: typeof import('vant/es')['Image']
VanImagePreview: typeof import('vant/es')['ImagePreview']
VanList: typeof import('vant/es')['List']
VanLoading: typeof import('vant/es')['Loading']
VanOverlay: typeof import('vant/es')['Overlay']
VanPicker: typeof import('vant/es')['Picker']
VanPopup: typeof import('vant/es')['Popup']
VanProgress: typeof import('vant/es')['Progress']
......@@ -38,10 +41,13 @@ declare module 'vue' {
VanSearch: typeof import('vant/es')['Search']
VanSkeleton: typeof import('vant/es')['Skeleton']
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']
VanTabbarItem: typeof import('vant/es')['TabbarItem']
VanTabs: typeof import('vant/es')['Tabs']
VanTag: typeof import('vant/es')['Tag']
VanUploader: typeof import('vant/es')['Uploader']
WorkOrderStatusTags: typeof import('./components/WorkOrderStatusTags.vue')['default']
}
}
......@@ -10,13 +10,31 @@ const props = defineProps({
const emit = defineEmits(["update"]);
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 optionsList = JSON.parse(props.item.options || '[]').map(item => {
const valueList = (item || '').split('-');
const optionsList = JSON.parse(props.item.options || "[]").map(item => {
const valueList = (item || "").split("-");
return {
text: valueList[1] || '',
value: valueList[0] || '',
text: valueList[1] || "",
value: valueList[0] || "",
};
});
return optionsList;
......@@ -29,15 +47,22 @@ function handleBut(item: { value: string }) {
} else {
pickerValue.value.push(item.value);
}
setupdate();
}
function setupdate() {
const valueList = (pickerValue.value || []).map(item => {
const object = (columnsList.value || []).find(finditem => finditem.value == item) || {};
return {
valueText: object.text || '',
valueKey: item || '',
valueText: object.text || "",
valueKey: item || "",
};
});
props.item.value = JSON.stringify(valueList || []);
emit("update", JSON.stringify(valueList || []));
if (valueList.length > 0) {
emit("update", JSON.stringify(valueList || []));
} else {
emit("update", "");
}
}
</script>
......@@ -49,10 +74,10 @@ function handleBut(item: { value: string }) {
<span>{{ item.nodeName }}</span>
</div>
<div class="selectList">
<div v-for="(item, index) in columnsList" :key="index" @click="handleBut(item)" class="selectBut"
:class="{ 'pitchOn': pickerValue.includes(item.value) }">
{{ item.text }}
<div v-if="pickerValue.includes(item.value)" class="pitchImg"></div>
<div v-for="(col, index) in columnsList" :key="index" class="selectBut"
:class="{ 'pitchOn': pickerValue.includes(col.value) }" @click="handleBut(col)">
{{ col.text }}
<div v-if="pickerValue.includes(col.value)" class="pitchImg"></div>
</div>
</div>
</div>
......@@ -60,27 +85,27 @@ function handleBut(item: { value: string }) {
<style lang="scss" scoped>
.buttonSelect {
width: 100%;
background: #ffffff;
float: left;
width: 100%;
background: #fff;
}
.title {
float: left;
width: 100%;
height: 24px;
color: #141e34;
font-size: 14px;
line-height: 24px;
float: left;
padding-left: 16px;
margin-top: 16px;
margin-bottom: 10px;
padding-left: 16px;
font-size: 14px;
line-height: 24px;
color: #141e34;
}
.isRequired {
color: #ee3040;
font-size: 14px;
padding-right: 2px;
font-size: 14px;
color: #ee3040;
}
.selectList {
......@@ -88,29 +113,27 @@ function handleBut(item: { value: string }) {
}
.selectBut {
width: -webkit-calc(33.333% - 12px);
width: -moz-calc(33.333% - 12px);
position: relative;
float: left;
width: calc(33.333% - 12px);
height: 36px;
line-height: 36px;
border-radius: 6px;
background: #f9f9f9;
margin-right: 6px;
margin-bottom: 12px;
margin-left: 6px;
font-size: 14px;
font-weight: 400;
line-height: 36px;
color: #333;
text-align: center;
color: #333333;
float: left;
cursor: pointer;
position: relative;
margin-bottom: 12px;
margin-left: 6px;
margin-right: 6px;
background: #f9f9f9;
border: 1px solid #f9f9f9;
border-radius: 6px;
}
.pitchOn {
background: #ecf1ff !important;
color: #185EFE !important;
background: #ecf1ff !important;
border: 1px solid #185efe !important;
}
......@@ -118,9 +141,9 @@ function handleBut(item: { value: string }) {
position: absolute;
top: 0;
right: 0;
z-index: 99;
width: 16px;
height: 16px;
z-index: 99;
background-image: url("https://img02.glsx.com.cn/aus/images/preference/pitchOn.png");
background-repeat: no-repeat;
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">
import { ref } from "vue";
import { uploadFile } from "@/utils/upload.js";
const uploading = ref(false);
import { uploadFile } from "@/utils/upload.js";
import { showToast } from "vant";
const props = defineProps({
item: {
type: Object,
default: () => { },
default: () => {},
},
});
const emit = defineEmits(["update"]);
const pickerValue = ref([]);
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) { pickerValue.value.push(i.valueText); }
}
}
updateData();
}
// 计算属性
const validationRules = computed(() => {
return JSON.parse(props.item.validationRules || '{}');
return JSON.parse(props.item.validationRules || "{}");
});
async function onFileChange(ev: Event) {
......@@ -39,11 +56,11 @@ async function onFileChange(ev: Event) {
showToast("上传成功");
pickerValue.value.push(url);
console.log('pickerValue.value', pickerValue.value);
console.log("pickerValue.value", pickerValue.value);
updateData();
} catch (e: unknown) {
const msg = e instanceof Error ? e.message : String(e);
} catch (error: unknown) {
const msg = error instanceof Error ? error.message : String(error);
showToast(`上传失败:${msg}`);
} finally {
uploading.value = false;
......@@ -56,125 +73,143 @@ function handleDelete(item: string) {
}
function updateData() {
props.item.value = JSON.stringify(pickerValue.value);
emit("update", JSON.stringify(pickerValue.value));
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 v-if="item.required === 1" class="isRequired">*</span>
<span>{{ item.nodeName }}</span>
</div>
<div v-if="validationRules.maxCount && validationRules.maxCount.length > 1 && item.interactionType == 'image_upload'"
class="titleTip">
有损伤请拍摄图片,无损伤请忽略
</div>
</div>
<input ref="fileInputRef" :accept="item.interactionType == 'image_upload' ? 'image/*' : 'video/*'"
class="hidden-input" type="file" @change="onFileChange">
<div class="uploadPage">
<div v-if="(validationRules.maxCount || 3) > pickerValue.length" class="uploadBox" @click="pickFile">
<van-icon name="plus" size="24" color="#999999" class="plusBox" />
<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>
<van-image width="96" height="96" style="border-radius: 8px;" :src="item" />
</div>
</div>
</div>
<div class="buttonSelect">
<div class="title">
<div class="titleContent">
<span v-if="item.required === 1" class="isRequired">*</span>
<span>{{ item.nodeName }}</span>
</div>
<div v-if="validationRules.maxCount && validationRules.maxCount.length > 1 && item.interactionType == 'image_upload'"
class="titleTip">
有损伤请拍摄图片,无损伤请忽略
</div>
</div>
<input ref="fileInputRef"
:accept="item.interactionType == 'image_upload' ? 'image/*' : 'video/*'"
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">
{{ item.interactionType == 'image_upload' ? '添加照片' : '添加视频' }}
</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 {
width: 100%;
background: #ffffff;
float: left;
width: 100%;
background: #fff;
}
.title {
width: 100%;
float: left;
width: 100%;
padding-left: 16px;
margin-top: 16px;
margin-bottom: 10px;
padding-left: 16px;
}
.titleContent {
float: left;
width: 100%;
height: 24px;
float: left;
color: #141e34;
font-size: 14px;
line-height: 24px;
color: #141e34;
}
.titleTip {
float: left;
width: 100%;
height: 16px;
line-height: 16px;
float: left;
color: #999999;
font-size: 12px;
font-weight: 400;
line-height: 16px;
color: #999;
}
.isRequired {
color: #ee3040;
font-size: 14px;
padding-right: 2px;
font-size: 14px;
color: #ee3040;
}
.hidden-input {
position: absolute;
width: 0;
height: 0;
opacity: 0;
pointer-events: none;
opacity: 0;
}
.uploadPage {
width: -webkit-calc(100% - 24px);
width: -moz-calc(100% - 24px);
width: calc(100% - 24px);
float: left;
width: calc(100% - 24px);
margin-left: 12px;
}
.uploadBox {
position: relative;
float: left;
width: 96px;
height: 96px;
border-radius: 8px;
border: 1px solid #dddddd;
background: #f9f9f9;
float: left;
margin-bottom: 16px;
margin-right: 12px;
position: relative;
margin-bottom: 16px;
background: #f9f9f9;
border: 1px solid #ddd;
border-radius: 8px;
}
.plusBox {
float: left;
margin-top: 22px;
margin-left: 36px;
margin-right: 36px;
margin-left: 36px;
}
.uploadTxt {
float: left;
width: 100%;
height: 20px;
float: left;
margin-top: 8px;
line-height: 20px;
color: #999999;
font-size: 12px;
font-weight: 400;
line-height: 20px;
color: #999;
text-align: center;
}
......@@ -182,9 +217,9 @@ function updateData() {
position: absolute;
top: 2px;
right: 2px;
z-index: 99;
width: 20px;
height: 20px;
z-index: 99;
cursor: pointer;
}
</style>
......@@ -4,47 +4,77 @@ import { computed, ref } from "vue";
const props = defineProps({
item: {
type: Object,
default: () => { },
default: () => {},
},
});
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 optionsList = JSON.parse(props.item.options || '[]').map(item => {
const valueList = (item || '').split('-');
const optionsList = JSON.parse(props.item.options || "[]").map(item => {
const valueList = (item || "").split("-");
return {
text: valueList[1] || '',
value: valueList[0] || '',
text: valueList[1] || "",
value: valueList[0] || "",
};
});
return optionsList;
});
function handleBut() {
const ObjectItem = columnsList.value.find(item => item.value == pickerValue.value);
props.item.valueText = ObjectItem.text || '';
props.item.valueKey = ObjectItem.value || '';
props.item.value = pickerValue.value || '';
emit("update", pickerValue.value);
const selected = columnsList.value.find((col) => col.value === pickerValue.value);
const value = pickerValue.value || "";
props.item.value = selected?.value || "";
props.item.valueText = selected?.text || "";
props.item.valueKey = selected?.value || "";
emit("update", {
value,
valueText: selected?.text || "",
valueKey: selected?.value || "",
});
}
</script>
<template>
<van-field name="radio" v-model="pickerValue" :required="item.required === 1" :label="item.nodeName">
<template #input>
<div class="templateBox">
<van-radio-group style="float: right;" v-model="pickerValue" @change="handleBut" direction="horizontal">
<van-radio v-for="item in columnsList" :key="item.value" :name="item.value" icon-size="14px">
{{ item.text }}
</van-radio>
</van-radio-group>
</div>
</template>
</van-field>
<van-field v-model="pickerValue"
:label="item.nodeName"
name="radio"
:required="item.required === 1">
<template #input>
<div class="templateBox">
<van-radio-group v-model="pickerValue"
direction="horizontal"
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-group>
</div>
</template>
</van-field>
</template>
<style lang="scss" scoped>
......
<script setup lang="ts">
import { ref } from "vue";
import { computed, ref } from "vue";
const props = defineProps({
item: {
type: Object,
default: () => { },
default: () => {},
},
});
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 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() {
showPicker.value = true;
if (!props.item.value) {
const date = new Date();
pickerValue.value = [date.getFullYear(), date.getMonth() + 1, date.getDate()];
if (columnsType.value.length === 2) {
pickerValue.value = [date.getFullYear(), date.getMonth() + 1];
} else {
pickerValue.value = [date.getFullYear(), date.getMonth() + 1, date.getDate()];
}
}
}
......@@ -26,21 +51,32 @@ function onConfirm() {
picker = pickerValue.value.join("-");
}
showPicker.value = false;
props.item.value = picker;
emit("update", picker);
}
</script>
<template>
<div>
<van-field v-model="item.value" clearable is-link :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" :title="item.nodeName" @cancel="showPicker = false"
@confirm="onConfirm" />
</van-popup>
</div>
<div>
<van-field v-model="displayValue"
clearable
is-link
: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" />
</van-popup>
</div>
</template>
<style lang="scss" scoped></style>
......@@ -12,13 +12,47 @@ const emit = defineEmits(["update"]);
const showPicker = ref(false);
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 optionsList = JSON.parse(props.item.options || '[]').map(item => {
const valueList = (item || '').split('-');
const optionsList = JSON.parse(props.item.options || "[]").map(item => {
const valueList = (item || "").split("-");
return {
text: valueList[1] || '',
value: valueList[0] || '',
text: valueList[1] || "",
value: valueList[0] || "",
};
});
return optionsList;
......@@ -27,18 +61,22 @@ const columnsList = computed(() => {
function onConfirm() {
const picker = pickerValue.value && pickerValue.value.length > 0 ? pickerValue.value[0] : "";
showPicker.value = false;
const ObjectItem = columnsList.value.find(item => item.value == picker);
props.item.valueText = ObjectItem.text || '';
props.item.valueKey = ObjectItem.value || '';
props.item.value = picker || '';
emit("update", picker);
const selected = columnsList.value.find((col) => col.value === picker) || {};
props.item.value = selected.value || "";
props.item.valueText = selected.text || "";
props.item.valueKey = selected.value || "";
emit("update", {
value: selected.value || "",
valueText: selected.text || "",
valueKey: selected.value || "",
});
}
</script>
<template>
<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" />
<van-popup v-model:show="showPicker" destroy-on-close position="bottom">
<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(() => {
case 3: {
return { text: "检测完成", bg: "#e9f9f1", color: "#2cca74" };
}
case 4:
default: {
return { text: "已取消", bg: "#f2f3f5", color: "#969799" };
}
......@@ -31,7 +30,9 @@ const auditTag = computed(() => {
if (props.auditStatus === undefined) return null;
if (props.status !== 2 && props.status !== 3) return null;
// auditStatus: 1待审批;2审批中;3审批通过;4审批驳回
// 待审核(待审批/审批中)仅在「检测完成」Tab 展示,检测中不显示
if (props.auditStatus === 1 || props.auditStatus === 2) {
if (props.status !== 3) return null;
return { text: "待审核", bg: "#f0eefd", color: "#6A56F0", icon: "clock" as const };
}
if (props.auditStatus === 3) {
......@@ -54,7 +55,9 @@ const auditTag = computed(() => {
<van-tag v-if="auditTag"
class="wo-tag"
: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 }}
</van-tag>
</div>
......
......@@ -5,9 +5,8 @@
import { Defaults, Request } from "glsk-toolkit";
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 ?? "";
let config: Record<string, unknown> = {};
......@@ -47,11 +46,11 @@ export function getRequestApi(): null | Request {
*/
function initRequestInstance(cfg: Record<string, unknown>): void {
const apiBaseUrl = ((
(cfg.apiEnv as { baseURL?: string; baseUrl?: string } | undefined)?.baseURL ??
(cfg.apiEnv as { baseURL?: string; baseUrl?: string } | undefined)?.baseUrl ??
(cfg.apiEnv as undefined | { baseURL?: string; baseUrl?: string })?.baseURL ??
(cfg.apiEnv as undefined | { baseURL?: string; baseUrl?: string })?.baseUrl ??
cfg.apiBaseUrl ??
(cfg.gsc as { baseUrl?: string; baseURL?: string } | undefined)?.baseUrl ??
(cfg.gsc as { baseUrl?: string; baseURL?: string } | undefined)?.baseURL
(cfg.gsc as undefined | { baseUrl?: string; baseURL?: string })?.baseUrl ??
(cfg.gsc as undefined | { baseUrl?: string; baseURL?: string })?.baseURL
) as string | undefined);
const baseUrl = apiBaseUrl || defaultBaseURL;
......
/**
* 配置中心常量
* 应用级常量(配置中心、鉴权存储 key 等)
*/
/** 二手车 H5 配置请求 URL */
export const CONFIG_CENTER_URL =
"https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=venus-usedcar-config&env=develop";
/** 配置缓存 key */
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 {
getConfig,
getRequestApi,
} 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 { LOGIN_REDIRECT_KEY } from "@/config/constants";
import { useUserStore } from "@stores/modules/user.ts";
import { closeToast, showLoadingToast } from "vant";
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({
history: createWebHistory(import.meta.env.BASE_URL),
......@@ -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) => {
const userStore = useUserStore();
showLoadingToast({
message: "加载中...",
forbidClick: true,
duration: 0,
loadingType: "spinner",
});
if (routeLoadingTimer !== undefined) {
clearTimeout(routeLoadingTimer);
routeLoadingTimer = undefined;
}
if (!to.meta.hideRouteLoading) {
routeLoadingTimer = window.setTimeout(() => {
routeLoadingTimer = undefined;
showLoadingToast({
message: "加载中...",
forbidClick: true,
duration: 0,
loadingType: "spinner",
});
}, ROUTE_LOADING_DELAY_MS);
}
if (to.meta.title) {
document.title = `${to.meta.title} - ${import.meta.env.VITE_APP_TITLE}`;
......@@ -50,7 +62,7 @@ router.beforeEach((to, from, next) => {
}
// 2. 没有 token 的情况
if (WHITE_LIST.includes(to.path)) {
if (WHITE_LIST.has(to.path)) {
next();
return;
}
......@@ -61,6 +73,10 @@ router.beforeEach((to, from, next) => {
});
router.afterEach(() => {
if (routeLoadingTimer !== undefined) {
clearTimeout(routeLoadingTimer);
routeLoadingTimer = undefined;
}
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";
const routes: RouteRecordRaw[] = [
......@@ -8,6 +17,7 @@ const routes: RouteRecordRaw[] = [
meta: {
title: "登录",
showTabBar: false,
hideRouteLoading: true,
},
},
{
......@@ -48,6 +58,33 @@ const routes: RouteRecordRaw[] = [
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[] = [
showTabBar: false,
},
},
/** 开发自测:OSS 分片上传 */
{
path: "/upload-demo",
name: "UploadDemo",
component: () => import("@views/upload-demo/index.vue"),
path: "/inspect-report",
name: "InspectReport",
component: () => import("@views/inspect-report/index.vue"),
meta: {
title: "OSS 上传 Demo",
title: "检测报告",
showTabBar: false,
},
},
{
path: "/word-order-detail/:id",
name: "WorkOrderDetail",
component: () => import("@views/word-order-detail/index.vue"),
path: "/inspect-detail",
name: "InspectDetail",
component: () => import("@views/inspect-detail/index.vue"),
meta: {
title: "工单详情",
title: "检测详情",
showTabBar: false,
},
},
......@@ -84,6 +120,7 @@ const routes: RouteRecordRaw[] = [
component: () => import("@views/404/index.vue"),
meta: {
title: "页面不存在",
hideRouteLoading: true,
},
},
];
......
import { defineStore } from "pinia";
import { ref, computed } from "vue";
import { computed, ref } 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 {
id: number;
......@@ -11,46 +13,59 @@ export interface UserInfo {
}
export const useUserStore = defineStore(
"user",
() => {
const token = ref<string>("");
const userInfo = ref<UserInfo | null>(null);
const isLoggedIn = computed(() => !!token.value);
const username = computed(() => userInfo.value?.nickname ?? "");
function setToken(val: string) {
token.value = val;
if (val) {
localStorage.setItem(TOKEN_KEY, val);
} else {
localStorage.removeItem(TOKEN_KEY);
}
}
function setUserInfo(info: UserInfo) {
userInfo.value = info;
}
function logout() {
token.value = "";
userInfo.value = null;
localStorage.removeItem(TOKEN_KEY);
}
return {
token,
userInfo,
isLoggedIn,
username,
setToken,
setUserInfo,
logout,
};
},
{
persist: {
pick: ["token", "userInfo"],
},
},
"user",
() => {
const token = ref<string>("");
const userInfo = ref<null | UserInfo>(null);
const isLoggedIn = computed(() => !!token.value);
const username = computed(() => userInfo.value?.nickname ?? "");
function setToken(val: string) {
token.value = val;
if (val) {
localStorage.setItem(TOKEN_KEY, val);
} else {
localStorage.removeItem(TOKEN_KEY);
}
}
function setUserInfo(info: UserInfo) {
userInfo.value = info;
}
/** 调服务端登出后清空 token、用户信息、本地缓存,并通知宿主 WebView */
async function logout() {
try {
if (token.value) {
await requestAuthLogout();
}
} catch {
// 接口失败仍执行本地登出
} finally {
token.value = "";
userInfo.value = null;
localStorage.removeItem(TOKEN_KEY);
notifyHostLogout();
}
sessionStorage.removeItem(LOGIN_REDIRECT_KEY);
const { default: router } = await import("@/router");
await router.replace({ path: "/login" });
}
return {
token,
userInfo,
isLoggedIn,
username,
setToken,
setUserInfo,
logout,
};
},
{
persist: {
pick: ["token", "userInfo"],
},
},
);
import type { RouteMeta } from "vue-router";
declare module "vue-router" {
interface RouteMeta {
......@@ -6,14 +5,16 @@ declare module "vue-router" {
keepAlive?: boolean;
showTabBar?: boolean;
requiresAuth?: boolean;
/** 为 true 时不展示全局路由 Loading、不参与延迟 Toast */
hideRouteLoading?: boolean;
}
}
declare global {
interface Window {
__APP_INFO__: {
version: string;
buildTime: string;
version: string;
};
}
}
......
import type { InspectionNode, LeafNodeRecord } from "@/api";
import type { InspectionNode, InspectionResultVO, LeafNodeRecord } from "@/api";
/** 检测评分:骨架/内饰等级选项(与 ScoreForm 共用) */
export const SCORE_RATING_OPTIONS = ["A", "B", "C", "D"] as const;
......@@ -10,6 +10,8 @@ export interface SubTab {
nodeId?: number;
/** 该二级项下的叶子节点列表(nodeType=3) */
leafNodes?: InspectionNode[];
/** 二级项节点上的检测结果(与接口一致,进度/勾选优先据此判断) */
inspectionResultVO?: InspectionResultVO;
/** 二级项自身的完成标志:0 未完成,1 已完成 */
completedFlag?: 0 | 1;
}
......@@ -21,6 +23,11 @@ export interface BigModule {
/** 是否存在二级分组 Tab;false 表示子节点直接为叶子(nodeType=3),不展示二级 Tab */
hasSecondaryTabs?: boolean;
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 { showToast } from "vant";
......@@ -48,7 +49,6 @@ export interface RequestConfig {
[key: string]: unknown;
}
const TOKEN_KEY = "venus_usedcar_token";
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]);
/** 未登录或登录过期 */
const BIZ_CODE_UNAUTHORIZED = 1006;
function normalizeBizCode(code: unknown): number | null {
function normalizeBizCode(code: unknown): null | number {
if (code === null || code === undefined || code === "") {
return null;
}
......@@ -82,11 +82,11 @@ function getToken(): string {
function resolveBaseURL(): string {
const cfg = getConfig() as Record<string, unknown>;
const apiBaseUrl =
((cfg.apiEnv as { baseURL?: string; baseUrl?: string } | undefined)?.baseURL ??
(cfg.apiEnv as { baseURL?: string; baseUrl?: string } | undefined)?.baseUrl ??
((cfg.apiEnv as undefined | { baseURL?: string; baseUrl?: string })?.baseURL ??
(cfg.apiEnv as undefined | { baseURL?: string; baseUrl?: string })?.baseUrl ??
(cfg.apiBaseUrl as string | undefined) ??
(cfg.gsc as { baseUrl?: string; baseURL?: string } | undefined)?.baseUrl ??
(cfg.gsc as { baseUrl?: string; baseURL?: string } | undefined)?.baseURL) as
(cfg.gsc as undefined | { baseUrl?: string; baseURL?: string })?.baseUrl ??
(cfg.gsc as undefined | { baseUrl?: string; baseURL?: string })?.baseURL) as
| string
| undefined;
......@@ -112,7 +112,7 @@ function getInstance(): AxiosInstance {
const token = getToken();
if (token) {
config.headers = {
...(config.headers || {}),
...config.headers,
Authorization: token,
} as typeof config.headers;
}
......
import { useUserStore } from "@stores/modules/user";
type HostMessage =
| { type: "INIT_TOKEN"; token?: string }
| { type: "AUTH_TOKEN"; token?: string }
| { type: "LOGOUT" }
| Record<string, unknown>;
| Record<string, unknown>
| { token?: string; type: "AUTH_TOKEN"; }
| { token?: string; type: "INIT_TOKEN"; }
| { type: "LOGOUT" };
function safeJsonParse(input: unknown): unknown {
if (typeof input !== "string") return input;
......@@ -35,10 +35,10 @@ function stripTokenFromUrl() {
}
function postToUniApp(payload: Record<string, unknown>) {
console.log('pad端postToUniApp', payload);
console.log("pad端postToUniApp", payload);
const w = window as unknown as {
uni?: { postMessage?: (args: { data: unknown }) => void };
parent?: Window;
uni?: { postMessage?: (args: { data: unknown }) => void };
};
const doPost = () => {
......@@ -61,7 +61,7 @@ function postToUniApp(payload: Record<string, unknown>) {
doPost();
} else {
// 等待 UniAppJSBridgeReady 事件后再发送
document.addEventListener('UniAppJSBridgeReady', doPost, { once: true });
document.addEventListener("UniAppJSBridgeReady", doPost, { once: true });
}
}
......@@ -109,7 +109,7 @@ export function initTokenBridge() {
}
}
if (type === "LOGOUT") {
userStore.logout();
void userStore.logout();
}
});
}
......
......@@ -8,9 +8,11 @@
<input class="score-input"
inputmode="numeric"
maxlength="3"
pattern="[0-9]*"
type="text"
:value="String(form.appearanceScore)"
@input="onAppearanceScoreInput" />
@input="onAppearanceScoreInput"
@keydown="onScoreInputKeydown" />
<span class="score-unit">分</span>
</div>
</div>
......@@ -55,7 +57,9 @@
@click="openRatingGuide('frame')"
@keydown.enter.prevent="openRatingGuide('frame')"
@keydown.space.prevent="openRatingGuide('frame')">
参考
<img alt="指引"
class="score-ref-icon"
:src="systemTipImg" />
</span>
</div>
<div class="rating-btns">
......@@ -64,11 +68,11 @@
class="rating-btn"
:class="{ active: form.frameRating === opt }"
@click="form.frameRating = opt">
<span v-if="form.frameRating === opt"
aria-hidden="true"
class="rating-btn-check">
☑️
</span>
<img v-if="form.frameRating === opt"
alt=""
aria-hidden="true"
class="rating-btn-check"
:src="ratingSelectedCheckImg" />
{{ opt }}
</div>
</div>
......@@ -93,7 +97,9 @@
@click="openRatingGuide('interior')"
@keydown.enter.prevent="openRatingGuide('interior')"
@keydown.space.prevent="openRatingGuide('interior')">
参考
<img alt="指引"
class="score-ref-icon"
:src="systemTipImg" />
</span>
</div>
<div class="rating-btns">
......@@ -102,11 +108,11 @@
class="rating-btn"
:class="{ active: form.interiorRating === opt }"
@click="form.interiorRating = opt">
<span v-if="form.interiorRating === opt"
aria-hidden="true"
class="rating-btn-check">
☑️
</span>
<img v-if="form.interiorRating === opt"
alt=""
aria-hidden="true"
class="rating-btn-check"
:src="ratingSelectedCheckImg" />
{{ opt }}
</div>
</div>
......@@ -129,9 +135,11 @@
<input class="score-input"
inputmode="numeric"
maxlength="3"
pattern="[0-9]*"
type="text"
:value="String(form.overallScore)"
@input="onOverallScoreInput" />
@input="onOverallScoreInput"
@keydown="onScoreInputKeydown" />
<span class="score-unit">分</span>
</div>
</div>
......@@ -180,6 +188,8 @@ import type { RatingGuideConfig } from "./rating-guide-content";
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 { getInspectionChildren } from "@api";
import { isRequestFailureAlreadyHandled } from "@utils/request";
......@@ -311,6 +321,28 @@ function clampScoreFromInput(raw: string): number {
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) {
form.appearanceScore = clampScoreFromInput((e.target as HTMLInputElement).value);
}
......@@ -364,7 +396,7 @@ defineExpose({ validate, getCompleteInspectionPayload });
.score-section {
box-sizing: border-box;
padding: 14px 16px;
background: #ffffff;
background: #fff;
border-radius: 8px;
opacity: 1;
}
......@@ -401,7 +433,7 @@ defineExpose({ validate, getCompleteInspectionPayload });
padding: 0 6px;
font-size: 16px;
font-weight: 500;
color: #333333;
color: #333;
text-align: center;
appearance: none;
background: #fff;
......@@ -422,12 +454,16 @@ defineExpose({ validate, getCompleteInspectionPayload });
}
.score-ref {
padding: 2px 8px;
font-size: 12px;
color: #185efe;
display: inline-flex;
align-items: center;
justify-content: center;
cursor: pointer;
border: 1px solid #185efe;
border-radius: 4px;
}
.score-ref-icon {
display: block;
width: auto;
height: 16px;
}
.score-slider-wrap {
......@@ -468,8 +504,8 @@ defineExpose({ validate, getCompleteInspectionPayload });
height: 40px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
color: #999;
cursor: pointer;
background: #f7f8fa;
border: 1px solid #e8e8e8;
border-radius: 8px;
......@@ -483,11 +519,12 @@ defineExpose({ validate, getCompleteInspectionPayload });
.rating-btn-check {
position: absolute;
top: 2px;
right: 2px;
font-size: 10px;
line-height: 1;
top: -3px;
right: 0;
width: 14px;
height: 14px;
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">
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 type { ReportItem } from "@/types/views/car-list";
import { showToast } from "vant";
const router = useRouter();
const keyword = ref("");
const refreshing = ref(false);
......@@ -15,6 +18,14 @@ const currentPage = ref(1);
const displayList = ref<ReportItem[]>([]);
const scroller = ref<Element | undefined>(undefined);
const listEmpty = computed(
() =>
!refreshing.value &&
!loading.value &&
displayList.value.length === 0 &&
finished.value,
);
function resetList() {
currentPage.value = 1;
finished.value = false;
......@@ -89,7 +100,7 @@ async function onRefresh() {
}
function onViewReport(item: ReportItem) {
showToast(`查看报告:${item.reportNo}`);
void router.push({ name: "CarDetail", params: { id: String(item.id) } });
}
watch([keyword], () => {
......@@ -114,11 +125,16 @@ void onRefresh();
</div>
</PageTop>
<div ref="scroller" class="list-wrap">
<div ref="scroller" class="list-wrap">
<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-text="没有更多了"
finished-text="到底了"
:scroller="scroller"
@load="onLoad">
<div v-for="item in displayList"
......@@ -187,16 +203,33 @@ void onRefresh();
.search-wrap {
padding: 0 12px;
:deep(.van-search) {
padding: 0;
background: transparent;
}
:deep(.van-search__content) {
background: #fff;
}
}
.list-wrap {
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;
overscroll-behavior: contain;
-webkit-overflow-scrolling: touch;
}
.list-empty {
display: flex;
align-items: center;
justify-content: center;
min-height: 220px;
padding: 32px 0;
}
.report-card {
padding: 12px;
margin-bottom: 12px;
......
......@@ -28,11 +28,20 @@ const tabCounts = ref({
});
const statusTabs = computed(() => [
{ status: 1 as const, label: "待检测", count: tabCounts.value.dispatchedCount },
{ status: 2 as const, label: "检测中", count: tabCounts.value.inProgressCount },
{ status: 3 as const, label: "检测完成", count: tabCounts.value.completedCount },
{ status: 1 as const, label: "待检测 ·", count: tabCounts.value.dispatchedCount },
{ status: 2 as const, label: "检测中 ·", count: tabCounts.value.inProgressCount },
{ status: 3 as const, label: "检测完成 ·", count: tabCounts.value.completedCount },
]);
/** 首屏/刷新结束后仍无数据 */
const listEmpty = computed(
() =>
!refreshing.value &&
!loading.value &&
displayList.value.length === 0 &&
finished.value,
);
// tag 样式与映射由 WorkOrderStatusTags 统一处理
function resetList() {
......@@ -106,9 +115,15 @@ async function fillMore() {
finished.value = !!res.last || next.length === 0;
}
/**
* van-list 在 emit load 前会先 `update:loading` 为 true,若此处再判断 `loading` 会直接 return,
* 且不会走 finally,导致 loading 一直为 true,`listEmpty` 永远为 false,空列表不显示「暂无数据」。
*/
async function onLoad() {
if (loading.value || finished.value) return;
loading.value = true;
if (refreshing.value || finished.value) {
loading.value = false;
return;
}
try {
await fillMore();
} finally {
......@@ -128,6 +143,7 @@ async function onRefresh() {
function onStatusChange(status: WorkOrderStatus) {
activeStatus.value = status;
keyword.value = "";
}
function startCheck(item: WorkOrderItem) {
......@@ -148,8 +164,11 @@ function viewWorkOrder(item: WorkOrderItem) :void{
router.push({ name: "WorkOrderDetail", params: { id: item.id } });
}
function viewReport(_item: WorkOrderItem) {
void router.push({ name: "CarList" });
function viewReport(item: WorkOrderItem) {
void router.push({
name: "InspectReport",
query: { recordId: item.id },
});
}
function showRejectReason(_item: WorkOrderItem) {
......@@ -257,9 +276,14 @@ void onRefresh();
<!-- 列表(独立滚动区域) -->
<div ref="scroller" class="list-wrap">
<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-text="没有更多了"
finished-text="到底了"
:scroller="scroller"
@load="onLoad">
<div v-for="item in displayList"
......@@ -303,7 +327,7 @@ void onRefresh();
<div class="card-footer">
<div class="card-bottom">
派单于 {{ item.dispatchTime }}
<span class="k">派单于</span> <span class="v">{{ item.dispatchTime }}</span>
</div>
<div class="card-actions"
@click.stop="stopCardFooterBubbling">
......@@ -405,6 +429,14 @@ void onRefresh();
-webkit-overflow-scrolling: touch;
}
.list-empty {
display: flex;
align-items: center;
justify-content: center;
min-height: 220px;
padding: 32px 0;
}
.order-card {
padding: 12px;
margin-bottom: 12px;
......@@ -476,8 +508,16 @@ void onRefresh();
.card-bottom {
min-width: 0;
font-size: $font-size-xs;
color: $color-text-disabled;
font-size: 12px;
.k {
margin-right: 6px;
color: #999ea8;
}
.v {
color: #666;
}
}
.card-actions {
......@@ -499,7 +539,7 @@ void onRefresh();
:deep(.wo-btn) {
height: auto;
padding: 6px 12px;
padding: 10px 12px;
font-size: 13px;
font-weight: 400;
line-height: 1;
......
......@@ -32,18 +32,20 @@ const {
<van-field v-model="phone"
class="rounded-full login-input"
clearable
inputmode="numeric"
label="手机号"
maxlength="11"
placeholder="请输入手机号"
type="tel" />
type="digit" />
<van-field v-model="code"
class="rounded-full login-input"
clearable
inputmode="numeric"
label="验证码"
maxlength="6"
placeholder="请输入验证码"
type="tel">
type="digit">
<template #button>
<van-button class="login-send-code-btn p-0 text-[13px] leading-[1.25]"
:class="countdown > 0 ? '!text-[#CCCCCC]' : '!text-[#185EFE]'"
......@@ -121,13 +123,13 @@ const {
min-height: 0 !important;
padding: 0 !important;
line-height: 1.25 !important;
border: none !important;
background: transparent !important;
border: none !important;
}
&:deep(.login-send-code-btn.van-button--disabled) {
opacity: 1;
background: transparent !important;
opacity: 1;
}
}
</style>
......
......@@ -28,18 +28,20 @@ const {
<van-field v-model="phone"
class="rounded-full login-input"
clearable
inputmode="numeric"
label="手机号"
maxlength="11"
placeholder="请输入手机号"
type="tel" />
type="digit" />
<van-field v-model="code"
class="rounded-full login-input"
clearable
inputmode="numeric"
label="验证码"
maxlength="6"
placeholder="请输入验证码"
type="tel">
type="digit">
<template #button>
<van-button class="p-0 text-[13px]"
:class="countdown > 0 ? '!text-[#CCCCCC]' : '!text-[#185EFE]'"
......
......@@ -4,6 +4,6 @@ import LoginMobile from "./LoginMobile.vue";
</script>
<template>
<LoginMobile />
<LoginMobile />
</template>
import { ref } from "vue";
import { ref, watch } from "vue";
import { useRouter } from "vue-router";
import { showFailToast, showSuccessToast } from "vant";
import { login, sendSmsCode } from "@/api/modules/user.ts";
import { LOGIN_REDIRECT_KEY } from "@/config/constants";
import { useUserStore } from "@/stores/modules/user.ts";
import { notifyHostToken } from "@/utils/webviewBridge";
const LOGIN_REDIRECT_KEY = "venus_usedcar_login_redirect";
import { showFailToast, showSuccessToast } from "vant";
export function useLogin() {
const router = useRouter();
......@@ -17,10 +15,20 @@ export function useLogin() {
const code = ref("");
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 countdown = ref(0);
const hasSent = ref(false);
let timer: number | null = null;
let timer: null | number = null;
const validPhone = (value: string) => /^1\d{10}$/.test(value);
......@@ -41,7 +49,9 @@ export function useLogin() {
timer && window.clearInterval(timer);
timer = window.setInterval(() => {
if (countdown.value <= 1) {
window.clearInterval(timer!);
if (timer !== null) {
window.clearInterval(timer);
}
timer = null;
countdown.value = 0;
} else {
......
<script setup lang="ts">
import type { InspectDetailAccount } from "@/api/modules/user";
import { computed, onActivated, onMounted, ref, watch } from "vue";
import type { InspectDetailAccount } from "@/api/modules/user";
import { getInspectDetail } from "@/api/modules/user";
import LogoutConfirmModal from "@/components/LogoutConfirmModal.vue";
import PageTop from "@/components/PageTop.vue";
import { useUserStore } from "@/stores";
import avatarDefault from "@assets/image/avatar.png";
import { showToast } from "vant";
const userStore = useUserStore();
const showLogoutConfirm = ref(false);
const avgInspectCost = ref<number>(0);
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(() =>
userStore.isLoggedIn ? inspectAccount.value?.name || userStore.username : ""
......@@ -24,8 +40,8 @@ const displayPhone = computed(() =>
const displayAvatar = computed(() =>
userStore.isLoggedIn
? inspectAccount.value?.avatar || userStore.userInfo?.avatar || ""
: ""
? inspectAccount.value?.avatar || userStore.userInfo?.avatar || avatarDefault
: avatarDefault
);
async function fetchInspectDetail() {
......@@ -50,8 +66,14 @@ function onLogin() {
showToast("登录功能开发中");
}
async function onLogout() {
userStore.logout();
function onLogoutTap() {
if (!userStore.isLoggedIn) return;
showLogoutConfirm.value = true;
}
async function onLogoutConfirm() {
showLogoutConfirm.value = false;
await userStore.logout();
avgInspectCost.value = 0;
inspectAccount.value = null;
showToast("已退出登录");
......@@ -72,7 +94,7 @@ watch(
<template>
<div class="mine-page">
<PageTop title="我的">
<div class="mine-header">
<div class="mine-header !pb-[24px]">
<div class="user-row">
<van-image class="avatar"
fit="cover"
......@@ -119,32 +141,28 @@ watch(
<div class="logout-wrap">
<van-button block
class="logout-btn"
round
@click="onLogout">
@click="onLogoutTap">
退出登录
</van-button>
</div>
<!-- 版本号 -->
<div class="app-version">
当前版本 v{{ __APP_VERSION__ ?? '1.0.0' }}
</div>
</div>
<LogoutConfirmModal :show="showLogoutConfirm"
@confirm="onLogoutConfirm"
@update:show="showLogoutConfirm = $event" />
</div>
</template>
<script lang="ts">
const __APP_VERSION__ = "1.0.0";
</script>
<style lang="scss" scoped>
@use "@assets/styles/variables" as *;
.mine-page {
height: calc(100vh - var(--tabbar-height) - env(safe-area-inset-bottom));
overflow: hidden;
display: flex;
flex-direction: column;
height: calc(100vh - var(--tabbar-height) - env(safe-area-inset-bottom));
overflow: hidden;
background: #f2f6fb;
:deep(.page-top) {
......@@ -153,12 +171,13 @@ const __APP_VERSION__ = "1.0.0";
}
.mine-content {
display: flex;
flex: 1;
flex-direction: column;
overflow: auto;
overscroll-behavior: contain;
-webkit-overflow-scrolling: touch;
display: flex;
flex-direction: column;
}
.mine-header {
......@@ -175,8 +194,6 @@ const __APP_VERSION__ = "1.0.0";
flex-shrink: 0;
align-items: center;
justify-content: center;
background-color: rgb(25 137 250 / 15%);
border: 2px solid rgb(25 137 250 / 25%);
border-radius: 50%;
}
......@@ -199,8 +216,10 @@ const __APP_VERSION__ = "1.0.0";
.avg-card {
padding: 16px;
margin: 6px 12px 0;
border-radius: 10px;
margin: 0 12px;
background: linear-gradient(180deg, #1874fe1a 0%, #1883fe00 50%);
border: 1px solid #fff;
border-radius: 12px;
.avg-label {
margin-bottom: 8px;
......@@ -217,16 +236,23 @@ const __APP_VERSION__ = "1.0.0";
}
.logout-wrap {
padding: 0 12px;
padding: 0 12px 40px;
margin-top: auto;
}
.logout-btn {
height: 44px;
color: $color-text-primary;
font-size: 16px;
font-weight: 400;
color: #222;
background: #fff;
border: 0;
box-shadow: 0 1px 0 rgb(0 0 0 / 4%);
border-radius: 8px;
box-shadow: none;
opacity: 1;
&:active::before {
opacity: 0;
}
}
.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">
import type { WorkOrderStatus } from "@/types/views/work-order-common";
import type {
InspectionWORespVO,
NodeVO,
......@@ -6,8 +7,7 @@ import type {
WorkOrderBaseInfo,
WorkOrderDetailRemote,
WorkOrderVehicle,
} from "@/types/views/word-order-detail";
import type { WorkOrderStatus } from "@/types/views/work-order-common";
} from "@/types/views/work-order-detail";
import { computed, onMounted, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
......@@ -63,8 +63,14 @@ function fmtTime(v?: string) {
}
function continueCheck():void {
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=()=>{
router.back();
};
......
......@@ -20,6 +20,7 @@
"@composables/*": ["src/composables/*"]
},
"resolveJsonModule": true,
"types": ["vite/client"],
"allowImportingTsExtensions": true,
"allowJs": true,
"strict": true,
......@@ -28,8 +29,7 @@
"noUnusedParameters": true,
"noEmit": true,
"isolatedModules": true,
"skipLibCheck": true,
"types": ["vite/client"]
"skipLibCheck": true
},
"references": [{ "path": "./tsconfig.node.json"}],
"include": [
......
import { dirname, resolve } from "node:path";
import process from "node:process";
import { fileURLToPath } from "node:url";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { VantResolver } from "unplugin-vue-components/resolvers";
import Components from "unplugin-vue-components/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 __dirname = dirname(__filename);
const PORT = 8082;
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "VITE_");
const env = loadEnv(mode, process.cwd(), "VITE_");
return {
plugins: [
vue(),
AutoImport({
imports: ["vue", "vue-router", "pinia", "@vueuse/core"],
dts: "src/auto-imports.d.ts",
eslintrc: { enabled: false },
}),
Components({
dts: "src/components.d.ts",
resolvers: [VantResolver()],
dirs: ["src/components", "src/layouts"],
}),
],
return {
plugins: [
vue(),
AutoImport({
imports: ["vue", "vue-router", "pinia", "@vueuse/core"],
dts: "src/auto-imports.d.ts",
eslintrc: { enabled: false },
}),
Components({
dts: "src/components.d.ts",
resolvers: [VantResolver()],
dirs: ["src/components", "src/layouts"],
}),
],
resolve: {
alias: {
"@": resolve(__dirname, "src"),
"@assets": resolve(__dirname, "src/assets"),
"@views": resolve(__dirname, "src/views"),
"@components": resolve(__dirname, "src/components"),
"@stores": resolve(__dirname, "src/stores"),
"@utils": resolve(__dirname, "src/utils"),
"@api": resolve(__dirname, "src/api"),
"@composables": resolve(__dirname, "src/composables"),
},
},
resolve: {
alias: {
"@": resolve(__dirname, "src"),
"@assets": resolve(__dirname, "src/assets"),
"@views": resolve(__dirname, "src/views"),
"@components": resolve(__dirname, "src/components"),
"@stores": resolve(__dirname, "src/stores"),
"@utils": resolve(__dirname, "src/utils"),
"@api": resolve(__dirname, "src/api"),
"@composables": resolve(__dirname, "src/composables"),
},
},
css: {
preprocessorOptions: {
scss: {
api: "modern-compiler",
},
},
},
css: {
preprocessorOptions: {
scss: {
api: "modern-compiler",
},
},
},
server: {
port: PORT,
host: true,
proxy: {
"/api": {
target: env.VITE_API_BASE_URL || "http://localhost:3000",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ""),
},
},
},
server: {
port: PORT,
host: true,
proxy: {
"/api": {
target: env.VITE_API_BASE_URL || "http://localhost:3000",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ""),
},
},
},
build: {
target: "es2015",
outDir: "dist",
cssCodeSplit: true,
rollupOptions: {
output: {
chunkFileNames: "assets/js/[name]-[hash].js",
entryFileNames: "assets/js/[name]-[hash].js",
assetFileNames: ({ name = "" }) => {
if (/\.(png|jpe?g|gif|svg|webp|ico)$/.test(name)) {
return "assets/images/[name]-[hash].[ext]";
}
if (/\.css$/.test(name)) {
return "assets/css/[name]-[hash].[ext]";
}
return "assets/[ext]/[name]-[hash].[ext]";
},
manualChunks: {
"vue-core": ["vue", "vue-router", "pinia"],
vant: ["vant"],
},
},
},
},
build: {
target: "es2015",
outDir: "dist",
cssCodeSplit: true,
rollupOptions: {
output: {
chunkFileNames: "assets/js/[name]-[hash].js",
entryFileNames: "assets/js/[name]-[hash].js",
assetFileNames: ({ name = "" }) => {
if (/\.(?:png|jpe?g|gif|svg|webp|ico)$/.test(name)) {
return "assets/images/[name]-[hash].[ext]";
}
if (/\.css$/.test(name)) {
return "assets/css/[name]-[hash].[ext]";
}
return "assets/[ext]/[name]-[hash].[ext]";
},
manualChunks: {
"vue-core": ["vue", "vue-router", "pinia"],
vant: ["vant"],
},
},
},
},
optimizeDeps: {
include: ["vue", "vue-router", "pinia", "@vueuse/core", "axios", "dayjs"],
},
};
optimizeDeps: {
include: ["vue", "vue-router", "pinia", "@vueuse/core", "axios", "dayjs"],
},
};
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!