| | |
| | | <template> |
| | | <div> |
| | | <div class="page"> |
| | | <h2 class="page-title">平台管理员</h2> |
| | | <el-form :inline="true" class="search-form" @submit.prevent="doSearch"> |
| | | <el-form-item label="姓名"> |
| | |
| | | <el-button @click="resetSearch">重置</el-button> |
| | | </el-form-item> |
| | | <el-form-item class="push-right"> |
| | | <el-button v-permission="'sys:users:create'" type="success" @click="openCreate">新增管理员</el-button> |
| | | <el-button v-permission="'sys:users:create'" type="primary" @click="openCreate">新增管理员</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | |
| | | <el-table :data="rows" v-loading="loading" stripe> |
| | | <div class="table-wrap"> |
| | | <el-table :data="rows" v-loading="loading" stripe height="100%"> |
| | | <el-table-column label="序号" width="64" :index="indexMethod" type="index" /> |
| | | <el-table-column prop="realName" label="姓名" width="100" show-overflow-tooltip /> |
| | | <el-table-column prop="username" label="登录账号" width="120" show-overflow-tooltip /> |
| | |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-table> |
| | | </div> |
| | | |
| | | <el-pagination |
| | | class="pager" |
| | | class="main-pager" |
| | | background |
| | | layout="prev, pager, next" |
| | | layout="sizes, prev, pager, next" |
| | | :total="total" |
| | | :page-size="size" |
| | | :page-sizes="[10, 20, 50, 100]" |
| | | v-model:current-page="page" |
| | | @current-change="load" |
| | | @size-change="onSizeChange" |
| | | /> |
| | | |
| | | <!-- 新增 --> |
| | |
| | | <el-option |
| | | v-for="r in roles" |
| | | :key="r.id" |
| | | :label="`${r.roleName} (${r.roleCode})`" |
| | | :label="r.roleName" |
| | | :value="r.id" |
| | | /> |
| | | </el-select> |
| | |
| | | <el-option |
| | | v-for="r in roles" |
| | | :key="r.id" |
| | | :label="`${r.roleName} (${r.roleCode})`" |
| | | :label="r.roleName" |
| | | :value="r.id" |
| | | /> |
| | | </el-select> |
| | |
| | | import { ElMessage, ElMessageBox } from "element-plus"; |
| | | import type { UploadRequestOptions } from "element-plus"; |
| | | import http from "../api/http"; |
| | | import { normalizeFormData } from "../utils/formHelper"; |
| | | |
| | | type RoleRow = { id: number; roleCode: string; roleName: string }; |
| | | |
| | |
| | | load(); |
| | | } |
| | | |
| | | function onSizeChange(nextSize: number) { |
| | | size.value = nextSize; |
| | | page.value = 1; |
| | | load(); |
| | | } |
| | | |
| | | function resetCreateForm() { |
| | | createForm.username = ""; |
| | | createForm.password = ""; |
| | |
| | | const nextStatus = isAdminUsername(createForm.username) ? 1 : (createForm.statusEnabled ? 1 : 0); |
| | | saving.value = true; |
| | | try { |
| | | await http.post("/sys/users", { |
| | | const payload = normalizeFormData({ |
| | | username: createForm.username.trim(), |
| | | password: createForm.password, |
| | | realName: createForm.realName || undefined, |
| | |
| | | roleIds: createForm.roleIds, |
| | | status: nextStatus, |
| | | }); |
| | | await http.post("/sys/users", payload); |
| | | ElMessage.success("已创建"); |
| | | dlgCreate.value = false; |
| | | load(); |
| | |
| | | const nextStatus = isAdminUsername(editForm.username) ? 1 : (editForm.statusEnabled ? 1 : 0); |
| | | saving.value = true; |
| | | try { |
| | | await http.put(`/sys/users/${editingId.value}`, { |
| | | const payload = normalizeFormData({ |
| | | uuid: editForm.uuid, |
| | | realName: editForm.realName || undefined, |
| | | mobile: editForm.mobile || undefined, |
| | |
| | | roleIds: editForm.roleIds, |
| | | status: nextStatus, |
| | | }); |
| | | await http.put(`/sys/users/${editingId.value}`, payload); |
| | | ElMessage.success("已保存"); |
| | | dlgEdit.value = false; |
| | | load(); |
| | |
| | | } |
| | | saving.value = true; |
| | | try { |
| | | await http.post(`/sys/users/${pwdUserId.value}/password`, { |
| | | const payload = normalizeFormData({ |
| | | uuid: pwdUserUuid.value, |
| | | newPassword: pwdForm.newPassword, |
| | | newPasswordConfirm: pwdForm.newPasswordConfirm, |
| | | }); |
| | | await http.post(`/sys/users/${pwdUserId.value}/password`, payload); |
| | | ElMessage.success("密码已重置"); |
| | | dlgPwd.value = false; |
| | | } catch (e: unknown) { |
| | |
| | | font-weight: 700; |
| | | } |
| | | |
| | | .page { |
| | | display: flex; |
| | | flex-direction: column; |
| | | height: calc(100vh - 190px); |
| | | min-height: 420px; |
| | | } |
| | | |
| | | .search-form { |
| | | margin-bottom: 12px; |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | | align-items: center; |
| | | gap: 4px 0; |
| | | flex: none; |
| | | } |
| | | .push-right { |
| | | margin-left: auto; |
| | | } |
| | | .pager { |
| | | .table-wrap { |
| | | flex: 1; |
| | | min-height: 0; |
| | | } |
| | | .main-pager { |
| | | margin-top: 12px; |
| | | justify-content: flex-end; |
| | | flex: none; |
| | | } |
| | | |
| | | .avatar-upload-row { |