mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
style(店铺概览 商品概览): 优化工具栏样式
This commit is contained in:
+249
-165
@@ -1,7 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { DatePicker, InputNumber, Select, Spin } from 'ant-design-vue';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { DatePicker, InputNumber, Popover, Select, Spin } from 'ant-design-vue';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
@@ -10,7 +12,6 @@ import { normalizeOverviewRangePickerChange } from '#/utils/overview-date-range'
|
||||
import {
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState,
|
||||
overviewToolbarLabelClass,
|
||||
overviewToolbarPanelClass,
|
||||
overviewToolbarShellClass,
|
||||
} from '../../../styles/overview-toolbar-classes';
|
||||
@@ -63,6 +64,43 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
});
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const openPopover = ref<string | null>(null);
|
||||
|
||||
function handlePopoverOpen(name: string, open: boolean) {
|
||||
if (open) {
|
||||
openPopover.value = name;
|
||||
} else if (openPopover.value === name) {
|
||||
openPopover.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
const ReceiptIcon = createIconifyIcon('lucide:receipt');
|
||||
const FilterIcon = createIconifyIcon('lucide:sliders-horizontal');
|
||||
const CalendarIcon = createIconifyIcon('lucide:calendar');
|
||||
|
||||
const collapsedFilterLabel = computed(() => {
|
||||
const shopName = props.shopId != null && props.shopId > 0
|
||||
? (props.shopOptions?.find((o) => o.value === String(props.shopId))?.label ?? `店铺 #${props.shopId}`)
|
||||
: '全部';
|
||||
const productName = props.productId != null && props.productId > 0
|
||||
? (props.productOptions?.find((o) => o.value === String(props.productId))?.label ?? `商品 #${props.productId}`)
|
||||
: '选择商品';
|
||||
return `${shopName}/${productName}`;
|
||||
});
|
||||
|
||||
const timeRangeLabel = computed(() => {
|
||||
const t = props.modelValue.activeTimeRange;
|
||||
if (t === 'today') return '今日';
|
||||
if (t === 'yesterday') return '昨日';
|
||||
if (t === '7days') return '近7日';
|
||||
if (t === '30days') return '近30日';
|
||||
if (t === 'thisMonth') return '本月';
|
||||
if (props.modelValue.customDateRange) {
|
||||
return `${props.modelValue.customDateRange[0].format('M/D')}-${props.modelValue.customDateRange[1].format('M/D')}`;
|
||||
}
|
||||
return '日期';
|
||||
});
|
||||
|
||||
const shopSelectValue = computed(() => {
|
||||
if (props.shopId != null && props.shopId > 0) {
|
||||
return String(props.shopId);
|
||||
@@ -174,181 +212,227 @@ const handleTaxRateChange = (val: number | string | undefined) => {
|
||||
<div
|
||||
class="overview-header-extra flex w-full max-w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-2"
|
||||
>
|
||||
<div :class="overviewToolbarShellClass">
|
||||
<div :class="[overviewToolbarPanelClass, 'flex items-center gap-2 px-2 py-1']">
|
||||
<span class="shrink-0" :class="overviewToolbarLabelClass">税率</span>
|
||||
<InputNumber
|
||||
:value="props.modelValue.taxRate"
|
||||
:min="0"
|
||||
:max="1"
|
||||
:step="0.01"
|
||||
:precision="2"
|
||||
size="small"
|
||||
class="tax-rate-input !h-8 !w-20 !rounded-lg !border-none !bg-transparent !text-center !text-sm !font-bold !text-slate-800 !shadow-none dark:!text-slate-100"
|
||||
:formatter="formatTaxRate"
|
||||
:parser="parseTaxRate"
|
||||
@change="handleTaxRateChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
:class="[
|
||||
overviewToolbarShellClass,
|
||||
'min-w-0 sm:max-w-[min(calc(100vw-2.5rem),56rem)]',
|
||||
]"
|
||||
<!-- 税率 -->
|
||||
<Popover
|
||||
trigger="click"
|
||||
:open="openPopover === 'taxRate'"
|
||||
placement="bottom"
|
||||
@update:open="(val: boolean) => handlePopoverOpen('taxRate', val)"
|
||||
overlay-class-name="workbench-toolbar-popover"
|
||||
>
|
||||
<div
|
||||
:class="[
|
||||
overviewToolbarPanelClass,
|
||||
'flex min-w-0 flex-col gap-2 p-1 sm:flex-row sm:items-center sm:gap-0 sm:divide-x sm:divide-slate-200 dark:sm:divide-[hsl(240deg_3.7%_28%)]',
|
||||
]"
|
||||
>
|
||||
<div
|
||||
class="flex min-w-0 items-center gap-2 px-2 py-0.5 sm:w-[11.5rem] sm:flex-none sm:shrink-0 sm:py-0"
|
||||
>
|
||||
<span class="w-9 shrink-0 text-right" :class="overviewToolbarLabelClass">
|
||||
店铺
|
||||
<template #content>
|
||||
<div class="flex items-center gap-2 whitespace-nowrap">
|
||||
<span class="shrink-0 text-xs font-bold text-slate-700 dark:text-slate-300">
|
||||
税率
|
||||
</span>
|
||||
<Select
|
||||
:value="shopSelectValue"
|
||||
<InputNumber
|
||||
:value="props.modelValue.taxRate"
|
||||
:min="0"
|
||||
:max="1"
|
||||
:step="0.01"
|
||||
:precision="2"
|
||||
size="small"
|
||||
show-search
|
||||
allow-clear
|
||||
:filter-option="false"
|
||||
:loading="props.shopListLoading"
|
||||
:options="props.shopOptions"
|
||||
placeholder="全部店铺"
|
||||
:dropdown-match-select-width="false"
|
||||
class="overview-header-select overview-shop-select min-w-0 flex-1"
|
||||
@change="handleShopSelectChange"
|
||||
@search="(kw: string) => emit('shop-search', kw)"
|
||||
@popup-scroll="(e: Event) => emit('shop-popup-scroll', e)"
|
||||
@dropdown-visible-change="
|
||||
(open: boolean) => emit('shop-dropdown-visible-change', open)
|
||||
"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="props.shopListLoading" class="py-3 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-1 text-xs text-slate-600">加载中...</div>
|
||||
</div>
|
||||
<div v-else class="py-3 text-center text-xs text-slate-600">暂无店铺</div>
|
||||
</template>
|
||||
</Select>
|
||||
class="tax-rate-input !h-8 !w-20 !rounded-lg !border-none !bg-transparent !text-center !text-sm !font-bold !text-slate-800 !shadow-none dark:!text-slate-100"
|
||||
:formatter="formatTaxRate"
|
||||
:parser="parseTaxRate"
|
||||
@change="handleTaxRateChange"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<div :class="[overviewToolbarShellClass, 'cursor-pointer']">
|
||||
<div
|
||||
class="flex min-w-0 flex-1 items-center gap-2 border-t border-slate-200/80 px-2 pt-2 sm:min-w-[16rem] sm:border-t-0 sm:py-0 sm:pt-0 dark:border-[hsl(240deg_3.7%_22%)]"
|
||||
:class="[overviewToolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
||||
>
|
||||
<span class="w-9 shrink-0 text-right" :class="overviewToolbarLabelClass">
|
||||
商品
|
||||
</span>
|
||||
<Select
|
||||
:value="
|
||||
props.productId != null && props.productId > 0
|
||||
? String(props.productId)
|
||||
: undefined
|
||||
"
|
||||
size="small"
|
||||
show-search
|
||||
:filter-option="false"
|
||||
:loading="props.productListLoading"
|
||||
:options="props.productOptions"
|
||||
placeholder="选择商品"
|
||||
:dropdown-match-select-width="false"
|
||||
class="overview-header-select overview-product-select min-w-0 flex-1"
|
||||
@change="handleProductSelectChange"
|
||||
@search="(kw: string) => emit('product-search', kw)"
|
||||
@popup-scroll="(e: Event) => emit('product-popup-scroll', e)"
|
||||
@dropdown-visible-change="
|
||||
(open: boolean) => emit('product-dropdown-visible-change', open)
|
||||
"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="props.productListLoading" class="py-3 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-1 text-xs text-slate-600">加载中...</div>
|
||||
</div>
|
||||
<div v-else class="py-3 text-center text-xs text-slate-600">暂无商品</div>
|
||||
</template>
|
||||
</Select>
|
||||
<ReceiptIcon class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300">税率{{ formatTaxRate(props.modelValue.taxRate) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Popover>
|
||||
|
||||
<div :class="overviewToolbarShellClass">
|
||||
<div
|
||||
:class="[overviewToolbarPanelClass, 'flex w-full items-center gap-1 overflow-x-auto p-1']"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === 'today'),
|
||||
]"
|
||||
@click="switchTimeRange('today')"
|
||||
<!-- 店铺/商品 -->
|
||||
<Popover
|
||||
trigger="click"
|
||||
:open="openPopover === 'filter'"
|
||||
placement="bottom"
|
||||
@update:open="(val: boolean) => handlePopoverOpen('filter', val)"
|
||||
overlay-class-name="workbench-toolbar-popover"
|
||||
>
|
||||
<template #content>
|
||||
<div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-0">
|
||||
<div
|
||||
class="flex min-w-0 items-center gap-2 px-2 py-0.5 sm:w-[11.5rem] sm:flex-none sm:shrink-0 sm:py-0"
|
||||
>
|
||||
<span
|
||||
class="w-9 shrink-0 text-right text-xs font-bold text-slate-700 dark:text-slate-300"
|
||||
>
|
||||
店铺
|
||||
</span>
|
||||
<Select
|
||||
:value="shopSelectValue"
|
||||
size="small"
|
||||
show-search
|
||||
allow-clear
|
||||
:filter-option="false"
|
||||
:loading="props.shopListLoading"
|
||||
:options="props.shopOptions"
|
||||
placeholder="全部店铺"
|
||||
:dropdown-match-select-width="false"
|
||||
class="overview-header-select overview-shop-select min-w-0 flex-1"
|
||||
@change="handleShopSelectChange"
|
||||
@search="(kw: string) => emit('shop-search', kw)"
|
||||
@popup-scroll="(e: Event) => emit('shop-popup-scroll', e)"
|
||||
@dropdown-visible-change="
|
||||
(open: boolean) => emit('shop-dropdown-visible-change', open)
|
||||
"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="props.shopListLoading" class="py-3 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-1 text-xs text-slate-600">加载中...</div>
|
||||
</div>
|
||||
<div v-else class="py-3 text-center text-xs text-slate-600">暂无店铺</div>
|
||||
</template>
|
||||
</Select>
|
||||
</div>
|
||||
<div
|
||||
class="flex min-w-0 flex-1 items-center gap-2 border-t border-slate-200/80 px-2 pt-2 sm:min-w-[16rem] sm:border-t-0 sm:py-0 sm:pt-0 dark:border-[hsl(240deg_3.7%_22%)]"
|
||||
>
|
||||
<span
|
||||
class="w-9 shrink-0 text-right text-xs font-bold text-slate-700 dark:text-slate-300"
|
||||
>
|
||||
商品
|
||||
</span>
|
||||
<Select
|
||||
:value="
|
||||
props.productId != null && props.productId > 0
|
||||
? String(props.productId)
|
||||
: undefined
|
||||
"
|
||||
size="small"
|
||||
show-search
|
||||
:filter-option="false"
|
||||
:loading="props.productListLoading"
|
||||
:options="props.productOptions"
|
||||
placeholder="选择商品"
|
||||
:dropdown-match-select-width="false"
|
||||
class="overview-header-select overview-product-select min-w-0 flex-1"
|
||||
@change="handleProductSelectChange"
|
||||
@search="(kw: string) => emit('product-search', kw)"
|
||||
@popup-scroll="(e: Event) => emit('product-popup-scroll', e)"
|
||||
@dropdown-visible-change="
|
||||
(open: boolean) => emit('product-dropdown-visible-change', open)
|
||||
"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="props.productListLoading" class="py-3 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-1 text-xs text-slate-600">加载中...</div>
|
||||
</div>
|
||||
<div v-else class="py-3 text-center text-xs text-slate-600">暂无商品</div>
|
||||
</template>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div :class="[overviewToolbarShellClass, 'cursor-pointer']">
|
||||
<div
|
||||
:class="[overviewToolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
||||
>
|
||||
今日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === 'yesterday'),
|
||||
]"
|
||||
@click="switchTimeRange('yesterday')"
|
||||
>
|
||||
昨日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === '7days'),
|
||||
]"
|
||||
@click="switchTimeRange('7days')"
|
||||
>
|
||||
近7日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === '30days'),
|
||||
]"
|
||||
@click="switchTimeRange('30days')"
|
||||
>
|
||||
近30日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === 'thisMonth'),
|
||||
]"
|
||||
@click="switchTimeRange('thisMonth')"
|
||||
>
|
||||
本月
|
||||
</button>
|
||||
<FilterIcon class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300">{{ collapsedFilterLabel }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex w-full items-center justify-between gap-2 sm:w-auto sm:justify-start">
|
||||
<span
|
||||
class="hidden whitespace-nowrap sm:inline"
|
||||
:class="overviewToolbarLabelClass"
|
||||
</Popover>
|
||||
|
||||
<!-- 时间范围 -->
|
||||
<Popover
|
||||
trigger="click"
|
||||
:open="openPopover === 'timeRange'"
|
||||
placement="bottom"
|
||||
@update:open="(val: boolean) => handlePopoverOpen('timeRange', val)"
|
||||
overlay-class-name="workbench-toolbar-popover"
|
||||
>
|
||||
<template #content>
|
||||
<div class="flex flex-col gap-2 px-1 py-0.5">
|
||||
<div class="flex items-center gap-1 overflow-x-auto whitespace-nowrap">
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === 'today'),
|
||||
]"
|
||||
@click="switchTimeRange('today')"
|
||||
>
|
||||
今日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === 'yesterday'),
|
||||
]"
|
||||
@click="switchTimeRange('yesterday')"
|
||||
>
|
||||
昨日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === '7days'),
|
||||
]"
|
||||
@click="switchTimeRange('7days')"
|
||||
>
|
||||
近7日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === '30days'),
|
||||
]"
|
||||
@click="switchTimeRange('30days')"
|
||||
>
|
||||
近30日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === 'thisMonth'),
|
||||
]"
|
||||
@click="switchTimeRange('thisMonth')"
|
||||
>
|
||||
本月
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span
|
||||
class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300"
|
||||
>
|
||||
自定义日期
|
||||
</span>
|
||||
<DatePicker.RangePicker
|
||||
:value="props.modelValue.customDateRange"
|
||||
size="small"
|
||||
format="YYYY-MM-DD"
|
||||
:allow-clear="false"
|
||||
:placeholder="['开始', '结束']"
|
||||
class="overview-header-range-picker !h-8 !w-full !border-none !bg-transparent !text-sm !font-bold !text-slate-800 sm:!w-[220px] dark:!text-slate-200"
|
||||
@change="handleCustomDateRangeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div :class="[overviewToolbarShellClass, 'cursor-pointer']">
|
||||
<div
|
||||
:class="[overviewToolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
||||
>
|
||||
自定义日期
|
||||
</span>
|
||||
<DatePicker.RangePicker
|
||||
:value="props.modelValue.customDateRange"
|
||||
size="small"
|
||||
format="YYYY-MM-DD"
|
||||
:allow-clear="false"
|
||||
:placeholder="['开始', '结束']"
|
||||
class="overview-header-range-picker !h-8 !w-full !border-none !bg-transparent !text-sm !font-bold !text-slate-800 sm:!w-[220px] dark:!text-slate-200"
|
||||
@change="handleCustomDateRangeChange"
|
||||
/>
|
||||
<CalendarIcon class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300">{{ timeRangeLabel }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Popover>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
+209
-128
@@ -1,5 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
import { DatePicker, InputNumber, Select, Spin } from 'ant-design-vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { DatePicker, InputNumber, Popover, Select, Spin } from 'ant-design-vue';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
@@ -8,7 +12,6 @@ import { normalizeOverviewRangePickerChange } from '#/utils/overview-date-range'
|
||||
import {
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState,
|
||||
overviewToolbarLabelClass,
|
||||
overviewToolbarPanelClass,
|
||||
overviewToolbarShellClass,
|
||||
} from '../../../styles/overview-toolbar-classes';
|
||||
@@ -51,6 +54,40 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
});
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const openPopover = ref<string | null>(null);
|
||||
|
||||
function handlePopoverOpen(name: string, open: boolean) {
|
||||
if (open) {
|
||||
openPopover.value = name;
|
||||
} else if (openPopover.value === name) {
|
||||
openPopover.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
const ReceiptIcon = createIconifyIcon('lucide:receipt');
|
||||
const ShopIcon = createIconifyIcon('lucide:store');
|
||||
const CalendarIcon = createIconifyIcon('lucide:calendar');
|
||||
|
||||
const selectedShopName = computed(() => {
|
||||
const id = props.shopId;
|
||||
if (id == null || id <= 0) return '选择店铺';
|
||||
const opt = props.shopOptions?.find((o) => o.value === String(id));
|
||||
return opt?.label ?? `店铺 #${id}`;
|
||||
});
|
||||
|
||||
const timeRangeLabel = computed(() => {
|
||||
const t = props.modelValue.activeTimeRange;
|
||||
if (t === 'today') return '今日';
|
||||
if (t === 'yesterday') return '昨日';
|
||||
if (t === '7days') return '近7日';
|
||||
if (t === '30days') return '近30日';
|
||||
if (t === 'thisMonth') return '本月';
|
||||
if (props.modelValue.customDateRange) {
|
||||
return `${props.modelValue.customDateRange[0].format('M/D')}-${props.modelValue.customDateRange[1].format('M/D')}`;
|
||||
}
|
||||
return '日期';
|
||||
});
|
||||
|
||||
const handleShopSelectChange = (value: unknown) => {
|
||||
const id = Number(value);
|
||||
if (!Number.isFinite(id) || id <= 0) return;
|
||||
@@ -145,140 +182,184 @@ const handleTaxRateChange = (val: number | string | undefined) => {
|
||||
<div
|
||||
class="overview-header-extra flex w-full max-w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-2"
|
||||
>
|
||||
<div :class="overviewToolbarShellClass">
|
||||
<div :class="[overviewToolbarPanelClass, 'flex items-center gap-2 px-2 py-1']">
|
||||
<span class="shrink-0" :class="overviewToolbarLabelClass">税率</span>
|
||||
<InputNumber
|
||||
:value="props.modelValue.taxRate"
|
||||
:min="0"
|
||||
:max="1"
|
||||
:step="0.01"
|
||||
:precision="2"
|
||||
size="small"
|
||||
class="tax-rate-input !h-8 !w-20 !rounded-lg !border-none !bg-transparent !text-center !text-sm !font-bold !text-slate-800 !shadow-none dark:!text-slate-100"
|
||||
:formatter="formatTaxRate"
|
||||
:parser="parseTaxRate"
|
||||
@change="handleTaxRateChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
:class="[
|
||||
overviewToolbarShellClass,
|
||||
'min-w-0 sm:max-w-[min(calc(100vw-2.5rem),28rem)]',
|
||||
]"
|
||||
<!-- 税率 -->
|
||||
<Popover
|
||||
trigger="click"
|
||||
:open="openPopover === 'taxRate'"
|
||||
placement="bottom"
|
||||
@update:open="(val: boolean) => handlePopoverOpen('taxRate', val)"
|
||||
overlay-class-name="workbench-toolbar-popover"
|
||||
>
|
||||
<div
|
||||
:class="[
|
||||
overviewToolbarPanelClass,
|
||||
'flex min-w-0 items-center gap-2 p-1 px-2 sm:min-w-[16rem]',
|
||||
]"
|
||||
>
|
||||
<span class="w-9 shrink-0 text-right" :class="overviewToolbarLabelClass">
|
||||
店铺
|
||||
</span>
|
||||
<Select
|
||||
:value="props.shopId != null && props.shopId > 0 ? String(props.shopId) : undefined"
|
||||
size="small"
|
||||
show-search
|
||||
:filter-option="false"
|
||||
:loading="props.shopListLoading"
|
||||
:options="props.shopOptions"
|
||||
placeholder="选择店铺"
|
||||
:dropdown-match-select-width="false"
|
||||
class="overview-header-select overview-shop-select min-w-0 flex-1"
|
||||
@change="handleShopSelectChange"
|
||||
@search="(kw: string) => emit('shop-search', kw)"
|
||||
@popup-scroll="(e: Event) => emit('shop-popup-scroll', e)"
|
||||
@dropdown-visible-change="
|
||||
(open: boolean) => emit('shop-dropdown-visible-change', open)
|
||||
"
|
||||
<template #content>
|
||||
<div class="flex items-center gap-2 whitespace-nowrap">
|
||||
<span class="shrink-0 text-xs font-bold text-slate-700 dark:text-slate-300">
|
||||
税率
|
||||
</span>
|
||||
<InputNumber
|
||||
:value="props.modelValue.taxRate"
|
||||
:min="0"
|
||||
:max="1"
|
||||
:step="0.01"
|
||||
:precision="2"
|
||||
size="small"
|
||||
class="tax-rate-input !h-8 !w-20 !rounded-lg !border-none !bg-transparent !text-center !text-sm !font-bold !text-slate-800 !shadow-none dark:!text-slate-100"
|
||||
:formatter="formatTaxRate"
|
||||
:parser="parseTaxRate"
|
||||
@change="handleTaxRateChange"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<div :class="[overviewToolbarShellClass, 'cursor-pointer']">
|
||||
<div
|
||||
:class="[overviewToolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="props.shopListLoading" class="py-3 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-1 text-xs text-slate-600">加载中...</div>
|
||||
</div>
|
||||
<div v-else class="py-3 text-center text-xs text-slate-600">暂无店铺</div>
|
||||
</template>
|
||||
</Select>
|
||||
<ReceiptIcon class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300">税率{{ formatTaxRate(props.modelValue.taxRate) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Popover>
|
||||
|
||||
<div :class="overviewToolbarShellClass">
|
||||
<div
|
||||
:class="[overviewToolbarPanelClass, 'flex w-full items-center gap-1 overflow-x-auto p-1']"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === 'today'),
|
||||
]"
|
||||
@click="switchTimeRange('today')"
|
||||
<!-- 店铺 -->
|
||||
<Popover
|
||||
trigger="click"
|
||||
:open="openPopover === 'shop'"
|
||||
placement="bottom"
|
||||
@update:open="(val: boolean) => handlePopoverOpen('shop', val)"
|
||||
overlay-class-name="workbench-toolbar-popover"
|
||||
>
|
||||
<template #content>
|
||||
<div class="flex items-center gap-2 px-2 py-0.5" style="min-width: 200px;">
|
||||
<span
|
||||
class="w-9 shrink-0 text-right text-xs font-bold text-slate-700 dark:text-slate-300"
|
||||
>
|
||||
店铺
|
||||
</span>
|
||||
<Select
|
||||
:value="props.shopId != null && props.shopId > 0 ? String(props.shopId) : undefined"
|
||||
size="small"
|
||||
show-search
|
||||
:filter-option="false"
|
||||
:loading="props.shopListLoading"
|
||||
:options="props.shopOptions"
|
||||
placeholder="选择店铺"
|
||||
:dropdown-match-select-width="false"
|
||||
class="overview-header-select overview-shop-select min-w-0 flex-1"
|
||||
@change="handleShopSelectChange"
|
||||
@search="(kw: string) => emit('shop-search', kw)"
|
||||
@popup-scroll="(e: Event) => emit('shop-popup-scroll', e)"
|
||||
@dropdown-visible-change="
|
||||
(open: boolean) => emit('shop-dropdown-visible-change', open)
|
||||
"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="props.shopListLoading" class="py-3 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-1 text-xs text-slate-600">加载中...</div>
|
||||
</div>
|
||||
<div v-else class="py-3 text-center text-xs text-slate-600">暂无店铺</div>
|
||||
</template>
|
||||
</Select>
|
||||
</div>
|
||||
</template>
|
||||
<div :class="[overviewToolbarShellClass, 'cursor-pointer']">
|
||||
<div
|
||||
:class="[overviewToolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
||||
>
|
||||
今日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === 'yesterday'),
|
||||
]"
|
||||
@click="switchTimeRange('yesterday')"
|
||||
>
|
||||
昨日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === '7days'),
|
||||
]"
|
||||
@click="switchTimeRange('7days')"
|
||||
>
|
||||
近7日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === '30days'),
|
||||
]"
|
||||
@click="switchTimeRange('30days')"
|
||||
>
|
||||
近30日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === 'thisMonth'),
|
||||
]"
|
||||
@click="switchTimeRange('thisMonth')"
|
||||
>
|
||||
本月
|
||||
</button>
|
||||
<ShopIcon class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300">{{ selectedShopName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex w-full items-center justify-between gap-2 sm:w-auto sm:justify-start">
|
||||
<span
|
||||
class="hidden whitespace-nowrap sm:inline"
|
||||
:class="overviewToolbarLabelClass"
|
||||
</Popover>
|
||||
|
||||
<!-- 时间范围 -->
|
||||
<Popover
|
||||
trigger="click"
|
||||
:open="openPopover === 'timeRange'"
|
||||
placement="bottom"
|
||||
@update:open="(val: boolean) => handlePopoverOpen('timeRange', val)"
|
||||
overlay-class-name="workbench-toolbar-popover"
|
||||
>
|
||||
<template #content>
|
||||
<div class="flex flex-col gap-2 px-1 py-0.5">
|
||||
<div class="flex items-center gap-1 overflow-x-auto whitespace-nowrap">
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === 'today'),
|
||||
]"
|
||||
@click="switchTimeRange('today')"
|
||||
>
|
||||
今日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === 'yesterday'),
|
||||
]"
|
||||
@click="switchTimeRange('yesterday')"
|
||||
>
|
||||
昨日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === '7days'),
|
||||
]"
|
||||
@click="switchTimeRange('7days')"
|
||||
>
|
||||
近7日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === '30days'),
|
||||
]"
|
||||
@click="switchTimeRange('30days')"
|
||||
>
|
||||
近30日
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
overviewTimeRangeBtnClass,
|
||||
overviewTimeRangeBtnState(props.modelValue.activeTimeRange === 'thisMonth'),
|
||||
]"
|
||||
@click="switchTimeRange('thisMonth')"
|
||||
>
|
||||
本月
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span
|
||||
class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300"
|
||||
>
|
||||
自定义日期
|
||||
</span>
|
||||
<DatePicker.RangePicker
|
||||
:value="props.modelValue.customDateRange"
|
||||
size="small"
|
||||
format="YYYY-MM-DD"
|
||||
:allow-clear="false"
|
||||
:placeholder="['开始', '结束']"
|
||||
class="overview-header-range-picker !h-8 !w-full !border-none !bg-transparent !text-sm !font-bold !text-slate-800 sm:!w-[220px] dark:!text-slate-200"
|
||||
@change="handleCustomDateRangeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div :class="[overviewToolbarShellClass, 'cursor-pointer']">
|
||||
<div
|
||||
:class="[overviewToolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
||||
>
|
||||
自定义日期
|
||||
</span>
|
||||
<DatePicker.RangePicker
|
||||
:value="props.modelValue.customDateRange"
|
||||
size="small"
|
||||
format="YYYY-MM-DD"
|
||||
:allow-clear="false"
|
||||
:placeholder="['开始', '结束']"
|
||||
class="overview-header-range-picker !h-8 !w-full !border-none !bg-transparent !text-sm !font-bold !text-slate-800 sm:!w-[220px] dark:!text-slate-200"
|
||||
@change="handleCustomDateRangeChange"
|
||||
/>
|
||||
<CalendarIcon class="h-4 w-4 shrink-0" />
|
||||
<span class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300">{{ timeRangeLabel }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Popover>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user