This commit is contained in:
龚皓 2024-11-26 16:11:50 +08:00
parent 207913a253
commit ccf101167a
1 changed files with 18 additions and 9 deletions

View File

@ -35,8 +35,7 @@
<el-row>
<el-col :span="24">
<div class="table-part">
<el-table v-loading="loading" :data="tableData"
class="user-table" border max-height="700px">
<el-table v-loading="loading" :data="tableData" class="user-table" border max-height="700px">
<el-table-column v-if="getColumnVisibility('selection')" type="selection"
min-width="55"></el-table-column>
<el-table-column v-if="getColumnVisibility('id')" prop="id" label="序号"
@ -45,11 +44,20 @@
min-width="180"></el-table-column>
<el-table-column v-if="getColumnVisibility('email')" prop="email" label="邮箱"
min-width="200"></el-table-column>
<el-table-column v-if="getColumnVisibility('actions')" label="操作" min-width="200" align="center">
<el-table-column v-if="getColumnVisibility('actions')" label="操作" min-width="200"
align="center">
<template #default="scope">
<el-button type="text" size="small"
@click="showEditUserDialog(scope.row)">编辑</el-button>
<el-button type="text" size="small" @click="confirmDelete(scope.row)">删除</el-button>
<el-tooltip v-if="scope.row.isLocked" content="此用户无法被编辑或删除">
<el-button type="text" size="small" disabled>
编辑
</el-button>
</el-tooltip>
<el-button v-else type="text" size="small" @click="showEditUserDialog(scope.row)">
编辑
</el-button>
<el-button type="text" size="small" :disabled="scope.row.isLocked"
@click="confirmDelete(scope.row)">删除
</el-button>
</template>
</el-table-column>
</el-table>
@ -138,9 +146,10 @@ const refreshTable = async () => {
try {
const users = await apiInstance.getAllUsers(); // getAllUsers
tableData.value = users.map((user: any, index: number) => ({
id: index + 1, // id
id: index + 1,
username: user.username,
email: user.email
email: user.email,
isLocked: ['turingvideo'].includes(user.username)
}));
} catch (error) {
ElMessage.error('刷新用户列表失败');
@ -267,7 +276,7 @@ const handleDeleteSelected = () => {
max-width: 100%;
}
.user-table{
.user-table {
width: 100%;
overflow: auto;
overflow-x: auto;