fix: 自定义标签
This commit is contained in:
@@ -197,43 +197,42 @@
|
||||
</el-card>
|
||||
|
||||
<!-- 展示形式切换(放在最上面) -->
|
||||
<div class="view-toolbar">
|
||||
<div class="view-switch">
|
||||
<span class="toolbar-label">展示形式:</span>
|
||||
<el-radio-group v-model="displayMode" size="default">
|
||||
<el-radio-button label="card">
|
||||
<el-icon><Grid /></el-icon>
|
||||
卡片
|
||||
</el-radio-button>
|
||||
<el-radio-button label="table">
|
||||
<el-icon><List /></el-icon>
|
||||
列表
|
||||
</el-radio-button>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
<div v-if="displayMode === 'table'" class="table-search">
|
||||
<el-input
|
||||
v-model="tableSearchKeyword"
|
||||
placeholder="搜索款号/名称"
|
||||
style="width: 200px"
|
||||
clearable
|
||||
>
|
||||
<template #prefix>
|
||||
<el-icon><Search /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 内容卡片:标签 + 卡片/列表内容(标签放在卡片内,不突兀) -->
|
||||
<!-- 内容卡片:展示形式切换 + 标签 + 卡片/列表内容(标签放在卡片内,不突兀) -->
|
||||
<el-card class="content-card" shadow="never">
|
||||
<!-- 展示形式切换:移入内容卡片内部,置于标签上方,仅保留切换按钮 -->
|
||||
<div class="view-toolbar">
|
||||
<div class="view-switch">
|
||||
<el-radio-group v-model="displayMode" size="default">
|
||||
<el-radio-button label="card">
|
||||
<el-icon><Grid /></el-icon>
|
||||
卡片
|
||||
</el-radio-button>
|
||||
<el-radio-button label="table">
|
||||
<el-icon><List /></el-icon>
|
||||
列表
|
||||
</el-radio-button>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
<div v-if="displayMode === 'table'" class="table-search">
|
||||
<el-input
|
||||
v-model="tableSearchKeyword"
|
||||
placeholder="搜索款号/名称"
|
||||
style="width: 200px"
|
||||
clearable
|
||||
>
|
||||
<template #prefix>
|
||||
<el-icon><Search /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 标签分类筛选:放在卡片内部 -->
|
||||
<div v-if="labelOpts.length > 0" class="filter-bar">
|
||||
<div
|
||||
v-for="opt in labelOpts"
|
||||
:key="opt.value"
|
||||
class="pill"
|
||||
:class="{ active: labelFilter === opt.value }"
|
||||
:class="['pill', { active: labelFilter === opt.value }]"
|
||||
@click="labelFilter = opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
@@ -495,6 +494,46 @@ function initQueryParamsFromRoute() {
|
||||
if (q.line) queryParams.line = String(q.line).split(',').filter(Boolean)
|
||||
if (q.spdm) queryParams.spdm = String(q.spdm)
|
||||
dateRange.value = [queryParams.rq, queryParams.rq2]
|
||||
|
||||
// 根据路由传入的时间区间反推当前快捷按钮
|
||||
try {
|
||||
const rq = queryParams.rq
|
||||
const rq2 = queryParams.rq2
|
||||
const today = dayjs().format('YYYY-MM-DD')
|
||||
|
||||
// 仅在 rq2 为今天时才尝试匹配 week7/day15/day30 或年份
|
||||
if (rq && rq2 && rq2 === today) {
|
||||
const diff = dayjs(today).diff(dayjs(rq), 'day')
|
||||
if (diff === 6) {
|
||||
activeTimeRange.value = 'week7'
|
||||
return
|
||||
}
|
||||
if (diff === 14) {
|
||||
activeTimeRange.value = 'day15'
|
||||
return
|
||||
}
|
||||
if (diff === 29) {
|
||||
activeTimeRange.value = 'day30'
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 尝试匹配全年快捷:从某年1月1日到该年末或今天
|
||||
if (rq && rq2) {
|
||||
const startYear = dayjs(rq).year()
|
||||
const yearStart = dayjs(`${startYear}-01-01`).format('YYYY-MM-DD')
|
||||
const yearEnd = startYear === dayjs().year() ? today : dayjs(`${startYear}-12-31`).format('YYYY-MM-DD')
|
||||
if (rq === yearStart && rq2 === yearEnd) {
|
||||
activeTimeRange.value = `year${startYear}`
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 其余情况,不高亮任何快捷按钮
|
||||
activeTimeRange.value = ''
|
||||
} catch {
|
||||
activeTimeRange.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
// 下拉选项(门店通过 executeTable tableName=kehu 获取)
|
||||
@@ -1275,6 +1314,24 @@ onMounted(async () => {
|
||||
color: #fff;
|
||||
border-color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
&.badge-danger {
|
||||
background: #fee2e2;
|
||||
color: #ef4444;
|
||||
border-color: #fecaca;
|
||||
}
|
||||
|
||||
&.badge-warn {
|
||||
background: #fef3c7;
|
||||
color: #d97706;
|
||||
border-color: #fde68a;
|
||||
}
|
||||
|
||||
&.badge-success {
|
||||
background: #dcfce7;
|
||||
color: #22c55e;
|
||||
border-color: #bbf7d0;
|
||||
}
|
||||
}
|
||||
|
||||
.view-toolbar {
|
||||
|
||||
Reference in New Issue
Block a user