role.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div class="user">
  3. <FullPage title='角色管理'
  4. :list='list'
  5. @init='init'
  6. :loading='loading'
  7. @searchData='init'
  8. @changePage='changePage'
  9. @changeSize='changeSize'
  10. :tableColums='tableColums'
  11. :tableData='tableData'
  12. :pageIndex='pageIndex'
  13. :total='total'>
  14. <div slot='titleButton'>
  15. <Button type="primary"
  16. ghost
  17. icon='md-add'
  18. @click="goPage(1)">新增角色</Button>
  19. </div>
  20. <div slot='navButton'>
  21. </div>
  22. <template slot='set'
  23. slot-scope='{row}'>
  24. <div class="table-set">
  25. <svg style="font-size:20px"
  26. color='#3764FF'
  27. @click="goPage(2,row)"
  28. class="icon icon-nav"
  29. aria-hidden="true">
  30. <use xlink:href="#iconbianji"></use>
  31. </svg>
  32. <svg @click="deleteItems(row)"
  33. class="icon icon-nav"
  34. style="font-size:20px"
  35. color='red'
  36. aria-hidden="true">
  37. <use xlink:href="#iconshanchu"></use>
  38. </svg>
  39. </div>
  40. </template>
  41. </FullPage>
  42. </div>
  43. </template>
  44. <script>
  45. export default {
  46. data () {
  47. return {
  48. list: [
  49. { title: '角色名', name: 'Input', serverName: 'group_title', value: '', placeholder: '请输入角色名' }
  50. ],
  51. tableColums: [
  52. { title: '序号', type: 'index', align: 'center', key: 'id', width: '100' },
  53. { title: '角色名', align: 'center', key: 'group_title' },
  54. { title: '操作', align: 'center', slot: 'set', width: '150' },
  55. ],
  56. tableData: [],
  57. pageIndex: 1,
  58. total: 0,
  59. pageSize: 10,
  60. proxyObj: {},
  61. loading: false,
  62. }
  63. },
  64. methods: {
  65. init (row) {
  66. this.pageIndex = 1
  67. row.page_index = this.pageIndex;
  68. row.page_size = this.pageSize;
  69. this.proxyObj = row
  70. this.getData(row)
  71. },
  72. getData (row) {
  73. this.loading = true
  74. this.axios('/api/group', { params: row }).then(res => {
  75. this.loading = false
  76. res.data.data.map(v => { v.value = v.id; v.label = v.group_title })
  77. // this.list[1].option = res.data.data;
  78. this.tableData = res.data.data;
  79. this.total = res.data.total;
  80. })
  81. },
  82. changePage (e) {
  83. this.pageIndex = e;
  84. this.proxyObj.page_index = this.pageIndex;
  85. this.getData(this.proxyObj)
  86. },
  87. changeSize (e) {
  88. this.pageSize = e;
  89. this.proxyObj.page_size = this.pageSize;
  90. this.getData(this.proxyObj)
  91. },
  92. deleteItems (row) {
  93. this.confirmDelete({
  94. content: '删除后该角色下的所有信息将被删除,订单中已使用的角色信息将会保留不变',
  95. then: () => {
  96. this.axios.post('/api/group', { id: row.id, state: 0, op: 'edit' }).then(res => {
  97. this.getData(this.proxyObj)
  98. })
  99. }
  100. })
  101. },
  102. goPage (n, row) {
  103. const id = row ? row.id : '';
  104. const group_title = row ? row.group_title : ''
  105. const group_type = row ? row.type : ''
  106. this.$router.push({
  107. path: '/cms/personnelmanagement/role/edit',
  108. query: {
  109. type: n,
  110. id: id,
  111. group_title: group_title,
  112. group_type: group_type
  113. }
  114. })
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .nav {
  121. display: flex;
  122. justify-content: space-between;
  123. align-items: center;
  124. }
  125. </style>