This commit is contained in:
lz_db
2026-10-17 19:04:05 +08:00
parent 28b11b4365
commit 1253c159f5
43 changed files with 2652 additions and 114 deletions
+86 -3
View File
@@ -48,9 +48,18 @@
</template>
</el-table-column>
<el-table-column prop="created_at" label="注册时间" width="170" />
<el-table-column label="操作" width="170" fixed="right">
<el-table-column label="操作" width="230" fixed="right">
<template #default="{ row }">
<el-button link type="primary" :icon="View" @click="toDetail(row)">详情</el-button>
<el-button
v-if="row.status !== 3"
link
type="warning"
:icon="Key"
@click="openResetPwd(row)"
>
改密
</el-button>
<el-button
v-if="row.status === 1"
link
@@ -84,16 +93,52 @@
@current-change="load"
/>
</div>
<!-- 重置密码弹窗 -->
<el-dialog v-model="pwdDialog.visible" title="重置用户密码" width="420px">
<el-form label-width="80px">
<el-form-item label="用户">
<span>{{ pwdDialog.nickname }} #{{ pwdDialog.userId }}</span>
</el-form-item>
<el-form-item label="新密码">
<el-input
v-model="pwdDialog.newPassword"
type="password"
show-password
placeholder="6-100 位"
maxlength="100"
/>
</el-form-item>
<el-form-item label="操作原因">
<el-input
v-model="pwdDialog.reason"
type="textarea"
:rows="2"
placeholder="必填,将记录操作日志"
maxlength="200"
/>
</el-form-item>
</el-form>
<div style="color: var(--el-color-warning); font-size: 12px; margin-top: -8px">
重置后该用户所有端登录态立即失效,需用新密码重新登录
</div>
<template #footer>
<el-button @click="pwdDialog.visible = false">取消</el-button>
<el-button type="primary" :loading="pwdDialog.submitting" @click="submitResetPwd">
确定
</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { Lock, Refresh, Search, Unlock, View } from '@element-plus/icons-vue'
import { Key, Lock, Refresh, Search, Unlock, View } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import { onMounted, reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import { listUsers, setUserStatus } from '@/api/users'
import { listUsers, resetUserPassword, setUserStatus } from '@/api/users'
import { askReason } from '@/utils/reason'
const STATUS_TAG = { 1: 'success', 2: 'danger', 3: 'info' }
@@ -154,5 +199,43 @@ async function toggleStatus(row, target) {
load()
}
const pwdDialog = reactive({
visible: false,
userId: 0,
nickname: '',
newPassword: '',
reason: '',
submitting: false,
})
function openResetPwd(row) {
pwdDialog.userId = row.user_id
pwdDialog.nickname = row.nickname || ''
pwdDialog.newPassword = ''
pwdDialog.reason = ''
pwdDialog.visible = true
}
async function submitResetPwd() {
const pwd = pwdDialog.newPassword.trim()
const reason = pwdDialog.reason.trim()
if (pwd.length < 6 || pwd.length > 100) {
ElMessage.warning('新密码长度需为 6-100 位')
return
}
if (!reason) {
ElMessage.warning('请填写操作原因')
return
}
pwdDialog.submitting = true
try {
await resetUserPassword(pwdDialog.userId, { new_password: pwd, reason })
ElMessage.success('密码已重置,该用户全端登录态已失效')
pwdDialog.visible = false
} finally {
pwdDialog.submitting = false
}
}
onMounted(load)
</script>