321 lines
6.3 KiB
Vue
321 lines
6.3 KiB
Vue
<template>
|
|
<t-navbar
|
|
fixed
|
|
:z-index="20"
|
|
title="客户"
|
|
>
|
|
<template #right>
|
|
<t-badge
|
|
v-if="canReadNotify"
|
|
class="notification-badge"
|
|
:count="unreadNotifyCount"
|
|
: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>
|
|
</t-navbar>
|
|
<main class="page-content scroll column home-tab">
|
|
<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>
|
|
</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>
|
|
</main>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { NotifyAPI, useUserStore } from "timi-web-api";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
|
|
|
defineOptions({
|
|
name: "HomeTab"
|
|
});
|
|
|
|
const router = useRouter();
|
|
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();
|
|
}
|
|
});
|
|
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
.home-tab {
|
|
gap: 1rem;
|
|
padding-left: 1rem;
|
|
padding-right: 1rem;
|
|
|
|
.entry-group {
|
|
|
|
& + & {
|
|
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;
|
|
|
|
gap: .875rem;
|
|
display: grid;
|
|
grid-template-columns: repeat(3, minmax(0, 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(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>
|