Commit e75c646e by chenwq1

feat: 更新大项选择弹窗逻辑与样式

- 修改大项选择弹窗,新增待确认模块的功能,用户选择后需点击确认。
- 优化弹窗样式,增加底部按钮以支持取消和确认操作。
- 引入 `watch` 监听弹窗状态,确保待确认模块与当前激活模块同步。
1 parent 1b491e8a
Pipeline #109 for e75c646e failed in 0 seconds
......@@ -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,7 +175,9 @@
</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";
......@@ -199,6 +220,28 @@ const {
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();
});
......@@ -450,8 +493,37 @@ 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;
overflow-y: auto;
padding: $spacing-sm 0;
-webkit-overflow-scrolling: touch;
}
.module-picker-footer {
display: flex;
flex-shrink: 0;
gap: $spacing-md;
align-items: center;
padding: 10px $spacing-base 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 {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!