<script lang="ts" setup>
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { HrmAttendanceExceptionApi } from '#/api/hrm/attendance/exception';
|
|
import { ref } from 'vue';
|
|
import { Page, useVbenModal } from '#/packages/effects/common-ui/src';
|
|
import { message, Modal, Select } from 'ant-design-vue';
|
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import {
|
getAttendanceExceptionApproveProcessList,
|
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();
|
}
|
|
/** 提交审批弹窗 */
|
const submitModalVisible = ref(false);
|
const currentRow = ref<HrmAttendanceExceptionApi.AttendanceException>();
|
const processList = ref<HrmAttendanceExceptionApi.ApproveProcess[]>([]);
|
const selectedProcessKey = ref<string>();
|
const submitLoading = ref(false);
|
|
/** 提交考勤异常申请 */
|
async function handleSubmit(row: HrmAttendanceExceptionApi.AttendanceException) {
|
const res = await getAttendanceExceptionApproveProcessList();
|
processList.value = res;
|
currentRow.value = row;
|
selectedProcessKey.value = undefined;
|
submitModalVisible.value = true;
|
}
|
|
/** 确认提交 */
|
async function confirmSubmit() {
|
if (!selectedProcessKey.value) {
|
message.warning('请选择审批流程');
|
return;
|
}
|
submitLoading.value = true;
|
try {
|
await submitAttendanceException(currentRow.value!.id!, selectedProcessKey.value);
|
message.success('提交审批成功');
|
submitModalVisible.value = false;
|
handleRefresh();
|
} finally {
|
submitLoading.value = false;
|
}
|
}
|
|
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>
|
|
<!-- 提交审批弹窗 -->
|
<Modal
|
v-model:open="submitModalVisible"
|
title="选择审批流程"
|
width="400px"
|
@ok="confirmSubmit"
|
:confirmLoading="submitLoading"
|
>
|
<Select
|
v-model:value="selectedProcessKey"
|
placeholder="请选择审批流程"
|
class="w-full"
|
>
|
<Select.Option
|
v-for="item in processList"
|
:key="item.key"
|
:value="item.key"
|
>
|
{{ item.name }}
|
</Select.Option>
|
</Select>
|
</Modal>
|
</Page>
|
</template>
|