feat(web): add tenant and user management pages
This commit is contained in:
@@ -12,7 +12,7 @@ export function listTenants() {
|
||||
return client.get('/api/v1/account/tenant/list')
|
||||
}
|
||||
|
||||
export function createUser(data: { username: string; password: string; realName?: string }) {
|
||||
export function createUser(data: { username: string; password: string; realName?: string; roleCodes?: string[] }) {
|
||||
return client.post('/api/v1/account/user', data)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,57 @@
|
||||
<template>
|
||||
<div>
|
||||
<h2>租户管理</h2>
|
||||
<el-form :model="form" inline>
|
||||
<el-form-item label="租户编码">
|
||||
<el-input v-model="form.tenantCode" placeholder="租户编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="租户名称">
|
||||
<el-input v-model="form.tenantName" placeholder="租户名称" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleCreate">创建</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table :data="tenants" border>
|
||||
<el-table-column prop="id" label="ID" width="80" />
|
||||
<el-table-column prop="tenantCode" label="租户编码" />
|
||||
<el-table-column prop="tenantName" label="租户名称" />
|
||||
<el-table-column prop="status" label="状态" />
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { createTenant, listTenants } from '@/api/account'
|
||||
|
||||
const form = reactive({
|
||||
tenantCode: '',
|
||||
tenantName: '',
|
||||
})
|
||||
|
||||
const tenants = ref<any[]>([])
|
||||
|
||||
async function loadTenants() {
|
||||
try {
|
||||
const res: any = await listTenants()
|
||||
tenants.value = res.data || []
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCreate() {
|
||||
try {
|
||||
await createTenant(form)
|
||||
ElMessage.success('创建成功')
|
||||
await loadTenants()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadTenants)
|
||||
</script>
|
||||
|
||||
@@ -1,5 +1,62 @@
|
||||
<template>
|
||||
<div>
|
||||
<h2>用户管理</h2>
|
||||
<el-form :model="form" inline>
|
||||
<el-form-item label="用户名">
|
||||
<el-input v-model="form.username" placeholder="用户名" />
|
||||
</el-form-item>
|
||||
<el-form-item label="密码">
|
||||
<el-input v-model="form.password" type="password" placeholder="密码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="真实姓名">
|
||||
<el-input v-model="form.realName" placeholder="真实姓名" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleCreate">创建</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table :data="users" border>
|
||||
<el-table-column prop="id" label="ID" width="80" />
|
||||
<el-table-column prop="username" label="用户名" />
|
||||
<el-table-column prop="realName" label="真实姓名" />
|
||||
<el-table-column prop="roleCodes" label="角色" />
|
||||
<el-table-column prop="status" label="状态" />
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { createUser, listUsers } from '@/api/account'
|
||||
|
||||
const form = reactive({
|
||||
username: '',
|
||||
password: '',
|
||||
realName: '',
|
||||
})
|
||||
|
||||
const users = ref<any[]>([])
|
||||
|
||||
async function loadUsers() {
|
||||
try {
|
||||
const res: any = await listUsers()
|
||||
users.value = res.data || []
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCreate() {
|
||||
try {
|
||||
await createUser({ ...form, roleCodes: ['tenant_admin'] })
|
||||
ElMessage.success('创建成功')
|
||||
await loadUsers()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadUsers)
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user