| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <template>
- <el-select v-model="selectValue" multiple placeholder="请选择">
- <el-option
- v-for="item in options"
- :key="item.id"
- :label="item.privName"
- :value="item.id"
- v-if="name == '角色管理'">
- </el-option>
- <el-option
- v-for="item in options"
- :key="item.guid"
- :label="item.roleName"
- :value="item.guid"
- v-if="name == '用户管理'">
- </el-option>
- <el-option
- v-for="(item,index) in options"
- :key="index"
- :label="item.dictTypeDesc"
- :value="item.id"
- v-if="name == '字典管理'">
- </el-option>
- </el-select>
- </template>
- <script>
- import request from '../utils/gw_ajax_request.js'
- export default {
- props: ['id'], //接收组件传过来的树形数据和根id
- name: 'select_multiple',
- data () {
- return {
- options: [],
- selectValue: [],
- name: this.$route.name
- }
- },
- mounted:function(){
- this.$route.name == '用户管理' ? this.getRoleList() : this.$route.name == '角色管理' ? this.getPrivList() : this.getDictType()
- },
- methods:{
- getPrivList(){
- request.get('sys/privs/findList').then((res)=>{
- if(res.data){
- this.options = res.data
- }
- })
- if(this.id){
- this.getCurrencyPriv()
- }
-
- },
- getRoleList(){
- request.get('dc/role/findList').then((res)=>{
- if(res.data){
- this.options = res.data
- }
- })
- console.log(this.id)
- if(this.id){
- this.getCurrencyRole()
- }
- },
- //当前用户或角色有哪些角色或权限
- getCurrencyPriv(){
- request.get(`sys/privs/tree-by-role/${this.id}`).then((res)=>{
- if(res.data){
- res.data.forEach(ele => {
- if(ele.checked){
- this.selectValue.push(ele.id)
- }
- });
- }
- })
- },
- getCurrencyRole(){
- request.get(`dc/role/list-by-user/${this.id}`).then((res)=>{
- if(res.data){
- res.data.forEach(ele => {
- if(ele.currentUser){
- this.selectValue.push(ele.guid)
- }
- });
- }
- })
- },
- //获取字典类型
- getDictType(){
- request.get('common/dict-types/list',{}).then((res)=>{
- if(res.data){
- this.options = res.data.data
- console.log(this.options)
- }
- })
- this.getCurrentDict()
- },
- getCurrentDict(){
- waterResource(`common/dict-types/${this.id}`).then((res)=>{
- if(res.data){
- this.selectValue.push(res.data.data.id)
- }
- })
- }
- },
- beforeDestroy(){
- console.log('destroyed')
- },
- watch:{
- selectValue(val){
- console.log(val)
- this.$emit('privInfo',val)
- },
- id(val){
- this.selectValue = []
- this.$route.name == '用户管理' ? this.getRoleList() : this.$route.name == '角色管理' ? this.getPrivList() : this.getDictType()
- }
- }
- }
- </script>
- <style>
- </style>
|