Commit a8f6e802 by 胡悦

用户、角色部分接口提交

1 parent f70ef5b0
......@@ -296,12 +296,10 @@ export default {
// 页码
handleSizeChange(value) {
this.page.pageSize = value
console.log('handleSizeChange', value)
this.getListApi ? this.refreshTable(false) : this.$emit('refreshTable', this.page)
},
handleCurrentChange(value) {
console.log('handleCurrentChange', value)
this.page.pageNumber = value
this.getListApi ? this.refreshTable(false) : this.$emit('refreshTable', this.page)
......
......@@ -32,7 +32,8 @@ const ROLE_API = {
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'
ROLE_DELETE: BASE_URL + '/usercenter/role/delete',
MENU_TREE: BASE_URL + '/usercenter/menu/checkedtree'
}
const MENU_API = {
MENU_SEARCH: BASE_URL + '/usercenter/menu/search',
......@@ -45,7 +46,7 @@ const MENU_API = {
const ORGINIZA_API = {
ORGINIZA_SEARCH: BASE_URL + '/usercenter/organization/rootList',
ORGINIZA_CHILDREN: BASE_URL + '/usercenter/organization/children',
ORGINIZA_SIMPLElIST: BASE_URL + '/usercenter/organization/simpleList',
ORGINIZA_SIMPLElIST: BASE_URL + '/usercenter/organization/simplelist',
ORGINIZA_TREEORY: BASE_URL + '/usercenter/organization/orgtree',
ORGINIZA_ADD: BASE_URL + '/usercenter/organization/add',
ORGINIZA_EDIT: BASE_URL + '/usercenter/organization/edit',
......
......@@ -36,4 +36,10 @@ function deleteRole (params) {
return request(params, url)
}
export { getRoleList, roleInfo, getTenantList, addRole, editRole, deleteRole }
// 获取菜单权限
function getMenuTree (params) {
const url = ROLE_API.MENU_TREE
return request(params, url)
}
export { getRoleList, roleInfo, getTenantList, addRole, editRole, deleteRole, getMenuTree }
......@@ -30,6 +30,7 @@
>新增</el-button>
</div>
<basic-table
ref="roleTable"
:tableParams="tableParams"
:getListApi="getListApi"
:searchForm="searchForm"
......@@ -65,14 +66,14 @@
>
<div slot="visible-type">
<el-radio-group
@change="radioChange($event)"
@change="radioChange(roleForm.visibleType)"
v-model="roleForm.visibleType"
>
<el-radio
v-for="(child,childIndex) in $Constants.ROLE_VISIBLE"
:key="childIndex"
:label="childIndex"
>{{child}}</el-radio>
>{{child}}{{childIndex}}</el-radio>
</el-radio-group>
<el-select
v-if="roleForm.visibleType == '2'"
......@@ -90,7 +91,7 @@
</div>
<div slot="menu-list">
<el-tree
:data="data"
:data="treedata"
show-checkbox
default-expand-all
node-key="id"
......@@ -109,7 +110,7 @@
</template>
<script>
import { getRoleList, roleInfo, getTenantList, addRole, editRole, deleteRole } from 'services/role';
import { getRoleList, roleInfo, getTenantList, addRole, editRole, deleteRole, getMenuTree } from 'services/role';
export default {
data() {
......@@ -152,11 +153,6 @@ export default {
btnList: [
{
type: 'primary',
name: '新增',
pType: 'create'
},
{
type: 'primary',
name: '编辑',
pType: 'edit'
},
......@@ -193,46 +189,12 @@ export default {
permissionType: [{ required: true, message: '请选择数据权限' }],
menuIdList: [{ required: true, validator: checkMenu, trigger: 'blur' }]
},
data: [{
id: 1,
label: '一级 1',
children: [{
id: 4,
label: '二级 1-1',
children: [{
id: 9,
label: '三级 1-1-1'
}, {
id: 10,
label: '三级 1-1-2'
}]
}]
}, {
id: 2,
label: '一级 2',
children: [{
id: 5,
label: '二级 2-1'
}, {
id: 6,
label: '二级 2-2'
}]
}, {
id: 3,
label: '一级 3',
children: [{
id: 7,
label: '二级 3-1'
}, {
id: 8,
label: '二级 3-2'
}]
}],
treedata: [],
tenantList: []
}
},
mounted() {
this.getTenantList()
this.getMenuTree()
},
methods: {
// 重置搜索条件
......@@ -274,7 +236,7 @@ export default {
enableStatus: true,
menuIdList: []
}
this.setCheckedNodes()
this.getTenantList()
this.handleClose()
break
case 'edit':
......@@ -291,7 +253,7 @@ export default {
roleInfo({ id: row.id }).then(res => {
this.roleForm = JSON.parse(JSON.stringify(res.data))
this.roleForm.enableStatus = res.data.enableStatus == 1 ? true : false
this.getMenuTree({ roleId: row.id })
this.handleClose(res.data)
})
},
......@@ -305,15 +267,28 @@ export default {
type: 'error',
callBack: () => {
deleteRole({ id: id }).then(res => {
this.$message({
type: 'success',
message: '删除成功!'
})
if (res.code == '200') {
this.$message({
type: 'success',
message: '删除成功!'
})
this.$refs.roleTable.refreshTable()
} else {
this.$message(res.message)
}
})
}
}
this.$Common.confirmDialog(tipData)
},
// 获取菜单权限列表
getMenuTree(params) {
getMenuTree(params).then(res => {
console.log(res)
this.treedata = res.data
})
},
// 获取选中菜单数组
getCheckedKeys() {
this.roleForm.menuIdList = this.$refs.tree.getCheckedKeys()
......@@ -329,7 +304,8 @@ export default {
})
},
radioChange(e) {
console.log(e)
console.log(e, this.roleForm)
this.$set(this.roleForm, 'visibleType', e)
}
}
}
......
......@@ -4,7 +4,12 @@
<div class="user-tree-top">
<span>组织架构</span>
</div>
<el-input size="mini"></el-input>
<el-input
size="mini"
placeholder="按回车搜索"
v-model="orgName"
@input="treeInput"
></el-input>
<el-tree
:data="treedata"
accordion
......@@ -44,6 +49,7 @@
>新增</el-button>
</div>
<basic-table
ref="userTable"
:tableParams="tableParams"
:searchForm="searchForm"
:getListApi="getListApi"
......@@ -126,6 +132,7 @@ export default {
data() {
return {
USERSTATUS: this.$Constants.USER_STATUS,
orgName: '',
searchForm: {},
userFormList: [
{
......@@ -138,13 +145,14 @@ export default {
type: 'select',
prop: 'userStatus',
placeholder: '请选择用户状态',
options: [{
value: '0',
label: '正常'
}, {
value: '1',
label: '停用'
}]
options:
[{
value: '1',
label: '正常'
}, {
value: '2',
label: '停用'
}]
}
],
tableParams: {
......@@ -158,15 +166,16 @@ export default {
prop: 'id'
}, {
label: '登录名称',
prop: 'account'
prop: 'account',
width: 120
}, {
label: '用户名称',
prop: 'username',
width: 120
width: 100
}, {
label: '部门',
prop: 'departmentName',
width: 200
width: 100
}, {
label: '手机号',
prop: 'phoneNumber',
......@@ -177,7 +186,8 @@ export default {
addHtml: 'status'
}, {
label: '创建时间',
prop: 'createDate'
prop: 'createdDate',
width: 150
}
],
tableOption: {
......@@ -296,7 +306,7 @@ export default {
}
]
}
]
],
}
},
watch: {
......@@ -320,10 +330,20 @@ export default {
if (valid) {
let params = JSON.parse(JSON.stringify(this.userForm))
params.enableStatus = this.userForm.enableStatus ? 1 : 2
delete params.departmentName
delete params.superiorName
let api = addUser
if (params.id) api = editUser
api(params).then(res => {
this.handleClose()
if (res.code = '200') {
this.$refs.userTable.refreshTable()
this.handleClose()
this.$message({
type: 'success',
message: '操作成功!'
})
}
})
} else {
console.log('error')
......@@ -340,7 +360,8 @@ export default {
},
// 组织架构节点
handleNodeClick(data) {
console.log(data)
this.searchForm.departmentId = data.id
this.$refs.userTable.refreshTable()
},
// 树节点内容区的渲染
renderContent(h, { node, data, store }) {
......@@ -393,10 +414,15 @@ export default {
type: 'error',
callBack: () => {
deleteUser({ id: id }).then(res => {
this.$message({
type: 'success',
message: '删除成功!'
})
if (res.code == '200') {
this.$message({
type: 'success',
message: '删除成功!'
})
this.$refs.userTable.refreshTable()
} else {
this.$message(res.message)
}
})
}
}
......@@ -404,14 +430,16 @@ export default {
},
// 部门弹窗
selectDepart() {
this.filterText = ''
this.filterDialogTitle = '选择组织'
this.getSimpleList()
this.closeFilter()
},
// 上级弹窗
selectSuperior() {
this.filterText = ''
this.filterDialogTitle = '选择直接上级'
this.getSuperUser()
this.getSuperUser({ departmentId: this.userForm.departmentId })
this.closeFilter()
},
......@@ -439,20 +467,21 @@ export default {
getSuperUser(params) {
getSuperUser(params).then(res => {
console.log(res)
this.filterTextData = res.data.list
this.filterTextData = res.data
})
},
// 获取组织树
getSimpleList() {
getSimpleList().then(res => {
getTreeOrg().then(res => {
console.log(res)
this.filterTextData = res.data.list
this.filterTextData = res.data
})
},
// 获取组织架构
getTreeOrg() {
getTreeOrg().then(res => {
getTreeOrg(params) {
getTreeOrg(params).then(res => {
console.log(res)
// this.searchForm.departmentId = res.data.id
this.treedata = res.data
})
},
......@@ -463,6 +492,14 @@ export default {
this.userData[5].options = res.data
console.log(this.roleList)
})
},
// 组织架构搜索
treeInput(value) {
const params = {
orgName: value
}
this.getTreeOrg(params)
// this.$refs.userTable.refreshTable()
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!