PermissionDataRuleList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <a-drawer
  3. title="数据权限规则"
  4. :width="drawerWidth"
  5. @close="onClose"
  6. :visible="visible">
  7. <!-- 抽屉内容的border -->
  8. <div
  9. :style="{
  10. padding:'10px',
  11. border: '1px solid #e9e9e9',
  12. background: '#fff',
  13. }">
  14. <div class="table-page-search-wrapper">
  15. <a-form @keyup.enter.native="searchQuery">
  16. <a-row :gutter="12">
  17. <a-col :md="8" :sm="8">
  18. <a-form-item label="规则名称" :labelCol="{span: 8}" :wrapperCol="{span: 14, offset: 1}">
  19. <a-input placeholder="请输入规则名称" v-model="queryParam.ruleName"></a-input>
  20. </a-form-item>
  21. </a-col>
  22. <a-col :md="8" :sm="8">
  23. <a-form-item label="规则值" :labelCol="{span: 8}" :wrapperCol="{span: 14, offset: 1}">
  24. <a-input placeholder="请输入规则值" v-model="queryParam.ruleValue"></a-input>
  25. </a-form-item>
  26. </a-col>
  27. <a-col :md="7" :sm="8">
  28. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  29. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  30. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  31. </span>
  32. </a-col>
  33. </a-row>
  34. <a-row>
  35. <a-col :md="24" :sm="24">
  36. <a-button style="margin-bottom: 10px" @click="addPermissionRule" type="primary" icon="plus">添加</a-button>
  37. </a-col>
  38. </a-row>
  39. </a-form>
  40. <a-table
  41. ref="table"
  42. rowKey="id"
  43. size="middle"
  44. :columns="columns"
  45. :dataSource="dataSource"
  46. :loading="loading"
  47. :rowClassName="getRowClassname">
  48. <template slot="ruleValueText" slot-scope="text,record">
  49. <j-ellipsis :value="text" :length="15"></j-ellipsis>
  50. </template>
  51. <span slot="action" slot-scope="text, record">
  52. <a @click="handleEdit(record)">
  53. <a-icon type="edit"/>编辑
  54. </a>
  55. <a-divider type="vertical"/>
  56. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  57. <a>删除</a>
  58. </a-popconfirm>
  59. </span>
  60. </a-table>
  61. </div>
  62. </div>
  63. <permission-data-rule-modal @ok="modalFormOk" ref="modalForm"></permission-data-rule-modal>
  64. </a-drawer>
  65. </template>
  66. <script>
  67. import {getPermissionRuleList, queryPermissionRule} from '@/api/api'
  68. import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  69. import PermissionDataRuleModal from './modules/PermissionDataRuleModal'
  70. const columns = [
  71. {
  72. title: '规则名称',
  73. dataIndex: 'ruleName',
  74. key: 'ruleName',
  75. width:150,
  76. },
  77. {
  78. title: '规则字段',
  79. dataIndex: 'ruleColumn',
  80. key: 'ruleColumn',
  81. width:150,
  82. },
  83. {
  84. title: '规则值',
  85. dataIndex: 'ruleValue',
  86. key: 'ruleValue',
  87. width:150,
  88. scopedSlots: {customRender: "ruleValueText"}
  89. },
  90. {
  91. title: '操作',
  92. dataIndex: 'action',
  93. scopedSlots: {customRender: 'action'},
  94. align: 'center'
  95. }
  96. ]
  97. export default {
  98. name: 'PermissionDataRuleList',
  99. mixins: [JeecgListMixin],
  100. components: {
  101. PermissionDataRuleModal
  102. },
  103. data() {
  104. return {
  105. queryParam: {},
  106. drawerWidth: 650,
  107. columns: columns,
  108. permId: '',
  109. visible: false,
  110. form: this.$form.createForm(this),
  111. loading: false,
  112. url: {
  113. list: "/sys/permission/getPermRuleListByPermId",
  114. delete: "/sys/permission/deletePermissionRule",
  115. },
  116. }
  117. },
  118. created() {
  119. this.resetScreenSize()
  120. },
  121. methods: {
  122. loadData() {
  123. //20190908 scott for: 首次进入菜单列表的时候,不加载权限列表
  124. if(!this.permId){
  125. return
  126. }
  127. let that = this
  128. this.dataSource = []
  129. var params = this.getQueryParams()//查询条件
  130. getPermissionRuleList(params).then((res) => {
  131. if (res.success) {
  132. that.dataSource = res.result
  133. }
  134. })
  135. },
  136. edit(record) {
  137. if (record.id) {
  138. this.visible = true
  139. this.permId = record.id
  140. }
  141. this.queryParam = {}
  142. this.queryParam.permissionId = record.id
  143. this.visible = true
  144. this.loadData()
  145. this.resetScreenSize()
  146. },
  147. addPermissionRule() {
  148. this.$refs.modalForm.add(this.permId)
  149. this.$refs.modalForm.title = '新增'
  150. },
  151. searchQuery() {
  152. var params = this.getQueryParams();
  153. params.permissionId = this.permId;
  154. queryPermissionRule(params).then((res) => {
  155. if (res.success) {
  156. this.dataSource = res.result
  157. }
  158. })
  159. },
  160. searchReset() {
  161. this.queryParam = {}
  162. this.queryParam.permissionId = this.permId
  163. this.loadData(1);
  164. },
  165. onClose() {
  166. this.visible = false
  167. },
  168. // 根据屏幕变化,设置抽屉尺寸
  169. resetScreenSize() {
  170. let screenWidth = document.body.clientWidth
  171. if (screenWidth < 500) {
  172. this.drawerWidth = screenWidth
  173. } else {
  174. this.drawerWidth = 650
  175. }
  176. },
  177. getRowClassname(record){
  178. if(record.status!=1){
  179. return "data-rule-invalid"
  180. }
  181. }
  182. }
  183. }
  184. </script>
  185. <style>
  186. .data-rule-invalid{
  187. background: #f4f4f4;
  188. color: #bababa;
  189. }
  190. </style>