11-mes-new/src/views/UserPage/usermanage.vue

404 lines
9.4 KiB
Vue
Raw Normal View History

2022-11-07 08:45:49 +08:00
<!--
* @Author: zwq
* @Date: 2021-04-06 19:33:11
* @LastEditors: gtz
* @LastEditTime: 2022-07-25 10:36:54
* @Description:
-->
<template>
2022-11-10 15:46:58 +08:00
<div class="app-container system-manage-landpage">
2022-11-07 08:45:49 +08:00
<el-container>
<el-aside>
2022-11-15 11:31:38 +08:00
<TestTree v-if="menuList.length > 0" :menu-list="menuList" @getOrganization="getOrganization" />
2022-11-15 10:09:07 +08:00
<!-- <side-tree v-if="menuList.length > 0" :menu-list="menuList" @getOrganization="getOrganization" /> -->
2022-11-07 08:45:49 +08:00
</el-aside>
2022-11-10 15:46:58 +08:00
<el-main>
2022-11-15 11:31:38 +08:00
<el-form ref="dataForm" :model="dataForm" :inline="true" size="mini" label-position="left">
<el-row>
<el-col style="margin: 0 0 28px;">
<!-- <el-form-item class="has-icon" label-width="100px" :label="$t('userManage.orgName')"> -->
<el-form-item class="has-icon">
<span v-if="dataForm.orgName">{{ dataForm.orgName }}</span>
<span v-else>用户管理</span>
</el-form-item>
</el-col>
<el-col>
<el-form-item :label="$t('userManage.userName')" prop="name">
<el-input
v-model="dataForm.name"
:placeholder="['placeholder.input', $t('userManage.userName')] | i18nFilterForm"
clearable
:style="{ width: '100%' }"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getList()">{{ 'btn.search' | i18nFilter }}</el-button>
</el-form-item>
</el-col>
</el-row>
2022-11-07 08:45:49 +08:00
</el-form>
<base-table
:top-btn-config="topBtnConfig"
:table-config="tableProps"
:table-data="list"
:is-loading="listLoading"
:page="dataForm.current"
:limit="dataForm.size"
@clickTopBtn="clickTopBtn"
>
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="trueWidth"
:method-list="tableBtn"
@clickBtn="handleClick"
/>
</base-table>
2022-11-10 15:46:58 +08:00
<pagination
v-show="total > 0"
:total="total"
:page.sync="dataForm.page"
:limit.sync="dataForm.limit"
@pagination="getList"
/>
2022-11-07 08:45:49 +08:00
<add-user-form :visible.sync="showDialog" @refreshDataList="getList" />
2022-11-10 15:46:58 +08:00
<edit-user-form :visible.sync="showEditDialog" :target-info="{ id: curEditId }" @refreshDataList="getList" />
2022-11-07 08:45:49 +08:00
<assign-Role :visible.sync="AssignRoleDialog" :user-id="userId" @refreshDataList="getList" />
</el-main>
</el-container>
</div>
</template>
<script>
2022-11-15 10:09:07 +08:00
import TestTree from './TestTree.vue'
2022-11-07 08:45:49 +08:00
import sideTree from '../system-manage/sideTree'
import { getOrgList } from '@/api/org'
import AddUserForm from './AddUserForm'
import EditUserForm from './EditUser'
import AssignRole from './AssignRole'
import BaseTable from '@/components/BaseTable'
// edit here
import { getUserList, delUser } from '@/api/user'
import { getRoleList } from '@/api/role'
import Pagination from '@/components/Pagination'
import MethodBtn from '@/components/BaseTable/subcomponents/MethodBtn'
import dataDict from '@/filters/DataDict'
import i18n from '@/lang'
const topBtnConfig = [
{
type: 'add',
btnName: 'btn.add'
}
]
// edit here
2022-11-10 15:46:58 +08:00
const tableBtn = [
{
type: 'edit',
btnName: 'btn.edit'
},
{
type: 'EmPower',
btnName: i18n.t('userManage.AssignRole')
},
{
type: 'delete',
btnName: 'btn.delete'
}
]
2022-11-07 08:45:49 +08:00
// birthday
// orgId
// sex
// code
// remark
2022-11-10 15:46:58 +08:00
const tableProps = [
{
prop: 'name',
label: i18n.t('userManage.userName')
2022-11-10 15:46:58 +08:00
},
{
prop: 'email',
label: i18n.t('userManage.email')
2022-11-10 15:46:58 +08:00
},
{
prop: 'mobile',
label: i18n.t('userManage.mobile')
2022-11-10 15:46:58 +08:00
},
// {
// prop: 'birthday',
// label: i18n.t('userManage.birthday'),
//
2022-11-10 15:46:58 +08:00
// },
{
prop: 'orgName',
label: i18n.t('userManage.orgName')
2022-11-10 15:46:58 +08:00
},
{
prop: 'roleName',
label: i18n.t('roleManage.roleName')
2022-11-10 15:46:58 +08:00
},
// {
// prop: 'sex',
// label: i18n.t('userManage.sex'),
//
2022-11-10 15:46:58 +08:00
// filter: dataDict('sex')
// },
{
prop: 'code',
label: i18n.t('userManage.code')
2022-11-10 15:46:58 +08:00
},
{
prop: 'enabled',
label: i18n.t('userManage.status'),
2022-11-10 15:46:58 +08:00
filter: dataDict('enableState')
},
{
prop: 'remark',
label: i18n.t('userManage.remark')
2022-11-10 15:46:58 +08:00
}
]
2022-11-07 08:45:49 +08:00
export default {
2022-11-15 10:09:07 +08:00
components: { TestTree, sideTree, Pagination, BaseTable, MethodBtn, AddUserForm, EditUserForm, AssignRole },
2022-11-07 08:45:49 +08:00
data() {
return {
topBtnConfig,
menuList: [],
tableBtn,
tableProps,
list: [],
total: 0,
trueWidth: 120,
listLoading: true,
showDialog: false,
curEditId: null,
userId: '',
showEditDialog: false,
AssignRoleDialog: false,
defaultProps: {
children: 'children',
label: 'label'
},
roleNameOptions: [],
dataForm: {
name: '',
sex: '',
roleName: '',
orgId: '',
orgName: '',
current: 1,
size: 20
},
2022-11-10 15:46:58 +08:00
sexOptions: [
{
label: '全部',
value: ''
},
{
label: '男',
value: 1
},
{
label: '女',
value: 2
}
]
2022-11-07 08:45:49 +08:00
}
},
created() {
this.getOrgList()
this.getList()
},
methods: {
async getOrgList() {
// edit here
const params = {
current: 1,
size: 500
}
this.roleNameOptions.splice(0, this.roleNameOptions.length)
const res = await getRoleList(params)
if (res.code === 0) {
this.roleNameOptions = res.data
}
this.menuList.splice(0, this.menuList.length)
const res1 = await getOrgList(params)
if (res1.code === 0) {
this.menuList = res1.data.records
2022-11-15 10:09:07 +08:00
console.log('menulist===>', this.menuList)
2022-11-07 08:45:49 +08:00
}
},
getOrganization(data) {
this.dataForm.orgId = data.id
this.dataForm.orgName = data.name
this.getList()
},
handleClick(raw) {
switch (raw.type) {
case 'delete':
this.$confirm(i18n.t('deleteMsgBox.content'), i18n.t('deleteMsgBox.hint'), {
confirmButtonText: i18n.t('btn.confirm'),
cancelButtonText: i18n.t('btn.cancel'),
type: 'warning'
2022-11-15 11:31:38 +08:00
}).then(async () => {
2022-11-07 08:45:49 +08:00
// 走接口
const result = await delUser({
id: raw.data.id
})
if (result.code === 0) {
this.$message({
type: 'success',
message: i18n.t('deleteMsgBox.doneMsg')
})
this.getList()
}
})
break
case 'edit':
this.showEditDialog = true
this.curEditId = raw.data.id
break
case 'EmPower':
this.AssignRoleDialog = true
this.userId = raw.data.id
break
}
},
async getList() {
this.listLoading = true
// edit here
const res = await getUserList(this.dataForm)
if (res.code === 0) {
this.list = res.data.records
this.list.forEach(item => {
item.roleName = item.stringList.toString()
})
this.total = res.data.total
this.listLoading = false
}
},
btnClick(val) {
this.headFormValue = val
// 如果点击的是搜索栏的其他按钮在这里继续写判断
if (this.headFormValue.btnName === 'search') {
this.getList()
}
},
clickTopBtn(val) {
if (val === 'add') {
2022-11-10 15:46:58 +08:00
this.showDialog = true // 新增
2022-11-07 08:45:49 +08:00
}
}
}
}
</script>
<style scoped>
2022-11-10 15:46:58 +08:00
.el-container >>> .el-aside {
border-radius: 8px;
background-color: #fff;
width: 256px !important;
margin: 0;
padding-left: 0;
padding-right: 0;
}
2022-11-15 11:31:38 +08:00
aside {
padding: 0;
}
2022-11-10 15:46:58 +08:00
.el-container >>> .el-main {
border-radius: 8px;
background-color: #fff;
border: unset;
}
.el-container >>> .el-tree-node__content {
padding-left: 16px !important;
padding-right: 16px !important;
}
.el-container >>> .el-tree-node__content:hover {
background-color: #e3efff;
}
.el-container >>> .el-tree-node:focus > .el-tree-node__content {
background-color: #e3efff;
}
/* .el-container >>> .el-icon-caret-right {
display: inline-block;
width: 4px;
height: 4px;
border-radius: 50%;
border: 1px solid #000;
background-color: transparent;
} */
.el-container >>> .el-icon-caret-right::before {
/* content: '';
display: inline-block;
width: 6px;
height: 6px;
border-radius: 50%;
border: 1px solid #000;
background-color: transparent; */
}
.system-manage-landpage {
background: unset;
padding: 0;
display: flex;
}
.el-container {
display: flex;
gap: 8px;
}
.el-container >>> .el-tree-node__label {
font-size: 14px;
line-height: 20px;
letter-spacing: 0.88px;
color: #161616;
2022-11-07 08:45:49 +08:00
}
2022-11-15 11:31:38 +08:00
.has-icon {
position: relative;
width: 100%;
display: flex;
align-items: center;
}
.has-icon::before {
content: '';
width: 4px;
border-radius: 2px;
height: 55%;
position: absolute;
/* top: 13%; */
left: 0;
background: #0b58ff;
}
:not(.has-icon) >>> .el-form-item__label {
font-size: 14px;
}
.has-icon >>> .el-form-item__label {
position: relative;
left: 12px;
font-size: 16px;
}
.has-icon >>> .el-form-item__content {
font-size: 16px;
margin-left: 12px;
}
.el-button--mini {
padding: 6px 12px;
border-radius: 4px;
}
/* .has-icon >>> .el-form-item__content {
position: absolute;
left: 24px;
} */
.el-form-item {
margin: 0;
}
2022-11-07 08:45:49 +08:00
</style>