fix(web-admin): stick category header tools with MpBusinessHeader.
Move expand-all and add into a header actions slot so they remain visible while scrolling. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
efe7f77a66
commit
ef71e842ee
4 files changed
+184
-26
No files matched your search
@@ -0,0 +1,61 @@
|
||||
<template>
|
||||
<header class="mp-wv-header">
|
||||
<div class="mp-wv-header__row">
|
||||
<button
|
||||
class="mp-wv-header__back mp-wv-touch-target"
|
||||
type="button"
|
||||
:aria-label="backLabel"
|
||||
@click="emit('back')"
|
||||
>
|
||||
←
|
||||
</button>
|
||||
<h1 class="mp-wv-header__title">{{ title }}</h1>
|
||||
<div v-if="$slots.actions" class="mp-wv-header__actions">
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
</div>
|
||||
<slot name="before-search" />
|
||||
<input
|
||||
v-if="searchable"
|
||||
class="mp-wv-search mp-wv-touch-target"
|
||||
type="search"
|
||||
:value="keyword"
|
||||
:aria-label="searchLabel"
|
||||
:placeholder="searchPlaceholder"
|
||||
autocomplete="off"
|
||||
@input="updateKeyword"
|
||||
@keyup.enter="emit('search')"
|
||||
/>
|
||||
<slot name="after-search" />
|
||||
</header>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
title: string
|
||||
backLabel?: string
|
||||
searchable?: boolean
|
||||
keyword?: string
|
||||
searchPlaceholder?: string
|
||||
searchLabel?: string
|
||||
}>(),
|
||||
{
|
||||
backLabel: '返回',
|
||||
searchable: false,
|
||||
keyword: '',
|
||||
searchPlaceholder: '搜索',
|
||||
searchLabel: '搜索'
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
back: []
|
||||
search: []
|
||||
'update:keyword': [value: string]
|
||||
}>()
|
||||
|
||||
function updateKeyword(event: Event) {
|
||||
emit('update:keyword', (event.target as HTMLInputElement).value)
|
||||
}
|
||||
</script>
|
||||
@@ -54,6 +54,15 @@
|
||||
|
||||
.mp-wv-header__row .mp-wv-header__title {
|
||||
flex: 1;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.mp-wv-header__actions {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.mp-wv-header__row .el-tag {
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
<template>
|
||||
<MpWebviewShell @ready="onShellReady">
|
||||
<div class="mp-product-page">
|
||||
<MpBusinessHeader title="产品分类" back-label="返回产品列表" @back="goBack" />
|
||||
<div class="mp-cat-header-tools">
|
||||
<button
|
||||
v-if="flatNodes.length"
|
||||
class="mp-cat-header-btn"
|
||||
type="button"
|
||||
@click="toggleExpandAll"
|
||||
>
|
||||
{{ expandAllLabel }}
|
||||
</button>
|
||||
<button class="mp-cat-header-btn" type="button" @click="openAdd()">新增</button>
|
||||
</div>
|
||||
<MpBusinessHeader title="产品分类" back-label="返回产品列表" @back="goBack">
|
||||
<template #actions>
|
||||
<button
|
||||
v-if="hasExpandableNodes"
|
||||
class="mp-cat-header-btn"
|
||||
type="button"
|
||||
@click="toggleExpandAll"
|
||||
>
|
||||
{{ expandAllLabel }}
|
||||
</button>
|
||||
<button class="mp-cat-header-btn" type="button" @click="openAdd()">新增</button>
|
||||
</template>
|
||||
</MpBusinessHeader>
|
||||
|
||||
<div v-if="loading && !tree.length" class="mp-product-loading">
|
||||
<van-loading vertical>正在加载分类</van-loading>
|
||||
@@ -284,6 +285,10 @@
|
||||
return 'success'
|
||||
}
|
||||
|
||||
const hasExpandableNodes = computed(
|
||||
() => Object.keys(collectExpandIds(tree.value)).length > 0
|
||||
)
|
||||
|
||||
const expandAllLabel = computed(() =>
|
||||
areAllExpandableExpanded(tree.value, expandedIds.value) ? '全部折叠' : '全部展开'
|
||||
)
|
||||
@@ -461,20 +466,6 @@
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.mp-product-page {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.mp-cat-header-tools {
|
||||
position: absolute;
|
||||
top: calc(8px + env(safe-area-inset-top, 0px));
|
||||
right: 12px;
|
||||
z-index: 60;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.mp-cat-header-btn {
|
||||
height: 32px;
|
||||
padding: 0 10px;
|
||||
|
||||
Reference in new issue
Block a user