feat: 第二阶段核心业务模块(CRM/房务/护理/月子餐)
后端: - 4个迁移文件新增23张业务表 - 23个Eloquent Model(含关联/类型转换/门店隔离) - 20个Controller(含CRUD+业务操作: 合同审核/入住退房/护理异常处理等) - 110+条API路由(crm/room/care/meal四大前缀) 前端: - 4个API模块(crm.js/room.js/care.js/meal.js) - 13个业务页面(线索/客户/合同/渠道/投诉/房型/房间/预定/护理档案/护理计划/护理记录/菜品/排餐)
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Care;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Care\CareException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CareExceptionController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = CareException::query()->with(['profile.customer', 'reporter', 'handler']);
|
||||
$query->when($request->care_profile_id, fn($q, $v) => $q->where('care_profile_id', $v));
|
||||
$query->when($request->level, fn($q, $v) => $q->where('level', $v));
|
||||
$query->when($request->has('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([
|
||||
'care_profile_id' => 'required|exists:care_profiles,id',
|
||||
'level' => 'required|integer|in:1,2,3',
|
||||
'description' => 'required|string',
|
||||
'images' => 'nullable|array',
|
||||
]);
|
||||
$validated['reporter_id'] = auth()->id();
|
||||
$validated['status'] = 0;
|
||||
|
||||
return $this->success(CareException::create($validated));
|
||||
}
|
||||
|
||||
public function show(CareException $careException): JsonResponse
|
||||
{
|
||||
return $this->success($careException->load(['profile.customer', 'reporter', 'handler']));
|
||||
}
|
||||
|
||||
public function update(Request $request, CareException $careException): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'level' => 'sometimes|integer|in:1,2,3',
|
||||
'description' => 'sometimes|string',
|
||||
'images' => 'nullable|array',
|
||||
]);
|
||||
$careException->update($validated);
|
||||
return $this->success($careException);
|
||||
}
|
||||
|
||||
public function handle(Request $request, CareException $careException): JsonResponse
|
||||
{
|
||||
if ($careException->status === 2) {
|
||||
return $this->error('该异常已处理', 40001);
|
||||
}
|
||||
$validated = $request->validate([
|
||||
'handle_result' => 'required|string',
|
||||
]);
|
||||
$careException->update([
|
||||
'handle_result' => $validated['handle_result'],
|
||||
'handler_id' => auth()->id(),
|
||||
'handle_at' => now(),
|
||||
'status' => 2,
|
||||
]);
|
||||
return $this->success($careException);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Care;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Care\CarePlan;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CarePlanController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = CarePlan::query()->with(['profile.customer', 'nurse']);
|
||||
$query->when($request->care_profile_id, fn($q, $v) => $q->where('care_profile_id', $v));
|
||||
$query->when($request->plan_date, fn($q, $v) => $q->whereDate('plan_date', $v));
|
||||
$query->when($request->nurse_id, fn($q, $v) => $q->where('nurse_id', $v));
|
||||
$query->when($request->has('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([
|
||||
'care_profile_id' => 'required|exists:care_profiles,id',
|
||||
'plan_date' => 'required|date',
|
||||
'stage' => 'nullable|string|max:50',
|
||||
'items' => 'nullable|array',
|
||||
'nurse_id' => 'nullable|exists:users,id',
|
||||
]);
|
||||
$validated['status'] = 0;
|
||||
return $this->success(CarePlan::create($validated));
|
||||
}
|
||||
|
||||
public function show(CarePlan $carePlan): JsonResponse
|
||||
{
|
||||
return $this->success($carePlan->load(['profile.customer', 'nurse', 'records']));
|
||||
}
|
||||
|
||||
public function update(Request $request, CarePlan $carePlan): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'plan_date' => 'sometimes|date',
|
||||
'stage' => 'nullable|string|max:50',
|
||||
'items' => 'nullable|array',
|
||||
'nurse_id' => 'nullable|exists:users,id',
|
||||
'status' => 'sometimes|integer|in:0,1,2',
|
||||
]);
|
||||
$carePlan->update($validated);
|
||||
return $this->success($carePlan);
|
||||
}
|
||||
|
||||
public function destroy(CarePlan $carePlan): JsonResponse
|
||||
{
|
||||
$carePlan->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Care;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Care\CareProfile;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CareProfileController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = CareProfile::query()->with('customer');
|
||||
$query->when($request->customer_id, fn($q, $v) => $q->where('customer_id', $v));
|
||||
$query->when($request->type, fn($q, $v) => $q->where('type', $v));
|
||||
$query->when($request->risk_level, fn($q, $v) => $q->where('risk_level', $v));
|
||||
|
||||
return $this->paginate($query->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'customer_id' => 'required|exists:customers,id',
|
||||
'reservation_id' => 'nullable|exists:reservations,id',
|
||||
'type' => 'required|integer|in:1,2',
|
||||
'baby_name' => 'nullable|string|max:50',
|
||||
'baby_gender' => 'nullable|integer|in:1,2',
|
||||
'baby_birthday' => 'nullable|date',
|
||||
'birth_weight' => 'nullable|numeric|min:0',
|
||||
'birth_method' => 'nullable|integer|in:1,2',
|
||||
'allergies' => 'nullable|string',
|
||||
'medical_history' => 'nullable|string',
|
||||
'risk_level' => 'sometimes|integer|in:0,1,2',
|
||||
'assessment' => 'nullable|array',
|
||||
]);
|
||||
return $this->success(CareProfile::create($validated));
|
||||
}
|
||||
|
||||
public function show(CareProfile $careProfile): JsonResponse
|
||||
{
|
||||
return $this->success($careProfile->load(['customer', 'plans.nurse', 'records', 'exceptions', 'healthMetrics']));
|
||||
}
|
||||
|
||||
public function update(Request $request, CareProfile $careProfile): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'baby_name' => 'nullable|string|max:50',
|
||||
'baby_gender' => 'nullable|integer|in:1,2',
|
||||
'baby_birthday' => 'nullable|date',
|
||||
'birth_weight' => 'nullable|numeric|min:0',
|
||||
'birth_method' => 'nullable|integer|in:1,2',
|
||||
'allergies' => 'nullable|string',
|
||||
'medical_history' => 'nullable|string',
|
||||
'risk_level' => 'sometimes|integer|in:0,1,2',
|
||||
'assessment' => 'nullable|array',
|
||||
]);
|
||||
$careProfile->update($validated);
|
||||
return $this->success($careProfile);
|
||||
}
|
||||
|
||||
public function destroy(CareProfile $careProfile): JsonResponse
|
||||
{
|
||||
$careProfile->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Care;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Care\CareRecord;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CareRecordController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = CareRecord::query()->with(['profile.customer', 'nurse']);
|
||||
$query->when($request->care_profile_id, fn($q, $v) => $q->where('care_profile_id', $v));
|
||||
$query->when($request->care_plan_id, fn($q, $v) => $q->where('care_plan_id', $v));
|
||||
$query->when($request->type, fn($q, $v) => $q->where('type', $v));
|
||||
$query->when($request->nurse_id, fn($q, $v) => $q->where('nurse_id', $v));
|
||||
|
||||
return $this->paginate($query->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'care_profile_id' => 'required|exists:care_profiles,id',
|
||||
'care_plan_id' => 'nullable|exists:care_plans,id',
|
||||
'type' => 'nullable|integer|in:1,2',
|
||||
'items' => 'nullable|array',
|
||||
'remark' => 'nullable|string',
|
||||
'images' => 'nullable|array',
|
||||
'recorded_at' => 'sometimes|date',
|
||||
]);
|
||||
$validated['nurse_id'] = auth()->id();
|
||||
$validated['recorded_at'] = $validated['recorded_at'] ?? now();
|
||||
|
||||
return $this->success(CareRecord::create($validated));
|
||||
}
|
||||
|
||||
public function show(CareRecord $careRecord): JsonResponse
|
||||
{
|
||||
return $this->success($careRecord->load(['profile.customer', 'plan', 'nurse']));
|
||||
}
|
||||
|
||||
public function update(Request $request, CareRecord $careRecord): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'type' => 'nullable|integer|in:1,2',
|
||||
'items' => 'nullable|array',
|
||||
'remark' => 'nullable|string',
|
||||
'images' => 'nullable|array',
|
||||
]);
|
||||
$careRecord->update($validated);
|
||||
return $this->success($careRecord);
|
||||
}
|
||||
|
||||
public function destroy(CareRecord $careRecord): JsonResponse
|
||||
{
|
||||
$careRecord->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Care;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Care\HealthMetric;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HealthMetricController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = HealthMetric::query()->with('recorder');
|
||||
$query->when($request->care_profile_id, fn($q, $v) => $q->where('care_profile_id', $v));
|
||||
$query->when($request->metric_type, fn($q, $v) => $q->where('metric_type', $v));
|
||||
$query->when($request->start_date, fn($q, $v) => $q->where('recorded_at', '>=', $v));
|
||||
$query->when($request->end_date, fn($q, $v) => $q->where('recorded_at', '<=', $v));
|
||||
|
||||
return $this->paginate($query->latest('recorded_at')->paginate($request->input('per_page', 50)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'care_profile_id' => 'required|exists:care_profiles,id',
|
||||
'metric_type' => 'required|string|max:30',
|
||||
'value' => 'required|numeric',
|
||||
'unit' => 'nullable|string|max:10',
|
||||
'recorded_at' => 'sometimes|date',
|
||||
'remark' => 'nullable|string|max:255',
|
||||
]);
|
||||
$validated['recorder_id'] = auth()->id();
|
||||
$validated['recorded_at'] = $validated['recorded_at'] ?? now();
|
||||
|
||||
return $this->success(HealthMetric::create($validated));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Crm;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Crm\Channel;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ChannelController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Channel::query();
|
||||
$query->when($request->name, fn($q, $v) => $q->where('name', 'like', "%{$v}%"));
|
||||
$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->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:50',
|
||||
'type' => 'required|integer|in:1,2,3',
|
||||
'status' => 'sometimes|integer|in:0,1',
|
||||
]);
|
||||
|
||||
$channel = Channel::create($validated);
|
||||
|
||||
return $this->success($channel);
|
||||
}
|
||||
|
||||
public function show(Channel $channel): JsonResponse
|
||||
{
|
||||
return $this->success($channel->load('leads'));
|
||||
}
|
||||
|
||||
public function update(Request $request, Channel $channel): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'sometimes|string|max:50',
|
||||
'type' => 'sometimes|integer|in:1,2,3',
|
||||
'status' => 'sometimes|integer|in:0,1',
|
||||
]);
|
||||
|
||||
$channel->update($validated);
|
||||
|
||||
return $this->success($channel);
|
||||
}
|
||||
|
||||
public function destroy(Channel $channel): JsonResponse
|
||||
{
|
||||
$channel->delete();
|
||||
|
||||
return $this->success(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Crm;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Crm\Complaint;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ComplaintController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Complaint::query()->with(['customer', 'handler']);
|
||||
$query->when($request->customer_id, fn($q, $v) => $q->where('customer_id', $v));
|
||||
$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->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'customer_id' => 'required|exists:customers,id',
|
||||
'type' => 'nullable|integer|in:1,2,3,4',
|
||||
'content' => 'required|string',
|
||||
'images' => 'nullable|array',
|
||||
]);
|
||||
$validated['status'] = 0;
|
||||
|
||||
return $this->success(Complaint::create($validated));
|
||||
}
|
||||
|
||||
public function show(Complaint $complaint): JsonResponse
|
||||
{
|
||||
return $this->success($complaint->load(['customer', 'handler']));
|
||||
}
|
||||
|
||||
public function update(Request $request, Complaint $complaint): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'type' => 'nullable|integer|in:1,2,3,4',
|
||||
'content' => 'sometimes|string',
|
||||
'images' => 'nullable|array',
|
||||
]);
|
||||
$complaint->update($validated);
|
||||
return $this->success($complaint);
|
||||
}
|
||||
|
||||
public function destroy(Complaint $complaint): JsonResponse
|
||||
{
|
||||
$complaint->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
|
||||
public function handle(Request $request, Complaint $complaint): JsonResponse
|
||||
{
|
||||
if ($complaint->status >= 2) {
|
||||
return $this->error('该投诉已处理', 40001);
|
||||
}
|
||||
$validated = $request->validate([
|
||||
'handle_result' => 'required|string',
|
||||
'status' => 'required|integer|in:2,3',
|
||||
]);
|
||||
$complaint->update([
|
||||
'handle_result' => $validated['handle_result'],
|
||||
'status' => $validated['status'],
|
||||
'handler_id' => auth()->id(),
|
||||
'handle_at' => now(),
|
||||
]);
|
||||
return $this->success($complaint);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Crm;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Crm\Contract;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ContractController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Contract::query()->with(['customer', 'auditor']);
|
||||
$query->when($request->contract_no, fn($q, $v) => $q->where('contract_no', 'like', "%{$v}%"));
|
||||
$query->when($request->customer_id, fn($q, $v) => $q->where('customer_id', $v));
|
||||
$query->when($request->has('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([
|
||||
'customer_id' => 'required|exists:customers,id',
|
||||
'contract_no' => 'required|string|max:50|unique:contracts',
|
||||
'package_name' => 'nullable|string|max:100',
|
||||
'total_amount' => 'required|numeric|min:0',
|
||||
'discount_amount' => 'sometimes|numeric|min:0',
|
||||
'actual_amount' => 'required|numeric|min:0',
|
||||
'days' => 'nullable|integer|min:1',
|
||||
'check_in_date' => 'nullable|date',
|
||||
'check_out_date' => 'nullable|date|after_or_equal:check_in_date',
|
||||
'remark' => 'nullable|string',
|
||||
]);
|
||||
$validated['created_by'] = auth()->id();
|
||||
$validated['status'] = 0;
|
||||
|
||||
return $this->success(Contract::create($validated));
|
||||
}
|
||||
|
||||
public function show(Contract $contract): JsonResponse
|
||||
{
|
||||
return $this->success($contract->load(['customer', 'auditor', 'creator']));
|
||||
}
|
||||
|
||||
public function update(Request $request, Contract $contract): JsonResponse
|
||||
{
|
||||
if ($contract->status !== 0) {
|
||||
return $this->error('只能修改待审核的合同', 40001);
|
||||
}
|
||||
$validated = $request->validate([
|
||||
'package_name' => 'nullable|string|max:100',
|
||||
'total_amount' => 'sometimes|numeric|min:0',
|
||||
'discount_amount' => 'sometimes|numeric|min:0',
|
||||
'actual_amount' => 'sometimes|numeric|min:0',
|
||||
'days' => 'nullable|integer|min:1',
|
||||
'check_in_date' => 'nullable|date',
|
||||
'check_out_date' => 'nullable|date|after_or_equal:check_in_date',
|
||||
'remark' => 'nullable|string',
|
||||
]);
|
||||
$contract->update($validated);
|
||||
return $this->success($contract);
|
||||
}
|
||||
|
||||
public function destroy(Contract $contract): JsonResponse
|
||||
{
|
||||
if ($contract->status !== 0) {
|
||||
return $this->error('只能删除待审核的合同', 40001);
|
||||
}
|
||||
$contract->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
|
||||
public function audit(Request $request, Contract $contract): JsonResponse
|
||||
{
|
||||
if ($contract->status !== 0) {
|
||||
return $this->error('该合同已审核', 40001);
|
||||
}
|
||||
$validated = $request->validate([
|
||||
'status' => 'required|integer|in:1,2',
|
||||
'audit_remark' => 'nullable|string|max:255',
|
||||
]);
|
||||
$contract->update([
|
||||
'status' => $validated['status'],
|
||||
'audit_user_id' => auth()->id(),
|
||||
'audit_at' => now(),
|
||||
'audit_remark' => $validated['audit_remark'] ?? null,
|
||||
]);
|
||||
|
||||
if ($validated['status'] === 1) {
|
||||
$contract->customer->update(['status' => 2]);
|
||||
}
|
||||
|
||||
return $this->success($contract);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Crm;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Crm\Customer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CustomerController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Customer::query()->with(['owner']);
|
||||
$query->when($request->name, fn($q, $v) => $q->where('name', 'like', "%{$v}%"));
|
||||
$query->when($request->phone, fn($q, $v) => $q->where('phone', 'like', "%{$v}%"));
|
||||
$query->when($request->status, fn($q, $v) => $q->where('status', $v));
|
||||
$query->when($request->owner_id, fn($q, $v) => $q->where('owner_id', $v));
|
||||
|
||||
return $this->paginate($query->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'lead_id' => 'nullable|exists:leads,id',
|
||||
'name' => 'required|string|max:50',
|
||||
'phone' => 'required|string|max:20',
|
||||
'id_card' => 'nullable|string|max:20',
|
||||
'wechat' => 'nullable|string|max:50',
|
||||
'birthday' => 'nullable|date',
|
||||
'expected_date' => 'nullable|date',
|
||||
'actual_date' => 'nullable|date',
|
||||
'baby_count' => 'sometimes|integer|min:1',
|
||||
'tags' => 'nullable|array',
|
||||
'remark' => 'nullable|string',
|
||||
'families' => 'nullable|array',
|
||||
'families.*.name' => 'nullable|string|max:50',
|
||||
'families.*.phone' => 'nullable|string|max:20',
|
||||
'families.*.relation' => 'nullable|string|max:20',
|
||||
'families.*.is_emergency' => 'nullable|boolean',
|
||||
]);
|
||||
|
||||
$families = $validated['families'] ?? [];
|
||||
unset($validated['families']);
|
||||
$validated['status'] = 1;
|
||||
|
||||
$customer = Customer::create($validated);
|
||||
if ($families) {
|
||||
$customer->families()->createMany($families);
|
||||
}
|
||||
|
||||
return $this->success($customer->load('families'));
|
||||
}
|
||||
|
||||
public function show(Customer $customer): JsonResponse
|
||||
{
|
||||
return $this->success($customer->load(['owner', 'families', 'contracts', 'complaints']));
|
||||
}
|
||||
|
||||
public function update(Request $request, Customer $customer): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'sometimes|string|max:50',
|
||||
'phone' => 'sometimes|string|max:20',
|
||||
'id_card' => 'nullable|string|max:20',
|
||||
'wechat' => 'nullable|string|max:50',
|
||||
'birthday' => 'nullable|date',
|
||||
'expected_date' => 'nullable|date',
|
||||
'actual_date' => 'nullable|date',
|
||||
'baby_count' => 'sometimes|integer|min:1',
|
||||
'tags' => 'nullable|array',
|
||||
'status' => 'sometimes|integer|in:1,2,3,4,5',
|
||||
'owner_id' => 'nullable|exists:users,id',
|
||||
'remark' => 'nullable|string',
|
||||
]);
|
||||
$customer->update($validated);
|
||||
return $this->success($customer);
|
||||
}
|
||||
|
||||
public function destroy(Customer $customer): JsonResponse
|
||||
{
|
||||
$customer->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Crm;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Crm\Lead;
|
||||
use App\Models\Crm\LeadFollow;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LeadController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Lead::query()->with(['channel', 'owner']);
|
||||
$query->when($request->name, fn($q, $v) => $q->where('name', 'like', "%{$v}%"));
|
||||
$query->when($request->phone, fn($q, $v) => $q->where('phone', 'like', "%{$v}%"));
|
||||
$query->when($request->status, fn($q, $v) => $q->where('status', $v));
|
||||
$query->when($request->channel_id, fn($q, $v) => $q->where('channel_id', $v));
|
||||
$query->when($request->owner_id, fn($q, $v) => $q->where('owner_id', $v));
|
||||
|
||||
return $this->paginate($query->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'channel_id' => 'nullable|exists:channels,id',
|
||||
'name' => 'required|string|max:50',
|
||||
'phone' => 'required|string|max:20',
|
||||
'wechat' => 'nullable|string|max:50',
|
||||
'expected_date' => 'nullable|date',
|
||||
'source' => 'nullable|string|max:50',
|
||||
'remark' => 'nullable|string',
|
||||
]);
|
||||
$validated['created_by'] = auth()->id();
|
||||
$validated['status'] = 1;
|
||||
|
||||
return $this->success(Lead::create($validated));
|
||||
}
|
||||
|
||||
public function show(Lead $lead): JsonResponse
|
||||
{
|
||||
return $this->success($lead->load(['channel', 'owner', 'follows.user']));
|
||||
}
|
||||
|
||||
public function update(Request $request, Lead $lead): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'channel_id' => 'nullable|exists:channels,id',
|
||||
'name' => 'sometimes|string|max:50',
|
||||
'phone' => 'sometimes|string|max:20',
|
||||
'wechat' => 'nullable|string|max:50',
|
||||
'expected_date' => 'nullable|date',
|
||||
'source' => 'nullable|string|max:50',
|
||||
'status' => 'sometimes|integer|in:1,2,3,4',
|
||||
'remark' => 'nullable|string',
|
||||
]);
|
||||
$lead->update($validated);
|
||||
return $this->success($lead);
|
||||
}
|
||||
|
||||
public function destroy(Lead $lead): JsonResponse
|
||||
{
|
||||
$lead->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
|
||||
public function follow(Request $request, Lead $lead): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'type' => 'nullable|integer|in:1,2,3,4',
|
||||
'content' => 'nullable|string',
|
||||
'next_follow_at' => 'nullable|date',
|
||||
]);
|
||||
$validated['lead_id'] = $lead->id;
|
||||
$validated['user_id'] = auth()->id();
|
||||
|
||||
$follow = LeadFollow::create($validated);
|
||||
$lead->update(['status' => 2]);
|
||||
|
||||
return $this->success($follow);
|
||||
}
|
||||
|
||||
public function assign(Request $request, Lead $lead): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'owner_id' => 'required|exists:users,id',
|
||||
]);
|
||||
$lead->update($validated);
|
||||
return $this->success($lead);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Crm;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Crm\QuestionnaireAnswer;
|
||||
use App\Models\Crm\QuestionnaireTemplate;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class QuestionnaireController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = QuestionnaireTemplate::query();
|
||||
$query->when($request->title, fn($q, $v) => $q->where('title', 'like', "%{$v}%"));
|
||||
$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->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'title' => 'required|string|max:100',
|
||||
'description' => 'nullable|string',
|
||||
'questions' => 'nullable|array',
|
||||
'type' => 'nullable|integer|in:1,2,3,4',
|
||||
'status' => 'sometimes|integer|in:0,1',
|
||||
]);
|
||||
return $this->success(QuestionnaireTemplate::create($validated));
|
||||
}
|
||||
|
||||
public function show(QuestionnaireTemplate $questionnaire): JsonResponse
|
||||
{
|
||||
return $this->success($questionnaire->load('answers.customer'));
|
||||
}
|
||||
|
||||
public function update(Request $request, QuestionnaireTemplate $questionnaire): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'title' => 'sometimes|string|max:100',
|
||||
'description' => 'nullable|string',
|
||||
'questions' => 'nullable|array',
|
||||
'type' => 'nullable|integer|in:1,2,3,4',
|
||||
'status' => 'sometimes|integer|in:0,1',
|
||||
]);
|
||||
$questionnaire->update($validated);
|
||||
return $this->success($questionnaire);
|
||||
}
|
||||
|
||||
public function destroy(QuestionnaireTemplate $questionnaire): JsonResponse
|
||||
{
|
||||
$questionnaire->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
|
||||
public function submitAnswer(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'questionnaire_template_id' => 'required|exists:questionnaire_templates,id',
|
||||
'customer_id' => 'required|exists:customers,id',
|
||||
'answers' => 'nullable|array',
|
||||
'score' => 'nullable|numeric|min:0|max:100',
|
||||
]);
|
||||
$validated['status'] = 1;
|
||||
|
||||
return $this->success(QuestionnaireAnswer::create($validated));
|
||||
}
|
||||
|
||||
public function answers(Request $request): JsonResponse
|
||||
{
|
||||
$query = QuestionnaireAnswer::query()->with(['template', 'customer']);
|
||||
$query->when($request->questionnaire_template_id, fn($q, $v) => $q->where('questionnaire_template_id', $v));
|
||||
$query->when($request->customer_id, fn($q, $v) => $q->where('customer_id', $v));
|
||||
|
||||
return $this->paginate($query->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Meal;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Meal\DailyMealPlan;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DailyMealPlanController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = DailyMealPlan::query()->with(['customer', 'review']);
|
||||
$query->when($request->customer_id, fn($q, $v) => $q->where('customer_id', $v));
|
||||
$query->when($request->plan_date, fn($q, $v) => $q->whereDate('plan_date', $v));
|
||||
$query->when($request->meal_type, fn($q, $v) => $q->where('meal_type', $v));
|
||||
$query->when($request->has('status'), fn($q) => $q->where('status', $request->status));
|
||||
|
||||
return $this->paginate($query->latest()->paginate($request->input('per_page', 30)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'customer_id' => 'required|exists:customers,id',
|
||||
'plan_date' => 'required|date',
|
||||
'meal_type' => 'required|integer|in:1,2,3,4,5',
|
||||
'dishes' => 'nullable|array',
|
||||
'special_note' => 'nullable|string',
|
||||
]);
|
||||
$validated['status'] = 0;
|
||||
|
||||
return $this->success(DailyMealPlan::create($validated));
|
||||
}
|
||||
|
||||
public function show(DailyMealPlan $dailyMealPlan): JsonResponse
|
||||
{
|
||||
return $this->success($dailyMealPlan->load(['customer', 'review']));
|
||||
}
|
||||
|
||||
public function update(Request $request, DailyMealPlan $dailyMealPlan): JsonResponse
|
||||
{
|
||||
if ($dailyMealPlan->status >= 2) {
|
||||
return $this->error('已送达的排餐不可修改', 40001);
|
||||
}
|
||||
$validated = $request->validate([
|
||||
'meal_type' => 'sometimes|integer|in:1,2,3,4,5',
|
||||
'dishes' => 'nullable|array',
|
||||
'special_note' => 'nullable|string',
|
||||
]);
|
||||
$dailyMealPlan->update($validated);
|
||||
return $this->success($dailyMealPlan);
|
||||
}
|
||||
|
||||
public function destroy(DailyMealPlan $dailyMealPlan): JsonResponse
|
||||
{
|
||||
if ($dailyMealPlan->status >= 1) {
|
||||
return $this->error('已备餐的排餐不可删除', 40001);
|
||||
}
|
||||
$dailyMealPlan->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
|
||||
public function deliver(DailyMealPlan $dailyMealPlan): JsonResponse
|
||||
{
|
||||
if ($dailyMealPlan->status >= 2) {
|
||||
return $this->error('已送达', 40001);
|
||||
}
|
||||
$dailyMealPlan->update([
|
||||
'status' => 2,
|
||||
'deliver_at' => now(),
|
||||
]);
|
||||
return $this->success($dailyMealPlan);
|
||||
}
|
||||
|
||||
public function updateStatus(Request $request, DailyMealPlan $dailyMealPlan): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'status' => 'required|integer|in:0,1,2,3',
|
||||
]);
|
||||
$dailyMealPlan->update($validated);
|
||||
return $this->success($dailyMealPlan);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Meal;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Meal\Dish;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DishController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Dish::query();
|
||||
$query->when($request->name, fn($q, $v) => $q->where('name', 'like', "%{$v}%"));
|
||||
$query->when($request->category, fn($q, $v) => $q->where('category', $v));
|
||||
$query->when($request->has('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:50',
|
||||
'category' => 'nullable|string|max:30',
|
||||
'description' => 'nullable|string',
|
||||
'image' => 'nullable|string|max:255',
|
||||
'ingredients' => 'nullable|array',
|
||||
'contraindications' => 'nullable|array',
|
||||
'price' => 'sometimes|numeric|min:0',
|
||||
'status' => 'sometimes|integer|in:0,1',
|
||||
]);
|
||||
return $this->success(Dish::create($validated));
|
||||
}
|
||||
|
||||
public function show(Dish $dish): JsonResponse
|
||||
{
|
||||
return $this->success($dish);
|
||||
}
|
||||
|
||||
public function update(Request $request, Dish $dish): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'sometimes|string|max:50',
|
||||
'category' => 'nullable|string|max:30',
|
||||
'description' => 'nullable|string',
|
||||
'image' => 'nullable|string|max:255',
|
||||
'ingredients' => 'nullable|array',
|
||||
'contraindications' => 'nullable|array',
|
||||
'price' => 'sometimes|numeric|min:0',
|
||||
'status' => 'sometimes|integer|in:0,1',
|
||||
]);
|
||||
$dish->update($validated);
|
||||
return $this->success($dish);
|
||||
}
|
||||
|
||||
public function destroy(Dish $dish): JsonResponse
|
||||
{
|
||||
$dish->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Meal;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Meal\MealPlanTemplate;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MealPlanTemplateController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = MealPlanTemplate::query();
|
||||
$query->when($request->name, fn($q, $v) => $q->where('name', 'like', "%{$v}%"));
|
||||
$query->when($request->stage, fn($q, $v) => $q->where('stage', $v));
|
||||
$query->when($request->has('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:50',
|
||||
'stage' => 'nullable|string|max:30',
|
||||
'meals' => 'nullable|array',
|
||||
'status' => 'sometimes|integer|in:0,1',
|
||||
]);
|
||||
return $this->success(MealPlanTemplate::create($validated));
|
||||
}
|
||||
|
||||
public function show(MealPlanTemplate $mealPlanTemplate): JsonResponse
|
||||
{
|
||||
return $this->success($mealPlanTemplate);
|
||||
}
|
||||
|
||||
public function update(Request $request, MealPlanTemplate $mealPlanTemplate): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'sometimes|string|max:50',
|
||||
'stage' => 'nullable|string|max:30',
|
||||
'meals' => 'nullable|array',
|
||||
'status' => 'sometimes|integer|in:0,1',
|
||||
]);
|
||||
$mealPlanTemplate->update($validated);
|
||||
return $this->success($mealPlanTemplate);
|
||||
}
|
||||
|
||||
public function destroy(MealPlanTemplate $mealPlanTemplate): JsonResponse
|
||||
{
|
||||
$mealPlanTemplate->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Meal;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Meal\MealReview;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MealReviewController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = MealReview::query()->with(['mealPlan', 'customer']);
|
||||
$query->when($request->customer_id, fn($q, $v) => $q->where('customer_id', $v));
|
||||
$query->when($request->daily_meal_plan_id, fn($q, $v) => $q->where('daily_meal_plan_id', $v));
|
||||
$query->when($request->score, fn($q, $v) => $q->where('score', $v));
|
||||
|
||||
return $this->paginate($query->latest('created_at')->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'daily_meal_plan_id' => 'required|exists:daily_meal_plans,id',
|
||||
'customer_id' => 'required|exists:customers,id',
|
||||
'score' => 'nullable|integer|min:1|max:5',
|
||||
'content' => 'nullable|string',
|
||||
]);
|
||||
return $this->success(MealReview::create($validated));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Room;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Room\CallRecord;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CallRecordController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = CallRecord::query()->with(['room', 'customer', 'handler']);
|
||||
$query->when($request->room_id, fn($q, $v) => $q->where('room_id', $v));
|
||||
$query->when($request->type, fn($q, $v) => $q->where('type', $v));
|
||||
$query->when($request->status, fn($q, $v) => $q->where('status', $v));
|
||||
|
||||
return $this->paginate($query->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'room_id' => 'required|exists:rooms,id',
|
||||
'customer_id' => 'nullable|exists:customers,id',
|
||||
'type' => 'nullable|integer|in:1,2,3,4',
|
||||
'remark' => 'nullable|string|max:255',
|
||||
]);
|
||||
$validated['status'] = 0;
|
||||
|
||||
return $this->success(CallRecord::create($validated));
|
||||
}
|
||||
|
||||
public function handle(Request $request, CallRecord $callRecord): JsonResponse
|
||||
{
|
||||
if ($callRecord->status === 2) {
|
||||
return $this->error('该呼叫已完成', 40001);
|
||||
}
|
||||
$callRecord->update([
|
||||
'status' => 2,
|
||||
'handler_id' => auth()->id(),
|
||||
'handle_at' => now(),
|
||||
'remark' => $request->input('remark', $callRecord->remark),
|
||||
]);
|
||||
return $this->success($callRecord);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Room;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Room\CustomerOuting;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CustomerOutingController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = CustomerOuting::query()->with(['reservation.room', 'customer']);
|
||||
$query->when($request->reservation_id, fn($q, $v) => $q->where('reservation_id', $v));
|
||||
$query->when($request->customer_id, fn($q, $v) => $q->where('customer_id', $v));
|
||||
|
||||
return $this->paginate($query->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'reservation_id' => 'required|exists:reservations,id',
|
||||
'customer_id' => 'required|exists:customers,id',
|
||||
'out_at' => 'required|date',
|
||||
'expected_back_at' => 'nullable|date|after:out_at',
|
||||
'reason' => 'nullable|string',
|
||||
'risk_note' => 'nullable|string',
|
||||
]);
|
||||
$validated['created_by'] = auth()->id();
|
||||
|
||||
return $this->success(CustomerOuting::create($validated));
|
||||
}
|
||||
|
||||
public function show(CustomerOuting $customerOuting): JsonResponse
|
||||
{
|
||||
return $this->success($customerOuting->load(['reservation.room', 'customer']));
|
||||
}
|
||||
|
||||
public function recordBack(Request $request, CustomerOuting $customerOuting): JsonResponse
|
||||
{
|
||||
if ($customerOuting->actual_back_at) {
|
||||
return $this->error('已记录返回时间', 40001);
|
||||
}
|
||||
$customerOuting->update(['actual_back_at' => $request->input('actual_back_at', now())]);
|
||||
return $this->success($customerOuting);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Room;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Room\Reservation;
|
||||
use App\Models\Room\Room;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ReservationController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Reservation::query()->with(['customer', 'room.roomType']);
|
||||
$query->when($request->customer_id, fn($q, $v) => $q->where('customer_id', $v));
|
||||
$query->when($request->room_id, fn($q, $v) => $q->where('room_id', $v));
|
||||
$query->when($request->status, fn($q, $v) => $q->where('status', $v));
|
||||
$query->when($request->check_in_date, fn($q, $v) => $q->whereDate('check_in_date', $v));
|
||||
|
||||
return $this->paginate($query->latest()->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'customer_id' => 'required|exists:customers,id',
|
||||
'contract_id' => 'nullable|exists:contracts,id',
|
||||
'room_id' => 'required|exists:rooms,id',
|
||||
'check_in_date' => 'required|date',
|
||||
'check_out_date' => 'required|date|after_or_equal:check_in_date',
|
||||
'remark' => 'nullable|string',
|
||||
]);
|
||||
$validated['created_by'] = auth()->id();
|
||||
$validated['status'] = 0;
|
||||
|
||||
$reservation = Reservation::create($validated);
|
||||
Room::find($validated['room_id'])->update(['status' => 2]);
|
||||
|
||||
return $this->success($reservation);
|
||||
}
|
||||
|
||||
public function show(Reservation $reservation): JsonResponse
|
||||
{
|
||||
return $this->success($reservation->load(['customer', 'room.roomType', 'contract', 'outings']));
|
||||
}
|
||||
|
||||
public function update(Request $request, Reservation $reservation): JsonResponse
|
||||
{
|
||||
if ($reservation->status >= 2) {
|
||||
return $this->error('已退房或已取消的预定不可修改', 40001);
|
||||
}
|
||||
$validated = $request->validate([
|
||||
'room_id' => 'sometimes|exists:rooms,id',
|
||||
'check_in_date' => 'sometimes|date',
|
||||
'check_out_date' => 'sometimes|date|after_or_equal:check_in_date',
|
||||
'remark' => 'nullable|string',
|
||||
]);
|
||||
$reservation->update($validated);
|
||||
return $this->success($reservation);
|
||||
}
|
||||
|
||||
public function destroy(Reservation $reservation): JsonResponse
|
||||
{
|
||||
if ($reservation->status === 1) {
|
||||
return $this->error('已入住的预定不可删除', 40001);
|
||||
}
|
||||
$reservation->room->update(['status' => 1]);
|
||||
$reservation->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
|
||||
public function checkIn(Reservation $reservation): JsonResponse
|
||||
{
|
||||
if ($reservation->status !== 0) {
|
||||
return $this->error('只有预定状态可以办理入住', 40001);
|
||||
}
|
||||
$reservation->update([
|
||||
'status' => 1,
|
||||
'actual_check_in' => now(),
|
||||
]);
|
||||
$reservation->room->update(['status' => 3]);
|
||||
$reservation->customer->update(['status' => 3]);
|
||||
|
||||
return $this->success($reservation);
|
||||
}
|
||||
|
||||
public function checkOut(Reservation $reservation): JsonResponse
|
||||
{
|
||||
if ($reservation->status !== 1) {
|
||||
return $this->error('只有入住状态可以办理退房', 40001);
|
||||
}
|
||||
$reservation->update([
|
||||
'status' => 2,
|
||||
'actual_check_out' => now(),
|
||||
]);
|
||||
$reservation->room->update(['status' => 5]);
|
||||
$reservation->customer->update(['status' => 4]);
|
||||
|
||||
return $this->success($reservation);
|
||||
}
|
||||
|
||||
public function cancel(Request $request, Reservation $reservation): JsonResponse
|
||||
{
|
||||
if ($reservation->status >= 2) {
|
||||
return $this->error('已退房或已取消的预定不可取消', 40001);
|
||||
}
|
||||
$reservation->update(['status' => 3, 'remark' => $request->input('remark', $reservation->remark)]);
|
||||
$reservation->room->update(['status' => 1]);
|
||||
|
||||
return $this->success($reservation);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Room;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Room\Room;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RoomController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Room::query()->with('roomType');
|
||||
$query->when($request->room_type_id, fn($q, $v) => $q->where('room_type_id', $v));
|
||||
$query->when($request->floor, fn($q, $v) => $q->where('floor', $v));
|
||||
$query->when($request->status, fn($q, $v) => $q->where('status', $v));
|
||||
$query->when($request->number, fn($q, $v) => $q->where('number', 'like', "%{$v}%"));
|
||||
|
||||
return $this->paginate($query->orderBy('sort')->paginate($request->input('per_page', 50)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'room_type_id' => 'required|exists:room_types,id',
|
||||
'floor' => 'nullable|string|max:10',
|
||||
'number' => 'required|string|max:20',
|
||||
'status' => 'sometimes|integer|in:1,2,3,4,5',
|
||||
'sort' => 'sometimes|integer',
|
||||
]);
|
||||
return $this->success(Room::create($validated));
|
||||
}
|
||||
|
||||
public function show(Room $room): JsonResponse
|
||||
{
|
||||
return $this->success($room->load(['roomType', 'reservations.customer']));
|
||||
}
|
||||
|
||||
public function update(Request $request, Room $room): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'room_type_id' => 'sometimes|exists:room_types,id',
|
||||
'floor' => 'nullable|string|max:10',
|
||||
'number' => 'sometimes|string|max:20',
|
||||
'sort' => 'sometimes|integer',
|
||||
]);
|
||||
$room->update($validated);
|
||||
return $this->success($room);
|
||||
}
|
||||
|
||||
public function destroy(Room $room): JsonResponse
|
||||
{
|
||||
if ($room->status === 3) {
|
||||
return $this->error('入住中的房间无法删除', 40001);
|
||||
}
|
||||
$room->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
|
||||
public function updateStatus(Request $request, Room $room): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'status' => 'required|integer|in:1,2,3,4,5',
|
||||
]);
|
||||
$room->update($validated);
|
||||
return $this->success($room);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Room;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Room\RoomType;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RoomTypeController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = RoomType::query()->withCount('rooms');
|
||||
$query->when($request->name, fn($q, $v) => $q->where('name', 'like', "%{$v}%"));
|
||||
$query->when($request->has('status'), fn($q) => $q->where('status', $request->status));
|
||||
|
||||
return $this->paginate($query->orderBy('sort')->paginate($request->input('per_page', 15)));
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:50',
|
||||
'price' => 'nullable|numeric|min:0',
|
||||
'description' => 'nullable|string',
|
||||
'images' => 'nullable|array',
|
||||
'facilities' => 'nullable|array',
|
||||
'sort' => 'sometimes|integer',
|
||||
'status' => 'sometimes|integer|in:0,1',
|
||||
]);
|
||||
return $this->success(RoomType::create($validated));
|
||||
}
|
||||
|
||||
public function show(RoomType $roomType): JsonResponse
|
||||
{
|
||||
return $this->success($roomType->load('rooms'));
|
||||
}
|
||||
|
||||
public function update(Request $request, RoomType $roomType): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'sometimes|string|max:50',
|
||||
'price' => 'nullable|numeric|min:0',
|
||||
'description' => 'nullable|string',
|
||||
'images' => 'nullable|array',
|
||||
'facilities' => 'nullable|array',
|
||||
'sort' => 'sometimes|integer',
|
||||
'status' => 'sometimes|integer|in:0,1',
|
||||
]);
|
||||
$roomType->update($validated);
|
||||
return $this->success($roomType);
|
||||
}
|
||||
|
||||
public function destroy(RoomType $roomType): JsonResponse
|
||||
{
|
||||
if ($roomType->rooms()->exists()) {
|
||||
return $this->error('该房型下有房间,无法删除', 40001);
|
||||
}
|
||||
$roomType->delete();
|
||||
return $this->success(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Care;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class CareException extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'care_profile_id', 'reporter_id', 'level', 'description',
|
||||
'images', 'status', 'handler_id', 'handle_result', 'handle_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'level' => 'integer',
|
||||
'images' => 'array',
|
||||
'status' => 'integer',
|
||||
'handle_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function profile(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CareProfile::class, 'care_profile_id');
|
||||
}
|
||||
|
||||
public function reporter(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'reporter_id');
|
||||
}
|
||||
|
||||
public function handler(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'handler_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Care;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class CarePlan extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'care_profile_id', 'plan_date', 'stage', 'items',
|
||||
'nurse_id', 'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'plan_date' => 'date',
|
||||
'items' => 'array',
|
||||
'status' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function profile(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CareProfile::class, 'care_profile_id');
|
||||
}
|
||||
|
||||
public function nurse(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'nurse_id');
|
||||
}
|
||||
|
||||
public function records(): HasMany
|
||||
{
|
||||
return $this->hasMany(CareRecord::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Care;
|
||||
|
||||
use App\Models\Crm\Customer;
|
||||
use App\Models\Room\Reservation;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class CareProfile extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'customer_id', 'reservation_id', 'type', 'baby_name', 'baby_gender',
|
||||
'baby_birthday', 'birth_weight', 'birth_method',
|
||||
'allergies', 'medical_history', 'risk_level', 'assessment',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'integer',
|
||||
'baby_gender' => 'integer',
|
||||
'baby_birthday' => 'datetime',
|
||||
'birth_weight' => 'decimal:2',
|
||||
'birth_method' => 'integer',
|
||||
'risk_level' => 'integer',
|
||||
'assessment' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function reservation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Reservation::class);
|
||||
}
|
||||
|
||||
public function plans(): HasMany
|
||||
{
|
||||
return $this->hasMany(CarePlan::class);
|
||||
}
|
||||
|
||||
public function records(): HasMany
|
||||
{
|
||||
return $this->hasMany(CareRecord::class);
|
||||
}
|
||||
|
||||
public function exceptions(): HasMany
|
||||
{
|
||||
return $this->hasMany(CareException::class);
|
||||
}
|
||||
|
||||
public function healthMetrics(): HasMany
|
||||
{
|
||||
return $this->hasMany(HealthMetric::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Care;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class CareRecord extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'care_profile_id', 'care_plan_id', 'type',
|
||||
'items', 'remark', 'images', 'nurse_id', 'recorded_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'integer',
|
||||
'items' => 'array',
|
||||
'images' => 'array',
|
||||
'recorded_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function profile(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CareProfile::class, 'care_profile_id');
|
||||
}
|
||||
|
||||
public function plan(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CarePlan::class, 'care_plan_id');
|
||||
}
|
||||
|
||||
public function nurse(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'nurse_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Care;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class HealthMetric extends Model
|
||||
{
|
||||
const UPDATED_AT = null;
|
||||
|
||||
protected $fillable = [
|
||||
'care_profile_id', 'metric_type', 'value', 'unit',
|
||||
'recorded_at', 'recorder_id', 'remark',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'value' => 'decimal:2',
|
||||
'recorded_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function profile(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CareProfile::class, 'care_profile_id');
|
||||
}
|
||||
|
||||
public function recorder(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'recorder_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Crm;
|
||||
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Channel extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'name', 'type', 'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'integer',
|
||||
'status' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function leads(): HasMany
|
||||
{
|
||||
return $this->hasMany(Lead::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Crm;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Complaint extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'customer_id', 'type', 'content', 'images',
|
||||
'status', 'handler_id', 'handle_result', 'handle_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'integer',
|
||||
'images' => 'array',
|
||||
'status' => 'integer',
|
||||
'handle_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function handler(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'handler_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Crm;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Contract extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'customer_id', 'contract_no', 'package_name',
|
||||
'total_amount', 'discount_amount', 'actual_amount',
|
||||
'days', 'check_in_date', 'check_out_date',
|
||||
'status', 'audit_user_id', 'audit_at', 'audit_remark',
|
||||
'remark', 'created_by',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'total_amount' => 'decimal:2',
|
||||
'discount_amount' => 'decimal:2',
|
||||
'actual_amount' => 'decimal:2',
|
||||
'days' => 'integer',
|
||||
'check_in_date' => 'date',
|
||||
'check_out_date' => 'date',
|
||||
'status' => 'integer',
|
||||
'audit_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function auditor(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'audit_user_id');
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Crm;
|
||||
|
||||
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;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Customer extends Model
|
||||
{
|
||||
use BelongsToStore, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'lead_id', 'name', 'phone', 'id_card', 'wechat',
|
||||
'birthday', 'expected_date', 'actual_date', 'baby_count',
|
||||
'tags', 'status', 'owner_id', 'remark',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'birthday' => 'date',
|
||||
'expected_date' => 'date',
|
||||
'actual_date' => 'date',
|
||||
'baby_count' => 'integer',
|
||||
'tags' => 'array',
|
||||
'status' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function lead(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Lead::class);
|
||||
}
|
||||
|
||||
public function owner(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'owner_id');
|
||||
}
|
||||
|
||||
public function families(): HasMany
|
||||
{
|
||||
return $this->hasMany(CustomerFamily::class);
|
||||
}
|
||||
|
||||
public function contracts(): HasMany
|
||||
{
|
||||
return $this->hasMany(Contract::class);
|
||||
}
|
||||
|
||||
public function questionnaireAnswers(): HasMany
|
||||
{
|
||||
return $this->hasMany(QuestionnaireAnswer::class);
|
||||
}
|
||||
|
||||
public function complaints(): HasMany
|
||||
{
|
||||
return $this->hasMany(Complaint::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Crm;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class CustomerFamily extends Model
|
||||
{
|
||||
protected $table = 'customer_families';
|
||||
|
||||
protected $fillable = [
|
||||
'customer_id', 'name', 'phone', 'relation', 'is_emergency',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_emergency' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Crm;
|
||||
|
||||
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 Lead extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'channel_id', 'name', 'phone', 'wechat',
|
||||
'expected_date', 'source', 'status', 'owner_id',
|
||||
'remark', 'created_by',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'expected_date' => 'date',
|
||||
'status' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function channel(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Channel::class);
|
||||
}
|
||||
|
||||
public function owner(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'owner_id');
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
public function follows(): HasMany
|
||||
{
|
||||
return $this->hasMany(LeadFollow::class);
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Crm;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class LeadFollow extends Model
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'lead_id', 'user_id', 'type', 'content', 'next_follow_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'integer',
|
||||
'next_follow_at' => 'datetime',
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function lead(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Lead::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Crm;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class QuestionnaireAnswer extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'questionnaire_template_id', 'customer_id',
|
||||
'answers', 'score', 'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'answers' => 'array',
|
||||
'score' => 'decimal:2',
|
||||
'status' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function template(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(QuestionnaireTemplate::class, 'questionnaire_template_id');
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Crm;
|
||||
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class QuestionnaireTemplate extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'title', 'description', 'questions', 'type', 'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'questions' => 'array',
|
||||
'type' => 'integer',
|
||||
'status' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function answers(): HasMany
|
||||
{
|
||||
return $this->hasMany(QuestionnaireAnswer::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Meal;
|
||||
|
||||
use App\Models\Crm\Customer;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
class DailyMealPlan extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'customer_id', 'plan_date', 'meal_type',
|
||||
'dishes', 'special_note', 'status', 'deliver_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'plan_date' => 'date',
|
||||
'meal_type' => 'integer',
|
||||
'dishes' => 'array',
|
||||
'status' => 'integer',
|
||||
'deliver_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function review(): HasOne
|
||||
{
|
||||
return $this->hasOne(MealReview::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Meal;
|
||||
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Dish extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'name', 'category', 'description', 'image',
|
||||
'ingredients', 'contraindications', 'price', 'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'ingredients' => 'array',
|
||||
'contraindications' => 'array',
|
||||
'price' => 'decimal:2',
|
||||
'status' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Meal;
|
||||
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MealPlanTemplate extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'name', 'stage', 'meals', 'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'meals' => 'array',
|
||||
'status' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Meal;
|
||||
|
||||
use App\Models\Crm\Customer;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class MealReview extends Model
|
||||
{
|
||||
const UPDATED_AT = null;
|
||||
|
||||
protected $fillable = [
|
||||
'daily_meal_plan_id', 'customer_id', 'score', 'content',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'score' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function mealPlan(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DailyMealPlan::class, 'daily_meal_plan_id');
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Room;
|
||||
|
||||
use App\Models\Crm\Customer;
|
||||
use App\Models\User;
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class CallRecord extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'room_id', 'customer_id', 'type',
|
||||
'status', 'handler_id', 'handle_at', 'remark',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'integer',
|
||||
'status' => 'integer',
|
||||
'handle_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function room(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Room::class);
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function handler(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'handler_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Room;
|
||||
|
||||
use App\Models\Crm\Customer;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class CustomerOuting extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'reservation_id', 'customer_id', 'out_at', 'expected_back_at',
|
||||
'actual_back_at', 'reason', 'risk_note', 'created_by',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'out_at' => 'datetime',
|
||||
'expected_back_at' => 'datetime',
|
||||
'actual_back_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function reservation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Reservation::class);
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Room;
|
||||
|
||||
use App\Models\Crm\Customer;
|
||||
use App\Models\Crm\Contract;
|
||||
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 Reservation extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'customer_id', 'contract_id', 'room_id',
|
||||
'check_in_date', 'check_out_date',
|
||||
'actual_check_in', 'actual_check_out',
|
||||
'status', 'remark', 'created_by',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'check_in_date' => 'date',
|
||||
'check_out_date' => 'date',
|
||||
'actual_check_in' => 'datetime',
|
||||
'actual_check_out' => 'datetime',
|
||||
'status' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function contract(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Contract::class);
|
||||
}
|
||||
|
||||
public function room(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Room::class);
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
public function outings(): HasMany
|
||||
{
|
||||
return $this->hasMany(CustomerOuting::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Room;
|
||||
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Room extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'room_type_id', 'floor', 'number',
|
||||
'status', 'sort',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => 'integer',
|
||||
'sort' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function roomType(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(RoomType::class);
|
||||
}
|
||||
|
||||
public function reservations(): HasMany
|
||||
{
|
||||
return $this->hasMany(Reservation::class);
|
||||
}
|
||||
|
||||
public function callRecords(): HasMany
|
||||
{
|
||||
return $this->hasMany(CallRecord::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Room;
|
||||
|
||||
use App\Traits\BelongsToStore;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class RoomType extends Model
|
||||
{
|
||||
use BelongsToStore;
|
||||
|
||||
protected $fillable = [
|
||||
'store_id', 'name', 'price', 'description',
|
||||
'images', 'facilities', 'sort', 'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'price' => 'decimal:2',
|
||||
'images' => 'array',
|
||||
'facilities' => 'array',
|
||||
'sort' => 'integer',
|
||||
'status' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function rooms(): HasMany
|
||||
{
|
||||
return $this->hasMany(Room::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
<?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('channels', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('store_id')->constrained();
|
||||
$table->string('name', 50);
|
||||
$table->tinyInteger('type')->nullable()->comment('1线上 2线下 3转介绍');
|
||||
$table->tinyInteger('status')->default(1);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// 线索
|
||||
Schema::create('leads', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('store_id')->constrained();
|
||||
$table->unsignedBigInteger('channel_id')->nullable();
|
||||
$table->string('name', 50);
|
||||
$table->string('phone', 20);
|
||||
$table->string('wechat', 50)->nullable();
|
||||
$table->date('expected_date')->nullable()->comment('预产期');
|
||||
$table->string('source', 50)->nullable();
|
||||
$table->tinyInteger('status')->default(1)->comment('1新建 2跟进中 3已转化 4无效');
|
||||
$table->unsignedBigInteger('owner_id')->nullable()->comment('负责销售');
|
||||
$table->text('remark')->nullable();
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index(['store_id', 'status']);
|
||||
$table->index('owner_id');
|
||||
$table->index('phone');
|
||||
});
|
||||
|
||||
// 线索跟进记录
|
||||
Schema::create('lead_follows', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('lead_id')->constrained()->onDelete('cascade');
|
||||
$table->unsignedBigInteger('user_id');
|
||||
$table->tinyInteger('type')->nullable()->comment('1电话 2微信 3到店 4其他');
|
||||
$table->text('content')->nullable();
|
||||
$table->timestamp('next_follow_at')->nullable();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->index('lead_id');
|
||||
});
|
||||
|
||||
// 客户
|
||||
Schema::create('customers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('store_id')->constrained();
|
||||
$table->unsignedBigInteger('lead_id')->nullable();
|
||||
$table->string('name', 50);
|
||||
$table->string('phone', 20);
|
||||
$table->string('id_card', 20)->nullable();
|
||||
$table->string('wechat', 50)->nullable();
|
||||
$table->date('birthday')->nullable();
|
||||
$table->date('expected_date')->nullable();
|
||||
$table->date('actual_date')->nullable();
|
||||
$table->tinyInteger('baby_count')->default(1);
|
||||
$table->json('tags')->nullable();
|
||||
$table->tinyInteger('status')->default(1)->comment('1潜在 2签约 3在住 4离店 5无效');
|
||||
$table->unsignedBigInteger('owner_id')->nullable();
|
||||
$table->text('remark')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->index(['store_id', 'status']);
|
||||
$table->index('phone');
|
||||
});
|
||||
|
||||
// 客户家属
|
||||
Schema::create('customer_families', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('customer_id')->constrained()->onDelete('cascade');
|
||||
$table->string('name', 50)->nullable();
|
||||
$table->string('phone', 20)->nullable();
|
||||
$table->string('relation', 20)->nullable();
|
||||
$table->tinyInteger('is_emergency')->default(0);
|
||||
$table->timestamps();
|
||||
$table->index('customer_id');
|
||||
});
|
||||
|
||||
// 合同
|
||||
Schema::create('contracts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('store_id')->constrained();
|
||||
$table->foreignId('customer_id')->constrained();
|
||||
$table->string('contract_no', 50)->unique();
|
||||
$table->string('package_name', 100)->nullable();
|
||||
$table->decimal('total_amount', 12, 2);
|
||||
$table->decimal('discount_amount', 12, 2)->default(0);
|
||||
$table->decimal('actual_amount', 12, 2);
|
||||
$table->integer('days')->nullable();
|
||||
$table->date('check_in_date')->nullable();
|
||||
$table->date('check_out_date')->nullable();
|
||||
$table->tinyInteger('status')->default(0)->comment('0待审 1通过 2无效 3已退');
|
||||
$table->unsignedBigInteger('audit_user_id')->nullable();
|
||||
$table->timestamp('audit_at')->nullable();
|
||||
$table->string('audit_remark', 255)->nullable();
|
||||
$table->text('remark')->nullable();
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('store_id');
|
||||
$table->index('customer_id');
|
||||
});
|
||||
|
||||
// 问卷模板
|
||||
Schema::create('questionnaire_templates', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('store_id')->nullable();
|
||||
$table->string('title', 100);
|
||||
$table->text('description')->nullable();
|
||||
$table->json('questions')->nullable();
|
||||
$table->tinyInteger('type')->nullable()->comment('1入住前 2入住中 3离店 4回访');
|
||||
$table->tinyInteger('status')->default(1);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// 问卷回收
|
||||
Schema::create('questionnaire_answers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('questionnaire_template_id')->constrained('questionnaire_templates')->onDelete('cascade');
|
||||
$table->foreignId('customer_id')->constrained();
|
||||
$table->json('answers')->nullable();
|
||||
$table->decimal('score', 5, 2)->nullable();
|
||||
$table->tinyInteger('status')->default(0)->comment('0未完成 1已提交');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// 投诉
|
||||
Schema::create('complaints', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('store_id')->constrained();
|
||||
$table->foreignId('customer_id')->constrained();
|
||||
$table->tinyInteger('type')->nullable()->comment('1服务 2膳食 3环境 4其他');
|
||||
$table->text('content');
|
||||
$table->json('images')->nullable();
|
||||
$table->tinyInteger('status')->default(0)->comment('0待处理 1处理中 2已解决 3已关闭');
|
||||
$table->unsignedBigInteger('handler_id')->nullable();
|
||||
$table->text('handle_result')->nullable();
|
||||
$table->timestamp('handle_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index(['store_id', 'status']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('complaints');
|
||||
Schema::dropIfExists('questionnaire_answers');
|
||||
Schema::dropIfExists('questionnaire_templates');
|
||||
Schema::dropIfExists('contracts');
|
||||
Schema::dropIfExists('customer_families');
|
||||
Schema::dropIfExists('customers');
|
||||
Schema::dropIfExists('lead_follows');
|
||||
Schema::dropIfExists('leads');
|
||||
Schema::dropIfExists('channels');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,95 @@
|
||||
<?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('room_types', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('store_id')->constrained();
|
||||
$table->string('name', 50);
|
||||
$table->decimal('price', 12, 2)->nullable()->comment('日单价');
|
||||
$table->text('description')->nullable();
|
||||
$table->json('images')->nullable();
|
||||
$table->json('facilities')->nullable();
|
||||
$table->integer('sort')->default(0);
|
||||
$table->tinyInteger('status')->default(1);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// 房间
|
||||
Schema::create('rooms', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('store_id')->constrained();
|
||||
$table->foreignId('room_type_id')->constrained();
|
||||
$table->string('floor', 10)->nullable();
|
||||
$table->string('number', 20);
|
||||
$table->tinyInteger('status')->default(1)->comment('1空房 2已预定 3入住 4维修 5清洁');
|
||||
$table->integer('sort')->default(0);
|
||||
$table->timestamps();
|
||||
$table->unique(['store_id', 'number']);
|
||||
});
|
||||
|
||||
// 预定/入住记录
|
||||
Schema::create('reservations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('store_id')->constrained();
|
||||
$table->foreignId('customer_id')->constrained();
|
||||
$table->unsignedBigInteger('contract_id')->nullable();
|
||||
$table->foreignId('room_id')->constrained();
|
||||
$table->date('check_in_date');
|
||||
$table->date('check_out_date');
|
||||
$table->timestamp('actual_check_in')->nullable();
|
||||
$table->timestamp('actual_check_out')->nullable();
|
||||
$table->tinyInteger('status')->default(0)->comment('0预定 1已入住 2已退房 3已取消');
|
||||
$table->text('remark')->nullable();
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index(['room_id', 'check_in_date', 'check_out_date']);
|
||||
$table->index('customer_id');
|
||||
});
|
||||
|
||||
// 客户外出记录
|
||||
Schema::create('customer_outings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('reservation_id')->constrained();
|
||||
$table->foreignId('customer_id')->constrained();
|
||||
$table->timestamp('out_at');
|
||||
$table->timestamp('expected_back_at')->nullable();
|
||||
$table->timestamp('actual_back_at')->nullable();
|
||||
$table->text('reason')->nullable();
|
||||
$table->text('risk_note')->nullable();
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// 呼叫记录
|
||||
Schema::create('call_records', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('store_id')->constrained();
|
||||
$table->foreignId('room_id')->constrained();
|
||||
$table->unsignedBigInteger('customer_id')->nullable();
|
||||
$table->tinyInteger('type')->nullable()->comment('1护理 2清洁 3送水 4其他');
|
||||
$table->tinyInteger('status')->default(0)->comment('0待处理 1处理中 2已完成');
|
||||
$table->unsignedBigInteger('handler_id')->nullable();
|
||||
$table->timestamp('handle_at')->nullable();
|
||||
$table->string('remark', 255)->nullable();
|
||||
$table->timestamps();
|
||||
$table->index(['store_id', 'status']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('call_records');
|
||||
Schema::dropIfExists('customer_outings');
|
||||
Schema::dropIfExists('reservations');
|
||||
Schema::dropIfExists('rooms');
|
||||
Schema::dropIfExists('room_types');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,99 @@
|
||||
<?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('care_profiles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('customer_id')->constrained();
|
||||
$table->unsignedBigInteger('reservation_id')->nullable();
|
||||
$table->tinyInteger('type')->comment('1妈妈 2宝宝');
|
||||
$table->string('baby_name', 50)->nullable();
|
||||
$table->tinyInteger('baby_gender')->nullable()->comment('1男 2女');
|
||||
$table->dateTime('baby_birthday')->nullable();
|
||||
$table->decimal('birth_weight', 5, 2)->nullable();
|
||||
$table->tinyInteger('birth_method')->nullable()->comment('1顺产 2剖宫产');
|
||||
$table->text('allergies')->nullable();
|
||||
$table->text('medical_history')->nullable();
|
||||
$table->tinyInteger('risk_level')->default(0)->comment('0正常 1低风险 2高风险');
|
||||
$table->json('assessment')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('customer_id');
|
||||
});
|
||||
|
||||
// 护理计划
|
||||
Schema::create('care_plans', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('care_profile_id')->constrained()->onDelete('cascade');
|
||||
$table->date('plan_date');
|
||||
$table->string('stage', 50)->nullable()->comment('阶段:产后第X天');
|
||||
$table->json('items')->nullable();
|
||||
$table->unsignedBigInteger('nurse_id')->nullable();
|
||||
$table->tinyInteger('status')->default(0)->comment('0待执行 1执行中 2已完成');
|
||||
$table->timestamps();
|
||||
$table->index(['care_profile_id', 'plan_date']);
|
||||
});
|
||||
|
||||
// 护理记录
|
||||
Schema::create('care_records', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('care_profile_id')->constrained()->onDelete('cascade');
|
||||
$table->unsignedBigInteger('care_plan_id')->nullable();
|
||||
$table->tinyInteger('type')->nullable()->comment('1妈妈护理 2宝宝护理');
|
||||
$table->json('items')->nullable();
|
||||
$table->text('remark')->nullable();
|
||||
$table->json('images')->nullable();
|
||||
$table->unsignedBigInteger('nurse_id');
|
||||
$table->timestamp('recorded_at');
|
||||
$table->timestamps();
|
||||
$table->index('care_profile_id');
|
||||
$table->index('recorded_at');
|
||||
});
|
||||
|
||||
// 护理异常
|
||||
Schema::create('care_exceptions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('care_profile_id')->constrained()->onDelete('cascade');
|
||||
$table->unsignedBigInteger('reporter_id');
|
||||
$table->tinyInteger('level')->comment('1一般 2重要 3紧急');
|
||||
$table->text('description');
|
||||
$table->json('images')->nullable();
|
||||
$table->tinyInteger('status')->default(0)->comment('0上报 1处理中 2已解决');
|
||||
$table->unsignedBigInteger('handler_id')->nullable();
|
||||
$table->text('handle_result')->nullable();
|
||||
$table->timestamp('handle_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('care_profile_id');
|
||||
});
|
||||
|
||||
// 健康指标记录
|
||||
Schema::create('health_metrics', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('care_profile_id')->constrained()->onDelete('cascade');
|
||||
$table->string('metric_type', 30)->comment('temperature/weight/jaundice/blood_pressure');
|
||||
$table->decimal('value', 8, 2);
|
||||
$table->string('unit', 10)->nullable();
|
||||
$table->timestamp('recorded_at');
|
||||
$table->unsignedBigInteger('recorder_id')->nullable();
|
||||
$table->string('remark', 255)->nullable();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->index(['care_profile_id', 'metric_type']);
|
||||
$table->index('recorded_at');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('health_metrics');
|
||||
Schema::dropIfExists('care_exceptions');
|
||||
Schema::dropIfExists('care_records');
|
||||
Schema::dropIfExists('care_plans');
|
||||
Schema::dropIfExists('care_profiles');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,73 @@
|
||||
<?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('dishes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('store_id')->constrained();
|
||||
$table->string('name', 50);
|
||||
$table->string('category', 30)->nullable()->comment('汤/主食/配菜/甜品');
|
||||
$table->text('description')->nullable();
|
||||
$table->string('image', 255)->nullable();
|
||||
$table->json('ingredients')->nullable();
|
||||
$table->json('contraindications')->nullable()->comment('禁忌');
|
||||
$table->decimal('price', 8, 2)->default(0);
|
||||
$table->tinyInteger('status')->default(1);
|
||||
$table->timestamps();
|
||||
$table->index('store_id');
|
||||
});
|
||||
|
||||
// 排餐模板
|
||||
Schema::create('meal_plan_templates', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('store_id')->constrained();
|
||||
$table->string('name', 50);
|
||||
$table->string('stage', 30)->nullable()->comment('适用阶段');
|
||||
$table->json('meals')->nullable();
|
||||
$table->tinyInteger('status')->default(1);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// 每日排餐
|
||||
Schema::create('daily_meal_plans', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('store_id')->constrained();
|
||||
$table->foreignId('customer_id')->constrained();
|
||||
$table->date('plan_date');
|
||||
$table->tinyInteger('meal_type')->comment('1早餐 2午餐 3下午茶 4晚餐 5宵夜');
|
||||
$table->json('dishes')->nullable();
|
||||
$table->text('special_note')->nullable();
|
||||
$table->tinyInteger('status')->default(0)->comment('0待备餐 1已备餐 2已送达 3未用');
|
||||
$table->timestamp('deliver_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index(['customer_id', 'plan_date']);
|
||||
$table->index(['store_id', 'plan_date']);
|
||||
});
|
||||
|
||||
// 膳食评价
|
||||
Schema::create('meal_reviews', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('daily_meal_plan_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('customer_id')->constrained();
|
||||
$table->tinyInteger('score')->nullable()->comment('1-5星');
|
||||
$table->text('content')->nullable();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->index('daily_meal_plan_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('meal_reviews');
|
||||
Schema::dropIfExists('daily_meal_plans');
|
||||
Schema::dropIfExists('meal_plan_templates');
|
||||
Schema::dropIfExists('dishes');
|
||||
}
|
||||
};
|
||||
@@ -11,6 +11,26 @@ use App\Http\Controllers\Admin\System\MenuController;
|
||||
use App\Http\Controllers\Admin\System\PermissionController;
|
||||
use App\Http\Controllers\Admin\System\DictionaryController;
|
||||
use App\Http\Controllers\Admin\System\OperationLogController;
|
||||
use App\Http\Controllers\Admin\Crm\ChannelController;
|
||||
use App\Http\Controllers\Admin\Crm\LeadController;
|
||||
use App\Http\Controllers\Admin\Crm\CustomerController;
|
||||
use App\Http\Controllers\Admin\Crm\ContractController;
|
||||
use App\Http\Controllers\Admin\Crm\QuestionnaireController;
|
||||
use App\Http\Controllers\Admin\Crm\ComplaintController;
|
||||
use App\Http\Controllers\Admin\Room\RoomTypeController;
|
||||
use App\Http\Controllers\Admin\Room\RoomController;
|
||||
use App\Http\Controllers\Admin\Room\ReservationController;
|
||||
use App\Http\Controllers\Admin\Room\CustomerOutingController;
|
||||
use App\Http\Controllers\Admin\Room\CallRecordController;
|
||||
use App\Http\Controllers\Admin\Care\CareProfileController;
|
||||
use App\Http\Controllers\Admin\Care\CarePlanController;
|
||||
use App\Http\Controllers\Admin\Care\CareRecordController;
|
||||
use App\Http\Controllers\Admin\Care\CareExceptionController;
|
||||
use App\Http\Controllers\Admin\Care\HealthMetricController;
|
||||
use App\Http\Controllers\Admin\Meal\DishController;
|
||||
use App\Http\Controllers\Admin\Meal\MealPlanTemplateController;
|
||||
use App\Http\Controllers\Admin\Meal\DailyMealPlanController;
|
||||
use App\Http\Controllers\Admin\Meal\MealReviewController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -66,4 +86,94 @@ Route::middleware(['auth:sanctum', 'store', 'oplog'])->group(function () {
|
||||
// 操作日志
|
||||
Route::get('operation-logs', [OperationLogController::class, 'index']);
|
||||
});
|
||||
|
||||
// --- CRM 客户关系模块 ---
|
||||
Route::prefix('crm')->group(function () {
|
||||
// 渠道管理
|
||||
Route::apiResource('channels', ChannelController::class);
|
||||
|
||||
// 线索管理
|
||||
Route::apiResource('leads', LeadController::class);
|
||||
Route::post('leads/{lead}/follow', [LeadController::class, 'follow']);
|
||||
Route::put('leads/{lead}/assign', [LeadController::class, 'assign']);
|
||||
|
||||
// 客户管理
|
||||
Route::apiResource('customers', CustomerController::class);
|
||||
|
||||
// 合同管理
|
||||
Route::apiResource('contracts', ContractController::class);
|
||||
Route::put('contracts/{contract}/audit', [ContractController::class, 'audit']);
|
||||
|
||||
// 问卷管理
|
||||
Route::apiResource('questionnaires', QuestionnaireController::class);
|
||||
Route::post('questionnaire-answers', [QuestionnaireController::class, 'submitAnswer']);
|
||||
Route::get('questionnaire-answers', [QuestionnaireController::class, 'answers']);
|
||||
|
||||
// 投诉管理
|
||||
Route::apiResource('complaints', ComplaintController::class);
|
||||
Route::put('complaints/{complaint}/handle', [ComplaintController::class, 'handle']);
|
||||
});
|
||||
|
||||
// --- 房务管理模块 ---
|
||||
Route::prefix('room')->group(function () {
|
||||
// 房型管理
|
||||
Route::apiResource('room-types', RoomTypeController::class);
|
||||
|
||||
// 房间管理
|
||||
Route::apiResource('rooms', RoomController::class);
|
||||
Route::put('rooms/{room}/status', [RoomController::class, 'updateStatus']);
|
||||
|
||||
// 预定管理
|
||||
Route::apiResource('reservations', ReservationController::class);
|
||||
Route::put('reservations/{reservation}/check-in', [ReservationController::class, 'checkIn']);
|
||||
Route::put('reservations/{reservation}/check-out', [ReservationController::class, 'checkOut']);
|
||||
Route::put('reservations/{reservation}/cancel', [ReservationController::class, 'cancel']);
|
||||
|
||||
// 外出记录
|
||||
Route::apiResource('customer-outings', CustomerOutingController::class)->only(['index', 'store', 'show']);
|
||||
Route::put('customer-outings/{customerOuting}/back', [CustomerOutingController::class, 'recordBack']);
|
||||
|
||||
// 呼叫记录
|
||||
Route::get('call-records', [CallRecordController::class, 'index']);
|
||||
Route::post('call-records', [CallRecordController::class, 'store']);
|
||||
Route::put('call-records/{callRecord}/handle', [CallRecordController::class, 'handle']);
|
||||
});
|
||||
|
||||
// --- 护理管理模块 ---
|
||||
Route::prefix('care')->group(function () {
|
||||
// 护理档案
|
||||
Route::apiResource('profiles', CareProfileController::class);
|
||||
|
||||
// 护理计划
|
||||
Route::apiResource('plans', CarePlanController::class);
|
||||
|
||||
// 护理记录
|
||||
Route::apiResource('records', CareRecordController::class);
|
||||
|
||||
// 护理异常
|
||||
Route::apiResource('exceptions', CareExceptionController::class)->except(['destroy']);
|
||||
Route::put('exceptions/{careException}/handle', [CareExceptionController::class, 'handle']);
|
||||
|
||||
// 健康指标
|
||||
Route::get('health-metrics', [HealthMetricController::class, 'index']);
|
||||
Route::post('health-metrics', [HealthMetricController::class, 'store']);
|
||||
});
|
||||
|
||||
// --- 月子餐模块 ---
|
||||
Route::prefix('meal')->group(function () {
|
||||
// 菜品库
|
||||
Route::apiResource('dishes', DishController::class);
|
||||
|
||||
// 排餐模板
|
||||
Route::apiResource('templates', MealPlanTemplateController::class);
|
||||
|
||||
// 每日排餐
|
||||
Route::apiResource('daily-plans', DailyMealPlanController::class);
|
||||
Route::put('daily-plans/{dailyMealPlan}/deliver', [DailyMealPlanController::class, 'deliver']);
|
||||
Route::put('daily-plans/{dailyMealPlan}/status', [DailyMealPlanController::class, 'updateStatus']);
|
||||
|
||||
// 膳食评价
|
||||
Route::get('reviews', [MealReviewController::class, 'index']);
|
||||
Route::post('reviews', [MealReviewController::class, 'store']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
// ─── Care Profiles ────────────────────────────────────────────────────────────
|
||||
export const careProfileApi = {
|
||||
getList: (params) => request.get('/care/profiles', { params }),
|
||||
getDetail: (id) => request.get(`/care/profiles/${id}`),
|
||||
create: (data) => request.post('/care/profiles', data),
|
||||
update: (id, data) => request.put(`/care/profiles/${id}`, data),
|
||||
delete: (id) => request.delete(`/care/profiles/${id}`)
|
||||
}
|
||||
|
||||
// ─── Care Plans ───────────────────────────────────────────────────────────────
|
||||
export const carePlanApi = {
|
||||
getList: (params) => request.get('/care/plans', { params }),
|
||||
getDetail: (id) => request.get(`/care/plans/${id}`),
|
||||
create: (data) => request.post('/care/plans', data),
|
||||
update: (id, data) => request.put(`/care/plans/${id}`, data),
|
||||
delete: (id) => request.delete(`/care/plans/${id}`)
|
||||
}
|
||||
|
||||
// ─── Care Records ─────────────────────────────────────────────────────────────
|
||||
export const careRecordApi = {
|
||||
getList: (params) => request.get('/care/records', { params }),
|
||||
getDetail: (id) => request.get(`/care/records/${id}`),
|
||||
create: (data) => request.post('/care/records', data),
|
||||
update: (id, data) => request.put(`/care/records/${id}`, data),
|
||||
delete: (id) => request.delete(`/care/records/${id}`)
|
||||
}
|
||||
|
||||
// ─── Care Exceptions ──────────────────────────────────────────────────────────
|
||||
export const careExceptionApi = {
|
||||
getList: (params) => request.get('/care/exceptions', { params }),
|
||||
getDetail: (id) => request.get(`/care/exceptions/${id}`),
|
||||
create: (data) => request.post('/care/exceptions', data),
|
||||
update: (id, data) => request.put(`/care/exceptions/${id}`, data),
|
||||
handle: (id, data) => request.put(`/care/exceptions/${id}/handle`, data)
|
||||
}
|
||||
|
||||
// ─── Health Metrics ───────────────────────────────────────────────────────────
|
||||
export const healthMetricApi = {
|
||||
getList: (params) => request.get('/care/health-metrics', { params }),
|
||||
create: (data) => request.post('/care/health-metrics', data)
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
// ─── Channels ─────────────────────────────────────────────────────────────────
|
||||
export const channelApi = {
|
||||
getList: (params) => request.get('/crm/channels', { params }),
|
||||
getDetail: (id) => request.get(`/crm/channels/${id}`),
|
||||
create: (data) => request.post('/crm/channels', data),
|
||||
update: (id, data) => request.put(`/crm/channels/${id}`, data),
|
||||
delete: (id) => request.delete(`/crm/channels/${id}`)
|
||||
}
|
||||
|
||||
// ─── Leads ────────────────────────────────────────────────────────────────────
|
||||
export const leadApi = {
|
||||
getList: (params) => request.get('/crm/leads', { params }),
|
||||
getDetail: (id) => request.get(`/crm/leads/${id}`),
|
||||
create: (data) => request.post('/crm/leads', data),
|
||||
update: (id, data) => request.put(`/crm/leads/${id}`, data),
|
||||
delete: (id) => request.delete(`/crm/leads/${id}`),
|
||||
follow: (id, data) => request.post(`/crm/leads/${id}/follow`, data),
|
||||
assign: (id, data) => request.put(`/crm/leads/${id}/assign`, data)
|
||||
}
|
||||
|
||||
// ─── Customers ────────────────────────────────────────────────────────────────
|
||||
export const customerApi = {
|
||||
getList: (params) => request.get('/crm/customers', { params }),
|
||||
getDetail: (id) => request.get(`/crm/customers/${id}`),
|
||||
create: (data) => request.post('/crm/customers', data),
|
||||
update: (id, data) => request.put(`/crm/customers/${id}`, data),
|
||||
delete: (id) => request.delete(`/crm/customers/${id}`)
|
||||
}
|
||||
|
||||
// ─── Contracts ────────────────────────────────────────────────────────────────
|
||||
export const contractApi = {
|
||||
getList: (params) => request.get('/crm/contracts', { params }),
|
||||
getDetail: (id) => request.get(`/crm/contracts/${id}`),
|
||||
create: (data) => request.post('/crm/contracts', data),
|
||||
update: (id, data) => request.put(`/crm/contracts/${id}`, data),
|
||||
delete: (id) => request.delete(`/crm/contracts/${id}`),
|
||||
audit: (id, data) => request.put(`/crm/contracts/${id}/audit`, data)
|
||||
}
|
||||
|
||||
// ─── Questionnaires ───────────────────────────────────────────────────────────
|
||||
export const questionnaireApi = {
|
||||
getList: (params) => request.get('/crm/questionnaires', { params }),
|
||||
getDetail: (id) => request.get(`/crm/questionnaires/${id}`),
|
||||
create: (data) => request.post('/crm/questionnaires', data),
|
||||
update: (id, data) => request.put(`/crm/questionnaires/${id}`, data),
|
||||
delete: (id) => request.delete(`/crm/questionnaires/${id}`),
|
||||
submitAnswer: (data) => request.post('/crm/questionnaire-answers', data),
|
||||
getAnswers: (params) => request.get('/crm/questionnaire-answers', { params })
|
||||
}
|
||||
|
||||
// ─── Complaints ───────────────────────────────────────────────────────────────
|
||||
export const complaintApi = {
|
||||
getList: (params) => request.get('/crm/complaints', { params }),
|
||||
getDetail: (id) => request.get(`/crm/complaints/${id}`),
|
||||
create: (data) => request.post('/crm/complaints', data),
|
||||
update: (id, data) => request.put(`/crm/complaints/${id}`, data),
|
||||
delete: (id) => request.delete(`/crm/complaints/${id}`),
|
||||
handle: (id, data) => request.put(`/crm/complaints/${id}/handle`, data)
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
// ─── Dishes ───────────────────────────────────────────────────────────────────
|
||||
export const dishApi = {
|
||||
getList: (params) => request.get('/meal/dishes', { params }),
|
||||
getDetail: (id) => request.get(`/meal/dishes/${id}`),
|
||||
create: (data) => request.post('/meal/dishes', data),
|
||||
update: (id, data) => request.put(`/meal/dishes/${id}`, data),
|
||||
delete: (id) => request.delete(`/meal/dishes/${id}`)
|
||||
}
|
||||
|
||||
// ─── Meal Plan Templates ──────────────────────────────────────────────────────
|
||||
export const mealTemplateApi = {
|
||||
getList: (params) => request.get('/meal/templates', { params }),
|
||||
getDetail: (id) => request.get(`/meal/templates/${id}`),
|
||||
create: (data) => request.post('/meal/templates', data),
|
||||
update: (id, data) => request.put(`/meal/templates/${id}`, data),
|
||||
delete: (id) => request.delete(`/meal/templates/${id}`)
|
||||
}
|
||||
|
||||
// ─── Daily Meal Plans ─────────────────────────────────────────────────────────
|
||||
export const dailyMealPlanApi = {
|
||||
getList: (params) => request.get('/meal/daily-plans', { params }),
|
||||
getDetail: (id) => request.get(`/meal/daily-plans/${id}`),
|
||||
create: (data) => request.post('/meal/daily-plans', data),
|
||||
update: (id, data) => request.put(`/meal/daily-plans/${id}`, data),
|
||||
delete: (id) => request.delete(`/meal/daily-plans/${id}`),
|
||||
deliver: (id) => request.put(`/meal/daily-plans/${id}/deliver`),
|
||||
updateStatus: (id, data) => request.put(`/meal/daily-plans/${id}/status`, data)
|
||||
}
|
||||
|
||||
// ─── Meal Reviews ─────────────────────────────────────────────────────────────
|
||||
export const mealReviewApi = {
|
||||
getList: (params) => request.get('/meal/reviews', { params }),
|
||||
create: (data) => request.post('/meal/reviews', data)
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
// ─── Room Types ───────────────────────────────────────────────────────────────
|
||||
export const roomTypeApi = {
|
||||
getList: (params) => request.get('/room/room-types', { params }),
|
||||
getDetail: (id) => request.get(`/room/room-types/${id}`),
|
||||
create: (data) => request.post('/room/room-types', data),
|
||||
update: (id, data) => request.put(`/room/room-types/${id}`, data),
|
||||
delete: (id) => request.delete(`/room/room-types/${id}`)
|
||||
}
|
||||
|
||||
// ─── Rooms ────────────────────────────────────────────────────────────────────
|
||||
export const roomApi = {
|
||||
getList: (params) => request.get('/room/rooms', { params }),
|
||||
getDetail: (id) => request.get(`/room/rooms/${id}`),
|
||||
create: (data) => request.post('/room/rooms', data),
|
||||
update: (id, data) => request.put(`/room/rooms/${id}`, data),
|
||||
delete: (id) => request.delete(`/room/rooms/${id}`),
|
||||
updateStatus: (id, data) => request.put(`/room/rooms/${id}/status`, data)
|
||||
}
|
||||
|
||||
// ─── Reservations ─────────────────────────────────────────────────────────────
|
||||
export const reservationApi = {
|
||||
getList: (params) => request.get('/room/reservations', { params }),
|
||||
getDetail: (id) => request.get(`/room/reservations/${id}`),
|
||||
create: (data) => request.post('/room/reservations', data),
|
||||
update: (id, data) => request.put(`/room/reservations/${id}`, data),
|
||||
delete: (id) => request.delete(`/room/reservations/${id}`),
|
||||
checkIn: (id) => request.put(`/room/reservations/${id}/check-in`),
|
||||
checkOut: (id) => request.put(`/room/reservations/${id}/check-out`),
|
||||
cancel: (id, data) => request.put(`/room/reservations/${id}/cancel`, data)
|
||||
}
|
||||
|
||||
// ─── Customer Outings ─────────────────────────────────────────────────────────
|
||||
export const customerOutingApi = {
|
||||
getList: (params) => request.get('/room/customer-outings', { params }),
|
||||
getDetail: (id) => request.get(`/room/customer-outings/${id}`),
|
||||
create: (data) => request.post('/room/customer-outings', data),
|
||||
recordBack: (id, data) => request.put(`/room/customer-outings/${id}/back`, data)
|
||||
}
|
||||
|
||||
// ─── Call Records ─────────────────────────────────────────────────────────────
|
||||
export const callRecordApi = {
|
||||
getList: (params) => request.get('/room/call-records', { params }),
|
||||
create: (data) => request.post('/room/call-records', data),
|
||||
handle: (id, data) => request.put(`/room/call-records/${id}/handle`, data)
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { carePlanApi, careProfileApi } from '@/api/care.js'
|
||||
import { userApi } from '@/api/system.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const profiles = ref([])
|
||||
const nurses = ref([])
|
||||
|
||||
const searchForm = reactive({ care_profile_id: '', plan_date: '', status: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({ id: null, care_profile_id: '', plan_date: '', stage: '', items: [], nurse_id: '', status: 0 })
|
||||
const isEdit = ref(false)
|
||||
|
||||
const statusMap = { 0: '待执行', 1: '执行中', 2: '已完成' }
|
||||
const statusType = { 0: 'info', 1: 'warning', 2: 'success' }
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try { const res = await carePlanApi.getList({ ...searchForm, ...pagination }); tableData.value = res.data?.list || res.data?.data || []; total.value = res.data?.total || 0 } finally { loading.value = false }
|
||||
}
|
||||
|
||||
async function fetchProfiles() { try { const res = await careProfileApi.getList({ per_page: 500 }); profiles.value = res.data?.list || res.data?.data || [] } catch {} }
|
||||
async function fetchNurses() { try { const res = await userApi.getList({ per_page: 200 }); nurses.value = res.data?.list || res.data?.data || [] } catch {} }
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() { Object.assign(searchForm, { care_profile_id: '', plan_date: '', status: '' }); handleSearch() }
|
||||
function handleAdd() { isEdit.value = false; Object.assign(form, { id: null, care_profile_id: '', plan_date: '', stage: '', items: [], nurse_id: '', status: 0 }); dialogVisible.value = true }
|
||||
async function handleEdit(row) { isEdit.value = true; Object.assign(form, { id: row.id, care_profile_id: row.care_profile_id, plan_date: row.plan_date, stage: row.stage || '', items: row.items || [], nurse_id: row.nurse_id || '', status: row.status }); dialogVisible.value = true }
|
||||
|
||||
async function handleSubmit() {
|
||||
submitLoading.value = true
|
||||
try {
|
||||
if (isEdit.value) { await carePlanApi.update(form.id, form) } else { await carePlanApi.create(form) }
|
||||
ElMessage.success(isEdit.value ? '更新成功' : '创建成功'); dialogVisible.value = false; fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
}
|
||||
|
||||
function handlePageChange(val) { pagination.page = val; fetchList() }
|
||||
function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() }
|
||||
onMounted(() => { fetchList(); fetchProfiles(); fetchNurses() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="search-bar">
|
||||
<el-select v-model="searchForm.care_profile_id" placeholder="护理档案" clearable filterable style="width:200px"><el-option v-for="p in profiles" :key="p.id" :label="`${p.customer?.name||''} - ${p.type===1?'妈妈':'宝宝'}`" :value="p.id" /></el-select>
|
||||
<el-date-picker v-model="searchForm.plan_date" type="date" value-format="YYYY-MM-DD" placeholder="计划日期" style="width:160px" />
|
||||
<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-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 label="客户" min-width="100"><template #default="{ row }">{{ row.profile?.customer?.name || '-' }}</template></el-table-column>
|
||||
<el-table-column prop="plan_date" label="计划日期" min-width="110" />
|
||||
<el-table-column prop="stage" label="阶段" min-width="100" />
|
||||
<el-table-column label="护士" min-width="100"><template #default="{ row }">{{ row.nurse?.name || '-' }}</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 label="操作" width="120" fixed="right" align="center">
|
||||
<template #default="{ row }"><el-button size="small" type="primary" link @click="handleEdit(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="550px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" label-width="80px">
|
||||
<el-form-item label="护理档案"><el-select v-model="form.care_profile_id" filterable style="width:100%"><el-option v-for="p in profiles" :key="p.id" :label="`${p.customer?.name||''} - ${p.type===1?'妈妈':'宝宝'}`" :value="p.id" /></el-select></el-form-item>
|
||||
<el-form-item label="计划日期"><el-date-picker v-model="form.plan_date" type="date" value-format="YYYY-MM-DD" style="width:100%" /></el-form-item>
|
||||
<el-form-item label="阶段"><el-input v-model="form.stage" placeholder="如:产后第1周" /></el-form-item>
|
||||
<el-form-item label="护士"><el-select v-model="form.nurse_id" filterable clearable style="width:100%"><el-option v-for="n in nurses" :key="n.id" :label="n.name" :value="n.id" /></el-select></el-form-item>
|
||||
<el-form-item v-if="isEdit" label="状态"><el-select v-model="form.status" style="width:100%"><el-option v-for="(v,k) in statusMap" :key="k" :label="v" :value="Number(k)" /></el-select></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,136 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { careProfileApi } from '@/api/care.js'
|
||||
import { customerApi } from '@/api/crm.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const detailVisible = ref(false)
|
||||
const detailData = ref(null)
|
||||
const customers = ref([])
|
||||
|
||||
const searchForm = reactive({ customer_id: '', type: '', risk_level: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({ id: null, customer_id: '', type: 1, baby_name: '', baby_gender: '', baby_birthday: '', birth_weight: '', birth_method: '', allergies: '', medical_history: '', risk_level: 0, assessment: [] })
|
||||
const isEdit = ref(false)
|
||||
const formRules = {
|
||||
customer_id: [{ required: true, message: '请选择客户', trigger: 'change' }],
|
||||
type: [{ required: true, message: '请选择类型', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const typeMap = { 1: '妈妈', 2: '宝宝' }
|
||||
const genderMap = { 1: '男', 2: '女' }
|
||||
const birthMethodMap = { 1: '顺产', 2: '剖宫产' }
|
||||
const riskMap = { 0: '正常', 1: '低风险', 2: '高风险' }
|
||||
const riskType = { 0: 'success', 1: 'warning', 2: 'danger' }
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try { const res = await careProfileApi.getList({ ...searchForm, ...pagination }); tableData.value = res.data?.list || res.data?.data || []; total.value = res.data?.total || 0 } finally { loading.value = false }
|
||||
}
|
||||
|
||||
async function fetchCustomers() { try { const res = await customerApi.getList({ per_page: 500 }); customers.value = res.data?.list || res.data?.data || [] } catch {} }
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() { Object.assign(searchForm, { customer_id: '', type: '', risk_level: '' }); handleSearch() }
|
||||
function handleAdd() { isEdit.value = false; Object.assign(form, { id: null, customer_id: '', type: 1, baby_name: '', baby_gender: '', baby_birthday: '', birth_weight: '', birth_method: '', allergies: '', medical_history: '', risk_level: 0, assessment: [] }); dialogVisible.value = true }
|
||||
async function handleEdit(row) { isEdit.value = true; const res = await careProfileApi.getDetail(row.id); const d = res.data; Object.assign(form, { id: d.id, customer_id: d.customer_id, type: d.type, baby_name: d.baby_name || '', baby_gender: d.baby_gender || '', baby_birthday: d.baby_birthday || '', birth_weight: d.birth_weight || '', birth_method: d.birth_method || '', allergies: d.allergies || '', medical_history: d.medical_history || '', risk_level: d.risk_level || 0, assessment: d.assessment || [] }); 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 careProfileApi.update(form.id, form) } else { await careProfileApi.create(form) }
|
||||
ElMessage.success(isEdit.value ? '更新成功' : '创建成功'); dialogVisible.value = false; fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
async function handleDetail(row) { const res = await careProfileApi.getDetail(row.id); detailData.value = res.data; detailVisible.value = true }
|
||||
|
||||
async function handleDelete(row) {
|
||||
await ElMessageBox.confirm('确定删除该护理档案吗?', '删除确认', { type: 'warning' })
|
||||
await careProfileApi.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(); fetchCustomers() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="search-bar">
|
||||
<el-select v-model="searchForm.customer_id" placeholder="选择客户" clearable filterable style="width:180px"><el-option v-for="c in customers" :key="c.id" :label="c.name" :value="c.id" /></el-select>
|
||||
<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.risk_level" placeholder="风险等级" clearable style="width:120px"><el-option v-for="(v,k) in riskMap" :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 label="客户" min-width="100"><template #default="{ row }">{{ row.customer?.name || '-' }}</template></el-table-column>
|
||||
<el-table-column label="类型" width="80" align="center"><template #default="{ row }"><el-tag :type="row.type===1?'':'success'" size="small">{{ typeMap[row.type] }}</el-tag></template></el-table-column>
|
||||
<el-table-column prop="baby_name" label="宝宝名" min-width="100" />
|
||||
<el-table-column label="性别" width="70" align="center"><template #default="{ row }">{{ genderMap[row.baby_gender] || '-' }}</template></el-table-column>
|
||||
<el-table-column label="分娩方式" width="90"><template #default="{ row }">{{ birthMethodMap[row.birth_method] || '-' }}</template></el-table-column>
|
||||
<el-table-column label="风险等级" width="90" align="center"><template #default="{ row }"><el-tag :type="riskType[row.risk_level]" size="small">{{ riskMap[row.risk_level] }}</el-tag></template></el-table-column>
|
||||
<el-table-column label="操作" width="200" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button size="small" type="primary" link @click="handleDetail(row)">详情</el-button>
|
||||
<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="isEdit?'编辑档案':'新增档案'" width="650px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="80px">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12"><el-form-item label="客户" prop="customer_id"><el-select v-model="form.customer_id" filterable style="width:100%"><el-option v-for="c in customers" :key="c.id" :label="c.name" :value="c.id" /></el-select></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="类型" prop="type"><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-col>
|
||||
<template v-if="form.type===2">
|
||||
<el-col :span="12"><el-form-item label="宝宝名"><el-input v-model="form.baby_name" /></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="性别"><el-select v-model="form.baby_gender" style="width:100%"><el-option label="男" :value="1" /><el-option label="女" :value="2" /></el-select></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="出生日期"><el-date-picker v-model="form.baby_birthday" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" style="width:100%" /></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="出生体重"><el-input-number v-model="form.birth_weight" :min="0" :precision="2" style="width:100%" /><span style="margin-left:4px">kg</span></el-form-item></el-col>
|
||||
</template>
|
||||
<el-col :span="12"><el-form-item label="分娩方式"><el-select v-model="form.birth_method" clearable style="width:100%"><el-option label="顺产" :value="1" /><el-option label="剖宫产" :value="2" /></el-select></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="风险等级"><el-select v-model="form.risk_level" style="width:100%"><el-option v-for="(v,k) in riskMap" :key="k" :label="v" :value="Number(k)" /></el-select></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="过敏史"><el-input v-model="form.allergies" type="textarea" :rows="2" /></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="病史"><el-input v-model="form.medical_history" type="textarea" :rows="2" /></el-form-item></el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer><el-button @click="dialogVisible=false">取消</el-button><el-button type="primary" :loading="submitLoading" @click="handleSubmit">确定</el-button></template>
|
||||
</el-dialog>
|
||||
<el-drawer v-model="detailVisible" title="护理档案详情" size="600px">
|
||||
<template v-if="detailData">
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="客户">{{ detailData.customer?.name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="类型">{{ typeMap[detailData.type] }}</el-descriptions-item>
|
||||
<el-descriptions-item label="宝宝名">{{ detailData.baby_name || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="风险等级"><el-tag :type="riskType[detailData.risk_level]" size="small">{{ riskMap[detailData.risk_level] }}</el-tag></el-descriptions-item>
|
||||
<el-descriptions-item label="过敏史">{{ detailData.allergies || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="病史">{{ detailData.medical_history || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<h4 style="margin:16px 0 8px">护理计划</h4>
|
||||
<el-table :data="detailData.plans || []" border size="small">
|
||||
<el-table-column prop="plan_date" label="日期" width="110" />
|
||||
<el-table-column prop="stage" label="阶段" />
|
||||
<el-table-column label="护士"><template #default="{ row }">{{ row.nurse?.name || '-' }}</template></el-table-column>
|
||||
<el-table-column label="状态" width="80"><template #default="{ row }"><el-tag size="small">{{ ['待执行','执行中','已完成'][row.status] }}</el-tag></template></el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,76 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { careRecordApi, careProfileApi } from '@/api/care.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const profiles = ref([])
|
||||
|
||||
const searchForm = reactive({ care_profile_id: '', type: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const form = reactive({ id: null, care_profile_id: '', care_plan_id: '', type: 1, items: [], remark: '', images: [], recorded_at: '' })
|
||||
const isEdit = ref(false)
|
||||
const typeMap = { 1: '妈妈护理', 2: '宝宝护理' }
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try { const res = await careRecordApi.getList({ ...searchForm, ...pagination }); tableData.value = res.data?.list || res.data?.data || []; total.value = res.data?.total || 0 } finally { loading.value = false }
|
||||
}
|
||||
|
||||
async function fetchProfiles() { try { const res = await careProfileApi.getList({ per_page: 500 }); profiles.value = res.data?.list || res.data?.data || [] } catch {} }
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() { Object.assign(searchForm, { care_profile_id: '', type: '' }); handleSearch() }
|
||||
function handleAdd() { isEdit.value = false; Object.assign(form, { id: null, care_profile_id: '', care_plan_id: '', type: 1, items: [], remark: '', images: [], recorded_at: '' }); dialogVisible.value = true }
|
||||
async function handleEdit(row) { isEdit.value = true; Object.assign(form, { id: row.id, care_profile_id: row.care_profile_id, care_plan_id: row.care_plan_id || '', type: row.type, items: row.items || [], remark: row.remark || '', images: row.images || [], recorded_at: row.recorded_at || '' }); dialogVisible.value = true }
|
||||
|
||||
async function handleSubmit() {
|
||||
submitLoading.value = true
|
||||
try {
|
||||
if (isEdit.value) { await careRecordApi.update(form.id, form) } else { await careRecordApi.create(form) }
|
||||
ElMessage.success(isEdit.value ? '更新成功' : '创建成功'); dialogVisible.value = false; fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
}
|
||||
|
||||
function handlePageChange(val) { pagination.page = val; fetchList() }
|
||||
function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() }
|
||||
onMounted(() => { fetchList(); fetchProfiles() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="search-bar">
|
||||
<el-select v-model="searchForm.care_profile_id" placeholder="护理档案" clearable filterable style="width:200px"><el-option v-for="p in profiles" :key="p.id" :label="`${p.customer?.name||''} - ${p.type===1?'妈妈':'宝宝'}`" :value="p.id" /></el-select>
|
||||
<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-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 label="客户" min-width="100"><template #default="{ row }">{{ row.profile?.customer?.name || '-' }}</template></el-table-column>
|
||||
<el-table-column label="类型" width="100" align="center"><template #default="{ row }">{{ typeMap[row.type] || '-' }}</template></el-table-column>
|
||||
<el-table-column label="护士" min-width="100"><template #default="{ row }">{{ row.nurse?.name || '-' }}</template></el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column prop="recorded_at" label="记录时间" min-width="160" />
|
||||
<el-table-column label="操作" width="120" fixed="right" align="center">
|
||||
<template #default="{ row }"><el-button size="small" type="primary" link @click="handleEdit(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="550px" destroy-on-close>
|
||||
<el-form :model="form" label-width="80px">
|
||||
<el-form-item label="护理档案"><el-select v-model="form.care_profile_id" filterable style="width:100%"><el-option v-for="p in profiles" :key="p.id" :label="`${p.customer?.name||''} - ${p.type===1?'妈妈':'宝宝'}`" :value="p.id" /></el-select></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-input v-model="form.remark" type="textarea" :rows="3" /></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,94 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { channelApi } from '@/api/crm.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
|
||||
const searchForm = reactive({ name: '', type: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({ id: null, name: '', type: 1, status: 1 })
|
||||
const isEdit = ref(false)
|
||||
const formRules = { name: [{ required: true, message: '请输入渠道名称', trigger: 'blur' }] }
|
||||
const typeMap = { 1: '线上', 2: '线下', 3: '转介绍' }
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await channelApi.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, { name: '', type: '' }); handleSearch() }
|
||||
|
||||
function handleAdd() { isEdit.value = false; Object.assign(form, { id: null, name: '', type: 1, status: 1 }); dialogVisible.value = true }
|
||||
async function handleEdit(row) { isEdit.value = true; Object.assign(form, { ...row }); 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 channelApi.update(form.id, form); ElMessage.success('更新成功') }
|
||||
else { await channelApi.create(form); ElMessage.success('创建成功') }
|
||||
dialogVisible.value = false; fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
await ElMessageBox.confirm(`确定删除渠道「${row.name}」吗?`, '删除确认', { type: 'warning' })
|
||||
await channelApi.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-input v-model="searchForm.name" placeholder="渠道名称" style="width:180px" clearable @keydown.enter="handleSearch" />
|
||||
<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-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="150" />
|
||||
<el-table-column label="类型" width="100" align="center"><template #default="{ row }">{{ typeMap[row.type] }}</template></el-table-column>
|
||||
<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 prop="created_at" label="创建时间" min-width="160" />
|
||||
<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="isEdit?'编辑渠道':'新增渠道'" width="450px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="80px">
|
||||
<el-form-item label="渠道名称" prop="name"><el-input v-model="form.name" /></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.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,116 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { complaintApi, customerApi } from '@/api/crm.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const handleVisible = ref(false)
|
||||
const currentComplaint = ref(null)
|
||||
const customers = ref([])
|
||||
|
||||
const searchForm = reactive({ customer_id: '', type: '', status: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({ id: null, customer_id: '', type: 1, content: '', images: [] })
|
||||
const isEdit = ref(false)
|
||||
const handleForm = reactive({ handle_result: '', status: 2 })
|
||||
|
||||
const typeMap = { 1: '服务', 2: '膳食', 3: '环境', 4: '其他' }
|
||||
const statusMap = { 0: '待处理', 1: '处理中', 2: '已解决', 3: '已关闭' }
|
||||
const statusType = { 0: 'danger', 1: 'warning', 2: 'success', 3: 'info' }
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await complaintApi.getList({ ...searchForm, ...pagination })
|
||||
tableData.value = res.data?.list || res.data?.data || []
|
||||
total.value = res.data?.total || 0
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
async function fetchCustomers() {
|
||||
try { const res = await customerApi.getList({ per_page: 500 }); customers.value = res.data?.list || res.data?.data || [] } catch {}
|
||||
}
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() { Object.assign(searchForm, { customer_id: '', type: '', status: '' }); handleSearch() }
|
||||
function handleAdd() { isEdit.value = false; Object.assign(form, { id: null, customer_id: '', type: 1, content: '', images: [] }); 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 complaintApi.update(form.id, form) } else { await complaintApi.create(form) }
|
||||
ElMessage.success('提交成功'); dialogVisible.value = false; fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
function openHandle(row) { currentComplaint.value = row; Object.assign(handleForm, { handle_result: '', status: 2 }); handleVisible.value = true }
|
||||
async function submitHandle() {
|
||||
if (!handleForm.handle_result) { ElMessage.warning('请输入处理结果'); return }
|
||||
await complaintApi.handle(currentComplaint.value.id, handleForm)
|
||||
ElMessage.success('处理完成'); handleVisible.value = false; fetchList()
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
await ElMessageBox.confirm('确定删除该投诉吗?', '删除确认', { type: 'warning' })
|
||||
await complaintApi.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(); fetchCustomers() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="search-bar">
|
||||
<el-select v-model="searchForm.customer_id" placeholder="选择客户" clearable filterable style="width:180px"><el-option v-for="c in customers" :key="c.id" :label="c.name" :value="c.id" /></el-select>
|
||||
<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.status" placeholder="状态" clearable style="width:120px"><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 label="客户" min-width="100"><template #default="{ row }">{{ row.customer?.name || '-' }}</template></el-table-column>
|
||||
<el-table-column label="类型" width="80" align="center"><template #default="{ row }">{{ typeMap[row.type] }}</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="处理人" min-width="100"><template #default="{ row }">{{ row.handler?.name || '-' }}</template></el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" min-width="160" />
|
||||
<el-table-column label="操作" width="160" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.status<2" size="small" type="success" link @click="openHandle(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="isEdit?'编辑投诉':'新增投诉'" width="550px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="{ customer_id:[{required:true,message:'请选择客户'}], content:[{required:true,message:'请输入内容'}] }" label-width="80px">
|
||||
<el-form-item label="客户" prop="customer_id"><el-select v-model="form.customer_id" filterable style="width:100%"><el-option v-for="c in customers" :key="c.id" :label="c.name" :value="c.id" /></el-select></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="内容" prop="content"><el-input v-model="form.content" type="textarea" :rows="4" /></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>
|
||||
<el-dialog v-model="handleVisible" title="处理投诉" width="500px" destroy-on-close>
|
||||
<el-form label-width="80px">
|
||||
<el-form-item label="处理结果"><el-input v-model="handleForm.handle_result" type="textarea" :rows="4" /></el-form-item>
|
||||
<el-form-item label="状态"><el-radio-group v-model="handleForm.status"><el-radio :value="2">已解决</el-radio><el-radio :value="3">已关闭</el-radio></el-radio-group></el-form-item>
|
||||
</el-form>
|
||||
<template #footer><el-button @click="handleVisible=false">取消</el-button><el-button type="primary" @click="submitHandle">确定</el-button></template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,184 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { contractApi, customerApi } from '@/api/crm.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('新增合同')
|
||||
const submitLoading = ref(false)
|
||||
const auditVisible = ref(false)
|
||||
const currentContract = ref(null)
|
||||
const customers = ref([])
|
||||
|
||||
const searchForm = reactive({ contract_no: '', customer_id: '', status: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({
|
||||
id: null, customer_id: '', contract_no: '', package_name: '',
|
||||
total_amount: 0, discount_amount: 0, actual_amount: 0,
|
||||
days: '', check_in_date: '', check_out_date: '', remark: ''
|
||||
})
|
||||
const isEdit = ref(false)
|
||||
const formRules = {
|
||||
customer_id: [{ required: true, message: '请选择客户', trigger: 'change' }],
|
||||
contract_no: [{ required: true, message: '请输入合同编号', trigger: 'blur' }],
|
||||
total_amount: [{ required: true, message: '请输入总金额', trigger: 'blur' }],
|
||||
actual_amount: [{ required: true, message: '请输入实付金额', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const auditForm = reactive({ status: 1, audit_remark: '' })
|
||||
const statusMap = { 0: '待审核', 1: '已通过', 2: '无效', 3: '已退' }
|
||||
const statusType = { 0: 'warning', 1: 'success', 2: 'danger', 3: 'info' }
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await contractApi.getList({ ...searchForm, ...pagination })
|
||||
tableData.value = res.data?.list || res.data?.data || []
|
||||
total.value = res.data?.total || 0
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
async function fetchCustomers() {
|
||||
try {
|
||||
const res = await customerApi.getList({ per_page: 500 })
|
||||
customers.value = res.data?.list || res.data?.data || []
|
||||
} catch {}
|
||||
}
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() { Object.assign(searchForm, { contract_no: '', customer_id: '', status: '' }); handleSearch() }
|
||||
|
||||
function handleAdd() {
|
||||
isEdit.value = false; dialogTitle.value = '新增合同'
|
||||
Object.assign(form, { id: null, customer_id: '', contract_no: '', package_name: '', total_amount: 0, discount_amount: 0, actual_amount: 0, days: '', check_in_date: '', check_out_date: '', remark: '' })
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleEdit(row) {
|
||||
if (row.status !== 0) { ElMessage.warning('只能编辑待审核合同'); return }
|
||||
isEdit.value = true; dialogTitle.value = '编辑合同'
|
||||
const res = await contractApi.getDetail(row.id)
|
||||
const d = res.data
|
||||
Object.assign(form, { id: d.id, customer_id: d.customer_id, contract_no: d.contract_no, package_name: d.package_name || '', total_amount: d.total_amount, discount_amount: d.discount_amount, actual_amount: d.actual_amount, days: d.days || '', check_in_date: d.check_in_date || '', check_out_date: d.check_out_date || '', remark: d.remark || '' })
|
||||
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 contractApi.update(form.id, form); ElMessage.success('更新成功') }
|
||||
else { await contractApi.create(form); ElMessage.success('创建成功') }
|
||||
dialogVisible.value = false; fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
if (row.status !== 0) { ElMessage.warning('只能删除待审核合同'); return }
|
||||
await ElMessageBox.confirm('确定删除该合同吗?', '删除确认', { type: 'warning' })
|
||||
await contractApi.delete(row.id); ElMessage.success('删除成功'); fetchList()
|
||||
}
|
||||
|
||||
function openAudit(row) {
|
||||
currentContract.value = row
|
||||
Object.assign(auditForm, { status: 1, audit_remark: '' })
|
||||
auditVisible.value = true
|
||||
}
|
||||
|
||||
async function submitAudit() {
|
||||
await contractApi.audit(currentContract.value.id, auditForm)
|
||||
ElMessage.success('审核完成')
|
||||
auditVisible.value = false; fetchList()
|
||||
}
|
||||
|
||||
function handlePageChange(val) { pagination.page = val; fetchList() }
|
||||
function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() }
|
||||
|
||||
onMounted(() => { fetchList(); fetchCustomers() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="search-bar">
|
||||
<el-input v-model="searchForm.contract_no" placeholder="合同编号" style="width:180px" clearable @keydown.enter="handleSearch" />
|
||||
<el-select v-model="searchForm.customer_id" placeholder="选择客户" clearable filterable style="width:180px">
|
||||
<el-option v-for="c in customers" :key="c.id" :label="`${c.name} (${c.phone})`" :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-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="contract_no" label="合同编号" min-width="150" />
|
||||
<el-table-column label="客户" min-width="100"><template #default="{ row }">{{ row.customer?.name || '-' }}</template></el-table-column>
|
||||
<el-table-column prop="package_name" label="套餐" min-width="120" />
|
||||
<el-table-column prop="actual_amount" label="实付金额" min-width="110" align="right" />
|
||||
<el-table-column prop="days" label="天数" width="70" align="center" />
|
||||
<el-table-column prop="check_in_date" label="入住日期" min-width="110" />
|
||||
<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="操作" width="200" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.status===0" size="small" type="success" link @click="openAudit(row)">审核</el-button>
|
||||
<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>
|
||||
|
||||
<!-- Add/Edit -->
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="700px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="90px">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12"><el-form-item label="客户" prop="customer_id"><el-select v-model="form.customer_id" placeholder="选择客户" filterable style="width:100%"><el-option v-for="c in customers" :key="c.id" :label="`${c.name} (${c.phone})`" :value="c.id" /></el-select></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="合同编号" prop="contract_no"><el-input v-model="form.contract_no" /></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="套餐名称"><el-input v-model="form.package_name" /></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="天数"><el-input-number v-model="form.days" :min="1" style="width:100%" /></el-form-item></el-col>
|
||||
<el-col :span="8"><el-form-item label="总金额" prop="total_amount"><el-input-number v-model="form.total_amount" :min="0" :precision="2" style="width:100%" /></el-form-item></el-col>
|
||||
<el-col :span="8"><el-form-item label="优惠金额"><el-input-number v-model="form.discount_amount" :min="0" :precision="2" style="width:100%" /></el-form-item></el-col>
|
||||
<el-col :span="8"><el-form-item label="实付金额" prop="actual_amount"><el-input-number v-model="form.actual_amount" :min="0" :precision="2" style="width:100%" /></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="入住日期"><el-date-picker v-model="form.check_in_date" type="date" value-format="YYYY-MM-DD" style="width:100%" /></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="退房日期"><el-date-picker v-model="form.check_out_date" type="date" value-format="YYYY-MM-DD" style="width:100%" /></el-form-item></el-col>
|
||||
<el-col :span="24"><el-form-item label="备注"><el-input v-model="form.remark" type="textarea" :rows="2" /></el-form-item></el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- Audit -->
|
||||
<el-dialog v-model="auditVisible" title="合同审核" width="450px" destroy-on-close>
|
||||
<el-form label-width="80px">
|
||||
<el-form-item label="审核结果">
|
||||
<el-radio-group v-model="auditForm.status">
|
||||
<el-radio :value="1">通过</el-radio>
|
||||
<el-radio :value="2">驳回</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="审核备注"><el-input v-model="auditForm.audit_remark" type="textarea" :rows="3" /></el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="auditVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submitAudit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,190 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { customerApi } from '@/api/crm.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('新增客户')
|
||||
const submitLoading = ref(false)
|
||||
const detailVisible = ref(false)
|
||||
const detailData = ref(null)
|
||||
|
||||
const searchForm = reactive({ name: '', phone: '', status: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({
|
||||
id: null, name: '', phone: '', id_card: '', wechat: '',
|
||||
birthday: '', expected_date: '', actual_date: '', baby_count: 1,
|
||||
tags: [], remark: '',
|
||||
families: []
|
||||
})
|
||||
const isEdit = ref(false)
|
||||
const formRules = {
|
||||
name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
|
||||
phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const statusMap = { 1: '潜在', 2: '签约', 3: '在住', 4: '离店', 5: '无效' }
|
||||
const statusType = { 1: 'info', 2: 'primary', 3: 'success', 4: '', 5: 'danger' }
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await customerApi.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, { name: '', phone: '', status: '' }); handleSearch() }
|
||||
|
||||
function handleAdd() {
|
||||
isEdit.value = false; dialogTitle.value = '新增客户'
|
||||
Object.assign(form, { id: null, name: '', phone: '', id_card: '', wechat: '', birthday: '', expected_date: '', actual_date: '', baby_count: 1, tags: [], remark: '', families: [] })
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleEdit(row) {
|
||||
isEdit.value = true; dialogTitle.value = '编辑客户'
|
||||
const res = await customerApi.getDetail(row.id)
|
||||
const d = res.data
|
||||
Object.assign(form, { id: d.id, name: d.name, phone: d.phone, id_card: d.id_card || '', wechat: d.wechat || '', birthday: d.birthday || '', expected_date: d.expected_date || '', actual_date: d.actual_date || '', baby_count: d.baby_count || 1, tags: d.tags || [], remark: d.remark || '', families: d.families || [] })
|
||||
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 customerApi.update(form.id, form); ElMessage.success('更新成功') }
|
||||
else { await customerApi.create(form); ElMessage.success('创建成功') }
|
||||
dialogVisible.value = false; fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
await ElMessageBox.confirm(`确定删除客户「${row.name}」吗?`, '删除确认', { type: 'warning' })
|
||||
await customerApi.delete(row.id); ElMessage.success('删除成功'); fetchList()
|
||||
}
|
||||
|
||||
async function handleDetail(row) {
|
||||
const res = await customerApi.getDetail(row.id)
|
||||
detailData.value = res.data
|
||||
detailVisible.value = true
|
||||
}
|
||||
|
||||
function addFamily() { form.families.push({ name: '', phone: '', relation: '', is_emergency: false }) }
|
||||
function removeFamily(idx) { form.families.splice(idx, 1) }
|
||||
|
||||
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-input v-model="searchForm.name" placeholder="客户姓名" style="width:160px" clearable @keydown.enter="handleSearch" />
|
||||
<el-input v-model="searchForm.phone" placeholder="手机号" style="width:160px" clearable @keydown.enter="handleSearch" />
|
||||
<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-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="100" />
|
||||
<el-table-column prop="phone" label="手机号" min-width="130" />
|
||||
<el-table-column prop="expected_date" label="预产期" min-width="110" />
|
||||
<el-table-column prop="baby_count" label="宝宝数" width="80" align="center" />
|
||||
<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="负责人" min-width="100">
|
||||
<template #default="{ row }">{{ row.owner?.name || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" min-width="160" />
|
||||
<el-table-column label="操作" width="220" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button size="small" type="primary" link @click="handleDetail(row)">详情</el-button>
|
||||
<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>
|
||||
|
||||
<!-- Add/Edit -->
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="700px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="80px">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12"><el-form-item label="姓名" prop="name"><el-input v-model="form.name" /></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="手机号" prop="phone"><el-input v-model="form.phone" /></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="身份证"><el-input v-model="form.id_card" /></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="微信号"><el-input v-model="form.wechat" /></el-form-item></el-col>
|
||||
<el-col :span="8"><el-form-item label="生日"><el-date-picker v-model="form.birthday" type="date" value-format="YYYY-MM-DD" style="width:100%" /></el-form-item></el-col>
|
||||
<el-col :span="8"><el-form-item label="预产期"><el-date-picker v-model="form.expected_date" type="date" value-format="YYYY-MM-DD" style="width:100%" /></el-form-item></el-col>
|
||||
<el-col :span="8"><el-form-item label="宝宝数"><el-input-number v-model="form.baby_count" :min="1" :max="5" /></el-form-item></el-col>
|
||||
<el-col :span="24"><el-form-item label="备注"><el-input v-model="form.remark" type="textarea" :rows="2" /></el-form-item></el-col>
|
||||
</el-row>
|
||||
<el-divider content-position="left">家属信息</el-divider>
|
||||
<div v-for="(f, idx) in form.families" :key="idx" style="margin-bottom:10px">
|
||||
<el-row :gutter="8">
|
||||
<el-col :span="5"><el-input v-model="f.name" placeholder="姓名" /></el-col>
|
||||
<el-col :span="5"><el-input v-model="f.phone" placeholder="手机号" /></el-col>
|
||||
<el-col :span="5"><el-input v-model="f.relation" placeholder="关系" /></el-col>
|
||||
<el-col :span="5"><el-checkbox v-model="f.is_emergency">紧急联系人</el-checkbox></el-col>
|
||||
<el-col :span="4"><el-button type="danger" link @click="removeFamily(idx)">移除</el-button></el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<el-button type="primary" link @click="addFamily">+ 添加家属</el-button>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- Detail -->
|
||||
<el-drawer v-model="detailVisible" title="客户详情" size="500px">
|
||||
<template v-if="detailData">
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="姓名">{{ detailData.name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="手机号">{{ detailData.phone }}</el-descriptions-item>
|
||||
<el-descriptions-item label="微信号">{{ detailData.wechat || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="状态"><el-tag :type="statusType[detailData.status]" size="small">{{ statusMap[detailData.status] }}</el-tag></el-descriptions-item>
|
||||
<el-descriptions-item label="预产期">{{ detailData.expected_date || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="宝宝数">{{ detailData.baby_count }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<h4 style="margin:16px 0 8px">家属信息</h4>
|
||||
<el-table :data="detailData.families || []" border size="small">
|
||||
<el-table-column prop="name" label="姓名" />
|
||||
<el-table-column prop="phone" label="手机号" />
|
||||
<el-table-column prop="relation" label="关系" />
|
||||
<el-table-column label="紧急联系人" width="100"><template #default="{ row }"><el-tag :type="row.is_emergency ? 'danger' : 'info'" size="small">{{ row.is_emergency ? '是' : '否' }}</el-tag></template></el-table-column>
|
||||
</el-table>
|
||||
<h4 style="margin:16px 0 8px">合同列表</h4>
|
||||
<el-table :data="detailData.contracts || []" border size="small">
|
||||
<el-table-column prop="contract_no" label="合同编号" />
|
||||
<el-table-column prop="actual_amount" label="实际金额" />
|
||||
<el-table-column prop="check_in_date" label="入住日期" />
|
||||
</el-table>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,251 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { leadApi, channelApi } from '@/api/crm.js'
|
||||
import { userApi } from '@/api/system.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('新增线索')
|
||||
const submitLoading = ref(false)
|
||||
const followVisible = ref(false)
|
||||
const assignVisible = ref(false)
|
||||
const currentLead = ref(null)
|
||||
|
||||
const channels = ref([])
|
||||
const users = ref([])
|
||||
|
||||
const searchForm = reactive({ name: '', phone: '', status: '', channel_id: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({
|
||||
id: null, channel_id: '', name: '', phone: '', wechat: '',
|
||||
expected_date: '', source: '', remark: ''
|
||||
})
|
||||
const isEdit = ref(false)
|
||||
const formRules = {
|
||||
name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
|
||||
phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const followForm = reactive({ type: 1, content: '', next_follow_at: '' })
|
||||
const assignForm = reactive({ owner_id: '' })
|
||||
|
||||
const statusMap = { 1: '新建', 2: '跟进中', 3: '已转化', 4: '无效' }
|
||||
const statusType = { 1: 'info', 2: 'warning', 3: 'success', 4: 'danger' }
|
||||
const followTypeMap = { 1: '电话', 2: '微信', 3: '到店', 4: '其他' }
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await leadApi.getList({ ...searchForm, ...pagination })
|
||||
tableData.value = res.data?.list || res.data?.data || []
|
||||
total.value = res.data?.total || 0
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
async function fetchChannels() {
|
||||
try {
|
||||
const res = await channelApi.getList({ per_page: 200 })
|
||||
channels.value = res.data?.list || res.data?.data || []
|
||||
} catch {}
|
||||
}
|
||||
|
||||
async function fetchUsers() {
|
||||
try {
|
||||
const res = await userApi.getList({ per_page: 200 })
|
||||
users.value = res.data?.list || res.data?.data || []
|
||||
} catch {}
|
||||
}
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() {
|
||||
Object.assign(searchForm, { name: '', phone: '', status: '', channel_id: '' })
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
isEdit.value = false
|
||||
dialogTitle.value = '新增线索'
|
||||
Object.assign(form, { id: null, channel_id: '', name: '', phone: '', wechat: '', expected_date: '', source: '', remark: '' })
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleEdit(row) {
|
||||
isEdit.value = true
|
||||
dialogTitle.value = '编辑线索'
|
||||
const res = await leadApi.getDetail(row.id)
|
||||
const d = res.data
|
||||
Object.assign(form, { id: d.id, channel_id: d.channel_id || '', name: d.name, phone: d.phone, wechat: d.wechat || '', expected_date: d.expected_date || '', source: d.source || '', remark: d.remark || '' })
|
||||
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 leadApi.update(form.id, form)
|
||||
ElMessage.success('更新成功')
|
||||
} else {
|
||||
await leadApi.create(form)
|
||||
ElMessage.success('创建成功')
|
||||
}
|
||||
dialogVisible.value = false
|
||||
fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
await ElMessageBox.confirm(`确定删除线索「${row.name}」吗?`, '删除确认', { type: 'warning' })
|
||||
await leadApi.delete(row.id)
|
||||
ElMessage.success('删除成功')
|
||||
fetchList()
|
||||
}
|
||||
|
||||
function openFollow(row) {
|
||||
currentLead.value = row
|
||||
Object.assign(followForm, { type: 1, content: '', next_follow_at: '' })
|
||||
followVisible.value = true
|
||||
}
|
||||
|
||||
async function submitFollow() {
|
||||
if (!followForm.content) { ElMessage.warning('请输入跟进内容'); return }
|
||||
await leadApi.follow(currentLead.value.id, followForm)
|
||||
ElMessage.success('跟进记录已添加')
|
||||
followVisible.value = false
|
||||
fetchList()
|
||||
}
|
||||
|
||||
function openAssign(row) {
|
||||
currentLead.value = row
|
||||
assignForm.owner_id = row.owner_id || ''
|
||||
assignVisible.value = true
|
||||
}
|
||||
|
||||
async function submitAssign() {
|
||||
if (!assignForm.owner_id) { ElMessage.warning('请选择负责人'); return }
|
||||
await leadApi.assign(currentLead.value.id, assignForm)
|
||||
ElMessage.success('分配成功')
|
||||
assignVisible.value = false
|
||||
fetchList()
|
||||
}
|
||||
|
||||
function handlePageChange(val) { pagination.page = val; fetchList() }
|
||||
function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() }
|
||||
|
||||
onMounted(() => { fetchList(); fetchChannels(); fetchUsers() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="search-bar">
|
||||
<el-input v-model="searchForm.name" placeholder="姓名" style="width:160px" clearable @keydown.enter="handleSearch" />
|
||||
<el-input v-model="searchForm.phone" placeholder="手机号" style="width:160px" clearable @keydown.enter="handleSearch" />
|
||||
<el-select v-model="searchForm.channel_id" placeholder="渠道" clearable style="width:140px">
|
||||
<el-option v-for="c in channels" :key="c.id" :label="c.name" :value="c.id" />
|
||||
</el-select>
|
||||
<el-select v-model="searchForm.status" placeholder="状态" clearable style="width:120px">
|
||||
<el-option label="新建" :value="1" /><el-option label="跟进中" :value="2" />
|
||||
<el-option label="已转化" :value="3" /><el-option label="无效" :value="4" />
|
||||
</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="100" />
|
||||
<el-table-column prop="phone" label="手机号" min-width="130" />
|
||||
<el-table-column label="渠道" min-width="100">
|
||||
<template #default="{ row }">{{ row.channel?.name || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="expected_date" label="预产期" min-width="110" />
|
||||
<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.owner?.name || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" min-width="160" />
|
||||
<el-table-column label="操作" width="260" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button size="small" type="primary" link @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button size="small" type="success" link @click="openFollow(row)">跟进</el-button>
|
||||
<el-button size="small" type="warning" link @click="openAssign(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>
|
||||
|
||||
<!-- Add/Edit -->
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="600px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="80px">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12"><el-form-item label="姓名" prop="name"><el-input v-model="form.name" /></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="手机号" prop="phone"><el-input v-model="form.phone" /></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="微信号"><el-input v-model="form.wechat" /></el-form-item></el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="渠道">
|
||||
<el-select v-model="form.channel_id" placeholder="选择渠道" clearable style="width:100%">
|
||||
<el-option v-for="c in channels" :key="c.id" :label="c.name" :value="c.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12"><el-form-item label="预产期"><el-date-picker v-model="form.expected_date" type="date" value-format="YYYY-MM-DD" style="width:100%" /></el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="来源"><el-input v-model="form.source" /></el-form-item></el-col>
|
||||
<el-col :span="24"><el-form-item label="备注"><el-input v-model="form.remark" type="textarea" :rows="2" /></el-form-item></el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- Follow -->
|
||||
<el-dialog v-model="followVisible" title="添加跟进" width="500px" destroy-on-close>
|
||||
<el-form label-width="80px">
|
||||
<el-form-item label="跟进方式">
|
||||
<el-select v-model="followForm.type" style="width:100%">
|
||||
<el-option v-for="(v,k) in followTypeMap" :key="k" :label="v" :value="Number(k)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="跟进内容"><el-input v-model="followForm.content" type="textarea" :rows="3" /></el-form-item>
|
||||
<el-form-item label="下次跟进"><el-date-picker v-model="followForm.next_follow_at" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" style="width:100%" /></el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="followVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submitFollow">提交</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- Assign -->
|
||||
<el-dialog v-model="assignVisible" title="分配负责人" width="400px" destroy-on-close>
|
||||
<el-form label-width="80px">
|
||||
<el-form-item label="负责人">
|
||||
<el-select v-model="assignForm.owner_id" placeholder="选择负责人" filterable style="width:100%">
|
||||
<el-option v-for="u in users" :key="u.id" :label="u.name" :value="u.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="assignVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submitAssign">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,104 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { dailyMealPlanApi } from '@/api/meal.js'
|
||||
import { customerApi } from '@/api/crm.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const customers = ref([])
|
||||
|
||||
const searchForm = reactive({ customer_id: '', plan_date: '', meal_type: '', status: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 30 })
|
||||
|
||||
const form = reactive({ id: null, customer_id: '', plan_date: '', meal_type: 1, dishes: [], special_note: '' })
|
||||
const isEdit = ref(false)
|
||||
|
||||
const mealTypeMap = { 1: '早餐', 2: '午餐', 3: '下午茶', 4: '晚餐', 5: '宵夜' }
|
||||
const statusMap = { 0: '待备餐', 1: '已备餐', 2: '已送达', 3: '未用' }
|
||||
const statusType = { 0: 'info', 1: 'warning', 2: 'success', 3: 'danger' }
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try { const res = await dailyMealPlanApi.getList({ ...searchForm, ...pagination }); tableData.value = res.data?.list || res.data?.data || []; total.value = res.data?.total || 0 } finally { loading.value = false }
|
||||
}
|
||||
|
||||
async function fetchCustomers() { try { const res = await customerApi.getList({ per_page: 500, status: 3 }); customers.value = res.data?.list || res.data?.data || [] } catch {} }
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() { Object.assign(searchForm, { customer_id: '', plan_date: '', meal_type: '', status: '' }); handleSearch() }
|
||||
function handleAdd() { isEdit.value = false; Object.assign(form, { id: null, customer_id: '', plan_date: '', meal_type: 1, dishes: [], special_note: '' }); dialogVisible.value = true }
|
||||
|
||||
async function handleSubmit() {
|
||||
submitLoading.value = true
|
||||
try {
|
||||
if (isEdit.value) { await dailyMealPlanApi.update(form.id, form) } else { await dailyMealPlanApi.create(form) }
|
||||
ElMessage.success(isEdit.value ? '更新成功' : '创建成功'); dialogVisible.value = false; fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
}
|
||||
|
||||
async function handleDeliver(row) {
|
||||
await ElMessageBox.confirm('确认已送达?', '送达确认', { type: 'info' })
|
||||
await dailyMealPlanApi.deliver(row.id); ElMessage.success('已标记送达'); fetchList()
|
||||
}
|
||||
|
||||
async function handleStatusChange(row, status) {
|
||||
await dailyMealPlanApi.updateStatus(row.id, { status }); ElMessage.success('状态更新成功'); fetchList()
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
await ElMessageBox.confirm('确定删除该排餐吗?', '删除确认', { type: 'warning' })
|
||||
await dailyMealPlanApi.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(); fetchCustomers() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="search-bar">
|
||||
<el-select v-model="searchForm.customer_id" placeholder="选择客户" clearable filterable style="width:180px"><el-option v-for="c in customers" :key="c.id" :label="c.name" :value="c.id" /></el-select>
|
||||
<el-date-picker v-model="searchForm.plan_date" type="date" value-format="YYYY-MM-DD" placeholder="日期" style="width:160px" />
|
||||
<el-select v-model="searchForm.meal_type" placeholder="餐型" clearable style="width:120px"><el-option v-for="(v,k) in mealTypeMap" :key="k" :label="v" :value="Number(k)" /></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-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 label="客户" min-width="100"><template #default="{ row }">{{ row.customer?.name || '-' }}</template></el-table-column>
|
||||
<el-table-column prop="plan_date" label="日期" width="110" />
|
||||
<el-table-column label="餐型" width="80" align="center"><template #default="{ row }">{{ mealTypeMap[row.meal_type] }}</template></el-table-column>
|
||||
<el-table-column prop="special_note" label="特殊备注" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column label="评分" width="70" align="center"><template #default="{ row }">{{ row.review?.score || '-' }}</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 label="操作" width="220" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.status<2" size="small" type="success" link @click="handleDeliver(row)">送达</el-button>
|
||||
<el-dropdown v-if="row.status<2" trigger="click" @command="(cmd) => handleStatusChange(row, cmd)" style="margin:0 8px">
|
||||
<el-button size="small" type="warning" link>状态</el-button>
|
||||
<template #dropdown><el-dropdown-menu><el-dropdown-item v-for="(v,k) in statusMap" :key="k" :command="Number(k)">{{ v }}</el-dropdown-item></el-dropdown-menu></template>
|
||||
</el-dropdown>
|
||||
<el-button v-if="row.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,30,50]" layout="total,sizes,prev,pager,next,jumper" background @current-change="handlePageChange" @size-change="handleSizeChange" />
|
||||
</div>
|
||||
<el-dialog v-model="dialogVisible" :title="isEdit?'编辑排餐':'新增排餐'" width="550px" destroy-on-close>
|
||||
<el-form :model="form" label-width="80px">
|
||||
<el-form-item label="客户"><el-select v-model="form.customer_id" filterable style="width:100%"><el-option v-for="c in customers" :key="c.id" :label="c.name" :value="c.id" /></el-select></el-form-item>
|
||||
<el-form-item label="日期"><el-date-picker v-model="form.plan_date" type="date" value-format="YYYY-MM-DD" style="width:100%" /></el-form-item>
|
||||
<el-form-item label="餐型"><el-select v-model="form.meal_type" style="width:100%"><el-option v-for="(v,k) in mealTypeMap" :key="k" :label="v" :value="Number(k)" /></el-select></el-form-item>
|
||||
<el-form-item label="特殊备注"><el-input v-model="form.special_note" 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,90 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { dishApi } from '@/api/meal.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
|
||||
const searchForm = reactive({ name: '', category: '', status: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({ id: null, name: '', category: '', description: '', image: '', ingredients: [], contraindications: [], price: 0, status: 1 })
|
||||
const isEdit = ref(false)
|
||||
const formRules = { name: [{ required: true, message: '请输入菜品名称', trigger: 'blur' }] }
|
||||
const categories = ['汤', '主食', '配菜', '甜品', '水果', '饮品']
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try { const res = await dishApi.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, { name: '', category: '', status: '' }); handleSearch() }
|
||||
function handleAdd() { isEdit.value = false; Object.assign(form, { id: null, name: '', category: '', description: '', image: '', ingredients: [], contraindications: [], price: 0, status: 1 }); dialogVisible.value = true }
|
||||
async function handleEdit(row) { isEdit.value = true; const res = await dishApi.getDetail(row.id); const d = res.data; Object.assign(form, { id: d.id, name: d.name, category: d.category || '', description: d.description || '', image: d.image || '', ingredients: d.ingredients || [], contraindications: d.contraindications || [], price: d.price || 0, status: d.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 dishApi.update(form.id, form) } else { await dishApi.create(form) }
|
||||
ElMessage.success(isEdit.value ? '更新成功' : '创建成功'); dialogVisible.value = false; fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
await ElMessageBox.confirm(`确定删除菜品「${row.name}」吗?`, '删除确认', { type: 'warning' })
|
||||
await dishApi.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-input v-model="searchForm.name" placeholder="菜品名称" style="width:180px" clearable @keydown.enter="handleSearch" />
|
||||
<el-select v-model="searchForm.category" placeholder="分类" clearable style="width:120px"><el-option v-for="c in categories" :key="c" :label="c" :value="c" /></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="120" />
|
||||
<el-table-column prop="category" label="分类" width="80" align="center" />
|
||||
<el-table-column prop="price" label="价格" width="90" align="right" />
|
||||
<el-table-column prop="description" label="描述" min-width="200" show-overflow-tooltip />
|
||||
<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="[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="550px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="80px">
|
||||
<el-form-item label="菜品名称" prop="name"><el-input v-model="form.name" /></el-form-item>
|
||||
<el-form-item label="分类"><el-select v-model="form.category" style="width:100%"><el-option v-for="c in categories" :key="c" :label="c" :value="c" /></el-select></el-form-item>
|
||||
<el-form-item label="价格"><el-input-number v-model="form.price" :min="0" :precision="2" style="width:100%" /></el-form-item>
|
||||
<el-form-item label="描述"><el-input v-model="form.description" type="textarea" :rows="3" /></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,122 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { reservationApi, roomApi } from '@/api/room.js'
|
||||
import { customerApi } from '@/api/crm.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const customers = ref([])
|
||||
const rooms = ref([])
|
||||
|
||||
const searchForm = reactive({ customer_id: '', room_id: '', status: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({ id: null, customer_id: '', room_id: '', contract_id: '', check_in_date: '', check_out_date: '', remark: '' })
|
||||
const isEdit = ref(false)
|
||||
const formRules = {
|
||||
customer_id: [{ required: true, message: '请选择客户', trigger: 'change' }],
|
||||
room_id: [{ required: true, message: '请选择房间', trigger: 'change' }],
|
||||
check_in_date: [{ required: true, message: '请选择入住日期', trigger: 'change' }],
|
||||
check_out_date: [{ required: true, message: '请选择退房日期', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const statusMap = { 0: '预定', 1: '已入住', 2: '已退房', 3: '已取消' }
|
||||
const statusType = { 0: 'warning', 1: 'success', 2: 'info', 3: 'danger' }
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await reservationApi.getList({ ...searchForm, ...pagination })
|
||||
tableData.value = res.data?.list || res.data?.data || []
|
||||
total.value = res.data?.total || 0
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
async function fetchCustomers() { try { const res = await customerApi.getList({ per_page: 500 }); customers.value = res.data?.list || res.data?.data || [] } catch {} }
|
||||
async function fetchRooms() { try { const res = await roomApi.getList({ per_page: 200 }); rooms.value = res.data?.list || res.data?.data || [] } catch {} }
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() { Object.assign(searchForm, { customer_id: '', room_id: '', status: '' }); handleSearch() }
|
||||
function handleAdd() { isEdit.value = false; Object.assign(form, { id: null, customer_id: '', room_id: '', contract_id: '', check_in_date: '', check_out_date: '', remark: '' }); 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 reservationApi.update(form.id, form) } else { await reservationApi.create(form) }
|
||||
ElMessage.success(isEdit.value ? '更新成功' : '预定成功'); dialogVisible.value = false; fetchList(); fetchRooms()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
async function handleCheckIn(row) {
|
||||
await ElMessageBox.confirm(`确定为「${row.customer?.name}」办理入住?`, '入住确认', { type: 'info' })
|
||||
await reservationApi.checkIn(row.id); ElMessage.success('入住成功'); fetchList(); fetchRooms()
|
||||
}
|
||||
|
||||
async function handleCheckOut(row) {
|
||||
await ElMessageBox.confirm(`确定为「${row.customer?.name}」办理退房?`, '退房确认', { type: 'warning' })
|
||||
await reservationApi.checkOut(row.id); ElMessage.success('退房成功'); fetchList(); fetchRooms()
|
||||
}
|
||||
|
||||
async function handleCancel(row) {
|
||||
await ElMessageBox.confirm('确定取消该预定吗?', '取消确认', { type: 'warning' })
|
||||
await reservationApi.cancel(row.id, {}); ElMessage.success('已取消'); fetchList(); fetchRooms()
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
await ElMessageBox.confirm('确定删除该预定吗?', '删除确认', { type: 'warning' })
|
||||
await reservationApi.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(); fetchCustomers(); fetchRooms() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="search-bar">
|
||||
<el-select v-model="searchForm.customer_id" placeholder="选择客户" clearable filterable style="width:180px"><el-option v-for="c in customers" :key="c.id" :label="`${c.name}(${c.phone})`" :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-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 label="客户" min-width="100"><template #default="{ row }">{{ row.customer?.name || '-' }}</template></el-table-column>
|
||||
<el-table-column label="房间" min-width="120"><template #default="{ row }">{{ row.room?.number || '-' }} ({{ row.room?.room_type?.name || '' }})</template></el-table-column>
|
||||
<el-table-column prop="check_in_date" label="入住日期" min-width="110" />
|
||||
<el-table-column prop="check_out_date" label="退房日期" min-width="110" />
|
||||
<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="操作" width="260" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.status===0" size="small" type="success" link @click="handleCheckIn(row)">入住</el-button>
|
||||
<el-button v-if="row.status===1" size="small" type="warning" link @click="handleCheckOut(row)">退房</el-button>
|
||||
<el-button v-if="row.status<2" size="small" type="info" link @click="handleCancel(row)">取消</el-button>
|
||||
<el-button v-if="row.status!==1" 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="新增预定" width="550px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="80px">
|
||||
<el-form-item label="客户" prop="customer_id"><el-select v-model="form.customer_id" filterable style="width:100%"><el-option v-for="c in customers" :key="c.id" :label="`${c.name}(${c.phone})`" :value="c.id" /></el-select></el-form-item>
|
||||
<el-form-item label="房间" prop="room_id"><el-select v-model="form.room_id" filterable style="width:100%"><el-option v-for="r in rooms.filter(r=>r.status===1)" :key="r.id" :label="`${r.number} (${r.room_type?.name||''})`" :value="r.id" /></el-select></el-form-item>
|
||||
<el-form-item label="入住日期" prop="check_in_date"><el-date-picker v-model="form.check_in_date" type="date" value-format="YYYY-MM-DD" style="width:100%" /></el-form-item>
|
||||
<el-form-item label="退房日期" prop="check_out_date"><el-date-picker v-model="form.check_out_date" type="date" value-format="YYYY-MM-DD" style="width:100%" /></el-form-item>
|
||||
<el-form-item label="备注"><el-input v-model="form.remark" type="textarea" :rows="2" /></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,92 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { roomTypeApi } from '@/api/room.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
|
||||
const searchForm = reactive({ name: '', status: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 20 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({ id: null, name: '', price: 0, description: '', facilities: [], 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 roomTypeApi.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, { name: '', status: '' }); handleSearch() }
|
||||
function handleAdd() { isEdit.value = false; Object.assign(form, { id: null, name: '', price: 0, description: '', facilities: [], sort: 0, status: 1 }); dialogVisible.value = true }
|
||||
async function handleEdit(row) { isEdit.value = true; const res = await roomTypeApi.getDetail(row.id); const d = res.data; Object.assign(form, { id: d.id, name: d.name, price: d.price || 0, description: d.description || '', facilities: d.facilities || [], sort: d.sort || 0, status: d.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 roomTypeApi.update(form.id, form) } else { await roomTypeApi.create(form) }
|
||||
ElMessage.success(isEdit.value ? '更新成功' : '创建成功'); dialogVisible.value = false; fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
await ElMessageBox.confirm(`确定删除房型「${row.name}」吗?`, '删除确认', { type: 'warning' })
|
||||
try { await roomTypeApi.delete(row.id); ElMessage.success('删除成功'); fetchList() } catch {}
|
||||
}
|
||||
|
||||
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-input v-model="searchForm.name" placeholder="房型名称" style="width:180px" clearable @keydown.enter="handleSearch" />
|
||||
<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="150" />
|
||||
<el-table-column prop="price" label="日单价(元)" min-width="120" align="right" />
|
||||
<el-table-column label="房间数" width="90" align="center"><template #default="{ row }">{{ row.rooms_count || 0 }}</template></el-table-column>
|
||||
<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 prop="description" label="描述" min-width="200" show-overflow-tooltip />
|
||||
<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="isEdit?'编辑房型':'新增房型'" width="550px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="80px">
|
||||
<el-form-item label="房型名称" prop="name"><el-input v-model="form.name" /></el-form-item>
|
||||
<el-form-item label="日单价"><el-input-number v-model="form.price" :min="0" :precision="2" style="width:100%" /></el-form-item>
|
||||
<el-form-item label="描述"><el-input v-model="form.description" type="textarea" :rows="3" /></el-form-item>
|
||||
<el-form-item label="排序"><el-input-number v-model="form.sort" :min="0" /></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,119 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { roomApi, roomTypeApi } from '@/api/room.js'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const roomTypes = ref([])
|
||||
|
||||
const searchForm = reactive({ room_type_id: '', floor: '', status: '' })
|
||||
const pagination = reactive({ page: 1, per_page: 50 })
|
||||
|
||||
const formRef = ref(null)
|
||||
const form = reactive({ id: null, room_type_id: '', floor: '', number: '', sort: 0 })
|
||||
const isEdit = ref(false)
|
||||
const formRules = {
|
||||
room_type_id: [{ required: true, message: '请选择房型', trigger: 'change' }],
|
||||
number: [{ required: true, message: '请输入房间号', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const statusMap = { 1: '空房', 2: '已预定', 3: '入住', 4: '维修', 5: '清洁' }
|
||||
const statusType = { 1: 'success', 2: 'warning', 3: 'primary', 4: 'danger', 5: 'info' }
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await roomApi.getList({ ...searchForm, ...pagination })
|
||||
tableData.value = res.data?.list || res.data?.data || []
|
||||
total.value = res.data?.total || 0
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
async function fetchRoomTypes() {
|
||||
try { const res = await roomTypeApi.getList({ per_page: 100 }); roomTypes.value = res.data?.list || res.data?.data || [] } catch {}
|
||||
}
|
||||
|
||||
function handleSearch() { pagination.page = 1; fetchList() }
|
||||
function handleReset() { Object.assign(searchForm, { room_type_id: '', floor: '', status: '' }); handleSearch() }
|
||||
|
||||
function handleAdd() { isEdit.value = false; Object.assign(form, { id: null, room_type_id: '', floor: '', number: '', sort: 0 }); dialogVisible.value = true }
|
||||
async function handleEdit(row) { isEdit.value = true; Object.assign(form, { id: row.id, room_type_id: row.room_type_id, floor: row.floor || '', number: row.number, sort: row.sort }); 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 roomApi.update(form.id, form) } else { await roomApi.create(form) }
|
||||
ElMessage.success(isEdit.value ? '更新成功' : '创建成功'); dialogVisible.value = false; fetchList()
|
||||
} finally { submitLoading.value = false }
|
||||
})
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
if (row.status === 3) { ElMessage.warning('入住中的房间无法删除'); return }
|
||||
await ElMessageBox.confirm(`确定删除房间「${row.number}」吗?`, '删除确认', { type: 'warning' })
|
||||
await roomApi.delete(row.id); ElMessage.success('删除成功'); fetchList()
|
||||
}
|
||||
|
||||
async function changeStatus(row, status) {
|
||||
await roomApi.updateStatus(row.id, { status })
|
||||
ElMessage.success('状态更新成功'); fetchList()
|
||||
}
|
||||
|
||||
function handlePageChange(val) { pagination.page = val; fetchList() }
|
||||
function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() }
|
||||
onMounted(() => { fetchList(); fetchRoomTypes() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="search-bar">
|
||||
<el-select v-model="searchForm.room_type_id" placeholder="房型" clearable style="width:160px"><el-option v-for="t in roomTypes" :key="t.id" :label="t.name" :value="t.id" /></el-select>
|
||||
<el-input v-model="searchForm.floor" placeholder="楼层" style="width:100px" clearable />
|
||||
<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-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="number" label="房间号" width="100" />
|
||||
<el-table-column label="房型" min-width="120"><template #default="{ row }">{{ row.room_type?.name || '-' }}</template></el-table-column>
|
||||
<el-table-column prop="floor" label="楼层" width="80" align="center" />
|
||||
<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="操作" width="300" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button size="small" type="primary" link @click="handleEdit(row)">编辑</el-button>
|
||||
<el-dropdown trigger="click" @command="(cmd) => changeStatus(row, cmd)" style="margin:0 8px">
|
||||
<el-button size="small" type="warning" link>切换状态</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item v-for="(v,k) in statusMap" :key="k" :command="Number(k)" :disabled="row.status===Number(k)">{{ v }}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<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="500px" destroy-on-close>
|
||||
<el-form ref="formRef" :model="form" :rules="formRules" label-width="80px">
|
||||
<el-form-item label="房型" prop="room_type_id"><el-select v-model="form.room_type_id" style="width:100%"><el-option v-for="t in roomTypes" :key="t.id" :label="t.name" :value="t.id" /></el-select></el-form-item>
|
||||
<el-form-item label="房间号" prop="number"><el-input v-model="form.number" /></el-form-item>
|
||||
<el-form-item label="楼层"><el-input v-model="form.floor" /></el-form-item>
|
||||
<el-form-item label="排序"><el-input-number v-model="form.sort" :min="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>
|
||||
Reference in New Issue
Block a user