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

This commit is contained in:
YunaiV
2025-09-06 15:12:58 +08:00
parent 5f77cde53f
commit a38e55651b
5 changed files with 110 additions and 100 deletions

View File

@@ -64,19 +64,28 @@ export function useGridFormSchema(): VbenFormSchema[] {
fieldName: 'name',
label: '岗位名称',
component: 'Input',
componentProps: {
placeholder: '请输入岗位名称',
allowClear: true,
},
},
{
fieldName: 'code',
label: '岗位编码',
component: 'Input',
componentProps: {
placeholder: '请输入岗位编码',
allowClear: true,
},
},
{
fieldName: 'status',
label: '岗位状态',
component: 'Select',
componentProps: {
allowClear: true,
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
placeholder: '请选择岗位状态',
allowClear: true,
},
},
];
@@ -89,26 +98,32 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
field: 'id',
title: '岗位编号',
minWidth: 200,
},
{
field: 'name',
title: '岗位名称',
minWidth: 200,
},
{
field: 'code',
title: '岗位编码',
minWidth: 200,
},
{
field: 'sort',
title: '显示顺序',
minWidth: 100,
},
{
field: 'remark',
title: '岗位备注',
minWidth: 200,
},
{
field: 'status',
title: '岗位状态',
minWidth: 100,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.COMMON_STATUS },
@@ -117,6 +132,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
field: 'createTime',
title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime',
},
{

View File

@@ -4,7 +4,7 @@ import type { SystemPostApi } from '#/api/system/post';
import { ref } from 'vue';
import { Page, useVbenModal } from '@vben/common-ui';
import { confirm, Page, useVbenModal } from '@vben/common-ui';
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
import { message } from 'ant-design-vue';
@@ -27,7 +27,7 @@ const [FormModal, formModalApi] = useVbenModal({
});
/** 刷新表格 */
function onRefresh() {
function handleRefresh() {
gridApi.query();
}
@@ -51,15 +51,29 @@ function handleEdit(row: SystemPostApi.Post) {
async function handleDelete(row: SystemPostApi.Post) {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.name]),
key: 'action_key_msg',
duration: 0,
});
try {
await deletePost(row.id as number);
message.success({
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
key: 'action_key_msg',
});
onRefresh();
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
handleRefresh();
} finally {
hideLoading();
}
}
/** 批量删除岗位 */
async function handleDeleteBatch() {
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
const hideLoading = message.loading({
content: $t('ui.actionMessage.deletingBatch'),
duration: 0,
});
try {
await deletePostList(checkedIds.value);
checkedIds.value = [];
message.success($t('ui.actionMessage.deleteSuccess'));
handleRefresh();
} finally {
hideLoading();
}
@@ -74,23 +88,6 @@ function handleRowCheckboxChange({
checkedIds.value = records.map((item) => item.id!);
}
/** 批量删除岗位 */
async function handleDeleteBatch() {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting'),
duration: 0,
key: 'action_process_msg',
});
try {
await deletePostList(checkedIds.value);
checkedIds.value = [];
message.success($t('ui.actionMessage.deleteSuccess'));
onRefresh();
} finally {
hideLoading();
}
}
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
@@ -128,7 +125,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
<template>
<Page auto-content-height>
<FormModal @success="onRefresh" />
<FormModal @success="handleRefresh" />
<Grid table-title="岗位列表">
<template #toolbar-tools>
<TableAction
@@ -148,12 +145,12 @@ const [Grid, gridApi] = useVbenVxeGrid({
onClick: handleExport,
},
{
label: '批量删除',
label: $t('ui.actionTitle.deleteBatch'),
type: 'primary',
danger: true,
disabled: isEmpty(checkedIds),
icon: ACTION_ICON.DELETE,
auth: ['system:post:delete'],
disabled: isEmpty(checkedIds),
onClick: handleDeleteBatch,
},
]"

View File

@@ -76,7 +76,7 @@ const [Modal, modalApi] = useVbenModal({
</script>
<template>
<Modal class="w-2/5" :title="getTitle">
<Modal class="w-[600px]" :title="getTitle">
<Form class="mx-4" />
</Modal>
</template>