Commit 0f60ec9b by yancanhua

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

# Conflicts:
#	apps/web/venus-usedcar-quality/src/components/CustomizeForm/Index.vue
2 parents b6bc0dd3 5322f7f5
Pipeline #112 for 0f60ec9b failed in 0 seconds
Showing 40 changed files with 736 additions and 478 deletions
......@@ -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 "./page";
export * from "./template";
export * from "./record";
export * from "./template";
......@@ -25,13 +25,13 @@ export interface InspectReportPageData<T> {
}
export interface InspectReportVehicleCover {
uid?: string | number;
uid?: number | string;
name?: string;
status?: string;
url?: string;
filePath?: string;
thumbPath?: string | null;
thumbUrl?: string | null;
thumbPath?: null | string;
thumbUrl?: null | string;
size?: number;
lastModified?: number;
lastModifiedDate?: string;
......
......@@ -21,7 +21,7 @@ export interface InspectionRecordSaveParams {
/** 大项 nodeId */
locationModule: number | string;
/** 二级项 nodeId;无二级分组时为 null */
locationSubModule: number | string | null;
locationSubModule: null | number | string;
/** true = 保存并跳下一步,false = 仅保存 */
nextFlag: boolean;
leafNodes: LeafNodeRecord[];
......@@ -31,7 +31,7 @@ export interface InspectionRecordSaveParams {
* 保存/下一步
*/
export function saveInspectionRecord(params: InspectionRecordSaveParams) {
return post<void>("/rest/inspectionRecord/save", params);
return post("/rest/inspectionRecord/save", params);
}
/**
......
......@@ -43,7 +43,7 @@ export interface InspectionNode {
options?: string;
validationRules?: string;
allowNoStructure?: number;
existsDefaultValue?: string | number;
existsDefaultValue?: number | string;
defaultValue?: string;
defaultType?: number;
nodeLevel: number;
......@@ -67,7 +67,7 @@ export interface InspectionNode {
* 获取检测模板根节点(大项)
* @param taskId 检测工单ID
*/
export function getInspectionRootNodes(taskId: string | number) {
export function getInspectionRootNodes(taskId: number | string) {
return get<InspectionNode[]>(`/rest/inspectionTemplate/${taskId}/rootNodes`);
}
......@@ -75,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;
}
......@@ -94,8 +94,8 @@ export interface InspectionScoreVO {
export type InspectionChildrenData =
| InspectionNode[]
| {
inspectionScoreVO?: InspectionScoreVO | null;
[key: string]: unknown;
inspectionScoreVO?: InspectionScoreVO | null;
};
/**
......@@ -103,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,
});
......@@ -137,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,
});
......@@ -149,8 +149,8 @@ function hasDefaultValueFlag(node: InspectionNode): boolean {
}
const KEYED_SELECT_INTERACTION_TYPES = new Set([
"dropdown",
"button_select",
"dropdown",
"radio_button_select",
]);
......@@ -257,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);
......@@ -275,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 ?? "";
......
......@@ -68,7 +68,7 @@ export function login(params: LoginParams) {
}
export function logout() {
return post<void>("/rest/auth/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;
}
......
......@@ -7,21 +7,20 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
ButtonSelect: typeof import('./components/CustomizeForm/buttonSelect.vue')['default']
CustomizeUploadFile: typeof import('./components/CustomizeForm/customizeUploadFile.vue')['default']
Index: typeof import('./components/CustomizeForm/Index.vue')['default']
ButtonSelect: typeof import('./components/customizeForm/buttonSelect.vue')['default']
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']
RadioSelect: typeof import('./components/customizeForm/radioSelect.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
SelectDatePicker: typeof import('./components/CustomizeForm/selectDatePicker.vue')['default']
SelectDropdown: typeof import('./components/CustomizeForm/selectDropdown.vue')['default']
SelectDatePicker: typeof import('./components/customizeForm/selectDatePicker.vue')['default']
SelectDropdown: typeof import('./components/customizeForm/selectDropdown.vue')['default']
VanActionSheet: typeof import('vant/es')['ActionSheet']
VanButton: typeof import('vant/es')['Button']
VanCheckbox: typeof import('vant/es')['Checkbox']
VanDatePicker: typeof import('vant/es')['DatePicker']
VanEmpty: typeof import('vant/es')['Empty']
VanField: typeof import('vant/es')['Field']
......@@ -38,12 +37,10 @@ declare module 'vue' {
VanRadio: typeof import('vant/es')['Radio']
VanRadioGroup: typeof import('vant/es')['RadioGroup']
VanSearch: typeof import('vant/es')['Search']
VanSkeleton: typeof import('vant/es')['Skeleton']
VanSlider: typeof import('vant/es')['Slider']
VanTabbar: typeof import('vant/es')['Tabbar']
VanTabbarItem: typeof import('vant/es')['TabbarItem']
VanTag: typeof import('vant/es')['Tag']
VanUploader: typeof import('vant/es')['Uploader']
WorkOrderStatusTags: typeof import('./components/WorkOrderStatusTags.vue')['default']
}
}
......@@ -4,14 +4,14 @@ import { computed, ref } from "vue";
const props = defineProps({
item: {
type: Object,
default: () => { },
default: () => {},
},
});
const emit = defineEmits(["update"]);
const pickerValue = ref([]);
//页面加载时初始化数据
// 页面加载时初始化数据
onMounted(() => {
initData();
});
......@@ -22,9 +22,9 @@ function initData() {
if (props?.item?.inspectionResultVO) {
const inspectionValueList = props?.item?.inspectionResultVO?.inspectionValueList || [];
if (inspectionValueList && inspectionValueList.length > 0 && inspectionValueList[0].valueKey) {
for (let i = 0; i < inspectionValueList.length; i++) {
if (inspectionValueList[i].valueKey) {
pickerValue.value.push(inspectionValueList[i].valueKey);
for (const element of inspectionValueList) {
if (element.valueKey) {
pickerValue.value.push(element.valueKey);
}
}
......@@ -35,11 +35,11 @@ function initData() {
// 计算属性
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;
......@@ -59,60 +59,61 @@ 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 || "",
};
});
if (valueList.length) {
props.item.value = JSON.stringify(valueList || []);
if (valueList.length > 0) {
emit("update", JSON.stringify(valueList || []));
} else {
props.item.value = '';
emit("update", '');
emit("update", "");
}
}
</script>
<template>
<div class="buttonSelect">
<div class="title">
<span v-if="item.required === 1" class="isRequired">*</span>
<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>
</div>
</div>
<div class="buttonSelect">
<div class="title">
<span v-if="item.required === 1" class="isRequired">*</span>
<span>{{ item.nodeName }}</span>
</div>
<div class="selectList">
<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>
</template>
<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 {
......@@ -120,29 +121,27 @@ function setupdate() {
}
.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;
}
......@@ -150,9 +149,9 @@ function setupdate() {
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, watch } from "vue";
import { uploadFile } from "@/utils/upload.js";
const uploading = ref(false);
import { ref } from "vue";
import { uploadFile } from "@/utils/upload.js";
import { showToast } from "vant";
const props = defineProps({
item: {
type: Object,
default: () => { },
default: () => {},
},
});
const emit = defineEmits(["update"]);
const uploading = ref(false);
const pickerValue = ref([]);
const fileInputRef = ref<HTMLInputElement | null>(null);
......@@ -20,7 +22,7 @@ function pickFile() {
fileInputRef.value?.click();
}
//页面加载时初始化数据
// 页面加载时初始化数据
onMounted(() => {
initData();
});
......@@ -31,7 +33,7 @@ function initData() {
if (props?.item?.inspectionResultVO) {
const inspectionValueList = props?.item?.inspectionResultVO?.inspectionValueList || [];
for (const i of inspectionValueList) {
if (i.valueText) { pickerValue.value.push(i.valueText) }
if (i.valueText) { pickerValue.value.push(i.valueText); }
}
}
updateData();
......@@ -39,7 +41,7 @@ function initData() {
// 计算属性
const validationRules = computed(() => {
return JSON.parse(props.item.validationRules || '{}');
return JSON.parse(props.item.validationRules || "{}");
});
async function onFileChange(ev: Event) {
......@@ -54,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;
......@@ -71,130 +73,143 @@ function handleDelete(item: string) {
}
function updateData() {
if (pickerValue.value.length) {
props.item.value = JSON.stringify(pickerValue.value);
if (pickerValue.value.length > 0) {
emit("update", JSON.stringify(pickerValue.value));
} else {
props.item.value = '';
emit("update", '');
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;
}
......@@ -202,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,63 +4,74 @@ 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 = '';
pickerValue.value = "";
if (props?.item?.inspectionResultVO) {
const inspectionValueList = props?.item?.inspectionResultVO?.inspectionValueList || [];
if (inspectionValueList && inspectionValueList.length > 0) {
pickerValue.value = inspectionValueList[0].valueKey || '';
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 || "";
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 columnsType = ref(['year', 'month', 'day']);
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'];
const validationRules = JSON.parse(props.item.validationRules || "{}");
if (validationRules.datePattern && validationRules.datePattern === "YYYY-MM") {
columnsType.value = ["year", "month"];
} else {
columnsType.value = ['year', 'month', 'day'];
columnsType.value = ["year", "month", "day"];
}
}
......@@ -46,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" :columns-type="columnsType"
@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>
......@@ -4,7 +4,7 @@ import { computed, ref } from "vue";
const props = defineProps({
item: {
type: Object,
default: () => { },
default: () => {},
},
});
......@@ -12,8 +12,23 @@ 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();
});
......@@ -32,11 +47,11 @@ function initData() {
// 计算属性
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;
......@@ -45,24 +60,37 @@ 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) || {};
emit("update", {
value: picker || "",
valueText: selected.text || "",
valueKey: selected.value || "",
});
}
</script>
<template>
<div>
<van-field v-model="item.valueText" 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"
@confirm="onConfirm" />
</van-popup>
</div>
<div>
<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"
@confirm="onConfirm" />
</van-popup>
</div>
</template>
<style lang="scss" scoped></style>
......@@ -50,8 +50,8 @@ defineProps<{
}>();
const emit = defineEmits<{
"update:show": [value: boolean];
confirm: [];
"update:show": [value: boolean];
}>();
function close() {
......@@ -109,9 +109,9 @@ function onConfirm() {
display: block;
width: 100%;
height: 100%;
pointer-events: none;
object-fit: cover;
object-position: top center;
pointer-events: none;
}
.logout-confirm__hero {
......
......@@ -20,7 +20,6 @@ const checkTag = computed(() => {
case 3: {
return { text: "检测完成", bg: "#e9f9f1", color: "#2cca74" };
}
case 4:
default: {
return { text: "已取消", bg: "#f2f3f5", color: "#969799" };
}
......@@ -56,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>
......
......@@ -6,6 +6,7 @@ import { Defaults, Request } from "glsk-toolkit";
import { showToast } from "vant";
import { CONFIG_CACHE_KEY, CONFIG_CENTER_URL, TOKEN_KEY } from "./constants";
const defaultBaseURL = import.meta.env.VITE_API_BASE_URL ?? "";
let config: Record<string, unknown> = {};
......@@ -45,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;
......
import { createRouter, createWebHistory } from "vue-router";
import { closeToast, showLoadingToast } from "vant";
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 ROUTE_LOADING_DELAY_MS = 200;
let routeLoadingTimer: ReturnType<typeof setTimeout> | undefined;
......@@ -22,7 +21,7 @@ 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();
......@@ -63,7 +62,7 @@ router.beforeEach((to, from, next) => {
}
// 2. 没有 token 的情况
if (WHITE_LIST.includes(to.path)) {
if (WHITE_LIST.has(to.path)) {
next();
return;
}
......
......@@ -88,6 +88,33 @@ const routes: RouteRecordRaw[] = [
],
},
{
path: "/car-detail/:id",
name: "CarDetail",
component: () => import("@views/car-detail/index.vue"),
meta: {
title: "车辆详情",
showTabBar: false,
},
},
{
path: "/inspect-report",
name: "InspectReport",
component: () => import("@views/inspect-report/index.vue"),
meta: {
title: "检测报告",
showTabBar: false,
},
},
{
path: "/inspect-detail",
name: "InspectDetail",
component: () => import("@views/inspect-detail/index.vue"),
meta: {
title: "检测详情",
showTabBar: false,
},
},
{
path: "/:pathMatch(.*)*",
name: "NotFound",
component: () => import("@views/404/index.vue"),
......
import { defineStore } from "pinia";
import { ref, computed } from "vue";
import { computed, ref } from "vue";
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;
......@@ -13,59 +13,59 @@ export interface UserInfo {
}
export const useUserStore = defineStore(
"user",
() => {
const token = ref<string>("");
const userInfo = ref<UserInfo | null>(null);
"user",
() => {
const token = ref<string>("");
const userInfo = ref<null | UserInfo>(null);
const isLoggedIn = computed(() => !!token.value);
const username = computed(() => userInfo.value?.nickname ?? "");
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 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 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" });
}
/** 调服务端登出后清空 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"],
},
},
return {
token,
userInfo,
isLoggedIn,
username,
setToken,
setUserInfo,
logout,
};
},
{
persist: {
pick: ["token", "userInfo"],
},
},
);
import type { RouteMeta } from "vue-router";
declare module "vue-router" {
interface RouteMeta {
......@@ -14,8 +13,8 @@ declare module "vue-router" {
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";
import { TOKEN_KEY } from "@/config/constants";
import { getConfig } from "../config/center";
/**
......@@ -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 });
}
}
......
......@@ -396,7 +396,7 @@ defineExpose({ validate, getCompleteInspectionPayload });
.score-section {
box-sizing: border-box;
padding: 14px 16px;
background: #ffffff;
background: #fff;
border-radius: 8px;
opacity: 1;
}
......@@ -433,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;
......@@ -462,8 +462,8 @@ defineExpose({ validate, getCompleteInspectionPayload });
.score-ref-icon {
display: block;
height: 16px;
width: auto;
height: 16px;
}
.score-slider-wrap {
......@@ -504,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;
......@@ -520,11 +520,11 @@ defineExpose({ validate, getCompleteInspectionPayload });
.rating-btn-check {
position: absolute;
top: -3px;
right: 0px;
right: 0;
width: 14px;
height: 14px;
object-fit: contain;
pointer-events: none;
object-fit: contain;
}
}
......
import type { BigModule, SubTab } from "@/types/views/car-detail";
import type {
CompleteInspectionResultData,
InspectionNode,
InspectionResultVO,
InspectionTemplateDefaultData,
} from "@api";
import type { RouteLocationNormalizedLoaded } from "vue-router";
import type { BigModule } from "@/types/views/car-detail";
import type { CompleteInspectionResultData, InspectionResultVO, InspectionTemplateDefaultData } from "@api";
import { computed, ref } from "vue";
import {
applyResolvedInitialValuesToLeafNodes,
......@@ -9,7 +16,6 @@ import {
getInspectionRootNodes,
getInspectionTemplateDefault,
} from "@api";
import { computed, ref } from "vue";
import { showToast } from "vant";
/** 检测评分大项的固定 key(非接口返回,手动追加至大项末尾) */
......@@ -25,6 +31,33 @@ export function isCompletedFlagFieldDone(flag: unknown): boolean {
return flag === 1 || String(flag ?? "") === "1";
}
/** 二级 Tab 是否完成:优先用接口节点上的 inspectionResultVO,无则回退 completedFlag(如整页叶子合成 Tab) */
export function isSubTabMarkCompleted(sub: SubTab): boolean {
if (sub.inspectionResultVO !== null && sub.inspectionResultVO !== undefined) {
return isInspectionVoCompleted(sub.inspectionResultVO);
}
return isCompletedFlagFieldDone(sub.completedFlag);
}
/** 二级子节点列表:总进度 = 列表长度,已完成 = 各节点 inspectionResultVO.completedFlag */
function computeSecondaryProgressFromList(list: InspectionNode[]): { done: number; total: number; } {
const nodes = Array.isArray(list) ? list : [];
return {
total: nodes.length,
done: nodes.filter((n) => isInspectionVoCompleted(n.inspectionResultVO)).length,
};
}
function secondaryProgressOrFallback(module: BigModule): { done: number; total: number; } {
if (module.secondaryProgress) return module.secondaryProgress;
const subs = module.subTabs;
if (subs.length === 0) return { total: 0, done: 0 };
return {
total: subs.length,
done: subs.filter((s) => isSubTabMarkCompleted(s)).length,
};
}
/** 提交评分返回里是否仍有未完成项(`firstUncompletedNodeId` 有有效值) */
export function hasCompleteInspectionUncompletedHint(data: CompleteInspectionResultData | undefined): boolean {
if (!data) return false;
......@@ -60,17 +93,18 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
bigModules.value.filter((module) => module.key !== SCORE_BIG_KEY)
);
const flattenedMainSubTabs = computed(() =>
mainInspectionBigModules.value.flatMap((module) => module.subTabs)
);
const progressTotal = computed(() => flattenedMainSubTabs.value.length);
const progressDone = computed(() =>
flattenedMainSubTabs.value.filter((subTab) => isCompletedFlagFieldDone(subTab.completedFlag)).length
);
/** 检测进度:仅当前大项 — 分母为二级接口列表长度,分子为各二级节点 inspectionResultVO.completedFlag */
const progressTotal = computed(() => {
const m = activeBigModule.value;
if (!m || m.key === SCORE_BIG_KEY) return 0;
return secondaryProgressOrFallback(m).total;
});
const remainingSubTabCount = computed(() => progressTotal.value - progressDone.value);
const progressDone = computed(() => {
const m = activeBigModule.value;
if (!m || m.key === SCORE_BIG_KEY) return 0;
return secondaryProgressOrFallback(m).done;
});
const activeSubTab = computed(
() =>
......@@ -78,6 +112,16 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
activeBigModule.value?.subTabs[0]
);
/** 有真实二级 Tab 时,当前是否为该大项的最后一个二级项(用于底部主按钮「提交检测内容」) */
const isLastSubTabOfActiveBigModule = computed(() => {
const m = activeBigModule.value;
if (!m || m.hasSecondaryTabs !== true) return false;
const subs = m.subTabs;
if (subs.length === 0) return true;
const idx = subs.findIndex((s) => s.key === activeSubKey.value);
return idx !== -1 && idx === subs.length - 1;
});
const currentLeafNodes = computed(() => activeSubTab.value?.leafNodes ?? []);
async function initializeInspection() {
......@@ -136,13 +180,17 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
if (!force && targetBigModule.subTabs.length > 0) {
if (syncSelection) {
activeSubKey.value = targetBigModule.subTabs[0]!.key;
const firstSub = targetBigModule.subTabs[0];
if (firstSub) {
activeSubKey.value = firstSub.key;
}
}
return;
}
const childLevelNodes = await getInspectionChildren(bigModuleKey, taskId.value);
const list = Array.isArray(childLevelNodes) ? childLevelNodes : [];
targetBigModule.secondaryProgress = computeSecondaryProgressFromList(list);
const firstChild = list[0];
const isDirectLeafChildren = firstChild !== undefined && firstChild.nodeType === 3;
......@@ -173,12 +221,16 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
label: node.nodeName,
nodeId: node.id,
leafNodes: applyResolvedInitialValuesToLeafNodes(node.childrenNodes, templateDefaultData),
inspectionResultVO: node.inspectionResultVO,
completedFlag: isInspectionVoCompleted(node.inspectionResultVO) ? 1 : 0,
}));
}
if (targetBigModule.subTabs.length > 0 && syncSelection) {
activeSubKey.value = targetBigModule.subTabs[0]!.key;
const firstSub = targetBigModule.subTabs[0];
if (firstSub) {
activeSubKey.value = firstSub.key;
}
}
} catch (error) {
console.error("加载二级项失败:", error);
......@@ -214,30 +266,45 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
return false;
}
function advanceInspectionStep() {
const activeModule = activeBigModule.value;
if (!activeModule) return;
const subTabsOfActive = activeModule.subTabs;
const activeSubIndex = subTabsOfActive.findIndex((subTab) => subTab.key === activeSubKey.value);
if (activeSubIndex < subTabsOfActive.length - 1) {
activeSubKey.value = subTabsOfActive[activeSubIndex + 1]!.key;
return;
}
async function advanceToNextMainInspectionModule() {
const mains = mainInspectionBigModules.value;
const activeMainIndex = mains.findIndex((module) => module.key === activeBigKey.value);
if (activeMainIndex < mains.length - 1) {
const nextMain = mains[activeMainIndex + 1]!;
const nextMain = mains[activeMainIndex + 1];
if (!nextMain) {
return;
}
activeBigKey.value = nextMain.key;
loadSubTabsForBigModule(nextMain.key, true, true).then(() => {
activeSubKey.value = nextMain.subTabs[0]?.key ?? "";
});
} else {
activeBigKey.value = SCORE_BIG_KEY;
activeSubKey.value = "";
await loadSubTabsForBigModule(nextMain.key, true, true);
activeSubKey.value = nextMain.subTabs[0]?.key ?? "";
return;
}
activeBigKey.value = SCORE_BIG_KEY;
activeSubKey.value = "";
}
/**
* 保存(nextFlag)成功后的跳转:
* - 有二级且非最后一个二级 → 仅切到同一大项下一二级;
* - 有二级且最后一个二级,或无二级(整大项一屏)→ 进入下一个检测大项(或检测评分)
*/
async function advanceInspectionStep() {
const activeModule = activeBigModule.value;
if (!activeModule) return;
if (activeModule.hasSecondaryTabs === true) {
const subTabs = activeModule.subTabs;
const activeSubIndex = subTabs.findIndex((subTab) => subTab.key === activeSubKey.value);
if (activeSubIndex !== -1 && activeSubIndex < subTabs.length - 1) {
const nextSub = subTabs[activeSubIndex + 1];
if (nextSub) {
activeSubKey.value = nextSub.key;
}
return;
}
}
await advanceToNextMainInspectionModule();
}
function onOpenModulePicker() {
......@@ -258,7 +325,7 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
mainInspectionBigModules,
progressTotal,
progressDone,
remainingSubTabCount,
isLastSubTabOfActiveBigModule,
activeSubTab,
currentLeafNodes,
initializeInspection,
......
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 { ref, type Ref } from "vue";
import { useRouter } from "vue-router";
import { showToast } from "vant";
import ScoreForm from "../components/ScoreForm.vue";
import {
hasCompleteInspectionUncompletedHint,
SCORE_BIG_KEY,
type InspectModulesReturn,
SCORE_BIG_KEY
} from "./useInspectModules";
function buildInspectionSavePayload(
......@@ -114,7 +119,7 @@ export function useInspectSubmit(
if (modules.activeBigKey.value !== SCORE_BIG_KEY) {
await modules.loadSubTabsForBigModule(modules.activeBigKey.value, false, true);
}
modules.advanceInspectionStep();
await modules.advanceInspectionStep();
} catch (error) {
if (!isRequestFailureAlreadyHandled(error)) {
showToast("保存失败,请重试");
......@@ -152,14 +157,18 @@ export function useInspectSubmit(
);
if (activeSubIndex > 0) {
const prevSubKey = subTabsOfActive[activeSubIndex - 1]!.key;
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]!;
const previousMain = mains[activeMainIndex - 1];
if (!previousMain) {
return;
}
modules.activeBigKey.value = previousMain.key;
await modules.loadSubTabsForBigModule(previousMain.key, true, true);
modules.activeSubKey.value =
......
......@@ -72,13 +72,13 @@
<div v-for="subTab in activeBigModule?.subTabs"
:key="subTab.key"
class="subtab-item"
:class="{ active: subTab.key === activeSubKey, completed: isCompletedFlagFieldDone(subTab.completedFlag) }"
:class="{ active: subTab.key === activeSubKey, completed: isSubTabMarkCompleted(subTab) }"
@click="onSelectSubTab(subTab.key)">
{{ subTab.label }}
<van-icon v-if="isCompletedFlagFieldDone(subTab.completedFlag)"
<van-icon v-if="isSubTabMarkCompleted(subTab)"
class="subtab-done-icon"
color="#27CD5A"
name="checked" />
{{ subTab.label }}
</div>
</div>
......@@ -127,7 +127,7 @@
{{
activeBigModule?.hasSecondaryTabs === false
? "完成检测"
: remainingSubTabCount === 1
: isLastSubTabOfActiveBigModule
? "提交检测内容"
: "下一步"
}}
......@@ -135,20 +135,39 @@
</template>
</div>
<!-- 大项选择弹窗 -->
<!-- 大项选择弹窗:列表仅高亮待定项,点确定后才切换模块 -->
<van-action-sheet v-model:show="showModulePicker"
title="选择检测模块">
<div class="module-picker-list">
<div v-for="bigModule in bigModules"
:key="bigModule.key"
class="module-picker-item"
:class="{ selected: bigModule.key === activeBigKey }"
@click="onSelectBigModule(bigModule)">
<span class="picker-label">{{ bigModule.label }}</span>
<van-icon v-if="bigModule.key === activeBigKey"
color="#477ffe"
name="success"
size="16" />
<div class="module-picker-sheet">
<div class="module-picker-list">
<div v-for="bigModule in bigModules"
:key="bigModule.key"
class="module-picker-item"
:class="{ selected: bigModule.key === pendingModuleKey }"
@click="setPendingModuleKey(bigModule.key)">
<span class="picker-label">{{ bigModule.label }}</span>
<van-icon v-if="bigModule.key === pendingModuleKey"
color="#477ffe"
name="success"
size="16" />
</div>
</div>
<div class="module-picker-footer">
<van-button class="module-picker-btn-cancel"
plain
round
type="primary"
@click="onCancelModulePicker">
取消
</van-button>
<van-button block
class="module-picker-btn-confirm"
color="#477ffe"
round
type="primary"
@click="onConfirmModulePicker">
确定
</van-button>
</div>
</div>
</van-action-sheet>
......@@ -156,13 +175,15 @@
</template>
<script setup lang="ts">
import { onMounted, ref } from "vue";
import type { BigModule } from "@/types/views/car-detail";
import { onMounted, ref, watch } from "vue";
import { useRoute } from "vue-router";
import customizeForm from "@/components/CustomizeForm/Index.vue";
import ScoreForm from "./components/ScoreForm.vue";
import { isCompletedFlagFieldDone, SCORE_BIG_KEY, useInspectModules } from "./composables/useInspectModules";
import { isSubTabMarkCompleted, SCORE_BIG_KEY, useInspectModules } from "./composables/useInspectModules";
import { useInspectSubmit } from "./composables/useInspectSubmit";
const route = useRoute();
......@@ -192,13 +213,35 @@ const {
showInspectionProgressBar,
progressTotal,
progressDone,
remainingSubTabCount,
isLastSubTabOfActiveBigModule,
activeSubTab,
currentLeafNodes,
initializeInspection,
onOpenModulePicker,
} = modules;
/** 弹窗内待确认的模块 key,打开时与当前 active 同步 */
const pendingModuleKey = ref<number | string>("");
function setPendingModuleKey(key: number | string) {
pendingModuleKey.value = key;
}
watch(showModulePicker, (open: boolean) => {
if (open) pendingModuleKey.value = activeBigKey.value;
});
function onCancelModulePicker() {
showModulePicker.value = false;
}
async function onConfirmModulePicker() {
const list: BigModule[] = bigModules.value;
const picked = list.find((m) => m.key === pendingModuleKey.value);
if (picked) await onSelectBigModule(picked);
else showModulePicker.value = false;
}
onMounted(() => {
initializeInspection();
});
......@@ -221,7 +264,7 @@ onMounted(() => {
// ===== 顶部区(透明,跟随页面背景) =====
.inspect-top {
flex-shrink: 0;
padding: calc(env(safe-area-inset-top) + 12px) $spacing-base 12px;
padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
}
.inspect-nav {
......@@ -251,8 +294,8 @@ onMounted(() => {
}
.nav-module-arrow {
color: #333333;
font-weight: 600;
color: #333;
transition: $transition-fast;
}
}
......@@ -344,7 +387,7 @@ onMounted(() => {
display: flex;
flex-shrink: 0;
gap: 10px;
padding: 10px $spacing-base;
padding: 10px 16px;
overflow-x: auto;
background: #fff linear-gradient(180deg, #e8efff 0%, #fff 100%);
border-radius: 12px 12px 0 0;
......@@ -387,14 +430,13 @@ onMounted(() => {
.inspect-subtab-scroll {
flex: 1;
min-height: 0;
overflow-x: hidden;
overflow-y: auto;
overflow: hidden auto;
-webkit-overflow-scrolling: touch;
}
// ===== 中间内容区(高度自适应,不独立滚动) =====
.inspect-content {
padding: 0 $spacing-base $spacing-base;
padding: 0 16px 16px;
}
// ===== 加载状态 =====
......@@ -434,7 +476,7 @@ onMounted(() => {
flex-shrink: 0;
gap: $spacing-md;
align-items: center;
padding: 10px $spacing-base calc(10px + env(safe-area-inset-bottom));
padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
background-color: $color-bg-card;
box-shadow: 0 -2px 10px rgb(0 0 0 / 8%);
......@@ -450,15 +492,44 @@ onMounted(() => {
// ===== 大项选择弹窗 =====
.module-picker-sheet {
display: flex;
flex-direction: column;
max-height: min(70vh, 520px);
}
.module-picker-list {
padding: $spacing-sm 0 calc($spacing-sm + env(safe-area-inset-bottom));
flex: 1;
min-height: 0;
padding: $spacing-sm 0;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.module-picker-footer {
display: flex;
flex-shrink: 0;
gap: $spacing-md;
align-items: center;
padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
background-color: $color-bg-card;
box-shadow: 0 -2px 10px rgb(0 0 0 / 8%);
.module-picker-btn-cancel {
flex-shrink: 0;
width: 88px;
}
.module-picker-btn-confirm {
flex: 1;
}
}
.module-picker-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14px $spacing-base;
padding: 14px 16px;
cursor: pointer;
transition: $transition-fast;
......
......@@ -216,7 +216,7 @@ void onRefresh();
.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;
......
......@@ -143,6 +143,7 @@ async function onRefresh() {
function onStatusChange(status: WorkOrderStatus) {
activeStatus.value = status;
keyword.value = "";
}
function startCheck(item: WorkOrderItem) {
......@@ -163,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) {
......@@ -505,13 +509,14 @@ void onRefresh();
.card-bottom {
min-width: 0;
font-size: 12px;
.k {
margin-right: 6px;
color: #999ea8;
}
.v {
color: #666666;
color: #666;
}
}
......
......@@ -123,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>
......
......@@ -4,6 +4,6 @@ import LoginMobile from "./LoginMobile.vue";
</script>
<template>
<LoginMobile />
<LoginMobile />
</template>
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";
import { LOGIN_REDIRECT_KEY } from "@/config/constants";
import { showFailToast, showSuccessToast } from "vant";
export function useLogin() {
const router = useRouter();
......@@ -19,18 +17,18 @@ export function useLogin() {
/** 仅数字 + 长度上限;配合 Field type=digit,并兜底粘贴等非数字字符 */
watch(phone, (v) => {
const n = v.replace(/\D/g, "").slice(0, 11);
const n = v.replaceAll(/\D/g, "").slice(0, 11);
if (n !== v) phone.value = n;
});
watch(code, (v) => {
const n = v.replace(/\D/g, "").slice(0, 6);
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);
......@@ -51,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 {
......
......@@ -7,6 +7,7 @@ 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";
......@@ -39,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() {
......@@ -93,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"
......@@ -158,10 +159,10 @@ watch(
@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) {
......@@ -170,12 +171,13 @@ watch(
}
.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 {
......@@ -192,8 +194,6 @@ watch(
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%;
}
......@@ -216,8 +216,10 @@ watch(
.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;
......@@ -242,11 +244,11 @@ watch(
height: 44px;
font-size: 16px;
font-weight: 400;
color: #222222;
background: #ffffff;
color: #222;
background: #fff;
border-radius: 8px;
opacity: 1;
box-shadow: none;
opacity: 1;
&:active::before {
opacity: 0;
......
<script setup lang="ts">
import type { WorkOrderStatus } from "@/types/views/work-order-common";
import type {
InspectionWORespVO,
NodeVO,
......@@ -7,7 +8,6 @@ import type {
WorkOrderDetailRemote,
WorkOrderVehicle,
} from "@/types/views/work-order-detail";
import type { WorkOrderStatus } from "@/types/views/work-order-common";
import { computed, onMounted, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
......
......@@ -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";
const __filename = fileURLToPath(import.meta.url);
......@@ -13,83 +14,83 @@ 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!