|
@@ -7,9 +7,33 @@
|
|
<el-form-item label="角色名称" prop="roleName">
|
|
<el-form-item label="角色名称" prop="roleName">
|
|
<el-input v-model="dataForm.roleName" placeholder="角色名称"></el-input>
|
|
<el-input v-model="dataForm.roleName" placeholder="角色名称"></el-input>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
+ <el-form-item label="通用角色" size="mini" prop="isCommon">
|
|
|
|
+ <el-radio-group v-model="dataForm.isCommon">
|
|
|
|
+ <el-radio :label="false">否</el-radio>
|
|
|
|
+ <el-radio :label="true">是</el-radio>
|
|
|
|
+ </el-radio-group>
|
|
|
|
+ </el-form-item>
|
|
<el-form-item label="备注" prop="remark">
|
|
<el-form-item label="备注" prop="remark">
|
|
<el-input v-model="dataForm.remark" placeholder="备注"></el-input>
|
|
<el-input v-model="dataForm.remark" placeholder="备注"></el-input>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
+ <el-form-item label="所属机构" prop="orgId">
|
|
|
|
+ <el-popover
|
|
|
|
+ ref="menuListPopover"
|
|
|
|
+ placement="bottom-start"
|
|
|
|
+ trigger="click">
|
|
|
|
+ <el-tree
|
|
|
|
+ :data="orgList"
|
|
|
|
+ :props="orgListTreeProps"
|
|
|
|
+ node-key="menuId"
|
|
|
|
+ ref="menuListTree"
|
|
|
|
+ @current-change="menuListTreeCurrentChangeHandle"
|
|
|
|
+ :default-expand-all="true"
|
|
|
|
+ :highlight-current="true"
|
|
|
|
+ :expand-on-click-node="false">
|
|
|
|
+ </el-tree>
|
|
|
|
+ </el-popover>
|
|
|
|
+ <el-input v-model="dataForm.orgName" v-popover:menuListPopover :readonly="true" placeholder="点击选择所属机构" class="menu-list__input"></el-input>
|
|
|
|
+ </el-form-item>
|
|
<el-form-item size="mini" label="授权">
|
|
<el-form-item size="mini" label="授权">
|
|
<el-tree
|
|
<el-tree
|
|
:data="menuList"
|
|
:data="menuList"
|
|
@@ -29,24 +53,34 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
- import { treeDataTranslate } from '@/utils'
|
|
|
|
export default {
|
|
export default {
|
|
data () {
|
|
data () {
|
|
return {
|
|
return {
|
|
visible: false,
|
|
visible: false,
|
|
menuList: [],
|
|
menuList: [],
|
|
|
|
+ orgList: [],
|
|
menuListTreeProps: {
|
|
menuListTreeProps: {
|
|
|
|
+ label: 'name',
|
|
|
|
+ children: 'list'
|
|
|
|
+ },
|
|
|
|
+ orgListTreeProps: {
|
|
label: 'name',
|
|
label: 'name',
|
|
children: 'children'
|
|
children: 'children'
|
|
},
|
|
},
|
|
dataForm: {
|
|
dataForm: {
|
|
id: 0,
|
|
id: 0,
|
|
roleName: '',
|
|
roleName: '',
|
|
- remark: ''
|
|
|
|
|
|
+ remark: '',
|
|
|
|
+ isCommon: false,
|
|
|
|
+ orgId: '',
|
|
|
|
+ orgName: ''
|
|
},
|
|
},
|
|
dataRule: {
|
|
dataRule: {
|
|
roleName: [
|
|
roleName: [
|
|
{ required: true, message: '角色名称不能为空', trigger: 'blur' }
|
|
{ required: true, message: '角色名称不能为空', trigger: 'blur' }
|
|
|
|
+ ],
|
|
|
|
+ orgId: [
|
|
|
|
+ { required: true, message: '所属机构不能为空', trigger: 'change' }
|
|
]
|
|
]
|
|
},
|
|
},
|
|
tempKey: -666666 // 临时key, 用于解决tree半选中状态项不能传给后台接口问题. # 待优化
|
|
tempKey: -666666 // 临时key, 用于解决tree半选中状态项不能传给后台接口问题. # 待优化
|
|
@@ -56,11 +90,23 @@
|
|
init (id) {
|
|
init (id) {
|
|
this.dataForm.id = id || 0
|
|
this.dataForm.id = id || 0
|
|
this.$http({
|
|
this.$http({
|
|
- url: this.$http.adornUrl('/sys/menu/list'),
|
|
|
|
|
|
+ url: this.$http.adornUrl('/user-service/menu/tree'),
|
|
method: 'get',
|
|
method: 'get',
|
|
params: this.$http.adornParams()
|
|
params: this.$http.adornParams()
|
|
}).then(({data}) => {
|
|
}).then(({data}) => {
|
|
- this.menuList = treeDataTranslate(data, 'menuId')
|
|
|
|
|
|
+ if (data.code === '200') {
|
|
|
|
+ this.menuList = data.data
|
|
|
|
+ }
|
|
|
|
+ }).then(() => {
|
|
|
|
+ this.$http({
|
|
|
|
+ url: this.$http.adornUrl('/user-service/org/queryTree'),
|
|
|
|
+ method: 'get',
|
|
|
|
+ params: this.$http.adornParams()
|
|
|
|
+ }).then(({data}) => {
|
|
|
|
+ if (data.code === '200') {
|
|
|
|
+ this.orgList = data.data
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}).then(() => {
|
|
}).then(() => {
|
|
this.visible = true
|
|
this.visible = true
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
@@ -70,38 +116,46 @@
|
|
}).then(() => {
|
|
}).then(() => {
|
|
if (this.dataForm.id) {
|
|
if (this.dataForm.id) {
|
|
this.$http({
|
|
this.$http({
|
|
- url: this.$http.adornUrl(`/sys/role/info/${this.dataForm.id}`),
|
|
|
|
|
|
+ url: this.$http.adornUrl(`/user-service/role/info/${this.dataForm.id}`),
|
|
method: 'get',
|
|
method: 'get',
|
|
params: this.$http.adornParams()
|
|
params: this.$http.adornParams()
|
|
}).then(({data}) => {
|
|
}).then(({data}) => {
|
|
- if (data && data.code === 0) {
|
|
|
|
- this.dataForm.roleName = data.role.roleName
|
|
|
|
- this.dataForm.remark = data.role.remark
|
|
|
|
- var idx = data.role.menuIdList.indexOf(this.tempKey)
|
|
|
|
|
|
+ if (data && data.code === '200') {
|
|
|
|
+ this.dataForm.roleName = data.data.roleName
|
|
|
|
+ this.dataForm.remark = data.data.remark
|
|
|
|
+ this.dataForm.isCommon = data.data.isCommon
|
|
|
|
+ this.dataForm.orgId = data.data.orgId
|
|
|
|
+ var idx = data.data.menuIdList.indexOf(this.tempKey)
|
|
if (idx !== -1) {
|
|
if (idx !== -1) {
|
|
- data.role.menuIdList.splice(idx, data.role.menuIdList.length - idx)
|
|
|
|
|
|
+ data.data.menuIdList.splice(idx, data.data.menuIdList.length - idx)
|
|
}
|
|
}
|
|
- this.$refs.menuListTree.setCheckedKeys(data.role.menuIdList)
|
|
|
|
|
|
+ this.$refs.menuListTree.setCheckedKeys(data.data.menuIdList)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ menuListTreeCurrentChangeHandle (data, node) {
|
|
|
|
+ this.dataForm.orgId = data.orgId
|
|
|
|
+ this.dataForm.orgName = data.name
|
|
|
|
+ },
|
|
// 表单提交
|
|
// 表单提交
|
|
dataFormSubmit () {
|
|
dataFormSubmit () {
|
|
this.$refs['dataForm'].validate((valid) => {
|
|
this.$refs['dataForm'].validate((valid) => {
|
|
if (valid) {
|
|
if (valid) {
|
|
this.$http({
|
|
this.$http({
|
|
- url: this.$http.adornUrl(`/sys/role/${!this.dataForm.id ? 'save' : 'update'}`),
|
|
|
|
|
|
+ url: this.$http.adornUrl(`/user-service/role/${!this.dataForm.id ? 'save' : 'update'}`),
|
|
method: 'post',
|
|
method: 'post',
|
|
data: this.$http.adornData({
|
|
data: this.$http.adornData({
|
|
'roleId': this.dataForm.id || undefined,
|
|
'roleId': this.dataForm.id || undefined,
|
|
'roleName': this.dataForm.roleName,
|
|
'roleName': this.dataForm.roleName,
|
|
'remark': this.dataForm.remark,
|
|
'remark': this.dataForm.remark,
|
|
|
|
+ 'isCommon': this.dataForm.isCommon,
|
|
|
|
+ 'orgId': this.dataForm.orgId,
|
|
'menuIdList': [].concat(this.$refs.menuListTree.getCheckedKeys(), [this.tempKey], this.$refs.menuListTree.getHalfCheckedKeys())
|
|
'menuIdList': [].concat(this.$refs.menuListTree.getCheckedKeys(), [this.tempKey], this.$refs.menuListTree.getHalfCheckedKeys())
|
|
})
|
|
})
|
|
}).then(({data}) => {
|
|
}).then(({data}) => {
|
|
- if (data && data.code === 0) {
|
|
|
|
|
|
+ if (data && data.code === '200') {
|
|
this.$message({
|
|
this.$message({
|
|
message: '操作成功',
|
|
message: '操作成功',
|
|
type: 'success',
|
|
type: 'success',
|
|
@@ -112,7 +166,7 @@
|
|
}
|
|
}
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
- this.$message.error(data.msg)
|
|
|
|
|
|
+ this.$message.error(data.msg || '系统错误,请联系管理员')
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|