220 lines
5.0 KiB
Vue
220 lines
5.0 KiB
Vue
<template>
|
|
<div class="menus" :class="{ compact }">
|
|
<t-cell-group
|
|
v-for="(group, index) in visibleMenuGroupList"
|
|
:key="index"
|
|
class="menu-group"
|
|
theme="card"
|
|
v-entrance-transition
|
|
>
|
|
<t-cell
|
|
v-for="item in group.items"
|
|
:key="item.path"
|
|
class="menu-item"
|
|
:title="item.title"
|
|
arrow
|
|
hover
|
|
@click="go(item.path)"
|
|
>
|
|
<template #leftIcon>
|
|
<t-icon :name="item.icon" size="1.35rem" />
|
|
</template>
|
|
</t-cell>
|
|
</t-cell-group>
|
|
</div>
|
|
<center-tips v-if="!visibleMenuGroupList.length" :content="'当前账号暂无产品管理权限'" />
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { useUserStore } from "timi-web-api";
|
|
import { permissionCodes } from "@/utils/permission";
|
|
|
|
type MenuItem = {
|
|
icon: string;
|
|
path: string;
|
|
title: string;
|
|
visible: boolean;
|
|
};
|
|
|
|
type MenuGroup = {
|
|
items: MenuItem[];
|
|
/** 分组的稳定标识,用于按场景隐藏整组 */
|
|
key?: "analysis";
|
|
};
|
|
|
|
const props = withDefaults(defineProps<{
|
|
/** 分栏窄栏里固定单列 */
|
|
compact?: boolean;
|
|
/** 横屏分栏左侧已经展示图表,右侧不再重复「经营分析」入口 */
|
|
hideAnalysis?: boolean;
|
|
}>(), {
|
|
compact: false,
|
|
hideAnalysis: false
|
|
});
|
|
|
|
defineOptions({
|
|
name: "ProductEntryPanel"
|
|
});
|
|
|
|
const router = useRouter();
|
|
const userStore = useUserStore();
|
|
|
|
const menuGroupList = computed<MenuGroup[]>(() => [
|
|
{
|
|
items: [
|
|
{
|
|
icon: "catalog",
|
|
path: "/product/product-categories",
|
|
title: "产品分类",
|
|
visible: userStore.hasPermissions(permissionCodes.productCategory.read)
|
|
},
|
|
{
|
|
icon: "control-platform",
|
|
path: "/product/products",
|
|
title: "产品库",
|
|
visible: userStore.hasPermissions(permissionCodes.product.read)
|
|
},
|
|
{
|
|
icon: "wallet",
|
|
path: "/product/product-stocks",
|
|
title: "库存",
|
|
visible: userStore.hasPermissions(permissionCodes.productStock.read)
|
|
},
|
|
{
|
|
icon: "history",
|
|
path: "/product/product-stock-records",
|
|
title: "库存流水",
|
|
visible: userStore.hasPermissions(permissionCodes.productStock.read)
|
|
}
|
|
]
|
|
},
|
|
{
|
|
items: [
|
|
{
|
|
icon: "task",
|
|
path: "/product/sales-orders",
|
|
title: "交易订单",
|
|
visible: userStore.hasPermissions(permissionCodes.salesOrder.read)
|
|
},
|
|
{
|
|
icon: "wallet",
|
|
path: "/product/fund-records",
|
|
title: "资金流水",
|
|
visible: userStore.hasPermissions(permissionCodes.fundRecord.read)
|
|
},
|
|
{
|
|
icon: "undertake-delivery",
|
|
path: "/product/order-fulfillments",
|
|
title: "履约记录",
|
|
visible: userStore.hasPermissions(permissionCodes.orderFulfillment.read)
|
|
},
|
|
{
|
|
icon: "money",
|
|
path: "/product/consumption-records",
|
|
title: "消费记录",
|
|
visible: userStore.hasPermissions(permissionCodes.salesOrder.read)
|
|
}
|
|
]
|
|
},
|
|
{
|
|
items: [
|
|
{
|
|
icon: "layers",
|
|
path: "/product/package-configs",
|
|
title: "套餐配置",
|
|
visible: userStore.hasPermissions(permissionCodes.packageConfig.read)
|
|
},
|
|
{
|
|
icon: "task",
|
|
path: "/product/package-orders",
|
|
title: "套餐订单",
|
|
visible: userStore.hasPermissions(permissionCodes.packageConfig.read)
|
|
&& userStore.hasPermissions(permissionCodes.salesOrder.read)
|
|
}
|
|
]
|
|
},
|
|
{
|
|
items: [
|
|
{
|
|
icon: "cart",
|
|
path: "/product/points/redeem-skus",
|
|
title: "兑换商品",
|
|
visible: userStore.hasPermissions(permissionCodes.pointRedeemSku.manage)
|
|
},
|
|
{
|
|
icon: "gift",
|
|
path: "/product/points/redemptions",
|
|
title: "积分兑换",
|
|
visible: userStore.hasPermissions(permissionCodes.pointRedemption.create)
|
|
}
|
|
]
|
|
},
|
|
{
|
|
items: [
|
|
{
|
|
icon: "layers",
|
|
path: "/product/recycle-items",
|
|
title: "回收物",
|
|
visible: userStore.hasPermissions(permissionCodes.recycleExchange.configManage)
|
|
},
|
|
{
|
|
icon: "history",
|
|
path: "/product/recycle-payments",
|
|
title: "回收流水",
|
|
visible: userStore.hasPermissions(permissionCodes.fundRecord.read)
|
|
},
|
|
{
|
|
icon: "setting",
|
|
path: "/product/recycle-rules",
|
|
title: "兑换模板",
|
|
visible: userStore.hasPermissions(permissionCodes.recycleExchange.configManage)
|
|
},
|
|
{
|
|
icon: "chart-combo",
|
|
path: "/product/recycle-stats",
|
|
title: "回收统计",
|
|
visible: userStore.hasPermissions(permissionCodes.salesOrder.read)
|
|
}
|
|
]
|
|
},
|
|
{
|
|
key: "analysis",
|
|
items: [
|
|
{
|
|
icon: "chart-analytics",
|
|
path: "/product/product-data-charts",
|
|
title: "产品经营图表",
|
|
visible: userStore.hasPermissions(permissionCodes.stat.read)
|
|
},
|
|
{
|
|
icon: "chart-combo",
|
|
path: "/product/order-data-charts",
|
|
title: "客户经营图表",
|
|
visible: userStore.hasPermissions(permissionCodes.stat.read)
|
|
}
|
|
]
|
|
}
|
|
]);
|
|
|
|
const visibleMenuGroupList = computed<MenuGroup[]>(() => menuGroupList.value
|
|
.filter(group => !props.hideAnalysis || group.key !== "analysis")
|
|
.map(group => ({
|
|
...group,
|
|
items: group.items.filter(item => item.visible)
|
|
}))
|
|
.filter(group => group.items.length));
|
|
|
|
async function go(path: string): Promise<void> {
|
|
await router.push(path);
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
.menus {
|
|
gap: 2rem;
|
|
display: flex;
|
|
margin-top: 1rem;
|
|
flex-direction: column;
|
|
}
|
|
</style>
|