feat: 完善前端用户管理功能
This commit is contained in:
@@ -11,6 +11,14 @@ export default {
|
|||||||
rank: 1
|
rank: 1
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
|
{
|
||||||
|
path: "/auth/backendUser",
|
||||||
|
name: "backendUser",
|
||||||
|
component: () => import("@/views/auth/backendUser/index.vue"),
|
||||||
|
meta: {
|
||||||
|
title: "管理端用户"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/auth/company",
|
path: "/auth/company",
|
||||||
name: "company",
|
name: "company",
|
||||||
|
|||||||
@@ -37,13 +37,52 @@ const tableData = ref([]);
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
|
|
||||||
|
// 公司列表数据
|
||||||
|
const companyOptions = ref([]);
|
||||||
|
|
||||||
|
// 获取公司列表
|
||||||
|
const getCompanyList = async () => {
|
||||||
|
try {
|
||||||
|
const res = await request(authApi("getCompanyPrimaryInfo"), {
|
||||||
|
method: "post"
|
||||||
|
});
|
||||||
|
console.info(res);
|
||||||
|
if (res.status === 200) {
|
||||||
|
companyOptions.value = res.data.map(item => ({
|
||||||
|
value: item.id,
|
||||||
|
label: item.companyName
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("获取公司列表失败:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 角色列表数据
|
||||||
|
const roleOptions = ref([]);
|
||||||
|
// 获得角色列表
|
||||||
|
const getRoleList = async () => {
|
||||||
|
try {
|
||||||
|
const res = await request(authApi("getRoles"), {
|
||||||
|
method: "post"
|
||||||
|
});
|
||||||
|
console.info(res);
|
||||||
|
if (res.status === 200) {
|
||||||
|
roleOptions.value = res.data.map(item => ({
|
||||||
|
value: item.id,
|
||||||
|
label: item.roleName
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("获取角色列表失败:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 获得前端用户列表
|
// 获得前端用户列表
|
||||||
const getUserList = async () => {
|
const getUserList = async () => {
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const params = { ...queryParams.value };
|
const params = { ...queryParams.value };
|
||||||
|
|
||||||
console.info(params);
|
|
||||||
const data = await request(authApi("frontendUserPage"), {
|
const data = await request(authApi("frontendUserPage"), {
|
||||||
method: "post",
|
method: "post",
|
||||||
body: JSON.stringify(params)
|
body: JSON.stringify(params)
|
||||||
@@ -99,48 +138,59 @@ const columns: TableColumnList = [
|
|||||||
{
|
{
|
||||||
label: "账号",
|
label: "账号",
|
||||||
prop: "name",
|
prop: "name",
|
||||||
width: "260",
|
width: "160",
|
||||||
fixed: true
|
fixed: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "昵称",
|
label: "昵称",
|
||||||
prop: "nickName",
|
prop: "nickName",
|
||||||
width: "260"
|
width: "180"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "电话",
|
label: "电话",
|
||||||
prop: "phoneNum",
|
prop: "phoneNum",
|
||||||
width: "260"
|
width: "120"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "邮件",
|
label: "邮件",
|
||||||
prop: "email",
|
prop: "email",
|
||||||
width: "260"
|
width: "200"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "所属公司",
|
label: "所属公司",
|
||||||
prop: "companyId",
|
prop: "companyId",
|
||||||
width: "260"
|
width: "150",
|
||||||
|
formatter: row => {
|
||||||
|
const company = companyOptions.value.find(
|
||||||
|
item => item.value === row.companyId
|
||||||
|
);
|
||||||
|
return company ? company.label : "";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "角色",
|
label: "角色",
|
||||||
prop: "roleId",
|
prop: "roleId",
|
||||||
width: "260"
|
width: "150",
|
||||||
},
|
formatter: row => {
|
||||||
{
|
const role = roleOptions.value.find(item => item.value === row.roleId);
|
||||||
label: "微信ID",
|
return role ? role.label : "";
|
||||||
prop: "wxOpenid",
|
}
|
||||||
width: "260"
|
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// label: "微信ID",
|
||||||
|
// prop: "wxOpenid",
|
||||||
|
// width: "260"
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
label: "状态",
|
label: "状态",
|
||||||
prop: "status",
|
prop: "status",
|
||||||
width: "100"
|
width: "100",
|
||||||
|
slot: "status"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "上次登陆时间",
|
label: "上次登陆时间",
|
||||||
prop: "createTime",
|
prop: "createTime",
|
||||||
width: "260",
|
width: "155",
|
||||||
formatter: row => {
|
formatter: row => {
|
||||||
return row.createTime
|
return row.createTime
|
||||||
? dayjs(row.createTime).format("YYYY-MM-DD HH:mm:ss")
|
? dayjs(row.createTime).format("YYYY-MM-DD HH:mm:ss")
|
||||||
@@ -150,7 +200,7 @@ const columns: TableColumnList = [
|
|||||||
{
|
{
|
||||||
label: "创建时间",
|
label: "创建时间",
|
||||||
prop: "createTime",
|
prop: "createTime",
|
||||||
width: "260",
|
width: "155",
|
||||||
formatter: row => {
|
formatter: row => {
|
||||||
return row.createTime
|
return row.createTime
|
||||||
? dayjs(row.createTime).format("YYYY-MM-DD HH:mm:ss")
|
? dayjs(row.createTime).format("YYYY-MM-DD HH:mm:ss")
|
||||||
@@ -199,22 +249,31 @@ const handleDelete = row => {
|
|||||||
// 页面加载时获取数据
|
// 页面加载时获取数据
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getUserList();
|
getUserList();
|
||||||
|
getCompanyList(); // 获取公司列表数据
|
||||||
|
getRoleList(); // 获取角色列表数据
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="company-container">
|
<div class="company-container">
|
||||||
<div class="search-box">
|
<div class="search-box">
|
||||||
<el-form ref="queryForm" :model="queryParams" :inline="true">
|
<el-form
|
||||||
<el-form-item label="账号" prop="name">
|
ref="queryForm"
|
||||||
|
:model="queryParams"
|
||||||
|
:inline="true"
|
||||||
|
class="search-form"
|
||||||
|
>
|
||||||
|
<!-- 第一行 -->
|
||||||
|
<div class="form-row">
|
||||||
|
<el-form-item label="名称" prop="name">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.name"
|
v-model="queryParams.name"
|
||||||
placeholder="请输入账号"
|
placeholder="请输入名称"
|
||||||
clearable
|
clearable
|
||||||
@keyup.enter="handleSearch"
|
@keyup.enter="handleSearch"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="昵称" prop="nickName">
|
<el-form-item label="昵称" prop="nikeName">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.nikeName"
|
v-model="queryParams.nikeName"
|
||||||
placeholder="请输入昵称"
|
placeholder="请输入昵称"
|
||||||
@@ -222,6 +281,37 @@ onMounted(() => {
|
|||||||
@keyup.enter="handleSearch"
|
@keyup.enter="handleSearch"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="电话号码" prop="phoneNum">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.phoneNum"
|
||||||
|
placeholder="请输入电话号码"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleSearch"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="邮箱" prop="email">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.email"
|
||||||
|
placeholder="请输入邮箱"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleSearch"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="所属公司" prop="companyId">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.companyId"
|
||||||
|
placeholder="请选择公司"
|
||||||
|
clearable
|
||||||
|
class="company-select"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in companyOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="queryParams.status"
|
v-model="queryParams.status"
|
||||||
@@ -230,13 +320,14 @@ onMounted(() => {
|
|||||||
class="status-select"
|
class="status-select"
|
||||||
>
|
>
|
||||||
<el-option label="正常" value="1" />
|
<el-option label="正常" value="1" />
|
||||||
<el-option label="异常" value="0" />
|
<el-option label="禁用" value="0" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item class="search-buttons">
|
||||||
<el-button type="primary" @click="handleSearch">搜索</el-button>
|
<el-button type="primary" @click="handleSearch">搜索</el-button>
|
||||||
<el-button @click="handleReset">重置</el-button>
|
<el-button @click="handleReset">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -248,8 +339,8 @@ onMounted(() => {
|
|||||||
row-key="id"
|
row-key="id"
|
||||||
>
|
>
|
||||||
<template #status="{ row }">
|
<template #status="{ row }">
|
||||||
<el-tag :type="row.status === 1 ? 'success' : 'danger'" size="small">
|
<el-tag :type="row.status == '1' ? 'success' : 'danger'" size="small">
|
||||||
{{ row.status === 1 ? "正常" : "异常" }}
|
{{ row.status == "1" ? "正常" : "异常" }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -276,3 +367,55 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.company-container {
|
||||||
|
padding: 20px;
|
||||||
|
|
||||||
|
.search-box {
|
||||||
|
padding: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 4px;
|
||||||
|
|
||||||
|
.search-form {
|
||||||
|
.form-row {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-form-item) {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 200px;
|
||||||
|
margin-right: 10px;
|
||||||
|
margin-bottom: 0;
|
||||||
|
|
||||||
|
// 调整输入框宽度
|
||||||
|
.el-input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.search-buttons {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
min-width: auto;
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-select {
|
||||||
|
width: 80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.company-select {
|
||||||
|
width: 180px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user