feat: 第五阶段办公协同/统计报表/知识库模块
- 新增3个migration(9张表): office(6表)/report(1表)/kb(2表) - 新增9个Model + 9个Controller - 新增43条API路由(总计305条) - 新增3个前端API模块 + 10个管理页面 - 迁移运行通过, vite build验证通过
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Kb;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Kb\KbArticle;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class KbArticleController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = KbArticle::query()->with(['category', 'author']);
|
||||
$query->when($request->category_id, fn($q, $v) => $q->where('category_id', $v));
|
||||
$query->when($request->filled('status'), fn($q) => $q->where('status', $request->status));
|
||||
$query->when($request->filled('visibility'), fn($q) => $q->where('visibility', $request->visibility));
|
||||
$query->when($request->keyword, fn($q, $v) => $q->where('title', 'like', "%{$v}%"));
|
||||
|
||||
return $this->paginate($query->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'content' => 'nullable|string',
|
||||
'category_id' => 'nullable|exists:kb_categories,id',
|
||||
'visibility' => 'nullable|integer|in:1,2',
|
||||
'cover_image' => 'nullable|string|max:255',
|
||||
'attachments' => 'nullable|array',
|
||||
]);
|
||||
$validated['author_id'] = auth()->id();
|
||||
$validated['status'] = 0;
|
||||
|
||||
$article = KbArticle::create($validated);
|
||||
return $this->success($article->load(['category', 'author']));
|
||||
}
|
||||
|
||||
public function show(KbArticle $kbArticle): JsonResponse
|
||||
{
|
||||
$kbArticle->increment('views');
|
||||
return $this->success($kbArticle->load(['category', 'author']));
|
||||
}
|
||||
|
||||
public function update(Request $request, KbArticle $kbArticle): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'title' => 'sometimes|string|max:255',
|
||||
'content' => 'nullable|string',
|
||||
'category_id' => 'nullable|exists:kb_categories,id',
|
||||
'visibility' => 'nullable|integer|in:1,2',
|
||||
'cover_image' => 'nullable|string|max:255',
|
||||
'attachments' => 'nullable|array',
|
||||
]);
|
||||
$kbArticle->update($validated);
|
||||
return $this->success($kbArticle);
|
||||
}
|
||||
|
||||
public function destroy(KbArticle $kbArticle): JsonResponse
|
||||
{
|
||||
$kbArticle->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
|
||||
public function publish(KbArticle $kbArticle): JsonResponse
|
||||
{
|
||||
if ($kbArticle->status >= 2) {
|
||||
return $this->error('当前状态不允许发布');
|
||||
}
|
||||
$kbArticle->update(['status' => 2, 'published_at' => now()]);
|
||||
return $this->success($kbArticle);
|
||||
}
|
||||
|
||||
public function offline(KbArticle $kbArticle): JsonResponse
|
||||
{
|
||||
if ($kbArticle->status !== 2) {
|
||||
return $this->error('仅已发布文章可下架');
|
||||
}
|
||||
$kbArticle->update(['status' => 3]);
|
||||
return $this->success($kbArticle);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Kb;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Kb\KbCategory;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class KbCategoryController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = KbCategory::query()->with('children');
|
||||
$query->when($request->filled('status'), fn($q) => $q->where('status', $request->status));
|
||||
$query->where('parent_id', 0);
|
||||
|
||||
return $this->success($query->orderBy('sort')->orderBy('id')->get());
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:100',
|
||||
'parent_id' => 'nullable|integer|min:0',
|
||||
'sort' => 'nullable|integer',
|
||||
'status' => 'nullable|integer|in:0,1',
|
||||
]);
|
||||
$validated['parent_id'] = $validated['parent_id'] ?? 0;
|
||||
|
||||
$category = KbCategory::create($validated);
|
||||
return $this->success($category);
|
||||
}
|
||||
|
||||
public function show(KbCategory $kbCategory): JsonResponse
|
||||
{
|
||||
return $this->success($kbCategory->load('children'));
|
||||
}
|
||||
|
||||
public function update(Request $request, KbCategory $kbCategory): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'sometimes|string|max:100',
|
||||
'parent_id' => 'nullable|integer|min:0',
|
||||
'sort' => 'nullable|integer',
|
||||
'status' => 'nullable|integer|in:0,1',
|
||||
]);
|
||||
$kbCategory->update($validated);
|
||||
return $this->success($kbCategory);
|
||||
}
|
||||
|
||||
public function destroy(KbCategory $kbCategory): JsonResponse
|
||||
{
|
||||
if ($kbCategory->children()->exists()) {
|
||||
return $this->error('请先删除子分类');
|
||||
}
|
||||
if ($kbCategory->articles()->exists()) {
|
||||
return $this->error('该分类下还有文章,无法删除');
|
||||
}
|
||||
$kbCategory->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Office;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Office\Announcement;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AnnouncementController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Announcement::query()->with('author');
|
||||
$query->when($request->type, fn($q, $v) => $q->where('type', $v));
|
||||
$query->when($request->has('publish_status'), fn($q) => $q->where('publish_status', $request->publish_status));
|
||||
|
||||
return $this->paginate($query->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'content' => 'required|string',
|
||||
'type' => 'sometimes|integer|in:1,2,3',
|
||||
'is_top' => 'sometimes|boolean',
|
||||
]);
|
||||
$validated['author_id'] = auth()->id();
|
||||
|
||||
return $this->success(Announcement::create($validated));
|
||||
}
|
||||
|
||||
public function show(Announcement $announcement): JsonResponse
|
||||
{
|
||||
return $this->success($announcement->load('author'));
|
||||
}
|
||||
|
||||
public function update(Request $request, Announcement $announcement): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'title' => 'sometimes|string|max:255',
|
||||
'content' => 'sometimes|string',
|
||||
'type' => 'sometimes|integer|in:1,2,3',
|
||||
'is_top' => 'sometimes|boolean',
|
||||
]);
|
||||
$announcement->update($validated);
|
||||
|
||||
return $this->success($announcement);
|
||||
}
|
||||
|
||||
public function destroy(Announcement $announcement): JsonResponse
|
||||
{
|
||||
$announcement->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
|
||||
public function publish(Announcement $announcement): JsonResponse
|
||||
{
|
||||
if ($announcement->publish_status === 1) {
|
||||
return $this->error('该公告已发布', 40001);
|
||||
}
|
||||
$announcement->update([
|
||||
'publish_status' => 1,
|
||||
'published_at' => now(),
|
||||
]);
|
||||
|
||||
return $this->success($announcement);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Office;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Office\Approval;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ApprovalController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Approval::query()->with(['template', 'applicant']);
|
||||
$query->when($request->has('status'), fn($q) => $q->where('status', $request->status));
|
||||
$query->when($request->applicant_id, fn($q, $v) => $q->where('applicant_id', $v));
|
||||
|
||||
return $this->paginate($query->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'template_id' => 'nullable|exists:approval_templates,id',
|
||||
'form_data' => 'nullable|array',
|
||||
'related_type' => 'nullable|string|max:50',
|
||||
'related_id' => 'nullable|integer',
|
||||
]);
|
||||
$validated['applicant_id'] = auth()->id();
|
||||
$validated['status'] = 0;
|
||||
|
||||
return $this->success(Approval::create($validated));
|
||||
}
|
||||
|
||||
public function show(Approval $approval): JsonResponse
|
||||
{
|
||||
return $this->success($approval->load(['template', 'applicant', 'nodes.approver']));
|
||||
}
|
||||
|
||||
public function update(Request $request, Approval $approval): JsonResponse
|
||||
{
|
||||
if ($approval->status > 1) {
|
||||
return $this->error('该审批已完结,无法修改', 40001);
|
||||
}
|
||||
$validated = $request->validate([
|
||||
'title' => 'sometimes|string|max:255',
|
||||
'form_data' => 'nullable|array',
|
||||
]);
|
||||
$approval->update($validated);
|
||||
|
||||
return $this->success($approval);
|
||||
}
|
||||
|
||||
public function destroy(Approval $approval): JsonResponse
|
||||
{
|
||||
if ($approval->status > 1) {
|
||||
return $this->error('该审批已完结,无法删除', 40001);
|
||||
}
|
||||
$approval->delete();
|
||||
|
||||
return $this->success(null);
|
||||
}
|
||||
|
||||
public function approve(Approval $approval): JsonResponse
|
||||
{
|
||||
$node = $approval->nodes()
|
||||
->where('approver_id', auth()->id())
|
||||
->where('action', 0)
|
||||
->where('node_order', $approval->current_node)
|
||||
->first();
|
||||
|
||||
if (!$node) {
|
||||
return $this->error('无待处理的审批节点', 40001);
|
||||
}
|
||||
|
||||
$node->update(['action' => 1, 'acted_at' => now()]);
|
||||
|
||||
$pendingNodes = $approval->nodes()->where('action', 0)->exists();
|
||||
if (!$pendingNodes) {
|
||||
$approval->update(['status' => 2]);
|
||||
} else {
|
||||
$approval->update([
|
||||
'status' => 1,
|
||||
'current_node' => $approval->current_node + 1,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->success($approval->load('nodes'));
|
||||
}
|
||||
|
||||
public function reject(Request $request, Approval $approval): JsonResponse
|
||||
{
|
||||
$node = $approval->nodes()
|
||||
->where('approver_id', auth()->id())
|
||||
->where('action', 0)
|
||||
->where('node_order', $approval->current_node)
|
||||
->first();
|
||||
|
||||
if (!$node) {
|
||||
return $this->error('无待处理的审批节点', 40001);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'comment' => 'nullable|string|max:255',
|
||||
]);
|
||||
|
||||
$node->update([
|
||||
'action' => 2,
|
||||
'comment' => $validated['comment'] ?? null,
|
||||
'acted_at' => now(),
|
||||
]);
|
||||
$approval->update(['status' => 3]);
|
||||
|
||||
return $this->success($approval->load('nodes'));
|
||||
}
|
||||
|
||||
public function withdraw(Approval $approval): JsonResponse
|
||||
{
|
||||
if ($approval->status > 1) {
|
||||
return $this->error('该审批已完结,无法撤回', 40001);
|
||||
}
|
||||
$approval->update(['status' => 4]);
|
||||
|
||||
return $this->success($approval);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Office;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Office\ApprovalTemplate;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ApprovalTemplateController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = ApprovalTemplate::query();
|
||||
$query->when($request->type, fn($q, $v) => $q->where('type', $v));
|
||||
$query->when($request->has('status'), fn($q) => $q->where('status', $request->status));
|
||||
|
||||
return $this->paginate($query->orderBy('sort')->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:100',
|
||||
'type' => 'required|integer|in:1,2,3,4,5',
|
||||
'form_fields' => 'nullable|array',
|
||||
'flow_nodes' => 'nullable|array',
|
||||
'status' => 'sometimes|integer|in:0,1',
|
||||
'sort' => 'sometimes|integer',
|
||||
]);
|
||||
|
||||
return $this->success(ApprovalTemplate::create($validated));
|
||||
}
|
||||
|
||||
public function show(ApprovalTemplate $approvalTemplate): JsonResponse
|
||||
{
|
||||
return $this->success($approvalTemplate);
|
||||
}
|
||||
|
||||
public function update(Request $request, ApprovalTemplate $approvalTemplate): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'sometimes|string|max:100',
|
||||
'type' => 'sometimes|integer|in:1,2,3,4,5',
|
||||
'form_fields' => 'nullable|array',
|
||||
'flow_nodes' => 'nullable|array',
|
||||
'status' => 'sometimes|integer|in:0,1',
|
||||
'sort' => 'sometimes|integer',
|
||||
]);
|
||||
$approvalTemplate->update($validated);
|
||||
|
||||
return $this->success($approvalTemplate);
|
||||
}
|
||||
|
||||
public function destroy(ApprovalTemplate $approvalTemplate): JsonResponse
|
||||
{
|
||||
$approvalTemplate->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Office;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Office\Handover;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HandoverController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Handover::query()->with(['handoverUser', 'receiverUser']);
|
||||
$query->when($request->shift_date, fn($q, $v) => $q->where('shift_date', $v));
|
||||
$query->when($request->shift_type, fn($q, $v) => $q->where('shift_type', $v));
|
||||
|
||||
return $this->paginate($query->latest('created_at')->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'shift_date' => 'required|date',
|
||||
'shift_type' => 'required|integer|in:1,2,3,4',
|
||||
'content' => 'required|string',
|
||||
'issues' => 'nullable|string',
|
||||
]);
|
||||
$validated['handover_user_id'] = auth()->id();
|
||||
|
||||
return $this->success(Handover::create($validated));
|
||||
}
|
||||
|
||||
public function show(Handover $handover): JsonResponse
|
||||
{
|
||||
return $this->success($handover->load(['handoverUser', 'receiverUser']));
|
||||
}
|
||||
|
||||
public function confirm(Handover $handover): JsonResponse
|
||||
{
|
||||
if ($handover->status === 1) {
|
||||
return $this->error('该交接班已确认', 40001);
|
||||
}
|
||||
$handover->update([
|
||||
'receiver_user_id' => auth()->id(),
|
||||
'status' => 1,
|
||||
'confirmed_at' => now(),
|
||||
]);
|
||||
|
||||
return $this->success($handover);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Office;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Office\Notification;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class NotificationController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Notification::query()->where('user_id', auth()->id());
|
||||
$query->when($request->type, fn($q, $v) => $q->where('type', $v));
|
||||
$query->when($request->has('is_read'), fn($q) => $q->where('is_read', $request->boolean('is_read')));
|
||||
|
||||
return $this->paginate($query->latest('created_at')->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function markRead(Notification $notification): JsonResponse
|
||||
{
|
||||
if ($notification->user_id !== auth()->id()) {
|
||||
return $this->error('无权操作', 40003, 403);
|
||||
}
|
||||
$notification->update(['is_read' => true, 'read_at' => now()]);
|
||||
|
||||
return $this->success($notification);
|
||||
}
|
||||
|
||||
public function markAllRead(): JsonResponse
|
||||
{
|
||||
Notification::query()
|
||||
->where('user_id', auth()->id())
|
||||
->where('is_read', false)
|
||||
->update(['is_read' => true, 'read_at' => now()]);
|
||||
|
||||
return $this->success(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Report;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Crm\Contract;
|
||||
use App\Models\Crm\Customer;
|
||||
use App\Models\Crm\Lead;
|
||||
use App\Models\Finance\FinanceRecord;
|
||||
use App\Models\Room\Room;
|
||||
use App\Models\Room\RoomType;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ReportController extends Controller
|
||||
{
|
||||
public function overview(Request $request): JsonResponse
|
||||
{
|
||||
$data = [
|
||||
'customer_count' => Customer::count(),
|
||||
'contract_amount' => Contract::where('status', 2)->sum('actual_amount'),
|
||||
'room_count' => Room::count(),
|
||||
'occupied_count' => Room::where('status', 3)->count(),
|
||||
'today_revenue' => FinanceRecord::where('type', 1)->where('audit_status', 1)
|
||||
->whereDate('record_date', today())->sum('amount'),
|
||||
'month_revenue' => FinanceRecord::where('type', 1)->where('audit_status', 1)
|
||||
->whereMonth('record_date', now()->month)
|
||||
->whereYear('record_date', now()->year)->sum('amount'),
|
||||
];
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
public function revenue(Request $request): JsonResponse
|
||||
{
|
||||
$year = $request->input('year', now()->year);
|
||||
$records = FinanceRecord::where('audit_status', 1)
|
||||
->whereYear('record_date', $year)
|
||||
->selectRaw('MONTH(record_date) as month, type, SUM(amount) as total')
|
||||
->groupBy('month', 'type')
|
||||
->get();
|
||||
return $this->success($records);
|
||||
}
|
||||
|
||||
public function occupancy(Request $request): JsonResponse
|
||||
{
|
||||
$data = RoomType::withCount([
|
||||
'rooms',
|
||||
'rooms as occupied_count' => fn($q) => $q->where('status', 3),
|
||||
])->get();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
public function crmConversion(Request $request): JsonResponse
|
||||
{
|
||||
$data = [
|
||||
'total_leads' => Lead::count(),
|
||||
'following' => Lead::where('status', 2)->count(),
|
||||
'contracted' => Lead::where('status', 5)->count(),
|
||||
'by_channel' => Lead::selectRaw('channel_id, COUNT(*) as total, SUM(CASE WHEN status=5 THEN 1 ELSE 0 END) as converted')
|
||||
->groupBy('channel_id')
|
||||
->with('channel:id,name')
|
||||
->get(),
|
||||
];
|
||||
return $this->success($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Report;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Report\ReportExport;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ReportExportController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = ReportExport::query()->with('operator');
|
||||
$query->when($request->type, fn($q, $v) => $q->where('type', $v));
|
||||
$query->when($request->filled('status'), fn($q) => $q->where('status', $request->status));
|
||||
|
||||
return $this->paginate($query->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'type' => 'required|string|max:50',
|
||||
'params' => 'nullable|array',
|
||||
]);
|
||||
$validated['operator_id'] = auth()->id();
|
||||
$validated['status'] = 0;
|
||||
|
||||
$export = ReportExport::create($validated);
|
||||
return $this->success($export);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Kb;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class KbArticle extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'category_id', 'title', 'content', 'author_id',
|
||||
'status', 'visibility', 'cover_image', 'attachments',
|
||||
'views', 'likes', 'favorites', 'published_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => 'integer',
|
||||
'visibility' => 'integer',
|
||||
'views' => 'integer',
|
||||
'likes' => 'integer',
|
||||
'favorites' => 'integer',
|
||||
'attachments' => 'array',
|
||||
'published_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(KbCategory::class, 'category_id');
|
||||
}
|
||||
|
||||
public function author(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'author_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Kb;
|
||||
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class KbCategory extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'parent_id', 'name', 'sort', 'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'sort' => 'integer',
|
||||
'status' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function children(): HasMany
|
||||
{
|
||||
return $this->hasMany(self::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function parent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function articles(): HasMany
|
||||
{
|
||||
return $this->hasMany(KbArticle::class, 'category_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Office;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Announcement extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'title', 'content', 'type', 'is_top',
|
||||
'publish_status', 'published_at', 'author_id',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'integer',
|
||||
'publish_status' => 'integer',
|
||||
'is_top' => 'boolean',
|
||||
'published_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function author(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'author_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Office;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Approval extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'template_id', 'title', 'applicant_id', 'form_data',
|
||||
'status', 'current_node', 'related_type', 'related_id',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => 'integer',
|
||||
'current_node' => 'integer',
|
||||
'form_data' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function template(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ApprovalTemplate::class, 'template_id');
|
||||
}
|
||||
|
||||
public function applicant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'applicant_id');
|
||||
}
|
||||
|
||||
public function nodes(): HasMany
|
||||
{
|
||||
return $this->hasMany(ApprovalNode::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Office;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ApprovalNode extends Model
|
||||
{
|
||||
const UPDATED_AT = null;
|
||||
|
||||
protected $fillable = [
|
||||
'approval_id', 'node_order', 'approver_id', 'action', 'comment', 'acted_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'node_order' => 'integer',
|
||||
'action' => 'integer',
|
||||
'acted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function approval(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Approval::class);
|
||||
}
|
||||
|
||||
public function approver(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'approver_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Office;
|
||||
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ApprovalTemplate extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'name', 'type', 'form_fields', 'flow_nodes', 'status', 'sort',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'integer',
|
||||
'status' => 'integer',
|
||||
'sort' => 'integer',
|
||||
'form_fields' => 'array',
|
||||
'flow_nodes' => 'array',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Office;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Handover extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
const UPDATED_AT = null;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'shift_date', 'shift_type', 'handover_user_id',
|
||||
'receiver_user_id', 'content', 'issues', 'status', 'confirmed_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'shift_type' => 'integer',
|
||||
'status' => 'integer',
|
||||
'shift_date' => 'date',
|
||||
'confirmed_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function handoverUser(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'handover_user_id');
|
||||
}
|
||||
|
||||
public function receiverUser(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'receiver_user_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Office;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Notification extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
const UPDATED_AT = null;
|
||||
|
||||
protected $table = 'notifications';
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'user_id', 'title', 'content', 'type',
|
||||
'related_type', 'related_id', 'is_read', 'read_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'integer',
|
||||
'is_read' => 'boolean',
|
||||
'read_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Report;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ReportExport extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
const UPDATED_AT = null;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'name', 'type', 'params', 'file_path', 'status', 'operator_id',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'params' => 'array',
|
||||
'status' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function operator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'operator_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// 审批模板
|
||||
Schema::create('approval_templates', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('store_id')->index();
|
||||
$table->string('name', 100);
|
||||
$table->tinyInteger('type')->comment('1=请假 2=采购 3=合同 4=退款 5=换房');
|
||||
$table->json('form_fields')->nullable();
|
||||
$table->json('flow_nodes')->nullable();
|
||||
$table->tinyInteger('status')->default(1);
|
||||
$table->integer('sort')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// 审批记录
|
||||
Schema::create('approvals', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('store_id')->index();
|
||||
$table->unsignedBigInteger('template_id')->nullable();
|
||||
$table->string('title');
|
||||
$table->unsignedBigInteger('applicant_id')->index();
|
||||
$table->json('form_data')->nullable();
|
||||
$table->tinyInteger('status')->default(0)->comment('0=待审批 1=审批中 2=已通过 3=已驳回 4=已撤回');
|
||||
$table->integer('current_node')->default(0);
|
||||
$table->string('related_type', 50)->nullable();
|
||||
$table->unsignedBigInteger('related_id')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// 审批节点
|
||||
Schema::create('approval_nodes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('approval_id')->index();
|
||||
$table->integer('node_order')->default(0);
|
||||
$table->unsignedBigInteger('approver_id');
|
||||
$table->tinyInteger('action')->default(0)->comment('0=待处理 1=通过 2=驳回');
|
||||
$table->string('comment')->nullable();
|
||||
$table->timestamp('acted_at')->nullable();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
// 公告
|
||||
Schema::create('announcements', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('store_id')->index();
|
||||
$table->string('title');
|
||||
$table->text('content');
|
||||
$table->tinyInteger('type')->default(1)->comment('1=通知 2=公告 3=制度');
|
||||
$table->boolean('is_top')->default(false);
|
||||
$table->tinyInteger('publish_status')->default(0)->comment('0=草稿 1=已发布');
|
||||
$table->timestamp('published_at')->nullable();
|
||||
$table->unsignedBigInteger('author_id')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// 交接班
|
||||
Schema::create('handovers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('store_id')->index();
|
||||
$table->date('shift_date');
|
||||
$table->tinyInteger('shift_type')->comment('1=早班 2=中班 3=晚班 4=夜班');
|
||||
$table->unsignedBigInteger('handover_user_id');
|
||||
$table->unsignedBigInteger('receiver_user_id')->nullable();
|
||||
$table->text('content');
|
||||
$table->text('issues')->nullable();
|
||||
$table->tinyInteger('status')->default(0)->comment('0=待确认 1=已确认');
|
||||
$table->timestamp('confirmed_at')->nullable();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
// 消息通知
|
||||
Schema::create('notifications', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('store_id')->index();
|
||||
$table->unsignedBigInteger('user_id')->index();
|
||||
$table->string('title');
|
||||
$table->string('content')->nullable();
|
||||
$table->tinyInteger('type')->default(1)->comment('1=系统 2=审批 3=待办 4=提醒');
|
||||
$table->string('related_type', 50)->nullable();
|
||||
$table->unsignedBigInteger('related_id')->nullable();
|
||||
$table->boolean('is_read')->default(false);
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('notifications');
|
||||
Schema::dropIfExists('handovers');
|
||||
Schema::dropIfExists('announcements');
|
||||
Schema::dropIfExists('approval_nodes');
|
||||
Schema::dropIfExists('approvals');
|
||||
Schema::dropIfExists('approval_templates');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('report_exports', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('store_id')->index();
|
||||
$table->string('name');
|
||||
$table->string('type', 50)->comment('report type key');
|
||||
$table->json('params')->nullable();
|
||||
$table->string('file_path')->nullable();
|
||||
$table->tinyInteger('status')->default(0)->comment('0=生成中 1=已完成 2=失败');
|
||||
$table->unsignedBigInteger('operator_id')->nullable();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('report_exports');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('kb_categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('store_id')->index();
|
||||
$table->unsignedBigInteger('parent_id')->default(0)->index();
|
||||
$table->string('name', 100);
|
||||
$table->integer('sort')->default(0);
|
||||
$table->tinyInteger('status')->default(1);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('kb_articles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('store_id')->index();
|
||||
$table->unsignedBigInteger('category_id')->nullable()->index();
|
||||
$table->string('title');
|
||||
$table->longText('content')->nullable();
|
||||
$table->unsignedBigInteger('author_id')->nullable();
|
||||
$table->tinyInteger('status')->default(0)->comment('0=草稿 1=待审核 2=已发布 3=已下架');
|
||||
$table->tinyInteger('visibility')->default(1)->comment('1=内部 2=公开');
|
||||
$table->string('cover_image')->nullable();
|
||||
$table->json('attachments')->nullable();
|
||||
$table->unsignedInteger('views')->default(0);
|
||||
$table->unsignedInteger('likes')->default(0);
|
||||
$table->unsignedInteger('favorites')->default(0);
|
||||
$table->timestamp('published_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->fullText(['title', 'content']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('kb_articles');
|
||||
Schema::dropIfExists('kb_categories');
|
||||
}
|
||||
};
|
||||
@@ -55,6 +55,15 @@ use App\Http\Controllers\Admin\Hr\ScheduleController;
|
||||
use App\Http\Controllers\Admin\Hr\AttendanceRecordController;
|
||||
use App\Http\Controllers\Admin\Hr\LeaveRequestController;
|
||||
use App\Http\Controllers\Admin\Hr\SalaryRecordController;
|
||||
use App\Http\Controllers\Admin\Office\ApprovalTemplateController;
|
||||
use App\Http\Controllers\Admin\Office\ApprovalController;
|
||||
use App\Http\Controllers\Admin\Office\AnnouncementController;
|
||||
use App\Http\Controllers\Admin\Office\HandoverController;
|
||||
use App\Http\Controllers\Admin\Office\NotificationController;
|
||||
use App\Http\Controllers\Admin\Report\ReportController;
|
||||
use App\Http\Controllers\Admin\Report\ReportExportController;
|
||||
use App\Http\Controllers\Admin\Kb\KbCategoryController;
|
||||
use App\Http\Controllers\Admin\Kb\KbArticleController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -308,4 +317,55 @@ Route::middleware(['auth:sanctum', 'store', 'oplog'])->group(function () {
|
||||
Route::put('salaries/{salaryRecord}/confirm', [SalaryRecordController::class, 'confirm']);
|
||||
Route::put('salaries/{salaryRecord}/pay', [SalaryRecordController::class, 'pay']);
|
||||
});
|
||||
|
||||
// --- 办公协同模块 ---
|
||||
Route::prefix('office')->group(function () {
|
||||
// 审批模板
|
||||
Route::apiResource('approval-templates', ApprovalTemplateController::class);
|
||||
|
||||
// 审批管理
|
||||
Route::apiResource('approvals', ApprovalController::class)->except(['update']);
|
||||
Route::put('approvals/{approval}/approve', [ApprovalController::class, 'approve']);
|
||||
Route::put('approvals/{approval}/reject', [ApprovalController::class, 'reject']);
|
||||
Route::put('approvals/{approval}/withdraw', [ApprovalController::class, 'withdraw']);
|
||||
|
||||
// 公告管理
|
||||
Route::apiResource('announcements', AnnouncementController::class);
|
||||
Route::put('announcements/{announcement}/publish', [AnnouncementController::class, 'publish']);
|
||||
|
||||
// 交接班
|
||||
Route::get('handovers', [HandoverController::class, 'index']);
|
||||
Route::post('handovers', [HandoverController::class, 'store']);
|
||||
Route::get('handovers/{handover}', [HandoverController::class, 'show']);
|
||||
Route::put('handovers/{handover}/confirm', [HandoverController::class, 'confirm']);
|
||||
|
||||
// 消息通知
|
||||
Route::get('notifications', [NotificationController::class, 'index']);
|
||||
Route::put('notifications/{notification}/read', [NotificationController::class, 'markRead']);
|
||||
Route::put('notifications/read-all', [NotificationController::class, 'markAllRead']);
|
||||
});
|
||||
|
||||
// --- 统计报表模块 ---
|
||||
Route::prefix('report')->group(function () {
|
||||
// 聚合报表
|
||||
Route::get('overview', [ReportController::class, 'overview']);
|
||||
Route::get('revenue', [ReportController::class, 'revenue']);
|
||||
Route::get('occupancy', [ReportController::class, 'occupancy']);
|
||||
Route::get('crm-conversion', [ReportController::class, 'crmConversion']);
|
||||
|
||||
// 导出记录
|
||||
Route::get('exports', [ReportExportController::class, 'index']);
|
||||
Route::post('exports', [ReportExportController::class, 'store']);
|
||||
});
|
||||
|
||||
// --- 知识库模块 ---
|
||||
Route::prefix('kb')->group(function () {
|
||||
// 知识分类
|
||||
Route::apiResource('categories', KbCategoryController::class);
|
||||
|
||||
// 知识文章
|
||||
Route::apiResource('articles', KbArticleController::class);
|
||||
Route::put('articles/{kbArticle}/publish', [KbArticleController::class, 'publish']);
|
||||
Route::put('articles/{kbArticle}/offline', [KbArticleController::class, 'offline']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
// ─── KB Categories ───────────────────────────────────────────────────────────
|
||||
export const kbCategoryApi = {
|
||||
getList: (params) => request.get('/kb/categories', { params }),
|
||||
getDetail: (id) => request.get(`/kb/categories/${id}`),
|
||||
create: (data) => request.post('/kb/categories', data),
|
||||
update: (id, data) => request.put(`/kb/categories/${id}`, data),
|
||||
delete: (id) => request.delete(`/kb/categories/${id}`)
|
||||
}
|
||||
|
||||
// ─── KB Articles ─────────────────────────────────────────────────────────────
|
||||
export const kbArticleApi = {
|
||||
getList: (params) => request.get('/kb/articles', { params }),
|
||||
getDetail: (id) => request.get(`/kb/articles/${id}`),
|
||||
create: (data) => request.post('/kb/articles', data),
|
||||
update: (id, data) => request.put(`/kb/articles/${id}`, data),
|
||||
delete: (id) => request.delete(`/kb/articles/${id}`),
|
||||
publish: (id) => request.put(`/kb/articles/${id}/publish`),
|
||||
offline: (id) => request.put(`/kb/articles/${id}/offline`)
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
// ─── Approval Templates ──────────────────────────────────────────────────────
|
||||
export const approvalTemplateApi = {
|
||||
getList: (params) => request.get('/office/approval-templates', { params }),
|
||||
getDetail: (id) => request.get(`/office/approval-templates/${id}`),
|
||||
create: (data) => request.post('/office/approval-templates', data),
|
||||
update: (id, data) => request.put(`/office/approval-templates/${id}`, data),
|
||||
delete: (id) => request.delete(`/office/approval-templates/${id}`)
|
||||
}
|
||||
|
||||
// ─── Approvals ───────────────────────────────────────────────────────────────
|
||||
export const approvalApi = {
|
||||
getList: (params) => request.get('/office/approvals', { params }),
|
||||
getDetail: (id) => request.get(`/office/approvals/${id}`),
|
||||
create: (data) => request.post('/office/approvals', data),
|
||||
approve: (id, data) => request.put(`/office/approvals/${id}/approve`, data),
|
||||
reject: (id, data) => request.put(`/office/approvals/${id}/reject`, data),
|
||||
withdraw: (id) => request.put(`/office/approvals/${id}/withdraw`)
|
||||
}
|
||||
|
||||
// ─── Announcements ───────────────────────────────────────────────────────────
|
||||
export const announcementApi = {
|
||||
getList: (params) => request.get('/office/announcements', { params }),
|
||||
getDetail: (id) => request.get(`/office/announcements/${id}`),
|
||||
create: (data) => request.post('/office/announcements', data),
|
||||
update: (id, data) => request.put(`/office/announcements/${id}`, data),
|
||||
delete: (id) => request.delete(`/office/announcements/${id}`),
|
||||
publish: (id) => request.put(`/office/announcements/${id}/publish`)
|
||||
}
|
||||
|
||||
// ─── Handovers ───────────────────────────────────────────────────────────────
|
||||
export const handoverApi = {
|
||||
getList: (params) => request.get('/office/handovers', { params }),
|
||||
create: (data) => request.post('/office/handovers', data),
|
||||
confirm: (id) => request.put(`/office/handovers/${id}/confirm`)
|
||||
}
|
||||
|
||||
// ─── Notifications ───────────────────────────────────────────────────────────
|
||||
export const notificationApi = {
|
||||
getList: (params) => request.get('/office/notifications', { params }),
|
||||
markRead: (id) => request.put(`/office/notifications/${id}/read`),
|
||||
markAllRead: () => request.put('/office/notifications/read-all')
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
// ─── Report Dashboards ───────────────────────────────────────────────────────
|
||||
export const reportApi = {
|
||||
overview: (params) => request.get('/report/overview', { params }),
|
||||
revenue: (params) => request.get('/report/revenue', { params }),
|
||||
occupancy: (params) => request.get('/report/occupancy', { params }),
|
||||
crmConversion: (params) => request.get('/report/crm-conversion', { params })
|
||||
}
|
||||
|
||||
// ─── Report Exports ──────────────────────────────────────────────────────────
|
||||
export const reportExportApi = {
|
||||
getList: (params) => request.get('/report/exports', { params }),
|
||||
create: (data) => request.post('/report/exports', data)
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { kbArticleApi, kbCategoryApi } from '@/api/kb.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const categoryList = ref([])
|
||||
|
||||
const searchForm = reactive({ keyword: '', category_id: '', status: '', visibility: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({ id: null, title: '', category_id: '', content: '', visibility: 1, cover_image: '' })
|
||||
const isEdit = ref(false)
|
||||
const formRules = {
|
||||
title: [{ required: true, message: '请输入文章标题', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const statusMap = { 0: '草稿', 1: '待审核', 2: '已发布', 3: '已下架' }
|
||||
const statusType = { 0: 'info', 1: 'warning', 2: 'success', 3: 'danger' }
|
||||
const visibilityMap = { 1: '内部', 2: '公开' }
|
||||
|
||||
async function fetchCategories() {
|
||||
try {
|
||||
const res = await kbCategoryApi.getList({ per_page: 200 })
|
||||
categoryList.value = res.data?.list || res.data?.data || []
|
||||
} catch { categoryList.value = [] }
|
||||
}
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await kbArticleApi.getList({ ...searchForm, ...pagination })
|
||||
tableData.value = res.data?.list || res.data?.data || []
|
||||
total.value = res.data?.total || 0
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() { Object.assign(searchForm, { keyword: '', category_id: '', status: '', visibility: '' }); handleSearch() }
|
||||
|
||||
function handleAdd() {
|
||||
isEdit.value = false
|
||||
Object.assign(form, { id: null, title: '', category_id: '', content: '', visibility: 1, cover_image: '' })
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleEdit(row) {
|
||||
isEdit.value = true
|
||||
Object.assign(form, {
|
||||
id: row.id,
|
||||
title: row.title,
|
||||
category_id: row.category_id || '',
|
||||
content: row.content || '',
|
||||
visibility: row.visibility || 1,
|
||||
cover_image: row.cover_image || ''
|
||||
})
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!formRef.value) return
|
||||
await formRef.value.validate(async (valid) => {
|
||||
if (!valid) return
|
||||
submitLoading.value = true
|
||||
try {
|
||||
if (isEdit.value) { await kbArticleApi.update(form.id, form); ElMessage.success('更新成功') }
|
||||
else { await kbArticleApi.create(form); ElMessage.success('创建成功') }
|
||||
dialogVisible.value = false; fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
await ElMessageBox.confirm(`确定删除文章「${row.title}」吗?`, '删除确认', { type: 'warning' })
|
||||
await kbArticleApi.delete(row.id); ElMessage.success('删除成功'); fetchList()
|
||||
}
|
||||
|
||||
async function handlePublish(row) {
|
||||
await ElMessageBox.confirm(`确定发布文章「${row.title}」吗?`, '发布确认', { type: 'info' })
|
||||
await kbArticleApi.publish(row.id); ElMessage.success('发布成功'); fetchList()
|
||||
}
|
||||
|
||||
async function handleOffline(row) {
|
||||
await ElMessageBox.confirm(`确定下架文章「${row.title}」吗?`, '下架确认', { type: 'warning' })
|
||||
await kbArticleApi.offline(row.id); ElMessage.success('下架成功'); fetchList()
|
||||
}
|
||||
|
||||
function handlePageChange(val) { pagination.page = val; fetchList() }
|
||||
function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() }
|
||||
onMounted(() => { fetchCategories(); fetchList() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="search-bar">
|
||||
<el-input v-model="searchForm.keyword" placeholder="标题搜索" style="width:180px" clearable @keydown.enter="handleSearch" />
|
||||
<el-select v-model="searchForm.category_id" placeholder="分类" clearable style="width:150px">
|
||||
<el-option v-for="c in categoryList" :key="c.id" :label="c.name" :value="c.id" />
|
||||
</el-select>
|
||||
<el-select v-model="searchForm.status" placeholder="状态" clearable style="width:120px">
|
||||
<el-option v-for="(v, k) in statusMap" :key="k" :label="v" :value="Number(k)" />
|
||||
</el-select>
|
||||
<el-select v-model="searchForm.visibility" placeholder="可见范围" clearable style="width:120px">
|
||||
<el-option v-for="(v, k) in visibilityMap" :key="k" :label="v" :value="Number(k)" />
|
||||
</el-select>
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
</div>
|
||||
<div class="table-container">
|
||||
<div class="table-actions"><el-button type="primary" @click="handleAdd">新增文章</el-button></div>
|
||||
<el-table v-loading="loading" :data="tableData" border stripe style="width:100%">
|
||||
<el-table-column prop="title" label="标题" min-width="200" />
|
||||
<el-table-column label="分类" width="120" align="center">
|
||||
<template #default="{ row }">{{ row.category?.name || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="作者" width="100" align="center">
|
||||
<template #default="{ row }">{{ row.author?.name || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="可见范围" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.visibility === 1 ? 'warning' : 'success'" size="small">{{ visibilityMap[row.visibility] || '-' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusType[row.status]" size="small">{{ statusMap[row.status] || '-' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="views" label="浏览" width="70" align="center" />
|
||||
<el-table-column prop="likes" label="点赞" width="70" align="center" />
|
||||
<el-table-column prop="published_at" label="发布时间" min-width="160" />
|
||||
<el-table-column label="操作" width="220" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.status <= 1" size="small" type="primary" link @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button v-if="row.status <= 1" size="small" type="danger" link @click="handleDelete(row)">删除</el-button>
|
||||
<el-button v-if="row.status < 2" size="small" type="success" link @click="handlePublish(row)">发布</el-button>
|
||||
<el-button v-if="row.status === 2" size="small" type="warning" link @click="handleOffline(row)">下架</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination v-model:current-page="pagination.page" v-model:page-size="pagination.per_page" :total="total" :page-sizes="[10,20,50]" layout="total,sizes,prev,pager,next,jumper" background @current-change="handlePageChange" @size-change="handleSizeChange" />
|
||||
</div>
|
||||
<el-dialog v-model="dialogVisible" :title="isEdit ? '编辑文章' : '新增文章'" width="600px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="90px">
|
||||
<el-form-item label="文章标题" prop="title"><el-input v-model="form.title" placeholder="请输入文章标题" /></el-form-item>
|
||||
<el-form-item label="所属分类">
|
||||
<el-select v-model="form.category_id" placeholder="请选择分类" clearable style="width:100%">
|
||||
<el-option v-for="c in categoryList" :key="c.id" :label="c.name" :value="c.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="文章内容">
|
||||
<el-input v-model="form.content" type="textarea" :rows="10" placeholder="请输入文章内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="可见范围">
|
||||
<el-select v-model="form.visibility" style="width:100%">
|
||||
<el-option v-for="(v, k) in visibilityMap" :key="k" :label="v" :value="Number(k)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="封面图片">
|
||||
<el-input v-model="form.cover_image" placeholder="请输入封面图片URL" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,127 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { kbCategoryApi } from '@/api/kb.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
|
||||
const searchForm = reactive({ status: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 50 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({ id: null, name: '', parent_id: 0, sort: 0, status: 1 })
|
||||
const isEdit = ref(false)
|
||||
const formRules = {
|
||||
name: [{ required: true, message: '请输入分类名称', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await kbCategoryApi.getList({ ...searchForm, ...pagination })
|
||||
tableData.value = res.data?.list || res.data?.data || []
|
||||
total.value = res.data?.total || 0
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() { Object.assign(searchForm, { status: '' }); handleSearch() }
|
||||
|
||||
function handleAdd() {
|
||||
isEdit.value = false
|
||||
Object.assign(form, { id: null, name: '', parent_id: 0, sort: 0, status: 1 })
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleEdit(row) {
|
||||
isEdit.value = true
|
||||
Object.assign(form, {
|
||||
id: row.id,
|
||||
name: row.name,
|
||||
parent_id: row.parent_id || 0,
|
||||
sort: row.sort || 0,
|
||||
status: row.status
|
||||
})
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!formRef.value) return
|
||||
await formRef.value.validate(async (valid) => {
|
||||
if (!valid) return
|
||||
submitLoading.value = true
|
||||
try {
|
||||
if (isEdit.value) { await kbCategoryApi.update(form.id, form); ElMessage.success('更新成功') }
|
||||
else { await kbCategoryApi.create(form); ElMessage.success('创建成功') }
|
||||
dialogVisible.value = false; fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
await ElMessageBox.confirm(`确定删除分类「${row.name}」吗?`, '删除确认', { type: 'warning' })
|
||||
await kbCategoryApi.delete(row.id); ElMessage.success('删除成功'); fetchList()
|
||||
}
|
||||
|
||||
function handlePageChange(val) { pagination.page = val; fetchList() }
|
||||
function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() }
|
||||
onMounted(() => fetchList())
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="search-bar">
|
||||
<el-select v-model="searchForm.status" placeholder="状态" clearable style="width:120px">
|
||||
<el-option label="启用" :value="1" />
|
||||
<el-option label="停用" :value="0" />
|
||||
</el-select>
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
</div>
|
||||
<div class="table-container">
|
||||
<div class="table-actions"><el-button type="primary" @click="handleAdd">新增分类</el-button></div>
|
||||
<el-table v-loading="loading" :data="tableData" border stripe row-key="id" style="width:100%">
|
||||
<el-table-column prop="name" label="分类名称" min-width="180" />
|
||||
<el-table-column label="上级分类" width="120" align="center">
|
||||
<template #default="{ row }">{{ row.parent_id === 0 ? '顶级' : row.parent_id }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="sort" label="排序" width="80" align="center" />
|
||||
<el-table-column label="状态" width="80" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.status ? 'success' : 'danger'" size="small">{{ row.status ? '启用' : '停用' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="160" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button size="small" type="primary" link @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button size="small" type="danger" link @click="handleDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination v-model:current-page="pagination.page" v-model:page-size="pagination.per_page" :total="total" :page-sizes="[20,50,100]" layout="total,sizes,prev,pager,next,jumper" background @current-change="handlePageChange" @size-change="handleSizeChange" />
|
||||
</div>
|
||||
<el-dialog v-model="dialogVisible" :title="isEdit ? '编辑分类' : '新增分类'" width="450px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="90px">
|
||||
<el-form-item label="分类名称" prop="name"><el-input v-model="form.name" placeholder="请输入分类名称" /></el-form-item>
|
||||
<el-form-item label="上级分类">
|
||||
<el-input-number v-model="form.parent_id" :min="0" style="width:100%" />
|
||||
<div style="font-size:12px;color:var(--color-text-secondary)">0 表示顶级分类</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序">
|
||||
<el-input-number v-model="form.sort" :min="0" :max="9999" style="width:100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-switch v-model="form.status" :active-value="1" :inactive-value="0" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,148 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { announcementApi } from '@/api/office.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const isEdit = ref(false)
|
||||
|
||||
const searchForm = reactive({ type: '', publish_status: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({ id: null, title: '', content: '', type: 1, is_top: 0 })
|
||||
|
||||
const typeMap = { 1: '通知', 2: '公告', 3: '制度' }
|
||||
const typeTagType = { 1: '', 2: 'warning', 3: 'danger' }
|
||||
const publishStatusMap = { 0: '草稿', 1: '已发布' }
|
||||
const publishStatusType = { 0: 'info', 1: 'success' }
|
||||
|
||||
const formRules = {
|
||||
title: [{ required: true, message: '请输入标题' }]
|
||||
}
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await announcementApi.getList({ ...searchForm, ...pagination })
|
||||
tableData.value = res.data?.list || res.data?.data || []
|
||||
total.value = res.data?.total || 0
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() { Object.assign(searchForm, { type: '', publish_status: '' }); handleSearch() }
|
||||
|
||||
function handleAdd() {
|
||||
isEdit.value = false
|
||||
Object.assign(form, { id: null, title: '', content: '', type: 1, is_top: 0 })
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
function handleEdit(row) {
|
||||
isEdit.value = true
|
||||
Object.assign(form, { id: row.id, title: row.title, content: row.content, type: row.type, is_top: row.is_top })
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!formRef.value) return
|
||||
await formRef.value.validate(async (valid) => {
|
||||
if (!valid) return
|
||||
submitLoading.value = true
|
||||
try {
|
||||
if (isEdit.value) { await announcementApi.update(form.id, form) } else { await announcementApi.create(form) }
|
||||
ElMessage.success(isEdit.value ? '更新成功' : '创建成功'); dialogVisible.value = false; fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
async function handlePublish(row) {
|
||||
await ElMessageBox.confirm('确定发布该公告吗?发布后不可编辑或删除。', '发布确认', { type: 'warning' })
|
||||
await announcementApi.publish(row.id)
|
||||
ElMessage.success('发布成功'); fetchList()
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
await ElMessageBox.confirm('确定删除该公告吗?', '删除确认', { type: 'warning' })
|
||||
await announcementApi.delete(row.id); ElMessage.success('删除成功'); fetchList()
|
||||
}
|
||||
|
||||
function handlePageChange(val) { pagination.page = val; fetchList() }
|
||||
function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() }
|
||||
onMounted(() => { fetchList() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="search-bar">
|
||||
<el-select v-model="searchForm.type" placeholder="类型" clearable style="width:120px">
|
||||
<el-option v-for="(v, k) in typeMap" :key="k" :label="v" :value="Number(k)" />
|
||||
</el-select>
|
||||
<el-select v-model="searchForm.publish_status" placeholder="发布状态" clearable style="width:130px">
|
||||
<el-option v-for="(v, k) in publishStatusMap" :key="k" :label="v" :value="Number(k)" />
|
||||
</el-select>
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
</div>
|
||||
<div class="table-container">
|
||||
<div class="table-actions">
|
||||
<el-button type="primary" @click="handleAdd">新增公告</el-button>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="tableData" border stripe style="width:100%">
|
||||
<el-table-column prop="title" label="标题" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column label="类型" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="typeTagType[row.type]" size="small">{{ typeMap[row.type] }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="置顶" width="70" align="center">
|
||||
<template #default="{ row }">{{ row.is_top ? '是' : '否' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="发布状态" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="publishStatusType[row.publish_status]" size="small">{{ publishStatusMap[row.publish_status] }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="作者" min-width="100">
|
||||
<template #default="{ row }">{{ row.author?.name || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="published_at" label="发布时间" min-width="160" />
|
||||
<el-table-column label="操作" width="200" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.publish_status === 0" size="small" type="success" link @click="handlePublish(row)">发布</el-button>
|
||||
<el-button v-if="row.publish_status === 0" size="small" type="primary" link @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button v-if="row.publish_status === 0" size="small" type="danger" link @click="handleDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination v-model:current-page="pagination.page" v-model:page-size="pagination.per_page" :total="total" :page-sizes="[10,20,50]" layout="total,sizes,prev,pager,next,jumper" background @current-change="handlePageChange" @size-change="handleSizeChange" />
|
||||
</div>
|
||||
<el-dialog v-model="dialogVisible" :title="isEdit ? '编辑公告' : '新增公告'" width="600px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="80px">
|
||||
<el-form-item label="标题" prop="title">
|
||||
<el-input v-model="form.title" placeholder="请输入标题" />
|
||||
</el-form-item>
|
||||
<el-form-item label="内容">
|
||||
<el-input v-model="form.content" type="textarea" :rows="5" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="类型">
|
||||
<el-select v-model="form.type" style="width:100%">
|
||||
<el-option v-for="(v, k) in typeMap" :key="k" :label="v" :value="Number(k)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="置顶">
|
||||
<el-switch v-model="form.is_top" :active-value="1" :inactive-value="0" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,174 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { approvalTemplateApi } from '@/api/office.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('新增审批模板')
|
||||
const submitLoading = ref(false)
|
||||
const isEdit = ref(false)
|
||||
|
||||
const searchForm = reactive({ type: '', status: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({
|
||||
id: null, name: '', type: '', form_fields: '', flow_nodes: '', status: 1, sort: 0
|
||||
})
|
||||
|
||||
const typeMap = { 1: '请假', 2: '采购', 3: '合同', 4: '退款', 5: '换房' }
|
||||
|
||||
const formRules = {
|
||||
name: [{ required: true, message: '请输入模板名称', trigger: 'blur' }],
|
||||
type: [{ required: true, message: '请选择模板类型', trigger: 'change' }]
|
||||
}
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await approvalTemplateApi.getList({ ...searchForm, ...pagination })
|
||||
tableData.value = res.data?.list || res.data?.data || []
|
||||
total.value = res.data?.total || 0
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() {
|
||||
Object.assign(searchForm, { type: '', status: '' })
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
isEdit.value = false
|
||||
dialogTitle.value = '新增审批模板'
|
||||
Object.assign(form, { id: null, name: '', type: '', form_fields: '', flow_nodes: '', status: 1, sort: 0 })
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleEdit(row) {
|
||||
isEdit.value = true
|
||||
dialogTitle.value = '编辑审批模板'
|
||||
const res = await approvalTemplateApi.getDetail(row.id)
|
||||
const d = res.data
|
||||
Object.assign(form, {
|
||||
id: d.id, name: d.name, type: d.type,
|
||||
form_fields: d.form_fields ? (typeof d.form_fields === 'string' ? d.form_fields : JSON.stringify(d.form_fields, null, 2)) : '',
|
||||
flow_nodes: d.flow_nodes ? (typeof d.flow_nodes === 'string' ? d.flow_nodes : JSON.stringify(d.flow_nodes, null, 2)) : '',
|
||||
status: d.status, sort: d.sort || 0
|
||||
})
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!formRef.value) return
|
||||
await formRef.value.validate(async (valid) => {
|
||||
if (!valid) return
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const payload = { ...form }
|
||||
if (payload.form_fields) {
|
||||
try { payload.form_fields = JSON.parse(payload.form_fields) } catch { /* keep string */ }
|
||||
}
|
||||
if (payload.flow_nodes) {
|
||||
try { payload.flow_nodes = JSON.parse(payload.flow_nodes) } catch { /* keep string */ }
|
||||
}
|
||||
if (isEdit.value) {
|
||||
await approvalTemplateApi.update(form.id, payload)
|
||||
ElMessage.success('更新成功')
|
||||
} else {
|
||||
await approvalTemplateApi.create(payload)
|
||||
ElMessage.success('创建成功')
|
||||
}
|
||||
dialogVisible.value = false
|
||||
fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
await ElMessageBox.confirm(`确定删除审批模板「${row.name}」吗?`, '删除确认', { type: 'warning' })
|
||||
await approvalTemplateApi.delete(row.id)
|
||||
ElMessage.success('删除成功')
|
||||
fetchList()
|
||||
}
|
||||
|
||||
function handlePageChange(val) { pagination.page = val; fetchList() }
|
||||
function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() }
|
||||
|
||||
onMounted(() => { fetchList() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="search-bar">
|
||||
<el-select v-model="searchForm.type" placeholder="模板类型" clearable style="width:140px">
|
||||
<el-option v-for="(v, k) in typeMap" :key="k" :label="v" :value="Number(k)" />
|
||||
</el-select>
|
||||
<el-select v-model="searchForm.status" placeholder="状态" clearable style="width:120px">
|
||||
<el-option label="启用" :value="1" />
|
||||
<el-option label="停用" :value="0" />
|
||||
</el-select>
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
</div>
|
||||
|
||||
<div class="table-container">
|
||||
<div class="table-actions">
|
||||
<el-button type="primary" @click="handleAdd">新增模板</el-button>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="tableData" border stripe style="width:100%">
|
||||
<el-table-column prop="name" label="模板名称" min-width="160" />
|
||||
<el-table-column label="类型" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small">{{ typeMap[row.type] || '-' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.status === 1 ? 'success' : 'info'" size="small">{{ row.status === 1 ? '启用' : '停用' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="sort" label="排序" width="80" align="center" />
|
||||
<el-table-column label="操作" width="160" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button size="small" type="primary" link @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button size="small" type="danger" link @click="handleDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination v-model:current-page="pagination.page" v-model:page-size="pagination.per_page" :total="total" :page-sizes="[10,20,50]" layout="total,sizes,prev,pager,next,jumper" background @current-change="handlePageChange" @size-change="handleSizeChange" />
|
||||
</div>
|
||||
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="600px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="100px">
|
||||
<el-form-item label="模板名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入模板名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="模板类型" prop="type">
|
||||
<el-select v-model="form.type" placeholder="请选择类型" style="width:100%">
|
||||
<el-option v-for="(v, k) in typeMap" :key="k" :label="v" :value="Number(k)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="表单字段">
|
||||
<el-input v-model="form.form_fields" type="textarea" :rows="4" placeholder="JSON格式,如:[{"label":"天数","type":"number"}]" />
|
||||
</el-form-item>
|
||||
<el-form-item label="审批节点">
|
||||
<el-input v-model="form.flow_nodes" type="textarea" :rows="4" placeholder="JSON格式,如:[{"name":"主管审批","role":"manager"}]" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-switch v-model="form.status" :active-value="1" :inactive-value="0" active-text="启用" inactive-text="停用" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序">
|
||||
<el-input-number v-model="form.sort" :min="0" :max="9999" style="width:100%" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,149 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { approvalApi } from '@/api/office.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
|
||||
const searchForm = reactive({ status: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({ title: '', template_id: '', form_data: '' })
|
||||
|
||||
const statusMap = { 0: '待审批', 1: '审批中', 2: '已通过', 3: '已驳回', 4: '已撤回' }
|
||||
const statusType = { 0: 'warning', 1: 'primary', 2: 'success', 3: 'danger', 4: 'info' }
|
||||
|
||||
const formRules = {
|
||||
title: [{ required: true, message: '请输入审批标题', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await approvalApi.getList({ ...searchForm, ...pagination })
|
||||
tableData.value = res.data?.list || res.data?.data || []
|
||||
total.value = res.data?.total || 0
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() {
|
||||
Object.assign(searchForm, { status: '' })
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
Object.assign(form, { title: '', template_id: '', form_data: '' })
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!formRef.value) return
|
||||
await formRef.value.validate(async (valid) => {
|
||||
if (!valid) return
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const payload = { ...form }
|
||||
if (payload.form_data) {
|
||||
try { payload.form_data = JSON.parse(payload.form_data) } catch { /* keep string */ }
|
||||
}
|
||||
await approvalApi.create(payload)
|
||||
ElMessage.success('提交成功')
|
||||
dialogVisible.value = false
|
||||
fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
async function handleApprove(row) {
|
||||
await ElMessageBox.confirm('确定通过该审批吗?', '审批确认', { type: 'warning' })
|
||||
await approvalApi.approve(row.id, { status: 2 })
|
||||
ElMessage.success('审批已通过')
|
||||
fetchList()
|
||||
}
|
||||
|
||||
async function handleReject(row) {
|
||||
await ElMessageBox.confirm('确定驳回该审批吗?', '驳回确认', { type: 'warning' })
|
||||
await approvalApi.reject(row.id, { status: 3 })
|
||||
ElMessage.success('审批已驳回')
|
||||
fetchList()
|
||||
}
|
||||
|
||||
async function handleWithdraw(row) {
|
||||
await ElMessageBox.confirm('确定撤回该审批吗?', '撤回确认', { type: 'warning' })
|
||||
await approvalApi.withdraw(row.id)
|
||||
ElMessage.success('审批已撤回')
|
||||
fetchList()
|
||||
}
|
||||
|
||||
function handlePageChange(val) { pagination.page = val; fetchList() }
|
||||
function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() }
|
||||
|
||||
onMounted(() => { fetchList() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="search-bar">
|
||||
<el-select v-model="searchForm.status" placeholder="审批状态" clearable style="width:140px">
|
||||
<el-option v-for="(v, k) in statusMap" :key="k" :label="v" :value="Number(k)" />
|
||||
</el-select>
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
</div>
|
||||
|
||||
<div class="table-container">
|
||||
<div class="table-actions">
|
||||
<el-button type="primary" @click="handleAdd">发起审批</el-button>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="tableData" border stripe style="width:100%">
|
||||
<el-table-column prop="title" label="标题" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column label="申请人" min-width="100">
|
||||
<template #default="{ row }">{{ row.applicant?.name || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="审批模板" min-width="120">
|
||||
<template #default="{ row }">{{ row.template?.name || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusType[row.status]" size="small">{{ statusMap[row.status] }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" min-width="160" />
|
||||
<el-table-column label="操作" width="200" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<template v-if="row.status <= 1">
|
||||
<el-button size="small" type="success" link @click="handleApprove(row)">通过</el-button>
|
||||
<el-button size="small" type="danger" link @click="handleReject(row)">驳回</el-button>
|
||||
<el-button size="small" type="warning" link @click="handleWithdraw(row)">撤回</el-button>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination v-model:current-page="pagination.page" v-model:page-size="pagination.per_page" :total="total" :page-sizes="[10,20,50]" layout="total,sizes,prev,pager,next,jumper" background @current-change="handlePageChange" @size-change="handleSizeChange" />
|
||||
</div>
|
||||
|
||||
<el-dialog v-model="dialogVisible" title="发起审批" width="600px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="100px">
|
||||
<el-form-item label="审批标题" prop="title">
|
||||
<el-input v-model="form.title" placeholder="请输入审批标题" />
|
||||
</el-form-item>
|
||||
<el-form-item label="审批模板">
|
||||
<el-input v-model="form.template_id" placeholder="请输入模板ID" />
|
||||
</el-form-item>
|
||||
<el-form-item label="表单数据">
|
||||
<el-input v-model="form.form_data" type="textarea" :rows="4" placeholder="JSON格式" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">提交</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,133 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { handoverApi } from '@/api/office.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
|
||||
const searchForm = reactive({ shift_date: '', shift_type: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({ shift_date: '', shift_type: 1, content: '', issues: '' })
|
||||
|
||||
const shiftTypeMap = { 1: '早班', 2: '中班', 3: '晚班', 4: '夜班' }
|
||||
const shiftTagType = { 1: '', 2: 'warning', 3: 'danger', 4: 'info' }
|
||||
const statusMap = { 0: '待确认', 1: '已确认' }
|
||||
const statusType = { 0: 'warning', 1: 'success' }
|
||||
|
||||
const formRules = {
|
||||
shift_date: [{ required: true, message: '请选择交接日期' }],
|
||||
shift_type: [{ required: true, message: '请选择班次' }],
|
||||
content: [{ required: true, message: '请输入交接内容' }]
|
||||
}
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await handoverApi.getList({ ...searchForm, ...pagination })
|
||||
tableData.value = res.data?.list || res.data?.data || []
|
||||
total.value = res.data?.total || 0
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() { Object.assign(searchForm, { shift_date: '', shift_type: '' }); handleSearch() }
|
||||
|
||||
function handleAdd() {
|
||||
Object.assign(form, { shift_date: '', shift_type: 1, content: '', issues: '' })
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!formRef.value) return
|
||||
await formRef.value.validate(async (valid) => {
|
||||
if (!valid) return
|
||||
submitLoading.value = true
|
||||
try {
|
||||
await handoverApi.create(form)
|
||||
ElMessage.success('创建成功'); dialogVisible.value = false; fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
async function handleConfirm(row) {
|
||||
await ElMessageBox.confirm('确定确认接班吗?', '确认接班', { type: 'warning' })
|
||||
await handoverApi.confirm(row.id)
|
||||
ElMessage.success('确认成功'); fetchList()
|
||||
}
|
||||
|
||||
function handlePageChange(val) { pagination.page = val; fetchList() }
|
||||
function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() }
|
||||
onMounted(() => { fetchList() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="search-bar">
|
||||
<el-date-picker v-model="searchForm.shift_date" type="date" value-format="YYYY-MM-DD" placeholder="交接日期" clearable style="width:160px" />
|
||||
<el-select v-model="searchForm.shift_type" placeholder="班次" clearable style="width:120px">
|
||||
<el-option v-for="(v, k) in shiftTypeMap" :key="k" :label="v" :value="Number(k)" />
|
||||
</el-select>
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
</div>
|
||||
<div class="table-container">
|
||||
<div class="table-actions">
|
||||
<el-button type="primary" @click="handleAdd">新增交接</el-button>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="tableData" border stripe style="width:100%">
|
||||
<el-table-column prop="shift_date" label="交接日期" width="120" />
|
||||
<el-table-column label="班次" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="shiftTagType[row.shift_type]" size="small">{{ shiftTypeMap[row.shift_type] }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="交班人" min-width="100">
|
||||
<template #default="{ row }">{{ row.handover_user?.name || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="接班人" min-width="100">
|
||||
<template #default="{ row }">{{ row.receiver_user?.name || '待确认' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="content" label="交接内容" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column label="状态" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusType[row.status]" size="small">{{ statusMap[row.status] }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.status === 0" size="small" type="success" link @click="handleConfirm(row)">确认接班</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination v-model:current-page="pagination.page" v-model:page-size="pagination.per_page" :total="total" :page-sizes="[10,20,50]" layout="total,sizes,prev,pager,next,jumper" background @current-change="handlePageChange" @size-change="handleSizeChange" />
|
||||
</div>
|
||||
<el-dialog v-model="dialogVisible" title="新增交接记录" width="600px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="90px">
|
||||
<el-form-item label="交接日期" prop="shift_date">
|
||||
<el-date-picker v-model="form.shift_date" type="date" value-format="YYYY-MM-DD" placeholder="请选择日期" style="width:100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="班次" prop="shift_type">
|
||||
<el-select v-model="form.shift_type" style="width:100%">
|
||||
<el-option v-for="(v, k) in shiftTypeMap" :key="k" :label="v" :value="Number(k)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="交接内容" prop="content">
|
||||
<el-input v-model="form.content" type="textarea" :rows="4" placeholder="请输入交接内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="遗留问题">
|
||||
<el-input v-model="form.issues" type="textarea" :rows="3" placeholder="请输入遗留问题(选填)" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,135 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { notificationApi } from '@/api/office.js'
|
||||
|
||||
// ─── State ────────────────────────────────────────────────────────────────────
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
|
||||
const searchForm = reactive({ type: '', is_read: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const typeMap = { 1: '系统', 2: '审批', 3: '待办', 4: '提醒' }
|
||||
const typeStyle = { 1: '', 2: 'warning', 3: 'danger', 4: 'success' }
|
||||
|
||||
// ─── Methods ──────────────────────────────────────────────────────────────────
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await notificationApi.getList({ ...searchForm, ...pagination })
|
||||
tableData.value = res.data?.list || res.data?.data || []
|
||||
total.value = res.data?.total || 0
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() { Object.assign(searchForm, { type: '', is_read: '' }); handleSearch() }
|
||||
|
||||
async function handleMarkRead(row) {
|
||||
await notificationApi.markRead(row.id)
|
||||
ElMessage.success('已标记为已读')
|
||||
fetchList()
|
||||
}
|
||||
|
||||
async function handleMarkAllRead() {
|
||||
await notificationApi.markAllRead()
|
||||
ElMessage.success('全部标记为已读')
|
||||
fetchList()
|
||||
}
|
||||
|
||||
function handlePageChange(val) { pagination.page = val; fetchList() }
|
||||
function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() }
|
||||
|
||||
onMounted(fetchList)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<!-- Search -->
|
||||
<div class="search-bar">
|
||||
<el-select v-model="searchForm.type" placeholder="通知类型" clearable style="width: 140px">
|
||||
<el-option v-for="(v, k) in typeMap" :key="k" :label="v" :value="Number(k)" />
|
||||
</el-select>
|
||||
<el-select v-model="searchForm.is_read" placeholder="读取状态" clearable style="width: 130px">
|
||||
<el-option label="未读" :value="0" />
|
||||
<el-option label="已读" :value="1" />
|
||||
</el-select>
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
</div>
|
||||
|
||||
<!-- Table -->
|
||||
<div class="table-container">
|
||||
<div class="table-actions">
|
||||
<el-button type="primary" @click="handleMarkAllRead">全部标记已读</el-button>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="tableData" border stripe style="width: 100%">
|
||||
<el-table-column prop="title" label="标题" min-width="180" />
|
||||
<el-table-column prop="content" label="内容" min-width="260" show-overflow-tooltip />
|
||||
<el-table-column label="类型" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="typeStyle[row.type]" size="small">{{ typeMap[row.type] || '-' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="80" align="center">
|
||||
<template #default="{ row }">
|
||||
<span class="read-dot" :class="row.is_read ? 'read' : 'unread'" />
|
||||
<span>{{ row.is_read ? '已读' : '未读' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" min-width="160" />
|
||||
<el-table-column label="操作" width="120" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-if="!row.is_read"
|
||||
size="small"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleMarkRead(row)"
|
||||
>标记已读</el-button>
|
||||
<span v-else class="text-muted">-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-pagination
|
||||
v-model:current-page="pagination.page"
|
||||
v-model:page-size="pagination.per_page"
|
||||
:total="total"
|
||||
:page-sizes="[10, 20, 50]"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
background
|
||||
@current-change="handlePageChange"
|
||||
@size-change="handleSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.read-dot {
|
||||
display: inline-block;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
margin-right: 6px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.read-dot.unread {
|
||||
background-color: #67c23a;
|
||||
}
|
||||
|
||||
.read-dot.read {
|
||||
background-color: #c0c4cc;
|
||||
}
|
||||
|
||||
.text-muted {
|
||||
color: var(--color-text-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,176 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { reportExportApi } from '@/api/report.js'
|
||||
|
||||
// ─── State ────────────────────────────────────────────────────────────────────
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
|
||||
const searchForm = reactive({ type: '', status: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({ name: '', type: '', params: '' })
|
||||
const formRules = {
|
||||
name: [{ required: true, message: '请输入报表名称', trigger: 'blur' }],
|
||||
type: [{ required: true, message: '请选择报表类型', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const typeOptions = [
|
||||
{ label: '经营概览', value: 'overview' },
|
||||
{ label: '营收报表', value: 'revenue' },
|
||||
{ label: '入住率报表', value: 'occupancy' },
|
||||
{ label: 'CRM转化报表', value: 'crm' }
|
||||
]
|
||||
|
||||
const statusMap = { 0: '生成中', 1: '已完成', 2: '失败' }
|
||||
const statusType = { 0: 'warning', 1: 'success', 2: 'danger' }
|
||||
|
||||
// ─── Methods ──────────────────────────────────────────────────────────────────
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await reportExportApi.getList({ ...searchForm, ...pagination })
|
||||
tableData.value = res.data?.list || res.data?.data || []
|
||||
total.value = res.data?.total || 0
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() { Object.assign(searchForm, { type: '', status: '' }); handleSearch() }
|
||||
|
||||
function handleAdd() {
|
||||
Object.assign(form, { name: '', type: '', params: '' })
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!formRef.value) return
|
||||
await formRef.value.validate(async (valid) => {
|
||||
if (!valid) return
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const payload = { ...form }
|
||||
if (payload.params) {
|
||||
try { payload.params = JSON.parse(payload.params) } catch { /* send as string */ }
|
||||
}
|
||||
await reportExportApi.create(payload)
|
||||
ElMessage.success('导出任务已创建')
|
||||
dialogVisible.value = false
|
||||
fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
function handleDownload(row) {
|
||||
if (row.file_path) {
|
||||
window.open(row.file_path, '_blank')
|
||||
}
|
||||
}
|
||||
|
||||
function handlePageChange(val) { pagination.page = val; fetchList() }
|
||||
function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() }
|
||||
|
||||
onMounted(fetchList)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<!-- Search -->
|
||||
<div class="search-bar">
|
||||
<el-input v-model="searchForm.type" placeholder="报表类型" style="width: 160px" clearable @keydown.enter="handleSearch" />
|
||||
<el-select v-model="searchForm.status" placeholder="状态" clearable style="width: 130px">
|
||||
<el-option v-for="(v, k) in statusMap" :key="k" :label="v" :value="Number(k)" />
|
||||
</el-select>
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
</div>
|
||||
|
||||
<!-- Table -->
|
||||
<div class="table-container">
|
||||
<div class="table-actions">
|
||||
<el-button type="primary" @click="handleAdd">新建导出</el-button>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="tableData" border stripe style="width: 100%">
|
||||
<el-table-column prop="name" label="报表名称" min-width="160" />
|
||||
<el-table-column prop="type" label="类型" min-width="120" />
|
||||
<el-table-column label="状态" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusType[row.status]" size="small">{{ statusMap[row.status] || '-' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作人" min-width="100">
|
||||
<template #default="{ row }">{{ row.operator?.name || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" min-width="160" />
|
||||
<el-table-column label="操作" width="100" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-if="row.status === 1 && row.file_path"
|
||||
size="small"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleDownload(row)"
|
||||
>下载</el-button>
|
||||
<span v-else class="text-muted">-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-pagination
|
||||
v-model:current-page="pagination.page"
|
||||
v-model:page-size="pagination.per_page"
|
||||
:total="total"
|
||||
:page-sizes="[10, 20, 50]"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
background
|
||||
@current-change="handlePageChange"
|
||||
@size-change="handleSizeChange"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Create Dialog -->
|
||||
<el-dialog v-model="dialogVisible" title="新建导出" width="550px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="90px">
|
||||
<el-form-item label="报表名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入报表名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="报表类型" prop="type">
|
||||
<el-select v-model="form.type" placeholder="请选择报表类型" style="width: 100%">
|
||||
<el-option
|
||||
v-for="opt in typeOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="参数">
|
||||
<el-input
|
||||
v-model="form.params"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
placeholder="可选,JSON 格式参数"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.text-muted {
|
||||
color: var(--color-text-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,138 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { reportApi } from '@/api/report.js'
|
||||
|
||||
// ─── State ────────────────────────────────────────────────────────────────────
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
const cards = ref([
|
||||
{ key: 'customer_count', title: '客户数', value: '--', unit: '位', color: '#E8A87C', bg: '#FBE8D5' },
|
||||
{ key: 'contract_amount', title: '合同金额', value: '--', unit: '元', color: '#67C23A', bg: '#E8F5E1' },
|
||||
{ key: 'total_rooms', title: '总房间数', value: '--', unit: '间', color: '#409EFF', bg: '#E0EFFF' },
|
||||
{ key: 'occupied_rooms', title: '入住房间数', value: '--', unit: '间', color: '#E6A23C', bg: '#FDF0D6' },
|
||||
{ key: 'today_revenue', title: '今日营收', value: '--', unit: '元', color: '#F56C6C', bg: '#FDE2E2' },
|
||||
{ key: 'month_revenue', title: '月度营收', value: '--', unit: '元', color: '#C97B5E', bg: '#F9E8E0' }
|
||||
])
|
||||
|
||||
// ─── Methods ──────────────────────────────────────────────────────────────────
|
||||
|
||||
async function fetchOverview() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await reportApi.overview()
|
||||
const data = res.data || {}
|
||||
cards.value.forEach(card => {
|
||||
if (data[card.key] !== undefined && data[card.key] !== null) {
|
||||
card.value = data[card.key]
|
||||
}
|
||||
})
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
onMounted(fetchOverview)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container" v-loading="loading">
|
||||
<div class="section-title">经营概览</div>
|
||||
|
||||
<el-row :gutter="16" class="mt-16">
|
||||
<el-col
|
||||
v-for="card in cards"
|
||||
:key="card.key"
|
||||
:xs="24"
|
||||
:sm="12"
|
||||
:md="8"
|
||||
:lg="8"
|
||||
:xl="4"
|
||||
>
|
||||
<el-card shadow="hover" class="overview-card">
|
||||
<div class="card-inner">
|
||||
<div class="card-icon-wrap" :style="{ background: card.bg }">
|
||||
<span class="card-icon-text" :style="{ color: card.color }">{{ card.title.charAt(0) }}</span>
|
||||
</div>
|
||||
<div class="card-info">
|
||||
<div class="card-label">{{ card.title }}</div>
|
||||
<div class="card-value">
|
||||
<span class="card-number" :style="{ color: card.color }">{{ card.value }}</span>
|
||||
<span class="card-unit">{{ card.unit }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.section-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--color-text-primary);
|
||||
padding-left: 8px;
|
||||
border-left: 3px solid var(--color-primary);
|
||||
}
|
||||
|
||||
.mt-16 {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.overview-card {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.overview-card :deep(.el-card__body) {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.card-inner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.card-icon-wrap {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.card-icon-text {
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.card-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.card-label {
|
||||
font-size: 13px;
|
||||
color: var(--color-text-secondary);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.card-value {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.card-number {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.card-unit {
|
||||
font-size: 13px;
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user