<script lang="ts" setup>
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { HrmResignationApi } from '#/api/hrm/resignation';
|
|
import { Page, useVbenModal } from '#/packages/effects/common-ui/src';
|
|
import { message } from 'ant-design-vue';
|
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import {
|
cancelResignation,
|
deleteResignation,
|
getResignationPage,
|
submitResignation,
|
updateHandoverStatus,
|
} from '#/api/hrm/resignation';
|
import { $t } from '#/locales';
|
|
import { useGridColumns, useGridFormSchema } from './data';
|
import Form from './modules/form.vue';
|
|
const [FormModal, formModalApi] = useVbenModal({
|
connectedComponent: Form,
|
destroyOnClose: true,
|
});
|
|
/** 刷新表格 */
|
function handleRefresh() {
|
gridApi.query();
|
}
|
|
/** 创建离职申请 */
|
function handleCreate() {
|
formModalApi.setData({ formType: 'create' }).open();
|
}
|
|
/** 查看离职申请 */
|
function handleDetail(row: HrmResignationApi.Resignation) {
|
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
}
|
|
/** 编辑离职申请 */
|
function handleEdit(row: HrmResignationApi.Resignation) {
|
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
}
|
|
/** 删除离职申请 */
|
async function handleDelete(row: HrmResignationApi.Resignation) {
|
const hideLoading = message.loading({
|
content: $t('ui.actionMessage.deleting', ['离职申请']),
|
duration: 0,
|
});
|
try {
|
await deleteResignation(row.id!);
|
message.success($t('ui.actionMessage.deleteSuccess', ['离职申请']));
|
handleRefresh();
|
} finally {
|
hideLoading();
|
}
|
}
|
|
/** 提交离职申请 */
|
async function handleSubmit(row: HrmResignationApi.Resignation) {
|
await submitResignation(row.id!);
|
message.success('提交成功');
|
handleRefresh();
|
}
|
|
/** 撤销离职申请 */
|
async function handleCancel(row: HrmResignationApi.Resignation) {
|
await cancelResignation(row.id!);
|
message.success('撤销成功');
|
handleRefresh();
|
}
|
|
/** 更新交接状态 */
|
async function handleUpdateHandover(row: HrmResignationApi.Resignation) {
|
// 交接状态:0-未开始,10-进行中,20-已完成
|
const nextStatus = row.handoverStatus === 0 ? 10 : row.handoverStatus === 10 ? 20 : 0;
|
const statusText = nextStatus === 10 ? '进行中' : nextStatus === 20 ? '已完成' : '未开始';
|
await updateHandoverStatus(row.id!, nextStatus);
|
message.success(`交接状态已更新为:${statusText}`);
|
handleRefresh();
|
}
|
|
const [Grid, gridApi] = useVbenVxeGrid({
|
formOptions: {
|
schema: useGridFormSchema(),
|
},
|
gridOptions: {
|
columns: useGridColumns(),
|
height: 'auto',
|
keepSource: true,
|
proxyConfig: {
|
ajax: {
|
query: async ({ page }, formValues) =>
|
await getResignationPage({
|
pageNo: page.currentPage,
|
pageSize: page.pageSize,
|
...formValues,
|
}),
|
},
|
},
|
rowConfig: {
|
keyField: 'id',
|
isHover: true,
|
},
|
toolbarConfig: {
|
refresh: true,
|
search: true,
|
},
|
} as VxeTableGridOptions<HrmResignationApi.Resignation>,
|
});
|
</script>
|
|
<template>
|
<Page auto-content-height>
|
<FormModal @success="handleRefresh" />
|
<Grid table-title="离职申请列表">
|
<template #toolbar-tools>
|
<TableAction
|
:actions="[
|
{
|
label: $t('ui.actionTitle.create', ['离职申请']),
|
type: 'primary',
|
icon: ACTION_ICON.ADD,
|
auth: ['hrm:resignation:create'],
|
onClick: handleCreate,
|
},
|
]"
|
/>
|
</template>
|
<template #actions="{ row }">
|
<TableAction
|
:actions="[
|
{
|
label: '查看',
|
type: 'link',
|
onClick: handleDetail.bind(null, row),
|
},
|
{
|
label: $t('common.edit'),
|
type: 'link',
|
icon: ACTION_ICON.EDIT,
|
auth: ['hrm:resignation:update'],
|
ifShow: row.status === 0,
|
onClick: handleEdit.bind(null, row),
|
},
|
{
|
label: '提交',
|
type: 'link',
|
auth: ['hrm:resignation:submit'],
|
ifShow: row.status === 0,
|
onClick: handleSubmit.bind(null, row),
|
},
|
{
|
label: '撤销',
|
type: 'link',
|
auth: ['hrm:resignation:cancel'],
|
ifShow: row.status === 10,
|
onClick: handleCancel.bind(null, row),
|
},
|
{
|
label: '交接',
|
type: 'link',
|
auth: ['hrm:resignation:handover'],
|
ifShow: row.status === 20 && row.handoverStatus !== 20,
|
popConfirm: {
|
title: row.handoverStatus === 0 ? '确认开始交接吗?' : '确认完成交接吗?',
|
confirm: handleUpdateHandover.bind(null, row),
|
},
|
},
|
{
|
label: $t('common.delete'),
|
type: 'link',
|
danger: true,
|
icon: ACTION_ICON.DELETE,
|
auth: ['hrm:resignation:delete'],
|
ifShow: row.status === 0 || row.status === 40,
|
popConfirm: {
|
title: $t('ui.actionMessage.deleteConfirm', ['离职申请']),
|
confirm: handleDelete.bind(null, row),
|
},
|
},
|
]"
|
/>
|
</template>
|
</Grid>
|
</Page>
|
</template>
|