From 6bf79d6e656d1cfc7076da69914cbd14efce763a Mon Sep 17 00:00:00 2001 From: li Date: Sat, 14 Mar 2026 19:55:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20CRM=E5=AE=A2=E6=88=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?-=E8=AE=BE=E7=BD=AE=E5=BE=AE=E5=AE=A2=E5=AE=9D=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Crm/CustomerController.php | 12 +++++ backend/routes/api.php | 1 + frontend/src/api/crm.js | 3 +- frontend/src/views/crm/customers/index.vue | 49 ++++++++++++++++++- 4 files changed, 63 insertions(+), 2 deletions(-) diff --git a/backend/app/Http/Controllers/Admin/Crm/CustomerController.php b/backend/app/Http/Controllers/Admin/Crm/CustomerController.php index fa52f36..afb8415 100644 --- a/backend/app/Http/Controllers/Admin/Crm/CustomerController.php +++ b/backend/app/Http/Controllers/Admin/Crm/CustomerController.php @@ -83,4 +83,16 @@ class CustomerController extends Controller $customer->delete(); return $this->success(null); } + + /** + * 设置/重置客户端登录密码 + */ + public function setPassword(Request $request, Customer $customer): JsonResponse + { + $request->validate([ + 'password' => 'required|string|min:6', + ]); + $customer->update(['password' => $request->password]); + return $this->success(null, '密码设置成功'); + } } diff --git a/backend/routes/api.php b/backend/routes/api.php index e145691..de79583 100644 --- a/backend/routes/api.php +++ b/backend/routes/api.php @@ -145,6 +145,7 @@ Route::middleware(['auth:sanctum', 'store', 'oplog'])->group(function () { // 客户管理 Route::apiResource('customers', CustomerController::class); + Route::post('customers/{customer}/set-password', [CustomerController::class, 'setPassword']); // 合同管理 Route::apiResource('contracts', ContractController::class); diff --git a/frontend/src/api/crm.js b/frontend/src/api/crm.js index 6b77770..5bc1852 100644 --- a/frontend/src/api/crm.js +++ b/frontend/src/api/crm.js @@ -26,7 +26,8 @@ export const customerApi = { 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}`) + delete: (id) => request.delete(`/crm/customers/${id}`), + setPassword: (id, data) => request.post(`/crm/customers/${id}/set-password`, data), } // ─── Contracts ──────────────────────────────────────────────────────────────── diff --git a/frontend/src/views/crm/customers/index.vue b/frontend/src/views/crm/customers/index.vue index 43fd57c..bc4b94c 100644 --- a/frontend/src/views/crm/customers/index.vue +++ b/frontend/src/views/crm/customers/index.vue @@ -12,6 +12,12 @@ const submitLoading = ref(false) const detailVisible = ref(false) const detailData = ref(null) +// 设置密码 +const pwdVisible = ref(false) +const pwdForm = reactive({ password: '', confirm: '' }) +const pwdTarget = ref(null) +const pwdLoading = ref(false) + const searchForm = reactive({ name: '', phone: '', status: '' }) const pagination = reactive({ page: 1, per_page: 20 }) @@ -84,6 +90,27 @@ async function handleDetail(row) { function addFamily() { form.families.push({ name: '', phone: '', relation: '', is_emergency: false }) } function removeFamily(idx) { form.families.splice(idx, 1) } +function openSetPassword(row) { + pwdTarget.value = row + Object.assign(pwdForm, { password: '', confirm: '' }) + pwdVisible.value = true +} + +async function submitSetPassword() { + if (!pwdForm.password || pwdForm.password.length < 6) { + ElMessage.warning('密码不少于 6 位'); return + } + if (pwdForm.password !== pwdForm.confirm) { + ElMessage.warning('两次密码不一致'); return + } + pwdLoading.value = true + try { + await customerApi.setPassword(pwdTarget.value.id, { password: pwdForm.password }) + ElMessage.success('微客宝登录密码已设置') + pwdVisible.value = false + } finally { pwdLoading.value = false } +} + function handlePageChange(val) { pagination.page = val; fetchList() } function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() } @@ -124,10 +151,11 @@ onMounted(() => fetchList()) - + @@ -195,5 +223,24 @@ onMounted(() => fetchList()) + + + +
+ 为客户 {{ pwdTarget?.name }}({{ pwdTarget?.phone }})设置手机号登录密码 +
+ + + + + + + + + +