优化平台端租户端

This commit is contained in:
2026-09-09 00:30:44 +08:00
parent 672c22d9b6
commit 34b2449462
20 changed files with 847 additions and 42 deletions
@@ -35,11 +35,19 @@
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="140" align="center" fixed="right">
<el-table-column label="操作" width="260" align="center" fixed="right">
<template #default="{ row }">
<el-button text type="primary" @click="openPasswordDialog(row)">
修改密码
</el-button>
<el-button
text
:type="Number(row.status) === 1 ? 'warning' : 'success'"
@click="handleToggleStatus(row)"
>
{{ Number(row.status) === 1 ? "禁用" : "启用" }}
</el-button>
<el-button text type="danger" @click="handleDelete(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
@@ -65,9 +73,9 @@
<script setup lang="ts">
import { ref, reactive, watch } from "vue";
import { ElMessage } from "element-plus";
import { ElMessage, ElMessageBox } from "element-plus";
import { Plus } from "@element-plus/icons-vue";
import { getTenantUserList, editTenantUser } from "@/api/tenantUser";
import { getTenantUserList, editTenantUser, deleteTenantUser } from "@/api/tenantUser";
import AddUser from "./adduser.vue";
const props = defineProps<{
@@ -206,6 +214,54 @@ const submitPassword = async () => {
}
};
const handleToggleStatus = async (row: any) => {
const next = Number(row.status) === 1 ? 0 : 1;
const actionText = next === 0 ? "禁用" : "启用";
const name = row.name || row.account || `ID ${row.id}`;
try {
await ElMessageBox.confirm(`确定要${actionText}用户「${name}」吗?`, "提示", {
type: "warning",
});
} catch {
return;
}
try {
const res = await editTenantUser(row.id, { status: next });
if (res.code === 200) {
ElMessage.success(`${actionText}成功`);
refreshTenantUsers();
} else {
ElMessage.error(res.msg || `${actionText}失败`);
}
} catch (e: any) {
ElMessage.error(e?.message || `${actionText}失败`);
}
};
const handleDelete = async (row: any) => {
const name = row.name || row.account || `ID ${row.id}`;
try {
await ElMessageBox.confirm(
`确定要删除用户「${name}」吗?删除后不可恢复。`,
"警告",
{ type: "warning" }
);
} catch {
return;
}
try {
const res = await deleteTenantUser(row.id);
if (res.code === 200) {
ElMessage.success("删除成功");
refreshTenantUsers();
} else {
ElMessage.error(res.msg || "删除失败");
}
} catch (e: any) {
ElMessage.error(e?.message || "删除失败");
}
};
defineExpose({
refreshTenantUsers,
});