Commit ad64fdaa by chenwq1

feat: 新增中间

1 parent 27cec057
Pipeline #118 for ad64fdaa failed in 0 seconds
<script setup lang="ts">
import { ref, watch } from "vue";
import type { InspectionNode } from "@api";
import type { InspectionNode, InspectionTemplateDefaultData } from "@api";
import type { CustomizeFormValidateResult } from "@/types/views/car-detail";
import selectDatePicker from "@/components/CustomizeForm/selectDatePicker.vue";
import selectDropdown from "@/components/CustomizeForm/selectDropdown.vue";
......@@ -17,11 +17,14 @@ const props = withDefaults(
bigModuleLabel?: string;
subTabLabel?: string;
allowNoStructure?: boolean;
/** `getInspectionTemplateDefault` 解包后的 data(与 nodeCode 等字段对应) */
templateDefaultData?: InspectionTemplateDefaultData | null;
}>(), {
leafNodes: () => [],
bigModuleLabel: "",
subTabLabel: "",
allowNoStructure: false,
templateDefaultData: null,
});
type InspectionColumnRow = InspectionNode & {
......
......@@ -74,6 +74,8 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
const showModulePicker = ref(false);
const loading = ref(false);
const activeSubKey = ref<number | string>("");
/** `getInspectionTemplateDefault` 解包后的 data,供表单区等消费 */
const templateDefaultData = ref<InspectionTemplateDefaultData | null>(null);
const activeBigModule = computed(
() =>
......@@ -112,7 +114,7 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
activeBigModule.value?.subTabs[0]
);
/** 有真实二级 Tab 时,当前是否为该大项的最后一个二级项(用于底部主按钮「提交检测内容」) */
/** 有真实二级 Tab 时,当前是否为该大项的最后一个二级项 */
const isLastSubTabOfActiveBigModule = computed(() => {
const m = activeBigModule.value;
if (!m || m.hasSecondaryTabs !== true) return false;
......@@ -194,16 +196,17 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
const firstChild = list[0];
const isDirectLeafChildren = firstChild !== undefined && firstChild.nodeType === 3;
let templateDefaultData: InspectionTemplateDefaultData | null = null;
let fetchedDefaultData: InspectionTemplateDefaultData | null = null;
try {
templateDefaultData = await getInspectionTemplateDefault(taskId.value);
fetchedDefaultData = await getInspectionTemplateDefault(taskId.value);
} catch (error) {
console.error("获取模板默认值失败:", error);
}
templateDefaultData.value = fetchedDefaultData;
if (isDirectLeafChildren) {
targetBigModule.hasSecondaryTabs = false;
const leafNodes = applyResolvedInitialValuesToLeafNodes(list, templateDefaultData);
const leafNodes = applyResolvedInitialValuesToLeafNodes(list, fetchedDefaultData);
const allDone = list.every((n) => isInspectionVoCompleted(n.inspectionResultVO));
targetBigModule.subTabs = [
{
......@@ -220,7 +223,7 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
key: node.id,
label: node.nodeName,
nodeId: node.id,
leafNodes: applyResolvedInitialValuesToLeafNodes(node.childrenNodes, templateDefaultData),
leafNodes: applyResolvedInitialValuesToLeafNodes(node.childrenNodes, fetchedDefaultData),
inspectionResultVO: node.inspectionResultVO,
completedFlag: isInspectionVoCompleted(node.inspectionResultVO) ? 1 : 0,
}));
......@@ -328,6 +331,7 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
isLastSubTabOfActiveBigModule,
activeSubTab,
currentLeafNodes,
templateDefaultData,
initializeInspection,
loadSubTabsForBigModule,
switchToUncompletedInspectionNode,
......
......@@ -87,7 +87,8 @@
:active-sub-tab="activeBigModule"
:big-module-label="activeBigModule?.label"
:leaf-nodes="currentLeafNodes"
:sub-tab-label="activeSubTab?.label" />
:sub-tab-label="activeSubTab?.label"
:template-default-data="templateDefaultData" />
</div>
</div>
</div>
......@@ -106,7 +107,7 @@
提交评分
</van-button>
</template>
<!-- 普通检测页:有二级时上一步 + 下一步;无二级时仅完成检测(全宽) -->
<!-- 普通检测页:有二级时上一步 + 下一步;无二级时仅下一步(全宽) -->
<template v-else>
<van-button v-if="activeBigModule?.hasSecondaryTabs !== false"
class="btn-save"
......@@ -124,13 +125,7 @@
round
type="primary"
@click="onNext">
{{
activeBigModule?.hasSecondaryTabs === false
? "完成检测"
: isLastSubTabOfActiveBigModule
? "提交检测内容"
: "下一步"
}}
下一步
</van-button>
</template>
</div>
......@@ -191,6 +186,7 @@ const customizeFormRef = ref<InstanceType<typeof customizeForm> | null>(null);
const inspectionScoreFormRef = ref<InstanceType<typeof ScoreForm> | null>(null);
const modules = useInspectModules(route);
const templateDefaultData = modules.templateDefaultData;
const {
submitting,
onSelectBigModule,
......@@ -213,7 +209,6 @@ const {
showInspectionProgressBar,
progressTotal,
progressDone,
isLastSubTabOfActiveBigModule,
activeSubTab,
currentLeafNodes,
initializeInspection,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!