259 lines
5.4 KiB
Vue
259 lines
5.4 KiB
Vue
<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: 1rem;
|
|
|
|
> 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(min(6.5rem, calc(33.3333% - .5834rem)), 1fr));
|
|
|
|
.item-wrap {
|
|
min-width: 0;
|
|
}
|
|
|
|
.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: .5rem;
|
|
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>
|