DockerRegistry.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <el-container>
  3. <el-header height="220">
  4. <h3>docker 仓库列表</h3>
  5. <el-row style="margin-top: 10px">
  6. <el-button type="success" size="mini" icon="el-icon-plus" @click="handleShowAdd">添加</el-button>
  7. </el-row>
  8. </el-header>
  9. <el-main>
  10. <el-table
  11. :data="dataList"
  12. border
  13. height="480"
  14. style="width: 100%"
  15. >
  16. <el-table-column
  17. prop="registryUrl"
  18. label="仓库地址"
  19. />
  20. <el-table-column
  21. prop="registryNamespace"
  22. label="命名空间"
  23. />
  24. <el-table-column
  25. prop="repoAuthName"
  26. label="仓库认证名"
  27. />
  28. <el-table-column
  29. prop="useCount"
  30. label="使用量"
  31. >
  32. <template slot-scope="scope">
  33. <el-tag disable-transitions>
  34. <span>{{ scope.row.useCount }}</span>
  35. </el-tag>
  36. <el-button
  37. style="margin-top: 5px; margin-left: 5px"
  38. size="mini"
  39. type="success"
  40. @click="handleUsage(scope.row)"
  41. >查看</el-button>
  42. </template>
  43. </el-table-column>
  44. <el-table-column
  45. fixed="right"
  46. label="操作"
  47. width="120"
  48. >
  49. <template slot-scope="scope">
  50. <el-button
  51. size="mini"
  52. type="danger"
  53. @click="handleEdit(scope.$index, scope.row)"
  54. >删除</el-button>
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. <el-pagination
  59. background
  60. :small="screenWidth <= 768"
  61. layout="prev, pager, next"
  62. :page-size="pageSize"
  63. :current-page="currentPage"
  64. :total="totalSize"
  65. @current-change="handleCurrentChange"
  66. @prev-click="handleCurrentChange"
  67. @next-click="handleCurrentChange"
  68. />
  69. </el-main>
  70. <el-dialog
  71. title="添加 docker 仓库"
  72. append-to-body
  73. :visible.sync="showAddDialog"
  74. center
  75. >
  76. <registry-add-card
  77. @close="showAddDialog = false"
  78. @success="onAddSuccess"
  79. />
  80. </el-dialog>
  81. </el-container>
  82. </template>
  83. <script>
  84. import RegistryAddCard from '@/components/card/RegistryAddCard.vue'
  85. import {
  86. deleteDockerRegistry,
  87. getDockerRegistryList,
  88. } from '@/api/devops'
  89. export default {
  90. name: 'DockerRegistry',
  91. components: {
  92. RegistryAddCard
  93. },
  94. data() {
  95. return {
  96. queryInfo: {
  97. scope: null,
  98. pn: 1
  99. },
  100. // 屏幕宽度, 为了控制分页条的大小
  101. screenWidth: document.body.clientWidth,
  102. currentPage: 1,
  103. pageSize: 10,
  104. totalSize: 0,
  105. dataList: [],
  106. // **********************************************************************
  107. showAddDialog: false
  108. }
  109. },
  110. created() {
  111. document.title = 'docker 仓库列表'
  112. this.getData()
  113. },
  114. methods: {
  115. handleCurrentChange(pageNumber) {
  116. this.currentPage = pageNumber
  117. this.getData()
  118. // 回到顶部
  119. scrollTo(0, 0)
  120. },
  121. getData() {
  122. this.dataList = []
  123. getDockerRegistryList(this.currentPage).then(resp => {
  124. if (resp.code === 0) {
  125. const respData = resp.data
  126. this.dataList = respData.list
  127. this.totalSize = respData.totalSize
  128. } else {
  129. this.$message.error(resp.msg)
  130. }
  131. }).catch(error => {
  132. this.$message.error(error.message)
  133. })
  134. },
  135. handleShowAdd() {
  136. this.showAddDialog = true
  137. },
  138. onAddSuccess() {
  139. this.showAddDialog = false
  140. },
  141. handleEdit(index, row) {
  142. this.$confirm('确定要删除 ' + row.registryUrl + '?', '提示', {
  143. confirmButtonText: '确定',
  144. cancelButtonText: '取消',
  145. type: 'warning'
  146. }).then(() => {
  147. const formData = new FormData()
  148. formData.append('id', row.id)
  149. deleteDockerRegistry(formData).then(resp => {
  150. this.$message.info(resp.msg)
  151. this.getData()
  152. }).catch(error => {
  153. this.$message.error(error.message)
  154. })
  155. }).catch(() => {
  156. this.$message({
  157. type: 'info',
  158. message: '已取消'
  159. })
  160. })
  161. },
  162. handleUsage(row) {
  163. this.$message.info('handleUsage')
  164. }
  165. }
  166. }
  167. </script>
  168. <style>
  169. </style>