gaoluyang
2026-06-29 27cd042df9aca0383a49f3514bc21958dd890912
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
<script lang="ts" setup>
import type { SystemUserApi } from '#/api/system/user';
 
import { onMounted, ref } from 'vue';
 
import { IconifyIcon } from '../../../../../packages/icons/src';
 
import { Button, Form, FormItem, Select } from 'ant-design-vue';
 
import { getSimpleUserList } from '#/api/system/user';
 
import { CalendarPanel, useCalendar } from '../components';
 
const {
  calendarDayMap,
  currentDate,
  fetchCalendar,
  holidaySet,
  loadHolidays,
  loading,
  watchMonth,
} = useCalendar();
 
const userId = ref<number>();
const userOptions = ref<SystemUserApi.User[]>([]);
 
/** 查询当前月份的排班日历,按选中人员过滤 */
function doFetch() {
  if (!userId.value) {
    return;
  }
  fetchCalendar({ queryType: 'USER', userId: userId.value });
}
 
/** 查询按钮 / 下拉选人后刷新日历 */
function onUserQuery() {
  doFetch();
}
 
/** 监听月份切换,重新加载当月排班 */
watchMonth(() => {
  if (userId.value) {
    doFetch();
  }
});
 
onMounted(async () => {
  // 假期列表与人员列表并行加载,避免假期接口无权限或异常时阻断人员排班查询
  void loadHolidays();
  userOptions.value = await getSimpleUserList();
});
</script>
 
<template>
  <div>
    <!-- 顶部:人员选择 -->
    <Form layout="inline" class="mb-2.5">
      <FormItem label="人员">
        <Select
          v-model:value="userId"
          allow-clear
          show-search
          placeholder="请输入人员姓名搜索"
          class="!w-[200px]"
          :options="userOptions"
          :field-names="{ label: 'nickname', value: 'id' }"
          :filter-option="
            (input: string, option: any) =>
              (option?.nickname ?? '').includes(input)
          "
          @change="onUserQuery"
        />
      </FormItem>
      <FormItem>
        <Button type="primary" @click="onUserQuery">
          <template #icon>
            <IconifyIcon icon="lucide:search" />
          </template>
          查询
        </Button>
      </FormItem>
    </Form>
 
    <!-- 日历 -->
    <CalendarPanel
      v-model:current-date="currentDate"
      :calendar-day-map="calendarDayMap"
      :holiday-set="holidaySet"
      :loading="loading"
    />
  </div>
</template>