userAuth.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <el-dialog title="设置权限" :visible.sync="open" width="576px" center>
  3. <div class="etree">
  4. <el-tree
  5. ref="tree"
  6. node-key="path"
  7. :data="data"
  8. :default-checked-keys="sels"
  9. show-checkbox
  10. @node-click="nclick"
  11. default-expand-all>
  12. </el-tree>
  13. </div>
  14. <span slot="footer">
  15. <el-button @click="open = false">取 消</el-button>
  16. <el-button type="primary" @click="update">更 新</el-button>
  17. </span>
  18. </el-dialog>
  19. </template>
  20. <script>
  21. export default {
  22. data () {
  23. return {
  24. open: false,
  25. uid: 0,
  26. data: [],
  27. sels: []
  28. }
  29. },
  30. methods: {
  31. update () {
  32. let data = {auth: JSON.stringify(this.$refs.tree.getCheckedKeys(true))}
  33. this.$http.put('user/auth/' + this.uid, data).then(() => {
  34. this.open = false
  35. this.$emit('reload')
  36. }, err => {})
  37. },
  38. show (uid, data) {
  39. this.open = true
  40. this.uid = uid
  41. this.data = data.data
  42. this.sels = data.sels
  43. },
  44. nclick (d, n) {
  45. if (n.isLeaf) {
  46. this.$refs.tree.setChecked(d, !n.checked)
  47. }
  48. }
  49. }
  50. }
  51. </script>
  52. <style scoped>
  53. .etree{height: 340px;overflow: auto;}
  54. </style>