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>
<PermissionGate code="org:company:menu:assign">
<Button type="primary" @click="handleSelectAll"> 一键全选 </Button> <Button type="primary" @click="handleSelectAll"> 一键全选 </Button>
<Button @click="handleSelectNone"> 取消全选 </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">
<PermissionGate code="org:company:permission:assign">
<Button @click="selectNone">取消全选</Button> <Button @click="selectNone">取消全选</Button>
<Button type="primary" @click="selectAll">一键全选</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,6 +80,7 @@ const cellRoi = (v: number | null | undefined) =>
{{ props.headingSubtitle }} {{ props.headingSubtitle }}
</p> </p>
</div> </div>
<PermissionGate code="data:export">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<template v-if="categoryExportMode"> <template v-if="categoryExportMode">
<button <button
@@ -110,6 +112,7 @@ const cellRoi = (v: number | null | undefined) =>
</button> </button>
</template> </template>
</div> </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,6 +124,7 @@ const sortedData = computed(() => {
{{ props.headingSubtitle }} {{ props.headingSubtitle }}
</p> </p>
</div> </div>
<PermissionGate code="data:export">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<template v-if="platformExportMode"> <template v-if="platformExportMode">
<button <button
@@ -154,6 +156,7 @@ const sortedData = computed(() => {
</button> </button>
</template> </template>
</div> </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,6 +72,7 @@ const cellRoi = (v: number | null | undefined) =>
{{ props.headingSubtitle }} {{ props.headingSubtitle }}
</p> </p>
</div> </div>
<PermissionGate code="data:export">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<template v-if="shopExportMode"> <template v-if="shopExportMode">
<button <button
@@ -102,6 +104,7 @@ const cellRoi = (v: number | null | undefined) =>
</button> </button>
</template> </template>
</div> </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>
<PermissionGate code="channel:pdd:goods:delete">
<Popconfirm <Popconfirm
title="确定删除该商品及全部 SKU 吗?" title="确定删除该商品及全部 SKU 吗?"
@confirm="handleDelete(row)" @confirm="handleDelete(row)"
> >
<Button type="link" size="small" danger>删除</Button> <Button type="link" size="small" danger>删除</Button>
</Popconfirm> </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,6 +309,7 @@ async function handleSyncGoods(row: PddShopVO.Info) {
<Button type="link" size="small" @click="openShopDetail(row)"> <Button type="link" size="small" @click="openShopDetail(row)">
详情 详情
</Button> </Button>
<PermissionGate code="channel:pdd:goods:sync">
<Button <Button
type="link" type="link"
size="small" size="small"
@@ -317,6 +319,7 @@ async function handleSyncGoods(row: PddShopVO.Info) {
> >
同步商品 同步商品
</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,6 +201,7 @@ 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>
<PermissionGate code="org:company:menu:assign">
<Button :disabled="!currentCompany" @click="selectNone">取消全选</Button> <Button :disabled="!currentCompany" @click="selectNone">取消全选</Button>
<Button type="primary" :disabled="!currentCompany" @click="selectAll"> <Button type="primary" :disabled="!currentCompany" @click="selectAll">
一键全选 一键全选
@@ -207,6 +213,7 @@ async function 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,6 +222,7 @@ 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>
<PermissionGate code="org:company:permission:assign">
<Button :disabled="!currentCompany" @click="selectNone">取消全选</Button> <Button :disabled="!currentCompany" @click="selectNone">取消全选</Button>
<Button type="primary" :disabled="!currentCompany" @click="selectAll"> <Button type="primary" :disabled="!currentCompany" @click="selectAll">
一键全选 一键全选
@@ -226,6 +234,7 @@ onMounted(() => {
> >
保存配置 保存配置
</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>
<PermissionGate code="data:import-mapping:create">
<Button type="primary" @click="handleAdd"> <Button type="primary" @click="handleAdd">
<PlusIcon /> <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>
<PermissionGate code="data:import-mapping:update">
<Button size="small" @click="handleEdit(row)">编辑</Button> <Button size="small" @click="handleEdit(row)">编辑</Button>
</PermissionGate>
<PermissionGate code="data:import-mapping:delete">
<Popconfirm title="确定删除该模板?" @confirm="handleDelete(row)"> <Popconfirm title="确定删除该模板?" @confirm="handleDelete(row)">
<Button size="small" danger>删除</Button> <Button size="small" danger>删除</Button>
</Popconfirm> </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>
<PermissionGate code="data:import-mapping:create">
<Button type="primary" @click="handleAdd"> <Button type="primary" @click="handleAdd">
<PlusIcon /> <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>
<PermissionGate code="data:import-mapping:update">
<Button size="small" @click="handleEdit(row)">编辑</Button> <Button size="small" @click="handleEdit(row)">编辑</Button>
</PermissionGate>
<PermissionGate code="data:import-mapping:delete">
<Popconfirm title="确定删除该模板?" @confirm="handleDelete(row)"> <Popconfirm title="确定删除该模板?" @confirm="handleDelete(row)">
<Button size="small" danger>删除</Button> <Button size="small" danger>删除</Button>
</Popconfirm> </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
:disabled="selectedTemplateId !== undefined"
@click="handleSaveTemplate"
>
保存为模板 保存为模板
</Button> </Button>
</PermissionGate>
</div> </div>
</div> </div>
<template v-if="fieldDefsLoading"> <template v-if="fieldDefsLoading">
@@ -803,6 +809,7 @@ const shopOptions = computed(() => {
> >
下一步 下一步
</Button> </Button>
<PermissionGate code="data:import:create">
<Button <Button
v-if="currentStep === 1" v-if="currentStep === 1"
type="primary" type="primary"
@@ -811,6 +818,7 @@ const shopOptions = computed(() => {
> >
创建导入任务 创建导入任务
</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>
<PermissionGate code="data:import-mapping:create">
<Button <Button
:disabled="selectedTemplateId !== undefined" :disabled="selectedTemplateId !== undefined"
@click="handleSaveTemplate" @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>
<PermissionGate code="data:import-mapping:create">
<Button <Button
:disabled="selectedStatusTemplateId !== undefined" :disabled="selectedStatusTemplateId !== undefined"
@click="handleSaveStatusTemplate" @click="handleSaveStatusTemplate"
> >
保存为模板 保存为模板
</Button> </Button>
</PermissionGate>
</div> </div>
</div> </div>
<div <div
@@ -1862,6 +1867,7 @@ const shopOptions = computed(() => {
> >
下一步 下一步
</Button> </Button>
<PermissionGate code="data:import:create">
<Button <Button
v-if="currentStep === 2" v-if="currentStep === 2"
type="primary" type="primary"
@@ -1870,6 +1876,7 @@ const shopOptions = computed(() => {
> >
创建导入任务 创建导入任务
</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,18 +243,8 @@ async function fetchPlatformOptions() {
} }
} }
const gridOptions: VxeGridProps<OrderVO.Info> = { const orderTableBaseColumns: VxeGridProps<OrderVO.Info>['columns'] = [
checkboxConfig: {
highlight: true,
reserve: false,
},
columns: [
{ type: 'seq' as const, width: 56, title: '序号' }, { type: 'seq' as const, width: 56, title: '序号' },
{
type: 'checkbox' as const,
width: 48,
fixed: 'left' as const,
},
{ {
field: 'platformOrderNo', field: 'platformOrderNo',
title: '平台订单号', title: '平台订单号',
@@ -316,7 +313,30 @@ const gridOptions: VxeGridProps<OrderVO.Info> = {
fixed: 'right' as const, fixed: 'right' as const,
slots: { default: 'action' }, 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> = {
checkboxConfig: {
highlight: true,
reserve: false,
},
columns: orderTableColumns.value,
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,10 +685,13 @@ onMounted(async () => {
<template #extra> <template #extra>
<Space wrap size="small"> <Space wrap size="small">
<PermissionGate code="ec:order:create">
<Button type="primary" @click="handleAdd"> <Button type="primary" @click="handleAdd">
<PlusIcon class="mr-1 h-4 w-4" /> <PlusIcon class="mr-1 h-4 w-4" />
添加订单 添加订单
</Button> </Button>
</PermissionGate>
<PermissionGate code="ec:order:delete">
<Popconfirm <Popconfirm
title="确定删除选中的订单吗?删除后不可恢复。" title="确定删除选中的订单吗?删除后不可恢复。"
ok-text="确定删除" ok-text="确定删除"
@@ -684,6 +708,7 @@ onMounted(async () => {
批量删除 批量删除
</Button> </Button>
</Popconfirm> </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>
<PermissionGate code="ec:order:update">
<Button type="link" size="small" @click="handleEdit(row)"> <Button type="link" size="small" @click="handleEdit(row)">
编辑 编辑
</Button> </Button>
</PermissionGate>
<PermissionGate code="ec:order:delete">
<Popconfirm <Popconfirm
title="确定要删除这个订单吗?" title="确定要删除这个订单吗?"
@confirm="handleDelete(row)" @confirm="handleDelete(row)"
> >
<Button type="link" size="small" danger>删除</Button> <Button type="link" size="small" danger>删除</Button>
</Popconfirm> </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,
}, },
];
const categoryActionColumn: NonNullable<VxeGridProps<any>['columns']>[number] =
{ {
title: '操作', title: '操作',
width: 160, width: 160,
fixed: 'right' as const, fixed: 'right' as const,
slots: { default: 'action' }, 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>
<PermissionGate code="ec:product:category:create">
<Button type="primary" @click="handleAdd"> <Button type="primary" @click="handleAdd">
<PlusIcon /> <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>
<PermissionGate code="ec:product:category:update">
<Button size="small" @click="handleEdit(row)">编辑</Button> <Button size="small" @click="handleEdit(row)">编辑</Button>
</PermissionGate>
<PermissionGate code="ec:product:category:delete">
<Popconfirm <Popconfirm
title="确定要删除这个类目吗?" title="确定要删除这个类目吗?"
@confirm="handleDelete(row)" @confirm="handleDelete(row)"
> >
<Button size="small" danger>删除</Button> <Button size="small" danger>删除</Button>
</Popconfirm> </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>
<PermissionGate code="ec:product:create">
<Button type="primary" @click="handleAdd"> <Button type="primary" @click="handleAdd">
<PlusIcon class="mr-1 h-4 w-4" /> <PlusIcon class="mr-1 h-4 w-4" />
添加商品 添加商品
</Button> </Button>
</PermissionGate>
</template> </template>
<!-- 商品信息:主图 + 名称,点击打开详情 --> <!-- 商品信息:主图 + 名称,点击打开详情 -->
@@ -398,6 +401,7 @@ function handleDetailEdit(record: ProductVO.Info) {
<Button type="link" size="small" @click="openProductDetail(row)"> <Button type="link" size="small" @click="openProductDetail(row)">
详情 详情
</Button> </Button>
<PermissionGate code="ec:product:update">
<Button type="link" size="small" @click="handleEdit(row)"> <Button type="link" size="small" @click="handleEdit(row)">
<EditIcon class="mr-0.5 h-3.5 w-3.5" /> <EditIcon class="mr-0.5 h-3.5 w-3.5" />
编辑 编辑
@@ -406,10 +410,12 @@ function handleDetailEdit(record: ProductVO.Info) {
<CoinsIcon class="mr-0.5 h-3.5 w-3.5" /> <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>
<PermissionGate code="ec:product:delete">
<Popconfirm <Popconfirm
title="确定删除该商品吗?删除后不可恢复。" title="确定删除该商品吗?删除后不可恢复。"
ok-text="确定删除" ok-text="确定删除"
@@ -418,6 +424,7 @@ function handleDetailEdit(record: ProductVO.Info) {
> >
<Button type="link" size="small" danger>删除</Button> <Button type="link" size="small" danger>删除</Button>
</Popconfirm> </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 },
{ ];
const adFeeActionColumn: NonNullable<
VxeGridProps<AdFeeVO.Info>['columns']
>[number] = {
title: '操作', title: '操作',
minWidth: 140, minWidth: 140,
fixed: 'right' as const, fixed: 'right' as const,
slots: { default: 'action' }, 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()"
/> />
<PermissionGate code="ec:order:create">
<Button type="primary" @click="handleAdd"> <Button type="primary" @click="handleAdd">
<PlusIcon class="mr-1 h-4 w-4" /> <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>
<PermissionGate code="ec:order:update">
<Button size="small" @click="handleEdit(row)">编辑</Button> <Button size="small" @click="handleEdit(row)">编辑</Button>
</PermissionGate>
<PermissionGate code="ec:order:delete">
<Popconfirm <Popconfirm
title="确定要删除这条广告费记录吗?" title="确定要删除这条广告费记录吗?"
@confirm="handleDelete(row.id)" @confirm="handleDelete(row.id)"
> >
<Button size="small" danger>删除</Button> <Button size="small" danger>删除</Button>
</Popconfirm> </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,
}, },
{ ];
const brushOrderActionColumn: NonNullable<
VxeGridProps<BrushOrderVO.Info>['columns']
>[number] = {
title: '操作', title: '操作',
width: 140, width: 140,
fixed: 'right' as const, fixed: 'right' as const,
slots: { default: 'action' }, 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>
<PermissionGate code="ec:order:create">
<Button type="primary" @click="handleAdd"> <Button type="primary" @click="handleAdd">
<PlusIcon class="mr-1 h-4 w-4" /> <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>
<PermissionGate code="ec:order:update">
<Button size="small" @click="handleEdit(row)">编辑</Button> <Button size="small" @click="handleEdit(row)">编辑</Button>
</PermissionGate>
<PermissionGate code="ec:order:delete">
<Popconfirm <Popconfirm
title="确定要删除这条刷单记录吗?" title="确定要删除这条刷单记录吗?"
@confirm="handleDelete(row.id)" @confirm="handleDelete(row.id)"
> >
<Button size="small" danger>删除</Button> <Button size="small" danger>删除</Button>
</Popconfirm> </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,8 +116,7 @@ function toShopListRows(records: ShopVO.Info[]): ShopListRow[] {
return rows; return rows;
} }
const gridOptions: VxeGridProps<ShopListRow> = { const shopTableBaseColumns: VxeGridProps<ShopListRow>['columns'] = [
columns: [
{ {
width: 64, width: 64,
title: '序号', title: '序号',
@@ -152,13 +164,25 @@ const gridOptions: VxeGridProps<ShopListRow> = {
minWidth: 'auto', minWidth: 'auto',
slots: { default: 'updateTime' }, slots: { default: 'updateTime' },
}, },
{ ];
const shopActionColumn: NonNullable<
VxeGridProps<ShopListRow>['columns']
>[number] = {
title: '操作', title: '操作',
minWidth: 320, minWidth: 320,
showOverflow: false, showOverflow: false,
slots: { default: 'action' }, slots: { default: 'action' },
}, };
],
const shopTableColumns = computed(() =>
showActionColumn.value
? [...(shopTableBaseColumns ?? []), shopActionColumn]
: (shopTableBaseColumns ?? []),
);
const gridOptions: VxeGridProps<ShopListRow> = {
columns: shopTableColumns.value,
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>
<PermissionGate code="ec:shop:create">
<Button type="primary" @click="handleAdd"> <Button type="primary" @click="handleAdd">
<PlusIcon /> <PlusIcon />
添加店铺 添加店铺
</Button> </Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -820,8 +847,9 @@ 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)">
<PermissionGate code="channel:pdd:shop:update">
<Button <Button
v-if="isPddShop(row)" v-if="isPddShop(row)"
size="small" size="small"
@@ -832,13 +860,18 @@ onUnmounted(() => {
> >
{{ hasExternalShop(row) ? '重新授权' : '授权拼多多' }} {{ hasExternalShop(row) ? '重新授权' : '授权拼多多' }}
</Button> </Button>
</PermissionGate>
<PermissionGate code="ec:shop:update">
<Button size="small" @click="handleEdit(row)">编辑</Button> <Button size="small" @click="handleEdit(row)">编辑</Button>
</PermissionGate>
<PermissionGate code="ec:shop:delete">
<Popconfirm <Popconfirm
title="确定要删除这个店铺吗?" title="确定要删除这个店铺吗?"
@confirm="handleDelete(row)" @confirm="handleDelete(row)"
> >
<Button size="small" danger>删除</Button> <Button size="small" danger>删除</Button>
</Popconfirm> </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 },
{ ];
const monthlyTargetActionColumn: NonNullable<
VxeGridProps<ShopMonthlyTargetVO.Info>['columns']
>[number] = {
title: '操作', title: '操作',
minWidth: 140, minWidth: 140,
fixed: 'right' as const, fixed: 'right' as const,
slots: { default: 'action' }, 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()"
/> />
<PermissionGate code="ec:shop:create">
<Button type="primary" @click="handleAdd"> <Button type="primary" @click="handleAdd">
<PlusIcon class="mr-1 h-4 w-4" /> <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>
<PermissionGate code="ec:shop:update">
<Button size="small" @click="handleEdit(row)">编辑</Button> <Button size="small" @click="handleEdit(row)">编辑</Button>
</PermissionGate>
<PermissionGate code="ec:shop:delete">
<Popconfirm <Popconfirm
title="确定要删除这条月销量目标吗?" title="确定要删除这条月销量目标吗?"
@confirm="handleDelete(row.id)" @confirm="handleDelete(row.id)"
> >
<Button size="small" danger>删除</Button> <Button size="small" danger>删除</Button>
</Popconfirm> </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 },
{ ];
const apiKeyActionColumn: NonNullable<
VxeGridProps<OpenApiKeyVO.OpenApiKeyInfoVO>['columns']
>[number] = {
title: '操作', title: '操作',
width: 200, width: 200,
fixed: 'right', fixed: 'right',
slots: { default: 'action' }, 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>
<PermissionGate code="open:api-key:create">
<Button type="primary" @click="openCreateModal"> <Button type="primary" @click="openCreateModal">
<PlusIcon class="size-4" /> <PlusIcon class="size-4" />
创建 API Key 创建 API Key
</Button> </Button>
</PermissionGate>
</template> </template>
<template #permissions="{ row }"> <template #permissions="{ row }">
@@ -156,8 +183,9 @@ function getPermissionTooltip(row: OpenApiKeyVO.OpenApiKeyInfoVO) {
</Tag> </Tag>
</template> </template>
<template #action="{ row }"> <template v-if="showActionColumn" #action="{ row }">
<Space> <Space>
<PermissionGate code="open:api-key:update">
<Popconfirm <Popconfirm
v-if="row.status === 1" v-if="row.status === 1"
title="确认停用该 API Key?" title="确认停用该 API Key?"
@@ -172,9 +200,12 @@ function getPermissionTooltip(row: OpenApiKeyVO.OpenApiKeyInfoVO) {
> >
<Button type="link" size="small">启用</Button> <Button type="link" size="small">启用</Button>
</Popconfirm> </Popconfirm>
</PermissionGate>
<PermissionGate code="open:api-key:delete">
<Popconfirm title="确认删除该 API Key?" @confirm="handleDelete(row)"> <Popconfirm title="确认删除该 API Key?" @confirm="handleDelete(row)">
<Button type="link" danger size="small">删除</Button> <Button type="link" danger size="small">删除</Button>
</Popconfirm> </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,
}, },
{ ];
const accountActionColumn: NonNullable<
VxeGridProps<SuperAccountVO.AccountInfoVO>['columns']
>[number] = {
title: '操作', title: '操作',
minWidth: 140, minWidth: 140,
fixed: 'right' as const, fixed: 'right' as const,
slots: { default: 'action' }, 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>
<PermissionGate code="org:account:create">
<Button type="primary" @click="handleAdd"> <Button type="primary" @click="handleAdd">
<PlusIcon class="mr-2 h-4 w-4" /> <PlusIcon class="mr-2 h-4 w-4" />
新增账户 新增账户
</Button> </Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -431,6 +458,7 @@ onMounted(() => {
{{ company.status === 1 ? '启用' : '禁用' }} {{ company.status === 1 ? '启用' : '禁用' }}
</span> </span>
</button> </button>
<PermissionGate code="org:account:create">
<Button <Button
type="link" type="link"
size="small" size="small"
@@ -440,6 +468,7 @@ onMounted(() => {
<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>
<PermissionGate code="org:account:update">
<Button size="small" @click="handleEdit(row)">编辑</Button> <Button size="small" @click="handleEdit(row)">编辑</Button>
</PermissionGate>
<PermissionGate code="org:account:delete">
<Popconfirm <Popconfirm
title="确定要删除这个账户吗?" title="确定要删除这个账户吗?"
@confirm="handleDelete(row)" @confirm="handleDelete(row)"
> >
<Button size="small" danger>删除</Button> <Button size="small" danger>删除</Button>
</Popconfirm> </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,
}, },
{ ];
const accountActionColumn: NonNullable<VxeGridProps<any>['columns']>[number] = {
title: '操作', title: '操作',
width: 120, width: 120,
fixed: 'right' as const, fixed: 'right' as const,
slots: { default: 'action' }, 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>
<PermissionGate code="org:account:create">
<Button type="primary" @click="handleAdd"> <Button type="primary" @click="handleAdd">
<PlusIcon /> <PlusIcon />
添加账户 添加账户
</Button> </Button>
</PermissionGate>
<PermissionGate code="org:account:delete">
<Button v-if="hasSelected" danger @click="handleBatchDelete"> <Button v-if="hasSelected" danger @click="handleBatchDelete">
批量删除 批量删除
</Button> </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>
<PermissionGate code="org:account:update">
<Button size="small" @click="handleEdit(row)"> 编辑 </Button> <Button size="small" @click="handleEdit(row)"> 编辑 </Button>
</PermissionGate>
<PermissionGate code="org:account:delete">
<Popconfirm <Popconfirm
title="确定要删除这个账户吗?" title="确定要删除这个账户吗?"
@confirm="handleDelete(row)" @confirm="handleDelete(row)"
> >
<Button size="small" danger> 删除 </Button> <Button size="small" danger> 删除 </Button>
</Popconfirm> </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,
}, },
{ ];
const companyActionColumn: NonNullable<VxeGridProps<any>['columns']>[number] = {
title: '操作', title: '操作',
minWidth: 200, minWidth: 200,
fixed: 'right' as const, fixed: 'right' as const,
slots: { default: 'action' }, 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>
<PermissionGate code="org:company:create">
<Button type="primary" @click="handleAdd"> <Button type="primary" @click="handleAdd">
<PlusIcon /> <PlusIcon />
添加公司 添加公司
</Button> </Button>
</PermissionGate>
</Space> </Space>
</template> </template>
@@ -372,12 +398,17 @@ gridReloadRef.value = () => gridApi.reload();
</template> </template>
<!-- 操作列 --> <!-- 操作列 -->
<template #action="{ row }: { row: any }"> <template v-if="showActionColumn" #action="{ row }: { row: any }">
<Space> <Space>
<PermissionGate code="org:company:update">
<Button size="small" @click="handleEdit(row)"> 编辑 </Button> <Button size="small" @click="handleEdit(row)"> 编辑 </Button>
</PermissionGate>
<PermissionGate code="org:company:menu:assign">
<Button size="small" type="primary" @click="handleMenuManage(row)"> <Button size="small" type="primary" @click="handleMenuManage(row)">
菜单 菜单
</Button> </Button>
</PermissionGate>
<PermissionGate code="org:company:permission:assign">
<Button <Button
size="small" size="small"
type="primary" type="primary"
@@ -386,12 +417,15 @@ gridReloadRef.value = () => gridApi.reload();
> >
权限 权限
</Button> </Button>
</PermissionGate>
<PermissionGate code="org:company:delete">
<Popconfirm <Popconfirm
title="确定要删除这个公司吗?" title="确定要删除这个公司吗?"
@confirm="handleDelete(row)" @confirm="handleDelete(row)"
> >
<Button size="small" danger> 删除 </Button> <Button size="small" danger> 删除 </Button>
</Popconfirm> </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,
}, },
{ ];
const departmentActionColumn: NonNullable<
VxeGridProps<any>['columns']
>[number] = {
title: '操作', title: '操作',
minWidth: 200, minWidth: 200,
fixed: 'right' as const, fixed: 'right' as const,
slots: { default: 'action' }, 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>
<PermissionGate code="org:department:create">
<Button type="primary" @click="handleAdd"> <Button type="primary" @click="handleAdd">
<PlusIcon /> <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>
<PermissionGate code="org:department:update">
<Button size="small" @click="handleEdit(row)"> 编辑 </Button> <Button size="small" @click="handleEdit(row)"> 编辑 </Button>
</PermissionGate>
<PermissionGate code="org:department:delete">
<Popconfirm <Popconfirm
title="确定要删除这个部门吗?" title="确定要删除这个部门吗?"
@confirm="handleDelete(row)" @confirm="handleDelete(row)"
> >
<Button size="small" danger> 删除 </Button> <Button size="small" danger> 删除 </Button>
</Popconfirm> </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,
}, },
];
const positionActionColumn: NonNullable<VxeGridProps<any>['columns']>[number] =
{ {
title: '操作', title: '操作',
minWidth: 200, minWidth: 200,
fixed: 'right' as const, fixed: 'right' as const,
slots: { default: 'action' }, 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>
<PermissionGate code="org:position:create">
<Button type="primary" @click="handleAdd"> <Button type="primary" @click="handleAdd">
<PlusIcon /> <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>
<PermissionGate code="org:position:update">
<Button size="small" @click="handleEdit(row)"> 编辑 </Button> <Button size="small" @click="handleEdit(row)"> 编辑 </Button>
</PermissionGate>
<PermissionGate code="org:position:delete">
<Popconfirm <Popconfirm
title="确定要删除这个职位吗?" title="确定要删除这个职位吗?"
@confirm="handleDelete(row)" @confirm="handleDelete(row)"
> >
<Button size="small" danger> 删除 </Button> <Button size="small" danger> 删除 </Button>
</Popconfirm> </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,6 +311,7 @@ onMounted(() => {
<template #extra> <template #extra>
<Space> <Space>
<PermissionGate code="org:position:menu:assign">
<Button :disabled="!currentPosition" @click="handleSelectNone"> <Button :disabled="!currentPosition" @click="handleSelectNone">
取消全选 取消全选
</Button> </Button>
@@ -323,6 +329,7 @@ onMounted(() => {
> >
保存配置 保存配置
</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,6 +267,7 @@ onMounted(() => {
<template #extra> <template #extra>
<Space> <Space>
<PermissionGate code="org:position:permission:assign">
<Button :disabled="!currentPosition" @click="selectNone">取消全选</Button> <Button :disabled="!currentPosition" @click="selectNone">取消全选</Button>
<Button type="primary" :disabled="!currentPosition" @click="selectAll"> <Button type="primary" :disabled="!currentPosition" @click="selectAll">
一键全选 一键全选
@@ -271,6 +279,7 @@ onMounted(() => {
> >
保存配置 保存配置
</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,6 +506,7 @@ onMounted(() => {
/> />
</Form.Item> </Form.Item>
<Space> <Space>
<PermissionGate code="bi:order-stat:calc:create">
<Button <Button
type="primary" type="primary"
:loading="rebuildSubmitting" :loading="rebuildSubmitting"
@@ -513,6 +515,7 @@ onMounted(() => {
<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"
/> />
<PermissionGate code="bi:order-stat:calc:read">
<Button :loading="pollLoading" @click="fetchRebuildStatus()"> <Button :loading="pollLoading" @click="fetchRebuildStatus()">
<template #icon><RefreshIcon /></template> <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,6 +601,7 @@ onMounted(() => {
class="w-full" class="w-full"
/> />
</Form.Item> </Form.Item>
<PermissionGate code="bi:order-stat:calc:read">
<Button <Button
type="primary" type="primary"
:loading="reconcileLoading" :loading="reconcileLoading"
@@ -604,6 +610,7 @@ onMounted(() => {
<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">