116 lines
4.0 KiB
Vue
116 lines
4.0 KiB
Vue
/**
|
||
* features/chat/components/ChatLeaveAgentDialog.vue
|
||
* 请假 OA:选择代理人 / 申请人弹窗。
|
||
*/
|
||
<script setup lang="ts">
|
||
import { Loader2, Search, X } from 'lucide-vue-next';
|
||
import type { LeaveAgentOption } from '../types/leave.types';
|
||
|
||
const open = defineModel<boolean>('open', { required: true });
|
||
const keyword = defineModel<string>('keyword', { required: true });
|
||
|
||
defineProps<{
|
||
selectRole: 'agent' | 'applicant';
|
||
options: LeaveAgentOption[];
|
||
loading: boolean;
|
||
page: number;
|
||
hasMore: boolean;
|
||
}>();
|
||
|
||
const emit = defineEmits<{
|
||
close: [];
|
||
search: [];
|
||
'load-more': [];
|
||
'load-all': [];
|
||
select: [option: LeaveAgentOption];
|
||
}>();
|
||
</script>
|
||
|
||
<template>
|
||
<div
|
||
v-if="open"
|
||
class="dialog-overlay z-[100] items-center"
|
||
@click.self="emit('close')"
|
||
>
|
||
<div class="dialog-panel flex max-h-[80vh] max-w-2xl flex-col">
|
||
<div class="dialog-header">
|
||
<div>
|
||
<h3 class="section-title">
|
||
{{ $t('chat.selectWho', { role: selectRole === 'agent' ? $t('chat.leaveAgent') : $t('chat.leaveApplicant') }) }}
|
||
</h3>
|
||
<p class="section-desc mt-1">{{ $t('chat.oaDataConnected') }}</p>
|
||
</div>
|
||
<button type="button" class="btn-icon-ds" :aria-label="$t('admin.close')" @click="emit('close')">
|
||
<X class="h-5 w-5" />
|
||
</button>
|
||
</div>
|
||
|
||
<div class="dialog-body space-y-4 border-t-0 pt-4">
|
||
<div class="relative shrink-0">
|
||
<input
|
||
v-model="keyword"
|
||
type="text"
|
||
:placeholder="$t('chat.searchByNameOrEmployeeId')"
|
||
class="input-field pr-10"
|
||
@keydown.enter="emit('search')"
|
||
/>
|
||
<button
|
||
type="button"
|
||
class="absolute inset-y-0 right-0 flex w-10 items-center justify-center text-muted hover:text-brand-600"
|
||
@click="emit('search')"
|
||
>
|
||
<Search class="h-4 w-4" />
|
||
</button>
|
||
</div>
|
||
|
||
<div class="max-h-[50vh] flex-1 space-y-3 overflow-y-auto pr-2 scrollbar-thin">
|
||
<div v-if="loading && page === 1" class="flex justify-center py-8">
|
||
<Loader2 class="h-6 w-6 animate-spin text-brand-500" />
|
||
</div>
|
||
<div v-else-if="options.length === 0" class="py-8 text-center text-sm text-muted">
|
||
{{ $t('chat.noData') }}
|
||
</div>
|
||
<template v-else>
|
||
<button
|
||
v-for="option in options"
|
||
:key="option.uid"
|
||
type="button"
|
||
class="flex w-full items-center justify-between rounded-2xl border border-default px-4 py-4 text-left transition hover:border-brand-300 hover:bg-brand-50/50"
|
||
@click="emit('select', option)"
|
||
>
|
||
<div class="space-y-1">
|
||
<div class="text-sm font-semibold text-primary">{{ option.name }}</div>
|
||
<div class="text-xs text-muted">UID:{{ option.uid }}</div>
|
||
</div>
|
||
<div class="text-right text-xs text-muted">
|
||
<div>{{ $t('chat.employeeId') }}:{{ option.employeeId }}</div>
|
||
<div>{{ $t('chat.name') }}:{{ option.name }}</div>
|
||
</div>
|
||
</button>
|
||
|
||
<div v-if="hasMore" class="flex items-center justify-center space-x-6 py-4">
|
||
<button
|
||
type="button"
|
||
class="text-xs text-muted hover:text-secondary disabled:opacity-50"
|
||
:disabled="loading"
|
||
@click="emit('load-all')"
|
||
>
|
||
{{ $t('chat.loadAll') }}
|
||
</button>
|
||
<button
|
||
type="button"
|
||
class="text-xs text-brand-600 hover:text-brand-700 disabled:opacity-50"
|
||
:disabled="loading"
|
||
@click="emit('load-more')"
|
||
>
|
||
{{ loading ? $t('chat.loading') : $t('chat.loadMore') }}
|
||
</button>
|
||
</div>
|
||
<div v-else class="py-4 text-center text-xs text-muted">{{ $t('chat.noMoreData') }}</div>
|
||
</template>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|