Commit 4edfd455 by 前端

Merge branch 'release/venus-usedcar-h5/1.0.0' into 'master'

Release/venus usedcar h5/1.0.0

See merge request !21
2 parents dbb18679 5663883b
Pipeline #216 for 4edfd455 failed in 0 seconds
...@@ -51,12 +51,56 @@ export interface CompleteInspectionParams { ...@@ -51,12 +51,56 @@ export interface CompleteInspectionParams {
taskId: number | string; taskId: number | string;
} }
/** `completeInspection` 成功时 `data`:有未完成项时带首项节点信息(多为大项 rootNodeId) */ /** `completeInspection` 成功时 `data`:有未完成项时带分级节点信息 */
export interface CompleteInspectionResultData { export interface CompleteInspectionResultData {
firstUncompletedLv1NodeId?: null | number | string;
firstUncompletedLv1NodeName?: null | string;
firstUncompletedLv2NodeId?: null | number | string;
firstUncompletedLv2NodeName?: null | string;
firstUncompletedLv3NodeId?: null | number | string;
firstUncompletedLv3NodeName?: null | string;
/** 旧版接口字段,兼容 */
firstUncompletedNodeId?: null | number | string; firstUncompletedNodeId?: null | number | string;
firstUncompletedNodeName?: null | string; firstUncompletedNodeName?: null | string;
} }
function isNonemptyCompleteInspectionNodeId(id: unknown): id is number | string {
if (id === undefined || id === null) return false;
if (typeof id === "string" && id.trim() === "") return false;
return true;
}
/** 提交评分返回里是否仍有未完成项(存在可用于跳转的节点 id) */
export function hasCompleteInspectionUncompletedHint(data: CompleteInspectionResultData | undefined): boolean {
return getCompleteInspectionUncompletedNavigateTarget(data) !== null;
}
/**
* 未完成项:优先按二级节点跳转;无二级 id 时回退一级或旧字段。
* 提示文案优先三级名称(最细),其次二级、一级。
*/
export function getCompleteInspectionUncompletedNavigateTarget(
data: CompleteInspectionResultData | undefined
): { nodeId: number | string; toastName: string | undefined } | null {
if (!data) return null;
let nodeId: number | string | null = null;
if (isNonemptyCompleteInspectionNodeId(data.firstUncompletedLv2NodeId)) {
nodeId = data.firstUncompletedLv2NodeId;
} else if (isNonemptyCompleteInspectionNodeId(data.firstUncompletedLv1NodeId)) {
nodeId = data.firstUncompletedLv1NodeId;
} else if (isNonemptyCompleteInspectionNodeId(data.firstUncompletedNodeId)) {
nodeId = data.firstUncompletedNodeId;
}
if (nodeId === null) return null;
const toastName =
(data.firstUncompletedLv3NodeName && String(data.firstUncompletedLv3NodeName)) ||
(data.firstUncompletedLv2NodeName && String(data.firstUncompletedLv2NodeName)) ||
(data.firstUncompletedLv1NodeName && String(data.firstUncompletedLv1NodeName)) ||
(data.firstUncompletedNodeName && String(data.firstUncompletedNodeName)) ||
undefined;
return { nodeId, toastName };
}
/** /**
* 完成检测(提交检测评分) * 完成检测(提交检测评分)
*/ */
......
...@@ -60,8 +60,16 @@ export function getWorkOrderPage(params: WorkOrderListParams) { ...@@ -60,8 +60,16 @@ export function getWorkOrderPage(params: WorkOrderListParams) {
return post<WorkOrderPageData<WorkOrderRemoteItem>>("/rest/inspect/wo/page", params); return post<WorkOrderPageData<WorkOrderRemoteItem>>("/rest/inspect/wo/page", params);
} }
export function getWorkOrderCountByStatus() { export interface WorkOrderCountParams {
return get<WorkOrderCountData>("/rest/inspect/wo/countByStatus"); keyword?: string;
}
export function getWorkOrderCountByStatus(params?: WorkOrderCountParams) {
const keyword = params?.keyword?.trim();
return get<WorkOrderCountData>(
"/rest/inspect/wo/countByStatus",
keyword ? { keyword } : undefined
);
} }
export type WorkOrderDetailResult<T = unknown> = T; export type WorkOrderDetailResult<T = unknown> = T;
......
<script setup lang="ts"> <script setup lang="ts">
import type { CustomizeFormValidateResult } from "@/types/views/car-detail"; import type { CustomizeFormValidateResult } from "@/types/views/car-detail";
import type { InspectionNode, InspectionTemplateDefaultData } from "@api"; import {
formatInspectionDateSubmitValue,
getInspectionLeafInputInitial,
getInspectionLeafSelectInitial,
type InspectionNode,
type InspectionTemplateDefaultData,
} from "@api";
import { ref, watch } from "vue"; import { ref, watch } from "vue";
...@@ -43,13 +49,28 @@ const rules = ref({}); ...@@ -43,13 +49,28 @@ const rules = ref({});
// 加载中 // 加载中
const pageLoading = ref(false); const pageLoading = ref(false);
watch(() => props.leafNodes, (nodes) => { const SELECT_INTERACTION_TYPES = new Set(["dropdown", "radio_button_select"]);
pageLoading.value = true;
columnsList.value = (nodes || []).map((item) => ({ function mapLeafNodeToColumnRow(item: InspectionNode): InspectionColumnRow {
const row: InspectionColumnRow = {
...item, ...item,
resultStatus: item?.inspectionResultVO?.resultStatus == 3 ? true : false, resultStatus: item?.inspectionResultVO?.resultStatus == 3 ? true : false,
value: getValueText(item), value: "",
})) as InspectionColumnRow[]; };
if (SELECT_INTERACTION_TYPES.has(String(item.interactionType ?? ""))) {
const { value, valueKey, valueText } = getInspectionLeafSelectInitial(item);
row.value = value;
row.valueKey = valueKey;
row.valueText = valueText;
return row;
}
row.value = getInspectionLeafInputInitial(item);
return row;
}
watch(() => props.leafNodes, (nodes) => {
pageLoading.value = true;
columnsList.value = (nodes || []).map((item) => mapLeafNodeToColumnRow(item)) as InspectionColumnRow[];
console.log('leafNodes', columnsList.value); console.log('leafNodes', columnsList.value);
...@@ -65,20 +86,6 @@ onMounted(() => { ...@@ -65,20 +86,6 @@ onMounted(() => {
}, 1200); }, 1200);
}); });
function getValueText(item: any) {
let valueText = "";
if (item?.inspectionResultVO) {
const inspectionValueList = item?.inspectionResultVO?.inspectionValueList || [];
if (inspectionValueList && inspectionValueList.length > 0) {
const inputList = ["text_input", "textarea_input", "number_input", "date_picker"];
if (inputList.includes(item.interactionType)) {
valueText = inspectionValueList[0].valueText || "";
}
}
}
return valueText;
}
// 提交数据 // 提交数据
function setSubmitData() { function setSubmitData() {
const returnData: { const returnData: {
...@@ -93,9 +100,13 @@ function setSubmitData() { ...@@ -93,9 +100,13 @@ function setSubmitData() {
const inputList = ["text_input", "textarea_input", "number_input", "date_picker"]; const inputList = ["text_input", "textarea_input", "number_input", "date_picker"];
const dropdownList = ["dropdown", "radio_button_select"]; const dropdownList = ["dropdown", "radio_button_select"];
if (inputList.includes(item.interactionType) && item.value != null && item.value !== "") { if (inputList.includes(item.interactionType) && item.value != null && item.value !== "") {
const valueText =
item.interactionType === "date_picker"
? formatInspectionDateSubmitValue(item.value, item as InspectionNode)
: String(item.value ?? "");
const pushData = { const pushData = {
id: item.id, id: item.id,
valueText: item.value || "", valueText,
valueKey: "", valueKey: "",
interactionType: item.interactionType, interactionType: item.interactionType,
}; };
...@@ -283,7 +294,7 @@ defineExpose({ ...@@ -283,7 +294,7 @@ defineExpose({
<van-form ref="customizeFormRef" :model="form" :rules="rules"> <van-form ref="customizeFormRef" :model="form" :rules="rules">
<div v-for="(item, index) in columnsList" :key="index" class="customizeList" :class="{ <div v-for="(item, index) in columnsList" :key="item.id ?? index" class="customizeList" :class="{
'border-bottom': (index < columnsList.length - 1 && item.interactionType != 'image_upload') || item.interactionType == 'textarea_input', 'border-bottom': (index < columnsList.length - 1 && item.interactionType != 'image_upload') || item.interactionType == 'textarea_input',
'customizeList50': setImgWidth(item) 'customizeList50': setImgWidth(item)
}"> }">
......
<script setup lang="ts"> <script setup lang="ts">
import { getInspectionLeafSelectInitial } from "@api";
import { computed, onMounted, ref } from "vue"; import { computed, onMounted, ref } from "vue";
const props = defineProps({ const props = defineProps({
...@@ -16,15 +17,9 @@ onMounted(() => { ...@@ -16,15 +17,9 @@ onMounted(() => {
initData(); initData();
}); });
// 初始化数据
function initData() { function initData() {
pickerValue.value = ""; const { valueKey } = getInspectionLeafSelectInitial(props.item);
if (props?.item?.inspectionResultVO) { pickerValue.value = valueKey;
const inspectionValueList = props?.item?.inspectionResultVO?.inspectionValueList || [];
if (inspectionValueList && inspectionValueList.length > 0) {
pickerValue.value = inspectionValueList[0].valueKey || "";
}
}
} }
// 计算属性 // 计算属性
......
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, ref } from "vue"; import { formatInspectionDateSubmitValue, getDatePickerColumnsType } from "@api";
import { computed, onMounted, ref, watch } from "vue";
const props = defineProps({ const props = defineProps({
item: { item: {
...@@ -10,52 +11,73 @@ const props = defineProps({ ...@@ -10,52 +11,73 @@ const props = defineProps({
const emit = defineEmits(["update"]); const emit = defineEmits(["update"]);
/** 日期选择最早可选:1990-01-01(年月模式为 1990-01) */
const MIN_PICKER_DATE = new Date(1990, 0, 1);
const displayValue = computed({ const displayValue = computed({
get: () => String(props.item.value ?? ""), get: () => String(props.item.value ?? ""),
set: (v: string) => emit("update", v), set: (v: string) => emit("update", v),
}); });
const columnsType = ref(["year", "month", "day"]); const columnsType = ref<("year" | "month" | "day")[]>(["year", "month", "day"]);
const showPicker = ref(false); const showPicker = ref(false);
const pickerValue = ref([]); const pickerValue = ref([]);
// 页面加载时初始化数据 function syncColumnsType() {
columnsType.value = getDatePickerColumnsType(props.item);
}
onMounted(() => { onMounted(() => {
initData(); syncColumnsType();
}); });
// 初始化数据 watch(
function initData() { () => props.item?.validationRules,
const validationRules = JSON.parse(props.item.validationRules || "{}"); () => {
if (validationRules.datePattern && validationRules.datePattern.length > 8) { syncColumnsType();
columnsType.value = ["year", "month", "day"]; }
} else { );
columnsType.value = ["year", "month"];
function clampPickerParts(parts: (number | string)[]): (number | string)[] {
const year = Number(parts[0]);
const month = Number(parts[1] ?? 1);
const day = Number(parts[2] ?? 1);
const clampedYear = Math.max(year, MIN_PICKER_DATE.getFullYear());
const clampedMonth =
clampedYear === MIN_PICKER_DATE.getFullYear()
? Math.max(month, MIN_PICKER_DATE.getMonth() + 1)
: month;
if (columnsType.value.length === 2) {
return [clampedYear, clampedMonth];
} }
const clampedDay =
clampedYear === MIN_PICKER_DATE.getFullYear() &&
clampedMonth === MIN_PICKER_DATE.getMonth() + 1
? Math.max(day, MIN_PICKER_DATE.getDate())
: day;
return [clampedYear, clampedMonth, clampedDay];
} }
function handleShowPicker() { function handleShowPicker() {
showPicker.value = true; showPicker.value = true;
if (!props.item.value) { if (!props.item.value) {
const date = new Date(); const date = new Date();
if (columnsType.value.length === 2) { const parts =
pickerValue.value = [date.getFullYear(), date.getMonth() + 1]; columnsType.value.length === 2
} else { ? [date.getFullYear(), date.getMonth() + 1]
pickerValue.value = [date.getFullYear(), date.getMonth() + 1, date.getDate()]; : [date.getFullYear(), date.getMonth() + 1, date.getDate()];
} pickerValue.value = clampPickerParts(parts);
} else { } else {
const dateArr = props.item.value.split("-"); const dateArr = props.item.value.split("-").map((v) => Number(v) || v);
if (columnsType.value.length === 2) { pickerValue.value = clampPickerParts(dateArr);
pickerValue.value = [dateArr[0], dateArr[1]];
} else {
pickerValue.value = dateArr;
}
} }
} }
function onConfirm() { function onConfirm() {
let picker = ""; let picker = "";
if (pickerValue.value.length > 0) { if (pickerValue.value.length > 0) {
picker = pickerValue.value.join("-"); const clamped = clampPickerParts(pickerValue.value);
pickerValue.value = clamped;
picker = formatInspectionDateSubmitValue(clamped.join("-"), props.item);
} }
showPicker.value = false; showPicker.value = false;
emit("update", picker); emit("update", picker);
...@@ -77,8 +99,14 @@ function getLabelWidth(nodeName: string) { ...@@ -77,8 +99,14 @@ function getLabelWidth(nodeName: string) {
:placeholder="item.placeholder" readonly :required="item.required === 1" @click="handleShowPicker" :placeholder="item.placeholder" readonly :required="item.required === 1" @click="handleShowPicker"
input-align="right" :label-width="getLabelWidth(item.nodeName) + 'px'" /> input-align="right" :label-width="getLabelWidth(item.nodeName) + 'px'" />
<van-popup v-model:show="showPicker" destroy-on-close position="bottom" teleport="#vant-portal-host"> <van-popup v-model:show="showPicker" destroy-on-close position="bottom" teleport="#vant-portal-host">
<van-date-picker v-model="pickerValue" :columns-type="columnsType" :title="item.nodeName" <van-date-picker
@cancel="showPicker = false" @confirm="onConfirm" /> v-model="pickerValue"
:columns-type="columnsType"
:min-date="MIN_PICKER_DATE"
:title="item.nodeName"
@cancel="showPicker = false"
@confirm="onConfirm"
/>
</van-popup> </van-popup>
</div> </div>
</template> </template>
......
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, ref } from "vue"; import { getInspectionLeafSelectInitial } from "@api";
import { computed, onMounted, ref, watch } from "vue";
const props = defineProps({ const props = defineProps({
item: { item: {
...@@ -8,13 +9,13 @@ const props = defineProps({ ...@@ -8,13 +9,13 @@ const props = defineProps({
}, },
carTypeList: { carTypeList: {
type: Array, type: Array,
default: () => {}, default: () => [],
}, },
}); });
const emit = defineEmits(["update"]); const emit = defineEmits(["update"]);
const showPicker = ref(false); const showPicker = ref(false);
const pickerValue = ref([]); const pickerValue = ref<string[]>([]);
const displayValueText = computed({ const displayValueText = computed({
get: () => String(props.item.valueText ?? ""), get: () => String(props.item.valueText ?? ""),
...@@ -31,27 +32,8 @@ const displayValueText = computed({ ...@@ -31,27 +32,8 @@ const displayValueText = computed({
}, },
}); });
// 页面加载时初始化数据
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();
}
// 计算属性
const columnsList = computed(() => { const columnsList = computed(() => {
const optionsList = JSON.parse(props.item.options || "[]").map(item => { const optionsList = JSON.parse(props.item.options || "[]").map((item: string) => {
const valueList = (item || "").split("-"); const valueList = (item || "").split("-");
return { return {
text: valueList[1] || "", text: valueList[1] || "",
...@@ -61,23 +43,84 @@ const columnsList = computed(() => { ...@@ -61,23 +43,84 @@ const columnsList = computed(() => {
return props.item.nodeName === "车型" ? props.carTypeList : optionsList; return props.item.nodeName === "车型" ? props.carTypeList : optionsList;
}); });
function emitSelection(value: string, valueText: string, valueKey: string) {
const item = props.item as { value?: string; valueKey?: string; valueText?: string };
if (
String(item?.value ?? "") === value &&
String(item?.valueText ?? "") === valueText &&
String(item?.valueKey ?? "") === valueKey
) {
return;
}
emit("update", { value, valueText, valueKey });
}
function findColumn(valueKey: string, valueText: string) {
const cols = columnsList.value as { text?: string; value?: string }[];
if (valueKey) {
const byKey = cols.find((col) => col.value === valueKey);
if (byKey) return byKey;
}
if (valueText) {
return cols.find((col) => col.text === valueText || col.value === valueText);
}
return undefined;
}
/** 从 VO / 节点字段 / resolvedInitialValue 回显,无有效选中时不 emit 空值 */
function initData() {
const { valueKey, valueText } = getInspectionLeafSelectInitial(props.item);
if (!valueKey && !valueText) {
pickerValue.value = [];
return;
}
const selected = findColumn(valueKey, valueText);
if (selected?.value !== undefined && selected.value !== "") {
pickerValue.value = [String(selected.value)];
emitSelection(String(selected.value), String(selected.text ?? ""), String(selected.value));
return;
}
pickerValue.value = valueKey ? [valueKey] : [];
emitSelection(valueKey, valueText, valueKey || valueText);
}
onMounted(() => {
initData();
});
watch(
() => props.carTypeList,
() => {
if (props.item?.nodeName === "车型") {
initData();
}
}
);
function onConfirm() { function onConfirm() {
const picker = pickerValue.value && pickerValue.value.length > 0 ? pickerValue.value[0] : ""; const picker =
pickerValue.value && pickerValue.value.length > 0 ? pickerValue.value[0] : "";
showPicker.value = false; showPicker.value = false;
const selected = columnsList.value.find((col) => col.value === picker) || {}; if (!picker) {
emit("update", { const { valueKey, valueText } = getInspectionLeafSelectInitial(props.item);
value: selected.value || "", if (valueKey || valueText) {
valueText: selected.text || "", return;
valueKey: selected.value || "", }
}); emitSelection("", "", "");
return;
}
const selected =
(columnsList.value as { text?: string; value?: string }[]).find((col) => col.value === picker) ||
{};
emitSelection(String(selected.value ?? ""), String(selected.text ?? ""), String(selected.value ?? ""));
} }
function getLabelWidth(nodeName: string) { function getLabelWidth(nodeName: string) {
let widtPx = 76; let widtPx = 76;
if (nodeName.length > 4) { if (nodeName.length > 4) {
widtPx = widtPx + ((nodeName.length - 4) * 12); widtPx = widtPx + (nodeName.length - 4) * 12;
} }
return widtPx; return widtPx;
} }
...@@ -85,7 +128,8 @@ function getLabelWidth(nodeName: string) { ...@@ -85,7 +128,8 @@ function getLabelWidth(nodeName: string) {
<template> <template>
<div> <div>
<van-field v-model="displayValueText" <van-field
v-model="displayValueText"
clearable clearable
is-link is-link
:label="item.nodeName" :label="item.nodeName"
...@@ -93,16 +137,23 @@ function getLabelWidth(nodeName: string) { ...@@ -93,16 +137,23 @@ function getLabelWidth(nodeName: string) {
:placeholder="item.placeholder" :placeholder="item.placeholder"
readonly readonly
:required="item.required === 1" :required="item.required === 1"
@click="showPicker = true" input-align="right" :label-width="getLabelWidth(item.nodeName) + 'px'" /> input-align="right"
<van-popup v-model:show="showPicker" :label-width="getLabelWidth(item.nodeName) + 'px'"
@click="showPicker = true"
/>
<van-popup
v-model:show="showPicker"
destroy-on-close destroy-on-close
position="bottom" position="bottom"
teleport="#vant-portal-host"> teleport="#vant-portal-host"
<van-picker v-model="pickerValue" >
<van-picker
v-model="pickerValue"
:columns="columnsList" :columns="columnsList"
:title="item.nodeName" :title="item.nodeName"
@cancel="showPicker = false" @cancel="showPicker = false"
@confirm="onConfirm" /> @confirm="onConfirm"
/>
</van-popup> </van-popup>
</div> </div>
</template> </template>
......
...@@ -184,11 +184,7 @@ ...@@ -184,11 +184,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ScoreRatingOption } from "@/types/views/car-detail"; import type { ScoreRatingOption } from "@/types/views/car-detail";
import type { import type { CompleteInspectionParams, InspectionScoreVO } from "@api";
CompleteInspectionParams,
InspectionChildrenData,
InspectionScoreVO,
} from "@api";
import type { RatingGuideConfig } from "./rating-guide-content"; import type { RatingGuideConfig } from "./rating-guide-content";
...@@ -197,7 +193,7 @@ import { reactive, ref, watch } from "vue"; ...@@ -197,7 +193,7 @@ import { reactive, ref, watch } from "vue";
import ratingSelectedCheckImg from "@/assets/image/rating-selected-check.png"; import ratingSelectedCheckImg from "@/assets/image/rating-selected-check.png";
import systemTipImg from "@/assets/image/system-tip.png"; import systemTipImg from "@/assets/image/system-tip.png";
import { SCORE_RATING_OPTIONS as RATING_OPTIONS } from "@/types/views/car-detail"; import { SCORE_RATING_OPTIONS as RATING_OPTIONS } from "@/types/views/car-detail";
import { getInspectionChildren } from "@api"; import { extractInspectionScoreVO, getInspectionChildren } from "@api";
import { isRequestFailureAlreadyHandled } from "@utils/request"; import { isRequestFailureAlreadyHandled } from "@utils/request";
import { showToast } from "vant"; import { showToast } from "vant";
...@@ -242,28 +238,6 @@ function onRatingGuideShow(v: boolean) { ...@@ -242,28 +238,6 @@ function onRatingGuideShow(v: boolean) {
ratingGuideOpen.value = v; ratingGuideOpen.value = v;
} }
function extractInspectionScoreVO(raw: InspectionChildrenData): InspectionScoreVO | null {
if (!raw || typeof raw !== "object") {
return null;
}
/** `rootNodeId === -1` 时接口常返回 `[{ id: -1, inspectionScoreVO: {...}, ... }]`,与单对象两种形态 */
if (Array.isArray(raw)) {
for (const item of raw) {
if (!item || typeof item !== "object") continue;
const vo = (item as { inspectionScoreVO?: unknown }).inspectionScoreVO;
if (vo && typeof vo === "object") {
return vo as InspectionScoreVO;
}
}
return null;
}
const vo = raw.inspectionScoreVO;
if (!vo || typeof vo !== "object") {
return null;
}
return vo;
}
function scoreFieldToNumber(value: unknown, fallback = 0): number { function scoreFieldToNumber(value: unknown, fallback = 0): number {
if (value === null || value === undefined || value === "") { if (value === null || value === undefined || value === "") {
return fallback; return fallback;
......
import type { BigModule, SubTab } from "@/types/views/car-detail"; import type { BigModule, SubTab } from "@/types/views/car-detail";
import type { import type { InspectionNode, InspectionResultVO, InspectionTemplateDefaultData } from "@api";
CompleteInspectionResultData,
InspectionNode,
InspectionResultVO,
InspectionTemplateDefaultData,
} from "@api";
import type { RouteLocationNormalizedLoaded } from "vue-router"; import type { RouteLocationNormalizedLoaded } from "vue-router";
...@@ -12,9 +7,11 @@ import { computed, ref } from "vue"; ...@@ -12,9 +7,11 @@ import { computed, ref } from "vue";
import { import {
applyResolvedInitialValuesToLeafNodes, applyResolvedInitialValuesToLeafNodes,
extractInspectionScoreVO,
getInspectionChildren, getInspectionChildren,
getInspectionRootNodes, getInspectionRootNodes,
getInspectionTemplateDefault, getInspectionTemplateDefault,
resolveScoreModuleCompletedFlag,
} from "@api"; } from "@api";
import { isRequestFailureAlreadyHandled } from "@utils/request"; import { isRequestFailureAlreadyHandled } from "@utils/request";
import { showToast } from "vant"; import { showToast } from "vant";
...@@ -64,15 +61,6 @@ function secondaryProgressOrFallback(module: BigModule): { done: number; total: ...@@ -64,15 +61,6 @@ function secondaryProgressOrFallback(module: BigModule): { done: number; total:
}; };
} }
/** 提交评分返回里是否仍有未完成项(`firstUncompletedNodeId` 有有效值) */
export function hasCompleteInspectionUncompletedHint(data: CompleteInspectionResultData | undefined): boolean {
if (!data) return false;
const id = data.firstUncompletedNodeId;
if (id === undefined || id === null) return false;
if (typeof id === "string" && id.trim() === "") return false;
return true;
}
export function useInspectModules(route: RouteLocationNormalizedLoaded) { export function useInspectModules(route: RouteLocationNormalizedLoaded) {
const taskId = ref<number | string>(""); const taskId = ref<number | string>("");
const bigModules = ref<BigModule[]>([]); const bigModules = ref<BigModule[]>([]);
...@@ -160,6 +148,15 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) { ...@@ -160,6 +148,15 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
const scoreRoot = rootNodes.find((root) => String(root.id) === "-1"); const scoreRoot = rootNodes.find((root) => String(root.id) === "-1");
const inspectionRoots = rootNodes.filter((root) => String(root.id) !== "-1"); const inspectionRoots = rootNodes.filter((root) => String(root.id) !== "-1");
let scoreVo = null;
try {
const scoreRaw = await getInspectionChildren(-1, taskId.value);
scoreVo = extractInspectionScoreVO(scoreRaw);
} catch (error) {
console.error("刷新检测评分完成状态失败:", error);
}
const scoreCompletedFlag = resolveScoreModuleCompletedFlag(scoreRoot, scoreVo);
const refreshedInspectionModules: BigModule[] = inspectionRoots.map((root) => { const refreshedInspectionModules: BigModule[] = inspectionRoots.map((root) => {
const prev = oldByKey.get(String(root.id)); const prev = oldByKey.get(String(root.id));
return { return {
...@@ -176,7 +173,7 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) { ...@@ -176,7 +173,7 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
const scoreModule: BigModule = { const scoreModule: BigModule = {
key: SCORE_BIG_KEY, key: SCORE_BIG_KEY,
label: "检测评分", label: "检测评分",
completedFlag: scoreRoot?.completedFlag as 0 | 1 | string | undefined, completedFlag: scoreCompletedFlag,
subTabs: prevScore?.subTabs ?? [], subTabs: prevScore?.subTabs ?? [],
hasSecondaryTabs: prevScore?.hasSecondaryTabs, hasSecondaryTabs: prevScore?.hasSecondaryTabs,
secondaryProgress: prevScore?.secondaryProgress, secondaryProgress: prevScore?.secondaryProgress,
...@@ -400,6 +397,7 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) { ...@@ -400,6 +397,7 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
switchToUncompletedInspectionNode, switchToUncompletedInspectionNode,
advanceInspectionStep, advanceInspectionStep,
onOpenModulePicker, onOpenModulePicker,
refreshBigModulesFromRootNodes,
}; };
} }
......
...@@ -11,16 +11,15 @@ import { useRouter } from "vue-router"; ...@@ -11,16 +11,15 @@ import { useRouter } from "vue-router";
import customizeForm from "@/components/CustomizeForm/Index.vue"; import customizeForm from "@/components/CustomizeForm/Index.vue";
import { import {
completeInspection, completeInspection,
getCompleteInspectionUncompletedNavigateTarget,
hasCompleteInspectionUncompletedHint,
saveInspectionRecord, saveInspectionRecord,
} from "@api"; } from "@api";
import { isRequestFailureAlreadyHandled } from "@utils/request"; import { isRequestFailureAlreadyHandled } from "@utils/request";
import { showToast } from "vant"; import { showToast } from "vant";
import ScoreForm from "../components/ScoreForm.vue"; import ScoreForm from "../components/ScoreForm.vue";
import { import { SCORE_BIG_KEY } from "./useInspectModules";
hasCompleteInspectionUncompletedHint,
SCORE_BIG_KEY,
} from "./useInspectModules";
/** 底部操作区:仅当前点击的按钮显示 loading */ /** 底部操作区:仅当前点击的按钮显示 loading */
type FooterLoadingKey = "idle" | "prev" | "next" | "score"; type FooterLoadingKey = "idle" | "prev" | "next" | "score";
...@@ -213,8 +212,10 @@ export function useInspectSubmit( ...@@ -213,8 +212,10 @@ export function useInspectSubmit(
inspectionScoreFormRef.value.getCompleteInspectionPayload(modules.taskId.value) inspectionScoreFormRef.value.getCompleteInspectionPayload(modules.taskId.value)
); );
if (result && hasCompleteInspectionUncompletedHint(result)) { if (result && hasCompleteInspectionUncompletedHint(result)) {
const name = result.firstUncompletedNodeName; await modules.refreshBigModulesFromRootNodes();
const nid = result.firstUncompletedNodeId; const target = getCompleteInspectionUncompletedNavigateTarget(result);
const name = target?.toastName;
const nid = target?.nodeId;
showToast( showToast(
name ? `检测未完成,请先完成「${name}」` : "检测未完成,请先完成未填项" name ? `检测未完成,请先完成「${name}」` : "检测未完成,请先完成未填项"
); );
......
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
class="inspect-card inspect-card--subtabs"> class="inspect-card inspect-card--subtabs">
<!-- 二级项 Tab:仅当子节点为分组(nodeType=2)等多级结构时展示;叶子直挂大项时不展示 --> <!-- 二级项 Tab:仅当子节点为分组(nodeType=2)等多级结构时展示;叶子直挂大项时不展示 -->
<div v-if="activeBigModule?.hasSecondaryTabs === true" <div v-if="activeBigModule?.hasSecondaryTabs === true"
ref="subtabRowRef"
class="subtab-row"> class="subtab-row">
<div v-for="subTab in activeBigModule?.subTabs" <div v-for="subTab in activeBigModule?.subTabs"
:key="subTab.key" :key="subTab.key"
...@@ -180,7 +181,7 @@ ...@@ -180,7 +181,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { BigModule } from "@/types/views/car-detail"; import type { BigModule } from "@/types/views/car-detail";
import { onMounted, ref, watch } from "vue"; import { nextTick, onMounted, ref, watch } from "vue";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import customizeForm from "@/components/CustomizeForm/Index.vue"; import customizeForm from "@/components/CustomizeForm/Index.vue";
...@@ -224,6 +225,39 @@ const { ...@@ -224,6 +225,39 @@ const {
onOpenModulePicker, onOpenModulePicker,
} = modules; } = modules;
const subtabRowRef = ref<HTMLElement | null>(null);
/** 下一步 / 上一步 / 检测评分返回等程序切换二级 Tab 时,将当前项滚入横向可视区 */
function scrollActiveSubTabIntoView() {
void nextTick(() => {
void nextTick(() => {
const row = subtabRowRef.value;
if (!row || activeBigModule.value?.hasSecondaryTabs !== true) return;
const activeEl = row.querySelector<HTMLElement>(".subtab-item.active");
activeEl?.scrollIntoView({
behavior: "smooth",
block: "nearest",
inline: "center",
});
});
});
}
watch(
[activeSubKey, activeBigKey],
() => {
if (loading.value || activeBigKey.value === SCORE_BIG_KEY) return;
scrollActiveSubTabIntoView();
},
{ flush: "post" }
);
watch(loading, (isLoading) => {
if (!isLoading) {
scrollActiveSubTabIntoView();
}
});
/** 弹窗内待确认的模块 key,打开时与当前 active 同步 */ /** 弹窗内待确认的模块 key,打开时与当前 active 同步 */
const pendingModuleKey = ref<number | string>(""); const pendingModuleKey = ref<number | string>("");
......
<script setup lang="ts"> <script setup lang="ts">
import type { ReportItem } from "@/types/views/car-list"; import type { ReportItem } from "@/types/views/car-list";
import { computed, onActivated, ref, watch } from "vue"; import { computed, onActivated, ref } from "vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { getInspectReportPage } from "@/api/modules/inspect-report"; import { getInspectReportPage } from "@/api/modules/inspect-report";
...@@ -9,8 +9,11 @@ import PageTop from "@/components/PageTop.vue"; ...@@ -9,8 +9,11 @@ import PageTop from "@/components/PageTop.vue";
const router = useRouter(); const router = useRouter();
const keyword = ref(""); const keywordInput = ref("");
/** 点击「搜索」后生效的查询词 */
const searchKeyword = ref("");
const refreshing = ref(false); const refreshing = ref(false);
const searchLoading = ref(false);
const loading = ref(false); const loading = ref(false);
const finished = ref(false); const finished = ref(false);
const pageSize = 10; const pageSize = 10;
...@@ -85,7 +88,7 @@ async function fillMore() { ...@@ -85,7 +88,7 @@ async function fillMore() {
const res = await getInspectReportPage({ const res = await getInspectReportPage({
size: pageSize, size: pageSize,
page: currentPage.value, page: currentPage.value,
keyword: keyword.value.trim() || undefined, keyword: searchKeyword.value || undefined,
}); });
const next = (res.content ?? []).map((x: unknown) => mapReportItem(x as Record<string, unknown>)); const next = (res.content ?? []).map((x: unknown) => mapReportItem(x as Record<string, unknown>));
...@@ -98,18 +101,45 @@ async function fillMore() { ...@@ -98,18 +101,45 @@ async function fillMore() {
} }
function onLoad() { function onLoad() {
if (refreshing.value) {
loading.value = false;
return;
}
void fillMore(); void fillMore();
} }
let refreshTask: Promise<void> | null = null;
async function onRefresh() { async function onRefresh() {
// 勿在开头判断 refreshing:PullRefresh 触发 @refresh 时 v-model 已为 true,会误 return 且无法执行 finally,下拉一直转圈 if (refreshTask) {
return refreshTask;
}
refreshing.value = true; refreshing.value = true;
refreshTask = (async () => {
try { try {
resetList(); resetList();
await fillMore(); await fillMore();
} finally { } finally {
refreshing.value = false; refreshing.value = false;
refreshTask = null;
} }
})();
return refreshTask;
}
async function onSearch() {
if (refreshTask) return;
searchLoading.value = true;
searchKeyword.value = keywordInput.value.trim();
try {
await onRefresh();
} finally {
searchLoading.value = false;
}
}
function onClearKeyword() {
keywordInput.value = "";
} }
/** 检测报告列表:查看报告优先使用行内 h5Url,否则进站内报告页 */ /** 检测报告列表:查看报告优先使用行内 h5Url,否则进站内报告页 */
...@@ -124,9 +154,6 @@ function onViewReport(item: ReportItem) { ...@@ -124,9 +154,6 @@ function onViewReport(item: ReportItem) {
} }
} }
watch([keyword], () => {
void onRefresh();
});
onActivated(() => { onActivated(() => {
// keepAlive: true 下首次进入与从子页返回都会触发;勿再在 setup 末尾调用 onRefresh,否则会并发两次 fillMore、第一页重复追加 // keepAlive: true 下首次进入与从子页返回都会触发;勿再在 setup 末尾调用 onRefresh,否则会并发两次 fillMore、第一页重复追加
...@@ -144,22 +171,30 @@ onActivated(() => { ...@@ -144,22 +171,30 @@ onActivated(() => {
color="#969799" color="#969799"
name="search" name="search"
size="16" /> size="16" />
<input v-model="keyword" <input v-model="keywordInput"
autocomplete="off" autocomplete="off"
class="round-search__input" class="round-search__input"
enterkeyhint="search"
placeholder="搜索报告号、车牌号、车型名称" placeholder="搜索报告号、车牌号、车型名称"
type="search" /> type="search" />
<button v-show="keyword" <button v-show="keywordInput"
aria-label="清除" aria-label="清除"
class="round-search__clear" class="round-search__clear"
type="button" type="button"
@click="keyword = ''"> @click="onClearKeyword">
<van-icon color="#c8c9cc" <van-icon color="#c8c9cc"
name="clear" name="clear"
size="18" /> size="18" />
</button> </button>
</div> </div>
<van-button class="round-search__submit"
color="#185efe"
:disabled="searchLoading || refreshing"
:loading="searchLoading"
round
size="small"
@click="onSearch">
搜索
</van-button>
</div> </div>
</div> </div>
</PageTop> </PageTop>
...@@ -246,6 +281,7 @@ onActivated(() => { ...@@ -246,6 +281,7 @@ onActivated(() => {
.round-search { .round-search {
display: flex; display: flex;
gap: 8px;
align-items: center; align-items: center;
box-sizing: border-box; box-sizing: border-box;
padding: 0; padding: 0;
...@@ -308,6 +344,21 @@ onActivated(() => { ...@@ -308,6 +344,21 @@ onActivated(() => {
border: 0; border: 0;
} }
.round-search__submit {
flex-shrink: 0;
height: 34px;
padding: 0 14px;
border: 0;
}
:deep(.round-search__submit.van-button) {
height: 34px;
padding: 0 14px;
font-size: 14px;
font-weight: 500;
line-height: 34px;
}
.list-wrap { .list-wrap {
flex: 1; flex: 1;
padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
......
...@@ -10,9 +10,12 @@ import PageTop from "@/components/PageTop.vue"; ...@@ -10,9 +10,12 @@ import PageTop from "@/components/PageTop.vue";
import WorkOrderStatusTags from "@/components/WorkOrderStatusTags.vue"; import WorkOrderStatusTags from "@/components/WorkOrderStatusTags.vue";
import searchIcon from "@assets/image/searchIcon.png"; import searchIcon from "@assets/image/searchIcon.png";
const keyword = ref(""); const keywordInput = ref("");
/** 点击「搜索」后生效的查询词 */
const searchKeyword = ref("");
const activeStatus = ref<WorkOrderStatus>(1); const activeStatus = ref<WorkOrderStatus>(1);
const refreshing = ref(false); const refreshing = ref(false);
const searchLoading = ref(false);
const loading = ref(false); const loading = ref(false);
const finished = ref(false); const finished = ref(false);
const pageSize = 20; const pageSize = 20;
...@@ -94,7 +97,8 @@ function mapWorkOrderItem(item: Record<string, unknown>): WorkOrderItem { ...@@ -94,7 +97,8 @@ function mapWorkOrderItem(item: Record<string, unknown>): WorkOrderItem {
async function fetchTabCounts() { async function fetchTabCounts() {
try { try {
const data = await getWorkOrderCountByStatus(); const keyword = searchKeyword.value.trim();
const data = await getWorkOrderCountByStatus(keyword ? { keyword } : undefined);
tabCounts.value = { tabCounts.value = {
dispatchedCount: data.dispatchedCount ?? 0, dispatchedCount: data.dispatchedCount ?? 0,
inProgressCount: data.inProgressCount ?? 0, inProgressCount: data.inProgressCount ?? 0,
...@@ -111,7 +115,7 @@ async function fillMore() { ...@@ -111,7 +115,7 @@ async function fillMore() {
size: pageSize, size: pageSize,
page: currentPage.value, page: currentPage.value,
status: activeStatus.value, status: activeStatus.value,
keyword: keyword.value.trim(), keyword: searchKeyword.value,
}); });
const next = (res.content ?? []).map((item: unknown) => const next = (res.content ?? []).map((item: unknown) =>
mapWorkOrderItem(item as unknown as Record<string, unknown>) mapWorkOrderItem(item as unknown as Record<string, unknown>)
...@@ -137,19 +141,44 @@ async function onLoad() { ...@@ -137,19 +141,44 @@ async function onLoad() {
} }
} }
let refreshTask: Promise<void> | null = null;
async function onRefresh() { async function onRefresh() {
if (refreshTask) {
return refreshTask;
}
refreshing.value = true; refreshing.value = true;
refreshTask = (async () => {
try { try {
resetList(); resetList();
await Promise.all([fetchTabCounts(), fillMore()]); await Promise.all([fetchTabCounts(), fillMore()]);
} finally { } finally {
refreshing.value = false; refreshing.value = false;
refreshTask = null;
} }
})();
return refreshTask;
}
async function onSearch() {
if (refreshTask) return;
searchLoading.value = true;
searchKeyword.value = keywordInput.value.trim();
try {
await onRefresh();
} finally {
searchLoading.value = false;
}
}
function onClearKeyword() {
keywordInput.value = "";
} }
function onStatusChange(status: WorkOrderStatus) { function onStatusChange(status: WorkOrderStatus) {
activeStatus.value = status; activeStatus.value = status;
keyword.value = ""; keywordInput.value = "";
searchKeyword.value = "";
} }
function startCheck(item: WorkOrderItem) { function startCheck(item: WorkOrderItem) {
...@@ -260,7 +289,7 @@ function getCardActions(item: WorkOrderItem): CardAction[] { ...@@ -260,7 +289,7 @@ function getCardActions(item: WorkOrderItem): CardAction[] {
/** 底部操作区统一拦冒泡,避免点到按钮与卡片间隙时仍触发整张卡的 viewWorkOrder */ /** 底部操作区统一拦冒泡,避免点到按钮与卡片间隙时仍触发整张卡的 viewWorkOrder */
function stopCardFooterBubbling() {} function stopCardFooterBubbling() {}
watch([keyword, activeStatus], () => { watch(activeStatus, () => {
void onRefresh(); void onRefresh();
}); });
...@@ -289,22 +318,30 @@ void onRefresh(); ...@@ -289,22 +318,30 @@ void onRefresh();
aria-hidden="true" aria-hidden="true"
class="round-search__icon" class="round-search__icon"
:src="searchIcon" /> :src="searchIcon" />
<input v-model="keyword" <input v-model="keywordInput"
autocomplete="off" autocomplete="off"
class="round-search__input" class="round-search__input"
enterkeyhint="search"
placeholder="搜索车牌号、VIN码、车型名称" placeholder="搜索车牌号、VIN码、车型名称"
type="search" /> type="search" />
<button v-show="keyword" <button v-show="keywordInput"
aria-label="清除" aria-label="清除"
class="round-search__clear" class="round-search__clear"
type="button" type="button"
@click="keyword = ''"> @click="onClearKeyword">
<van-icon color="#c8c9cc" <van-icon color="#c8c9cc"
name="clear" name="clear"
size="18" /> size="18" />
</button> </button>
</div> </div>
<van-button class="round-search__submit"
color="#185efe"
:disabled="searchLoading || refreshing"
:loading="searchLoading"
round
size="small"
@click="onSearch">
搜索
</van-button>
</div> </div>
</div> </div>
</PageTop> </PageTop>
...@@ -464,6 +501,7 @@ void onRefresh(); ...@@ -464,6 +501,7 @@ void onRefresh();
.round-search { .round-search {
display: flex; display: flex;
gap: 8px;
align-items: center; align-items: center;
box-sizing: border-box; box-sizing: border-box;
padding: 0; padding: 0;
...@@ -528,6 +566,21 @@ void onRefresh(); ...@@ -528,6 +566,21 @@ void onRefresh();
border: 0; border: 0;
} }
.round-search__submit {
flex-shrink: 0;
height: 34px;
padding: 0 14px;
border: 0;
}
:deep(.round-search__submit.van-button) {
height: 34px;
padding: 0 14px;
font-size: 14px;
font-weight: 500;
line-height: 34px;
}
.list-wrap { .list-wrap {
flex: 1; flex: 1;
padding: 12px; padding: 12px;
......
...@@ -377,7 +377,7 @@ onMounted(() => { ...@@ -377,7 +377,7 @@ onMounted(() => {
:src="CDN.certification" /> :src="CDN.certification" />
</div> </div>
<div class="cert-info"> <div class="cert-info">
<span class="cert-title">广联认证检测</span> <span class="cert-title">优加认证检测</span>
<span class="cert-sub">官方认证</span> <span class="cert-sub">官方认证</span>
</div> </div>
</div> </div>
...@@ -539,7 +539,7 @@ onMounted(() => { ...@@ -539,7 +539,7 @@ onMounted(() => {
</div> </div>
<ul class="score-desc__list"> <ul class="score-desc__list">
<li v-for="(desc, idx) in reportData.scoreDescriptions" :key="idx"> <li v-for="(desc, idx) in reportData.scoreDescriptions" :key="idx">
<span class="desc-label">{{ desc.label }}:</span>{{ desc.text }} <span class="desc-label">{{ desc.label }}:</span><span class="desc-text">{{ desc.text }}</span>
</li> </li>
</ul> </ul>
</div> </div>
...@@ -642,7 +642,7 @@ onMounted(() => { ...@@ -642,7 +642,7 @@ onMounted(() => {
<span class="video-info__mark">*</span> <span class="video-info__mark">*</span>
<span class="video-info__label">检测机构:</span> <span class="video-info__label">检测机构:</span>
</div> </div>
<span class="video-info__value">广联认证</span> <span class="video-info__value">优加认证</span>
</div> </div>
<div class="video-info__item"> <div class="video-info__item">
<div class="video-info__lead"> <div class="video-info__lead">
...@@ -1146,6 +1146,8 @@ onMounted(() => { ...@@ -1146,6 +1146,8 @@ onMounted(() => {
font-size: $font-size-sm; font-size: $font-size-sm;
line-height: 1.6; line-height: 1.6;
color: $color-text-secondary; color: $color-text-secondary;
overflow-wrap: anywhere;
word-break: break-word;
// padding: $spacing-md 0 $spacing-md 12px; // padding: $spacing-md 0 $spacing-md 12px;
// border-bottom: 1px solid #fff0d6; // border-bottom: 1px solid #fff0d6;
border-bottom: 1px solid #e6ebf5; border-bottom: 1px solid #e6ebf5;
...@@ -1170,6 +1172,12 @@ onMounted(() => { ...@@ -1170,6 +1172,12 @@ onMounted(() => {
.desc-label { .desc-label {
color: $color-text-primary; color: $color-text-primary;
white-space: nowrap;
}
.desc-text {
word-break: break-all;
overflow-wrap: anywhere;
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!