app-func.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <div>
  3. <!-- 搜索栏 -->
  4. <search-bar :conditionForm="conditionForm" @submitSearch="receiveSearch"></search-bar>
  5. <!-- 操作栏 -->
  6. <operate-bar :pageOptList="pageOptList" @submitPageOpt="receviceOpt"></operate-bar>
  7. <!-- 列表 -->
  8. <vxe-table ref="vxeGrid" :data="tableData" v-bind="gridOptions" highlight-hover-row>
  9. <vxe-table-column type="checkbox" width="60" align="center">
  10. <template #header="row">
  11. <span class="custom-checkbox">
  12. <el-checkbox
  13. :indeterminate="row.indeterminate"
  14. v-model="row.checked"
  15. @change="handleToggleAllCheck"
  16. ></el-checkbox>
  17. </span>
  18. </template>
  19. <template #checkbox="scoped">
  20. <span class="custom-checkbox">
  21. <el-checkbox
  22. :indeterminate="scoped.indeterminate"
  23. v-model="scoped.checked"
  24. @change="handleToggleCheck(scoped.row)"
  25. ></el-checkbox>
  26. </span>
  27. </template>
  28. </vxe-table-column>
  29. <vxe-table-column type="seq" width="60" align="center" title="序号"></vxe-table-column>
  30. <vxe-table-column
  31. align="left"
  32. header-align="center"
  33. title="应用功能名称"
  34. field="label"
  35. :treeNode="true"
  36. ></vxe-table-column>
  37. <vxe-table-column align="center" title="红名单级别" field="level">
  38. <template #default="{ row }">
  39. {{ levelToLabel(row.level) }}
  40. </template>
  41. </vxe-table-column>
  42. <vxe-table-column align="center" title="操作" field="operate">
  43. <template #default="{ row }">
  44. <div class="u-table__operation">
  45. <el-tooltip content="删除" effect="dark" placement="top-end">
  46. <i :class="'删除' | optIcon" @click="handleRemove(row)"></i>
  47. </el-tooltip>
  48. </div>
  49. </template>
  50. </vxe-table-column>
  51. </vxe-table>
  52. <!-- 分页器 -->
  53. <div class="pagination-section">
  54. <el-pagination
  55. @size-change="handleSizeChange"
  56. @current-change="handleCurrentChange"
  57. :current-page="currentPage"
  58. :page-sizes="[10, 20, 30]"
  59. :page-size="pageSize"
  60. layout="total, sizes, prev, pager, next, jumper"
  61. :total="total"
  62. >
  63. </el-pagination>
  64. </div>
  65. </div>
  66. </template>
  67. <script>
  68. import batchAddAppFunc from './batch-add-appfunc.vue';
  69. import batchSetLevelAppFunc from './batch-setlevel-appfunc.vue';
  70. import batchDeleteAppFunc from './batch-delete-appfunc.vue';
  71. import { getRedAppFuncList, delRedAppFunc } from '@/api/list-manage';
  72. import { allAppFuncTree } from '@/api/permission-selfhelp-manage';
  73. import jzApi from '@/api/jz-base';
  74. import operateBar from '@/components/operate-bar';
  75. import searchBar from '@/components/search-bar';
  76. import { searchOpt } from '@/mixins/page-opt';
  77. import { appRestApi } from '@/api/application';
  78. export default {
  79. components: { operateBar, searchBar },
  80. mixins: [searchOpt],
  81. data() {
  82. return {
  83. pageOptList: ['批量添加', '批量设置名单级别', '批量删除'],
  84. // 分页器
  85. currentPage: 1,
  86. total: 0,
  87. pageSize: 10,
  88. // 数据
  89. tableData: [],
  90. gridOptions: {
  91. border: true,
  92. rowId: 'id',
  93. treeConfig: { children: 'child', indent: 40 },
  94. loading: false,
  95. checkboxConfig: {
  96. // 设置复选框支持分页勾选,需要设置 rowId 行数据主键
  97. reserve: true
  98. }
  99. },
  100. conditionForm: [
  101. {
  102. label: '应用系统名称',
  103. name: 'appName',
  104. op: 'like',
  105. value: '',
  106. component: 'SelectApp',
  107. apiUrl: appRestApi.table,
  108. valueName: 'applyName',
  109. labelName: 'applyName'
  110. }
  111. ]
  112. };
  113. },
  114. methods: {
  115. receviceOpt(type) {
  116. if (type == '批量添加') {
  117. this.handleAdd();
  118. } else if (type == '批量设置名单级别') {
  119. this.handleSetListLevel();
  120. } else if (type == '批量删除') {
  121. this.handleBatchRemove();
  122. }
  123. },
  124. handleToggleCheck(row) {
  125. this.$refs.vxeGrid.toggleCheckboxRow(row);
  126. },
  127. handleToggleAllCheck() {
  128. this.$refs.vxeGrid.toggleAllCheckboxRow();
  129. },
  130. /**
  131. * @description:查询
  132. */
  133. receiveSearch(value) {
  134. this.condition = value;
  135. this.reloadTable();
  136. },
  137. reloadTable() {
  138. this.currentPage = 1;
  139. const selectedData = this.$refs.vxeGrid.getCheckboxRecords(true).filter((item) => !item.isTreeNode);
  140. this.$refs.vxeGrid.reloadData(selectedData);
  141. this.getList();
  142. },
  143. // 打开弹窗
  144. openLayer(title, content, operate) {
  145. const vm = this;
  146. const checkboxReserveRecords = this.$refs.vxeGrid.getCheckboxReserveRecords(true);
  147. const checkboxRecords = this.$refs.vxeGrid.getCheckboxRecords(true);
  148. const indeterminateRecords = this.$refs.vxeGrid.getCheckboxIndeterminateRecords(true);
  149. const selectedData = [...checkboxRecords, ...checkboxReserveRecords, ...indeterminateRecords].filter(
  150. (item) => item.pid
  151. );
  152. const layer = this.$dgLayer({
  153. title,
  154. content,
  155. props: {
  156. data: this.allTree,
  157. selectedData,
  158. operate,
  159. value: selectedData.map((item) => item.id)
  160. },
  161. on: {
  162. success() {
  163. vm.reloadTable();
  164. layer.close(layer.dialogIndex);
  165. }
  166. },
  167. cancel: function (index) {
  168. // 关闭对应弹窗的ID
  169. layer.close(index);
  170. return false;
  171. },
  172. area: ['1000px', '800px']
  173. });
  174. },
  175. /**
  176. * 添加
  177. */
  178. handleAdd() {
  179. this.openLayer('批量添加应用功能红名单', batchAddAppFunc, 'add');
  180. },
  181. /**
  182. * 验证是否有批量选中
  183. */
  184. verify() {
  185. const selectedData = this.$refs.vxeGrid.getCheckboxRecords(true);
  186. if (selectedData.length == 0) {
  187. this.$message.warning('请至少选择一个应用功能!');
  188. return false;
  189. } else {
  190. return true;
  191. }
  192. },
  193. /**
  194. * 设置名单级别
  195. */
  196. handleSetListLevel() {
  197. if (!this.verify()) return;
  198. this.openLayer('批量设置红名单级别', batchSetLevelAppFunc, 'set');
  199. },
  200. /**
  201. * 批量删除
  202. */
  203. handleBatchRemove() {
  204. if (!this.verify()) return;
  205. this.openLayer('批量删除应用功能红名单', batchDeleteAppFunc, 'del');
  206. },
  207. /**
  208. * 单挑删除
  209. */
  210. handleRemove(row) {
  211. this.$dgConfirm(`是否确定删除这条数据!`, '提示', {}).then(() => {
  212. const params = {
  213. isTreeNode: row.isTreeNode,
  214. resourceId: row.id,
  215. resourceType: row.type
  216. };
  217. delRedAppFunc(params).then((res) => {
  218. this.$message.success('删除成功!');
  219. this.getList();
  220. });
  221. });
  222. },
  223. handleSizeChange(val) {
  224. this.pageSize = val;
  225. this.currentPage = 1;
  226. this.getList();
  227. },
  228. handleCurrentChange(val) {
  229. this.currentPage = val;
  230. this.getList();
  231. },
  232. /**
  233. * 获取列表
  234. */
  235. getList() {
  236. const params = {
  237. page: this.currentPage - 1,
  238. size: this.pageSize,
  239. searchCondition: this.condition
  240. };
  241. getRedAppFuncList(params).then((res) => {
  242. const { content, totalElements } = res.data;
  243. this.tableData = content;
  244. this.total = totalElements;
  245. });
  246. },
  247. /**
  248. * 获取全量的应用功能树
  249. */
  250. getAllFuncTree() {
  251. allAppFuncTree(false).then((res) => {
  252. this.allTree = res.data.content;
  253. });
  254. },
  255. /**
  256. * 获取级别级别枚举
  257. */
  258. getLevelEnum() {
  259. return new Promise((resolve) => {
  260. jzApi.fetchEnum('ListLevelEnum').then((res) => {
  261. this.levelList = res.data;
  262. resolve(res.data);
  263. });
  264. });
  265. },
  266. levelToLabel(val) {
  267. if (val) {
  268. return this.levelList.find((item) => item.value == val).label;
  269. } else {
  270. return '';
  271. }
  272. },
  273. async init() {
  274. await this.getLevelEnum();
  275. this.getList();
  276. }
  277. },
  278. created() {
  279. this.init();
  280. this.getAllFuncTree();
  281. }
  282. };
  283. </script>
  284. <style lang="scss" scoped>
  285. @import url('../index.scss');
  286. </style>