feat(前端): 增加按钮级权限控制

This commit is contained in:
2026-08-27 22:20:02 +08:00
parent b6ed7d166d
commit 65c412d533
29 changed files with 1247 additions and 703 deletions
@@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { MenuVO } from '#/api/sys/menu/types'; import type { MenuVO } from '#/api/sys/menu/types';
import { computed, ref } from 'vue'; import { computed, ref, watch } from 'vue';
import { useVbenDrawer } from '@vben/common-ui'; import { useVbenDrawer } from '@vben/common-ui';
@@ -12,6 +12,8 @@ import {
getCompanyMenuIdsApi, getCompanyMenuIdsApi,
} from '#/api/company/menu'; } from '#/api/company/menu';
import { getAllMenusApi } from '#/api/sys/menu'; import { getAllMenusApi } from '#/api/sys/menu';
import { PermissionGate } from '#/components/permission';
import { usePermission } from '#/composables/use-permission';
interface Props { interface Props {
company?: any; company?: any;
@@ -29,6 +31,9 @@ defineOptions({
defineProps<Props>(); defineProps<Props>();
const emit = defineEmits<Emits>(); const emit = defineEmits<Emits>();
const { hasPermission } = usePermission();
const canAssignMenu = computed(() => hasPermission('org:company:menu:assign'));
// 系统菜单列表数据 // 系统菜单列表数据
const systemMenuList = ref<MenuVO.MenuInfo[]>([]); const systemMenuList = ref<MenuVO.MenuInfo[]>([]);
@@ -78,6 +83,14 @@ const [MainDrawer, mainDrawerApi] = useVbenDrawer({
}, },
}); });
watch(
canAssignMenu,
(allowed: boolean) => {
mainDrawerApi.setState({ showConfirmButton: allowed });
},
{ immediate: true },
);
// 将菜单列表转换为树形结构 // 将菜单列表转换为树形结构
const menuTreeData = computed(() => { const menuTreeData = computed(() => {
const menuMap = new Map<number, any>(); const menuMap = new Map<number, any>();
@@ -408,8 +421,10 @@ defineExpose({
{{ option.label }} {{ option.label }}
</Select.Option> </Select.Option>
</Select> </Select>
<Button type="primary" @click="handleSelectAll"> 一键全选 </Button> <PermissionGate code="org:company:menu:assign">
<Button @click="handleSelectNone"> 取消全选 </Button> <Button type="primary" @click="handleSelectAll"> 一键全选 </Button>
<Button @click="handleSelectNone"> 取消全选 </Button>
</PermissionGate>
</div> </div>
</div> </div>
</div> </div>
@@ -421,7 +436,7 @@ defineExpose({
v-model:checked-keys="checkedKeys" v-model:checked-keys="checkedKeys"
v-model:expanded-keys="expandedKeys" v-model:expanded-keys="expandedKeys"
:tree-data="menuTreeData" :tree-data="menuTreeData"
checkable :checkable="canAssignMenu"
class="menu-tree" class="menu-tree"
@check="handleTreeCheckChange" @check="handleTreeCheckChange"
> >
@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref } from 'vue'; import { computed, ref, watch } from 'vue';
import { useVbenDrawer } from '@vben/common-ui'; import { useVbenDrawer } from '@vben/common-ui';
@@ -16,6 +16,8 @@ import {
getCompanyPermissionIdsApi, getCompanyPermissionIdsApi,
} from '#/api/company/permission/apis'; } from '#/api/company/permission/apis';
import { getAllPermissionsApi } from '#/api/sys/permission'; import { getAllPermissionsApi } from '#/api/sys/permission';
import { PermissionGate } from '#/components/permission';
import { usePermission } from '#/composables/use-permission';
interface Props { interface Props {
company?: any; company?: any;
@@ -33,6 +35,11 @@ defineOptions({
defineProps<Props>(); defineProps<Props>();
const emit = defineEmits<Emits>(); const emit = defineEmits<Emits>();
const { hasPermission } = usePermission();
const canAssignPermission = computed(() =>
hasPermission('org:company:permission:assign'),
);
// 所有权限列表 // 所有权限列表
const allPermissions = ref<any[]>([]); const allPermissions = ref<any[]>([]);
@@ -70,6 +77,14 @@ const [MainDrawer, mainDrawerApi] = useVbenDrawer({
}, },
}); });
watch(
canAssignPermission,
(allowed) => {
mainDrawerApi.setState({ showConfirmButton: allowed });
},
{ immediate: true },
);
// 按类型分组权限 // 按类型分组权限
const groupedPermissions = computed(() => { const groupedPermissions = computed(() => {
const groups: Record<string, any[]> = {}; const groups: Record<string, any[]> = {};
@@ -210,8 +225,10 @@ defineExpose({
</div> </div>
</div> </div>
<div class="stats-right"> <div class="stats-right">
<Button @click="selectNone">取消全选</Button> <PermissionGate code="org:company:permission:assign">
<Button type="primary" @click="selectAll">一键全选</Button> <Button @click="selectNone">取消全选</Button>
<Button type="primary" @click="selectAll">一键全选</Button>
</PermissionGate>
</div> </div>
</div> </div>
</div> </div>
@@ -237,6 +254,7 @@ defineExpose({
> >
<Checkbox <Checkbox
:checked="selectedPermissionIds.includes(perm.id)" :checked="selectedPermissionIds.includes(perm.id)"
:disabled="!canAssignPermission"
@change=" @change="
(e: any) => togglePermission(perm.id, e.target.checked) (e: any) => togglePermission(perm.id, e.target.checked)
" "
@@ -8,6 +8,7 @@ import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells'; import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue'; import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
import { PermissionGate } from '#/components/permission';
import AnimatedMoneyCell from '../../../components/AnimatedMoneyCell.vue'; import AnimatedMoneyCell from '../../../components/AnimatedMoneyCell.vue';
import { import {
@@ -79,37 +80,39 @@ const cellRoi = (v: number | null | undefined) =>
{{ props.headingSubtitle }} {{ props.headingSubtitle }}
</p> </p>
</div> </div>
<div class="flex items-center gap-3"> <PermissionGate code="data:export">
<template v-if="categoryExportMode"> <div class="flex items-center gap-3">
<button <template v-if="categoryExportMode">
class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]" <button
@click="emit('toggleCategoryExportMode', false)" class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
> @click="emit('toggleCategoryExportMode', false)"
取消选择 >
</button> 取消选择
<button </button>
class="rounded-[10px] bg-blue-500 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(59,130,246,0.28)] transition-colors hover:bg-blue-600 disabled:opacity-50 dark:shadow-none" <button
:disabled="selectedExportCategoryIds.length === 0" class="rounded-[10px] bg-blue-500 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(59,130,246,0.28)] transition-colors hover:bg-blue-600 disabled:opacity-50 dark:shadow-none"
@click="emit('export')" :disabled="selectedExportCategoryIds.length === 0"
> @click="emit('export')"
导出已选品类 ({{ selectedExportCategoryIds.length }}) >
</button> 导出已选品类 ({{ selectedExportCategoryIds.length }})
</template> </button>
<template v-else> </template>
<button <template v-else>
class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]" <button
@click="emit('toggleCategoryExportMode', true)" class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
> @click="emit('toggleCategoryExportMode', true)"
指定品类导出 >
</button> 指定品类导出
<button </button>
class="rounded-[10px] bg-slate-800 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(15,23,42,0.18)] transition-colors hover:bg-slate-900 dark:shadow-none" <button
@click="emit('export')" class="rounded-[10px] bg-slate-800 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(15,23,42,0.18)] transition-colors hover:bg-slate-900 dark:shadow-none"
> @click="emit('export')"
导出全部 >
</button> 导出全部
</template> </button>
</div> </template>
</div>
</PermissionGate>
</div> </div>
<div class="table-container"> <div class="table-container">
@@ -6,6 +6,7 @@ import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells'; import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue'; import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
import { PermissionGate } from '#/components/permission';
import AnimatedMoneyCell from '../../../components/AnimatedMoneyCell.vue'; import AnimatedMoneyCell from '../../../components/AnimatedMoneyCell.vue';
import { import {
@@ -123,37 +124,39 @@ const sortedData = computed(() => {
{{ props.headingSubtitle }} {{ props.headingSubtitle }}
</p> </p>
</div> </div>
<div class="flex items-center gap-3"> <PermissionGate code="data:export">
<template v-if="platformExportMode"> <div class="flex items-center gap-3">
<button <template v-if="platformExportMode">
class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]" <button
@click="emit('togglePlatformExportMode', false)" class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
> @click="emit('togglePlatformExportMode', false)"
取消选择 >
</button> 取消选择
<button </button>
class="rounded-[10px] bg-blue-500 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(59,130,246,0.28)] transition-colors hover:bg-blue-600 disabled:opacity-50 dark:shadow-none" <button
:disabled="selectedExportPlatformCodes.length === 0" class="rounded-[10px] bg-blue-500 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(59,130,246,0.28)] transition-colors hover:bg-blue-600 disabled:opacity-50 dark:shadow-none"
@click="emit('export')" :disabled="selectedExportPlatformCodes.length === 0"
> @click="emit('export')"
导出已选平台 ({{ selectedExportPlatformCodes.length }}) >
</button> 导出已选平台 ({{ selectedExportPlatformCodes.length }})
</template> </button>
<template v-else> </template>
<button <template v-else>
class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]" <button
@click="emit('togglePlatformExportMode', true)" class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
> @click="emit('togglePlatformExportMode', true)"
指定平台导出 >
</button> 指定平台导出
<button </button>
class="rounded-[10px] bg-slate-800 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(15,23,42,0.18)] transition-colors hover:bg-slate-900 dark:shadow-none" <button
@click="emit('export')" class="rounded-[10px] bg-slate-800 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(15,23,42,0.18)] transition-colors hover:bg-slate-900 dark:shadow-none"
> @click="emit('export')"
导出全部 >
</button> 导出全部
</template> </button>
</div> </template>
</div>
</PermissionGate>
</div> </div>
<!-- 表格 --> <!-- 表格 -->
@@ -7,6 +7,7 @@ import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells'; import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue'; import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
import { PermissionGate } from '#/components/permission';
import AnimatedMoneyCell from '../../../components/AnimatedMoneyCell.vue'; import AnimatedMoneyCell from '../../../components/AnimatedMoneyCell.vue';
import { import {
@@ -71,37 +72,39 @@ const cellRoi = (v: number | null | undefined) =>
{{ props.headingSubtitle }} {{ props.headingSubtitle }}
</p> </p>
</div> </div>
<div class="flex items-center gap-3"> <PermissionGate code="data:export">
<template v-if="shopExportMode"> <div class="flex items-center gap-3">
<button <template v-if="shopExportMode">
class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]" <button
@click="emit('toggleShopExportMode', false)" class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
> @click="emit('toggleShopExportMode', false)"
取消选择 >
</button> 取消选择
<button </button>
class="rounded-[10px] bg-blue-500 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(59,130,246,0.28)] transition-colors hover:bg-blue-600 disabled:opacity-50 dark:shadow-none" <button
:disabled="selectedExportShopIds.length === 0" class="rounded-[10px] bg-blue-500 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(59,130,246,0.28)] transition-colors hover:bg-blue-600 disabled:opacity-50 dark:shadow-none"
@click="emit('export')" :disabled="selectedExportShopIds.length === 0"
> @click="emit('export')"
导出已选店铺 ({{ selectedExportShopIds.length }}) >
</button> 导出已选店铺 ({{ selectedExportShopIds.length }})
</template> </button>
<template v-else> </template>
<button <template v-else>
class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]" <button
@click="emit('toggleShopExportMode', true)" class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
> @click="emit('toggleShopExportMode', true)"
指定店铺导出 >
</button> 指定店铺导出
<button </button>
class="rounded-[10px] bg-slate-800 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(15,23,42,0.18)] transition-colors hover:bg-slate-900 dark:shadow-none" <button
@click="emit('export')" class="rounded-[10px] bg-slate-800 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(15,23,42,0.18)] transition-colors hover:bg-slate-900 dark:shadow-none"
> @click="emit('export')"
导出全部 >
</button> 导出全部
</template> </button>
</div> </template>
</div>
</PermissionGate>
</div> </div>
<div class="table-container"> <div class="table-container">
@@ -14,6 +14,7 @@ import {
getPddGoodsPageApi, getPddGoodsPageApi,
} from '#/api/channel/pdd/goods'; } from '#/api/channel/pdd/goods';
import { getPddShopPageApi } from '#/api/channel/pdd/shop'; import { getPddShopPageApi } from '#/api/channel/pdd/shop';
import { PermissionGate } from '#/components/permission';
import PddShopColPage from '#/views/channel/pdd/components/PddShopColPage.vue'; import PddShopColPage from '#/views/channel/pdd/components/PddShopColPage.vue';
import PddShopDetailModal from '#/views/channel/pdd/shop/components/PddShopDetailModal.vue'; import PddShopDetailModal from '#/views/channel/pdd/shop/components/PddShopDetailModal.vue';
import ProductDetailDrawer from '#/views/ec/product/list/components/ProductDetailDrawer.vue'; import ProductDetailDrawer from '#/views/ec/product/list/components/ProductDetailDrawer.vue';
@@ -395,12 +396,14 @@ onMounted(async () => {
<Button type="link" size="small" @click="openDetail(row)"> <Button type="link" size="small" @click="openDetail(row)">
详情 详情
</Button> </Button>
<Popconfirm <PermissionGate code="channel:pdd:goods:delete">
title="确定删除该商品及全部 SKU 吗?" <Popconfirm
@confirm="handleDelete(row)" title="确定删除该商品及全部 SKU 吗?"
> @confirm="handleDelete(row)"
<Button type="link" size="small" danger>删除</Button> >
</Popconfirm> <Button type="link" size="small" danger>删除</Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -14,6 +14,7 @@ import {
getPddShopPageApi, getPddShopPageApi,
} from '#/api/channel/pdd/shop'; } from '#/api/channel/pdd/shop';
import { syncPddGoodsByShopApi } from '#/api/channel/pdd/goods'; import { syncPddGoodsByShopApi } from '#/api/channel/pdd/goods';
import { PermissionGate } from '#/components/permission';
import PddShopDetailModal from './components/PddShopDetailModal.vue'; import PddShopDetailModal from './components/PddShopDetailModal.vue';
@@ -308,15 +309,17 @@ async function handleSyncGoods(row: PddShopVO.Info) {
<Button type="link" size="small" @click="openShopDetail(row)"> <Button type="link" size="small" @click="openShopDetail(row)">
详情 详情
</Button> </Button>
<Button <PermissionGate code="channel:pdd:goods:sync">
type="link" <Button
size="small" type="link"
:loading="syncingShopId === row.id" size="small"
:disabled="syncingShopId != null && syncingShopId !== row.id" :loading="syncingShopId === row.id"
@click="handleSyncGoods(row)" :disabled="syncingShopId != null && syncingShopId !== row.id"
> @click="handleSyncGoods(row)"
同步商品 >
</Button> 同步商品
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -19,12 +19,17 @@ import {
getCompanyMenusApi, getCompanyMenusApi,
getCompanyMenuIdsApi, getCompanyMenuIdsApi,
} from '#/api/company/menu/apis'; } from '#/api/company/menu/apis';
import { PermissionGate } from '#/components/permission';
import { usePermission } from '#/composables/use-permission';
import CompanyColPage from '#/views/company/components/CompanyColPage.vue'; import CompanyColPage from '#/views/company/components/CompanyColPage.vue';
defineOptions({ defineOptions({
name: 'CompanyMenuManagePage', name: 'CompanyMenuManagePage',
}); });
const { hasPermission } = usePermission();
const canAssignMenu = computed(() => hasPermission('org:company:menu:assign'));
const selectedCompanyId = ref<number | undefined>(undefined); const selectedCompanyId = ref<number | undefined>(undefined);
const currentCompany = ref<CompanyVO.CompanyInfoVO | null>(null); const currentCompany = ref<CompanyVO.CompanyInfoVO | null>(null);
@@ -196,17 +201,19 @@ async function handleSave() {
<span v-if="stats.changed" class="text-orange-500">(未保存)</span> <span v-if="stats.changed" class="text-orange-500">(未保存)</span>
</span> </span>
</template> </template>
<Button :disabled="!currentCompany" @click="selectNone">取消全选</Button> <PermissionGate code="org:company:menu:assign">
<Button type="primary" :disabled="!currentCompany" @click="selectAll"> <Button :disabled="!currentCompany" @click="selectNone">取消全选</Button>
一键全选 <Button type="primary" :disabled="!currentCompany" @click="selectAll">
</Button> 一键全选
<Button </Button>
type="primary" <Button
:disabled="!currentCompany || !stats.changed" type="primary"
@click="handleSave" :disabled="!currentCompany || !stats.changed"
> @click="handleSave"
保存配置 >
</Button> 保存配置
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -223,7 +230,7 @@ async function handleSave() {
v-model:checked-keys="selectedMenuIds" v-model:checked-keys="selectedMenuIds"
v-model:expanded-keys="menuExpandedKeys" v-model:expanded-keys="menuExpandedKeys"
:tree-data="menuTreeData" :tree-data="menuTreeData"
checkable :checkable="canAssignMenu"
block-node block-node
:selectable="false" :selectable="false"
@check="handleTreeCheckChange" @check="handleTreeCheckChange"
@@ -20,10 +20,17 @@ import {
getCompanyPermissionIdsApi, getCompanyPermissionIdsApi,
} from '#/api/company/permission/apis'; } from '#/api/company/permission/apis';
import { getPermissionTreeApi } from '#/api/sys/permission'; import { getPermissionTreeApi } from '#/api/sys/permission';
import { PermissionGate } from '#/components/permission';
import { usePermission } from '#/composables/use-permission';
import CompanyColPage from '#/views/company/components/CompanyColPage.vue'; import CompanyColPage from '#/views/company/components/CompanyColPage.vue';
defineOptions({ name: 'CompanyPermissionManagePage' }); defineOptions({ name: 'CompanyPermissionManagePage' });
const { hasPermission } = usePermission();
const canAssignPermission = computed(() =>
hasPermission('org:company:permission:assign'),
);
type PermissionTreeNode = { type PermissionTreeNode = {
key: number; key: number;
title: string; title: string;
@@ -215,17 +222,19 @@ onMounted(() => {
<span v-if="stats.changed" class="text-orange-500">(未保存)</span> <span v-if="stats.changed" class="text-orange-500">(未保存)</span>
</span> </span>
</template> </template>
<Button :disabled="!currentCompany" @click="selectNone">取消全选</Button> <PermissionGate code="org:company:permission:assign">
<Button type="primary" :disabled="!currentCompany" @click="selectAll"> <Button :disabled="!currentCompany" @click="selectNone">取消全选</Button>
一键全选 <Button type="primary" :disabled="!currentCompany" @click="selectAll">
</Button> 一键全选
<Button </Button>
type="primary" <Button
:disabled="!currentCompany || !stats.changed" type="primary"
@click="handleSave" :disabled="!currentCompany || !stats.changed"
> @click="handleSave"
保存配置 >
</Button> 保存配置
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -243,7 +252,7 @@ onMounted(() => {
v-model:checked-keys="selectedPermissionIds" v-model:checked-keys="selectedPermissionIds"
v-model:expanded-keys="expandedKeys" v-model:expanded-keys="expandedKeys"
:tree-data="permissionTreeData" :tree-data="permissionTreeData"
checkable :checkable="canAssignPermission"
block-node block-node
:selectable="false" :selectable="false"
@check="handleTreeCheckChange" @check="handleTreeCheckChange"
@@ -2,7 +2,7 @@
import type { VxeGridProps } from '#/adapter/vxe-table'; import type { VxeGridProps } from '#/adapter/vxe-table';
import type { ImportMappingVO } from '#/api/ec/import/mapping'; import type { ImportMappingVO } from '#/api/ec/import/mapping';
import { ref } from 'vue'; import { computed, ref } from 'vue';
import { Page } from '@vben/common-ui'; import { Page } from '@vben/common-ui';
import { createIconifyIcon } from '@vben/icons'; import { createIconifyIcon } from '@vben/icons';
@@ -14,6 +14,11 @@ import {
deleteImportMappingApi, deleteImportMappingApi,
getImportMappingPageApi, getImportMappingPageApi,
} from '#/api/ec/import/mapping'; } from '#/api/ec/import/mapping';
import { PermissionGate } from '#/components/permission';
import {
syncVxeGridColumns,
useActionColumnVisible,
} from '#/composables/use-vxe-action-column';
import { ImportMappingType } from '#/api/ec/import/mapping/types/types.enum'; import { ImportMappingType } from '#/api/ec/import/mapping/types/types.enum';
import ImportMappingFormModal from '../import-mapping/components/ImportMappingFormModal.vue'; import ImportMappingFormModal from '../import-mapping/components/ImportMappingFormModal.vue';
@@ -25,8 +30,14 @@ const PlusIcon = createIconifyIcon('lucide:plus');
const loading = ref(false); const loading = ref(false);
const formModalRef = ref(); const formModalRef = ref();
const gridOptions: VxeGridProps<any> = { const mappingActionCodes = [
columns: [ 'data:import-mapping:create',
'data:import-mapping:update',
'data:import-mapping:delete',
];
const showActionColumn = useActionColumnVisible(mappingActionCodes);
const mappingTableBaseColumns: VxeGridProps<any>['columns'] = [
{ type: 'seq', width: 80, title: '序号' }, { type: 'seq', width: 80, title: '序号' },
{ {
field: 'name', field: 'name',
@@ -42,8 +53,23 @@ const gridOptions: VxeGridProps<any> = {
}, },
{ field: 'createTime', title: '创建时间', width: 180 }, { field: 'createTime', title: '创建时间', width: 180 },
{ field: 'updateTime', title: '更新时间', width: 180 }, { field: 'updateTime', title: '更新时间', width: 180 },
{ title: '操作', width: 160, fixed: 'right', slots: { default: 'action' } }, ];
],
const mappingActionColumn: NonNullable<VxeGridProps<any>['columns']>[number] = {
title: '操作',
width: 160,
fixed: 'right',
slots: { default: 'action' },
};
const mappingTableColumns = computed(() =>
showActionColumn.value
? [...(mappingTableBaseColumns ?? []), mappingActionColumn]
: (mappingTableBaseColumns ?? []),
);
const gridOptions: VxeGridProps<any> = {
columns: mappingTableColumns.value,
height: 'auto', height: 'auto',
border: true, border: true,
stripe: true, stripe: true,
@@ -84,6 +110,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
showSearchForm: false, showSearchForm: false,
tableTitle: '字段映射模板', tableTitle: '字段映射模板',
}); });
syncVxeGridColumns(gridApi, mappingTableColumns);
function refresh() { function refresh() {
gridApi?.reload(); gridApi?.reload();
@@ -137,10 +164,12 @@ function getTypeName(type: ImportMappingType): string {
<Grid :loading="loading"> <Grid :loading="loading">
<template #toolbar-tools> <template #toolbar-tools>
<Space> <Space>
<Button type="primary" @click="handleAdd"> <PermissionGate code="data:import-mapping:create">
<PlusIcon /> <Button type="primary" @click="handleAdd">
新建模板 <PlusIcon />
</Button> 新建模板
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -154,12 +183,16 @@ function getTypeName(type: ImportMappingType): string {
<Tag color="green">{{ getMappingCount(row.mapping) }} 个字段</Tag> <Tag color="green">{{ getMappingCount(row.mapping) }} 个字段</Tag>
</template> </template>
<template #action="{ row }: { row: ImportMappingVO.ImportMappingInfoVO }"> <template v-if="showActionColumn" #action="{ row }: { row: ImportMappingVO.ImportMappingInfoVO }">
<Space> <Space>
<Button size="small" @click="handleEdit(row)">编辑</Button> <PermissionGate code="data:import-mapping:update">
<Popconfirm title="确定删除该模板?" @confirm="handleDelete(row)"> <Button size="small" @click="handleEdit(row)">编辑</Button>
<Button size="small" danger>删除</Button> </PermissionGate>
</Popconfirm> <PermissionGate code="data:import-mapping:delete">
<Popconfirm title="确定删除该模板?" @confirm="handleDelete(row)">
<Button size="small" danger>删除</Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -2,7 +2,7 @@
import type { VxeGridProps } from '#/adapter/vxe-table'; import type { VxeGridProps } from '#/adapter/vxe-table';
import type { ImportMappingVO } from '#/api/ec/import/mapping'; import type { ImportMappingVO } from '#/api/ec/import/mapping';
import { ref } from 'vue'; import { computed, ref } from 'vue';
import { Page } from '@vben/common-ui'; import { Page } from '@vben/common-ui';
import { createIconifyIcon } from '@vben/icons'; import { createIconifyIcon } from '@vben/icons';
@@ -14,6 +14,11 @@ import {
deleteImportMappingApi, deleteImportMappingApi,
getImportMappingPageApi, getImportMappingPageApi,
} from '#/api/ec/import/mapping'; } from '#/api/ec/import/mapping';
import { PermissionGate } from '#/components/permission';
import {
syncVxeGridColumns,
useActionColumnVisible,
} from '#/composables/use-vxe-action-column';
import { ImportMappingType } from '#/api/ec/import/mapping/types/types.enum'; import { ImportMappingType } from '#/api/ec/import/mapping/types/types.enum';
import ImportMappingFormModal from '../import-mapping/components/ImportMappingFormModal.vue'; import ImportMappingFormModal from '../import-mapping/components/ImportMappingFormModal.vue';
@@ -25,8 +30,14 @@ const PlusIcon = createIconifyIcon('lucide:plus');
const loading = ref(false); const loading = ref(false);
const formModalRef = ref(); const formModalRef = ref();
const gridOptions: VxeGridProps<any> = { const mappingActionCodes = [
columns: [ 'data:import-mapping:create',
'data:import-mapping:update',
'data:import-mapping:delete',
];
const showActionColumn = useActionColumnVisible(mappingActionCodes);
const mappingTableBaseColumns: VxeGridProps<any>['columns'] = [
{ type: 'seq', width: 80, title: '序号' }, { type: 'seq', width: 80, title: '序号' },
{ {
field: 'name', field: 'name',
@@ -42,8 +53,23 @@ const gridOptions: VxeGridProps<any> = {
}, },
{ field: 'createTime', title: '创建时间', width: 180 }, { field: 'createTime', title: '创建时间', width: 180 },
{ field: 'updateTime', title: '更新时间', width: 180 }, { field: 'updateTime', title: '更新时间', width: 180 },
{ title: '操作', width: 160, fixed: 'right', slots: { default: 'action' } }, ];
],
const mappingActionColumn: NonNullable<VxeGridProps<any>['columns']>[number] = {
title: '操作',
width: 160,
fixed: 'right',
slots: { default: 'action' },
};
const mappingTableColumns = computed(() =>
showActionColumn.value
? [...(mappingTableBaseColumns ?? []), mappingActionColumn]
: (mappingTableBaseColumns ?? []),
);
const gridOptions: VxeGridProps<any> = {
columns: mappingTableColumns.value,
height: 'auto', height: 'auto',
border: true, border: true,
stripe: true, stripe: true,
@@ -84,6 +110,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
showSearchForm: false, showSearchForm: false,
tableTitle: '订单状态映射模板', tableTitle: '订单状态映射模板',
}); });
syncVxeGridColumns(gridApi, mappingTableColumns);
function refresh() { function refresh() {
gridApi?.reload(); gridApi?.reload();
@@ -137,10 +164,12 @@ function getTypeName(type: ImportMappingType): string {
<Grid :loading="loading"> <Grid :loading="loading">
<template #toolbar-tools> <template #toolbar-tools>
<Space> <Space>
<Button type="primary" @click="handleAdd"> <PermissionGate code="data:import-mapping:create">
<PlusIcon /> <Button type="primary" @click="handleAdd">
新建模板 <PlusIcon />
</Button> 新建模板
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -154,12 +183,16 @@ function getTypeName(type: ImportMappingType): string {
<Tag color="green">{{ getMappingCount(row.mapping) }} 个状态</Tag> <Tag color="green">{{ getMappingCount(row.mapping) }} 个状态</Tag>
</template> </template>
<template #action="{ row }: { row: ImportMappingVO.ImportMappingInfoVO }"> <template v-if="showActionColumn" #action="{ row }: { row: ImportMappingVO.ImportMappingInfoVO }">
<Space> <Space>
<Button size="small" @click="handleEdit(row)">编辑</Button> <PermissionGate code="data:import-mapping:update">
<Popconfirm title="确定删除该模板?" @confirm="handleDelete(row)"> <Button size="small" @click="handleEdit(row)">编辑</Button>
<Button size="small" danger>删除</Button> </PermissionGate>
</Popconfirm> <PermissionGate code="data:import-mapping:delete">
<Popconfirm title="确定删除该模板?" @confirm="handleDelete(row)">
<Button size="small" danger>删除</Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -20,6 +20,7 @@ import { getAdFeeFieldsApi } from '#/api/ec/shop/ad-fee/apis';
import { getShopPageApi } from '#/api/ec/shop'; import { getShopPageApi } from '#/api/ec/shop';
import { createImportTaskApi } from '#/api/ec/import/task'; import { createImportTaskApi } from '#/api/ec/import/task';
import { useImportTaskStore } from '#/store'; import { useImportTaskStore } from '#/store';
import { PermissionGate } from '#/components/permission';
import { uploadFile } from '#/utils/upload-file'; import { uploadFile } from '#/utils/upload-file';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
@@ -601,9 +602,14 @@ const shopOptions = computed(() => {
</span> </span>
</Select.Option> </Select.Option>
</Select> </Select>
<Button :disabled="selectedTemplateId !== undefined" @click="handleSaveTemplate"> <PermissionGate code="data:import-mapping:create">
保存为模板 <Button
</Button> :disabled="selectedTemplateId !== undefined"
@click="handleSaveTemplate"
>
保存为模板
</Button>
</PermissionGate>
</div> </div>
</div> </div>
<template v-if="fieldDefsLoading"> <template v-if="fieldDefsLoading">
@@ -803,14 +809,16 @@ const shopOptions = computed(() => {
> >
下一步 下一步
</Button> </Button>
<Button <PermissionGate code="data:import:create">
v-if="currentStep === 1" <Button
type="primary" v-if="currentStep === 1"
:loading="createTaskSubmitting" type="primary"
@click="handleCreateTask" :loading="createTaskSubmitting"
> @click="handleCreateTask"
创建导入任务 >
</Button> 创建导入任务
</Button>
</PermissionGate>
</div> </div>
</div> </div>
@@ -34,6 +34,7 @@ import { createImportTaskApi } from '#/api/ec/import/task';
import { getAllOrderStatusListApi } from '#/api/ec/order/status'; import { getAllOrderStatusListApi } from '#/api/ec/order/status';
import { getShopPageApi } from '#/api/ec/shop'; import { getShopPageApi } from '#/api/ec/shop';
import { useImportTaskStore } from '#/store'; import { useImportTaskStore } from '#/store';
import { PermissionGate } from '#/components/permission';
import { uploadFile } from '#/utils/upload-file'; import { uploadFile } from '#/utils/upload-file';
import { createPatchedFile } from '../utils/skuCodePatch'; import { createPatchedFile } from '../utils/skuCodePatch';
@@ -1426,12 +1427,14 @@ const shopOptions = computed(() => {
</span> </span>
</Select.Option> </Select.Option>
</Select> </Select>
<Button <PermissionGate code="data:import-mapping:create">
:disabled="selectedTemplateId !== undefined" <Button
@click="handleSaveTemplate" :disabled="selectedTemplateId !== undefined"
> @click="handleSaveTemplate"
保存为模板 >
</Button> 保存为模板
</Button>
</PermissionGate>
</div> </div>
</div> </div>
<template v-if="fieldDefsLoading"> <template v-if="fieldDefsLoading">
@@ -1599,12 +1602,14 @@ const shopOptions = computed(() => {
</span> </span>
</Select.Option> </Select.Option>
</Select> </Select>
<Button <PermissionGate code="data:import-mapping:create">
:disabled="selectedStatusTemplateId !== undefined" <Button
@click="handleSaveStatusTemplate" :disabled="selectedStatusTemplateId !== undefined"
> @click="handleSaveStatusTemplate"
保存为模板 >
</Button> 保存为模板
</Button>
</PermissionGate>
</div> </div>
</div> </div>
<div <div
@@ -1862,14 +1867,16 @@ const shopOptions = computed(() => {
> >
下一步 下一步
</Button> </Button>
<Button <PermissionGate code="data:import:create">
v-if="currentStep === 2" <Button
type="primary" v-if="currentStep === 2"
:loading="createTaskSubmitting" type="primary"
@click="handleCreateTask" :loading="createTaskSubmitting"
> @click="handleCreateTask"
创建导入任务 >
</Button> 创建导入任务
</Button>
</PermissionGate>
</div> </div>
</div> </div>
@@ -32,6 +32,11 @@ import {
} from '#/api/ec/order'; } from '#/api/ec/order';
import { getProductPageApi } from '#/api/ec/product'; import { getProductPageApi } from '#/api/ec/product';
import { getPlatformListApi } from '#/api/ec/platform'; import { getPlatformListApi } from '#/api/ec/platform';
import { PermissionGate } from '#/components/permission';
import {
syncVxeGridColumns,
useActionColumnVisible,
} from '#/composables/use-vxe-action-column';
import PlatformTag from '#/components/platform/PlatformTag.vue'; import PlatformTag from '#/components/platform/PlatformTag.vue';
import { import {
getFirstOrderItem, getFirstOrderItem,
@@ -109,6 +114,8 @@ const platformLoaded = ref(false);
const currentSort = ref<null | { field: string; order: 'asc' | 'desc' }>(null); const currentSort = ref<null | { field: string; order: 'asc' | 'desc' }>(null);
const showCheckboxColumn = useActionColumnVisible(['ec:order:delete']);
function money(v?: null | number) { function money(v?: null | number) {
if (v == null || Number.isNaN(Number(v))) return '-'; if (v == null || Number.isNaN(Number(v))) return '-';
return `¥${Number(v).toFixed(2)}`; return `¥${Number(v).toFixed(2)}`;
@@ -236,87 +243,100 @@ async function fetchPlatformOptions() {
} }
} }
const orderTableBaseColumns: VxeGridProps<OrderVO.Info>['columns'] = [
{ type: 'seq' as const, width: 56, title: '序号' },
{
field: 'platformOrderNo',
title: '平台订单号',
minWidth: 180,
showOverflow: 'tooltip' as const,
sortable: true,
},
{
title: '平台',
width: 100,
slots: { default: 'platform' },
},
{
field: 'shopName',
title: '店铺',
minWidth: 120,
showOverflow: 'tooltip' as const,
sortable: true,
slots: { default: 'shopName' },
},
{
title: '商品',
minWidth: 240,
showOverflow: false,
slots: { default: 'goods' },
},
{
field: 'payAmount',
title: '实付',
width: 100,
sortable: true,
slots: { default: 'payAmount' },
},
{
field: 'receivedAmount',
title: '商家实收',
width: 110,
sortable: true,
slots: { default: 'receivedAmount' },
},
{
title: '订单状态',
width: 110,
slots: { default: 'orderStatus' },
},
{
title: '来源',
width: 80,
slots: { default: 'source' },
},
{
field: 'orderTime',
title: '下单时间',
minWidth: 160,
sortable: true,
},
{
title: '收件地区',
minWidth: 140,
showOverflow: 'tooltip' as const,
slots: { default: 'region' },
},
{
title: '操作',
width: 180,
fixed: 'right' as const,
slots: { default: 'action' },
},
];
const orderCheckboxColumn: NonNullable<
VxeGridProps<OrderVO.Info>['columns']
>[number] = {
type: 'checkbox' as const,
width: 48,
fixed: 'left' as const,
};
const orderTableColumns = computed(() => {
const cols = [...(orderTableBaseColumns ?? [])];
if (showCheckboxColumn.value) {
cols.splice(1, 0, orderCheckboxColumn);
}
return cols;
});
const gridOptions: VxeGridProps<OrderVO.Info> = { const gridOptions: VxeGridProps<OrderVO.Info> = {
checkboxConfig: { checkboxConfig: {
highlight: true, highlight: true,
reserve: false, reserve: false,
}, },
columns: [ columns: orderTableColumns.value,
{ type: 'seq' as const, width: 56, title: '序号' },
{
type: 'checkbox' as const,
width: 48,
fixed: 'left' as const,
},
{
field: 'platformOrderNo',
title: '平台订单号',
minWidth: 180,
showOverflow: 'tooltip' as const,
sortable: true,
},
{
title: '平台',
width: 100,
slots: { default: 'platform' },
},
{
field: 'shopName',
title: '店铺',
minWidth: 120,
showOverflow: 'tooltip' as const,
sortable: true,
slots: { default: 'shopName' },
},
{
title: '商品',
minWidth: 240,
showOverflow: false,
slots: { default: 'goods' },
},
{
field: 'payAmount',
title: '实付',
width: 100,
sortable: true,
slots: { default: 'payAmount' },
},
{
field: 'receivedAmount',
title: '商家实收',
width: 110,
sortable: true,
slots: { default: 'receivedAmount' },
},
{
title: '订单状态',
width: 110,
slots: { default: 'orderStatus' },
},
{
title: '来源',
width: 80,
slots: { default: 'source' },
},
{
field: 'orderTime',
title: '下单时间',
minWidth: 160,
sortable: true,
},
{
title: '收件地区',
minWidth: 140,
showOverflow: 'tooltip' as const,
slots: { default: 'region' },
},
{
title: '操作',
width: 180,
fixed: 'right' as const,
slots: { default: 'action' },
},
],
height: '100%', height: '100%',
border: true, border: true,
stripe: true, stripe: true,
@@ -559,6 +579,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
}, },
}); });
gridReloadRef.value = () => gridApi.reload(); gridReloadRef.value = () => gridApi.reload();
syncVxeGridColumns(gridApi, orderTableColumns);
watch(selectedShopId, () => { watch(selectedShopId, () => {
gridApi.reload(); gridApi.reload();
@@ -664,26 +685,30 @@ onMounted(async () => {
<template #extra> <template #extra>
<Space wrap size="small"> <Space wrap size="small">
<Button type="primary" @click="handleAdd"> <PermissionGate code="ec:order:create">
<PlusIcon class="mr-1 h-4 w-4" /> <Button type="primary" @click="handleAdd">
添加订单 <PlusIcon class="mr-1 h-4 w-4" />
</Button> 添加订单
<Popconfirm
title="确定删除选中的订单吗?删除后不可恢复。"
ok-text="确定删除"
cancel-text="取消"
:ok-button-props="{ danger: true, loading: batchDeleteLoading }"
:disabled="!hasSelected"
@confirm="handleBatchDelete"
>
<Button
danger
:disabled="!hasSelected"
:loading="batchDeleteLoading"
>
批量删除
</Button> </Button>
</Popconfirm> </PermissionGate>
<PermissionGate code="ec:order:delete">
<Popconfirm
title="确定删除选中的订单吗?删除后不可恢复。"
ok-text="确定删除"
cancel-text="取消"
:ok-button-props="{ danger: true, loading: batchDeleteLoading }"
:disabled="!hasSelected"
@confirm="handleBatchDelete"
>
<Button
danger
:disabled="!hasSelected"
:loading="batchDeleteLoading"
>
批量删除
</Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -761,15 +786,19 @@ onMounted(async () => {
<Button type="link" size="small" @click="openDetail(row)"> <Button type="link" size="small" @click="openDetail(row)">
详情 详情
</Button> </Button>
<Button type="link" size="small" @click="handleEdit(row)"> <PermissionGate code="ec:order:update">
编辑 <Button type="link" size="small" @click="handleEdit(row)">
</Button> 编辑
<Popconfirm </Button>
title="确定要删除这个订单吗?" </PermissionGate>
@confirm="handleDelete(row)" <PermissionGate code="ec:order:delete">
> <Popconfirm
<Button type="link" size="small" danger>删除</Button> title="确定要删除这个订单吗?"
</Popconfirm> @confirm="handleDelete(row)"
>
<Button type="link" size="small" danger>删除</Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -14,6 +14,11 @@ import {
deleteCategoryApi, deleteCategoryApi,
getCategoryTreeApi, getCategoryTreeApi,
} from '#/api/ec/product/category'; } from '#/api/ec/product/category';
import { PermissionGate } from '#/components/permission';
import {
syncVxeGridColumns,
useActionColumnVisible,
} from '#/composables/use-vxe-action-column';
import CategoryFormModal from './components/CategoryFormModal.vue'; import CategoryFormModal from './components/CategoryFormModal.vue';
@@ -25,9 +30,14 @@ const PlusIcon = createIconifyIcon('lucide:plus');
const loading = ref(false); const loading = ref(false);
const categoryFormModalRef = ref(); const categoryFormModalRef = ref();
// VbenVxeGrid 表格配置 const categoryActionCodes = [
const gridOptions: VxeGridProps<any> = { 'ec:product:category:create',
columns: [ 'ec:product:category:update',
'ec:product:category:delete',
];
const showActionColumn = useActionColumnVisible(categoryActionCodes);
const categoryTableBaseColumns: VxeGridProps<any>['columns'] = [
{ {
type: 'seq' as const, type: 'seq' as const,
width: 80, width: 80,
@@ -60,13 +70,25 @@ const gridOptions: VxeGridProps<any> = {
title: '更新时间', title: '更新时间',
minWidth: 160, minWidth: 160,
}, },
{ ];
title: '操作',
width: 160, const categoryActionColumn: NonNullable<VxeGridProps<any>['columns']>[number] =
fixed: 'right' as const, {
slots: { default: 'action' }, title: '操作',
}, width: 160,
], fixed: 'right' as const,
slots: { default: 'action' },
};
const categoryTableColumns = computed(() =>
showActionColumn.value
? [...(categoryTableBaseColumns ?? []), categoryActionColumn]
: (categoryTableBaseColumns ?? []),
);
// VbenVxeGrid 表格配置
const gridOptions: VxeGridProps<any> = {
columns: categoryTableColumns.value,
height: 'auto', height: 'auto',
border: true, border: true,
stripe: true, stripe: true,
@@ -144,6 +166,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
tableTitle: '商品类目配置', tableTitle: '商品类目配置',
}); });
gridReloadRef.value = () => gridApi.reload(); gridReloadRef.value = () => gridApi.reload();
syncVxeGridColumns(gridApi, categoryTableColumns);
function refreshTable() { function refreshTable() {
gridApi?.reload(); gridApi?.reload();
@@ -184,10 +207,12 @@ function handleModalSuccess() {
<Grid :loading="loading"> <Grid :loading="loading">
<template #toolbar-tools> <template #toolbar-tools>
<Space> <Space>
<Button type="primary" @click="handleAdd"> <PermissionGate code="ec:product:category:create">
<PlusIcon /> <Button type="primary" @click="handleAdd">
添加类目 <PlusIcon />
</Button> 添加类目
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -200,15 +225,19 @@ function handleModalSuccess() {
</template> </template>
<!-- 操作列 --> <!-- 操作列 -->
<template #action="{ row }: { row: any }"> <template v-if="showActionColumn" #action="{ row }: { row: any }">
<Space> <Space>
<Button size="small" @click="handleEdit(row)">编辑</Button> <PermissionGate code="ec:product:category:update">
<Popconfirm <Button size="small" @click="handleEdit(row)">编辑</Button>
title="确定要删除这个类目吗?" </PermissionGate>
@confirm="handleDelete(row)" <PermissionGate code="ec:product:category:delete">
> <Popconfirm
<Button size="small" danger>删除</Button> title="确定要删除这个类目吗?"
</Popconfirm> @confirm="handleDelete(row)"
>
<Button size="small" danger>删除</Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -14,6 +14,7 @@ import { Button, Image, message, Popconfirm, Space, Tag } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { deleteProductApi, getProductPageApi } from '#/api/ec/product'; import { deleteProductApi, getProductPageApi } from '#/api/ec/product';
import { PermissionGate } from '#/components/permission';
import ProductDetailModal from './components/ProductDetailModal.vue'; import ProductDetailModal from './components/ProductDetailModal.vue';
import ProductFormModal from './components/ProductFormModal.vue'; import ProductFormModal from './components/ProductFormModal.vue';
@@ -324,10 +325,12 @@ function handleDetailEdit(record: ProductVO.Info) {
<Page auto-content-height> <Page auto-content-height>
<Grid :loading="loading" class="product-grid"> <Grid :loading="loading" class="product-grid">
<template #toolbar-tools> <template #toolbar-tools>
<Button type="primary" @click="handleAdd"> <PermissionGate code="ec:product:create">
<PlusIcon class="mr-1 h-4 w-4" /> <Button type="primary" @click="handleAdd">
添加商品 <PlusIcon class="mr-1 h-4 w-4" />
</Button> 添加商品
</Button>
</PermissionGate>
</template> </template>
<!-- 商品信息:主图 + 名称,点击打开详情 --> <!-- 商品信息:主图 + 名称,点击打开详情 -->
@@ -398,26 +401,30 @@ function handleDetailEdit(record: ProductVO.Info) {
<Button type="link" size="small" @click="openProductDetail(row)"> <Button type="link" size="small" @click="openProductDetail(row)">
详情 详情
</Button> </Button>
<Button type="link" size="small" @click="handleEdit(row)"> <PermissionGate code="ec:product:update">
<EditIcon class="mr-0.5 h-3.5 w-3.5" /> <Button type="link" size="small" @click="handleEdit(row)">
编辑 <EditIcon class="mr-0.5 h-3.5 w-3.5" />
</Button> 编辑
<Button type="link" size="small" @click="handleCost(row)"> </Button>
<CoinsIcon class="mr-0.5 h-3.5 w-3.5" /> <Button type="link" size="small" @click="handleCost(row)">
成本 <CoinsIcon class="mr-0.5 h-3.5 w-3.5" />
</Button> 成本
</Button>
</PermissionGate>
<Button type="link" size="small" @click="goToOverview(row)"> <Button type="link" size="small" @click="goToOverview(row)">
<ChartIcon class="mr-0.5 h-3.5 w-3.5" /> <ChartIcon class="mr-0.5 h-3.5 w-3.5" />
统计 统计
</Button> </Button>
<Popconfirm <PermissionGate code="ec:product:delete">
title="确定删除该商品吗?删除后不可恢复。" <Popconfirm
ok-text="确定删除" title="确定删除该商品吗?删除后不可恢复。"
cancel-text="取消" ok-text="确定删除"
@confirm="handleDelete(row)" cancel-text="取消"
> @confirm="handleDelete(row)"
<Button type="link" size="small" danger>删除</Button> >
</Popconfirm> <Button type="link" size="small" danger>删除</Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -4,7 +4,7 @@ import type { AdFeeDTO, AdFeeVO } from '#/api/ec/shop/ad-fee/types';
import type { ShopVO } from '#/api/ec/shop/types'; import type { ShopVO } from '#/api/ec/shop/types';
import type { PageQueryDTO } from '#/types/common'; import type { PageQueryDTO } from '#/types/common';
import { ref, watch } from 'vue'; import { computed, ref, watch } from 'vue';
import { createIconifyIcon } from '@vben/icons'; import { createIconifyIcon } from '@vben/icons';
@@ -19,6 +19,11 @@ import {
import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { deleteAdFeeApi, getAdFeePageApi } from '#/api/ec/shop/ad-fee'; import { deleteAdFeeApi, getAdFeePageApi } from '#/api/ec/shop/ad-fee';
import { PermissionGate } from '#/components/permission';
import {
syncVxeGridColumns,
useActionColumnVisible,
} from '#/composables/use-vxe-action-column';
import EcShopColPage from '#/views/ec/components/EcShopColPage.vue'; import EcShopColPage from '#/views/ec/components/EcShopColPage.vue';
import AdFeeFormModal from './components/AdFeeFormModal.vue'; import AdFeeFormModal from './components/AdFeeFormModal.vue';
@@ -49,8 +54,14 @@ function handleAddForShop(shopId: number) {
formModalVisible.value = true; formModalVisible.value = true;
} }
const gridOptions: VxeGridProps<AdFeeVO.Info> = { const adFeeActionCodes = [
columns: [ 'ec:order:create',
'ec:order:update',
'ec:order:delete',
];
const showActionColumn = useActionColumnVisible(adFeeActionCodes);
const adFeeTableBaseColumns: VxeGridProps<AdFeeVO.Info>['columns'] = [
{ type: 'seq' as const, minWidth: 56, title: '序号' }, { type: 'seq' as const, minWidth: 56, title: '序号' },
{ {
field: 'shopName', field: 'shopName',
@@ -77,13 +88,25 @@ const gridOptions: VxeGridProps<AdFeeVO.Info> = {
slots: { default: 'feeAmount' }, slots: { default: 'feeAmount' },
}, },
{ field: 'feeDate', title: '发生日期', minWidth: 110 }, { field: 'feeDate', title: '发生日期', minWidth: 110 },
{ ];
title: '操作',
minWidth: 140, const adFeeActionColumn: NonNullable<
fixed: 'right' as const, VxeGridProps<AdFeeVO.Info>['columns']
slots: { default: 'action' }, >[number] = {
}, title: '操作',
], minWidth: 140,
fixed: 'right' as const,
slots: { default: 'action' },
};
const adFeeTableColumns = computed(() =>
showActionColumn.value
? [...(adFeeTableBaseColumns ?? []), adFeeActionColumn]
: (adFeeTableBaseColumns ?? []),
);
const gridOptions: VxeGridProps<AdFeeVO.Info> = {
columns: adFeeTableColumns.value,
height: '100%', height: '100%',
border: true, border: true,
stripe: true, stripe: true,
@@ -151,6 +174,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
showSearchForm: false, showSearchForm: false,
tableTitle: '', tableTitle: '',
}); });
syncVxeGridColumns(gridApi, adFeeTableColumns);
watch(selectedShopId, () => { watch(selectedShopId, () => {
gridApi.reload(); gridApi.reload();
@@ -235,10 +259,12 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
allow-clear allow-clear
@change="() => refreshTable()" @change="() => refreshTable()"
/> />
<Button type="primary" @click="handleAdd"> <PermissionGate code="ec:order:create">
<PlusIcon class="mr-1 h-4 w-4" /> <Button type="primary" @click="handleAdd">
新增广告费 <PlusIcon class="mr-1 h-4 w-4" />
</Button> 新增广告费
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -264,15 +290,19 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
</div> </div>
</template> </template>
<template #action="{ row }"> <template v-if="showActionColumn" #action="{ row }">
<Space> <Space>
<Button size="small" @click="handleEdit(row)">编辑</Button> <PermissionGate code="ec:order:update">
<Popconfirm <Button size="small" @click="handleEdit(row)">编辑</Button>
title="确定要删除这条广告费记录吗?" </PermissionGate>
@confirm="handleDelete(row.id)" <PermissionGate code="ec:order:delete">
> <Popconfirm
<Button size="small" danger>删除</Button> title="确定要删除这条广告费记录吗?"
</Popconfirm> @confirm="handleDelete(row.id)"
>
<Button size="small" danger>删除</Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -5,7 +5,7 @@ import type { ProductDTO, ProductVO } from '#/api/ec/product/types';
import type { ShopVO } from '#/api/ec/shop/types'; import type { ShopVO } from '#/api/ec/shop/types';
import type { PageQueryDTO } from '#/types/common'; import type { PageQueryDTO } from '#/types/common';
import { ref, watch } from 'vue'; import { computed, ref, watch } from 'vue';
import { createIconifyIcon } from '@vben/icons'; import { createIconifyIcon } from '@vben/icons';
@@ -26,6 +26,11 @@ import {
getBrushOrderPageApi, getBrushOrderPageApi,
} from '#/api/ec/shop/fake-orders-fee'; } from '#/api/ec/shop/fake-orders-fee';
import { getProductPageApi } from '#/api/ec/product'; import { getProductPageApi } from '#/api/ec/product';
import { PermissionGate } from '#/components/permission';
import {
syncVxeGridColumns,
useActionColumnVisible,
} from '#/composables/use-vxe-action-column';
import EcShopColPage from '#/views/ec/components/EcShopColPage.vue'; import EcShopColPage from '#/views/ec/components/EcShopColPage.vue';
import BrushOrderFormModal from './components/BrushOrderFormModal.vue'; import BrushOrderFormModal from './components/BrushOrderFormModal.vue';
@@ -122,8 +127,14 @@ function handleAddForShop(shopId: number) {
formModalVisible.value = true; formModalVisible.value = true;
} }
const gridOptions: VxeGridProps<BrushOrderVO.Info> = { const brushOrderActionCodes = [
columns: [ 'ec:order:create',
'ec:order:update',
'ec:order:delete',
];
const showActionColumn = useActionColumnVisible(brushOrderActionCodes);
const brushOrderTableBaseColumns: VxeGridProps<BrushOrderVO.Info>['columns'] = [
{ {
type: 'seq' as const, type: 'seq' as const,
width: 56, width: 56,
@@ -160,13 +171,25 @@ const gridOptions: VxeGridProps<BrushOrderVO.Info> = {
title: '创建时间', title: '创建时间',
minWidth: 160, minWidth: 160,
}, },
{ ];
title: '操作',
width: 140, const brushOrderActionColumn: NonNullable<
fixed: 'right' as const, VxeGridProps<BrushOrderVO.Info>['columns']
slots: { default: 'action' }, >[number] = {
}, title: '操作',
], width: 140,
fixed: 'right' as const,
slots: { default: 'action' },
};
const brushOrderTableColumns = computed(() =>
showActionColumn.value
? [...(brushOrderTableBaseColumns ?? []), brushOrderActionColumn]
: (brushOrderTableBaseColumns ?? []),
);
const gridOptions: VxeGridProps<BrushOrderVO.Info> = {
columns: brushOrderTableColumns.value,
height: '100%', height: '100%',
border: true, border: true,
stripe: true, stripe: true,
@@ -241,6 +264,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
showSearchForm: false, showSearchForm: false,
tableTitle: '', tableTitle: '',
}); });
syncVxeGridColumns(gridApi, brushOrderTableColumns);
watch(selectedShopId, () => { watch(selectedShopId, () => {
gridApi.reload(); gridApi.reload();
@@ -307,10 +331,12 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
</template> </template>
<template #extra> <template #extra>
<Button type="primary" @click="handleAdd"> <PermissionGate code="ec:order:create">
<PlusIcon class="mr-1 h-4 w-4" /> <Button type="primary" @click="handleAdd">
新增刷单记录 <PlusIcon class="mr-1 h-4 w-4" />
</Button> 新增刷单记录
</Button>
</PermissionGate>
</template> </template>
<div class="shrink-0 space-y-2 border-t border-border px-4 py-3"> <div class="shrink-0 space-y-2 border-t border-border px-4 py-3">
@@ -418,15 +444,19 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
</span> </span>
</template> </template>
<template #action="{ row }"> <template v-if="showActionColumn" #action="{ row }">
<Space> <Space>
<Button size="small" @click="handleEdit(row)">编辑</Button> <PermissionGate code="ec:order:update">
<Popconfirm <Button size="small" @click="handleEdit(row)">编辑</Button>
title="确定要删除这条刷单记录吗?" </PermissionGate>
@confirm="handleDelete(row.id)" <PermissionGate code="ec:order:delete">
> <Popconfirm
<Button size="small" danger>删除</Button> title="确定要删除这条刷单记录吗?"
</Popconfirm> @confirm="handleDelete(row.id)"
>
<Button size="small" danger>删除</Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -20,6 +20,11 @@ import { batchPddAdFeePipelineStatusApi } from '#/api/channel/pdd/goods-ad-fee-i
import type { PddGoodsAdFeeImportVO } from '#/api/channel/pdd/goods-ad-fee-import'; import type { PddGoodsAdFeeImportVO } from '#/api/channel/pdd/goods-ad-fee-import';
import { getPlatformListApi } from '#/api/ec/platform'; import { getPlatformListApi } from '#/api/ec/platform';
import { deleteShopApi, getShopPageApi } from '#/api/ec/shop'; import { deleteShopApi, getShopPageApi } from '#/api/ec/shop';
import { PermissionGate } from '#/components/permission';
import {
syncVxeGridColumns,
useActionColumnVisible,
} from '#/composables/use-vxe-action-column';
import { import {
getPlatformLabel, getPlatformLabel,
getPlatformTagColor, getPlatformTagColor,
@@ -60,7 +65,15 @@ type ShopListRow = Partial<ShopVO.Info> & {
shop?: ShopVO.Info; shop?: ShopVO.Info;
}; };
const COLUMN_COUNT = 8; const shopActionCodes = [
'ec:shop:create',
'ec:shop:update',
'ec:shop:delete',
'channel:pdd:shop:update',
];
const showActionColumn = useActionColumnVisible(shopActionCodes);
const columnCount = computed(() => (showActionColumn.value ? 8 : 7));
const searchForm = ref({ const searchForm = ref({
name: '', name: '',
@@ -103,62 +116,73 @@ function toShopListRows(records: ShopVO.Info[]): ShopListRow[] {
return rows; return rows;
} }
const shopTableBaseColumns: VxeGridProps<ShopListRow>['columns'] = [
{
width: 64,
title: '序号',
align: 'center' as const,
showOverflow: false,
slots: { default: 'seq' },
},
{
title: 'Logo',
width: 120,
align: 'center' as const,
showOverflow: false,
slots: { default: 'logoOrPipeline' },
},
{
field: 'name',
title: '店铺名称',
minWidth: 'auto',
showOverflow: 'tooltip' as const,
slots: { default: 'name' },
},
{
field: 'platformName',
title: '平台',
minWidth: 120,
showOverflow: true,
slots: { default: 'platformName' },
},
{
title: '外部店铺',
minWidth: 180,
align: 'center' as const,
showOverflow: false,
slots: { default: 'externalShop' },
},
{
field: 'createTime',
title: '创建时间',
minWidth: 'auto',
slots: { default: 'createTime' },
},
{
field: 'updateTime',
title: '更新时间',
minWidth: 'auto',
slots: { default: 'updateTime' },
},
];
const shopActionColumn: NonNullable<
VxeGridProps<ShopListRow>['columns']
>[number] = {
title: '操作',
minWidth: 320,
showOverflow: false,
slots: { default: 'action' },
};
const shopTableColumns = computed(() =>
showActionColumn.value
? [...(shopTableBaseColumns ?? []), shopActionColumn]
: (shopTableBaseColumns ?? []),
);
const gridOptions: VxeGridProps<ShopListRow> = { const gridOptions: VxeGridProps<ShopListRow> = {
columns: [ columns: shopTableColumns.value,
{
width: 64,
title: '序号',
align: 'center' as const,
showOverflow: false,
slots: { default: 'seq' },
},
{
title: 'Logo',
width: 120,
align: 'center' as const,
showOverflow: false,
slots: { default: 'logoOrPipeline' },
},
{
field: 'name',
title: '店铺名称',
minWidth: 'auto',
showOverflow: 'tooltip' as const,
slots: { default: 'name' },
},
{
field: 'platformName',
title: '平台',
minWidth: 120,
showOverflow: true,
slots: { default: 'platformName' },
},
{
title: '外部店铺',
minWidth: 180,
align: 'center' as const,
showOverflow: false,
slots: { default: 'externalShop' },
},
{
field: 'createTime',
title: '创建时间',
minWidth: 'auto',
slots: { default: 'createTime' },
},
{
field: 'updateTime',
title: '更新时间',
minWidth: 'auto',
slots: { default: 'updateTime' },
},
{
title: '操作',
minWidth: 320,
showOverflow: false,
slots: { default: 'action' },
},
],
height: 'auto', height: 'auto',
border: true, border: true,
stripe: false, stripe: false,
@@ -185,7 +209,7 @@ const gridOptions: VxeGridProps<ShopListRow> = {
// 管线次行:从 Logo 起横向合并剩余列 // 管线次行:从 Logo 起横向合并剩余列
if (row._rowType === 'pipeline' || row._rowType === 'adfee-pipeline') { if (row._rowType === 'pipeline' || row._rowType === 'adfee-pipeline') {
if (columnIndex === 1) { if (columnIndex === 1) {
return { rowspan: 1, colspan: COLUMN_COUNT - 1 }; return { rowspan: 1, colspan: columnCount.value - 1 };
} }
return { rowspan: 0, colspan: 0 }; return { rowspan: 0, colspan: 0 };
} }
@@ -297,6 +321,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
tableTitle: '店铺管理', tableTitle: '店铺管理',
}); });
gridReloadRef.value = () => gridApi.reload(); gridReloadRef.value = () => gridApi.reload();
syncVxeGridColumns(gridApi, shopTableColumns);
async function fetchPlatformOptions() { async function fetchPlatformOptions() {
try { try {
@@ -662,10 +687,12 @@ onUnmounted(() => {
<Grid :loading="loading" class="shop-grid"> <Grid :loading="loading" class="shop-grid">
<template #toolbar-tools> <template #toolbar-tools>
<Space> <Space>
<Button type="primary" @click="handleAdd"> <PermissionGate code="ec:shop:create">
<PlusIcon /> <Button type="primary" @click="handleAdd">
添加店铺 <PlusIcon />
</Button> 添加店铺
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -820,25 +847,31 @@ onUnmounted(() => {
<span v-if="!isSubPipelineRow(row)">{{ row.updateTime }}</span> <span v-if="!isSubPipelineRow(row)">{{ row.updateTime }}</span>
</template> </template>
<template #action="{ row }: { row: ShopListRow }"> <template v-if="showActionColumn" #action="{ row }: { row: ShopListRow }">
<Space v-if="!isSubPipelineRow(row)"> <Space v-if="!isSubPipelineRow(row)">
<Button <PermissionGate code="channel:pdd:shop:update">
v-if="isPddShop(row)" <Button
size="small" v-if="isPddShop(row)"
type="primary" size="small"
ghost type="primary"
:loading="authorizing" ghost
@click="handleAuthorizePdd(row)" :loading="authorizing"
> @click="handleAuthorizePdd(row)"
{{ hasExternalShop(row) ? '重新授权' : '授权拼多多' }} >
</Button> {{ hasExternalShop(row) ? '重新授权' : '授权拼多多' }}
<Button size="small" @click="handleEdit(row)">编辑</Button> </Button>
<Popconfirm </PermissionGate>
title="确定要删除这个店铺吗?" <PermissionGate code="ec:shop:update">
@confirm="handleDelete(row)" <Button size="small" @click="handleEdit(row)">编辑</Button>
> </PermissionGate>
<Button size="small" danger>删除</Button> <PermissionGate code="ec:shop:delete">
</Popconfirm> <Popconfirm
title="确定要删除这个店铺吗?"
@confirm="handleDelete(row)"
>
<Button size="small" danger>删除</Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -7,7 +7,7 @@ import type {
import type { ShopVO } from '#/api/ec/shop/types'; import type { ShopVO } from '#/api/ec/shop/types';
import type { PageQueryDTO } from '#/types/common'; import type { PageQueryDTO } from '#/types/common';
import { ref, watch } from 'vue'; import { computed, ref, watch } from 'vue';
import { createIconifyIcon } from '@vben/icons'; import { createIconifyIcon } from '@vben/icons';
@@ -25,6 +25,11 @@ import {
deleteShopMonthlyTargetApi, deleteShopMonthlyTargetApi,
getShopMonthlyTargetPageApi, getShopMonthlyTargetPageApi,
} from '#/api/ec/shop/monthly-target'; } from '#/api/ec/shop/monthly-target';
import { PermissionGate } from '#/components/permission';
import {
syncVxeGridColumns,
useActionColumnVisible,
} from '#/composables/use-vxe-action-column';
import EcShopColPage from '#/views/ec/components/EcShopColPage.vue'; import EcShopColPage from '#/views/ec/components/EcShopColPage.vue';
import ShopMonthlyTargetFormModal from './components/ShopMonthlyTargetFormModal.vue'; import ShopMonthlyTargetFormModal from './components/ShopMonthlyTargetFormModal.vue';
@@ -55,8 +60,15 @@ function handleAddForShop(shopId: number) {
formModalVisible.value = true; formModalVisible.value = true;
} }
const gridOptions: VxeGridProps<ShopMonthlyTargetVO.Info> = { const monthlyTargetActionCodes = [
columns: [ 'ec:shop:create',
'ec:shop:update',
'ec:shop:delete',
];
const showActionColumn = useActionColumnVisible(monthlyTargetActionCodes);
const monthlyTargetTableBaseColumns: VxeGridProps<ShopMonthlyTargetVO.Info>['columns'] =
[
{ type: 'seq' as const, minWidth: 56, title: '序号' }, { type: 'seq' as const, minWidth: 56, title: '序号' },
{ {
field: 'shopName', field: 'shopName',
@@ -78,13 +90,25 @@ const gridOptions: VxeGridProps<ShopMonthlyTargetVO.Info> = {
showOverflow: 'tooltip' as const, showOverflow: 'tooltip' as const,
}, },
{ field: 'createTime', title: '创建时间', minWidth: 160 }, { field: 'createTime', title: '创建时间', minWidth: 160 },
{ ];
title: '操作',
minWidth: 140, const monthlyTargetActionColumn: NonNullable<
fixed: 'right' as const, VxeGridProps<ShopMonthlyTargetVO.Info>['columns']
slots: { default: 'action' }, >[number] = {
}, title: '操作',
], minWidth: 140,
fixed: 'right' as const,
slots: { default: 'action' },
};
const monthlyTargetTableColumns = computed(() =>
showActionColumn.value
? [...(monthlyTargetTableBaseColumns ?? []), monthlyTargetActionColumn]
: (monthlyTargetTableBaseColumns ?? []),
);
const gridOptions: VxeGridProps<ShopMonthlyTargetVO.Info> = {
columns: monthlyTargetTableColumns.value,
height: '100%', height: '100%',
border: true, border: true,
stripe: true, stripe: true,
@@ -152,6 +176,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
showSearchForm: false, showSearchForm: false,
tableTitle: '', tableTitle: '',
}); });
syncVxeGridColumns(gridApi, monthlyTargetTableColumns);
watch(selectedShopId, () => { watch(selectedShopId, () => {
gridApi.reload(); gridApi.reload();
@@ -238,10 +263,12 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
allow-clear allow-clear
@change="() => refreshTable()" @change="() => refreshTable()"
/> />
<Button type="primary" @click="handleAdd"> <PermissionGate code="ec:shop:create">
<PlusIcon class="mr-1 h-4 w-4" /> <Button type="primary" @click="handleAdd">
新增月销量目标 <PlusIcon class="mr-1 h-4 w-4" />
</Button> 新增月销量目标
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -255,15 +282,19 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
</span> </span>
</template> </template>
<template #action="{ row }"> <template v-if="showActionColumn" #action="{ row }">
<Space> <Space>
<Button size="small" @click="handleEdit(row)">编辑</Button> <PermissionGate code="ec:shop:update">
<Popconfirm <Button size="small" @click="handleEdit(row)">编辑</Button>
title="确定要删除这条月销量目标吗?" </PermissionGate>
@confirm="handleDelete(row.id)" <PermissionGate code="ec:shop:delete">
> <Popconfirm
<Button size="small" danger>删除</Button> title="确定要删除这条月销量目标吗?"
</Popconfirm> @confirm="handleDelete(row.id)"
>
<Button size="small" danger>删除</Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -2,7 +2,7 @@
import type { VxeGridProps } from '#/adapter/vxe-table'; import type { VxeGridProps } from '#/adapter/vxe-table';
import type { OpenApiKeyVO } from '#/api/open/api-key'; import type { OpenApiKeyVO } from '#/api/open/api-key';
import { ref } from 'vue'; import { computed, ref } from 'vue';
import { Page } from '@vben/common-ui'; import { Page } from '@vben/common-ui';
import { createIconifyIcon } from '@vben/icons'; import { createIconifyIcon } from '@vben/icons';
@@ -16,6 +16,11 @@ import {
enableOpenApiKeyApi, enableOpenApiKeyApi,
getOpenApiKeyListApi, getOpenApiKeyListApi,
} from '#/api/open/api-key'; } from '#/api/open/api-key';
import { PermissionGate } from '#/components/permission';
import {
syncVxeGridColumns,
useActionColumnVisible,
} from '#/composables/use-vxe-action-column';
import CreateApiKeyModal from './components/CreateApiKeyModal.vue'; import CreateApiKeyModal from './components/CreateApiKeyModal.vue';
import OpenApiBaseUrlDisplay from './components/OpenApiBaseUrlDisplay.vue'; import OpenApiBaseUrlDisplay from './components/OpenApiBaseUrlDisplay.vue';
@@ -30,8 +35,15 @@ function formatExpireAt(cellValue?: null | string) {
return cellValue ? String(cellValue) : '永不过期'; return cellValue ? String(cellValue) : '永不过期';
} }
const gridOptions: VxeGridProps<OpenApiKeyVO.OpenApiKeyInfoVO> = { const apiKeyActionCodes = [
columns: [ 'open:api-key:create',
'open:api-key:update',
'open:api-key:delete',
];
const showActionColumn = useActionColumnVisible(apiKeyActionCodes);
const apiKeyTableBaseColumns: VxeGridProps<OpenApiKeyVO.OpenApiKeyInfoVO>['columns'] =
[
{ type: 'seq', title: '序号', minWidth: 60 }, { type: 'seq', title: '序号', minWidth: 60 },
{ field: 'name', title: '名称', minWidth: 140 }, { field: 'name', title: '名称', minWidth: 140 },
{ field: 'keyPrefix', title: 'Key 前缀', minWidth: 180 }, { field: 'keyPrefix', title: 'Key 前缀', minWidth: 180 },
@@ -57,13 +69,25 @@ const gridOptions: VxeGridProps<OpenApiKeyVO.OpenApiKeyInfoVO> = {
formatExpireAt(cellValue), formatExpireAt(cellValue),
}, },
{ field: 'createTime', title: '创建时间', minWidth: 160 }, { field: 'createTime', title: '创建时间', minWidth: 160 },
{ ];
title: '操作',
width: 200, const apiKeyActionColumn: NonNullable<
fixed: 'right', VxeGridProps<OpenApiKeyVO.OpenApiKeyInfoVO>['columns']
slots: { default: 'action' }, >[number] = {
}, title: '操作',
], width: 200,
fixed: 'right',
slots: { default: 'action' },
};
const apiKeyTableColumns = computed(() =>
showActionColumn.value
? [...(apiKeyTableBaseColumns ?? []), apiKeyActionColumn]
: (apiKeyTableBaseColumns ?? []),
);
const gridOptions: VxeGridProps<OpenApiKeyVO.OpenApiKeyInfoVO> = {
columns: apiKeyTableColumns.value,
height: 'auto', height: 'auto',
border: true, border: true,
stripe: true, stripe: true,
@@ -91,6 +115,7 @@ const gridOptions: VxeGridProps<OpenApiKeyVO.OpenApiKeyInfoVO> = {
}; };
const [Grid, gridApi] = useVbenVxeGrid({ gridOptions }); const [Grid, gridApi] = useVbenVxeGrid({ gridOptions });
syncVxeGridColumns(gridApi, apiKeyTableColumns);
async function handleDisable(row: OpenApiKeyVO.OpenApiKeyInfoVO) { async function handleDisable(row: OpenApiKeyVO.OpenApiKeyInfoVO) {
await disableOpenApiKeyApi(row.id); await disableOpenApiKeyApi(row.id);
@@ -132,10 +157,12 @@ function getPermissionTooltip(row: OpenApiKeyVO.OpenApiKeyInfoVO) {
<Grid :loading="loading"> <Grid :loading="loading">
<template #toolbar-tools> <template #toolbar-tools>
<Button type="primary" @click="openCreateModal"> <PermissionGate code="open:api-key:create">
<PlusIcon class="size-4" /> <Button type="primary" @click="openCreateModal">
创建 API Key <PlusIcon class="size-4" />
</Button> 创建 API Key
</Button>
</PermissionGate>
</template> </template>
<template #permissions="{ row }"> <template #permissions="{ row }">
@@ -156,25 +183,29 @@ function getPermissionTooltip(row: OpenApiKeyVO.OpenApiKeyInfoVO) {
</Tag> </Tag>
</template> </template>
<template #action="{ row }"> <template v-if="showActionColumn" #action="{ row }">
<Space> <Space>
<Popconfirm <PermissionGate code="open:api-key:update">
v-if="row.status === 1" <Popconfirm
title="确认停用该 API Key?" v-if="row.status === 1"
@confirm="handleDisable(row)" title="确认停用该 API Key?"
> @confirm="handleDisable(row)"
<Button type="link" size="small">停用</Button> >
</Popconfirm> <Button type="link" size="small">停用</Button>
<Popconfirm </Popconfirm>
v-else <Popconfirm
title="确认启用该 API Key?" v-else
@confirm="handleEnable(row)" title="确认启用该 API Key?"
> @confirm="handleEnable(row)"
<Button type="link" size="small">启用</Button> >
</Popconfirm> <Button type="link" size="small">启用</Button>
<Popconfirm title="确认删除该 API Key?" @confirm="handleDelete(row)"> </Popconfirm>
<Button type="link" danger size="small">删除</Button> </PermissionGate>
</Popconfirm> <PermissionGate code="open:api-key:delete">
<Popconfirm title="确认删除该 API Key?" @confirm="handleDelete(row)">
<Button type="link" danger size="small">删除</Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -35,6 +35,11 @@ import {
} from '#/api/sys/account'; } from '#/api/sys/account';
import SuperAccountFormModal from './components/SuperAccountFormModal.vue'; import SuperAccountFormModal from './components/SuperAccountFormModal.vue';
import { PermissionGate } from '#/components/permission';
import {
syncVxeGridColumns,
useActionColumnVisible,
} from '#/composables/use-vxe-action-column';
import { import {
SIDEBAR_LIST_SHELL_CLASS, SIDEBAR_LIST_SHELL_CLASS,
sidebarListRowClass, sidebarListRowClass,
@@ -82,8 +87,15 @@ const selectedCompanyLabel = computed(() => {
return currentCompany.value.name; return currentCompany.value.name;
}); });
const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = { const accountActionCodes = [
columns: [ 'org:account:create',
'org:account:update',
'org:account:delete',
];
const showActionColumn = useActionColumnVisible(accountActionCodes);
const accountTableBaseColumns: VxeGridProps<SuperAccountVO.AccountInfoVO>['columns'] =
[
{ type: 'seq' as const, minWidth: 56, title: '序号' }, { type: 'seq' as const, minWidth: 56, title: '序号' },
{ {
field: 'loginCode', field: 'loginCode',
@@ -139,13 +151,25 @@ const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
minWidth: 160, minWidth: 160,
showOverflow: 'tooltip' as const, showOverflow: 'tooltip' as const,
}, },
{ ];
title: '操作',
minWidth: 140, const accountActionColumn: NonNullable<
fixed: 'right' as const, VxeGridProps<SuperAccountVO.AccountInfoVO>['columns']
slots: { default: 'action' }, >[number] = {
}, title: '操作',
], minWidth: 140,
fixed: 'right' as const,
slots: { default: 'action' },
};
const accountTableColumns = computed(() =>
showActionColumn.value
? [...(accountTableBaseColumns ?? []), accountActionColumn]
: (accountTableBaseColumns ?? []),
);
const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
columns: accountTableColumns.value,
height: '100%', height: '100%',
border: true, border: true,
stripe: true, stripe: true,
@@ -220,6 +244,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
showSearchForm: false, showSearchForm: false,
tableTitle: '账户列表', tableTitle: '账户列表',
}); });
syncVxeGridColumns(gridApi, accountTableColumns);
async function searchCompanies() { async function searchCompanies() {
companyLoading.value = true; companyLoading.value = true;
@@ -345,10 +370,12 @@ onMounted(() => {
<template #extra> <template #extra>
<Space> <Space>
<Button type="primary" @click="handleAdd"> <PermissionGate code="org:account:create">
<PlusIcon class="mr-2 h-4 w-4" /> <Button type="primary" @click="handleAdd">
新增账户 <PlusIcon class="mr-2 h-4 w-4" />
</Button> 新增账户
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -431,15 +458,17 @@ onMounted(() => {
{{ company.status === 1 ? '启用' : '禁用' }} {{ company.status === 1 ? '启用' : '禁用' }}
</span> </span>
</button> </button>
<Button <PermissionGate code="org:account:create">
type="link" <Button
size="small" type="link"
class="!h-7 shrink-0 !px-1 !text-xs font-semibold opacity-80 group-hover:opacity-100" size="small"
@click.stop="handleAddForCompany(company)" class="!h-7 shrink-0 !px-1 !text-xs font-semibold opacity-80 group-hover:opacity-100"
> @click.stop="handleAddForCompany(company)"
<PlusIcon class="mr-0.5 inline h-3.5 w-3.5" /> >
添加 <PlusIcon class="mr-0.5 inline h-3.5 w-3.5" />
</Button> 添加
</Button>
</PermissionGate>
</div> </div>
</div> </div>
</div> </div>
@@ -537,15 +566,19 @@ onMounted(() => {
</Tag> </Tag>
</template> </template>
<template #action="{ row }"> <template v-if="showActionColumn" #action="{ row }">
<Space> <Space>
<Button size="small" @click="handleEdit(row)">编辑</Button> <PermissionGate code="org:account:update">
<Popconfirm <Button size="small" @click="handleEdit(row)">编辑</Button>
title="确定要删除这个账户吗?" </PermissionGate>
@confirm="handleDelete(row)" <PermissionGate code="org:account:delete">
> <Popconfirm
<Button size="small" danger>删除</Button> title="确定要删除这个账户吗?"
</Popconfirm> @confirm="handleDelete(row)"
>
<Button size="small" danger>删除</Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -15,6 +15,11 @@ import {
admin_deleteAccountApi, admin_deleteAccountApi,
admin_getAccountPageApi, admin_getAccountPageApi,
} from '#/api/company/account'; } from '#/api/company/account';
import { PermissionGate } from '#/components/permission';
import {
syncVxeGridColumns,
useActionColumnVisible,
} from '#/composables/use-vxe-action-column';
import AccountFormModal from './components/AccountFormModal.vue'; import AccountFormModal from './components/AccountFormModal.vue';
@@ -51,6 +56,13 @@ const statusOptions = [
{ label: '停用', value: 0 }, { label: '停用', value: 0 },
]; ];
const accountActionCodes = [
'org:account:create',
'org:account:update',
'org:account:delete',
];
const showActionColumn = useActionColumnVisible(accountActionCodes);
// 搜索表单配置 // 搜索表单配置
const gridReloadRef = ref<(() => void) | null>(null); const gridReloadRef = ref<(() => void) | null>(null);
const formOptions = computed(() => ({ const formOptions = computed(() => ({
@@ -108,9 +120,7 @@ const formOptions = computed(() => ({
collapsedRows: 1, collapsedRows: 1,
})); }));
// VbenVxeGrid 表格配置 const accountTableBaseColumns: VxeGridProps<any>['columns'] = [
const gridOptions: VxeGridProps<any> = {
columns: [
{ {
type: 'seq' as const, type: 'seq' as const,
minWidth: 'auto', minWidth: 'auto',
@@ -163,13 +173,24 @@ const gridOptions: VxeGridProps<any> = {
title: '创建时间', title: '创建时间',
minWidth: 160, minWidth: 160,
}, },
{ ];
title: '操作',
width: 120, const accountActionColumn: NonNullable<VxeGridProps<any>['columns']>[number] = {
fixed: 'right' as const, title: '操作',
slots: { default: 'action' }, width: 120,
}, fixed: 'right' as const,
], slots: { default: 'action' },
};
const accountTableColumns = computed(() =>
showActionColumn.value
? [...(accountTableBaseColumns ?? []), accountActionColumn]
: (accountTableBaseColumns ?? []),
);
// VbenVxeGrid 表格配置
const gridOptions: VxeGridProps<any> = {
columns: accountTableColumns.value,
height: 'auto', height: 'auto',
border: true, border: true,
stripe: true, stripe: true,
@@ -246,6 +267,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
tableTitle: '账户管理', tableTitle: '账户管理',
}); });
gridReloadRef.value = () => gridApi.reload(); gridReloadRef.value = () => gridApi.reload();
syncVxeGridColumns(gridApi, accountTableColumns);
// 计算属性 // 计算属性
const hasSelected = computed(() => { const hasSelected = computed(() => {
@@ -352,13 +374,17 @@ function handleModalSuccess() {
<!-- 工具栏工具 --> <!-- 工具栏工具 -->
<template #toolbar-tools> <template #toolbar-tools>
<Space> <Space>
<Button type="primary" @click="handleAdd"> <PermissionGate code="org:account:create">
<PlusIcon /> <Button type="primary" @click="handleAdd">
添加账户 <PlusIcon />
</Button> 添加账户
<Button v-if="hasSelected" danger @click="handleBatchDelete"> </Button>
批量删除 </PermissionGate>
</Button> <PermissionGate code="org:account:delete">
<Button v-if="hasSelected" danger @click="handleBatchDelete">
批量删除
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -377,15 +403,19 @@ function handleModalSuccess() {
</template> </template>
<!-- 操作列 --> <!-- 操作列 -->
<template #action="{ row }"> <template v-if="showActionColumn" #action="{ row }">
<Space> <Space>
<Button size="small" @click="handleEdit(row)"> 编辑 </Button> <PermissionGate code="org:account:update">
<Popconfirm <Button size="small" @click="handleEdit(row)"> 编辑 </Button>
title="确定要删除这个账户吗?" </PermissionGate>
@confirm="handleDelete(row)" <PermissionGate code="org:account:delete">
> <Popconfirm
<Button size="small" danger> 删除 </Button> title="确定要删除这个账户吗?"
</Popconfirm> @confirm="handleDelete(row)"
>
<Button size="small" danger> 删除 </Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -17,6 +17,11 @@ import {
} from '#/api/company'; } from '#/api/company';
import CompanyMenuDrawer from '#/components/CompanyMenuDrawer.vue'; import CompanyMenuDrawer from '#/components/CompanyMenuDrawer.vue';
import CompanyPermissionDrawer from '#/components/CompanyPermissionDrawer.vue'; import CompanyPermissionDrawer from '#/components/CompanyPermissionDrawer.vue';
import { PermissionGate } from '#/components/permission';
import {
syncVxeGridColumns,
useActionColumnVisible,
} from '#/composables/use-vxe-action-column';
import CompanyLogoAvatar from '#/views/company/components/CompanyLogoAvatar.vue'; import CompanyLogoAvatar from '#/views/company/components/CompanyLogoAvatar.vue';
import CompanyFormModal from './components/CompanyFormModal.vue'; import CompanyFormModal from './components/CompanyFormModal.vue';
@@ -46,9 +51,16 @@ const statusOptions = [
{ label: '正常', value: 1 }, { label: '正常', value: 1 },
]; ];
// VbenVxeGrid 表格配置 const companyActionCodes = [
const gridOptions: VxeGridProps<any> = { 'org:company:create',
columns: [ 'org:company:update',
'org:company:delete',
'org:company:menu:assign',
'org:company:permission:assign',
];
const showActionColumn = useActionColumnVisible(companyActionCodes);
const companyTableBaseColumns: VxeGridProps<any>['columns'] = [
{ {
type: 'seq' as const, type: 'seq' as const,
minWidth: 'auto', minWidth: 'auto',
@@ -108,13 +120,24 @@ const gridOptions: VxeGridProps<any> = {
title: '创建时间', title: '创建时间',
minWidth: 180, minWidth: 180,
}, },
{ ];
title: '操作',
minWidth: 200, const companyActionColumn: NonNullable<VxeGridProps<any>['columns']>[number] = {
fixed: 'right' as const, title: '操作',
slots: { default: 'action' }, minWidth: 200,
}, fixed: 'right' as const,
], slots: { default: 'action' },
};
const companyTableColumns = computed(() =>
showActionColumn.value
? [...(companyTableBaseColumns ?? []), companyActionColumn]
: (companyTableBaseColumns ?? []),
);
// VbenVxeGrid 表格配置
const gridOptions: VxeGridProps<any> = {
columns: companyTableColumns.value,
height: 'auto', height: 'auto',
border: true, border: true,
stripe: true, stripe: true,
@@ -320,6 +343,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
tableTitle: '公司管理', tableTitle: '公司管理',
}); });
gridReloadRef.value = () => gridApi.reload(); gridReloadRef.value = () => gridApi.reload();
syncVxeGridColumns(gridApi, companyTableColumns);
</script> </script>
<template> <template>
@@ -335,10 +359,12 @@ gridReloadRef.value = () => gridApi.reload();
<!-- 工具栏工具 --> <!-- 工具栏工具 -->
<template #toolbar-tools> <template #toolbar-tools>
<Space> <Space>
<Button type="primary" @click="handleAdd"> <PermissionGate code="org:company:create">
<PlusIcon /> <Button type="primary" @click="handleAdd">
添加公司 <PlusIcon />
</Button> 添加公司
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -372,26 +398,34 @@ gridReloadRef.value = () => gridApi.reload();
</template> </template>
<!-- 操作列 --> <!-- 操作列 -->
<template #action="{ row }: { row: any }"> <template v-if="showActionColumn" #action="{ row }: { row: any }">
<Space> <Space>
<Button size="small" @click="handleEdit(row)"> 编辑 </Button> <PermissionGate code="org:company:update">
<Button size="small" type="primary" @click="handleMenuManage(row)"> <Button size="small" @click="handleEdit(row)"> 编辑 </Button>
菜单 </PermissionGate>
</Button> <PermissionGate code="org:company:menu:assign">
<Button <Button size="small" type="primary" @click="handleMenuManage(row)">
size="small" 菜单
type="primary" </Button>
ghost </PermissionGate>
@click="handlePermissionManage(row)" <PermissionGate code="org:company:permission:assign">
> <Button
权限 size="small"
</Button> type="primary"
<Popconfirm ghost
title="确定要删除这个公司吗?" @click="handlePermissionManage(row)"
@confirm="handleDelete(row)" >
> 权限
<Button size="small" danger> 删除 </Button> </Button>
</Popconfirm> </PermissionGate>
<PermissionGate code="org:company:delete">
<Popconfirm
title="确定要删除这个公司吗?"
@confirm="handleDelete(row)"
>
<Button size="small" danger> 删除 </Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -18,6 +18,11 @@ import {
deleteDepartmentApi, deleteDepartmentApi,
getDepartmentPageApi, getDepartmentPageApi,
} from '#/api/org/department'; } from '#/api/org/department';
import { PermissionGate } from '#/components/permission';
import {
syncVxeGridColumns,
useActionColumnVisible,
} from '#/composables/use-vxe-action-column';
import DepartmentModal from './components/DepartmentModal.vue'; import DepartmentModal from './components/DepartmentModal.vue';
@@ -70,9 +75,14 @@ const parentDepartmentOptions = computed(() => {
return options; return options;
}); });
// VbenVxeGrid 表格配置 const departmentActionCodes = [
const gridOptions: VxeGridProps<any> = { 'org:department:create',
columns: [ 'org:department:update',
'org:department:delete',
];
const showActionColumn = useActionColumnVisible(departmentActionCodes);
const departmentTableBaseColumns: VxeGridProps<any>['columns'] = [
{ {
type: 'seq' as const, type: 'seq' as const,
minWidth: 'auto', minWidth: 'auto',
@@ -105,13 +115,26 @@ const gridOptions: VxeGridProps<any> = {
title: '创建时间', title: '创建时间',
minWidth: 180, minWidth: 180,
}, },
{ ];
title: '操作',
minWidth: 200, const departmentActionColumn: NonNullable<
fixed: 'right' as const, VxeGridProps<any>['columns']
slots: { default: 'action' }, >[number] = {
}, title: '操作',
], minWidth: 200,
fixed: 'right' as const,
slots: { default: 'action' },
};
const departmentTableColumns = computed(() =>
showActionColumn.value
? [...(departmentTableBaseColumns ?? []), departmentActionColumn]
: (departmentTableBaseColumns ?? []),
);
// VbenVxeGrid 表格配置
const gridOptions: VxeGridProps<any> = {
columns: departmentTableColumns.value,
height: 'auto', height: 'auto',
border: true, border: true,
stripe: true, stripe: true,
@@ -285,6 +308,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
tableTitle: '部门管理', tableTitle: '部门管理',
}); });
gridReloadRef.value = () => gridApi.reload(); gridReloadRef.value = () => gridApi.reload();
syncVxeGridColumns(gridApi, departmentTableColumns);
</script> </script>
<template> <template>
@@ -300,10 +324,12 @@ gridReloadRef.value = () => gridApi.reload();
<!-- 工具栏工具 --> <!-- 工具栏工具 -->
<template #toolbar-tools> <template #toolbar-tools>
<Space> <Space>
<Button type="primary" @click="handleAdd"> <PermissionGate code="org:department:create">
<PlusIcon /> <Button type="primary" @click="handleAdd">
添加部门 <PlusIcon />
</Button> 添加部门
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -325,15 +351,19 @@ gridReloadRef.value = () => gridApi.reload();
</template> </template>
<!-- 操作列 --> <!-- 操作列 -->
<template #action="{ row }: { row: any }"> <template v-if="showActionColumn" #action="{ row }: { row: any }">
<Space> <Space>
<Button size="small" @click="handleEdit(row)"> 编辑 </Button> <PermissionGate code="org:department:update">
<Popconfirm <Button size="small" @click="handleEdit(row)"> 编辑 </Button>
title="确定要删除这个部门吗?" </PermissionGate>
@confirm="handleDelete(row)" <PermissionGate code="org:department:delete">
> <Popconfirm
<Button size="small" danger> 删除 </Button> title="确定要删除这个部门吗?"
</Popconfirm> @confirm="handleDelete(row)"
>
<Button size="small" danger> 删除 </Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -15,6 +15,11 @@ import {
deletePositionApi, deletePositionApi,
getPositionPageApi, getPositionPageApi,
} from '#/api/org/position'; } from '#/api/org/position';
import { PermissionGate } from '#/components/permission';
import {
syncVxeGridColumns,
useActionColumnVisible,
} from '#/composables/use-vxe-action-column';
import PositionModal from './components/PositionModal.vue'; import PositionModal from './components/PositionModal.vue';
@@ -47,9 +52,14 @@ const departmentOptions = ref([
{ label: '市场部', value: 4 }, { label: '市场部', value: 4 },
]); ]);
// VbenVxeGrid 表格配置 const positionActionCodes = [
const gridOptions: VxeGridProps<any> = { 'org:position:create',
columns: [ 'org:position:update',
'org:position:delete',
];
const showActionColumn = useActionColumnVisible(positionActionCodes);
const positionTableBaseColumns: VxeGridProps<any>['columns'] = [
{ {
type: 'seq' as const, type: 'seq' as const,
minWidth: 'auto', minWidth: 'auto',
@@ -87,13 +97,25 @@ const gridOptions: VxeGridProps<any> = {
title: '创建时间', title: '创建时间',
minWidth: 180, minWidth: 180,
}, },
{ ];
title: '操作',
minWidth: 200, const positionActionColumn: NonNullable<VxeGridProps<any>['columns']>[number] =
fixed: 'right' as const, {
slots: { default: 'action' }, title: '操作',
}, minWidth: 200,
], fixed: 'right' as const,
slots: { default: 'action' },
};
const positionTableColumns = computed(() =>
showActionColumn.value
? [...(positionTableBaseColumns ?? []), positionActionColumn]
: (positionTableBaseColumns ?? []),
);
// VbenVxeGrid 表格配置
const gridOptions: VxeGridProps<any> = {
columns: positionTableColumns.value,
height: 'auto', height: 'auto',
border: true, border: true,
stripe: true, stripe: true,
@@ -231,6 +253,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
showSearchForm: true, showSearchForm: true,
tableTitle: '职位管理', tableTitle: '职位管理',
}); });
syncVxeGridColumns(gridApi, positionTableColumns);
</script> </script>
<template> <template>
@@ -246,10 +269,12 @@ const [Grid, gridApi] = useVbenVxeGrid({
<!-- 工具栏工具 --> <!-- 工具栏工具 -->
<template #toolbar-tools> <template #toolbar-tools>
<Space> <Space>
<Button type="primary" @click="handleAdd"> <PermissionGate code="org:position:create">
<PlusIcon /> <Button type="primary" @click="handleAdd">
添加职位 <PlusIcon />
</Button> 添加职位
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -272,15 +297,19 @@ const [Grid, gridApi] = useVbenVxeGrid({
</template> </template>
<!-- 操作列 --> <!-- 操作列 -->
<template #action="{ row }: { row: any }"> <template v-if="showActionColumn" #action="{ row }: { row: any }">
<Space> <Space>
<Button size="small" @click="handleEdit(row)"> 编辑 </Button> <PermissionGate code="org:position:update">
<Popconfirm <Button size="small" @click="handleEdit(row)"> 编辑 </Button>
title="确定要删除这个职位吗?" </PermissionGate>
@confirm="handleDelete(row)" <PermissionGate code="org:position:delete">
> <Popconfirm
<Button size="small" danger> 删除 </Button> title="确定要删除这个职位吗?"
</Popconfirm> @confirm="handleDelete(row)"
>
<Button size="small" danger> 删除 </Button>
</Popconfirm>
</PermissionGate>
</Space> </Space>
</template> </template>
</Grid> </Grid>
@@ -27,6 +27,8 @@ import {
batchUpdatePositionMenusApi, batchUpdatePositionMenusApi,
getPositionMenuIdsApi, getPositionMenuIdsApi,
} from '#/api/org/position/menu'; } from '#/api/org/position/menu';
import { PermissionGate } from '#/components/permission';
import { usePermission } from '#/composables/use-permission';
defineOptions({ defineOptions({
name: 'PositionMenuManagePage', name: 'PositionMenuManagePage',
@@ -34,6 +36,9 @@ defineOptions({
const BriefcaseIcon = createIconifyIcon('lucide:briefcase'); const BriefcaseIcon = createIconifyIcon('lucide:briefcase');
const { hasPermission } = usePermission();
const canAssignMenu = computed(() => hasPermission('org:position:menu:assign'));
const searchForm = ref({ const searchForm = ref({
name: '', name: '',
status: undefined as number | undefined, status: undefined as number | undefined,
@@ -306,23 +311,25 @@ onMounted(() => {
<template #extra> <template #extra>
<Space> <Space>
<Button :disabled="!currentPosition" @click="handleSelectNone"> <PermissionGate code="org:position:menu:assign">
取消全选 <Button :disabled="!currentPosition" @click="handleSelectNone">
</Button> 取消全选
<Button </Button>
type="primary" <Button
:disabled="!currentPosition" type="primary"
@click="handleSelectAll" :disabled="!currentPosition"
> @click="handleSelectAll"
一键全选 >
</Button> 一键全选
<Button </Button>
type="primary" <Button
:disabled="!currentPosition || !stats.changed" type="primary"
@click="savePositionPermissions" :disabled="!currentPosition || !stats.changed"
> @click="savePositionPermissions"
保存配置 >
</Button> 保存配置
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -511,7 +518,7 @@ onMounted(() => {
v-model:checked-keys="checkedKeys" v-model:checked-keys="checkedKeys"
v-model:expanded-keys="expandedKeys" v-model:expanded-keys="expandedKeys"
:tree-data="menuTreeData" :tree-data="menuTreeData"
checkable :checkable="canAssignMenu"
block-node block-node
:selectable="false" :selectable="false"
@check="handleTreeCheckChange" @check="handleTreeCheckChange"
@@ -27,11 +27,18 @@ import {
getPositionAssignablePermissionTreeApi, getPositionAssignablePermissionTreeApi,
getPositionPermissionIdsApi, getPositionPermissionIdsApi,
} from '#/api/org/position/permission'; } from '#/api/org/position/permission';
import { PermissionGate } from '#/components/permission';
import { usePermission } from '#/composables/use-permission';
defineOptions({ name: 'PositionPermissionManagePage' }); defineOptions({ name: 'PositionPermissionManagePage' });
const BriefcaseIcon = createIconifyIcon('lucide:briefcase'); const BriefcaseIcon = createIconifyIcon('lucide:briefcase');
const { hasPermission } = usePermission();
const canAssignPermission = computed(() =>
hasPermission('org:position:permission:assign'),
);
type PermissionTreeNode = { type PermissionTreeNode = {
key: number; key: number;
title: string; title: string;
@@ -260,17 +267,19 @@ onMounted(() => {
<template #extra> <template #extra>
<Space> <Space>
<Button :disabled="!currentPosition" @click="selectNone">取消全选</Button> <PermissionGate code="org:position:permission:assign">
<Button type="primary" :disabled="!currentPosition" @click="selectAll"> <Button :disabled="!currentPosition" @click="selectNone">取消全选</Button>
一键全选 <Button type="primary" :disabled="!currentPosition" @click="selectAll">
</Button> 一键全选
<Button </Button>
type="primary" <Button
:disabled="!currentPosition || !stats.changed" type="primary"
@click="handleSave" :disabled="!currentPosition || !stats.changed"
> @click="handleSave"
保存配置 >
</Button> 保存配置
</Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -450,7 +459,7 @@ onMounted(() => {
v-model:checked-keys="selectedPermissionIds" v-model:checked-keys="selectedPermissionIds"
v-model:expanded-keys="expandedKeys" v-model:expanded-keys="expandedKeys"
:tree-data="permissionTreeData" :tree-data="permissionTreeData"
checkable :checkable="canAssignPermission"
block-node block-node
:selectable="false" :selectable="false"
@check="handleTreeCheckChange" @check="handleTreeCheckChange"
@@ -37,6 +37,7 @@ import {
getOrderStatRebuildStatusApi, getOrderStatRebuildStatusApi,
reconcileOrderStatApi, reconcileOrderStatApi,
} from '#/api/sys/order-stat'; } from '#/api/sys/order-stat';
import { PermissionGate } from '#/components/permission';
import { import {
SIDEBAR_LIST_SHELL_CLASS, SIDEBAR_LIST_SHELL_CLASS,
sidebarListRowClass, sidebarListRowClass,
@@ -505,14 +506,16 @@ onMounted(() => {
/> />
</Form.Item> </Form.Item>
<Space> <Space>
<Button <PermissionGate code="bi:order-stat:calc:create">
type="primary" <Button
:loading="rebuildSubmitting" type="primary"
@click="handleCreateRebuild" :loading="rebuildSubmitting"
> @click="handleCreateRebuild"
<template #icon><PlayIcon /></template> >
创建灌数任务 <template #icon><PlayIcon /></template>
</Button> 创建灌数任务
</Button>
</PermissionGate>
</Space> </Space>
<div v-if="lastTaskId" class="mt-2 text-sm text-muted-foreground"> <div v-if="lastTaskId" class="mt-2 text-sm text-muted-foreground">
最近任务 ID:<Tag color="blue">{{ lastTaskId }}</Tag> 最近任务 ID:<Tag color="blue">{{ lastTaskId }}</Tag>
@@ -526,10 +529,12 @@ onMounted(() => {
placeholder="任务 ID" placeholder="任务 ID"
style="width: 160px" style="width: 160px"
/> />
<Button :loading="pollLoading" @click="fetchRebuildStatus()"> <PermissionGate code="bi:order-stat:calc:read">
<template #icon><RefreshIcon /></template> <Button :loading="pollLoading" @click="fetchRebuildStatus()">
查询 <template #icon><RefreshIcon /></template>
</Button> 查询
</Button>
</PermissionGate>
<span class="text-sm text-muted-foreground"> <span class="text-sm text-muted-foreground">
自动刷新(3s) 自动刷新(3s)
<Switch v-model:checked="autoPoll" class="ml-2" size="small" /> <Switch v-model:checked="autoPoll" class="ml-2" size="small" />
@@ -596,14 +601,16 @@ onMounted(() => {
class="w-full" class="w-full"
/> />
</Form.Item> </Form.Item>
<Button <PermissionGate code="bi:order-stat:calc:read">
type="primary" <Button
:loading="reconcileLoading" type="primary"
@click="handleReconcile" :loading="reconcileLoading"
> @click="handleReconcile"
<template #icon><SearchIcon /></template> >
执行对账 <template #icon><SearchIcon /></template>
</Button> 执行对账
</Button>
</PermissionGate>
</Form> </Form>
<div v-if="reconcileReport" class="mt-4"> <div v-if="reconcileReport" class="mt-4">