index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div class="workSpace">
  3. <searchForm :keys="['roleName']" ref="searchForm" @on-search="onSearch">
  4. <addRoleBtn class="addRoleBtn" @after-op="getList()"></addRoleBtn>
  5. </searchForm>
  6. <VaCard tag="b" class="table">
  7. <div class="va-table-responsive">
  8. <VaDataTable :items="users" :columns="columns" :loading="loading">
  9. <template #cell(setting)="{ rowData }">
  10. <permissionSetting :params="rowData"></permissionSetting>
  11. <previewManByRoleBtn :params="rowData"></previewManByRoleBtn>
  12. <editRoleBtn :params="rowData" @after-op="getList"></editRoleBtn>
  13. <deleteRoleBtn :params="rowData" @after-op="getList"></deleteRoleBtn>
  14. </template>
  15. </VaDataTable>
  16. </div>
  17. <div class="pagination">
  18. <VaPagination
  19. @click="update"
  20. v-model="pageInfo.pageNum"
  21. :total="pageInfo.total"
  22. :page-size="pageInfo.pageSize"
  23. :visible-pages="4"
  24. class="justify-center sm:justify-start"
  25. />
  26. </div>
  27. </VaCard>
  28. </div>
  29. </template>
  30. <script>
  31. import searchForm from '../module/searchForm.vue'
  32. import addRoleBtn from './module/addRoleBtn.vue'
  33. import permissionSetting from './module/permissionSetting.vue'
  34. import previewManByRoleBtn from './module/previewManByRoleBtn.vue'
  35. import deleteRoleBtn from './module/deleteRoleBtn.vue'
  36. import editRoleBtn from './module/editRoleBtn.vue'
  37. import dict from '../../../common/dict'
  38. export default {
  39. name: 'index',
  40. components: {
  41. searchForm,
  42. addRoleBtn,
  43. permissionSetting,
  44. previewManByRoleBtn,
  45. deleteRoleBtn,
  46. editRoleBtn,
  47. },
  48. methods: {
  49. onSearch(v) {
  50. this.pageInfo.pageNum = 1
  51. this.getList()
  52. },
  53. update(v) {
  54. this.getList()
  55. },
  56. getList() {
  57. let params = {
  58. pageNum: Math.ceil(this.pageInfo.pageNum / this.pageInfo.pageSize),
  59. pageSize: this.pageInfo.pageSize,
  60. roleName: this.$refs.searchForm.form.roleName,
  61. }
  62. this.$api.getRoleList(params).then((res) => {
  63. this.users = res.result.records
  64. this.pageInfo.total = res.result.total
  65. })
  66. },
  67. },
  68. mounted() {
  69. this.getList()
  70. },
  71. data() {
  72. return {
  73. page: 3,
  74. pageInfo: {
  75. ...dict.pageInfo,
  76. },
  77. columns: [
  78. { key: 'roleName', label: '角色名称' },
  79. { key: 'setting', label: '设置' },
  80. ],
  81. loading: false,
  82. users: [],
  83. }
  84. },
  85. }
  86. </script>
  87. <style scoped lang="less">
  88. .workSpace {
  89. width: 100%;
  90. flex: 1;
  91. }
  92. .table {
  93. margin-top: 20px;
  94. width: 100%;
  95. }
  96. .va-table-responsive {
  97. width: 100%;
  98. }
  99. .va-table {
  100. width: 100%;
  101. }
  102. .addRoleBtn {
  103. margin-left: 12px;
  104. }
  105. </style>