index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <div class="content-container">
  3. <el-row class="tool-bar">
  4. <el-col :span="12" class="left">
  5. <div class="content-title">
  6. Api接入管理
  7. </div>
  8. </el-col>
  9. <el-col :span="12" class="right">
  10. <el-input v-model="conditions.keywords" style="width: 200px;" class="filter-item" prefix-icon="el-icon-search" placeholder="请输入内容" @keyup.enter.native="getData" />
  11. <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-search" @click="getData">查询</el-button>
  12. <el-button type="primary" @click="handleAdd">添加</el-button>
  13. </el-col>
  14. </el-row>
  15. <el-table v-loading="listLoading" :data="dataList" fit style="width: 100%">
  16. <el-table-column type="index" align="center" label="序号" width="80" />
  17. <el-table-column label="名称" align="center" width="150">
  18. <template v-slot="{row}">
  19. <span>{{ row.ocName }}</span>
  20. </template>
  21. </el-table-column>
  22. <el-table-column label="APP ID" align="center" width="150">
  23. <template v-slot="{row}">
  24. <span>{{ row.accessAppId }}</span>
  25. </template>
  26. </el-table-column>
  27. <el-table-column label="Url" align="center" width="150">
  28. <template v-slot="{row}">
  29. <span>{{ row.accessUrl }}</span>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="APP Key" align="center" width="150">
  33. <template v-slot="{row}">
  34. <span>{{ row.accessAppKey }}</span>
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="APP Secret" align="center" width="150">
  38. <template v-slot="{row}">
  39. <span>{{ row.accessAppSecret }}</span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="Token">
  43. <template v-slot="{row}">
  44. <span>{{ row.accessToken }}</span>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="remark">
  48. <template v-slot="{row}">
  49. <span>{{ row.remark }}</span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column align="center" label="状态" width="150">
  53. <template v-slot="{row}">
  54. <div>
  55. <el-switch
  56. v-model="row.status"
  57. active-text="激活"
  58. inactive-text="未激活"
  59. :active-value="1"
  60. :inactive-value="0"
  61. @change="(status)=>handlerChangeStatus(status, row)"
  62. />
  63. </div>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width">
  67. <template v-slot="{row}">
  68. <el-button size="mini" @click="handleEdit(row)">修改</el-button>
  69. <el-button size="mini" type="danger" @click="handleDelete(row)">删除</el-button>
  70. </template>
  71. </el-table-column>
  72. </el-table>
  73. <div class="pagination-container">
  74. <pagination v-show="total>0" :total="total" :page.sync="conditions.page" :limit.sync="conditions.limit" @pagination="getData" />
  75. </div>
  76. <access ref="AddAccess" title="添加Api接入" @formSuccess="getData" />
  77. <access ref="EditAccess" title="编辑Api接入" @formSuccess="getData" />
  78. </div>
  79. </template>
  80. <script>
  81. import Access from './access'
  82. import { getAccessByPage, deleteAccessById, updateAccessStatus } from '@/api/system/accessApi'
  83. import Pagination from '@/components/Pagination'
  84. export default {
  85. name: 'AccessList',
  86. components: {
  87. Pagination,
  88. Access
  89. },
  90. data() {
  91. return {
  92. dataList: null,
  93. listLoading: false,
  94. total: 0,
  95. conditions: {
  96. page: 1,
  97. limit: 10,
  98. keywords: ''
  99. }
  100. }
  101. },
  102. mounted() {
  103. this.getData()
  104. },
  105. methods: {
  106. // 初始化
  107. getData() {
  108. this.listLoading = true
  109. getAccessByPage(this.conditions).then((resp) => {
  110. const { code, data, total, msg } = resp
  111. this.listLoading = false
  112. if (code === 200) {
  113. this.total = total
  114. this.dataList = data
  115. } else {
  116. this.$message.error(msg)
  117. }
  118. }).catch((error) => {
  119. console.log(error)
  120. })
  121. },
  122. // 添加
  123. handleAdd() {
  124. this.$refs['AddAccess'].showAddModel()
  125. },
  126. // 修改
  127. handleEdit(data) {
  128. const { accessId } = data
  129. this.$refs['EditAccess'].showEditModel(accessId)
  130. },
  131. // 更改 "Status"
  132. handlerChangeStatus(status, data) {
  133. const { accessId } = data
  134. updateAccessStatus(accessId, status).then((resp) => {
  135. const { code, msg } = resp
  136. if (code === 200) {
  137. this.$message.success(msg)
  138. } else {
  139. this.$message.error(msg)
  140. }
  141. }).catch((error) => {
  142. console.log(error)
  143. })
  144. },
  145. // 删除
  146. handleDelete(data) {
  147. const { accessId } = data
  148. this.$confirm('此操作将永久删除, 是否继续?', '提示', {
  149. confirmButtonText: '确定',
  150. cancelButtonText: '取消',
  151. type: 'warning'
  152. }).then(() => {
  153. deleteAccessById(accessId).then((resp) => {
  154. const { code, msg } = resp
  155. if (code === 200) {
  156. this.getData()
  157. this.$message.success(msg)
  158. } else {
  159. this.$message.error(msg)
  160. }
  161. }).catch((error) => {
  162. console.log(error)
  163. })
  164. }).catch(() => {
  165. this.$message.info('已取消删除')
  166. })
  167. }
  168. }
  169. }
  170. </script>