提交“
This commit is contained in:
1 parent
5d9fb5ce19
commit
9177e1b7f1
231 files changed
+21207
No files matched your search
@@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<ol class="mp-crm-approval-timeline" aria-label="审批进度">
|
||||
<li
|
||||
v-for="(item, index) in items"
|
||||
:key="item.id || index"
|
||||
class="mp-crm-approval-timeline__item"
|
||||
>
|
||||
<div class="mp-crm-approval-timeline__rail" aria-hidden="true">
|
||||
<span class="mp-crm-approval-timeline__avatar">{{
|
||||
item.avatar || avatarText(item.name)
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="mp-crm-approval-timeline__content">
|
||||
<div class="mp-crm-approval-timeline__head">
|
||||
<strong>{{ item.name }}</strong>
|
||||
<span class="status-tag" :class="`status-tag--${item.tone || 'info'}`">
|
||||
{{ item.status }}
|
||||
</span>
|
||||
</div>
|
||||
<p v-if="item.opinion" class="mp-crm-approval-timeline__opinion">{{ item.opinion }}</p>
|
||||
<time
|
||||
v-if="item.time"
|
||||
class="mp-crm-approval-timeline__time"
|
||||
:datetime="item.datetime || undefined"
|
||||
>{{ item.time }}</time
|
||||
>
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
type MpStatusTone = 'success' | 'warning' | 'danger' | 'info' | 'primary'
|
||||
|
||||
interface MpApprovalTimelineItem {
|
||||
id?: string
|
||||
name: string
|
||||
avatar?: string
|
||||
status: string
|
||||
tone?: MpStatusTone
|
||||
opinion?: string
|
||||
time?: string
|
||||
datetime?: string
|
||||
}
|
||||
|
||||
defineProps<{
|
||||
items: MpApprovalTimelineItem[]
|
||||
}>()
|
||||
|
||||
function avatarText(name: string) {
|
||||
return (
|
||||
String(name || '审')
|
||||
.trim()
|
||||
.slice(-1) || '审'
|
||||
)
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,92 @@
|
||||
<template>
|
||||
<ul class="mp-crm-att-grid" aria-label="附件列表">
|
||||
<li v-if="editable" class="att-item att-item--add">
|
||||
<button class="att-add" type="button" @click="emit('add')">
|
||||
<span aria-hidden="true">+</span>
|
||||
<small>上传</small>
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
v-for="item in items"
|
||||
:key="item.id || item.url || item.name"
|
||||
class="att-item"
|
||||
:class="{ 'is-uploading': item.uploading }"
|
||||
>
|
||||
<button
|
||||
v-if="editable && !item.uploading"
|
||||
class="att-icon att-icon--del"
|
||||
type="button"
|
||||
:aria-label="`删除附件:${item.name || '未命名附件'}`"
|
||||
@click.stop="emit('remove', item)"
|
||||
>
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<button
|
||||
v-if="item.url && !item.uploading"
|
||||
class="att-icon att-icon--dl"
|
||||
type="button"
|
||||
:aria-label="`下载附件:${item.name || '未命名附件'}`"
|
||||
@click.stop="emit('download', item)"
|
||||
>
|
||||
<span aria-hidden="true">↓</span>
|
||||
</button>
|
||||
<button
|
||||
class="att-preview"
|
||||
type="button"
|
||||
:disabled="Boolean(item.uploading) || !item.url"
|
||||
@click="emit('preview', item)"
|
||||
>
|
||||
<img v-if="isImage(item)" class="att-img" :src="item.url" :alt="item.name || '附件'" />
|
||||
<span v-else class="att-doc" :class="{ 'att-doc--word': isWord(item) }">
|
||||
<strong>{{ extension(item) }}</strong>
|
||||
</span>
|
||||
</button>
|
||||
<span class="att-name">{{ item.name || '附件' }}</span>
|
||||
<span v-if="item.uploading" class="att-uploading">上传中…</span>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
export interface MpAttachmentItem {
|
||||
id?: string
|
||||
url: string
|
||||
name?: string
|
||||
isImage?: boolean
|
||||
uploading?: boolean
|
||||
}
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
items: MpAttachmentItem[]
|
||||
editable?: boolean
|
||||
}>(),
|
||||
{
|
||||
editable: false
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
add: []
|
||||
preview: [item: MpAttachmentItem]
|
||||
download: [item: MpAttachmentItem]
|
||||
remove: [item: MpAttachmentItem]
|
||||
}>()
|
||||
|
||||
function isImage(item: MpAttachmentItem) {
|
||||
if (item.isImage !== undefined) return item.isImage
|
||||
return /\.(?:avif|gif|jpe?g|png|webp)(?:\?.*)?$/i.test(item.url || item.name || '')
|
||||
}
|
||||
|
||||
function extension(item: MpAttachmentItem) {
|
||||
const value = (item.name || item.url).split('?')[0]
|
||||
const suffix = value.includes('.') ? value.split('.').pop() : 'FILE'
|
||||
return String(suffix || 'FILE')
|
||||
.slice(0, 5)
|
||||
.toUpperCase()
|
||||
}
|
||||
|
||||
function isWord(item: MpAttachmentItem) {
|
||||
return /^(DOC|DOCX|XLS|XLSX|PPT)/.test(extension(item))
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,83 @@
|
||||
<template>
|
||||
<article class="expense-card mp-crm-expense-card" @click="emit('open')">
|
||||
<div class="ec-top">
|
||||
<button
|
||||
v-if="selectable"
|
||||
class="expense-card__select mp-wv-touch-target"
|
||||
type="button"
|
||||
:aria-label="selected ? '取消选择' : '选择'"
|
||||
:aria-pressed="selected"
|
||||
@click.stop="emit('select', !selected)"
|
||||
>
|
||||
<span aria-hidden="true">{{ selected ? '✓' : '' }}</span>
|
||||
</button>
|
||||
<h2 class="ec-title">
|
||||
<button
|
||||
class="expense-card__open mp-wv-touch-target"
|
||||
type="button"
|
||||
:aria-label="openLabel || `查看${title}`"
|
||||
@click.stop="emit('open')"
|
||||
>
|
||||
{{ title }}
|
||||
</button>
|
||||
</h2>
|
||||
<span class="status-tag" :class="`status-tag--${statusTone}`">{{ status }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="amount !== undefined && amount !== ''" class="ec-amount">
|
||||
<span class="ec-amount__label">{{ amountLabel }}</span>
|
||||
<strong class="ec-amount__value">{{ amount }}</strong>
|
||||
</div>
|
||||
|
||||
<div v-if="slots.emphasis" class="ec-emphasis">
|
||||
<slot name="emphasis" />
|
||||
</div>
|
||||
|
||||
<div v-if="slots.kv" class="list-card-kv">
|
||||
<slot name="kv" />
|
||||
</div>
|
||||
|
||||
<p v-if="time" class="ec-time">{{ time }}</p>
|
||||
|
||||
<div v-if="showActions && slots.actions" class="ec-bottom" @click.stop>
|
||||
<div class="op-actions">
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
type MpStatusTone = 'success' | 'warning' | 'danger' | 'info' | 'primary'
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
title: string
|
||||
status: string
|
||||
statusTone?: MpStatusTone
|
||||
amount?: string
|
||||
amountLabel?: string
|
||||
time?: string
|
||||
selectable?: boolean
|
||||
selected?: boolean
|
||||
openLabel?: string
|
||||
showActions?: boolean
|
||||
}>(),
|
||||
{
|
||||
statusTone: 'info',
|
||||
amount: undefined,
|
||||
amountLabel: '金额',
|
||||
time: '',
|
||||
selectable: false,
|
||||
selected: false,
|
||||
openLabel: '',
|
||||
showActions: true
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
open: []
|
||||
select: [selected: boolean]
|
||||
}>()
|
||||
const slots = useSlots()
|
||||
</script>
|
||||
@@ -0,0 +1,370 @@
|
||||
<template>
|
||||
<div
|
||||
class="mp-list-skel"
|
||||
:class="{
|
||||
'mp-list-skel--full': variant === 'full',
|
||||
'mp-customer-list': layout === 'customer'
|
||||
}"
|
||||
role="status"
|
||||
aria-live="polite"
|
||||
aria-busy="true"
|
||||
:aria-label="ariaLabel"
|
||||
>
|
||||
<template v-if="variant === 'full' && layout === 'customer'">
|
||||
<!-- 与正式页 MpBusinessHeader 同结构:返回和标题保持可读,Tab / 搜索 / 筛选走骨架闪动 -->
|
||||
<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="返回"
|
||||
@click="emit('back')"
|
||||
>
|
||||
←
|
||||
</button>
|
||||
<h1 class="mp-wv-header__title">{{ title }}</h1>
|
||||
</div>
|
||||
<div v-if="tabs.length" class="mp-list-skel__tabs" aria-hidden="true">
|
||||
<span
|
||||
v-for="(tab, index) in tabs"
|
||||
:key="tab"
|
||||
class="mp-wv-skel mp-list-skel__header-bar mp-list-skel__tab-bar"
|
||||
:class="{ 'is-active': index === 0 }"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
v-if="searchable"
|
||||
class="mp-wv-skel mp-list-skel__header-bar mp-list-skel__search-bar"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<div v-if="filters.length" class="mp-list-skel__dd" aria-hidden="true">
|
||||
<span
|
||||
v-for="filter in filters"
|
||||
:key="filter"
|
||||
class="mp-wv-skel mp-list-skel__header-bar mp-list-skel__dd-bar"
|
||||
/>
|
||||
</div>
|
||||
</header>
|
||||
</template>
|
||||
<template v-else-if="variant === 'full'">
|
||||
<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="返回"
|
||||
@click="emit('back')"
|
||||
>
|
||||
←
|
||||
</button>
|
||||
<h1 class="mp-wv-header__title">{{ title }}</h1>
|
||||
</div>
|
||||
</header>
|
||||
</template>
|
||||
|
||||
<p v-if="caption" class="mp-list-skel__caption">{{ caption }}</p>
|
||||
|
||||
<p v-if="layout !== 'customer'" class="mp-list-skel__summary" aria-hidden="true">
|
||||
<span class="mp-wv-skel mp-list-skel__summary-bar" />
|
||||
</p>
|
||||
|
||||
<div
|
||||
class="mp-list-skel__cards"
|
||||
:class="{
|
||||
'mp-customer-content mp-wv-pad-speed': variant === 'full' && layout === 'customer'
|
||||
}"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<article
|
||||
v-for="n in cardCount"
|
||||
:key="n"
|
||||
class="mp-list-skel__card"
|
||||
:class="
|
||||
layout === 'customer'
|
||||
? 'mp-wv-card mp-customer-list-card mp-wv-card--skeleton'
|
||||
: 'mp-crm-expense-card'
|
||||
"
|
||||
>
|
||||
<template v-if="layout === 'customer'">
|
||||
<div class="mp-list-skel__card-top">
|
||||
<div class="mp-list-skel__card-titles">
|
||||
<div class="mp-wv-skel mp-wv-skel--title" />
|
||||
<div class="mp-wv-skel mp-wv-skel--sub mp-list-skel__meta" />
|
||||
</div>
|
||||
<div class="mp-wv-skel mp-wv-skel--tag" />
|
||||
</div>
|
||||
<div class="mp-list-skel__card-preview">
|
||||
<div class="mp-list-skel__preview-line">
|
||||
<div class="mp-wv-skel mp-list-skel__preview-label" />
|
||||
<div class="mp-wv-skel mp-list-skel__preview-value" />
|
||||
</div>
|
||||
<div class="mp-list-skel__preview-line">
|
||||
<div class="mp-wv-skel mp-list-skel__preview-label" />
|
||||
<div class="mp-wv-skel mp-list-skel__preview-value mp-list-skel__preview-value--short" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="mp-list-skel__card-toggle">
|
||||
<div class="mp-wv-skel mp-list-skel__toggle-bar" />
|
||||
</div>
|
||||
<div class="mp-list-skel__card-actions mp-list-skel__card-actions--stretch">
|
||||
<div class="mp-wv-skel mp-wv-skel--btn" />
|
||||
<div class="mp-wv-skel mp-wv-skel--btn" />
|
||||
<div class="mp-wv-skel mp-wv-skel--btn" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="mp-list-skel__card-top">
|
||||
<div class="mp-wv-skel mp-wv-skel--title" />
|
||||
<div class="mp-wv-skel mp-wv-skel--tag" />
|
||||
</div>
|
||||
<div class="mp-list-skel__card-emphasis">
|
||||
<div class="mp-wv-skel mp-wv-skel--sub" />
|
||||
<div class="mp-wv-skel mp-wv-skel--sub" />
|
||||
</div>
|
||||
<div class="mp-list-skel__card-kv">
|
||||
<div class="mp-wv-skel mp-wv-skel--line" />
|
||||
<div class="mp-wv-skel mp-wv-skel--line mp-wv-skel--mid" />
|
||||
<div class="mp-wv-skel mp-wv-skel--line mp-wv-skel--short" />
|
||||
<div class="mp-wv-skel mp-wv-skel--line" />
|
||||
</div>
|
||||
<div class="mp-list-skel__card-actions">
|
||||
<div class="mp-wv-skel mp-wv-skel--btn" />
|
||||
<div class="mp-wv-skel mp-wv-skel--btn" />
|
||||
<div class="mp-wv-skel mp-wv-skel--btn mp-wv-skel--btn-wide" />
|
||||
</div>
|
||||
</template>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const emit = defineEmits<{ back: [] }>()
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
variant?: 'full' | 'body'
|
||||
layout?: 'default' | 'customer'
|
||||
title?: string
|
||||
searchable?: boolean
|
||||
searchPlaceholder?: string
|
||||
tabs?: string[]
|
||||
filters?: string[]
|
||||
cardCount?: number
|
||||
caption?: string
|
||||
ariaLabel?: string
|
||||
}>(),
|
||||
{
|
||||
variant: 'body',
|
||||
layout: 'default',
|
||||
title: '',
|
||||
searchable: false,
|
||||
searchPlaceholder: '搜索',
|
||||
tabs: () => [],
|
||||
filters: () => [],
|
||||
cardCount: 3,
|
||||
caption: '',
|
||||
ariaLabel: '页面加载中'
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
/* 绿头上的骨架条:半透明白闪动,和卡片区浅色骨架区分开 */
|
||||
.mp-list-skel__header-bar {
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
rgb(255 255 255 / 22%) 25%,
|
||||
rgb(255 255 255 / 52%) 37%,
|
||||
rgb(255 255 255 / 22%) 63%
|
||||
);
|
||||
background-size: 400% 100%;
|
||||
}
|
||||
|
||||
.mp-list-skel__tabs {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
margin-top: 8px;
|
||||
min-height: 34px;
|
||||
}
|
||||
|
||||
.mp-list-skel__tab-bar {
|
||||
flex: 1;
|
||||
height: 12px;
|
||||
margin: 0;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.mp-list-skel__tab-bar.is-active {
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
.mp-list-skel__search-bar {
|
||||
height: 36px;
|
||||
margin: 10px 0 0;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.mp-list-skel__dd {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
margin-top: 8px;
|
||||
min-height: 36px;
|
||||
}
|
||||
|
||||
.mp-list-skel__dd-bar {
|
||||
flex: 1;
|
||||
height: 12px;
|
||||
margin: 0;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.mp-list-skel__caption {
|
||||
margin: 2px 0 12px;
|
||||
font-size: 12px;
|
||||
color: #6b7b74;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.mp-list-skel__summary {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
.mp-list-skel__summary-bar {
|
||||
display: block;
|
||||
width: 52%;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
.mp-list-skel__card {
|
||||
pointer-events: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.mp-list-skel__card-top {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.mp-list-skel__card-titles {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.mp-list-skel__card-top .mp-wv-skel--title {
|
||||
max-width: 78%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.mp-list-skel__meta {
|
||||
width: 88%;
|
||||
max-width: 280px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.mp-list-skel__card-preview {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.mp-list-skel__preview-line {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.mp-list-skel__preview-label {
|
||||
width: 4.5em;
|
||||
height: 12px;
|
||||
margin: 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.mp-list-skel__preview-value {
|
||||
width: 42%;
|
||||
height: 12px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.mp-list-skel__preview-value--short {
|
||||
width: 32%;
|
||||
}
|
||||
|
||||
.mp-list-skel__card-toggle {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 10px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px dashed #dcebe4;
|
||||
}
|
||||
|
||||
.mp-list-skel__toggle-bar {
|
||||
width: 4.5em;
|
||||
height: 12px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.mp-list-skel__card-emphasis {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 0 12px 8px;
|
||||
}
|
||||
|
||||
.mp-list-skel__card-emphasis .mp-wv-skel {
|
||||
width: 36%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.mp-list-skel__card-kv {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
padding: 4px 12px 10px;
|
||||
}
|
||||
|
||||
.mp-list-skel__card-kv .mp-wv-skel {
|
||||
margin-top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.mp-list-skel__card-kv .mp-wv-skel--mid {
|
||||
width: 78%;
|
||||
}
|
||||
|
||||
.mp-list-skel__card-kv .mp-wv-skel--short {
|
||||
width: 58%;
|
||||
}
|
||||
|
||||
.mp-list-skel__card-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding: 0 12px 12px;
|
||||
}
|
||||
|
||||
.mp-list-skel__card-actions--stretch {
|
||||
justify-content: stretch;
|
||||
margin-top: 12px;
|
||||
padding: 10px 0 0;
|
||||
border-top: 1px dashed #dcebe4;
|
||||
|
||||
.mp-wv-skel--btn {
|
||||
flex: 1;
|
||||
width: auto;
|
||||
height: 36px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
/* default expense-card 骨架仍用区块内边距 */
|
||||
.mp-crm-expense-card.mp-list-skel__card .mp-list-skel__card-top {
|
||||
padding: 12px 12px 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,16 @@
|
||||
<template>
|
||||
<MpStructSkeleton kind="detail" :caption="title" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import MpStructSkeleton from '@/components/mp/MpStructSkeleton.vue'
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
title?: string
|
||||
}>(),
|
||||
{
|
||||
title: '正在加载'
|
||||
}
|
||||
)
|
||||
</script>
|
||||
@@ -0,0 +1,48 @@
|
||||
<template>
|
||||
<nav class="mp-wv-status-tabs" :aria-label="ariaLabel">
|
||||
<button
|
||||
v-for="tab in tabs"
|
||||
:key="String(tab.value)"
|
||||
class="filter-tag"
|
||||
:class="{ 'is-active': tab.value === modelValue }"
|
||||
type="button"
|
||||
:aria-pressed="tab.value === modelValue"
|
||||
:disabled="tab.disabled"
|
||||
@click="selectTab(tab)"
|
||||
>
|
||||
<span>{{ tab.label }}</span>
|
||||
<span v-if="tab.count !== undefined" class="filter-tag__count">{{ tab.count }}</span>
|
||||
</button>
|
||||
</nav>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" generic="T extends string | number">
|
||||
interface MpStatusTab<T extends string | number = string> {
|
||||
label: string
|
||||
value: T
|
||||
count?: number
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
modelValue: T
|
||||
tabs: MpStatusTab<T>[]
|
||||
ariaLabel?: string
|
||||
}>(),
|
||||
{
|
||||
ariaLabel: '状态筛选'
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: T]
|
||||
change: [value: T]
|
||||
}>()
|
||||
|
||||
function selectTab(tab: MpStatusTab<T>) {
|
||||
if (tab.disabled) return
|
||||
emit('update:modelValue', tab.value)
|
||||
emit('change', tab.value)
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,141 @@
|
||||
<template>
|
||||
<div
|
||||
class="mp-struct"
|
||||
:class="`mp-struct--${kind}`"
|
||||
role="status"
|
||||
aria-live="polite"
|
||||
aria-busy="true"
|
||||
:aria-label="caption"
|
||||
>
|
||||
<p v-if="caption" class="mp-struct__caption">{{ caption }}</p>
|
||||
|
||||
<template v-if="kind === 'detail'">
|
||||
<article class="mp-struct__card">
|
||||
<div class="mp-struct__bar mp-struct__bar--title" />
|
||||
<div class="mp-struct__lines">
|
||||
<div class="mp-struct__bar" />
|
||||
<div class="mp-struct__bar mp-struct__bar--mid" />
|
||||
<div class="mp-struct__bar" />
|
||||
<div class="mp-struct__bar mp-struct__bar--short" />
|
||||
<div class="mp-struct__bar" />
|
||||
<div class="mp-struct__bar mp-struct__bar--mid" />
|
||||
</div>
|
||||
</article>
|
||||
<article class="mp-struct__card">
|
||||
<div class="mp-struct__bar mp-struct__bar--label" />
|
||||
<div class="mp-struct__bar mp-struct__bar--block" />
|
||||
<div class="mp-struct__bar mp-struct__bar--block" />
|
||||
</article>
|
||||
</template>
|
||||
|
||||
<template v-else-if="kind === 'media'">
|
||||
<div class="mp-struct__media" />
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div v-for="n in count" :key="n" class="mp-struct__field">
|
||||
<div class="mp-struct__bar mp-struct__bar--label" />
|
||||
<div class="mp-struct__bar mp-struct__bar--block" />
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
kind?: 'detail' | 'sheet' | 'media'
|
||||
caption?: string
|
||||
count?: number
|
||||
}>(),
|
||||
{
|
||||
kind: 'detail',
|
||||
caption: '正在加载',
|
||||
count: 3
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.mp-struct {
|
||||
padding: 4px 0 12px;
|
||||
}
|
||||
|
||||
.mp-struct__caption {
|
||||
margin: 2px 0 12px;
|
||||
font-size: 12px;
|
||||
color: #6b7b74;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.mp-struct__card {
|
||||
margin-bottom: 12px;
|
||||
padding: 14px;
|
||||
background: #fff;
|
||||
border: 1px solid #dcebe4;
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
.mp-struct__lines {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.mp-struct__field + .mp-struct__field {
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.mp-struct__media {
|
||||
width: min(220px, 70%);
|
||||
height: 220px;
|
||||
margin: 12px auto 8px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.mp-struct__bar,
|
||||
.mp-struct__media {
|
||||
border-radius: 6px;
|
||||
background: linear-gradient(90deg, #e7f3ed 25%, #f7fbf9 37%, #e7f3ed 63%);
|
||||
background-size: 400% 100%;
|
||||
animation: mp-struct-shimmer 1.2s ease infinite;
|
||||
}
|
||||
|
||||
.mp-struct__bar {
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
.mp-struct__bar--title {
|
||||
width: 46%;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.mp-struct__bar--mid {
|
||||
width: 72%;
|
||||
}
|
||||
|
||||
.mp-struct__bar--short {
|
||||
width: 46%;
|
||||
}
|
||||
|
||||
.mp-struct__bar--label {
|
||||
width: 28%;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.mp-struct__bar--block {
|
||||
width: 100%;
|
||||
height: 36px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
@keyframes mp-struct-shimmer {
|
||||
0% {
|
||||
background-position: 100% 0;
|
||||
}
|
||||
|
||||
100% {
|
||||
background-position: 0 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<div class="mp-wv-filter-wrap mp-wv-filter-wrap--business">
|
||||
<div class="mp-wv-filter-bar mp-wv-filter-bar--three">
|
||||
<button
|
||||
v-for="filter in visibleFilters"
|
||||
:key="filter.key"
|
||||
class="mp-wv-filter-trig"
|
||||
:class="{ open: openKey === filter.key }"
|
||||
type="button"
|
||||
:aria-expanded="openKey === filter.key"
|
||||
@click="toggle(filter.key)"
|
||||
>
|
||||
<span class="mp-wv-filter-trig__val">{{ filter.label }}</span>
|
||||
<span class="mp-wv-filter-trig__arrow" aria-hidden="true">▼</span>
|
||||
</button>
|
||||
<button
|
||||
class="mp-wv-filter-trig mp-wv-filter-more"
|
||||
type="button"
|
||||
:aria-label="moreActive ? `${moreLabel},已有筛选` : moreLabel"
|
||||
@click="openMore"
|
||||
>
|
||||
<span>{{ moreLabel }}</span>
|
||||
<span v-if="moreActive" class="mp-wv-filter-more__dot" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="mp-wv-filter-panel" :class="{ open: Boolean(activeFilter) }">
|
||||
<button
|
||||
v-for="option in activeFilter?.options || []"
|
||||
:key="String(option.value)"
|
||||
class="mp-wv-filter-opt"
|
||||
:class="{ active: option.value === activeFilter?.value }"
|
||||
type="button"
|
||||
@click="selectOption(option.value)"
|
||||
>
|
||||
<span>{{ option.label }}</span>
|
||||
<span class="mp-wv-filter-opt__check" aria-hidden="true">✓</span>
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
class="mp-wv-filter-mask"
|
||||
:class="{ open: Boolean(activeFilter) }"
|
||||
type="button"
|
||||
aria-label="关闭筛选"
|
||||
@click="close"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
interface MpQuickFilterOption {
|
||||
label: string
|
||||
value: string | number
|
||||
}
|
||||
|
||||
interface MpQuickFilter {
|
||||
key: string
|
||||
label: string
|
||||
value: string | number
|
||||
options: MpQuickFilterOption[]
|
||||
}
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
quickFilters: [MpQuickFilter, MpQuickFilter]
|
||||
moreLabel?: string
|
||||
moreActive?: boolean
|
||||
}>(),
|
||||
{
|
||||
moreLabel: '更多',
|
||||
moreActive: false
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
select: [payload: { key: string; value: string | number }]
|
||||
more: []
|
||||
}>()
|
||||
|
||||
const openKey = ref('')
|
||||
const visibleFilters = computed(() => props.quickFilters.slice(0, 2))
|
||||
const activeFilter = computed(() =>
|
||||
visibleFilters.value.find((filter) => filter.key === openKey.value)
|
||||
)
|
||||
|
||||
function toggle(key: string) {
|
||||
openKey.value = openKey.value === key ? '' : key
|
||||
}
|
||||
|
||||
function close() {
|
||||
openKey.value = ''
|
||||
}
|
||||
|
||||
function selectOption(value: string | number) {
|
||||
if (!activeFilter.value) return
|
||||
emit('select', { key: activeFilter.value.key, value })
|
||||
close()
|
||||
}
|
||||
|
||||
function openMore() {
|
||||
close()
|
||||
emit('more')
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user