index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <a-card :bordered="false">
  3. <content-header title="API权限"></content-header>
  4. <a-alert style="margin-bottom: 20px" :message="warningText" type="warning" show-icon />
  5. <div class="table-operator">
  6. <a-button type="primary" icon="plus" @click="handleAdd">新增</a-button>
  7. </div>
  8. <a-table
  9. rowKey="apiId"
  10. :columns="columns"
  11. :data-source="list"
  12. :loading="isLoading"
  13. :pagination="false"
  14. >
  15. <span class="actions" slot="action" slot-scope="text, item">
  16. <a @click="handleEdit(item)">编辑</a>
  17. <a @click="handleDelete(item)">删除</a>
  18. </span>
  19. </a-table>
  20. <add-form ref="AddForm" :apiList="list" @handleSubmit="handleRefresh" />
  21. <edit-form ref="EditForm" :apiList="list" @handleSubmit="handleRefresh" />
  22. </a-card>
  23. </template>
  24. <script>
  25. import * as Api from '@/api/store/api'
  26. import { ContentHeader, STable } from '@/components'
  27. import AddForm from './modules/AddForm'
  28. import EditForm from './modules/EditForm'
  29. export default {
  30. components: {
  31. ContentHeader,
  32. STable,
  33. AddForm,
  34. EditForm
  35. },
  36. data () {
  37. return {
  38. // 提示文字
  39. warningText: '此处用于管理商户后台的菜单数据,请勿对本页面数据进行更改(会导致系统无法更新升级)',
  40. // 正在加载
  41. isLoading: false,
  42. // 表头
  43. columns: [
  44. {
  45. title: '权限ID',
  46. dataIndex: 'apiId'
  47. // width: '25%',
  48. },
  49. {
  50. title: '权限名称',
  51. dataIndex: 'name'
  52. },
  53. {
  54. title: '权限url',
  55. dataIndex: 'url'
  56. },
  57. {
  58. title: '排序',
  59. dataIndex: 'sort'
  60. },
  61. {
  62. title: '添加时间',
  63. dataIndex: 'createTime'
  64. },
  65. {
  66. title: '操作',
  67. dataIndex: 'action',
  68. width: '150px',
  69. scopedSlots: { customRender: 'action' }
  70. }
  71. ],
  72. // 列表数据
  73. list: []
  74. }
  75. },
  76. created () {
  77. // 获取列表数据
  78. this.getListData()
  79. },
  80. methods: {
  81. /**
  82. * 获取列表数据
  83. */
  84. getListData () {
  85. this.isLoading = true
  86. Api.list().then(response => {
  87. this.list = response.data.list
  88. })
  89. .finally(() => this.isLoading = false)
  90. },
  91. /**
  92. * 新增权限
  93. */
  94. handleAdd () {
  95. this.$refs.AddForm.show()
  96. },
  97. /**
  98. * 编辑权限
  99. */
  100. handleEdit (item) {
  101. this.$refs.EditForm.show(item)
  102. },
  103. /**
  104. * 删除记录
  105. */
  106. handleDelete (item) {
  107. const self = this
  108. self.$confirm({
  109. title: '您确定要删除该记录吗?',
  110. content: '确认后将无法恢复',
  111. onOk () {
  112. // 确认删除
  113. return self.onSubmitDelete(item)
  114. }
  115. })
  116. },
  117. /**
  118. * 确认删除
  119. */
  120. onSubmitDelete (item) {
  121. return Api.deleted({ apiId: item['apiId'] })
  122. .then((result) => {
  123. this.$message.success(result.message)
  124. this.handleRefresh()
  125. })
  126. },
  127. /**
  128. * 刷新列表
  129. */
  130. handleRefresh () {
  131. this.getListData()
  132. }
  133. }
  134. }
  135. </script>