roleList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div class="full-container-p24">
  3. <div style="display: flex; justify-content: space-between">
  4. <div style="display: flex">
  5. <el-input
  6. placeholder="请输入部门/职位名称"
  7. prefix-icon="el-icon-search"
  8. v-model="term"
  9. clearable
  10. style="height: 32px; width: 330px; line-height: 32px"
  11. @keyup.enter.native="getRoleList"
  12. ></el-input>
  13. <div class="seach-btn" @click="getRoleList">查询</div>
  14. </div>
  15. <el-button v-auth="'ADDUPDATEROLE'" type="primary" @click="addRole"
  16. >添加职位</el-button
  17. >
  18. </div>
  19. <div style="margin-top: 24px">
  20. <el-table :data="tableData" stripe style="width: 100%">
  21. <el-table-column
  22. type="index"
  23. label="序号"
  24. min-width="80"
  25. align="center"
  26. ></el-table-column>
  27. <el-table-column
  28. prop="roleName"
  29. label="职位名称"
  30. min-width="100"
  31. align="center"
  32. ></el-table-column>
  33. <el-table-column
  34. prop="departmentName"
  35. label="部门"
  36. min-width="100"
  37. align="center"
  38. ></el-table-column>
  39. <el-table-column
  40. prop="createTime"
  41. label="创建时间"
  42. min-width="160"
  43. align="center"
  44. >
  45. <template v-slot="scope">
  46. {{ subTimeStr(scope.row.createTime) }}
  47. </template>
  48. </el-table-column>
  49. <el-table-column
  50. v-auth="'ADDUPDATEROLE'"
  51. label="操作"
  52. min-width="120"
  53. align="center"
  54. >
  55. <template v-slot="scope">
  56. <el-button
  57. @click="roleDetail(scope.row.id)"
  58. size="small"
  59. type="primary"
  60. >详情</el-button
  61. >
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. <div style="width: 100%; text-align: right; margin-top: 43px">
  66. <el-pagination
  67. background
  68. layout="prev, pager, next"
  69. :total="total"
  70. @current-change="pageChange"
  71. ></el-pagination>
  72. </div>
  73. </div>
  74. </div>
  75. </template>
  76. <script setup>
  77. import api from "../../apis/fetch";
  78. import { ref, onMounted, reactive } from "vue";
  79. import { ElNotification, ElMessageBox } from "element-plus";
  80. import router from "../../router";
  81. import store from "../../store";
  82. import { subTimeStr } from "../../utils/utils";
  83. let tableData = ref([]);
  84. let currentPage = ref(1);
  85. let total = ref(0);
  86. let term = ref("");
  87. let loginAccountId = ref(0);
  88. async function getRoleList() {
  89. let res = await api.getRoleList({
  90. term: term.value,
  91. currentPage: currentPage.value,
  92. size: 10,
  93. loginAccountId: loginAccountId.value,
  94. });
  95. if (res.data.status == 0) {
  96. tableData.value = res.data.result;
  97. total.value = res.data.total;
  98. } else {
  99. tableData.value = [];
  100. total.value = 0;
  101. }
  102. }
  103. function pageChange(e) {
  104. currentPage.value = e;
  105. getRoleList();
  106. }
  107. function addRole() {
  108. router.push("/authManage/addRole");
  109. }
  110. function roleDetail(roleId) {
  111. router.push({
  112. path: "/authManage/addRole",
  113. query: {
  114. roleId,
  115. },
  116. });
  117. }
  118. onMounted(() => {
  119. loginAccountId.value = localStorage.loginAccountId;
  120. getRoleList();
  121. });
  122. </script>
  123. <style scoped>
  124. .seach-btn {
  125. display: inline-block;
  126. width: 60px;
  127. height: 38px;
  128. background: #0094fe;
  129. border-radius: 2px;
  130. font-size: 14px;
  131. font-family: PingFangSC-Regular, PingFang SC;
  132. font-weight: 400;
  133. color: #ffffff;
  134. text-align: center;
  135. line-height: 38px;
  136. margin-left: 10px;
  137. cursor: pointer;
  138. }
  139. </style>