0a05c8cc87d9349a35536878cbe47d4834e7e67c.svn-base 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper">
  4. <a-form layout="inline">
  5. <a-row :gutter="48">
  6. <a-col :md="8" :sm="24">
  7. <a-form-item label="角色ID">
  8. <a-input placeholder="请输入"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="8" :sm="24">
  12. <a-form-item label="状态">
  13. <a-select placeholder="请选择" default-value="0">
  14. <a-select-option value="0">全部</a-select-option>
  15. <a-select-option value="1">正常</a-select-option>
  16. <a-select-option value="2">禁用</a-select-option>
  17. </a-select>
  18. </a-form-item>
  19. </a-col>
  20. <a-col :md="8" :sm="24">
  21. <span class="table-page-search-submitButtons">
  22. <a-button type="primary">查询</a-button>
  23. <a-button style="margin-left: 8px">重置</a-button>
  24. </span>
  25. </a-col>
  26. </a-row>
  27. </a-form>
  28. </div>
  29. <s-table
  30. ref="table"
  31. size="default"
  32. :columns="columns"
  33. :data="loadData"
  34. >
  35. <div
  36. slot="expandedRowRender"
  37. slot-scope="record"
  38. style="margin: 0">
  39. <a-row
  40. :gutter="24"
  41. :style="{ marginBottom: '12px' }">
  42. <a-col :span="12" v-for="(role, index) in record.permissions" :key="index" :style="{ marginBottom: '12px' }">
  43. <a-col :span="4">
  44. <span>{{ role.permissionName }}:</span>
  45. </a-col>
  46. <a-col :span="20" v-if="role.actionEntitySet.length > 0">
  47. <a-tag color="cyan" v-for="(action, k) in role.actionEntitySet" :key="k">{{ action.describe }}</a-tag>
  48. </a-col>
  49. <a-col :span="20" v-else>-</a-col>
  50. </a-col>
  51. </a-row>
  52. </div>
  53. <span slot="action" slot-scope="text, record">
  54. <a @click="$refs.modal.edit(record)">编辑</a>
  55. <a-divider type="vertical" />
  56. <a-dropdown>
  57. <a class="ant-dropdown-link">
  58. 更多 <a-icon type="down" />
  59. </a>
  60. <a-menu slot="overlay">
  61. <a-menu-item>
  62. <a href="javascript:;">详情</a>
  63. </a-menu-item>
  64. <a-menu-item>
  65. <a href="javascript:;">禁用</a>
  66. </a-menu-item>
  67. <a-menu-item>
  68. <a href="javascript:;">删除</a>
  69. </a-menu-item>
  70. </a-menu>
  71. </a-dropdown>
  72. </span>
  73. </s-table>
  74. <role-modal ref="modal" @ok="handleOk"></role-modal>
  75. </a-card>
  76. </template>
  77. <script>
  78. import STable from '@/components/table/'
  79. import RoleModal from './modules/RoleModal'
  80. export default {
  81. name: "TableList",
  82. components: {
  83. STable,
  84. RoleModal
  85. },
  86. data () {
  87. return {
  88. description: '列表使用场景:后台管理中的权限管理以及角色管理,可用于基于 RBAC 设计的角色权限控制,颗粒度细到每一个操作类型。',
  89. visible: false,
  90. form: null,
  91. mdl: {},
  92. // 高级搜索 展开/关闭
  93. advanced: false,
  94. // 查询参数
  95. queryParam: {},
  96. // 表头
  97. columns: [
  98. {
  99. title: '唯一识别码',
  100. dataIndex: 'id'
  101. },
  102. {
  103. title: '角色名称',
  104. dataIndex: 'name',
  105. },
  106. {
  107. title: '状态',
  108. dataIndex: 'status'
  109. },
  110. {
  111. title: '创建时间',
  112. dataIndex: 'createTime',
  113. sorter: true
  114. }, {
  115. title: '操作',
  116. width: '150px',
  117. dataIndex: 'action',
  118. scopedSlots: { customRender: 'action' },
  119. }
  120. ],
  121. // 加载数据方法 必须为 Promise 对象
  122. loadData: parameter => {
  123. return this.$http.get('/mock/api/role', {
  124. params: Object.assign(parameter, this.queryParam)
  125. }).then(res => {
  126. return res.result
  127. })
  128. },
  129. selectedRowKeys: [],
  130. selectedRows: []
  131. }
  132. },
  133. methods: {
  134. handleEdit (record) {
  135. this.mdl = Object.assign({}, record)
  136. this.mdl.permissions.forEach(permission => {
  137. permission.actionsOptions = permission.actionEntitySet.map(action => {
  138. return { label: action.describe, value: action.action, defaultCheck: action.defaultCheck }
  139. })
  140. })
  141. console.log(this.mdl)
  142. this.visible = true
  143. },
  144. handleOk () {
  145. // 新增/修改 成功时,重载列表
  146. this.$refs.table.refresh()
  147. },
  148. onChange (selectedRowKeys, selectedRows) {
  149. this.selectedRowKeys = selectedRowKeys
  150. this.selectedRows = selectedRows
  151. },
  152. toggleAdvanced () {
  153. this.advanced = !this.advanced
  154. },
  155. },
  156. watch: {
  157. /*
  158. 'selectedRows': function (selectedRows) {
  159. this.needTotalList = this.needTotalList.map(item => {
  160. return {
  161. ...item,
  162. total: selectedRows.reduce( (sum, val) => {
  163. return sum + val[item.dataIndex]
  164. }, 0)
  165. }
  166. })
  167. }
  168. */
  169. }
  170. }
  171. </script>