修复:修复无店铺后台登录引导
This commit is contained in:
@@ -14,6 +14,15 @@
|
||||
layout="vertical"
|
||||
@finish="handleLogin"
|
||||
>
|
||||
<a-alert
|
||||
v-if="!shopLoading && !hasAvailableShops"
|
||||
type="warning"
|
||||
show-icon
|
||||
message="当前暂无可选店铺"
|
||||
description="如果你使用的是平台管理员账号,可以直接登录后台先创建第一家店铺;其他后台账号仍需先绑定店铺。"
|
||||
style="margin-bottom: 16px"
|
||||
/>
|
||||
|
||||
<a-form-item label="用户名" name="account">
|
||||
<a-input
|
||||
v-model:value="formState.account"
|
||||
@@ -37,10 +46,10 @@
|
||||
<a-select
|
||||
v-model:value="formState.shopId"
|
||||
size="large"
|
||||
placeholder="请选择登录店铺"
|
||||
:placeholder="hasAvailableShops ? '请选择登录店铺' : '当前暂无可选店铺'"
|
||||
:loading="shopLoading"
|
||||
:options="shopOptions"
|
||||
:disabled="shopLoading || shopOptions.length === 0"
|
||||
:disabled="shopLoading || !hasAvailableShops"
|
||||
show-search
|
||||
:filter-option="filterShopOption"
|
||||
/>
|
||||
@@ -96,6 +105,7 @@ const shopOptions = computed(() =>
|
||||
value: shop.id
|
||||
}))
|
||||
)
|
||||
const hasAvailableShops = computed(() => shopOptions.value.length > 0)
|
||||
|
||||
const formRules = {
|
||||
account: [
|
||||
@@ -103,7 +113,15 @@ const formRules = {
|
||||
{ pattern: /^[a-zA-Z0-9_\-@.]+$/, message: '账号只能包含数字、字母、下划线、连字符、@和点号', trigger: 'blur' }
|
||||
],
|
||||
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
|
||||
shopId: [{ required: true, message: '请选择登录店铺', trigger: 'change' }]
|
||||
shopId: [{
|
||||
validator: async () => {
|
||||
if (!hasAvailableShops.value || formState.shopId) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
return Promise.reject(new Error('请选择登录店铺'))
|
||||
},
|
||||
trigger: 'change'
|
||||
}]
|
||||
} as any
|
||||
|
||||
const filterShopOption = (input: string, option: { label?: string | number } | undefined) =>
|
||||
@@ -128,6 +146,10 @@ const loadShops = async () => {
|
||||
shopLoading.value = true
|
||||
try {
|
||||
shops.value = await shopApi.getShopsSimple() as unknown as ShopSimpleVO[]
|
||||
if (!shops.value.length) {
|
||||
formState.shopId = undefined
|
||||
return
|
||||
}
|
||||
if (!formState.shopId && shops.value.length === 1) {
|
||||
const [onlyShop] = shops.value
|
||||
if (onlyShop) {
|
||||
@@ -150,7 +172,7 @@ const handleLogin = async () => {
|
||||
const res = await adminAuthApi.login({
|
||||
account: formState.account,
|
||||
password: formState.password,
|
||||
shopId: formState.shopId as number
|
||||
shopId: formState.shopId
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
<template>
|
||||
<div class="home">
|
||||
<a-page-header title="欢迎使用后台管理系统" :sub-title="welcomeMessage" />
|
||||
|
||||
<a-alert
|
||||
v-if="isBootstrapAdmin"
|
||||
class="bootstrap-alert"
|
||||
type="warning"
|
||||
show-icon
|
||||
message="当前处于建店引导态"
|
||||
description="系统里还没有可用店铺。当前账号已允许登录后台先创建第一家店铺,其他后台模块会保持不可用,创建完成后请重新登录并选择店铺。"
|
||||
/>
|
||||
|
||||
<a-card class="time-card">
|
||||
<a-statistic title="当前时间" :value="currentTime" />
|
||||
@@ -90,6 +99,8 @@ const welcomeMessage = computed(() => {
|
||||
}
|
||||
})
|
||||
|
||||
const isBootstrapAdmin = computed(() => userInfo.value?.type === 4 && !userInfo.value?.shopId)
|
||||
|
||||
const groupedPermissions = computed(() => {
|
||||
const groups: Record<string, PermissionVO[]> = {}
|
||||
userPermissions.value.forEach(permission => {
|
||||
@@ -140,13 +151,9 @@ const quickActions = computed(() => {
|
||||
permissionCode: 'permission:view'
|
||||
}
|
||||
]
|
||||
|
||||
// 根据用户类型过滤操作
|
||||
if (userInfo.value?.type === 3) { // 美甲师
|
||||
return actions.filter(item => ['products', 'users'].includes(item.key))
|
||||
}
|
||||
|
||||
return actions
|
||||
|
||||
const grantedPermissions = new Set(userPermissions.value.map(permission => permission.permissionCode))
|
||||
return actions.filter(item => grantedPermissions.has(item.permissionCode))
|
||||
})
|
||||
|
||||
const getUserTypeText = (type: number | undefined) => {
|
||||
@@ -226,6 +233,10 @@ onMounted(() => {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.bootstrap-alert {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.info-card {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
@@ -320,4 +331,4 @@ onMounted(() => {
|
||||
color: #1890ff;
|
||||
background: #f0f2f5;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user