mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 06:29:20 +08:00
fix(ecom-dmb): 登录验证公司成员状态;公司概览三组件合并为ComparisonSwitcher
This commit is contained in:
+11
-2
@@ -526,6 +526,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
||||
// 如果 lastCompanyId 无效,从已按加入时间排序的成员列表中找第一个可用公司
|
||||
if (companyIdForToken == null) {
|
||||
for (var member : memberships) {
|
||||
if (member.getStatus() == null || member.getStatus() != 1) {
|
||||
continue; // 跳过禁用状态的成员
|
||||
}
|
||||
var company = companyService.getById(member.getCompanyId());
|
||||
if (isCompanyAvailable(company)) {
|
||||
companyIdForToken = member.getCompanyId();
|
||||
@@ -537,9 +540,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// lastCompanyId 有效,直接从成员列表找对应的 positionId 和 companyRole
|
||||
// lastCompanyId 有效,从成员列表验证状态并获取 positionId
|
||||
for (var member : memberships) {
|
||||
if (member.getCompanyId().equals(companyIdForToken)) {
|
||||
if (member.getStatus() == null || member.getStatus() != 1) {
|
||||
throw new BusinessException("当前公司成员状态异常,请重新登录");
|
||||
}
|
||||
positionIdForToken = member.getPositionId();
|
||||
break;
|
||||
}
|
||||
@@ -550,10 +556,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
||||
throw new BusinessException("无可用公司,无法登录");
|
||||
}
|
||||
|
||||
// 从成员列表获取公司成员角色
|
||||
// 从成员列表获取公司成员角色(同时验证状态)
|
||||
String companyRoleForToken = null;
|
||||
for (var member : memberships) {
|
||||
if (member.getCompanyId().equals(companyIdForToken)) {
|
||||
if (member.getStatus() == null || member.getStatus() != 1) {
|
||||
throw new BusinessException("当前公司成员状态异常,请重新登录");
|
||||
}
|
||||
// MyBatis 可能将 ENUM 映射为 String,统一转 String 处理
|
||||
Object roleObj = member.getRole();
|
||||
if (roleObj instanceof CompanyMemberRole) {
|
||||
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
<script lang="ts" setup>
|
||||
import type { CompanyOverviewVO } from '#/api/ecommerce/company-overview';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { Segmented } from 'ant-design-vue';
|
||||
|
||||
import CategoryComparisonTable from './CategoryComparisonTable.vue';
|
||||
import PlatformSummaryCard from './PlatformSummaryCard.vue';
|
||||
import ShopComparisonTable from './ShopComparisonTable.vue';
|
||||
|
||||
defineOptions({ name: 'ComparisonSwitcher' });
|
||||
|
||||
interface Props {
|
||||
taxRate: number;
|
||||
platformSummary?: CompanyOverviewVO.PlatformOverview;
|
||||
platformExportMode: boolean;
|
||||
selectedExportPlatformIds: number[];
|
||||
shopComparisons?: CompanyOverviewVO.ShopOverview;
|
||||
shopExportMode: boolean;
|
||||
selectedExportShopIds: number[];
|
||||
categoryComparisons?: CompanyOverviewVO.CategoryOverview;
|
||||
categoryExportMode: boolean;
|
||||
selectedExportCategoryIds: number[];
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:selectedExportPlatformIds', ids: number[]): void;
|
||||
(e: 'togglePlatformExportMode', enabled: boolean): void;
|
||||
(e: 'platformExport'): void;
|
||||
(e: 'update:selectedExportShopIds', ids: number[]): void;
|
||||
(e: 'toggleShopExportMode', enabled: boolean): void;
|
||||
(e: 'shopExport'): void;
|
||||
(e: 'navigate', shopId: number): void;
|
||||
(e: 'update:selectedExportCategoryIds', ids: number[]): void;
|
||||
(e: 'toggleCategoryExportMode', enabled: boolean): void;
|
||||
(e: 'categoryExport'): void;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const activeMode = ref<'platform' | 'shop' | 'category'>('platform');
|
||||
|
||||
const modeOptions = [
|
||||
{ label: '平台汇总', value: 'platform' },
|
||||
{ label: '店铺对比', value: 'shop' },
|
||||
{ label: '品类对比', value: 'category' },
|
||||
] as const;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-4">
|
||||
<div class="flex justify-end">
|
||||
<Segmented
|
||||
v-model:value="activeMode"
|
||||
:options="modeOptions"
|
||||
class="comparison-segmented"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<PlatformSummaryCard
|
||||
v-if="activeMode === 'platform'"
|
||||
:platform-summary="props.platformSummary"
|
||||
:tax-rate="props.taxRate"
|
||||
:platform-export-mode="props.platformExportMode"
|
||||
:selected-export-platform-ids="props.selectedExportPlatformIds"
|
||||
@update:selected-export-platform-ids="
|
||||
(ids) => emit('update:selectedExportPlatformIds', ids)
|
||||
"
|
||||
@toggle-platform-export-mode="
|
||||
(enabled) => emit('togglePlatformExportMode', enabled)
|
||||
"
|
||||
@export="emit('platformExport')"
|
||||
/>
|
||||
|
||||
<ShopComparisonTable
|
||||
v-if="activeMode === 'shop'"
|
||||
:shop-comparisons="props.shopComparisons"
|
||||
:tax-rate="props.taxRate"
|
||||
:shop-export-mode="props.shopExportMode"
|
||||
:selected-export-shop-ids="props.selectedExportShopIds"
|
||||
@update:selected-export-shop-ids="
|
||||
(ids) => emit('update:selectedExportShopIds', ids)
|
||||
"
|
||||
@toggle-shop-export-mode="(enabled) => emit('toggleShopExportMode', enabled)"
|
||||
@export="emit('shopExport')"
|
||||
@navigate="(shopId) => emit('navigate', shopId)"
|
||||
/>
|
||||
|
||||
<CategoryComparisonTable
|
||||
v-if="activeMode === 'category'"
|
||||
:category-comparisons="props.categoryComparisons"
|
||||
:tax-rate="props.taxRate"
|
||||
:category-export-mode="props.categoryExportMode"
|
||||
:selected-export-category-ids="props.selectedExportCategoryIds"
|
||||
@toggle-category-export-mode="
|
||||
(enabled) => emit('toggleCategoryExportMode', enabled)
|
||||
"
|
||||
@update:selected-export-category-ids="
|
||||
(ids) => emit('update:selectedExportCategoryIds', ids)
|
||||
"
|
||||
@export="emit('categoryExport')"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
:deep(.comparison-segmented) {
|
||||
background: rgb(148 163 184 / 16%);
|
||||
border-radius: 999px;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
:deep(.comparison-segmented .ant-segmented-item-label) {
|
||||
font-weight: 700;
|
||||
padding: 4px 14px;
|
||||
}
|
||||
|
||||
:deep(.comparison-segmented .ant-segmented-item-selected) {
|
||||
color: #1d4ed8;
|
||||
}
|
||||
|
||||
:global(html.dark) :deep(.comparison-segmented) {
|
||||
background: hsl(240deg 3.7% 22% / 70%);
|
||||
}
|
||||
|
||||
:global(html.dark) :deep(.comparison-segmented .ant-segmented-item) {
|
||||
color: hsl(240deg 5% 64.9%);
|
||||
}
|
||||
|
||||
:global(html.dark) :deep(.comparison-segmented .ant-segmented-item-selected) {
|
||||
color: #60a5fa;
|
||||
}
|
||||
</style>
|
||||
+20
-1
@@ -247,6 +247,25 @@ const sortIcon = (field: string) => {
|
||||
:key="p.platformId"
|
||||
class="transition-colors hover:bg-blue-50/50 dark:hover:bg-[hsl(217.2deg_32.6%_17.5%/30%)] dark:bg-[hsl(217.2deg_32.6%_17.5%/50%)]"
|
||||
>
|
||||
<td
|
||||
v-if="platformExportMode"
|
||||
class="border-r border-slate-100 dark:border-r-[hsl(240deg_3.7%_22%)] bg-slate-50/50 dark:bg-[hsl(240deg_3.7%_22%/50%)] p-3 text-center"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="h-4 w-4 cursor-pointer accent-blue-600"
|
||||
:checked="selectedExportPlatformIds.includes(p.platformId)"
|
||||
@change="
|
||||
(e) => {
|
||||
const checked = (e.target as HTMLInputElement).checked;
|
||||
const newIds = checked
|
||||
? [...selectedExportPlatformIds, p.platformId]
|
||||
: selectedExportPlatformIds.filter((id) => id !== p.platformId);
|
||||
emit('update:selectedExportPlatformIds', newIds);
|
||||
}
|
||||
"
|
||||
/>
|
||||
</td>
|
||||
<!-- 平台名 -->
|
||||
<td
|
||||
class="sticky-col border-r-2 border-slate-100 bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-6 font-bold shadow-sm dark:shadow-none"
|
||||
@@ -328,7 +347,7 @@ const sortIcon = (field: string) => {
|
||||
</tfoot>
|
||||
<tfoot v-else class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
|
||||
<tr class="text-center text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
<td colspan="19" class="p-6">暂无数据</td>
|
||||
<td :colspan="platformExportMode ? 20 : 19" class="p-6">暂无数据</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
@@ -23,11 +23,9 @@ import { getCompanyOverviewApi } from '#/api/ecommerce/company-overview/apis';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
import { exportByPost } from '#/utils/export';
|
||||
|
||||
import CategoryComparisonTable from './components/CategoryComparisonTable.vue';
|
||||
import ComparisonSwitcher from './components/ComparisonSwitcher.vue';
|
||||
import KpiCards from './components/KpiCards.vue';
|
||||
import ShopCharts from './components/ShopCharts.vue';
|
||||
import PlatformSummaryCard from './components/PlatformSummaryCard.vue';
|
||||
import ShopComparisonTable from './components/ShopComparisonTable.vue';
|
||||
|
||||
defineOptions({ name: 'CompanyOverview' });
|
||||
|
||||
@@ -578,38 +576,28 @@ const navigateToShopOverview = (shopId: number) => {
|
||||
:shop-efficiency-quadrants="overviewData?.shopEfficiencyQuadrants"
|
||||
/>
|
||||
|
||||
<!-- 第三层:平台维度汇总 -->
|
||||
<PlatformSummaryCard
|
||||
:platform-summary="overviewData?.platformSummary"
|
||||
<!-- 第三层:平台/店铺/品类明细切换 -->
|
||||
<ComparisonSwitcher
|
||||
:tax-rate="taxRate"
|
||||
:platform-summary="overviewData?.platformSummary"
|
||||
:platform-export-mode="platformExportMode"
|
||||
:selected-export-platform-ids="selectedExportPlatformIds"
|
||||
@update:selected-export-platform-ids="(ids) => (selectedExportPlatformIds = ids)"
|
||||
@toggle-platform-export-mode="togglePlatformExportMode"
|
||||
@export="handlePlatformExport"
|
||||
/>
|
||||
|
||||
<!-- 第四层:横向对比大表 -->
|
||||
<ShopComparisonTable
|
||||
:shop-comparisons="overviewData?.shopComparisons"
|
||||
:tax-rate="taxRate"
|
||||
:shop-export-mode="shopExportMode"
|
||||
:selected-export-shop-ids="selectedExportShopIds"
|
||||
@update:selected-export-shop-ids="(ids) => (selectedExportShopIds = ids)"
|
||||
@toggle-shop-export-mode="toggleShopExportMode"
|
||||
@export="handleExportCompanyOverview"
|
||||
@navigate="navigateToShopOverview"
|
||||
/>
|
||||
|
||||
<!-- 第五层:品类多维度经营明细对比 -->
|
||||
<CategoryComparisonTable
|
||||
:category-comparisons="overviewData?.categoryComparisons"
|
||||
:tax-rate="taxRate"
|
||||
:category-export-mode="categoryExportMode"
|
||||
:selected-export-category-ids="selectedExportCategoryIds"
|
||||
@update:selected-export-platform-ids="(ids) => (selectedExportPlatformIds = ids)"
|
||||
@toggle-platform-export-mode="togglePlatformExportMode"
|
||||
@platform-export="handlePlatformExport"
|
||||
@update:selected-export-shop-ids="(ids) => (selectedExportShopIds = ids)"
|
||||
@toggle-shop-export-mode="toggleShopExportMode"
|
||||
@shop-export="handleExportCompanyOverview"
|
||||
@navigate="navigateToShopOverview"
|
||||
@toggle-category-export-mode="handleCategoryExportToggle"
|
||||
@update:selected-export-category-ids="selectedExportCategoryIds = $event"
|
||||
@export="handleCategoryExport"
|
||||
@category-export="handleCategoryExport"
|
||||
/>
|
||||
</div>
|
||||
</Spin>
|
||||
|
||||
Reference in New Issue
Block a user