1aee3024dd24d00711c6caf6928983ba5fd39fb7.svn-base 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <el-select v-model="selectValue" multiple placeholder="请选择">
  3. <el-option
  4. v-for="item in options"
  5. :key="item.id"
  6. :label="item.privName"
  7. :value="item.id"
  8. v-if="name == '角色管理'">
  9. </el-option>
  10. <el-option
  11. v-for="item in options"
  12. :key="item.guid"
  13. :label="item.roleName"
  14. :value="item.guid"
  15. v-if="name == '用户管理'">
  16. </el-option>
  17. <el-option
  18. v-for="(item,index) in options"
  19. :key="index"
  20. :label="item.dictTypeDesc"
  21. :value="item.id"
  22. v-if="name == '字典管理'">
  23. </el-option>
  24. </el-select>
  25. </template>
  26. <script>
  27. import request from '../utils/gw_ajax_request.js'
  28. export default {
  29. props: ['id'], //接收组件传过来的树形数据和根id
  30. name: 'select_multiple',
  31. data () {
  32. return {
  33. options: [],
  34. selectValue: [],
  35. name: this.$route.name
  36. }
  37. },
  38. mounted:function(){
  39. this.$route.name == '用户管理' ? this.getRoleList() : this.$route.name == '角色管理' ? this.getPrivList() : this.getDictType()
  40. },
  41. methods:{
  42. getPrivList(){
  43. request.get('sys/privs/findList').then((res)=>{
  44. if(res.data){
  45. this.options = res.data
  46. }
  47. })
  48. if(this.id){
  49. this.getCurrencyPriv()
  50. }
  51. },
  52. getRoleList(){
  53. request.get('dc/role/findList').then((res)=>{
  54. if(res.data){
  55. this.options = res.data
  56. }
  57. })
  58. console.log(this.id)
  59. if(this.id){
  60. this.getCurrencyRole()
  61. }
  62. },
  63. //当前用户或角色有哪些角色或权限
  64. getCurrencyPriv(){
  65. request.get(`sys/privs/tree-by-role/${this.id}`).then((res)=>{
  66. if(res.data){
  67. res.data.forEach(ele => {
  68. if(ele.checked){
  69. this.selectValue.push(ele.id)
  70. }
  71. });
  72. }
  73. })
  74. },
  75. getCurrencyRole(){
  76. request.get(`dc/role/list-by-user/${this.id}`).then((res)=>{
  77. if(res.data){
  78. res.data.forEach(ele => {
  79. if(ele.currentUser){
  80. this.selectValue.push(ele.guid)
  81. }
  82. });
  83. }
  84. })
  85. },
  86. //获取字典类型
  87. getDictType(){
  88. request.get('common/dict-types/list',{}).then((res)=>{
  89. if(res.data){
  90. this.options = res.data.data
  91. console.log(this.options)
  92. }
  93. })
  94. this.getCurrentDict()
  95. },
  96. getCurrentDict(){
  97. waterResource(`common/dict-types/${this.id}`).then((res)=>{
  98. if(res.data){
  99. this.selectValue.push(res.data.data.id)
  100. }
  101. })
  102. }
  103. },
  104. beforeDestroy(){
  105. console.log('destroyed')
  106. },
  107. watch:{
  108. selectValue(val){
  109. console.log(val)
  110. this.$emit('privInfo',val)
  111. },
  112. id(val){
  113. this.selectValue = []
  114. this.$route.name == '用户管理' ? this.getRoleList() : this.$route.name == '角色管理' ? this.getPrivList() : this.getDictType()
  115. }
  116. }
  117. }
  118. </script>
  119. <style>
  120. </style>