feat: CRM客户管理-设置微客宝登录密码
This commit is contained in:
@@ -83,4 +83,16 @@ class CustomerController extends Controller
|
|||||||
$customer->delete();
|
$customer->delete();
|
||||||
return $this->success(null);
|
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, '密码设置成功');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ Route::middleware(['auth:sanctum', 'store', 'oplog'])->group(function () {
|
|||||||
|
|
||||||
// 客户管理
|
// 客户管理
|
||||||
Route::apiResource('customers', CustomerController::class);
|
Route::apiResource('customers', CustomerController::class);
|
||||||
|
Route::post('customers/{customer}/set-password', [CustomerController::class, 'setPassword']);
|
||||||
|
|
||||||
// 合同管理
|
// 合同管理
|
||||||
Route::apiResource('contracts', ContractController::class);
|
Route::apiResource('contracts', ContractController::class);
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ export const customerApi = {
|
|||||||
getDetail: (id) => request.get(`/crm/customers/${id}`),
|
getDetail: (id) => request.get(`/crm/customers/${id}`),
|
||||||
create: (data) => request.post('/crm/customers', data),
|
create: (data) => request.post('/crm/customers', data),
|
||||||
update: (id, data) => request.put(`/crm/customers/${id}`, 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 ────────────────────────────────────────────────────────────────
|
// ─── Contracts ────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ const submitLoading = ref(false)
|
|||||||
const detailVisible = ref(false)
|
const detailVisible = ref(false)
|
||||||
const detailData = ref(null)
|
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 searchForm = reactive({ name: '', phone: '', status: '' })
|
||||||
const pagination = reactive({ page: 1, per_page: 20 })
|
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 addFamily() { form.families.push({ name: '', phone: '', relation: '', is_emergency: false }) }
|
||||||
function removeFamily(idx) { form.families.splice(idx, 1) }
|
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 handlePageChange(val) { pagination.page = val; fetchList() }
|
||||||
function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() }
|
function handleSizeChange(val) { pagination.per_page = val; pagination.page = 1; fetchList() }
|
||||||
|
|
||||||
@@ -124,10 +151,11 @@ onMounted(() => fetchList())
|
|||||||
<template #default="{ row }">{{ row.owner?.name || '-' }}</template>
|
<template #default="{ row }">{{ row.owner?.name || '-' }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="created_at" label="创建时间" min-width="160" />
|
<el-table-column prop="created_at" label="创建时间" min-width="160" />
|
||||||
<el-table-column label="操作" width="220" fixed="right" align="center">
|
<el-table-column label="操作" width="260" fixed="right" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-button size="small" type="primary" text @click="handleDetail(row)">详情</el-button>
|
<el-button size="small" type="primary" text @click="handleDetail(row)">详情</el-button>
|
||||||
<el-button size="small" type="primary" text @click="handleEdit(row)">编辑</el-button>
|
<el-button size="small" type="primary" text @click="handleEdit(row)">编辑</el-button>
|
||||||
|
<el-button size="small" type="warning" text @click="openSetPassword(row)">设置密码</el-button>
|
||||||
<el-button size="small" type="danger" text @click="handleDelete(row)">删除</el-button>
|
<el-button size="small" type="danger" text @click="handleDelete(row)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -195,5 +223,24 @@ onMounted(() => fetchList())
|
|||||||
</el-table>
|
</el-table>
|
||||||
</template>
|
</template>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
|
|
||||||
|
<!-- 设置微客宝登录密码 -->
|
||||||
|
<el-dialog v-model="pwdVisible" title="设置微客宝登录密码" width="400px" destroy-on-close>
|
||||||
|
<div style="margin-bottom:12px; color:#606266; font-size:13px;">
|
||||||
|
为客户 <strong>{{ pwdTarget?.name }}</strong>({{ pwdTarget?.phone }})设置手机号登录密码
|
||||||
|
</div>
|
||||||
|
<el-form label-width="90px">
|
||||||
|
<el-form-item label="新密码">
|
||||||
|
<el-input v-model="pwdForm.password" type="password" show-password placeholder="不少于 6 位" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="确认密码">
|
||||||
|
<el-input v-model="pwdForm.confirm" type="password" show-password placeholder="再次输入密码" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="pwdVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="pwdLoading" @click="submitSetPassword">确认设置</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user