batch-add-appfunc.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <!--
  2. 批量添加应用功能红名单
  3. @Author: linqian
  4. @Date: 2021-07-13
  5. -->
  6. <template>
  7. <div>
  8. <el-form inline>
  9. <el-form-item label="应用系统名称:">
  10. <el-input v-model="appName" clearable></el-input>
  11. </el-form-item>
  12. <el-form-item>
  13. <dg-button type="primary" @click="handleSearch" icon="el-icon-search">查询</dg-button>
  14. </el-form-item>
  15. </el-form>
  16. <!-- 表格树 -->
  17. <vxe-table ref="vxeGrid" :data="sourceData" v-bind="gridOptions" highlight-hover-row>
  18. <vxe-table-column type="checkbox" width="60" align="center">
  19. <template #header="row">
  20. <span class="custom-checkbox">
  21. <el-checkbox
  22. :indeterminate="row.indeterminate"
  23. v-model="row.checked"
  24. @change="handleToggleAllCheck"
  25. ></el-checkbox>
  26. </span>
  27. </template>
  28. <template #checkbox="scoped">
  29. <span class="custom-checkbox">
  30. <el-checkbox
  31. :indeterminate="scoped.indeterminate"
  32. v-model="scoped.checked"
  33. @change="handleToggleCheck(scoped.row)"
  34. ></el-checkbox>
  35. </span>
  36. </template>
  37. </vxe-table-column>
  38. <vxe-table-column type="seq" width="60" align="center" title="序号"></vxe-table-column>
  39. <vxe-table-column align="left" header-align="center" title="应用功能名称" field="label" :treeNode="true"></vxe-table-column>
  40. </vxe-table>
  41. <div v-footer>
  42. <dg-button @click="handleCancel">取消</dg-button>
  43. <dg-button type="primary" @click="handleSubmit">确定</dg-button>
  44. </div>
  45. </div>
  46. </template>
  47. <script>
  48. import getTreeDataMixin from '@/pages/common/transfer-tree/mixin';
  49. import batchSetlevelAppFunc from './batch-setlevel-appfunc.vue';
  50. import { getFunIdsInRedList } from '@/api/list-manage';
  51. export default {
  52. props: {
  53. data: [Array]
  54. },
  55. mixins: [getTreeDataMixin],
  56. components: {},
  57. data() {
  58. return {
  59. appName: '',
  60. value: [],
  61. valueName: 'id',
  62. childrenName: 'child',
  63. pidName: 'p',
  64. gridOptions: {
  65. border: true,
  66. rowId: 'id',
  67. treeConfig: { children: 'child', indent: 40 },
  68. loading: false,
  69. checkboxConfig: {
  70. // 设置复选框支持分页勾选,需要设置 rowId 行数据主键
  71. reserve: true
  72. }
  73. }
  74. };
  75. },
  76. computed: {},
  77. methods: {
  78. handleToggleCheck(row) {
  79. this.$refs.vxeGrid.toggleCheckboxRow(row);
  80. },
  81. handleToggleAllCheck() {
  82. this.$refs.vxeGrid.toggleAllCheckboxRow();
  83. },
  84. handleSearch() {
  85. this.dataSource = this.data.filter((item) => item.label.indexOf(this.appName) > -1);
  86. },
  87. handleCancel() {
  88. this.$emit('close');
  89. },
  90. handleSubmit() {
  91. // 获取全选和半选的节点
  92. const checkboxRecords = this.$refs.vxeGrid.getCheckboxRecords(true);
  93. const checkboxReserveRecords = this.$refs.vxeGrid.getCheckboxReserveRecords(true);
  94. const indeterminateRecords = this.$refs.vxeGrid.getCheckboxIndeterminateRecords(true);
  95. const totalRecords = [...checkboxRecords, ...checkboxReserveRecords, ...indeterminateRecords].filter((item) => item.appId);
  96. if (totalRecords.length > 0) {
  97. this.setLevel(totalRecords);
  98. } else {
  99. this.$message.warning('请至少选择一个应用功能!');
  100. }
  101. },
  102. /**
  103. * 设置名单级别
  104. */
  105. setLevel(selectedData) {
  106. const vm = this;
  107. const layer = this.$dgLayer({
  108. title: '设置红名单级别',
  109. content: batchSetlevelAppFunc,
  110. props: {
  111. data: this.data,
  112. value: selectedData.map((item) => item.id),
  113. selectedData,
  114. operate: 'add'
  115. },
  116. on: {
  117. success() {
  118. vm.$emit('success');
  119. layer.close(layer.dialogIndex);
  120. }
  121. },
  122. cancel: function (index) {
  123. // 关闭对应弹窗的ID
  124. layer.close(index);
  125. return false;
  126. },
  127. area: ['800px', '600px']
  128. });
  129. }
  130. },
  131. created() {
  132. // 查询已被添加为红名单的功能id
  133. getFunIdsInRedList().then((res) => {
  134. this.value = this.getChildKeys(this.data, res.data.content);
  135. });
  136. },
  137. mounted() {}
  138. };
  139. </script>
  140. <style lang='scss' scoped>
  141. @import url('../index.scss');
  142. </style>