feat: 优化管理后台页面UI、修复TS编译错误、新增人生事件模块

- 优化 AI 配置列表页面:重构统计卡片、搜索表单、表格列展示
- 修复 3 处 TypeScript TS6133 编译错误,恢复构建
- 新增管理员修改密码和重置密码功能
- 优化小程序多个页面样式和交互
- 人生事件模块完善

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-10 23:23:09 +08:00
parent 60c63850ee
commit 755059807a
62 changed files with 4661 additions and 3019 deletions
+74 -1
View File
@@ -55,6 +55,7 @@
<el-table-column label="操作" width="200" fixed="right">
<template #default="{ row }">
<el-button type="primary" link @click="handleEdit(row)">编辑</el-button>
<el-button type="warning" link @click="handleChangePassword(row)">修改密码</el-button>
<el-button type="danger" link @click="handleDelete(row)">删除</el-button>
</template>
</el-table-column>
@@ -128,13 +129,32 @@
</el-button>
</template>
</el-dialog>
<!-- 修改密码对话框 -->
<el-dialog v-model="changePasswordVisible" title="修改密码" width="450px">
<el-form ref="changePwFormRef" :model="changePwForm" :rules="changePwRules" label-width="80px">
<el-form-item label="账号">
<el-input :model-value="changePwForm.account" disabled />
</el-form-item>
<el-form-item label="新密码" prop="newPassword">
<el-input v-model="changePwForm.newPassword" type="password" show-password placeholder="请输入新密码" />
</el-form-item>
<el-form-item label="确认密码" prop="confirmPassword">
<el-input v-model="changePwForm.confirmPassword" type="password" show-password placeholder="请再次输入新密码" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="changePasswordVisible = false">取消</el-button>
<el-button type="primary" @click="handleResetPasswordSubmit" :loading="changePwSubmitting">确定</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus'
import { getAdminPage, createAdmin, updateAdmin, deleteAdmin } from '@/api/admin'
import { getAdminPage, createAdmin, updateAdmin, deleteAdmin, resetAdminPassword } from '@/api/admin'
import type { Admin, AdminPageRequest } from '@/types/admin'
import { validateAccount, validatePassword, validateEmail, validatePhone } from '@/utils/validate'
@@ -181,6 +201,31 @@ const formRules: FormRules = {
const dialogTitle = ref('新增管理员')
const changePasswordVisible = ref(false)
const changePwSubmitting = ref(false)
const changePwFormRef = ref<FormInstance>()
const changePwForm = reactive({
id: '',
account: '',
newPassword: '',
confirmPassword: ''
})
const validateConfirmPw = (_rule: any, value: string, callback: any) => {
if (!value) {
callback(new Error('请再次输入密码'))
} else if (value !== changePwForm.newPassword) {
callback(new Error('两次输入的密码不一致'))
} else {
callback()
}
}
const changePwRules: FormRules = {
newPassword: [{ required: true, message: '请输入新密码', trigger: 'blur' }],
confirmPassword: [{ required: true, validator: validateConfirmPw, trigger: 'blur' }]
}
const fetchData = async () => {
loading.value = true
try {
@@ -245,6 +290,34 @@ const handleDelete = (row: Admin) => {
})
}
const handleChangePassword = (row: Admin) => {
changePwForm.id = row.id
changePwForm.account = row.account
changePwForm.newPassword = ''
changePwForm.confirmPassword = ''
changePasswordVisible.value = true
}
const handleResetPasswordSubmit = async () => {
if (!changePwFormRef.value) return
await changePwFormRef.value.validate(async (valid) => {
if (!valid) return
changePwSubmitting.value = true
try {
await resetAdminPassword({
id: changePwForm.id,
newPassword: changePwForm.newPassword
})
ElMessage.success('密码重置成功')
changePasswordVisible.value = false
} catch (error: any) {
ElMessage.error(error?.response?.data?.message || '重置密码失败')
} finally {
changePwSubmitting.value = false
}
})
}
const handleSubmit = async () => {
if (!formRef.value) return