2026-02-28 23:44:38 +08:00
|
|
|
|
{{--
|
|
|
|
|
|
文件功能:后台任命管理页面
|
|
|
|
|
|
展示当前所有在职人员,支持新增任命和撤销职务
|
|
|
|
|
|
任命时可搜索用户并选择目标职务
|
|
|
|
|
|
|
|
|
|
|
|
@author ChatRoom Laravel
|
|
|
|
|
|
@version 1.0.0
|
|
|
|
|
|
--}}
|
|
|
|
|
|
|
|
|
|
|
|
@extends('admin.layouts.app')
|
|
|
|
|
|
|
|
|
|
|
|
@section('title', '任命管理')
|
|
|
|
|
|
|
|
|
|
|
|
@section('content')
|
2026-04-26 18:10:37 +08:00
|
|
|
|
@php require resource_path('views/admin/partials/list-theme.php'); @endphp
|
|
|
|
|
|
|
2026-02-28 23:44:38 +08:00
|
|
|
|
<div x-data="{
|
|
|
|
|
|
showForm: false,
|
|
|
|
|
|
username: '',
|
|
|
|
|
|
position_id: '',
|
|
|
|
|
|
remark: '',
|
|
|
|
|
|
searchResults: [],
|
|
|
|
|
|
showDropdown: false,
|
|
|
|
|
|
searching: false,
|
|
|
|
|
|
searchTimer: null,
|
|
|
|
|
|
openAppoint() {
|
|
|
|
|
|
this.username = '';
|
|
|
|
|
|
this.position_id = '';
|
|
|
|
|
|
this.remark = '';
|
|
|
|
|
|
this.searchResults = [];
|
|
|
|
|
|
this.showDropdown = false;
|
|
|
|
|
|
this.showForm = true;
|
|
|
|
|
|
},
|
|
|
|
|
|
async doSearch(val) {
|
|
|
|
|
|
this.username = val;
|
|
|
|
|
|
clearTimeout(this.searchTimer);
|
|
|
|
|
|
if (val.length < 1) {
|
|
|
|
|
|
this.searchResults = [];
|
|
|
|
|
|
this.showDropdown = false;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.searching = true;
|
|
|
|
|
|
this.searchTimer = setTimeout(async () => {
|
|
|
|
|
|
const res = await fetch(`{{ route('admin.appointments.search-users') }}?q=${encodeURIComponent(val)}`);
|
|
|
|
|
|
this.searchResults = await res.json();
|
|
|
|
|
|
this.showDropdown = this.searchResults.length > 0;
|
|
|
|
|
|
this.searching = false;
|
|
|
|
|
|
}, 250);
|
|
|
|
|
|
},
|
|
|
|
|
|
selectUser(u) {
|
|
|
|
|
|
this.username = u.username;
|
|
|
|
|
|
this.showDropdown = false;
|
|
|
|
|
|
this.searchResults = [];
|
|
|
|
|
|
}
|
|
|
|
|
|
}">
|
|
|
|
|
|
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<div class="{{ $adminListPageClass }}">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
{{-- 头部 --}}
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<div class="{{ $adminListHeaderCardClass }}">
|
|
|
|
|
|
<div class="flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<h2 class="{{ $adminListHeaderTitleClass }}">任命管理</h2>
|
|
|
|
|
|
<p class="{{ $adminListHeaderSubtitleClass }}">管理当前所有在职职位人员,执行任命或撤销操作</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="flex flex-wrap items-center gap-2">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
<a href="{{ route('admin.appointments.history') }}"
|
2026-04-26 18:10:37 +08:00
|
|
|
|
class="{{ $adminListSecondaryButtonClass }} inline-flex items-center justify-center">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
历史记录
|
|
|
|
|
|
</a>
|
|
|
|
|
|
<button @click="openAppoint()"
|
2026-04-26 18:10:37 +08:00
|
|
|
|
class="inline-flex items-center justify-center rounded-lg bg-orange-500 px-4 py-2 text-sm font-semibold text-white shadow-sm transition hover:bg-orange-600">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
+ 新增任命
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-04-26 18:10:37 +08:00
|
|
|
|
</div>
|
2026-02-28 23:44:38 +08:00
|
|
|
|
|
|
|
|
|
|
{{-- 在职人员列表 --}}
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<div class="{{ $adminListCardClass }}">
|
|
|
|
|
|
<div class="{{ $adminListSectionHeadClass }}">
|
|
|
|
|
|
<h3 class="{{ $adminListSectionTitleClass }}">在职人员列表</h3>
|
|
|
|
|
|
<p class="{{ $adminListSectionDescClass }}">展示当前所有已任命且仍在职的人员,可直接查看履职日志或执行撤销。</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="{{ $adminListTableWrapClass }}">
|
|
|
|
|
|
<table class="{{ $adminListTableClass }} whitespace-nowrap">
|
|
|
|
|
|
<thead>
|
|
|
|
|
|
<tr class="{{ $adminListTableHeadRowClass }}">
|
|
|
|
|
|
<th class="{{ $adminListTableHeadCellClass }}">用户</th>
|
|
|
|
|
|
<th class="{{ $adminListTableHeadCellClass }}">部门·职务</th>
|
|
|
|
|
|
<th class="{{ $adminListTableHeadCellClass }} text-center">等级</th>
|
|
|
|
|
|
<th class="{{ $adminListTableHeadCellClass }}">任命人</th>
|
|
|
|
|
|
<th class="{{ $adminListTableHeadCellClass }} text-center">任命时间</th>
|
|
|
|
|
|
<th class="{{ $adminListTableHeadCellClass }} text-center">在职天数</th>
|
|
|
|
|
|
<th class="{{ $adminListTableHeadCellClass }} text-right">操作</th>
|
2026-02-28 23:44:38 +08:00
|
|
|
|
</tr>
|
|
|
|
|
|
</thead>
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<tbody class="{{ $adminListTableBodyClass }}">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
@forelse ($activePositions as $up)
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<tr class="{{ $adminListTableRowClass }}">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
<td class="px-4 py-3">
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<div class="{{ $adminListPrimaryTextClass }}">{{ $up->user->username }}</div>
|
|
|
|
|
|
<div class="{{ $adminListSecondaryTextClass }}">Lv.{{ $up->user->user_level }}</div>
|
2026-02-28 23:44:38 +08:00
|
|
|
|
</td>
|
|
|
|
|
|
<td class="px-4 py-3">
|
|
|
|
|
|
<div class="flex items-center space-x-1">
|
|
|
|
|
|
<span class="text-lg">{{ $up->position->icon }}</span>
|
|
|
|
|
|
<div>
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<div class="{{ $adminListSecondaryTextClass }}">{{ $up->position->department->name }}</div>
|
|
|
|
|
|
<div class="text-sm font-semibold" style="color: {{ $up->position->department->color }}">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
{{ $up->position->name }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
<td class="px-4 py-3 text-center">
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<span class="inline-flex items-center rounded-full bg-orange-100 px-2 py-0.5 text-xs font-mono font-semibold text-orange-700">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
Lv.{{ $up->position->level }}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</td>
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<td class="px-4 py-3 {{ $adminListBodyTextClass }}">{{ $up->appointedBy?->username ?? '系统' }}</td>
|
|
|
|
|
|
<td class="px-4 py-3 text-center {{ $adminListSecondaryTextClass }}">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
{{ $up->appointed_at->format('Y-m-d') }}
|
|
|
|
|
|
</td>
|
|
|
|
|
|
<td class="px-4 py-3 text-center">
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<span class="inline-flex items-center rounded-full bg-blue-100 px-2 py-0.5 text-xs font-semibold text-blue-700">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
{{ $up->duration_days }} 天
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</td>
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<td class="px-4 py-3 text-right">
|
|
|
|
|
|
<div class="flex flex-wrap items-center justify-end gap-2">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
<a href="{{ route('admin.appointments.duty-logs', $up->id) }}"
|
2026-04-26 18:10:37 +08:00
|
|
|
|
class="{{ $adminListActionButtonClass }} bg-blue-50 text-blue-600 hover:bg-blue-600 hover:text-white">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
登录日志
|
|
|
|
|
|
</a>
|
|
|
|
|
|
<a href="{{ route('admin.appointments.authority-logs', $up->id) }}"
|
2026-04-26 18:10:37 +08:00
|
|
|
|
class="{{ $adminListActionButtonClass }} bg-purple-50 text-purple-600 hover:bg-purple-600 hover:text-white">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
操作日志
|
|
|
|
|
|
</a>
|
|
|
|
|
|
<form action="{{ route('admin.appointments.revoke', $up->id) }}" method="POST"
|
|
|
|
|
|
class="inline"
|
2026-04-25 13:31:18 +08:00
|
|
|
|
data-admin-confirm="确定撤销【{{ $up->user->username }}】的【{{ $up->position->name }}】职务?撤销后其等级将归 1。">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
@csrf @method('DELETE')
|
|
|
|
|
|
<button type="submit"
|
2026-04-26 18:10:37 +08:00
|
|
|
|
class="{{ $adminListActionButtonClass }} bg-red-50 text-red-600 hover:bg-red-600 hover:text-white">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
撤销职务
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</form>
|
2026-04-26 18:10:37 +08:00
|
|
|
|
</div>
|
2026-02-28 23:44:38 +08:00
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
@empty
|
|
|
|
|
|
<tr>
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<td colspan="7" class="{{ $adminListEmptyClass }}">暂无在职人员</td>
|
2026-02-28 23:44:38 +08:00
|
|
|
|
</tr>
|
|
|
|
|
|
@endforelse
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
</table>
|
2026-04-26 18:10:37 +08:00
|
|
|
|
</div>
|
2026-02-28 23:44:38 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{{-- 新增任命弹窗 --}}
|
|
|
|
|
|
<div x-show="showForm" style="display: none;"
|
|
|
|
|
|
class="fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4">
|
|
|
|
|
|
<div @click.away="showForm = false" class="bg-white rounded-xl shadow-2xl w-full max-w-md" x-transition>
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<div class="flex items-center justify-between rounded-t-xl border-b border-orange-800 bg-orange-700 px-6 py-4">
|
|
|
|
|
|
<h3 class="text-lg font-bold text-white">新增任命</h3>
|
2026-02-28 23:44:38 +08:00
|
|
|
|
<button @click="showForm = false"
|
2026-04-26 18:10:37 +08:00
|
|
|
|
class="text-2xl leading-none text-orange-200 transition hover:text-white">×</button>
|
2026-02-28 23:44:38 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="p-6">
|
|
|
|
|
|
<form action="{{ route('admin.appointments.store') }}" method="POST">
|
|
|
|
|
|
@csrf
|
|
|
|
|
|
<div class="space-y-4">
|
|
|
|
|
|
<div>
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<label class="{{ $adminListFilterLabelClass }}">用户名</label>
|
2026-02-28 23:44:38 +08:00
|
|
|
|
<div class="relative">
|
|
|
|
|
|
<input type="text" name="username" x-model="username" required
|
|
|
|
|
|
placeholder="输入关键字搜索用户..." @input="doSearch($event.target.value)"
|
|
|
|
|
|
@blur="setTimeout(() => showDropdown = false, 200)"
|
|
|
|
|
|
@focus="if(username.length > 0) doSearch(username)"
|
2026-04-26 18:10:37 +08:00
|
|
|
|
class="w-full {{ $adminListFilterInputClass }}" autocomplete="off">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
{{-- 搜索中指示 --}}
|
|
|
|
|
|
<span x-show="searching"
|
|
|
|
|
|
class="absolute right-2 top-2.5 text-gray-400 text-xs">搜索中…</span>
|
|
|
|
|
|
{{-- 下拉结果 --}}
|
|
|
|
|
|
<div x-show="showDropdown" style="display:none;"
|
2026-04-26 18:10:37 +08:00
|
|
|
|
class="absolute z-50 mt-1 max-h-48 w-full overflow-y-auto rounded-lg border border-orange-100 bg-white shadow-lg">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
<template x-for="u in searchResults" :key="u.id">
|
|
|
|
|
|
<div @mousedown="selectUser(u)"
|
2026-04-26 18:10:37 +08:00
|
|
|
|
class="flex cursor-pointer items-center justify-between px-3 py-2 hover:bg-orange-50">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
<span class="font-bold text-sm" x-text="u.username"></span>
|
|
|
|
|
|
<span class="text-xs text-gray-400" x-text="'Lv.' + u.user_level"></span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<div x-show="searchResults.length === 0 && !searching"
|
|
|
|
|
|
class="px-3 py-2 text-xs text-gray-400">无匹配用户(或已有职务)</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div>
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<label class="{{ $adminListFilterLabelClass }}">目标职务</label>
|
2026-02-28 23:44:38 +08:00
|
|
|
|
<select name="position_id" x-model="position_id" required
|
2026-04-26 18:10:37 +08:00
|
|
|
|
class="w-full {{ $adminListFilterInputClass }}">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
<option value="">-- 请选择职务 --</option>
|
|
|
|
|
|
@foreach ($departments as $dept)
|
|
|
|
|
|
<optgroup label="{{ $dept->name }}">
|
|
|
|
|
|
@foreach ($dept->positions as $pos)
|
|
|
|
|
|
@php
|
|
|
|
|
|
$current = $pos->active_user_positions_count ?? 0;
|
|
|
|
|
|
$max = $pos->max_persons;
|
|
|
|
|
|
$isFull = $max && $current >= $max;
|
|
|
|
|
|
$cap = $max
|
|
|
|
|
|
? "在职 {$current}/{$max} 人" . ($isFull ? ' ⚠️满' : '')
|
|
|
|
|
|
: "在职 {$current} 人·不限额";
|
|
|
|
|
|
@endphp
|
|
|
|
|
|
<option value="{{ $pos->id }}"
|
|
|
|
|
|
{{ $isFull ? 'style=color:#dc2626' : '' }}>
|
|
|
|
|
|
{{ $pos->icon }}
|
|
|
|
|
|
{{ $pos->name }}(Lv.{{ $pos->level }},{{ $cap }})
|
|
|
|
|
|
</option>
|
|
|
|
|
|
@endforeach
|
|
|
|
|
|
</optgroup>
|
|
|
|
|
|
@endforeach
|
|
|
|
|
|
</select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div>
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<label class="{{ $adminListFilterLabelClass }}">任命备注(可选)</label>
|
2026-02-28 23:44:38 +08:00
|
|
|
|
<input type="text" name="remark" x-model="remark" maxlength="255"
|
2026-04-26 18:10:37 +08:00
|
|
|
|
placeholder="例:表现优秀,特此提拔" class="w-full {{ $adminListFilterInputClass }}">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-04-26 18:10:37 +08:00
|
|
|
|
<div class="mt-4 flex justify-end gap-3 border-t border-gray-100 pt-4">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
<button type="button" @click="showForm = false"
|
2026-04-26 18:10:37 +08:00
|
|
|
|
class="{{ $adminListSecondaryButtonClass }}">取消</button>
|
2026-02-28 23:44:38 +08:00
|
|
|
|
<button type="submit"
|
2026-04-26 18:10:37 +08:00
|
|
|
|
class="rounded-lg bg-orange-500 px-4 py-2 text-sm font-semibold text-white shadow-sm transition hover:bg-orange-600">
|
2026-02-28 23:44:38 +08:00
|
|
|
|
确认任命
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</form>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-04-26 18:10:37 +08:00
|
|
|
|
</div>
|
2026-02-28 23:44:38 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
@endsection
|