reactor:【system 系统管理】social 进一步统一代码风格

This commit is contained in:
YunaiV
2025-09-06 20:32:46 +08:00
parent 8d5a6d8aa0
commit 35bd5adf45
9 changed files with 168 additions and 142 deletions

View File

@@ -46,3 +46,10 @@ export function updateSocialClient(data: SystemSocialClientApi.SocialClient) {
export function deleteSocialClient(id: number) { export function deleteSocialClient(id: number) {
return requestClient.delete(`/system/social-client/delete?id=${id}`); return requestClient.delete(`/system/social-client/delete?id=${id}`);
} }
/** 批量删除社交客户端 */
export function deleteSocialClientList(ids: number[]) {
return requestClient.delete(
`/system/social-client/delete-list?ids=${ids.join(',')}`,
);
}

View File

@@ -104,6 +104,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Input', component: 'Input',
componentProps: { componentProps: {
placeholder: '请输入应用名', placeholder: '请输入应用名',
allowClear: true,
}, },
}, },
{ {
@@ -132,6 +133,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Input', component: 'Input',
componentProps: { componentProps: {
placeholder: '请输入客户端编号', placeholder: '请输入客户端编号',
allowClear: true,
}, },
}, },
{ {
@@ -150,17 +152,21 @@ export function useGridFormSchema(): VbenFormSchema[] {
/** 列表的字段 */ /** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions['columns'] { export function useGridColumns(): VxeTableGridOptions['columns'] {
return [ return [
{ type: 'checkbox', width: 40 },
{ {
field: 'id', field: 'id',
title: '编号', title: '编号',
minWidth: 100,
}, },
{ {
field: 'name', field: 'name',
title: '应用名', title: '应用名',
minWidth: 120,
}, },
{ {
field: 'socialType', field: 'socialType',
title: '社交平台', title: '社交平台',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.SYSTEM_SOCIAL_TYPE }, props: { type: DICT_TYPE.SYSTEM_SOCIAL_TYPE },
@@ -169,6 +175,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'userType', field: 'userType',
title: '用户类型', title: '用户类型',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.USER_TYPE }, props: { type: DICT_TYPE.USER_TYPE },
@@ -177,10 +184,12 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'clientId', field: 'clientId',
title: '客户端编号', title: '客户端编号',
minWidth: 180,
}, },
{ {
field: 'status', field: 'status',
title: '状态', title: '状态',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.COMMON_STATUS }, props: { type: DICT_TYPE.COMMON_STATUS },
@@ -189,11 +198,12 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'createTime', field: 'createTime',
title: '创建时间', title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
title: '操作', title: '操作',
width: 130, width: 220,
fixed: 'right', fixed: 'right',
slots: { default: 'actions' }, slots: { default: 'actions' },
}, },

View File

@@ -2,13 +2,17 @@
import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemSocialClientApi } from '#/api/system/social/client'; import type { SystemSocialClientApi } from '#/api/system/social/client';
import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; import { ref } from 'vue';
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { isEmpty } from '@vben/utils';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { import {
deleteSocialClient, deleteSocialClient,
deleteSocialClientList,
getSocialClientPage, getSocialClientPage,
} from '#/api/system/social/client'; } from '#/api/system/social/client';
import { $t } from '#/locales'; import { $t } from '#/locales';
@@ -22,7 +26,7 @@ const [FormModal, formModalApi] = useVbenModal({
}); });
/** 刷新表格 */ /** 刷新表格 */
function onRefresh() { function handleRefresh() {
gridApi.query(); gridApi.query();
} }
@@ -40,20 +44,43 @@ function handleEdit(row: SystemSocialClientApi.SocialClient) {
async function handleDelete(row: SystemSocialClientApi.SocialClient) { async function handleDelete(row: SystemSocialClientApi.SocialClient) {
const hideLoading = message.loading({ const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.name]), content: $t('ui.actionMessage.deleting', [row.name]),
key: 'action_key_msg', duration: 0,
}); });
try { try {
await deleteSocialClient(row.id as number); await deleteSocialClient(row.id as number);
message.success({ message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
content: $t('ui.actionMessage.deleteSuccess', [row.name]), handleRefresh();
key: 'action_key_msg',
});
onRefresh();
} finally { } finally {
hideLoading(); hideLoading();
} }
} }
/** 批量删除社交客户端 */
async function handleDeleteBatch() {
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
const hideLoading = message.loading({
content: $t('ui.actionMessage.deletingBatch'),
duration: 0,
});
try {
await deleteSocialClientList(checkedIds.value);
checkedIds.value = [];
message.success($t('ui.actionMessage.deleteSuccess'));
handleRefresh();
} finally {
hideLoading();
}
}
const checkedIds = ref<number[]>([]);
function handleRowCheckboxChange({
records,
}: {
records: SystemSocialClientApi.SocialClient[];
}) {
checkedIds.value = records.map((item) => item.id!);
}
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({
formOptions: { formOptions: {
schema: useGridFormSchema(), schema: useGridFormSchema(),
@@ -75,12 +102,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
}, },
rowConfig: { rowConfig: {
keyField: 'id', keyField: 'id',
isHover: true,
}, },
toolbarConfig: { toolbarConfig: {
refresh: true, refresh: true,
search: true, search: true,
}, },
} as VxeTableGridOptions<SystemSocialClientApi.SocialClient>, } as VxeTableGridOptions<SystemSocialClientApi.SocialClient>,
gridEvents: {
checkboxAll: handleRowCheckboxChange,
checkboxChange: handleRowCheckboxChange,
},
}); });
</script> </script>
@@ -90,7 +122,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
<DocAlert title="三方登录" url="https://doc.iocoder.cn/social-user/" /> <DocAlert title="三方登录" url="https://doc.iocoder.cn/social-user/" />
</template> </template>
<FormModal @success="onRefresh" /> <FormModal @success="handleRefresh" />
<Grid table-title="社交客户端列表"> <Grid table-title="社交客户端列表">
<template #toolbar-tools> <template #toolbar-tools>
<TableAction <TableAction
@@ -102,6 +134,15 @@ const [Grid, gridApi] = useVbenVxeGrid({
auth: ['system:social-client:create'], auth: ['system:social-client:create'],
onClick: handleCreate, onClick: handleCreate,
}, },
{
label: $t('ui.actionTitle.deleteBatch'),
type: 'primary',
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['system:social-client:delete'],
disabled: isEmpty(checkedIds),
onClick: handleDeleteBatch,
},
]" ]"
/> />
</template> </template>

View File

@@ -55,6 +55,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'type', field: 'type',
title: '社交平台', title: '社交平台',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.SYSTEM_SOCIAL_TYPE }, props: { type: DICT_TYPE.SYSTEM_SOCIAL_TYPE },
@@ -63,14 +64,17 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'openid', field: 'openid',
title: '社交 openid', title: '社交 openid',
minWidth: 180,
}, },
{ {
field: 'nickname', field: 'nickname',
title: '用户昵称', title: '用户昵称',
minWidth: 120,
}, },
{ {
field: 'avatar', field: 'avatar',
title: '用户头像', title: '用户头像',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellImage', name: 'CellImage',
}, },
@@ -78,16 +82,18 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'createTime', field: 'createTime',
title: '创建时间', title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'updateTime', field: 'updateTime',
title: '更新时间', title: '更新时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
title: '操作', title: '操作',
width: 80, width: 120,
fixed: 'right', fixed: 'right',
slots: { default: 'actions' }, slots: { default: 'actions' },
}, },

View File

@@ -3,10 +3,10 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemSocialUserApi } from '#/api/system/social/user'; import type { SystemSocialUserApi } from '#/api/system/social/user';
import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getSocialUserPage } from '#/api/system/social/user'; import { getSocialUserPage } from '#/api/system/social/user';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data'; import { useGridColumns, useGridFormSchema } from './data';
import Detail from './modules/detail.vue'; import Detail from './modules/detail.vue';
@@ -42,6 +42,7 @@ const [Grid] = useVbenVxeGrid({
}, },
rowConfig: { rowConfig: {
keyField: 'id', keyField: 'id',
isHover: true,
}, },
toolbarConfig: { toolbarConfig: {
refresh: true, refresh: true,

View File

@@ -1,8 +1,6 @@
import type { VbenFormSchema } from '#/adapter/form'; import type { VbenFormSchema } from '#/adapter/form';
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemSocialClientApi } from '#/api/system/social/client';
import { useAccess } from '@vben/access';
import { import {
CommonStatusEnum, CommonStatusEnum,
DICT_TYPE, DICT_TYPE,
@@ -12,8 +10,6 @@ import { getDictOptions } from '@vben/hooks';
import { z } from '#/adapter/form'; import { z } from '#/adapter/form';
const { hasAccessByCodes } = useAccess();
/** 新增/修改的表单 */ /** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] { export function useFormSchema(): VbenFormSchema[] {
return [ return [
@@ -108,6 +104,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Input', component: 'Input',
componentProps: { componentProps: {
placeholder: '请输入应用名', placeholder: '请输入应用名',
clearable: true,
}, },
}, },
{ {
@@ -136,6 +133,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Input', component: 'Input',
componentProps: { componentProps: {
placeholder: '请输入客户端编号', placeholder: '请输入客户端编号',
clearable: true,
}, },
}, },
{ {
@@ -152,18 +150,13 @@ export function useGridFormSchema(): VbenFormSchema[] {
} }
/** 列表的字段 */ /** 列表的字段 */
export function useGridColumns<T = SystemSocialClientApi.SocialClient>( export function useGridColumns(): VxeTableGridOptions['columns'] {
onActionClick: OnActionClickFn<T>,
): VxeTableGridOptions['columns'] {
return [ return [
{ { type: 'checkbox', width: 40 },
type: 'checkbox',
width: 40,
},
{ {
field: 'id', field: 'id',
title: '编号', title: '编号',
minWidth: 80, minWidth: 100,
}, },
{ {
field: 'name', field: 'name',
@@ -173,7 +166,7 @@ export function useGridColumns<T = SystemSocialClientApi.SocialClient>(
{ {
field: 'socialType', field: 'socialType',
title: '社交平台', title: '社交平台',
minWidth: 120, minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.SYSTEM_SOCIAL_TYPE }, props: { type: DICT_TYPE.SYSTEM_SOCIAL_TYPE },
@@ -182,7 +175,7 @@ export function useGridColumns<T = SystemSocialClientApi.SocialClient>(
{ {
field: 'userType', field: 'userType',
title: '用户类型', title: '用户类型',
minWidth: 120, minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.USER_TYPE }, props: { type: DICT_TYPE.USER_TYPE },
@@ -196,7 +189,7 @@ export function useGridColumns<T = SystemSocialClientApi.SocialClient>(
{ {
field: 'status', field: 'status',
title: '状态', title: '状态',
minWidth: 80, minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.COMMON_STATUS }, props: { type: DICT_TYPE.COMMON_STATUS },
@@ -209,29 +202,10 @@ export function useGridColumns<T = SystemSocialClientApi.SocialClient>(
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'operation',
title: '操作', title: '操作',
minWidth: 130, width: 220,
align: 'center',
fixed: 'right', fixed: 'right',
cellRender: { slots: { default: 'actions' },
attrs: {
nameField: 'name',
nameTitle: '社交客户端',
onClick: onActionClick,
},
name: 'CellOperation',
options: [
{
code: 'edit',
show: hasAccessByCodes(['system:social-client:update']),
},
{
code: 'delete',
show: hasAccessByCodes(['system:social-client:delete']),
},
],
},
}, },
]; ];
} }

View File

@@ -1,8 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { import type { VxeTableGridOptions } from '#/adapter/vxe-table';
OnActionClickParams,
VxeTableGridOptions,
} from '#/adapter/vxe-table';
import type { SystemSocialClientApi } from '#/api/system/social/client'; import type { SystemSocialClientApi } from '#/api/system/social/client';
import { ref } from 'vue'; import { ref } from 'vue';
@@ -29,41 +26,48 @@ const [FormModal, formModalApi] = useVbenModal({
}); });
/** 刷新表格 */ /** 刷新表格 */
function onRefresh() { function handleRefresh() {
gridApi.query(); gridApi.query();
} }
/** 创建社交客户端 */ /** 创建社交客户端 */
function onCreate() { function handleCreate() {
formModalApi.setData(null).open(); formModalApi.setData(null).open();
} }
/** 编辑社交客户端 */ /** 编辑社交客户端 */
function onEdit(row: SystemSocialClientApi.SocialClient) { function handleEdit(row: SystemSocialClientApi.SocialClient) {
formModalApi.setData(row).open(); formModalApi.setData(row).open();
} }
/** 删除社交客户端 */ /** 删除社交客户端 */
async function onDelete(row: SystemSocialClientApi.SocialClient) { async function handleDelete(row: SystemSocialClientApi.SocialClient) {
const loadingInstance = ElLoading.service({ const hideLoading = ElLoading.service({
text: $t('ui.actionMessage.deleting', [row.name]), text: $t('ui.actionMessage.deleting', [row.name]),
}); });
try { try {
await deleteSocialClient(row.id as number); await deleteSocialClient(row.id as number);
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name])); ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
onRefresh(); handleRefresh();
} finally { } finally {
loadingInstance.close(); hideLoading.close();
} }
} }
/** 批量删除社交客户端 */ /** 批量删除社交客户端 */
async function onDeleteBatch() { async function handleDeleteBatch() {
await confirm('确定要批量删除该社交客户端吗?'); await confirm($t('ui.actionMessage.deleteBatchConfirm'));
const hideLoading = ElLoading.service({
text: $t('ui.actionMessage.deletingBatch'),
});
try {
await deleteSocialClientList(checkedIds.value); await deleteSocialClientList(checkedIds.value);
checkedIds.value = []; checkedIds.value = [];
ElMessage.success($t('ui.actionMessage.deleteSuccess')); ElMessage.success($t('ui.actionMessage.deleteSuccess'));
onRefresh(); handleRefresh();
} finally {
hideLoading.close();
}
} }
const checkedIds = ref<number[]>([]); const checkedIds = ref<number[]>([]);
@@ -75,29 +79,12 @@ function handleRowCheckboxChange({
checkedIds.value = records.map((item) => item.id!); checkedIds.value = records.map((item) => item.id!);
} }
/** 表格操作按钮的回调函数 */
function onActionClick({
code,
row,
}: OnActionClickParams<SystemSocialClientApi.SocialClient>) {
switch (code) {
case 'delete': {
onDelete(row);
break;
}
case 'edit': {
onEdit(row);
break;
}
}
}
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({
formOptions: { formOptions: {
schema: useGridFormSchema(), schema: useGridFormSchema(),
}, },
gridOptions: { gridOptions: {
columns: useGridColumns(onActionClick), columns: useGridColumns(),
height: 'auto', height: 'auto',
keepSource: true, keepSource: true,
proxyConfig: { proxyConfig: {
@@ -113,6 +100,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
}, },
rowConfig: { rowConfig: {
keyField: 'id', keyField: 'id',
isHover: true,
}, },
toolbarConfig: { toolbarConfig: {
refresh: true, refresh: true,
@@ -132,7 +120,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
<DocAlert title="三方登录" url="https://doc.iocoder.cn/social-user/" /> <DocAlert title="三方登录" url="https://doc.iocoder.cn/social-user/" />
</template> </template>
<FormModal @success="onRefresh" /> <FormModal @success="handleRefresh" />
<Grid table-title="社交客户端列表"> <Grid table-title="社交客户端列表">
<template #toolbar-tools> <template #toolbar-tools>
<TableAction <TableAction
@@ -142,15 +130,40 @@ const [Grid, gridApi] = useVbenVxeGrid({
type: 'primary', type: 'primary',
icon: ACTION_ICON.ADD, icon: ACTION_ICON.ADD,
auth: ['system:social-client:create'], auth: ['system:social-client:create'],
onClick: onCreate, onClick: handleCreate,
}, },
{ {
label: $t('ui.actionTitle.deleteBatch'), label: $t('ui.actionTitle.deleteBatch'),
type: 'danger', type: 'danger',
icon: ACTION_ICON.DELETE, icon: ACTION_ICON.DELETE,
disabled: isEmpty(checkedIds),
auth: ['system:social-client:delete'], auth: ['system:social-client:delete'],
onClick: onDeleteBatch, disabled: isEmpty(checkedIds),
onClick: handleDeleteBatch,
},
]"
/>
</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'primary',
link: true,
icon: ACTION_ICON.EDIT,
auth: ['system:social-client:update'],
onClick: handleEdit.bind(null, row),
},
{
label: $t('common.delete'),
type: 'danger',
link: true,
icon: ACTION_ICON.DELETE,
auth: ['system:social-client:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
confirm: handleDelete.bind(null, row),
},
}, },
]" ]"
/> />

View File

@@ -1,15 +1,11 @@
import type { VbenFormSchema } from '#/adapter/form'; import type { VbenFormSchema } from '#/adapter/form';
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemSocialUserApi } from '#/api/system/social/user';
import { useAccess } from '@vben/access';
import { DICT_TYPE } from '@vben/constants'; import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks'; import { getDictOptions } from '@vben/hooks';
import { getRangePickerDefaultProps } from '#/utils'; import { getRangePickerDefaultProps } from '#/utils';
const { hasAccessByCodes } = useAccess();
/** 列表的搜索表单 */ /** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] { export function useGridFormSchema(): VbenFormSchema[] {
return [ return [
@@ -54,14 +50,12 @@ export function useGridFormSchema(): VbenFormSchema[] {
} }
/** 列表的字段 */ /** 列表的字段 */
export function useGridColumns<T = SystemSocialUserApi.SocialUser>( export function useGridColumns(): VxeTableGridOptions['columns'] {
onActionClick: OnActionClickFn<T>,
): VxeTableGridOptions['columns'] {
return [ return [
{ {
field: 'type', field: 'type',
title: '社交平台', title: '社交平台',
minWidth: 120, minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.SYSTEM_SOCIAL_TYPE }, props: { type: DICT_TYPE.SYSTEM_SOCIAL_TYPE },
@@ -80,7 +74,7 @@ export function useGridColumns<T = SystemSocialUserApi.SocialUser>(
{ {
field: 'avatar', field: 'avatar',
title: '用户头像', title: '用户头像',
minWidth: 80, minWidth: 100,
cellRender: { cellRender: {
name: 'CellImage', name: 'CellImage',
}, },
@@ -98,26 +92,10 @@ export function useGridColumns<T = SystemSocialUserApi.SocialUser>(
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'operation',
title: '操作', title: '操作',
minWidth: 100, width: 120,
align: 'center',
fixed: 'right', fixed: 'right',
cellRender: { slots: { default: 'actions' },
attrs: {
nameField: 'nickname',
nameTitle: '社交用户',
onClick: onActionClick,
},
name: 'CellOperation',
options: [
{
code: 'detail',
text: '详情',
show: hasAccessByCodes(['system:social-user:query']),
},
],
},
}, },
]; ];
} }

View File

@@ -1,14 +1,12 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { import type { VxeTableGridOptions } from '#/adapter/vxe-table';
OnActionClickParams,
VxeTableGridOptions,
} from '#/adapter/vxe-table';
import type { SystemSocialUserApi } from '#/api/system/social/user'; import type { SystemSocialUserApi } from '#/api/system/social/user';
import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getSocialUserPage } from '#/api/system/social/user'; import { getSocialUserPage } from '#/api/system/social/user';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data'; import { useGridColumns, useGridFormSchema } from './data';
import Detail from './modules/detail.vue'; import Detail from './modules/detail.vue';
@@ -18,35 +16,17 @@ const [DetailModal, detailModalApi] = useVbenModal({
destroyOnClose: true, destroyOnClose: true,
}); });
/** 刷新表格 */
// function onRefresh() {
// gridApi.query();
// }
/** 查看详情 */ /** 查看详情 */
function onDetail(row: SystemSocialUserApi.SocialUser) { function handleDetail(row: SystemSocialUserApi.SocialUser) {
detailModalApi.setData(row).open(); detailModalApi.setData(row).open();
} }
/** 表格操作按钮的回调函数 */
function onActionClick({
code,
row,
}: OnActionClickParams<SystemSocialUserApi.SocialUser>) {
switch (code) {
case 'detail': {
onDetail(row);
break;
}
}
}
const [Grid] = useVbenVxeGrid({ const [Grid] = useVbenVxeGrid({
formOptions: { formOptions: {
schema: useGridFormSchema(), schema: useGridFormSchema(),
}, },
gridOptions: { gridOptions: {
columns: useGridColumns(onActionClick), columns: useGridColumns(),
height: 'auto', height: 'auto',
keepSource: true, keepSource: true,
proxyConfig: { proxyConfig: {
@@ -62,6 +42,7 @@ const [Grid] = useVbenVxeGrid({
}, },
rowConfig: { rowConfig: {
keyField: 'id', keyField: 'id',
isHover: true,
}, },
toolbarConfig: { toolbarConfig: {
refresh: true, refresh: true,
@@ -78,6 +59,21 @@ const [Grid] = useVbenVxeGrid({
</template> </template>
<DetailModal /> <DetailModal />
<Grid table-title="社交用户列表" /> <Grid table-title="社交用户列表">
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.detail'),
type: 'primary',
link: true,
icon: ACTION_ICON.VIEW,
auth: ['system:social-user:query'],
onClick: handleDetail.bind(null, row),
},
]"
/>
</template>
</Grid>
</Page> </Page>
</template> </template>