<script lang="ts" setup>
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { HrmLeaveTypeConfigApi } from '#/api/hrm/leave-type-config';
|
|
import { Page, useVbenModal } from '#/packages/effects/common-ui/src';
|
|
import { message, Tag } from 'ant-design-vue';
|
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { getLeaveTypeConfigList } from '#/api/hrm/leave-type-config';
|
import { $t } from '#/locales';
|
|
import { useGridColumns } from './data';
|
import Form from './modules/form.vue';
|
|
const [FormModal, formModalApi] = useVbenModal({
|
connectedComponent: Form,
|
destroyOnClose: true,
|
});
|
|
/** 刷新表格 */
|
function handleRefresh() {
|
gridApi.query();
|
}
|
|
/** 编辑配置 */
|
function handleEdit(row: HrmLeaveTypeConfigApi.LeaveTypeConfig) {
|
formModalApi.setData({ id: row.id, row }).open();
|
}
|
|
const [Grid, gridApi] = useVbenVxeGrid({
|
gridOptions: {
|
columns: useGridColumns(),
|
height: 'auto',
|
keepSource: true,
|
proxyConfig: {
|
ajax: {
|
query: async () => await getLeaveTypeConfigList(),
|
},
|
},
|
rowConfig: {
|
keyField: 'id',
|
isHover: true,
|
},
|
pagerConfig: {
|
enabled: false,
|
},
|
toolbarConfig: {
|
refresh: true,
|
},
|
} as VxeTableGridOptions<HrmLeaveTypeConfigApi.LeaveTypeConfig>,
|
});
|
</script>
|
|
<template>
|
<Page auto-content-height>
|
<FormModal @success="handleRefresh" />
|
<Grid table-title="请假扣款配置列表">
|
<template #deductionRatio="{ row }">
|
<Tag :color="row.deductionRatio === 0 ? 'success' : row.deductionRatio === 1 ? 'error' : 'warning'">
|
{{ row.deductionRatio === 0 ? '不扣款' : `${(row.deductionRatio * 100).toFixed(0)}%` }}
|
</Tag>
|
</template>
|
<template #status="{ row }">
|
<Tag :color="row.status === 0 ? 'success' : 'default'">
|
{{ row.status === 0 ? '启用' : '禁用' }}
|
</Tag>
|
</template>
|
<template #actions="{ row }">
|
<TableAction
|
:actions="[
|
{
|
label: $t('common.edit'),
|
type: 'link',
|
icon: ACTION_ICON.EDIT,
|
auth: ['hrm:leave-type-config:update'],
|
onClick: handleEdit.bind(null, row),
|
},
|
]"
|
/>
|
</template>
|
</Grid>
|
</Page>
|
</template>
|