mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 15:13:55 +08:00
Merge pull request #644 from xinnan-tech/web-admin-modify
Web admin modify
This commit is contained in:
@@ -1,19 +1,39 @@
|
||||
<template>
|
||||
<el-dialog :visible.sync="visible" width="400px" center>
|
||||
<div style="margin: 0 10px 10px;display: flex;align-items: center;gap: 10px;font-weight: 700;font-size: 20px;text-align: left;color: #3d4566;">
|
||||
<div style="width: 40px;height: 40px;border-radius: 50%;background: #5778ff;display: flex;align-items: center;justify-content: center;">
|
||||
<img src="@/assets/login/shield.png" alt="" style="width: 19px;height: 23px; filter: brightness(0) invert(1);" />
|
||||
</div>
|
||||
用户新密码
|
||||
</div>
|
||||
<div style="height: 1px;background: #e8f0ff;" />
|
||||
<div style="margin: 22px 15px;">
|
||||
<div style="font-weight: 400;font-size: 14px;text-align: left;color: #3d4566;">
|
||||
<div style="color: red;display: inline-block;">*</div>
|
||||
用户密码:
|
||||
用户新密码:
|
||||
</div>
|
||||
<div class="input-46" style="margin-top: 12px;">
|
||||
<el-input v-model="password" type="text" :readonly="true" style="font-weight: bold; color: #333;"/>
|
||||
<el-input
|
||||
v-model="password"
|
||||
type="text"
|
||||
:readonly="true"
|
||||
style="font-weight: bold; color: #333;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex;margin: 15px 15px;gap: 7px;">
|
||||
<div class="dialog-btn" style="background: #e6ebff;border: 1px solid #adbdff;color: #5778ff;" @click="closeDialog">
|
||||
<div
|
||||
class="dialog-btn"
|
||||
style="background: #e6ebff;border: 1px solid #adbdff;color: #5778ff;"
|
||||
@click="closeDialog"
|
||||
>
|
||||
关闭
|
||||
</div>
|
||||
<div class="dialog-btn" style="background: #5778ff;color: white;" @click="copyPassword">
|
||||
<div
|
||||
class="dialog-btn"
|
||||
style="background: #5778ff;color: white;"
|
||||
@click="copyPassword"
|
||||
>
|
||||
复制密码
|
||||
</div>
|
||||
</div>
|
||||
@@ -74,4 +94,4 @@ export default {
|
||||
background-color: #f6f8fb !important;
|
||||
cursor: default !important;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</div>
|
||||
|
||||
<el-card class="user-card" shadow="never">
|
||||
<el-table :data="userList" class="transparent-table" :header-cell-class-name="headerCellClassName">
|
||||
<el-table ref="userTable" :data="userList" class="transparent-table" :header-cell-class-name="headerCellClassName">
|
||||
<el-table-column label="选择" type="selection" align="center" width="120"></el-table-column>
|
||||
<el-table-column label="用户Id" prop="userid" align="center"></el-table-column>
|
||||
<el-table-column label="手机号码" prop="mobile" align="center"></el-table-column>
|
||||
@@ -33,10 +33,10 @@
|
||||
|
||||
<div class="table_bottom">
|
||||
<div class="ctrl_btn">
|
||||
<el-button size="mini" type="primary" style="width: 72px; background: #5f70f3">全选</el-button>
|
||||
<el-button size="mini" type="success" icon="el-icon-circle-check" style="background: #5bc98c">启用</el-button>
|
||||
<el-button size="mini" type="warning" style="color: black; background: #f6d075"><i class="el-icon-remove-outline rotated-icon"></i>禁用</el-button>
|
||||
<el-button size="mini" type="danger" icon="el-icon-delete" style="background: #fd5b63">删除</el-button>
|
||||
<el-button size="mini" type="primary" class="select-all-btn" @click="handleSelectAll">全选</el-button>
|
||||
<el-button size="mini" type="success" icon="el-icon-circle-check" @click="batchEnable">启用</el-button>
|
||||
<el-button size="mini" type="warning" @click="batchDisable"><i class="el-icon-remove-outline rotated-icon"></i>禁用</el-button>
|
||||
<el-button size="mini" type="danger" icon="el-icon-delete" @click="batchDelete">删除</el-button>
|
||||
</div>
|
||||
<div class="custom-pagination">
|
||||
<button class="pagination-btn" :disabled="currentPage === 1" @click="goFirst">首页</button>
|
||||
@@ -124,23 +124,105 @@ export default {
|
||||
this.currentPage = 1;
|
||||
this.fetchUsers();
|
||||
},
|
||||
|
||||
// 全选
|
||||
handleSelectAll() {
|
||||
this.$refs.userTable.toggleAllSelection();
|
||||
},
|
||||
|
||||
// 批量删除用户
|
||||
batchDelete() {
|
||||
console.log('执行批量删除操作');
|
||||
const selectedUsers = this.$refs.userTable.selection;
|
||||
if (selectedUsers.length === 0) {
|
||||
this.$message.warning('请先选择需要删除的用户');
|
||||
return;
|
||||
}
|
||||
|
||||
this.$confirm(`确定要删除选中的${selectedUsers.length}个用户吗?`, '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
const loading = this.$loading({
|
||||
lock: true,
|
||||
text: '正在删除中...',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
|
||||
try {
|
||||
const results = await Promise.all(
|
||||
selectedUsers.map(user => {
|
||||
return new Promise((resolve) => {
|
||||
adminApi.deleteUser(user.userid, ({data}) => {
|
||||
if (data.code === 0) {
|
||||
resolve({success: true, userid: user.userid});
|
||||
} else {
|
||||
resolve({success: false, userid: user.userid, msg: data.msg});
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
const successCount = results.filter(r => r.success).length;
|
||||
const failCount = results.length - successCount;
|
||||
|
||||
if (failCount === 0) {
|
||||
this.$message.success(`成功删除${successCount}个用户`);
|
||||
} else if (successCount === 0) {
|
||||
this.$message.error(`删除失败,请重试`);
|
||||
} else {
|
||||
this.$message.warning(`成功删除${successCount}个用户,${failCount}个删除失败`);
|
||||
}
|
||||
|
||||
this.fetchUsers();
|
||||
} catch (error) {
|
||||
this.$message.error('删除过程中发生错误');
|
||||
} finally {
|
||||
loading.close();
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$message.info('已取消删除');
|
||||
});
|
||||
},
|
||||
|
||||
// 批量启用用户
|
||||
batchEnable() {
|
||||
const selectedUsers = this.$refs.userTable.selection;
|
||||
if (selectedUsers.length === 0) {
|
||||
this.$message.warning('请先选择需要启用的用户');
|
||||
return;
|
||||
}
|
||||
selectedUsers.forEach(user => {
|
||||
user.status = '正常';
|
||||
});
|
||||
this.$message.success('启用操作成功');
|
||||
},
|
||||
|
||||
// 批量禁用用户
|
||||
batchDisable() {
|
||||
console.log('执行批量禁用操作');
|
||||
this.userList.forEach(user => {
|
||||
user.status = '禁用';
|
||||
});
|
||||
this.$message.success('状态已更新为禁用');
|
||||
},
|
||||
|
||||
// 重置密码
|
||||
resetPassword(row) {
|
||||
this.$confirm('重置后将会生成新密码,是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消'
|
||||
}).then(() => {
|
||||
adminApi.resetUserPassword(row.userid, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.currentPassword = data.data
|
||||
this.showViewPassword = true
|
||||
} else {
|
||||
this.$message.error(data.msg || '获取密码失败')
|
||||
this.$message.success('密码已重置,请通知用户使用新密码登录')
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
},
|
||||
disableUser(row) {
|
||||
row.status = '禁用';
|
||||
console.log('禁用用户:', row);
|
||||
@@ -149,6 +231,7 @@ export default {
|
||||
row.status = '正常';
|
||||
console.log('恢复用户:', row);
|
||||
},
|
||||
|
||||
// 用户删除
|
||||
deleteUser(row) {
|
||||
this.$confirm('确定要删除该用户吗?', '警告', {
|
||||
@@ -166,11 +249,7 @@ export default {
|
||||
})
|
||||
}).catch(() => {})
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.pageSize = val;
|
||||
console.log('每页条数:', val);
|
||||
},
|
||||
headerCellClassName({column, columnIndex}) {
|
||||
headerCellClassName({columnIndex}) {
|
||||
if (columnIndex === 0) {
|
||||
return 'custom-selection-header'
|
||||
}
|
||||
@@ -196,6 +275,7 @@ export default {
|
||||
this.currentPage = page;
|
||||
this.fetchUsers();
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -281,78 +361,203 @@ $table-bg-color: #ecf1fd;
|
||||
.ctrl_btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-left: 25px;
|
||||
}
|
||||
}
|
||||
margin-left: 30px;
|
||||
.el-button {
|
||||
min-width: 72px;
|
||||
height: 32px;
|
||||
padding: 7px 12px;
|
||||
font-size: 12px;
|
||||
border-radius: 4px;
|
||||
line-height: 1;
|
||||
font-weight: 500;
|
||||
border: none;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
.rotated-icon {
|
||||
display: inline-block;
|
||||
transform: rotate(45deg);
|
||||
margin-right: 4px;
|
||||
color: black;
|
||||
}
|
||||
&:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
:deep(.el-table) {
|
||||
background: $table-bg-color;
|
||||
&:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
&.transparent-table {
|
||||
.el-table__header th {
|
||||
background: $table-bg-color !important;
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
opacity: 0;
|
||||
border-radius: 100%;
|
||||
transform: scale(1, 1) translate(-50%, -50%);
|
||||
transform-origin: 50% 50%;
|
||||
}
|
||||
|
||||
&:focus:not(:active)::after {
|
||||
animation: ripple 0.6s ease-out;
|
||||
}
|
||||
}
|
||||
|
||||
/* 全选按钮 */
|
||||
.el-button--primary {
|
||||
background: #5f70f3;
|
||||
box-shadow: 0 2px 6px rgba(95, 112, 243, 0.3);
|
||||
|
||||
&:hover {
|
||||
background: #4d5fe1;
|
||||
box-shadow: 0 4px 8px rgba(95, 112, 243, 0.4);
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: #3a4bcf;
|
||||
box-shadow: 0 2px 4px rgba(95, 112, 243, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
/* 启用按钮 */
|
||||
.el-button--success {
|
||||
background: #5bc98c;
|
||||
box-shadow: 0 2px 6px rgba(91, 201, 140, 0.3);
|
||||
|
||||
&:hover {
|
||||
background: #4ab57d;
|
||||
box-shadow: 0 4px 8px rgba(91, 201, 140, 0.4);
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: #3aa16e;
|
||||
box-shadow: 0 2px 4px rgba(91, 201, 140, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
/* 禁用按钮 */
|
||||
.el-button--warning {
|
||||
background: #f6d075;
|
||||
color: black;
|
||||
box-shadow: 0 2px 6px rgba(246, 208, 117, 0.3);
|
||||
|
||||
&:hover {
|
||||
background: #e4c068;
|
||||
box-shadow: 0 4px 8px rgba(246, 208, 117, 0.4);
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: #d2b05b;
|
||||
box-shadow: 0 2px 4px rgba(246, 208, 117, 0.2);
|
||||
}
|
||||
|
||||
.rotated-icon {
|
||||
display: inline-block;
|
||||
transform: rotate(45deg);
|
||||
margin-right: 4px;
|
||||
color: black;
|
||||
}
|
||||
}
|
||||
|
||||
&::before {
|
||||
display: none;
|
||||
}
|
||||
/* 删除按钮 */
|
||||
.el-button--danger {
|
||||
background: #fd5b63;
|
||||
box-shadow: 0 2px 6px rgba(253, 91, 99, 0.3);
|
||||
|
||||
&:last-child td {
|
||||
border-bottom: none !important;
|
||||
}
|
||||
&:hover {
|
||||
background: #e44a52;
|
||||
box-shadow: 0 4px 8px rgba(253, 91, 99, 0.4);
|
||||
}
|
||||
|
||||
.el-table__body tr {
|
||||
background-color: $table-bg-color;
|
||||
td {
|
||||
border: {
|
||||
top: 1px solid rgba(0, 0, 0, 0.04);
|
||||
bottom: 1px solid rgba(0, 0, 0, 0.04);
|
||||
&:active {
|
||||
background: #cb3941;
|
||||
box-shadow: 0 2px 4px rgba(253, 91, 99, 0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes ripple {
|
||||
0% {
|
||||
transform: scale(0, 0);
|
||||
opacity: 0.5;
|
||||
}
|
||||
100% {
|
||||
transform: scale(20, 20);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.rotated-icon {
|
||||
display: inline-block;
|
||||
transform: rotate(45deg);
|
||||
margin-right: 4px;
|
||||
color: black;
|
||||
}
|
||||
|
||||
:deep(.el-table) {
|
||||
background: $table-bg-color;
|
||||
|
||||
&.transparent-table {
|
||||
.el-table__header th {
|
||||
background: $table-bg-color !important;
|
||||
color: black;
|
||||
}
|
||||
|
||||
&::before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&:last-child td {
|
||||
border-bottom: none !important;
|
||||
}
|
||||
|
||||
.el-table__body tr {
|
||||
background-color: $table-bg-color;
|
||||
td {
|
||||
border: {
|
||||
top: 1px solid rgba(0, 0, 0, 0.04);
|
||||
bottom: 1px solid rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 300px;
|
||||
margin-right: 10px;
|
||||
.search-input {
|
||||
width: 300px;
|
||||
margin-right: 10px;
|
||||
|
||||
:deep(.el-input__inner) {
|
||||
background-color: transparent;
|
||||
border-color: #d3d6dc;
|
||||
:deep(.el-input__inner) {
|
||||
background-color: transparent;
|
||||
border-color: #d3d6dc;
|
||||
|
||||
&:focus {
|
||||
border-color: #409eff;
|
||||
}
|
||||
&:focus {
|
||||
border-color: #409eff;
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: #606266;
|
||||
opacity: 0.7;
|
||||
&::placeholder {
|
||||
color: #606266;
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.custom-selection-header) {
|
||||
.el-checkbox {
|
||||
display: none !important;
|
||||
}
|
||||
:deep(.custom-selection-header) {
|
||||
.el-checkbox {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: '选择';
|
||||
display: inline-block;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
padding-bottom: 18px;
|
||||
&::after {
|
||||
content: '选择';
|
||||
display: inline-block;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
padding-bottom: 18px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.custom-pagination {
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user