整理管理员列表
This commit is contained in:
@@ -1,19 +1,29 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>添加</span>
|
||||
</a-button>
|
||||
</a-space>
|
||||
<div class="search">
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="搜索关键词"
|
||||
v-model:value="where.keywords"
|
||||
@pressEnter="search"
|
||||
@search="search"
|
||||
style="width: 360px"
|
||||
/>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||
import type { GradeParam } from '@/api/user/grade/model';
|
||||
import { watch } from 'vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import { ref, watch } from 'vue';
|
||||
import { OrderGoods, OrderGoodsParam } from '@/api/order/goods/model';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { Organization } from '@/api/system/organization/model';
|
||||
import { utils, writeFile } from 'xlsx';
|
||||
import dayjs from 'dayjs';
|
||||
import { Grade } from '@/api/user/grade/model';
|
||||
import { BookingUserParam } from '@/api/booking/bookingUser/model';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -24,15 +34,112 @@
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: GradeParam): void;
|
||||
(e: 'search', where?: OrderGoodsParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'batchMove'): void;
|
||||
(e: 'advanced'): void;
|
||||
}>();
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<BookingUserParam>({
|
||||
id: undefined,
|
||||
keywords: undefined,
|
||||
timeStart: undefined,
|
||||
timeEnd: undefined
|
||||
});
|
||||
// 下来选项
|
||||
// const categoryId = ref<number>(0);
|
||||
const post = ref<number>(0);
|
||||
const sign = ref<number>(0);
|
||||
const noSign = ref<number>(0);
|
||||
// 日期范围选择
|
||||
const dateRange = ref<[string, string]>(['', '']);
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
const [d1, d2] = dateRange.value ?? [];
|
||||
where.timeStart = d1 ? dayjs(d1).valueOf() / 1000 : undefined;
|
||||
where.timeEnd = d2 ? dayjs(d2).valueOf() / 1000 : undefined;
|
||||
// where.createTimeStart = d1 ? d1 + ' 00:00:00' : undefined;
|
||||
// where.createTimeEnd = d2 ? d2 + ' 00:00:00' : undefined;
|
||||
emit('search', {
|
||||
...where
|
||||
});
|
||||
};
|
||||
|
||||
const chooseOrganization = (e: Organization) => {
|
||||
// where.organizationId = e.organizationId;
|
||||
// where.organizationName = e.organizationName;
|
||||
search();
|
||||
};
|
||||
|
||||
const chooseGradeId = (e: Grade) => {
|
||||
where.gradeId = e.gradeId;
|
||||
where.gradeName = e.name;
|
||||
search();
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
const reset = () => {
|
||||
dateRange.value = ['', ''];
|
||||
resetFields();
|
||||
post.value = 0;
|
||||
sign.value = 0;
|
||||
noSign.value = 0;
|
||||
search();
|
||||
};
|
||||
|
||||
// 导出
|
||||
const handleExport = () => {
|
||||
if (!props.selection?.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
const array: (string | number)[][] = [
|
||||
[
|
||||
'部门',
|
||||
'编号',
|
||||
'姓名',
|
||||
'早餐报餐次数',
|
||||
'早餐签到次数',
|
||||
'午餐报餐次数',
|
||||
'午餐签到次数',
|
||||
'晚餐报餐次数',
|
||||
'晚餐签到次数',
|
||||
'消费金额'
|
||||
]
|
||||
];
|
||||
props.selection?.forEach((d: OrderGoods) => {
|
||||
array.push([
|
||||
`${d.organizationName}`,
|
||||
`${d.userId}`,
|
||||
`${d.nickname}`,
|
||||
`${d.breakfastPostUsers}`,
|
||||
`${d.breakfastSignUsers}`,
|
||||
`${d.lunchPostUsers}`,
|
||||
`${d.lunchSignUsers}`,
|
||||
`${d.dinnerPostUsers}`,
|
||||
`${d.dinnerSignUsers}`
|
||||
]);
|
||||
});
|
||||
const sheetName = '报餐统计导出';
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
// 设置列宽
|
||||
sheet['!cols'] = [
|
||||
{ wch: 10 },
|
||||
{ wch: 10 },
|
||||
{ wch: 10 },
|
||||
{ wch: 10 },
|
||||
{ wch: 20 },
|
||||
{ wch: 40 },
|
||||
{ wch: 10 }
|
||||
];
|
||||
writeFile(workbook, '报餐统计导出.xlsx');
|
||||
};
|
||||
|
||||
watch(
|
||||
|
||||
Reference in New Issue
Block a user