index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <div class="container">
  3. <div class="top-se">
  4. <seek-page :seekList="seekList" @search="reload"></seek-page>
  5. </div>
  6. <ele-pro-table
  7. ref="table"
  8. :columns="columns"
  9. :datasource="datasource"
  10. :selection.sync="selectionList"
  11. row-key="id"
  12. :page-size="20"
  13. @columns-change="handleColumnChange"
  14. :cache-key="cacheKeyUrl"
  15. height="calc(100vh - 330px)"
  16. full-height="calc(100vh - 176px)"
  17. >
  18. <!-- 表头工具栏 -->
  19. <template v-slot:toolbar>
  20. <el-button
  21. size="small"
  22. type="primary"
  23. icon="el-icon-plus"
  24. class="ele-btn-icon"
  25. @click="addHandler"
  26. v-if="$hasPermission('main:team:save')"
  27. >
  28. 新建
  29. </el-button>
  30. <el-button
  31. size="small"
  32. type="danger"
  33. el-icon-delete
  34. class="ele-btn-icon"
  35. @click="allDelBtn"
  36. :disabled="selectionList?.length === 0"
  37. >
  38. 批量删除
  39. </el-button>
  40. <el-button
  41. type="success"
  42. class="ele-btn-icon"
  43. size="small"
  44. @click="openRules"
  45. >
  46. 脱敏规则表
  47. </el-button>
  48. </template>
  49. <!-- 操作列 -->
  50. <template v-slot:action="{ row }">
  51. <el-link
  52. type="primary"
  53. :underline="false"
  54. icon="el-icon-edit"
  55. @click="editHandler(row.id)"
  56. v-if="$hasPermission('main:team:update')"
  57. >
  58. 修改
  59. </el-link>
  60. <el-popconfirm
  61. class="ele-action"
  62. title="确定要删除此数据吗?"
  63. @confirm="deleteHandler(row.id)"
  64. v-if="$hasPermission('main:team:delete')"
  65. >
  66. <template v-slot:reference>
  67. <el-link type="danger" :underline="false" icon="el-icon-delete">
  68. 删除
  69. </el-link>
  70. </template>
  71. </el-popconfirm>
  72. </template>
  73. </ele-pro-table>
  74. <RulesList v-if="rulesVisible" :visible.sync="rulesVisible"></RulesList>
  75. <AddDesensitizerule
  76. @success="successHandler"
  77. v-if="desensitizeruleVisible"
  78. :visible.sync="desensitizeruleVisible"
  79. :isUpdate.sync="isUpdate"
  80. :id="dataId"
  81. ></AddDesensitizerule>
  82. </div>
  83. </template>
  84. <script>
  85. import tabMixins from '@/mixins/tableColumnsMixin';
  86. import {
  87. datadesensitizerulePage,
  88. deleteDatadesensitizerule
  89. } from '@/api/system/dataDesensitization';
  90. import RulesList from './components/RulesList';
  91. import AddDesensitizerule from './components/AddDesensitizerule';
  92. export default {
  93. mixins: [tabMixins],
  94. components: {
  95. RulesList,
  96. AddDesensitizerule
  97. },
  98. data() {
  99. return {
  100. selectionList: [],
  101. rulesVisible: false,
  102. desensitizeruleVisible: false,
  103. isUpdate: false,
  104. dataId: '',
  105. cacheKeyUrl: 'mainData-system-dataDesensitization'
  106. };
  107. },
  108. computed: {
  109. columns() {
  110. let arr = [
  111. {
  112. width: 45,
  113. type: 'selection',
  114. columnKey: 'selection',
  115. align: 'center',
  116. fixed: 'left',
  117. reserveSelection: true
  118. },
  119. {
  120. width: 55,
  121. label: '序号',
  122. type: 'index',
  123. columnKey: 'index',
  124. align: 'center',
  125. fixed: 'left'
  126. },
  127. {
  128. prop: 'moduleName',
  129. label: '脱敏页面',
  130. align: 'center',
  131. showOverflowTooltip: true
  132. },
  133. {
  134. prop: 'functionName',
  135. label: '脱敏名称',
  136. align: 'center',
  137. showOverflowTooltip: true
  138. },
  139. {
  140. prop: 'requestUri',
  141. label: '请求接口',
  142. align: 'center',
  143. showOverflowTooltip: true
  144. },
  145. {
  146. columnKey: 'action',
  147. label: '操作',
  148. width: 220,
  149. align: 'center',
  150. resizable: false,
  151. slot: 'action',
  152. showOverflowTooltip: true,
  153. fixed: 'right'
  154. }
  155. ];
  156. return arr;
  157. },
  158. seekList() {
  159. return [
  160. {
  161. label: '脱敏页面:',
  162. value: 'moduleName',
  163. type: 'input',
  164. placeholder: ''
  165. },
  166. {
  167. label: '脱敏名称:',
  168. value: 'functionName',
  169. type: 'input',
  170. placeholder: ''
  171. },
  172. {
  173. label: '请求接口:',
  174. value: 'requestUri',
  175. type: 'input',
  176. placeholder: ''
  177. }
  178. ];
  179. }
  180. },
  181. methods: {
  182. async datasource({ page, limit, where, order }) {
  183. let res = await datadesensitizerulePage({
  184. ...where,
  185. pageNum: page,
  186. size: limit
  187. });
  188. return res;
  189. },
  190. addHandler() {
  191. this.desensitizeruleVisible = true;
  192. },
  193. editHandler(id) {
  194. this.dataId = id;
  195. this.isUpdate = true;
  196. this.desensitizeruleVisible = true;
  197. },
  198. async deleteHandler(id) {
  199. await deleteDatadesensitizerule([id]);
  200. this.reload();
  201. },
  202. search() {},
  203. async allDelBtn() {
  204. if (!this.selectionList.length) return;
  205. let ids = this.selectionList.map((item) => item.id);
  206. await deleteDatadesensitizerule(ids);
  207. this.selection = [];
  208. this.reload();
  209. },
  210. openRules() {
  211. this.rulesVisible = true;
  212. },
  213. successHandler() {
  214. this.reload();
  215. },
  216. reload(where) {
  217. this.$refs.table.reload({ page: 1, where: where });
  218. }
  219. }
  220. };
  221. </script>
  222. <style lang="scss" scoped>
  223. .container {
  224. width: 100%;
  225. height: 100%;
  226. }
  227. .top-se {
  228. background-color: #fff;
  229. padding: 20px;
  230. height: 100px;
  231. }
  232. </style>