<script lang="ts" setup>
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { HrmAttendanceExceptionApi } from '#/api/hrm/attendance/exception';
|
|
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 { getAttendanceExceptionPage, submitAttendanceException } from '#/api/hrm/attendance/exception';
|
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: HrmAttendanceExceptionApi.AttendanceException) {
|
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
}
|
|
/** 提交考勤异常申请 */
|
async function handleSubmit(row: HrmAttendanceExceptionApi.AttendanceException) {
|
await submitAttendanceException(row.id!);
|
message.success('提交成功');
|
handleRefresh();
|
}
|
|
const [Grid, gridApi] = useVbenVxeGrid({
|
formOptions: {
|
schema: useGridFormSchema(),
|
},
|
gridOptions: {
|
columns: useGridColumns(),
|
height: 'auto',
|
keepSource: true,
|
proxyConfig: {
|
ajax: {
|
query: async ({ page }, formValues) =>
|
await getAttendanceExceptionPage({
|
pageNo: page.currentPage,
|
pageSize: page.pageSize,
|
...formValues,
|
}),
|
},
|
},
|
rowConfig: {
|
keyField: 'id',
|
isHover: true,
|
},
|
toolbarConfig: {
|
refresh: true,
|
search: true,
|
},
|
} as VxeTableGridOptions<HrmAttendanceExceptionApi.AttendanceException>,
|
});
|
</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:attendance-exception:create'],
|
onClick: handleCreate,
|
},
|
]"
|
/>
|
</template>
|
<template #actions="{ row }">
|
<TableAction
|
:actions="[
|
{
|
label: '查看',
|
type: 'link',
|
onClick: handleDetail.bind(null, row),
|
},
|
{
|
label: '提交',
|
type: 'link',
|
auth: ['hrm:attendance-exception:submit'],
|
ifShow: row.status === 0,
|
onClick: handleSubmit.bind(null, row),
|
},
|
]"
|
/>
|
</template>
|
</Grid>
|
</Page>
|
</template>
|