merge store overview and home for wide mode
This commit is contained in:
@@ -149,6 +149,19 @@ html.theme-dark body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tab 页的内容宽度约束。
|
||||||
|
*
|
||||||
|
* 手机上内容本来就占满宽度,平板/横屏起限制最大宽度并居中,
|
||||||
|
* 避免入口卡片、设置列表、图表被拉成整屏宽的长条。
|
||||||
|
* 各页用 --tab-body-max 覆盖默认宽度(1rem = 16px)。
|
||||||
|
*/
|
||||||
|
.tab-body {
|
||||||
|
width: 100%;
|
||||||
|
max-width: var(--tab-body-max, 60rem);
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
.loading {
|
.loading {
|
||||||
margin: 1rem auto;
|
margin: 1rem auto;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
<h2 v-text="title" />
|
<h2 v-text="title" />
|
||||||
<span v-if="caption" class="caption" v-text="caption" />
|
<span v-if="caption" class="caption" v-text="caption" />
|
||||||
</div>
|
</div>
|
||||||
<div ref="chartElement" class="chart" :style="{ height }" />
|
<!-- min-height 而非 height:卡片在栅格里被拉伸时图表区能跟着 flex 填满 -->
|
||||||
|
<div ref="chartElement" class="chart" :style="{ minHeight: height }" />
|
||||||
<center-tips v-if="loading">
|
<center-tips v-if="loading">
|
||||||
<t-loading size="1.5rem" text="加载中" />
|
<t-loading size="1.5rem" text="加载中" />
|
||||||
</center-tips>
|
</center-tips>
|
||||||
@@ -78,10 +79,12 @@ function updateChartWidth(): void {
|
|||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.date-range-chart-card {
|
.date-range-chart-card {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
|
display: flex;
|
||||||
position: relative;
|
position: relative;
|
||||||
background: rgba(255, 255, 255, .92);
|
background: rgba(255, 255, 255, .92);
|
||||||
box-shadow: var(--td-shadow-1);
|
box-shadow: var(--td-shadow-1);
|
||||||
border-radius: 1.25rem;
|
border-radius: 1.25rem;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
gap: .5rem;
|
gap: .5rem;
|
||||||
@@ -103,18 +106,17 @@ function updateChartWidth(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.chart {
|
.chart {
|
||||||
|
flex: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(html.theme-dark) {
|
// :global 必须包住整条选择器,只包第一个 compound 会导致后代选择器被丢弃
|
||||||
.chart-section {
|
:global(html.theme-dark .date-range-chart-card) {
|
||||||
background: rgba(15, 23, 42, .88);
|
background: rgba(15, 23, 42, .88);
|
||||||
box-shadow: 0 .75rem 2rem rgba(2, 6, 23, .32);
|
box-shadow: 0 .75rem 2rem rgba(2, 6, 23, .32);
|
||||||
|
}
|
||||||
h2 {
|
:global(html.theme-dark .date-range-chart-card h2) {
|
||||||
color: #e2e8f0;
|
color: #e2e8f0;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -78,8 +78,15 @@ const tabList: TabItem[] = [
|
|||||||
{ value: "/store", icon: "shop-3", text: "门店", permission: permissionCodes.stat.read },
|
{ value: "/store", icon: "shop-3", text: "门店", permission: permissionCodes.stat.read },
|
||||||
{ value: "/management", icon: "setting-1", text: "管理" }
|
{ value: "/management", icon: "setting-1", text: "管理" }
|
||||||
];
|
];
|
||||||
|
/**
|
||||||
|
* 横屏平板(出现左侧导航栏)把门店并进客户页:左门店、右操作入口,
|
||||||
|
* 导航里不再单独保留门店入口。
|
||||||
|
*/
|
||||||
|
const mergedIntoCustomer = computed(() => railVisible.value);
|
||||||
|
|
||||||
const list = computed(() => tabList.filter(item => (
|
const list = computed(() => tabList.filter(item => (
|
||||||
(!item.permission || userStore.hasPermissions(item.permission, item.permissionMode))
|
(!mergedIntoCustomer.value || item.value !== "/store")
|
||||||
|
&& (!item.permission || userStore.hasPermissions(item.permission, item.permissionMode))
|
||||||
&& (!item.role || userStore.hasRoles(item.role, item.roleMode))
|
&& (!item.role || userStore.hasRoles(item.role, item.roleMode))
|
||||||
)));
|
)));
|
||||||
|
|
||||||
@@ -99,7 +106,10 @@ async function syncVisibleTab(): Promise<void> {
|
|||||||
tabVal.value = visiblePath;
|
tabVal.value = visiblePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (route.path === "/customers" && visiblePath !== "/customers") {
|
// 停在已隐藏的 tab 根路径上(如横屏下的 /store)时,回到第一个可见 tab;
|
||||||
|
// 只处理 tab 根路径,详情页不在这里跳转
|
||||||
|
const tabPath = resolveTabValue(route.path);
|
||||||
|
if (route.path === tabPath && (tabPath === "/customers" || tabPath === "/store") && visiblePath !== tabPath) {
|
||||||
await router.replace(visiblePath);
|
await router.replace(visiblePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ const {
|
|||||||
maxSliderValue,
|
maxSliderValue,
|
||||||
visibleDateTextList,
|
visibleDateTextList,
|
||||||
handleSliderChange
|
handleSliderChange
|
||||||
} = useStoreChartWindow(dateTextList);
|
} = useStoreChartWindow(dateTextList, chartWidth);
|
||||||
const { restDaySet } = useRestDayCalendar(dateTextList);
|
const { restDaySet } = useRestDayCalendar(dateTextList);
|
||||||
const chartOption = computed<EChartsOption>(() => ({
|
const chartOption = computed<EChartsOption>(() => ({
|
||||||
...buildStoreBaseChartOption(visibleDateTextList.value),
|
...buildStoreBaseChartOption(visibleDateTextList.value),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-can="permissionCodes.stat.read" class="store-data-charts">
|
<div v-can="permissionCodes.stat.read" class="store-data-charts">
|
||||||
|
<div class="chart-head">
|
||||||
<store-chart-summary v-entrance-transition :date-text-list="dateTextList" />
|
<store-chart-summary v-entrance-transition :date-text-list="dateTextList" />
|
||||||
<t-segmented
|
<t-segmented
|
||||||
v-model="chartMode"
|
v-model="chartMode"
|
||||||
@@ -8,6 +9,8 @@
|
|||||||
:options="chartModeOptions"
|
:options="chartModeOptions"
|
||||||
v-entrance-transition
|
v-entrance-transition
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="chart-grid" :class="{ compact }">
|
||||||
<template v-if="chartMode === 'event'">
|
<template v-if="chartMode === 'event'">
|
||||||
<store-event-record-calendar-section v-entrance-transition @list="toEventRecordList" />
|
<store-event-record-calendar-section v-entrance-transition @list="toEventRecordList" />
|
||||||
<store-event-record-trend-chart v-entrance-transition :date-text-list="dateTextList" />
|
<store-event-record-trend-chart v-entrance-transition :date-text-list="dateTextList" />
|
||||||
@@ -18,9 +21,9 @@
|
|||||||
<template v-if="chartMode === 'customer'">
|
<template v-if="chartMode === 'customer'">
|
||||||
<store-customer-growth-chart v-entrance-transition :date-text-list="dateTextList" />
|
<store-customer-growth-chart v-entrance-transition :date-text-list="dateTextList" />
|
||||||
<store-customer-age-chart v-entrance-transition />
|
<store-customer-age-chart v-entrance-transition />
|
||||||
|
<store-customer-gender-chart v-entrance-transition />
|
||||||
<store-customer-tag-word-cloud-chart v-entrance-transition />
|
<store-customer-tag-word-cloud-chart v-entrance-transition />
|
||||||
<store-customer-disease-word-cloud-chart v-entrance-transition />
|
<store-customer-disease-word-cloud-chart v-entrance-transition />
|
||||||
<store-customer-gender-chart v-entrance-transition />
|
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<store-point-daily-trend-chart v-entrance-transition :date-text-list="dateTextList" />
|
<store-point-daily-trend-chart v-entrance-transition :date-text-list="dateTextList" />
|
||||||
@@ -28,6 +31,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -47,6 +51,13 @@ import StorePointRedemptionRankChart from "@/pages/store/component/StorePointRed
|
|||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import type { EventRecordCalendarListPayload } from "@/components/EventRecordCalendar.vue";
|
import type { EventRecordCalendarListPayload } from "@/components/EventRecordCalendar.vue";
|
||||||
|
|
||||||
|
withDefaults(defineProps<{
|
||||||
|
/** 窄容器(平板横屏左侧分栏)里图表固定单列,不按视口宽度分两列 */
|
||||||
|
compact?: boolean;
|
||||||
|
}>(), {
|
||||||
|
compact: false
|
||||||
|
});
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "StoreDataCharts"
|
name: "StoreDataCharts"
|
||||||
});
|
});
|
||||||
@@ -129,15 +140,71 @@ function buildDateTextList(begin: Date, end: Date): string[] {
|
|||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.store-data-charts {
|
.store-data-charts {
|
||||||
gap: .5rem;
|
gap: 1rem;
|
||||||
padding: 0 1rem;
|
padding: 0 1rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
|
.chart-head {
|
||||||
|
gap: 1rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
.chart-mode {
|
.chart-mode {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图表栅格:手机上单列,平板起两列,没有独占整行的图。
|
||||||
|
* 同一行的卡片拉伸等高(默认 stretch),图表区 flex 填满卡片,
|
||||||
|
* 容器尺寸变化由 useStoreChart 的 ResizeObserver 负责重绘。
|
||||||
|
* compact 是分栏里的窄容器:保持单列和各图自身高度。
|
||||||
|
*/
|
||||||
|
.chart-grid {
|
||||||
|
gap: 1rem;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr);
|
||||||
|
|
||||||
|
@media (min-width: 48rem) {
|
||||||
|
|
||||||
|
&:not(.compact) {
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
|
||||||
|
> * {
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 各组件的 .chart 是固定高度,双列时改成随卡片拉伸
|
||||||
|
:deep(.chart-section),
|
||||||
|
:deep(.store-event-record-number-value-chart) {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.chart {
|
||||||
|
flex: 1;
|
||||||
|
height: auto;
|
||||||
|
min-height: 10rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 平板上统计卡和模式切换不必占满整行,限宽居中更紧凑
|
||||||
|
@media (min-width: 48rem) {
|
||||||
|
|
||||||
|
.chart-head > .summary {
|
||||||
|
max-width: 40rem;
|
||||||
|
margin: 1rem auto 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-mode {
|
||||||
|
max-width: 30rem;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.summary {
|
.summary {
|
||||||
gap: .75rem;
|
gap: .75rem;
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -168,22 +235,15 @@ function buildDateTextList(begin: Date, end: Date): string[] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(html.theme-dark) {
|
// :global 必须包住整条选择器——只包第一个 compound 时,后面的后代选择器会被编译器整条丢掉
|
||||||
.data-charts-page {
|
:global(html.theme-dark .store-data-charts .summary .item) {
|
||||||
.summary {
|
|
||||||
.item {
|
|
||||||
background: rgba(15, 23, 42, .88);
|
background: rgba(15, 23, 42, .88);
|
||||||
box-shadow: 0 .75rem 2rem rgba(2, 6, 23, .32);
|
box-shadow: 0 .75rem 2rem rgba(2, 6, 23, .32);
|
||||||
|
}
|
||||||
span {
|
:global(html.theme-dark .store-data-charts .summary .item span) {
|
||||||
color: #94a3b8;
|
color: #94a3b8;
|
||||||
}
|
}
|
||||||
|
:global(html.theme-dark .store-data-charts .summary .item strong) {
|
||||||
strong {
|
|
||||||
color: #e2e8f0;
|
color: #e2e8f0;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="store-event-record-number-value-chart">
|
<section ref="rootElement" class="store-event-record-number-value-chart">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h2>事件值变化</h2>
|
<h2>事件值变化</h2>
|
||||||
<t-button
|
<t-button
|
||||||
@@ -70,8 +70,10 @@ let statRequestId = 0;
|
|||||||
// ---------- 图表窗口 ----------
|
// ---------- 图表窗口 ----------
|
||||||
|
|
||||||
const dateTextList = computed(() => props.dateTextList);
|
const dateTextList = computed(() => props.dateTextList);
|
||||||
const { rangeText, showSlider, sliderValue, maxSliderValue, visibleDateTextList, handleSliderChange } = useStoreChartWindow(dateTextList);
|
const rootElement = ref<HTMLElement>();
|
||||||
const chartStyle = { height: "16rem" };
|
const chartWidth = ref(window.innerWidth);
|
||||||
|
const { rangeText, showSlider, sliderValue, maxSliderValue, visibleDateTextList, handleSliderChange } = useStoreChartWindow(dateTextList, chartWidth);
|
||||||
|
const chartStyle = { minHeight: "16rem" };
|
||||||
const chartOption = computed<EChartsOption>(() => ({
|
const chartOption = computed<EChartsOption>(() => ({
|
||||||
...buildStoreBaseChartOption(visibleDateTextList.value),
|
...buildStoreBaseChartOption(visibleDateTextList.value),
|
||||||
legend: { show: false },
|
legend: { show: false },
|
||||||
@@ -99,16 +101,33 @@ const chartOption = computed<EChartsOption>(() => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const { chartElement } = useStoreChart(chartOption);
|
const { chartElement } = useStoreChart(chartOption);
|
||||||
|
let resizeObserver: ResizeObserver | undefined;
|
||||||
|
|
||||||
watch([() => props.dateTextList, selectedEventId], async () => {
|
watch([() => props.dateTextList, selectedEventId], async () => {
|
||||||
await loadNumberValueStat();
|
await loadNumberValueStat();
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
// 图表未选中事件时不渲染,宽度只能从外层容器量
|
||||||
|
resizeObserver = new window.ResizeObserver(updateChartWidth);
|
||||||
|
if (rootElement.value) {
|
||||||
|
resizeObserver.observe(rootElement.value);
|
||||||
|
updateChartWidth();
|
||||||
|
}
|
||||||
await loadEvents();
|
await loadEvents();
|
||||||
await loadNumberValueStat();
|
await loadNumberValueStat();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
resizeObserver?.disconnect();
|
||||||
|
resizeObserver = undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
function updateChartWidth(): void {
|
||||||
|
// 减去容器左右各 1rem 内边距,贴近图表的实际宽度
|
||||||
|
chartWidth.value = Math.max(1, (rootElement.value?.clientWidth || window.innerWidth) - 32);
|
||||||
|
}
|
||||||
|
|
||||||
async function loadEvents(): Promise<void> {
|
async function loadEvents(): Promise<void> {
|
||||||
numberEventList.value = (await StoreChartAPI.listValidEvents()).filter(item => item.valueType === "NUMBER");
|
numberEventList.value = (await StoreChartAPI.listValidEvents()).filter(item => item.valueType === "NUMBER");
|
||||||
if (!selectedEventId.value) {
|
if (!selectedEventId.value) {
|
||||||
|
|||||||
@@ -49,12 +49,13 @@ const {
|
|||||||
maxSliderValue,
|
maxSliderValue,
|
||||||
visibleDateTextList,
|
visibleDateTextList,
|
||||||
handleSliderChange
|
handleSliderChange
|
||||||
} = useStoreChartWindow(dateTextList);
|
} = useStoreChartWindow(dateTextList, chartWidth);
|
||||||
const legendRowCount = computed(() => countLegendRows(eventList.value.map(event => event.name || "未命名事件")));
|
const legendRowCount = computed(() => countLegendRows(eventList.value.map(event => event.name || "未命名事件")));
|
||||||
const chartHeight = computed(() => `${16 + Math.max(0, legendRowCount.value - 1) * 1.5}rem`);
|
const chartHeight = computed(() => `${16 + Math.max(0, legendRowCount.value - 1) * 1.5}rem`);
|
||||||
const legendBottom = computed(() => 20 + legendRowCount.value * 24);
|
const legendBottom = computed(() => 20 + legendRowCount.value * 24);
|
||||||
|
// min-height instead of height: chart area flex-grows with the card in tablet grid
|
||||||
const chartStyle = computed(() => ({
|
const chartStyle = computed(() => ({
|
||||||
height: chartHeight.value
|
minHeight: chartHeight.value
|
||||||
}));
|
}));
|
||||||
const chartOption = computed<EChartsOption>(() => ({
|
const chartOption = computed<EChartsOption>(() => ({
|
||||||
...buildStoreBaseChartOption(visibleDateTextList.value),
|
...buildStoreBaseChartOption(visibleDateTextList.value),
|
||||||
|
|||||||
@@ -49,14 +49,15 @@ const {
|
|||||||
maxSliderValue,
|
maxSliderValue,
|
||||||
visibleDateTextList,
|
visibleDateTextList,
|
||||||
handleSliderChange
|
handleSliderChange
|
||||||
} = useStoreChartWindow(dateTextList);
|
} = useStoreChartWindow(dateTextList, chartWidth);
|
||||||
const visibleDateValueSet = computed(() => new Set(visibleDateTextList.value.map(getDateValue)));
|
const visibleDateValueSet = computed(() => new Set(visibleDateTextList.value.map(getDateValue)));
|
||||||
const shouldRotateAxisLabel = computed(() => eventList.value.length > 4 || eventList.value.some(item => 6 < getEventName(item).length));
|
const shouldRotateAxisLabel = computed(() => eventList.value.length > 4 || eventList.value.some(item => 6 < getEventName(item).length));
|
||||||
const legendRowCount = computed(() => countLegendRows(eventList.value.map(getEventName)));
|
const legendRowCount = computed(() => countLegendRows(eventList.value.map(getEventName)));
|
||||||
const chartHeight = computed(() => `${16 + Math.max(0, legendRowCount.value - 1) * 1.5}rem`);
|
const chartHeight = computed(() => `${16 + Math.max(0, legendRowCount.value - 1) * 1.5}rem`);
|
||||||
const legendBottom = computed(() => 20 + legendRowCount.value * 24);
|
const legendBottom = computed(() => 20 + legendRowCount.value * 24);
|
||||||
|
// min-height instead of height: chart area flex-grows with the card in tablet grid
|
||||||
const chartStyle = computed(() => ({
|
const chartStyle = computed(() => ({
|
||||||
height: chartHeight.value
|
minHeight: chartHeight.value
|
||||||
}));
|
}));
|
||||||
const chartOption = computed<EChartsOption>(() => ({
|
const chartOption = computed<EChartsOption>(() => ({
|
||||||
...buildStoreBaseChartOption(props.dateTextList),
|
...buildStoreBaseChartOption(props.dateTextList),
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ const {
|
|||||||
maxSliderValue,
|
maxSliderValue,
|
||||||
visibleDateTextList,
|
visibleDateTextList,
|
||||||
handleSliderChange
|
handleSliderChange
|
||||||
} = useStoreChartWindow(dateTextList);
|
} = useStoreChartWindow(dateTextList, chartWidth);
|
||||||
const chartOption = computed<EChartsOption>(() => {
|
const chartOption = computed<EChartsOption>(() => {
|
||||||
const labelList = visibleDateTextList.value.map(item => item.slice(5));
|
const labelList = visibleDateTextList.value.map(item => item.slice(5));
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ export function buildStoreBaseChartOption(dateTextList: string[]): EChartsOption
|
|||||||
export function useStoreChart(option: ComputedRef<EChartsOption> | Ref<EChartsOption>) {
|
export function useStoreChart(option: ComputedRef<EChartsOption> | Ref<EChartsOption>) {
|
||||||
const chartElement = ref<HTMLElement>();
|
const chartElement = ref<HTMLElement>();
|
||||||
let chart: ECharts | undefined;
|
let chart: ECharts | undefined;
|
||||||
|
let resizeObserver: ResizeObserver | undefined;
|
||||||
|
|
||||||
watch(option, async () => {
|
watch(option, async () => {
|
||||||
await nextTick();
|
await nextTick();
|
||||||
@@ -75,9 +76,17 @@ export function useStoreChart(option: ComputedRef<EChartsOption> | Ref<EChartsOp
|
|||||||
await nextTick();
|
await nextTick();
|
||||||
renderChart();
|
renderChart();
|
||||||
window.addEventListener("resize", resizeChart);
|
window.addEventListener("resize", resizeChart);
|
||||||
|
// 平板栅格下卡片会被同行伙伴拉伸(如日历异步加载撑高行),
|
||||||
|
// 视口没有 resize,必须观察容器自身尺寸
|
||||||
|
if (chartElement.value && typeof ResizeObserver !== "undefined") {
|
||||||
|
resizeObserver = new ResizeObserver(() => resizeChart());
|
||||||
|
resizeObserver.observe(chartElement.value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
resizeObserver?.disconnect();
|
||||||
|
resizeObserver = undefined;
|
||||||
window.removeEventListener("resize", resizeChart);
|
window.removeEventListener("resize", resizeChart);
|
||||||
chart?.dispose();
|
chart?.dispose();
|
||||||
chart = undefined;
|
chart = undefined;
|
||||||
@@ -101,11 +110,19 @@ export function useStoreChart(option: ComputedRef<EChartsOption> | Ref<EChartsOp
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useStoreChartWindow(dateTextList: ComputedRef<string[]>) {
|
/**
|
||||||
|
* 时间窗:按图表实际宽度决定一次显示多少天。
|
||||||
|
*
|
||||||
|
* 平板上图表会被放进双列栅格,视口宽度不再等于图表宽度,
|
||||||
|
* 所以优先用外部传入的实测宽度(ResizeObserver),拿不到时再退回视口宽度。
|
||||||
|
*/
|
||||||
|
export function useStoreChartWindow(dateTextList: ComputedRef<string[]>, chartWidth?: Ref<number>) {
|
||||||
const sliderValue = ref<number[]>([0, 0]);
|
const sliderValue = ref<number[]>([0, 0]);
|
||||||
const viewportWidth = ref(window.innerWidth);
|
const viewportWidth = ref(window.innerWidth);
|
||||||
let isSliderInitialized = false;
|
let isUserAdjusted = false;
|
||||||
const visibleDayCount = computed(() => Math.max(6, Math.floor(viewportWidth.value / 64)));
|
const measuredWidth = computed(() => chartWidth?.value || 0);
|
||||||
|
const chartViewportWidth = computed(() => (0 < measuredWidth.value ? measuredWidth.value : viewportWidth.value));
|
||||||
|
const visibleDayCount = computed(() => Math.max(6, Math.floor(chartViewportWidth.value / 64)));
|
||||||
const maxSliderValue = computed(() => Math.max(0, dateTextList.value.length - 1));
|
const maxSliderValue = computed(() => Math.max(0, dateTextList.value.length - 1));
|
||||||
const visibleDateTextList = computed(() => dateTextList.value.slice(sliderValue.value[0], sliderValue.value[1] + 1));
|
const visibleDateTextList = computed(() => dateTextList.value.slice(sliderValue.value[0], sliderValue.value[1] + 1));
|
||||||
const showSlider = computed(() => visibleDayCount.value < dateTextList.value.length);
|
const showSlider = computed(() => visibleDayCount.value < dateTextList.value.length);
|
||||||
@@ -117,11 +134,12 @@ export function useStoreChartWindow(dateTextList: ComputedRef<string[]>) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
watch(maxSliderValue, value => {
|
watch(maxSliderValue, value => {
|
||||||
if (!isSliderInitialized) {
|
// 用户拖过滑块之后只做越界收敛,不覆盖他的选择
|
||||||
|
if (!isUserAdjusted) {
|
||||||
sliderValue.value = getLatestSliderRange();
|
sliderValue.value = getLatestSliderRange();
|
||||||
isSliderInitialized = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [start, end] = sliderValue.value;
|
const [start, end] = sliderValue.value;
|
||||||
if (value < end) {
|
if (value < end) {
|
||||||
sliderValue.value = [Math.max(0, value - Math.max(0, end - start)), value];
|
sliderValue.value = [Math.max(0, value - Math.max(0, end - start)), value];
|
||||||
@@ -130,6 +148,15 @@ export function useStoreChartWindow(dateTextList: ComputedRef<string[]>) {
|
|||||||
immediate: true
|
immediate: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 图表宽度变化(转屏、平板双列)时跟着调整可见天数
|
||||||
|
watch(visibleDayCount, () => {
|
||||||
|
if (isUserAdjusted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sliderValue.value = getLatestSliderRange();
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
window.addEventListener("resize", updateViewportWidth);
|
window.addEventListener("resize", updateViewportWidth);
|
||||||
});
|
});
|
||||||
@@ -142,6 +169,8 @@ export function useStoreChartWindow(dateTextList: ComputedRef<string[]>) {
|
|||||||
if (!Array.isArray(value)) {
|
if (!Array.isArray(value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isUserAdjusted = true;
|
||||||
const [start = 0, end = start] = value;
|
const [start = 0, end = start] = value;
|
||||||
sliderValue.value = [start, Math.max(start, end)];
|
sliderValue.value = [start, Math.max(start, end)];
|
||||||
}
|
}
|
||||||
|
|||||||
+76
-258
@@ -1,316 +1,134 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tui-page-layout tui-navbar home-tab">
|
<div class="tui-page-layout tui-navbar home-tab">
|
||||||
<t-navbar
|
<t-navbar
|
||||||
|
v-if="!mergedLayout"
|
||||||
fixed
|
fixed
|
||||||
:z-index="20"
|
:z-index="20"
|
||||||
title="客户"
|
title="客户"
|
||||||
>
|
>
|
||||||
<template #right>
|
<template #right>
|
||||||
<t-badge
|
<navbar-notify-button />
|
||||||
v-if="canReadNotify"
|
</template>
|
||||||
class="notification-badge"
|
</t-navbar>
|
||||||
:count="unreadNotifyCount"
|
<main class="tui-page-content" :class="mergedLayout ? 'wide-split' : 'scroll column'">
|
||||||
:offset="[-6, 6]"
|
<!-- 平板横屏:门店与客户合并成一页,两栏各自保留导航栏 -->
|
||||||
:max-count="99"
|
<div v-if="mergedLayout" class="split">
|
||||||
:show-zero="false"
|
<section class="pane store-pane">
|
||||||
>
|
<t-navbar :z-index="20" title="门店">
|
||||||
|
<template #right>
|
||||||
<t-button
|
<t-button
|
||||||
aria-label="通知"
|
aria-label="刷新"
|
||||||
@click="router.push('/notify')"
|
@click="storeOverviewRef?.refresh()"
|
||||||
theme="default"
|
theme="default"
|
||||||
shape="square"
|
|
||||||
variant="text"
|
variant="text"
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
<t-icon name="notification" size="1.25rem" />
|
<t-icon name="refresh" size="1.25rem" />
|
||||||
</t-button>
|
</t-button>
|
||||||
</t-badge>
|
|
||||||
</template>
|
</template>
|
||||||
</t-navbar>
|
</t-navbar>
|
||||||
<main class="tui-page-content scroll column">
|
<div class="pane-body">
|
||||||
<pending-notice-bar />
|
<store-overview ref="storeOverviewRef" compact />
|
||||||
<section
|
|
||||||
v-for="group in visibleEntryGroupList"
|
|
||||||
:key="group.title"
|
|
||||||
class="entry-group"
|
|
||||||
>
|
|
||||||
<h2 v-text="group.title"/>
|
|
||||||
<div class="items" :class="group.layout">
|
|
||||||
<div
|
|
||||||
v-for="item in group.entryList"
|
|
||||||
:key="item.path"
|
|
||||||
class="item-wrap"
|
|
||||||
v-entrance-transition="{ step: 30 }"
|
|
||||||
>
|
|
||||||
<t-button
|
|
||||||
class="item"
|
|
||||||
:class="{ quick: item.path === '/customer/quick-sign-in' || item.path === '/management/order-fulfillments/quick' }"
|
|
||||||
variant="text"
|
|
||||||
@click="router.push(item.path)"
|
|
||||||
>
|
|
||||||
<div class="body">
|
|
||||||
<t-icon :name="item.icon" size="1.75rem"/>
|
|
||||||
<h2 v-text="item.title"/>
|
|
||||||
</div>
|
|
||||||
</t-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<div class="help-wrap" v-entrance-transition>
|
<section class="pane entry-pane">
|
||||||
<t-button
|
<t-navbar :z-index="20" title="客户">
|
||||||
class="help"
|
<template #right>
|
||||||
theme="primary"
|
<navbar-notify-button />
|
||||||
variant="text"
|
|
||||||
content="使用帮助"
|
|
||||||
@click="router.push('/management/help')"
|
|
||||||
>
|
|
||||||
<template #icon>
|
|
||||||
<t-icon name="help-circle"/>
|
|
||||||
</template>
|
</template>
|
||||||
</t-button>
|
</t-navbar>
|
||||||
<t-button
|
<div class="pane-body">
|
||||||
v-if="canUseAi"
|
<pending-notice-bar />
|
||||||
class="ai"
|
<customer-entry-panel />
|
||||||
theme="primary"
|
|
||||||
variant="text"
|
|
||||||
content="AI 小糕"
|
|
||||||
@click="openAiChat"
|
|
||||||
>
|
|
||||||
<template #icon>
|
|
||||||
<t-icon name="robot-2" />
|
|
||||||
</template>
|
|
||||||
</t-button>
|
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
<template v-else>
|
||||||
|
<div class="tab-body">
|
||||||
|
<pending-notice-bar />
|
||||||
|
<customer-entry-panel />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { NotifyAPI, useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
|
import { useLayout } from "timi-tdesign-mobile";
|
||||||
import PendingNoticeBar from "./component/PendingNoticeBar.vue";
|
import PendingNoticeBar from "./component/PendingNoticeBar.vue";
|
||||||
import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import CustomerEntryPanel from "./component/CustomerEntryPanel.vue";
|
||||||
|
import NavbarNotifyButton from "./component/NavbarNotifyButton.vue";
|
||||||
|
import StoreOverview from "./component/StoreOverview.vue";
|
||||||
|
import { permissionCodes } from "@/utils/permission";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "HomeTab"
|
name: "HomeTab"
|
||||||
});
|
});
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const unreadNotifyCount = ref(0);
|
|
||||||
|
|
||||||
interface HomeEntry {
|
|
||||||
path: string;
|
|
||||||
permission: string;
|
|
||||||
icon: string;
|
|
||||||
title: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface HomeEntryGroup {
|
|
||||||
title: string;
|
|
||||||
layout?: "customer";
|
|
||||||
entryList: HomeEntry[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const entryGroupList: HomeEntryGroup[] = [
|
|
||||||
{
|
|
||||||
title: "客户管理",
|
|
||||||
layout: "customer",
|
|
||||||
entryList: [
|
|
||||||
{
|
|
||||||
path: "/management/customers/create?redirect=/customers",
|
|
||||||
permission: permissionCodes.customer.create,
|
|
||||||
icon: "user-add",
|
|
||||||
title: "录入"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/customer/registration",
|
|
||||||
permission: permissionCodes.eventRecord.create,
|
|
||||||
icon: "task-checked",
|
|
||||||
title: "登记"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/customer/quick-sign-in",
|
|
||||||
permission: permissionCodes.eventRecord.create,
|
|
||||||
icon: "scan",
|
|
||||||
title: "快速扫码登记"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "订单管理",
|
|
||||||
entryList: [
|
|
||||||
{
|
|
||||||
path: "/management/sales-orders/create",
|
|
||||||
permission: permissionCodes.salesOrder.create,
|
|
||||||
icon: "task-add",
|
|
||||||
title: "创建产品订单"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/management/customer-packages/create",
|
|
||||||
permission: permissionCodes.customerPackage.create,
|
|
||||||
icon: "layers",
|
|
||||||
title: "创建套餐订单"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/management/order-fulfillments/quick",
|
|
||||||
permission: permissionCodes.orderFulfillment.create,
|
|
||||||
icon: "undertake-delivery",
|
|
||||||
title: "快速履约"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/management/sales-orders",
|
|
||||||
permission: permissionCodes.salesOrder.read,
|
|
||||||
icon: "task",
|
|
||||||
title: "销售订单"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/management/points/redemptions",
|
|
||||||
permission: permissionCodes.pointRedemption.create,
|
|
||||||
icon: "gift",
|
|
||||||
title: "积分兑换"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const visibleEntryGroupList = computed(() => entryGroupList
|
|
||||||
.map(group => ({
|
|
||||||
...group,
|
|
||||||
entryList: group.entryList.filter(item => userStore.hasPermissions(item.permission))
|
|
||||||
}))
|
|
||||||
.filter(group => group.entryList.length));
|
|
||||||
const canReadNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.read));
|
|
||||||
const canUseAi = computed(() => userStore.hasRoles(gaoRoleCodes.storeManager));
|
|
||||||
|
|
||||||
async function openAiChat(): Promise<void> {
|
|
||||||
await router.push("/ai/chat");
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadUnreadNotifyCount(): Promise<void> {
|
|
||||||
try {
|
|
||||||
unreadNotifyCount.value = Math.max(0, await NotifyAPI.countUnreadInternal());
|
|
||||||
} catch (error) {
|
|
||||||
unreadNotifyCount.value = 0;
|
|
||||||
console.warn("未读通知数量加载失败", error);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
if (canReadNotify.value) {
|
|
||||||
await loadUnreadNotifyCount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// 横屏平板(出现左侧导航栏)才合并门店与客户入口;
|
||||||
|
// 没有统计权限的账号本来就没有门店 tab,这里同样不显示左侧分栏
|
||||||
|
const { isWide } = useLayout({ tablet: true });
|
||||||
|
const mergedLayout = computed(() => isWide.value && userStore.hasPermissions(permissionCodes.stat.read));
|
||||||
|
const storeOverviewRef = ref<InstanceType<typeof StoreOverview>>();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.home-tab {
|
.home-tab {
|
||||||
|
|
||||||
.entry-group {
|
.wide-split {
|
||||||
margin: 0 1rem;
|
overflow: hidden;
|
||||||
|
padding-top: 0;
|
||||||
& + & {
|
padding-bottom: 0;
|
||||||
margin-top: 1.5rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
> h2 {
|
.split {
|
||||||
color: #52607a;
|
flex: 1;
|
||||||
margin: 0 0 .75rem 0;
|
|
||||||
font-size: .875rem;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
.items {
|
|
||||||
--td-button-border-radius: 1.75rem;
|
|
||||||
|
|
||||||
gap: .875rem;
|
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
min-height: 0;
|
||||||
|
grid-template-columns: minmax(0, 1fr) clamp(24rem, 28vw, 28rem);
|
||||||
|
}
|
||||||
|
|
||||||
.item {
|
.pane {
|
||||||
--entry-color: #0f766e;
|
|
||||||
--entry-color-active: #0a5d56;
|
|
||||||
--entry-background: rgba(255, 255, 255, .92);
|
|
||||||
|
|
||||||
color: var(--entry-color);
|
|
||||||
width: 100%;
|
|
||||||
height: auto;
|
|
||||||
margin: 0;
|
|
||||||
padding: 1rem;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
position: relative;
|
position: relative;
|
||||||
text-align: center;
|
min-height: 0;
|
||||||
background: var(--entry-background);
|
overflow: hidden;
|
||||||
box-shadow: 0 .75rem 2rem rgba(15, 23, 42, .08);
|
|
||||||
align-items: center;
|
|
||||||
aspect-ratio: 1;
|
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
|
||||||
|
|
||||||
&.quick {
|
&:first-child {
|
||||||
--td-button-default-text-active-bg-color: var(--entry-color-active);
|
border-right: 1px solid var(--td-component-border);
|
||||||
|
|
||||||
color: var(--entry-background);
|
|
||||||
background: var(--entry-color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.body {
|
// 栏内导航栏贴在栏顶,内容从它下方滚过,和整页的毛玻璃效果一致
|
||||||
inset: 1rem;
|
.t-navbar {
|
||||||
display: flex;
|
top: 0;
|
||||||
gap: .5rem;
|
left: 0;
|
||||||
|
right: 0;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
align-items: center;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
|
|
||||||
h2 {
|
// navbar 默认 fixed:内容层原本贴着视口,这里收回栏内;
|
||||||
margin: 0;
|
// 占位块是给 fixed 模式撑高度用的,栏内不需要
|
||||||
font-size: .75rem;
|
:deep(.t-navbar__content) {
|
||||||
line-height: 1.5;
|
left: 0;
|
||||||
}
|
right: 0;
|
||||||
}
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.t-navbar__placeholder) {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.help-wrap {
|
.pane-body {
|
||||||
--td-button-border-radius: 1rem;
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
gap: 1rem;
|
overflow: auto;
|
||||||
width: fit-content;
|
padding-top: calc(var(--tui-nav-height, 48px) + 1rem);
|
||||||
margin: 1rem auto 0 auto;
|
padding-bottom: 1rem;
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
.help,
|
|
||||||
.ai {
|
|
||||||
width: 8rem;
|
|
||||||
background: white;
|
|
||||||
box-shadow: var(--td-shadow-3);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(html.theme-dark) {
|
|
||||||
.entry-page {
|
|
||||||
.entry-group > h2 {
|
|
||||||
color: #94a3b8;
|
|
||||||
}
|
|
||||||
|
|
||||||
.item {
|
|
||||||
--entry-background: rgba(15, 23, 42, .88);
|
|
||||||
box-shadow: 0 .75rem 2rem rgba(2, 6, 23, .32);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.notification-badge {
|
|
||||||
:deep(.t-badge__content) {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<t-navbar fixed :z-index="20" title="产品" />
|
<t-navbar fixed :z-index="20" title="产品" />
|
||||||
<main class="tui-page-content scroll column product-tab">
|
<main class="tui-page-content scroll column product-tab">
|
||||||
|
<div class="tab-body menu-grid">
|
||||||
<t-cell-group
|
<t-cell-group
|
||||||
v-for="(group, index) in visibleMenuGroupList"
|
v-for="(group, index) in visibleMenuGroupList"
|
||||||
:key="group.title"
|
:key="group.title"
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</t-cell>
|
</t-cell>
|
||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
|
</div>
|
||||||
<center-tips v-if="!visibleMenuGroupList.length" :content="'当前账号暂无产品管理权限'" />
|
<center-tips v-if="!visibleMenuGroupList.length" :content="'当前账号暂无产品管理权限'" />
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
@@ -178,5 +180,35 @@ async function go(path: string): Promise<void> {
|
|||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.product-tab {
|
.product-tab {
|
||||||
gap: .5rem;
|
gap: .5rem;
|
||||||
|
|
||||||
|
.tab-body {
|
||||||
|
--tab-body-max: 72rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平板起分组卡片并排:同一屏能看到更多分组,
|
||||||
|
* 行宽也不会被拉到整屏宽(手机形态完全不变)。
|
||||||
|
*/
|
||||||
|
.menu-grid {
|
||||||
|
gap: .5rem;
|
||||||
|
display: grid;
|
||||||
|
padding: 0 1rem;
|
||||||
|
align-items: start;
|
||||||
|
grid-template-columns: minmax(0, 1fr);
|
||||||
|
|
||||||
|
// 卡片自带 16px 外边距,进栅格后间距交给容器的 padding 和 gap
|
||||||
|
:deep(.t-cell-group--card) {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 48rem) {
|
||||||
|
gap: .75rem;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 80rem) {
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<t-navbar fixed :z-index="20" title="管理" />
|
<t-navbar fixed :z-index="20" title="管理" />
|
||||||
<main class="tui-page-content scroll column management-tab">
|
<main class="tui-page-content scroll column management-tab">
|
||||||
|
<div class="tab-body">
|
||||||
|
<div class="menu-grid">
|
||||||
<t-cell-group class="user-card" theme="card" v-entrance-transition>
|
<t-cell-group class="user-card" theme="card" v-entrance-transition>
|
||||||
<t-cell
|
<t-cell
|
||||||
v-if="currentUser"
|
v-if="currentUser"
|
||||||
@@ -60,10 +62,12 @@
|
|||||||
</template>
|
</template>
|
||||||
</t-cell>
|
</t-cell>
|
||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
|
</div>
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<p>技术支持:夜雨</p>
|
<p>技术支持:夜雨</p>
|
||||||
<p>Copyright © 2026 imyeyu.com</p>
|
<p>Copyright © 2026 imyeyu.com</p>
|
||||||
</footer>
|
</footer>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -333,6 +337,54 @@ onBeforeRouteLeave(() => {
|
|||||||
.management-tab {
|
.management-tab {
|
||||||
gap: .5rem;
|
gap: .5rem;
|
||||||
|
|
||||||
|
.tab-body {
|
||||||
|
--tab-body-max: 72rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平板起分组卡片并排,同一行的卡片拉伸等高(默认 stretch),
|
||||||
|
* 账户卡片独占一行当页头——它只有一条 cell,
|
||||||
|
* 和分组卡片并排会在下面留下一大块空白。
|
||||||
|
* 手机上仍是单列,间距保持 .5rem。
|
||||||
|
*/
|
||||||
|
.menu-grid {
|
||||||
|
gap: .5rem;
|
||||||
|
display: grid;
|
||||||
|
padding: 0 1rem;
|
||||||
|
grid-template-columns: minmax(0, 1fr);
|
||||||
|
|
||||||
|
// 卡片自带 16px 外边距,进栅格后间距交给容器的 padding 和 gap
|
||||||
|
:deep(.t-cell-group--card) {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 48rem) {
|
||||||
|
gap: .75rem;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
|
||||||
|
.user-card {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cell-group 的白色在 cell 上,根节点被拉伸后下半截是透明的,
|
||||||
|
* 同行的卡片看起来还是高矮不一;把容器色补到根上才是真正等高。
|
||||||
|
* 标题自带的灰底在卡片里会变成一条灰带,一并清掉。
|
||||||
|
*/
|
||||||
|
:deep(.t-cell-group--card) {
|
||||||
|
background: var(--td-bg-color-container, #fff);
|
||||||
|
|
||||||
|
.t-cell-group__title {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 80rem) {
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.user-card {
|
.user-card {
|
||||||
|
|
||||||
.info {
|
.info {
|
||||||
|
|||||||
+6
-201
@@ -3,7 +3,7 @@
|
|||||||
<template #right>
|
<template #right>
|
||||||
<t-button
|
<t-button
|
||||||
aria-label="刷新"
|
aria-label="刷新"
|
||||||
@click="refreshCharts"
|
@click="storeOverviewRef?.refresh()"
|
||||||
theme="default"
|
theme="default"
|
||||||
variant="text"
|
variant="text"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -13,213 +13,18 @@
|
|||||||
</template>
|
</template>
|
||||||
</t-navbar>
|
</t-navbar>
|
||||||
<main class="tui-page-content scroll column store-tab">
|
<main class="tui-page-content scroll column store-tab">
|
||||||
<t-cell-group
|
<div class="tab-body">
|
||||||
v-if="canViewStore || canManageStore"
|
<store-overview ref="storeOverviewRef" />
|
||||||
theme="card"
|
</div>
|
||||||
v-entrance-transition
|
|
||||||
>
|
|
||||||
<t-cell
|
|
||||||
v-if="canViewStore"
|
|
||||||
class="info"
|
|
||||||
:title="currentStoreStore.currentStoreName"
|
|
||||||
:description="currentStore?.address"
|
|
||||||
/>
|
|
||||||
<t-cell
|
|
||||||
v-if="canSelectStore"
|
|
||||||
class="action"
|
|
||||||
title="切换门店"
|
|
||||||
note="选择使用门店"
|
|
||||||
arrow
|
|
||||||
hover
|
|
||||||
@click="openStorePicker"
|
|
||||||
>
|
|
||||||
<template #leftIcon>
|
|
||||||
<t-icon name="swap" />
|
|
||||||
</template>
|
|
||||||
</t-cell>
|
|
||||||
<t-cell
|
|
||||||
v-if="canManageStore"
|
|
||||||
class="action"
|
|
||||||
title="门店管理"
|
|
||||||
note="管理门店资料和营业日"
|
|
||||||
arrow
|
|
||||||
hover
|
|
||||||
@click="goStoreManagement"
|
|
||||||
>
|
|
||||||
<template #leftIcon>
|
|
||||||
<t-icon name="shop-3" />
|
|
||||||
</template>
|
|
||||||
</t-cell>
|
|
||||||
<t-cell
|
|
||||||
v-if="canManageStoreDiary"
|
|
||||||
class="action"
|
|
||||||
title="门店日记"
|
|
||||||
note="记录门店经营日常"
|
|
||||||
arrow
|
|
||||||
hover
|
|
||||||
@click="goStoreDiaryManagement"
|
|
||||||
>
|
|
||||||
<template #leftIcon>
|
|
||||||
<t-icon name="file" />
|
|
||||||
</template>
|
|
||||||
</t-cell>
|
|
||||||
</t-cell-group>
|
|
||||||
<store-data-charts :key="`${currentStoreStore.currentStoreId}-${chartRefreshKey}`" />
|
|
||||||
<t-popup v-model="storePickerVisible" placement="bottom">
|
|
||||||
<t-picker
|
|
||||||
v-model="storePickerDraft"
|
|
||||||
:columns="storePickerColumns"
|
|
||||||
title="切换门店"
|
|
||||||
@cancel="storePickerVisible = false"
|
|
||||||
@confirm="confirmStorePicker"
|
|
||||||
/>
|
|
||||||
</t-popup>
|
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Message } from "@/utils/message";
|
import StoreOverview from "@/pages/tabs/component/StoreOverview.vue";
|
||||||
import { useUserStore } from "timi-web-api";
|
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
|
||||||
import { clearStoreChartCache } from "@/utils/storeChartCache";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import { gaoRoleCodes, gaoStoreScopePermissionCodes, permissionCodes } from "@/utils/permission";
|
|
||||||
|
|
||||||
type PickerValue = string | number;
|
|
||||||
|
|
||||||
const StoreDataCharts = defineAsyncComponent(() => import("@/pages/store/component/StoreDataCharts.vue"));
|
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "StoreTab"
|
name: "StoreTab"
|
||||||
});
|
});
|
||||||
|
|
||||||
const router = useRouter();
|
const storeOverviewRef = ref<InstanceType<typeof StoreOverview>>();
|
||||||
const userStore = useUserStore();
|
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
|
||||||
const chartRefreshKey = ref(0);
|
|
||||||
|
|
||||||
const currentStore = computed(() => currentStoreStore.currentStore);
|
|
||||||
const canSelectStore = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
|
||||||
const canLoadLoginStore = computed(() => userStore.hasPermissions(gaoStoreScopePermissionCodes, "or"));
|
|
||||||
const canViewStore = computed(() => canSelectStore.value || canLoadLoginStore.value);
|
|
||||||
const canManageStore = computed(() => userStore.hasRoles([
|
|
||||||
gaoRoleCodes.globalManager,
|
|
||||||
gaoRoleCodes.storeManager
|
|
||||||
], "or") && userStore.hasPermissions(permissionCodes.store.read));
|
|
||||||
const canManageStoreDiary = computed(() => userStore.hasRoles(gaoRoleCodes.storeManager)
|
|
||||||
&& userStore.hasPermissions(permissionCodes.storeDiary.create));
|
|
||||||
|
|
||||||
// ---------- 门店切换 ----------
|
|
||||||
|
|
||||||
const storePickerVisible = ref(false);
|
|
||||||
const storePickerDraft = ref<PickerValue[]>([]);
|
|
||||||
const storePickerColumns = computed(() => [
|
|
||||||
currentStoreStore.storeList.map(item => ({
|
|
||||||
label: item.name || item.code || "未命名门店",
|
|
||||||
value: item.id || ""
|
|
||||||
})).filter(item => item.value)
|
|
||||||
]);
|
|
||||||
|
|
||||||
function openStorePicker(): void {
|
|
||||||
if (!canSelectStore.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!currentStoreStore.storeList.length) {
|
|
||||||
Message.warning("暂无可选门店");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
storePickerDraft.value = [currentStoreStore.currentStoreId];
|
|
||||||
storePickerVisible.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function confirmStorePicker(): void {
|
|
||||||
const storeId = String(storePickerDraft.value[0] || "");
|
|
||||||
if (!storeId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
currentStoreStore.selectStore(storeId);
|
|
||||||
storePickerVisible.value = false;
|
|
||||||
Message.success("当前门店已切换");
|
|
||||||
}
|
|
||||||
|
|
||||||
function refreshCharts(): void {
|
|
||||||
clearStoreChartCache();
|
|
||||||
chartRefreshKey.value++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- 门店管理 ----------
|
|
||||||
|
|
||||||
async function goStoreManagement(): Promise<void> {
|
|
||||||
if (canSelectStore.value) {
|
|
||||||
await router.push("/management/stores");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const store = await currentStoreStore.loadLoginStore();
|
|
||||||
if (!store?.id) {
|
|
||||||
Message.warning("未绑定所属门店");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await router.push(`/management/stores/${store.id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function goStoreDiaryManagement(): Promise<void> {
|
|
||||||
if (!canManageStoreDiary.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const store = await currentStoreStore.loadLoginStore();
|
|
||||||
if (!store?.id) {
|
|
||||||
Message.warning("未绑定所属门店");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await router.push({ name: "StoreDiaryList" });
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
if (canSelectStore.value) {
|
|
||||||
await currentStoreStore.loadStoreList();
|
|
||||||
} else if (canLoadLoginStore.value) {
|
|
||||||
await currentStoreStore.loadLoginStore();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
|
||||||
.store-tab {
|
|
||||||
.store-header {
|
|
||||||
|
|
||||||
.store-card {
|
|
||||||
|
|
||||||
.info {
|
|
||||||
:deep(.t-cell__title-text) {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
:global(html.theme-dark) {
|
|
||||||
.store-tab {
|
|
||||||
.store-card {
|
|
||||||
.info {
|
|
||||||
:deep(.t-cell__description) {
|
|
||||||
color: #94a3b8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -0,0 +1,258 @@
|
|||||||
|
<template>
|
||||||
|
<div class="entry-panel">
|
||||||
|
<section
|
||||||
|
v-for="group in visibleEntryGroupList"
|
||||||
|
:key="group.title"
|
||||||
|
class="entry-group"
|
||||||
|
>
|
||||||
|
<h2 v-text="group.title"/>
|
||||||
|
<div class="items" :class="group.layout">
|
||||||
|
<div
|
||||||
|
v-for="item in group.entryList"
|
||||||
|
:key="item.path"
|
||||||
|
class="item-wrap"
|
||||||
|
v-entrance-transition="{ step: 30 }"
|
||||||
|
>
|
||||||
|
<t-button
|
||||||
|
class="item"
|
||||||
|
:class="{ quick: item.quick }"
|
||||||
|
variant="text"
|
||||||
|
@click="router.push(item.path)"
|
||||||
|
>
|
||||||
|
<div class="body">
|
||||||
|
<t-icon :name="item.icon" size="1.75rem"/>
|
||||||
|
<h2 v-text="item.title"/>
|
||||||
|
</div>
|
||||||
|
</t-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<div class="help-wrap" v-entrance-transition>
|
||||||
|
<t-button
|
||||||
|
class="help"
|
||||||
|
theme="primary"
|
||||||
|
variant="text"
|
||||||
|
content="使用帮助"
|
||||||
|
@click="router.push('/management/help')"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<t-icon name="help-circle"/>
|
||||||
|
</template>
|
||||||
|
</t-button>
|
||||||
|
<t-button
|
||||||
|
v-if="canUseAi"
|
||||||
|
class="ai"
|
||||||
|
theme="primary"
|
||||||
|
variant="text"
|
||||||
|
content="AI 小糕"
|
||||||
|
@click="openAiChat"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<t-icon name="robot-2" />
|
||||||
|
</template>
|
||||||
|
</t-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useUserStore } from "timi-web-api";
|
||||||
|
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: "CustomerEntryPanel"
|
||||||
|
});
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const userStore = useUserStore();
|
||||||
|
|
||||||
|
interface HomeEntry {
|
||||||
|
path: string;
|
||||||
|
permission: string;
|
||||||
|
icon: string;
|
||||||
|
title: string;
|
||||||
|
/** 高频入口:沿用实心主色卡片 */
|
||||||
|
quick?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface HomeEntryGroup {
|
||||||
|
title: string;
|
||||||
|
layout?: "customer";
|
||||||
|
entryList: HomeEntry[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const entryGroupList: HomeEntryGroup[] = [
|
||||||
|
{
|
||||||
|
title: "客户管理",
|
||||||
|
layout: "customer",
|
||||||
|
entryList: [
|
||||||
|
{
|
||||||
|
path: "/management/customers/create?redirect=/customers",
|
||||||
|
permission: permissionCodes.customer.create,
|
||||||
|
icon: "user-add",
|
||||||
|
title: "录入"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/customer/registration",
|
||||||
|
permission: permissionCodes.eventRecord.create,
|
||||||
|
icon: "task-checked",
|
||||||
|
title: "登记"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/customer/quick-sign-in",
|
||||||
|
permission: permissionCodes.eventRecord.create,
|
||||||
|
icon: "scan",
|
||||||
|
title: "快速扫码登记",
|
||||||
|
quick: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "订单管理",
|
||||||
|
entryList: [
|
||||||
|
{
|
||||||
|
path: "/management/sales-orders/create",
|
||||||
|
permission: permissionCodes.salesOrder.create,
|
||||||
|
icon: "task-add",
|
||||||
|
title: "创建产品订单"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/management/customer-packages/create",
|
||||||
|
permission: permissionCodes.customerPackage.create,
|
||||||
|
icon: "layers",
|
||||||
|
title: "创建套餐订单"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/management/order-fulfillments/quick",
|
||||||
|
permission: permissionCodes.orderFulfillment.create,
|
||||||
|
icon: "undertake-delivery",
|
||||||
|
title: "快速履约",
|
||||||
|
quick: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/management/sales-orders",
|
||||||
|
permission: permissionCodes.salesOrder.read,
|
||||||
|
icon: "task",
|
||||||
|
title: "销售订单"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/management/points/redemptions",
|
||||||
|
permission: permissionCodes.pointRedemption.create,
|
||||||
|
icon: "gift",
|
||||||
|
title: "积分兑换"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const visibleEntryGroupList = computed(() => entryGroupList
|
||||||
|
.map(group => ({
|
||||||
|
...group,
|
||||||
|
entryList: group.entryList.filter(item => userStore.hasPermissions(item.permission))
|
||||||
|
}))
|
||||||
|
.filter(group => group.entryList.length));
|
||||||
|
const canUseAi = computed(() => userStore.hasRoles(gaoRoleCodes.storeManager));
|
||||||
|
|
||||||
|
async function openAiChat(): Promise<void> {
|
||||||
|
await router.push("/ai/chat");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
.entry-panel {
|
||||||
|
|
||||||
|
.entry-group {
|
||||||
|
margin: 0 1rem;
|
||||||
|
|
||||||
|
& + & {
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
> h2 {
|
||||||
|
color: #52607a;
|
||||||
|
margin: 0 0 .75rem 0;
|
||||||
|
font-size: .875rem;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.items {
|
||||||
|
--td-button-border-radius: 1.75rem;
|
||||||
|
|
||||||
|
// 按最小宽度铺排:手机刚好吃下 3 列,平板自动加列而不是把卡片放大
|
||||||
|
gap: .875rem;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
|
||||||
|
|
||||||
|
.item {
|
||||||
|
--entry-color: #0f766e;
|
||||||
|
--entry-color-active: #0a5d56;
|
||||||
|
--entry-background: rgba(255, 255, 255, .92);
|
||||||
|
|
||||||
|
color: var(--entry-color);
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
margin: 0;
|
||||||
|
padding: 1rem;
|
||||||
|
display: flex;
|
||||||
|
position: relative;
|
||||||
|
text-align: center;
|
||||||
|
background: var(--entry-background);
|
||||||
|
box-shadow: 0 .75rem 2rem rgba(15, 23, 42, .08);
|
||||||
|
align-items: center;
|
||||||
|
aspect-ratio: 1;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
&.quick {
|
||||||
|
--td-button-default-text-active-bg-color: var(--entry-color-active);
|
||||||
|
|
||||||
|
color: var(--entry-background);
|
||||||
|
background: var(--entry-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.body {
|
||||||
|
inset: 1rem;
|
||||||
|
display: flex;
|
||||||
|
gap: .5rem;
|
||||||
|
position: absolute;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: .75rem;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-wrap {
|
||||||
|
--td-button-border-radius: 1rem;
|
||||||
|
|
||||||
|
gap: 1rem;
|
||||||
|
width: fit-content;
|
||||||
|
margin: 1rem auto 0 auto;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.help,
|
||||||
|
.ai {
|
||||||
|
width: 8rem;
|
||||||
|
background: white;
|
||||||
|
box-shadow: var(--td-shadow-3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// :global 必须包住整条选择器,只包第一个 compound 时后代选择器会被编译器丢掉
|
||||||
|
:global(html.theme-dark .entry-panel .entry-group > h2) {
|
||||||
|
color: #94a3b8;
|
||||||
|
}
|
||||||
|
:global(html.theme-dark .entry-panel .entry-group .item) {
|
||||||
|
--entry-background: rgba(15, 23, 42, .88);
|
||||||
|
box-shadow: 0 .75rem 2rem rgba(2, 6, 23, .32);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<template>
|
||||||
|
<t-badge
|
||||||
|
v-if="canRead"
|
||||||
|
class="notify-button"
|
||||||
|
:count="unreadCount"
|
||||||
|
:offset="[-6, 6]"
|
||||||
|
:max-count="99"
|
||||||
|
:show-zero="false"
|
||||||
|
>
|
||||||
|
<t-button
|
||||||
|
aria-label="通知"
|
||||||
|
@click="router.push('/notify')"
|
||||||
|
theme="default"
|
||||||
|
shape="square"
|
||||||
|
variant="text"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<t-icon name="notification" size="1.25rem" />
|
||||||
|
</t-button>
|
||||||
|
</t-badge>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { NotifyAPI, useUserStore } from "timi-web-api";
|
||||||
|
import { corePermissionCodes } from "@/utils/permission";
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: "NavbarNotifyButton"
|
||||||
|
});
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const unreadCount = ref(0);
|
||||||
|
|
||||||
|
const canRead = computed(() => userStore.hasPermissions(corePermissionCodes.notify.read));
|
||||||
|
|
||||||
|
async function loadUnreadCount(): Promise<void> {
|
||||||
|
try {
|
||||||
|
unreadCount.value = Math.max(0, await NotifyAPI.countUnreadInternal());
|
||||||
|
} catch (error) {
|
||||||
|
unreadCount.value = 0;
|
||||||
|
console.warn("未读通知数量加载失败", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
if (canRead.value) {
|
||||||
|
await loadUnreadCount();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
.notify-button {
|
||||||
|
:deep(.t-badge__content) {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,206 @@
|
|||||||
|
<template>
|
||||||
|
<t-cell-group
|
||||||
|
v-if="canViewStore || canManageStore"
|
||||||
|
class="store-card"
|
||||||
|
theme="card"
|
||||||
|
v-entrance-transition
|
||||||
|
>
|
||||||
|
<t-cell
|
||||||
|
v-if="canViewStore"
|
||||||
|
class="info"
|
||||||
|
:title="currentStoreStore.currentStoreName"
|
||||||
|
:description="currentStore?.address"
|
||||||
|
/>
|
||||||
|
<t-cell
|
||||||
|
v-if="canSelectStore"
|
||||||
|
class="action"
|
||||||
|
title="切换门店"
|
||||||
|
note="选择使用门店"
|
||||||
|
arrow
|
||||||
|
hover
|
||||||
|
@click="openStorePicker"
|
||||||
|
>
|
||||||
|
<template #leftIcon>
|
||||||
|
<t-icon name="swap" />
|
||||||
|
</template>
|
||||||
|
</t-cell>
|
||||||
|
<t-cell
|
||||||
|
v-if="canManageStore"
|
||||||
|
class="action"
|
||||||
|
title="门店管理"
|
||||||
|
note="管理门店资料和营业日"
|
||||||
|
arrow
|
||||||
|
hover
|
||||||
|
@click="goStoreManagement"
|
||||||
|
>
|
||||||
|
<template #leftIcon>
|
||||||
|
<t-icon name="shop-3" />
|
||||||
|
</template>
|
||||||
|
</t-cell>
|
||||||
|
<t-cell
|
||||||
|
v-if="canManageStoreDiary"
|
||||||
|
class="action"
|
||||||
|
title="门店日记"
|
||||||
|
note="记录门店经营日常"
|
||||||
|
arrow
|
||||||
|
hover
|
||||||
|
@click="goStoreDiaryManagement"
|
||||||
|
>
|
||||||
|
<template #leftIcon>
|
||||||
|
<t-icon name="file" />
|
||||||
|
</template>
|
||||||
|
</t-cell>
|
||||||
|
</t-cell-group>
|
||||||
|
<store-data-charts
|
||||||
|
:key="`${currentStoreStore.currentStoreId}-${chartRefreshKey}`"
|
||||||
|
:compact="compact"
|
||||||
|
/>
|
||||||
|
<t-popup v-model="storePickerVisible" placement="bottom">
|
||||||
|
<t-picker
|
||||||
|
v-model="storePickerDraft"
|
||||||
|
:columns="storePickerColumns"
|
||||||
|
title="切换门店"
|
||||||
|
@cancel="storePickerVisible = false"
|
||||||
|
@confirm="confirmStorePicker"
|
||||||
|
/>
|
||||||
|
</t-popup>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { Message } from "@/utils/message";
|
||||||
|
import { useUserStore } from "timi-web-api";
|
||||||
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
|
import { clearStoreChartCache } from "@/utils/storeChartCache";
|
||||||
|
import { gaoRoleCodes, gaoStoreScopePermissionCodes, permissionCodes } from "@/utils/permission";
|
||||||
|
|
||||||
|
type PickerValue = string | number;
|
||||||
|
|
||||||
|
const StoreDataCharts = defineAsyncComponent(() => import("@/pages/store/component/StoreDataCharts.vue"));
|
||||||
|
|
||||||
|
withDefaults(defineProps<{
|
||||||
|
/** 窄栏(平板横屏的左侧分栏)里图表改为单列 */
|
||||||
|
compact?: boolean;
|
||||||
|
}>(), {
|
||||||
|
compact: false
|
||||||
|
});
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: "StoreOverview"
|
||||||
|
});
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
|
const chartRefreshKey = ref(0);
|
||||||
|
|
||||||
|
const currentStore = computed(() => currentStoreStore.currentStore);
|
||||||
|
const canSelectStore = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||||
|
const canLoadLoginStore = computed(() => userStore.hasPermissions(gaoStoreScopePermissionCodes, "or"));
|
||||||
|
const canViewStore = computed(() => canSelectStore.value || canLoadLoginStore.value);
|
||||||
|
const canManageStore = computed(() => userStore.hasRoles([
|
||||||
|
gaoRoleCodes.globalManager,
|
||||||
|
gaoRoleCodes.storeManager
|
||||||
|
], "or") && userStore.hasPermissions(permissionCodes.store.read));
|
||||||
|
const canManageStoreDiary = computed(() => userStore.hasRoles(gaoRoleCodes.storeManager)
|
||||||
|
&& userStore.hasPermissions(permissionCodes.storeDiary.create));
|
||||||
|
|
||||||
|
// ---------- 门店切换 ----------
|
||||||
|
|
||||||
|
const storePickerVisible = ref(false);
|
||||||
|
const storePickerDraft = ref<PickerValue[]>([]);
|
||||||
|
const storePickerColumns = computed(() => [
|
||||||
|
currentStoreStore.storeList.map(item => ({
|
||||||
|
label: item.name || item.code || "未命名门店",
|
||||||
|
value: item.id || ""
|
||||||
|
})).filter(item => item.value)
|
||||||
|
]);
|
||||||
|
|
||||||
|
function openStorePicker(): void {
|
||||||
|
if (!canSelectStore.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!currentStoreStore.storeList.length) {
|
||||||
|
Message.warning("暂无可选门店");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
storePickerDraft.value = [currentStoreStore.currentStoreId];
|
||||||
|
storePickerVisible.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirmStorePicker(): void {
|
||||||
|
const storeId = String(storePickerDraft.value[0] || "");
|
||||||
|
if (!storeId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentStoreStore.selectStore(storeId);
|
||||||
|
storePickerVisible.value = false;
|
||||||
|
Message.success("当前门店已切换");
|
||||||
|
}
|
||||||
|
|
||||||
|
function refresh(): void {
|
||||||
|
clearStoreChartCache();
|
||||||
|
chartRefreshKey.value++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- 门店管理 ----------
|
||||||
|
|
||||||
|
async function goStoreManagement(): Promise<void> {
|
||||||
|
if (canSelectStore.value) {
|
||||||
|
await router.push("/management/stores");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const store = await currentStoreStore.loadLoginStore();
|
||||||
|
if (!store?.id) {
|
||||||
|
Message.warning("未绑定所属门店");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await router.push(`/management/stores/${store.id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function goStoreDiaryManagement(): Promise<void> {
|
||||||
|
if (!canManageStoreDiary.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const store = await currentStoreStore.loadLoginStore();
|
||||||
|
if (!store?.id) {
|
||||||
|
Message.warning("未绑定所属门店");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await router.push({ name: "StoreDiaryList" });
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
if (canSelectStore.value) {
|
||||||
|
await currentStoreStore.loadStoreList();
|
||||||
|
} else if (canLoadLoginStore.value) {
|
||||||
|
await currentStoreStore.loadLoginStore();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
refresh
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
.store-card {
|
||||||
|
|
||||||
|
// 门店资料卡只有几行,平板上限宽居中,避免拉成整屏宽的空卡片
|
||||||
|
@media (min-width: 48rem) {
|
||||||
|
max-width: 40rem;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// :global 必须包住整条选择器,只包第一个 compound 时后代选择器会被编译器丢掉
|
||||||
|
:global(html.theme-dark .store-card .info .t-cell__description) {
|
||||||
|
color: #94a3b8;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user