Commit ad64fdaa by chenwq1

feat: 新增中间

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