4fdd7311302c10f515b2ba1b03e9f49d250e93de.svn-base 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. <span slot="action" slot-scope="text, record">
  49. <a @click="handleEdit(record)">
  50. <a-icon type="edit"/>编辑
  51. </a>
  52. <a-divider type="vertical"/>
  53. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  54. <a>删除</a>
  55. </a-popconfirm>
  56. </span>
  57. </a-table>
  58. </div>
  59. </div>
  60. <permission-data-rule-modal @ok="modalFormOk" ref="modalForm"></permission-data-rule-modal>
  61. </a-drawer>
  62. </template>
  63. <script>
  64. import {getPermissionRuleList, queryPermissionRule} from '@/api/api'
  65. import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  66. import PermissionDataRuleModal from './modules/PermissionDataRuleModal'
  67. const columns = [
  68. {
  69. title: '规则名称',
  70. dataIndex: 'ruleName',
  71. key: 'ruleName'
  72. },
  73. {
  74. title: '规则字段',
  75. dataIndex: 'ruleColumn',
  76. key: 'ruleColumn'
  77. },
  78. {
  79. title: '规则值',
  80. dataIndex: 'ruleValue',
  81. key: 'ruleValue'
  82. },
  83. {
  84. title: '操作',
  85. dataIndex: 'action',
  86. scopedSlots: {customRender: 'action'},
  87. align: 'center'
  88. }
  89. ]
  90. export default {
  91. name: 'PermissionDataRuleList',
  92. mixins: [JeecgListMixin],
  93. components: {
  94. PermissionDataRuleModal
  95. },
  96. data() {
  97. return {
  98. queryParam: {},
  99. drawerWidth: 650,
  100. columns: columns,
  101. permId: '',
  102. visible: false,
  103. form: this.$form.createForm(this),
  104. loading: false,
  105. url: {
  106. list: "/sys/permission/getPermRuleListByPermId",
  107. delete: "/sys/permission/deletePermissionRule",
  108. },
  109. }
  110. },
  111. created() {
  112. this.resetScreenSize()
  113. },
  114. methods: {
  115. loadData() {
  116. //20190908 scott for: 首次进入菜单列表的时候,不加载权限列表
  117. if(!this.permId){
  118. return
  119. }
  120. let that = this
  121. this.dataSource = []
  122. var params = this.getQueryParams()//查询条件
  123. getPermissionRuleList(params).then((res) => {
  124. if (res.success) {
  125. that.dataSource = res.result
  126. }
  127. })
  128. },
  129. edit(record) {
  130. if (record.id) {
  131. this.visible = true
  132. this.permId = record.id
  133. }
  134. this.queryParam = {}
  135. this.queryParam.permissionId = record.id
  136. this.visible = true
  137. this.loadData()
  138. this.resetScreenSize()
  139. },
  140. addPermissionRule() {
  141. this.$refs.modalForm.add(this.permId)
  142. this.$refs.modalForm.title = '新增'
  143. },
  144. searchQuery() {
  145. var params = this.getQueryParams();
  146. params.permissionId = this.permId;
  147. queryPermissionRule(params).then((res) => {
  148. if (res.success) {
  149. this.dataSource = res.result
  150. }
  151. })
  152. },
  153. searchReset() {
  154. this.queryParam = {}
  155. this.queryParam.permissionId = this.permId
  156. this.loadData(1);
  157. },
  158. onClose() {
  159. this.visible = false
  160. },
  161. // 根据屏幕变化,设置抽屉尺寸
  162. resetScreenSize() {
  163. let screenWidth = document.body.clientWidth
  164. if (screenWidth < 500) {
  165. this.drawerWidth = screenWidth
  166. } else {
  167. this.drawerWidth = 650
  168. }
  169. },
  170. getRowClassname(record){
  171. if(record.status!=1){
  172. return "data-rule-invalid"
  173. }
  174. }
  175. }
  176. }
  177. </script>
  178. <style>
  179. .data-rule-invalid{
  180. background: #f4f4f4;
  181. color: #bababa;
  182. }
  183. </style>