Commit b71d9b4d by 胡悦

提交用户和角色接口逻辑

1 parent c224df34
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
<el-select <el-select
v-model="ruleForm[item.prop]" v-model="ruleForm[item.prop]"
:placeholder="item.placeholder || '请选择'" :placeholder="item.placeholder || '请选择'"
:filterable="item.filterable || false"
@change="selectChange" @change="selectChange"
> >
<el-option <el-option
...@@ -64,7 +65,7 @@ ...@@ -64,7 +65,7 @@
<el-radio <el-radio
v-for="(child,childIndex) in item.children" v-for="(child,childIndex) in item.children"
:key="childIndex" :key="childIndex"
:label="child" :label="childIndex"
>{{child}}</el-radio> >{{child}}</el-radio>
</el-radio-group> </el-radio-group>
<el-select <el-select
...@@ -83,11 +84,11 @@ ...@@ -83,11 +84,11 @@
</el-option> </el-option>
</el-select> </el-select>
</template> </template>
<template <template v-else-if="item.type == 'customize'">
v-else-if="item.type == 'customize'" <slot
name="form-slot" :scope="scope"
:name="item.slotName"
> >
<slot :scope="scope">
</slot> </slot>
</template> </template>
</template> </template>
...@@ -140,6 +141,8 @@ export default { ...@@ -140,6 +141,8 @@ export default {
default: '100px' default: '100px'
} }
}, },
mounted() {
},
methods: { methods: {
selectChange(val) { selectChange(val) {
// console.log(val ,'selectChange') // console.log(val ,'selectChange')
......
...@@ -20,12 +20,27 @@ const API = { ...@@ -20,12 +20,27 @@ const API = {
const USER_API = { const USER_API = {
USER_SEARCH: BASE_URL + '/usercenter/user/search', USER_SEARCH: BASE_URL + '/usercenter/user/search',
USER_SUPER: BASE_URL + '/usercenter/user/suitableSuperUsers', USER_SUPER: BASE_URL + '/usercenter/user/suitableSuperUsers',
USER_ADD: BASE_URL + '/usercenter/user/add' USER_ADD: BASE_URL + '/usercenter/user/add',
USER_EDIT: BASE_URL + '/usercenter/user/edit',
USER_INFO: BASE_URL + '/usercenter/user/info',
USER_DELETE: BASE_URL + '/usercenter/user/delete',
ROLE_SIMPLELIST: BASE_URL + '/usercenter/role/simplelist'
} }
const ROLE_API = { const ROLE_API = {
ROLE_SEARCH: { ROLE_SEARCH: BASE_URL + '/usercenter/role/search',
apiUrl: BASE_URL + '/usercenter/role/search' ROLE_INFO: BASE_URL + '/usercenter/role/info',
} TENANT_SIMPLELIST: BASE_URL + '/usercenter/tenant/simplelist',
ROLE_ADD: BASE_URL + '/usercenter/role/add',
ROLE_EDIT: BASE_URL + '/usercenter/role/edit',
ROLE_DELETE: BASE_URL + '/usercenter/role/delete'
}
const MENU_API = {
MENU_SEARCH: BASE_URL + '/usercenter/menu/search',
MENU_CHILDREN: BASE_URL + '/usercenter/menu/children',
MENU_ADD: BASE_URL + '/usercenter/menu/add',
MENU_EDIT: BASE_URL + '/usercenter/menu/edit',
MENU_DELETE: BASE_URL + '/usercenter/menu/delete',
MENU_INFO: BASE_URL + '/usercenter/menu/info'
} }
const ORGINIZA_API = { const ORGINIZA_API = {
ORGINIZA_SEARCH: BASE_URL + '/usercenter/organization/rootList', ORGINIZA_SEARCH: BASE_URL + '/usercenter/organization/rootList',
...@@ -48,4 +63,4 @@ const WORKLOG_API = { ...@@ -48,4 +63,4 @@ const WORKLOG_API = {
WORKLOG_SEARCH: BASE_URL + '/loggincenter/loggin/search', WORKLOG_SEARCH: BASE_URL + '/loggincenter/loggin/search',
WORKLOG_EXPORT: BASE_URL + '/loggincenter/loggin/export' WORKLOG_EXPORT: BASE_URL + '/loggincenter/loggin/export'
} }
export { API, USER_API, ROLE_API, ORGINIZA_API, DICT_API, WORKLOG_API } export { API, USER_API, ROLE_API, ORGINIZA_API, DICT_API, WORKLOG_API, MENU_API }
import { MENU_API } from '@/config/config'
import request from '@/services/request'
// 获取菜单列表
function getMenuList (params) {
const url = MENU_API.MENU_SEARCH
return request(params, url)
}
// 根据菜单根节点获取子节点
function getMenuChildren (params) {
const url = MENU_API.MENU_CHILDREN
return request(params, url)
}
// 添加菜单
function addMenu (params) {
const url = MENU_API.MENU_ADD
return request(params, url, 'post')
}
// 编辑菜单
function editMenu (params) {
const url = MENU_API.MENU_EDIT
return request(params, url, 'post')
}
// 删除菜单
function deleteMenu (params) {
const url = MENU_API.MENU_DELETE
return request(params, url)
}
// 获取菜单列表
function menuInfo (params) {
const url = MENU_API.MENU_INFO
return request(params, url)
}
export { getMenuList, getMenuChildren, addMenu, editMenu, menuInfo, deleteMenu }
import HTTP from '@/utils/http'
import { ROLE_API } from '@/config/config' import { ROLE_API } from '@/config/config'
import request from '@/services/request'
export default class RoleService extends HTTP { // 获取用户列表
function getRoleList (params) {
const url = ROLE_API.ROLE_SEARCH
return request(params, url)
}
// 获取用户详情
function roleInfo (params) {
const url = ROLE_API.ROLE_INFO
return request(params, url)
}
// 获取租户列表
function getTenantList (params) {
const url = ROLE_API.TENANT_SIMPLELIST
return request(params, url)
} }
// 获取用户列表
function addRole (params) {
const url = ROLE_API.ROLE_ADD
return request(params, url, 'post')
}
// 获取用户列表
function editRole (params) {
const url = ROLE_API.ROLE_EDIT
return request(params, url, 'post')
}
// 获取用户列表
function deleteRole (params) {
const url = ROLE_API.ROLE_DELETE
return request(params, url)
}
export { getRoleList, roleInfo, getTenantList, addRole, editRole, deleteRole }
import { USER_API} from '@/config/config' import { USER_API } from '@/config/config'
import request from '@/services/request' import request from '@/services/request'
// 获取用户列表 // 获取用户列表
...@@ -14,7 +14,26 @@ function getSuperUser (params) { ...@@ -14,7 +14,26 @@ function getSuperUser (params) {
// 新增用户 // 新增用户
function addUser (params) { function addUser (params) {
const url = USER_API.USER_ADD const url = USER_API.USER_ADD
return request(params, url, 'post')
}
// 编辑用户
function editUser (params) {
const url = USER_API.USER_EDIT
return request(params, url, 'post')
}
// 用户详情
function detailUser (params) {
const url = USER_API.USER_INFO
return request(params, url) return request(params, url)
} }
// 删除用户
export { getUserList, getSuperUser, addUser} function deleteUser (params) {
const url = USER_API.USER_DELETE
return request(params, url)
}
// 下拉角色列表
function roleList (params) {
const url = USER_API.ROLE_SIMPLELIST
return request(params, url)
}
export { getUserList, getSuperUser, addUser, editUser, detailUser, deleteUser, roleList }
const Constants = { const Constants = {
// 用户状态 // 用户状态
USER_STATUS: { USER_STATUS: {
'0': '正常, green', '1': '正常, green',
'-1': '停用, red' '2': '停用, red'
}, },
// 角色数据权限 // 角色数据权限
ROLE_AUTH: { ROLE_AUTH: {
...@@ -14,9 +14,20 @@ const Constants = { ...@@ -14,9 +14,20 @@ const Constants = {
}, },
// 租户可见度 // 租户可见度
ROLE_VISIBLE: { ROLE_VISIBLE: {
'0': '共享', 0: '共享',
'1': '仅系统管理员', 1: '仅系统管理员',
'2': '可见租户' 2: '可见租户'
},
// 菜单类型
MENU_TYPE: {
1: '目录',
2: '菜单',
3: '按钮'
},
// 菜单状态
MENU_STATUS: {
1: '正常, green',
2: '不显示, gray'
}, },
// 组织状态 // 组织状态
ORGINIZA_STATUS: { ORGINIZA_STATUS: {
......
...@@ -4,19 +4,20 @@ ...@@ -4,19 +4,20 @@
<search-form <search-form
class="searchTop border-shadow" class="searchTop border-shadow"
:formModel="searchForm" :formModel="searchForm"
:formList="userFormList" :formList="menuFormList"
> >
<slot name="form-slot"> <slot name="form-slot">
<el-button <el-button
type="primary" type="primary"
:size="btn_size" :size="btn_size"
icon="el-icon-search" icon="el-icon-search"
:id="tableParams.btnId" @click="search"
>搜索</el-button> >搜索</el-button>
<el-button <el-button
type="primary" type="primary"
:size="btn_size" :size="btn_size"
icon="el-icon-refresh" icon="el-icon-refresh"
@click="refresh"
>重置</el-button> >重置</el-button>
</slot> </slot>
</search-form> </search-form>
...@@ -29,24 +30,14 @@ ...@@ -29,24 +30,14 @@
>新增</el-button> >新增</el-button>
</div> </div>
<el-table <el-table
v-loading="loading" :data="menuTableData"
align="center"
ref="multipleTable"
:data="listData"
tooltip-effect="dark"
style="width: 100%" style="width: 100%"
@row-click="rowClick" row-key="id"
:header-cell-style="{background:'#f5f7fa'}" border
lazy
:load="load"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
> >
<table-tree-column
ref='OrgiSort'
@table-click="tableClick"
prop="departmentName"
header-align="center"
treeKey="id"
width="300"
label="组织名称"
></table-tree-column>
<el-table-column <el-table-column
v-for="(item,index) in listHeadData" v-for="(item,index) in listHeadData"
:key="index" :key="index"
...@@ -58,13 +49,12 @@ ...@@ -58,13 +49,12 @@
show-overflow-tooltip show-overflow-tooltip
> >
<template slot-scope="scope"> <template slot-scope="scope">
<template v-if="item.prop === 'orgStatus'"> <template v-if="item.prop === 'enableStatus'">
dfs <span
<!-- <span
class="dot" class="dot"
:class="ORGINIZASTATUS[scope.row[item.prop]].split(',')[1]" :class="scope.row.enableStatus ? MENUSTATUS[scope.row.enableStatus].split(',')[1] : ''"
></span> ></span>
<span class="statusText">{{ORGINIZASTATUS[scope.row[item.prop]].split(',')[0]}}</span> --> <span class="statusText">{{ scope.row.enableStatus ? MENUSTATUS[scope.row.enableStatus].split(',')[0] : '--'}}</span>
</template> </template>
<template v-else> <template v-else>
{{scope.row[item.prop]?scope.row[item.prop]:'--'}} {{scope.row[item.prop]?scope.row[item.prop]:'--'}}
...@@ -85,23 +75,34 @@ ...@@ -85,23 +75,34 @@
:type="j.type" :type="j.type"
size="mini" size="mini"
plain plain
@click="btnClick(j.pType, scope.scope)" @click="btnClick(j.pType, scope.row)"
>{{j.name}}</el-button> >{{j.name}}</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- <el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="page.pageNum"
:page-sizes="[10,20,30,40]"
:page-size="page.pageSize"
:total="getListApi ? total : tableTotal"
layout="sizes,total,->,prev,pager,next,jumper"
>
</el-pagination> -->
<basic-dialog <basic-dialog
:title="userDialogTitle" :title="menuDialogTitle"
:isVisible="userVisible" :isVisible="menuVisible"
@confirmDialog="handleConfirm" @confirmDialog="handleConfirm"
@closeDialog="handleClose" @closeDialog="handleClose"
> >
<slot> <slot>
<rule-form <rule-form
:ruleForm="userForm" :ruleForm="menuForm"
:rules="userRules" :rules="menuRules"
:ruleData="userData" :ruleData="menuData"
ref='userForm' ref='menuForm'
></rule-form> ></rule-form>
</slot> </slot>
</basic-dialog> </basic-dialog>
...@@ -134,39 +135,46 @@ ...@@ -134,39 +135,46 @@
</div> </div>
</template> </template>
<script> <script>
import { getMenuList, getMenuChildren, addMenu, editMenu, menuInfo, deleteMenu } from 'services/menu';
import OrginizaService from 'services/orginizaManage';
const orginizaService = new OrginizaService();
export default { export default {
data() { data() {
return { return {
ORGINIZASTATUS: this.$Constants.ORGINIZASTATUS, MENUSTATUS: this.$Constants.MENU_STATUS,
searchForm: {}, searchForm: {},
userFormList: [ menuFormList: [
{ {
type: 'input', type: 'input',
inputType: 'text', inputType: 'text',
prop: 'organizationName', prop: 'organizationName',
placeholder: '请输入组织名称' placeholder: '请输入菜单名称'
}, },
{ {
type: 'select', type: 'select',
prop: 'enableStatus', prop: 'enableStatus',
placeholder: '请选择组织状态', placeholder: '请选择菜单状态',
options: [{ options: [{
value: '0', value: '1',
label: '正常' label: '正常'
}, { }, {
value: '1', value: '2',
label: '停用' label: '不显示'
}] }]
} }
], ],
listHeadData: [ // 列表 头部设置 数据 menuTableData: [],
// 列表 头部设置 数据
listHeadData: [
{ prop: 'menuName', label: '菜单名称' },
{ prop: 'orderNum', label: '排序' }, { prop: 'orderNum', label: '排序' },
{ prop: 'frontRoute', label: '请求地址' },
{ prop: 'enableStatus', label: '状态' }, { prop: 'enableStatus', label: '状态' },
{ prop: 'createTime', label: '创建时间' } { prop: 'permissionTag', label: '权限标识' }
], ],
page: {
pageNum: 10,
pageSize: 1
},
total: 10,
tableParams: { tableParams: {
tableOption: { tableOption: {
btnList: [ btnList: [
...@@ -189,24 +197,30 @@ export default { ...@@ -189,24 +197,30 @@ export default {
} }
}, },
// 弹窗数据 // 弹窗数据
userDialogTitle: '新增用户', menuDialogTitle: '新增菜单',
userVisible: false, menuVisible: false,
userForm: { menuForm: {
account: '', parentName: '',
departmentId: '',
superiorId: '',
enableStatus: true enableStatus: true
}, },
userData: [ menuData: [
{ label: '组织名称', prop: 'account', type: 'input' }, { label: '菜单类型', prop: 'type', type: 'radio', children: this.$Constants.MENU_TYPE },
{ label: '显示排序', prop: 'departmentId', type: 'input' }, { label: '上级菜单', prop: 'parentName', type: 'input', readonly: true, clickFunc: this.selectSuperior },
{ label: '组织状态', prop: 'superiorId', type: 'input' } { label: '菜单名称', prop: 'menuName', type: 'input' },
{ label: '权限标识', prop: 'permissionTag', type: 'input' },
{ label: '前端路由', prop: 'frontRoute', type: 'input' },
{ label: '显示排序', prop: 'orderNum', type: 'input' },
{ label: '显示状态', prop: 'enableStatus', type: 'switch' },
{ label: '图标', prop: 'icon', type: 'input' }
], ],
userRules: { menuRules: {
account: [{ required: true, message: '请输入登录名称', trigger: blur }] type: [{ required: true, message: '请输入菜单类型', trigger: 'change' }],
menuName: [{ required: true, message: '请输入菜单名称', trigger: 'blur' }],
orderNum: [{ required: true, message: '请输入显示排序', trigger: 'blur' }],
enableStatus: [{ required: true }],
}, },
// 部门弹窗 // 部门弹窗
filterDialogTitle: '选择组织', filterDialogTitle: '选择上级',
filterVisible: false, filterVisible: false,
filterText: '', filterText: '',
filterTextData: [ filterTextData: [
...@@ -276,8 +290,6 @@ export default { ...@@ -276,8 +290,6 @@ export default {
children: 'children', children: 'children',
label: 'label' label: 'label'
}, },
listData: [
],
loading: false loading: false
} }
...@@ -291,12 +303,25 @@ export default { ...@@ -291,12 +303,25 @@ export default {
this.getList() this.getList()
}, },
methods: { methods: {
// 确定,新增用户、编辑用户 search() {
},
// 重置搜索条件
refresh() {
this.searchForm = {}
},
// 确定,新增、编辑
handleConfirm() { handleConfirm() {
console.log(this.$refs.userForm) console.log(this.menuForm)
this.$refs.userForm.$children[0].validate((valid) => { this.$refs.menuForm.$children[0].validate((valid) => {
if (valid) { if (valid) {
let params = JSON.parse(JSON.stringify(this.menuForm))
params.enableStatus = this.menuForm.enableStatus ? 1 : 2
let api = addMenu
if (params.id) api = editMenu
api(params).then(res => {
this.handleClose() this.handleClose()
})
} else { } else {
console.log('error') console.log('error')
} }
...@@ -304,10 +329,10 @@ export default { ...@@ -304,10 +329,10 @@ export default {
}, },
// 取消 // 取消
handleClose() { handleClose() {
if (!this.userVisible && this.$refs.userForm) { if (!this.menuVisible && this.$refs.menuForm) {
this.$refs.userForm.$children[0].resetFields() this.$refs.menuForm.$children[0].resetFields()
} }
this.userVisible = !this.userVisible this.menuVisible = !this.menuVisible
}, },
// 按钮事件 // 按钮事件
btnClick(pType, scope) { btnClick(pType, scope) {
...@@ -323,7 +348,13 @@ export default { ...@@ -323,7 +348,13 @@ export default {
}, },
// 编辑触发事件 // 编辑触发事件
editEvent(row) { editEvent(row) {
this.handleClose() console.log(row)
menuInfo({ id: row.id }).then(res => {
this.menuDialogTitle = '编辑菜单'
this.menuForm = JSON.parse(JSON.stringify(res.data))
this.menuForm.enableStatus = res.data.enableStatus == 1 ? true : false
this.handleClose(res.data)
})
}, },
// 删除触发事件 // 删除触发事件
deleteEvent(id) { deleteEvent(id) {
...@@ -334,52 +365,64 @@ export default { ...@@ -334,52 +365,64 @@ export default {
tipTitle: '提示', tipTitle: '提示',
type: 'error', type: 'error',
callBack: () => { callBack: () => {
deleteMenu({ id: id }).then(res => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
}) })
})
} }
} }
this.$Common.confirmDialog(tipData) this.$Common.confirmDialog(tipData)
}, },
// 部门弹窗 load(tree, treeNode, resolve) {
selectDepart() { setTimeout(() => {
this.filterDialogTitle = '选择组织' resolve([
this.closeFilter() {
id: 31,
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄'
}, {
id: 32,
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄'
}
])
}, 1000)
}, },
// 上级弹窗 // 上级弹窗
selectSuperior() { selectSuperior() {
this.filterDialogTitle = '选择直接上级'
this.closeFilter() this.closeFilter()
}, },
closeFilter() { closeFilter() {
this.filterVisible = !this.filterVisible this.filterVisible = !this.filterVisible
}, },
filterConfirm() { filterConfirm() {
console.log(this.$refs.tree.getCheckedKeys(false, true)) console.log(this.$refs.tree.getCurrentNode())
// this.closeFilter() this.menuForm.parentId = this.$refs.tree.getCurrentNode().id
this.menuForm.parentName = this.$refs.tree.getCurrentNode().label
this.closeFilter()
}, },
filterNode(value, data) { filterNode(value, data) {
console.log(value, data) console.log(value, data)
if (!value) return true if (!value) return true
return data.label.indexOf(value) !== -1 return data.label.indexOf(value) !== -1
}, },
// 表格方法
rowClick(row, e, col) {
console.log(row, e, col, 'row cliock data')
orginizaService.getChildren(row.id).then(res => {
console.log(res)
row.children = res.data.list
})
},
// 业务
tableClick(that, index, row, data) {
console.log(that, index, row, data, 'tableClick')
},
getList() { getList() {
orginizaService.getTableList().then((res) => { getMenuList().then((res) => {
console.log(res); console.log(res);
this.listData = res.data.list let arr = res.data.list
// for (let i in arr) {
// console.log(i)
// if (arr[i].haschildren) {
// console.log('Jinlaile ')
// arr[i].children = []
// }
// }
this.menuTableData = arr
console.log(this.menuTableData)
}, (err) => { }, (err) => {
}); });
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</div> </div>
<basic-table <basic-table
:tableParams="tableParams" :tableParams="tableParams"
:apiParame="apiParame" :getListApi="getListApi"
:searchForm="searchForm" :searchForm="searchForm"
:hasNum="false" :hasNum="false"
> >
...@@ -63,10 +63,32 @@ ...@@ -63,10 +63,32 @@
:labelWidth="'120px'" :labelWidth="'120px'"
ref='roleForm' ref='roleForm'
> >
<slot <div slot="visible-type">
name="form-slot" <el-radio-group
slot-scope="scope" @change="radioChange($event)"
v-model="roleForm.visibleType"
>
<el-radio
v-for="(child,childIndex) in $Constants.ROLE_VISIBLE"
:key="childIndex"
:label="childIndex"
>{{child}}</el-radio>
</el-radio-group>
<el-select
v-if="roleForm.visibleType == '2'"
v-model="roleForm.visibleTenant"
placeholder="请选择"
>
<el-option
v-for="i in tenantList"
:key="i.tenantId"
:label="i.departmentName"
:value="i.tenantId"
> >
</el-option>
</el-select>
</div>
<div slot="menu-list">
<el-tree <el-tree
:data="data" :data="data"
show-checkbox show-checkbox
...@@ -74,9 +96,11 @@ ...@@ -74,9 +96,11 @@
node-key="id" node-key="id"
ref="tree" ref="tree"
highlight-current highlight-current
@getCheckedKeys="getCheckedKeys"
@setCheckedNodes="setCheckedNodes"
> >
</el-tree> </el-tree>
</slot> </div>
</rule-form> </rule-form>
</slot> </slot>
</basic-dialog> </basic-dialog>
...@@ -85,13 +109,17 @@ ...@@ -85,13 +109,17 @@
</template> </template>
<script> <script>
import { import { getRoleList, roleInfo, getTenantList, addRole, editRole, deleteRole } from 'services/role';
ROLE_API
} from '@/config/config'
import RoleService from 'services/role';
export default { export default {
data() { data() {
var checkMenu = (rule, value, callBack) => {
if (value && value.length == 0) {
return callBack(new Error('请选择菜单列表'))
} else {
return callBack()
}
}
return { return {
searchForm: {}, searchForm: {},
roleFormList: [ roleFormList: [
...@@ -140,31 +168,30 @@ export default { ...@@ -140,31 +168,30 @@ export default {
] ]
} }
}, },
apiParame: ROLE_API.ROLE_SEARCH, getListApi: getRoleList,
// 弹窗数据 // 弹窗数据
roleDialogTitle: '新增角色', roleDialogTitle: '新增角色',
roleVisible: false, roleVisible: false,
roleForm: { roleForm: {
account: '胡悦', enableStatus: true,
departmentId: '', menuIdList: []
superiorId: '',
enableStatus: true
}, },
roleData: [ roleData: [
{ label: '角色名称:', prop: 'roleName', type: 'input' }, { label: '角色名称:', prop: 'roleName', type: 'input' },
{ label: '备注:', prop: 'remark', type: 'input' }, { label: '备注:', prop: 'remark', type: 'input' },
{ label: '状态:', prop: 'enableStatus', type: 'switch' }, { label: '状态:', prop: 'enableStatus', type: 'switch' },
{ label: '租户可见度:', prop: 'visibleType', type: 'radio', hasSelect: true, children: this.$Constants.ROLE_VISIBLE }, { label: '租户可见度:', prop: 'visibleType', type: 'customize', slotName: 'visible-type' },
// { label: '租户可见度:', prop: 'visibleType', type: 'radio', hasSelect: true, children: this.$Constants.ROLE_VISIBLE },
{ label: '数据权限:', prop: 'permissionType', type: 'radio', children: this.$Constants.ROLE_AUTH }, { label: '数据权限:', prop: 'permissionType', type: 'radio', children: this.$Constants.ROLE_AUTH },
// [{ id: 1, label: '本人' }, { id: 2, label: '本人及下属' }, { id: 3, label: '本部门' }, { id: 4, label: '本部门&下属' }, { id: 5, label: '全部' }] // [{ id: 1, label: '本人' }, { id: 2, label: '本人及下属' }, { id: 3, label: '本部门' }, { id: 4, label: '本部门&下属' }, { id: 5, label: '全部' }]
{ label: '菜单权限:', prop: 'menuIdList', type: 'customize' } { label: '菜单权限:', prop: 'menuIdList', type: 'customize', slotName: 'menu-list' }
], ],
roleRules: { roleRules: {
roleName: [{ required: true, message: '请输入角色名称', trigger: blur }], roleName: [{ required: true, message: '请输入角色名称', trigger: 'blur' }],
enableStatus: [{ required: true }], enableStatus: [{ required: true }],
visibleType: [{ required: true, message: '请选择租户可见度' }], visibleType: [{ required: true, message: '请选择租户可见度' }],
permissionType: [{ required: true, message: '请选择数据权限' }], permissionType: [{ required: true, message: '请选择数据权限' }],
menuIdList: [{ required: true, message: '请选择菜单列表' }] menuIdList: [{ required: true, validator: checkMenu, trigger: 'blur' }]
}, },
data: [{ data: [{
id: 1, id: 1,
...@@ -200,9 +227,13 @@ export default { ...@@ -200,9 +227,13 @@ export default {
id: 8, id: 8,
label: '二级 3-2' label: '二级 3-2'
}] }]
}] }],
tenantList: []
} }
}, },
mounted() {
this.getTenantList()
},
methods: { methods: {
// 重置搜索条件 // 重置搜索条件
refresh() { refresh() {
...@@ -210,10 +241,17 @@ export default { ...@@ -210,10 +241,17 @@ export default {
}, },
// 确定 // 确定
handleConfirm() { handleConfirm() {
console.log(this.$refs.roleForm) this.getCheckedKeys()
console.log(this.roleForm)
this.$refs.roleForm.$children[0].validate((valid) => { this.$refs.roleForm.$children[0].validate((valid) => {
if (valid) { if (valid) {
let params = JSON.parse(JSON.stringify(this.roleForm))
params.enableStatus = this.roleForm.enableStatus ? 1 : 2
let api = addRole
if (params.id) api = editRole
api(params).then(res => {
this.handleClose() this.handleClose()
})
} else { } else {
console.log('error') console.log('error')
} }
...@@ -232,6 +270,11 @@ export default { ...@@ -232,6 +270,11 @@ export default {
switch (pType) { switch (pType) {
case 'create': case 'create':
this.roleDialogTitle = '新增角色' this.roleDialogTitle = '新增角色'
this.roleForm = {
enableStatus: true,
menuIdList: []
}
this.setCheckedNodes()
this.handleClose() this.handleClose()
break break
case 'edit': case 'edit':
...@@ -245,7 +288,12 @@ export default { ...@@ -245,7 +288,12 @@ export default {
}, },
// 编辑触发事件 // 编辑触发事件
editEvent(row) { editEvent(row) {
this.handleClose() roleInfo({ id: row.id }).then(res => {
this.roleForm = JSON.parse(JSON.stringify(res.data))
this.roleForm.enableStatus = res.data.enableStatus == 1 ? true : false
this.handleClose(res.data)
})
}, },
// 删除触发事件 // 删除触发事件
deleteEvent(id) { deleteEvent(id) {
...@@ -256,13 +304,32 @@ export default { ...@@ -256,13 +304,32 @@ export default {
tipTitle: '提示', tipTitle: '提示',
type: 'error', type: 'error',
callBack: () => { callBack: () => {
deleteRole({ id: id }).then(res => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
}) })
})
} }
} }
this.$Common.confirmDialog(tipData) this.$Common.confirmDialog(tipData)
},
// 获取选中菜单数组
getCheckedKeys() {
this.roleForm.menuIdList = this.$refs.tree.getCheckedKeys()
console.log(this.$refs.tree.getCheckedKeys())
},
setCheckedNodes() {
this.$refs.tree.setCheckedNodes([])
},
// 获取租户列表
getTenantList() {
getTenantList().then(res => {
this.tenantList = res.data
})
},
radioChange(e) {
console.log(e)
} }
} }
} }
......
...@@ -56,7 +56,8 @@ ...@@ -56,7 +56,8 @@
<span <span
class="dot" class="dot"
:class="scope.scope.enableStatus ? USERSTATUS[scope.scope.enableStatus].split(',')[1] : ''" :class="scope.scope.enableStatus ? USERSTATUS[scope.scope.enableStatus].split(',')[1] : ''"
></span><span class="statusText">{{ scope.scope.enableStatus ? USERSTATUS[scope.scope.enableStatus].split(',')[0] : '--'}}</span> ></span>
<span class="statusText">{{ scope.scope.enableStatus ? USERSTATUS[scope.scope.enableStatus].split(',')[0] : '--'}}</span>
</span> </span>
<span <span
slot="table-button" slot="table-button"
...@@ -119,7 +120,7 @@ ...@@ -119,7 +120,7 @@
<script> <script>
// import UserService from 'services/user'; // import UserService from 'services/user';
import { getUserList, getSuperUser, addUser } from 'services/user'; import { getUserList, getSuperUser, addUser, editUser, detailUser, deleteUser, roleList } from 'services/user';
import OrginizaService from 'services/orginizaManage'; import OrginizaService from 'services/orginizaManage';
const orginizaService = new OrginizaService(); const orginizaService = new OrginizaService();
export default { export default {
...@@ -207,18 +208,19 @@ export default { ...@@ -207,18 +208,19 @@ export default {
superiorName: '', superiorName: '',
enableStatus: true enableStatus: true
}, },
roleList: [],
userData: [ userData: [
{ label: '登录名称:', prop: 'account', type: 'input' }, { label: '登录名称:', prop: 'account', type: 'input' },
{ label: '部门名称:', prop: 'departmentName', type: 'input', readonly: true, clickFunc: this.selectDepart }, { label: '部门名称:', prop: 'departmentName', type: 'input', readonly: true, clickFunc: this.selectDepart },
{ label: '直接上级:', prop: 'superiorName', type: 'input', readonly: true, clickFunc: this.selectSuperior }, { label: '直接上级:', prop: 'superiorName', type: 'input', readonly: true, clickFunc: this.selectSuperior },
{ label: '用户名称:', prop: 'username', type: 'input' }, { label: '用户名称:', prop: 'username', type: 'input' },
{ label: '密码:', prop: 'password', type: 'input', inputText: 'password' }, { label: '密码:', prop: 'password', type: 'input', inputText: 'password' },
{ label: '角色:', prop: 'roleId', type: 'select', options: [] }, { label: '角色:', prop: 'roleId', type: 'select', options: [], key: 'roleName', value: 'roleId', filterable: true },
{ label: '邮箱:', prop: 'email', type: 'input' }, { label: '邮箱:', prop: 'email', type: 'input' },
{ label: '手机:', prop: 'phoneNumber', type: 'input' }, { label: '手机:', prop: 'phoneNumber', type: 'input' },
{ label: '性别:', prop: 'gender', type: 'select', options: [] }, { label: '性别:', prop: 'gender', type: 'select', options: [{ label: '男', value: 0 }, { label: '女', value: 1 }] },
{ label: '状态:', prop: 'enableStatus', type: 'switch' }, { label: '状态:', prop: 'enableStatus', type: 'switch' },
{ label: '岗位:', prop: 'position', type: 'select', options: [] } { label: '岗位:', prop: 'position', type: 'select', options: [{ label: '12121', value: 0 }, { label: 'fasdfas', value: 1 }] }
], ],
userRules: { userRules: {
account: [{ required: true, message: '请输入登录名称', trigger: blur }], account: [{ required: true, message: '请输入登录名称', trigger: blur }],
...@@ -305,6 +307,7 @@ export default { ...@@ -305,6 +307,7 @@ export default {
}, },
mounted() { mounted() {
this.getTreeOrg() this.getTreeOrg()
this.getRoleList()
}, },
methods: { methods: {
// 重置搜索条件 // 重置搜索条件
...@@ -313,10 +316,16 @@ export default { ...@@ -313,10 +316,16 @@ export default {
}, },
// 确定,新增用户、编辑用户 // 确定,新增用户、编辑用户
handleConfirm() { handleConfirm() {
console.log(this.$refs.userForm) console.log(this.userForm)
this.$refs.userForm.$children[0].validate((valid) => { this.$refs.userForm.$children[0].validate((valid) => {
if (valid) { if (valid) {
let params = JSON.parse(JSON.stringify(this.userForm))
params.enableStatus = this.userForm.enableStatus ? 1 : 2
let api = addUser
if (params.id) api = editUser
api(params).then(res => {
this.handleClose() this.handleClose()
})
} else { } else {
console.log('error') console.log('error')
} }
...@@ -328,6 +337,7 @@ export default { ...@@ -328,6 +337,7 @@ export default {
this.$refs.userForm.$children[0].resetFields() this.$refs.userForm.$children[0].resetFields()
} }
this.userVisible = !this.userVisible this.userVisible = !this.userVisible
console.log(this.userForm)
}, },
// 组织架构节点 // 组织架构节点
handleNodeClick(data) { handleNodeClick(data) {
...@@ -347,6 +357,11 @@ export default { ...@@ -347,6 +357,11 @@ export default {
switch (pType) { switch (pType) {
case 'create': case 'create':
this.userDialogTitle = '新增用户' this.userDialogTitle = '新增用户'
this.userForm = {
departmentName: '',
superiorName: '',
enableStatus: true
}
this.handleClose() this.handleClose()
break break
case 'edit': case 'edit':
...@@ -361,9 +376,13 @@ export default { ...@@ -361,9 +376,13 @@ export default {
// 编辑触发事件 // 编辑触发事件
editEvent(row) { editEvent(row) {
console.log(row) console.log(row)
detailUser({ id: row.id }).then(res => {
this.userDialogTitle = '编辑用户' this.userDialogTitle = '编辑用户'
this.userForm = row this.userForm = JSON.parse(JSON.stringify(res.data))
this.handleClose(row) this.userForm.enableStatus = res.data.enableStatus == 1 ? true : false
this.handleClose(res.data)
})
}, },
// 删除触发事件 // 删除触发事件
deleteEvent(id) { deleteEvent(id) {
...@@ -374,10 +393,12 @@ export default { ...@@ -374,10 +393,12 @@ export default {
tipTitle: '提示', tipTitle: '提示',
type: 'error', type: 'error',
callBack: () => { callBack: () => {
deleteUser({ id: id }).then(res => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
}) })
})
} }
} }
this.$Common.confirmDialog(tipData) this.$Common.confirmDialog(tipData)
...@@ -435,6 +456,14 @@ export default { ...@@ -435,6 +456,14 @@ export default {
console.log(res) console.log(res)
this.data = res.data.list this.data = res.data.list
}) })
},
// 角色下拉列表
getRoleList() {
roleList().then(res => {
this.roleList = res.data
this.userData[5].options = res.data
console.log(this.roleList)
})
} }
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!