gaoluyang
2 天以前 b64a0deae5b5d33f9e20671a68936b27f0b9b00b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { HrmAttendanceSummaryApi } from '#/api/hrm/attendance/summary';
 
import { Page, useVbenModal } from '#/packages/effects/common-ui/src';
import { downloadFileFromBlobPart } from '#/packages/utils/src';
 
import { Tag } from 'ant-design-vue';
 
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { exportAttendanceSummary, getAttendanceSummaryPage } from '#/api/hrm/attendance/summary';
import { $t } from '#/locales';
 
import { useGridColumns, useGridFormSchema } from './data';
import GenerateForm from './modules/generate-form.vue';
 
const [GenerateModal, generateModalApi] = useVbenModal({
  connectedComponent: GenerateForm,
  destroyOnClose: true,
});
 
/** 刷新表格 */
function handleRefresh() {
  gridApi.query();
}
 
/** 生成统计 */
function handleGenerate() {
  generateModalApi.open();
}
 
/** 导出考勤统计 */
async function handleExport() {
  const data = await exportAttendanceSummary(await gridApi.formApi.getValues());
  downloadFileFromBlobPart({ fileName: '考勤统计.xls', source: data });
}
 
const [Grid, gridApi] = useVbenVxeGrid({
  formOptions: {
    schema: useGridFormSchema(),
  },
  gridOptions: {
    columns: useGridColumns(),
    height: 'auto',
    keepSource: true,
    proxyConfig: {
      ajax: {
        query: async ({ page }, formValues) =>
          await getAttendanceSummaryPage({
            pageNo: page.currentPage,
            pageSize: page.pageSize,
            ...formValues,
          }),
      },
    },
    rowConfig: {
      keyField: 'id',
      isHover: true,
    },
    toolbarConfig: {
      refresh: true,
      search: true,
    },
  } as VxeTableGridOptions<HrmAttendanceSummaryApi.AttendanceSummary>,
});
</script>
 
<template>
  <Page auto-content-height>
    <GenerateModal @success="handleRefresh" />
    <Grid table-title="考勤统计列表">
      <template #toolbar-tools>
        <TableAction
          :actions="[
            {
              label: '生成统计',
              type: 'primary',
              icon: ACTION_ICON.ADD,
              auth: ['hrm:attendance-summary:generate'],
              onClick: handleGenerate,
            },
            {
              label: $t('ui.actionTitle.export'),
              type: 'primary',
              icon: ACTION_ICON.DOWNLOAD,
              auth: ['hrm:attendance-summary:export'],
              onClick: handleExport,
            },
          ]"
        />
      </template>
      <template #lateCount="{ row }">
        <Tag v-if="row.lateCount && row.lateCount > 0" color="warning">{{ row.lateCount }}</Tag>
        <span v-else>{{ row.lateCount || 0 }}</span>
      </template>
      <template #earlyCount="{ row }">
        <Tag v-if="row.earlyCount && row.earlyCount > 0" color="warning">{{ row.earlyCount }}</Tag>
        <span v-else>{{ row.earlyCount || 0 }}</span>
      </template>
      <template #absentCount="{ row }">
        <Tag v-if="row.absentCount && row.absentCount > 0" color="error">{{ row.absentCount }}</Tag>
        <span v-else>{{ row.absentCount || 0 }}</span>
      </template>
    </Grid>
  </Page>
</template>