You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

selectGrampusImages.vue 7.6 kB

3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <div class="inline required field" :class="{ 'unite': benchmarkNew, 'min_title': benchmarkNew}">
  3. <label v-if="benchmarkNew" style="font-weight: normal;">镜像</label>
  4. <label v-else>镜像</label>
  5. <span v-if="benchmarkNew">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
  6. <input v-if="benchmarkNew" type="text" name="image" :value="imageAddress" style="width: 48.5%;"
  7. placeholder="选择镜像或输入镜像地址">
  8. <input v-else type="text" name="image" :value="imageAddress" placeholder="选择镜像或输入镜像地址">
  9. <el-button type="text" @click="dialogVisible = true" icon="el-icon-plus" style="color: #0366d6;">选择镜像
  10. </el-button>
  11. <el-dialog title="选择镜像" :visible.sync="dialogVisible" width="50%">
  12. <div class="ui icon input" style="z-index: 9999;position: absolute;right: 50px;height:30px;">
  13. <i class="search icon" style="cursor: pointer;pointer-events:auto"></i>
  14. <input type="text" placeholder="搜镜像Tag/描述/标签..." v-model="search">
  15. </div>
  16. <el-tabs v-model="activeName" @tab-click="handleClick">
  17. <el-tab-pane label="公开镜像" name="first" v-loading="loadingPublic">
  18. <div style="display: flex;align-items: center;justify-content: space-between;padding: 1rem 0;border-bottom:1px solid #F5F5F5"
  19. v-for="(publicData,index) in tableDataPublic" :key="index">
  20. <div style="width: 90%;">
  21. <div style="display: flex;align-items: center;justify-content: space-between;">
  22. <div style="display: flex;align-items: center;">
  23. <span class="panel_dataset_name text-over"
  24. style="margin-left: 0;">{{publicData.tag}} </span>
  25. <img v-if="publicData.type==5" src="/img/jian.svg" style="margin-left: 0.5rem;">
  26. </div>
  27. <div v-if="!!publicData.topics" class="text-over">
  28. <span v-for="(topic,index) in publicData.topics"
  29. class="ui repo-topic label topic">{{topic}}</span>
  30. </div>
  31. </div>
  32. <div style="margin-top: 8px;display: flex;">
  33. <a v-if="publicData.relAvatarLink||publicData.userName" :title="publicData.userName"
  34. style="cursor: default;">
  35. <img class="ui avatar mini image" style="width: 20px;height: 20px;"
  36. :src="publicData.relAvatarLink">
  37. </a>
  38. <a v-else><img class="ui avatar mini image" title="Ghost" src="/user/avatar/ghost/-1"
  39. style="width: 20px;height: 20px;"></a>
  40. <span class="panel_datset_desc">{{publicData.description}}</span>
  41. </div>
  42. </div>
  43. <div>
  44. <button class="ui primary basic button mini"
  45. @click.stop.prevent="selectImages(publicData.place,publicData.tag)">使用</button>
  46. </div>
  47. </div>
  48. <div class="ui container" style="margin-top:50px;text-align:center">
  49. <el-pagination background @current-change="handleCurrentChangePublic"
  50. :current-page="currentPagePublic" :page-size="pageSizePublic"
  51. layout="total, prev, pager, next" :total="totalNumPublic">
  52. </el-pagination>
  53. </div>
  54. </el-tab-pane>
  55. </el-tabs>
  56. </el-dialog>
  57. </div>
  58. </template>
  59. <script>
  60. const { _AppSubUrl, _StaticUrlPrefix, csrf } = window.config;
  61. export default {
  62. components: {
  63. },
  64. data() {
  65. return {
  66. dialogVisible: false,
  67. benchmarkNew: false,
  68. imageAddress: '',
  69. activeName: 'first',
  70. search: '',
  71. checked: false,
  72. currentPagePublic: 1,
  73. pageSizePublic: 5,
  74. totalNumPublic: 0,
  75. paramsPublic: { page: 1, pageSize: 5, q: '', recommend: false,cloudbrainType: 2 },
  76. tableDataPublic: [],
  77. loadingPublic: false,
  78. };
  79. },
  80. methods: {
  81. handleClick(tab, event) {
  82. this.search = ''
  83. if (tab.name == "first") {
  84. this.paramsPublic.q = ''
  85. this.getImageListPublic()
  86. }
  87. },
  88. tableHeaderStyle({ row, column, rowIndex, columnIndex }) {
  89. if (rowIndex === 0) {
  90. return 'background:#f5f5f6;color:#606266'
  91. }
  92. },
  93. handleCurrentChangePublic(val) {
  94. this.paramsPublic.page = val
  95. this.getImageListPublic()
  96. },
  97. getImageListPublic() {
  98. this.loadingPublic = true
  99. this.$axios.get('/explore/images/public', {
  100. params: this.paramsPublic
  101. }).then((res) => {
  102. this.totalNumPublic = res.data.count
  103. this.tableDataPublic = res.data.images
  104. this.loadingPublic = false
  105. })
  106. },
  107. searchName() {
  108. if (this.activeName == 'first') {
  109. this.paramsPublic.q = this.search
  110. this.paramsPublic.page = 1
  111. this.getImageListPublic()
  112. }
  113. },
  114. selectImages(place) {
  115. this.imageAddress = place
  116. this.dialogVisible = false
  117. },
  118. },
  119. watch: {
  120. search(val) {
  121. if (this.activeName == 'first') {
  122. this.paramsPublic.q = val
  123. this.getImageListPublic()
  124. }
  125. }
  126. },
  127. mounted() {
  128. this.getImageListPublic()
  129. if (location.href.indexOf('benchmark') !== -1 || location.href.indexOf('train-job') !== -1) {
  130. this.benchmarkNew = true
  131. }
  132. },
  133. created() {
  134. }
  135. };
  136. </script>
  137. <style scoped>
  138. .header-wrapper {
  139. background-color: #f5f5f6;
  140. padding-top: 15px;
  141. }
  142. .image_text {
  143. padding: 25px 0 55px 0;
  144. }
  145. #header {
  146. position: relative;
  147. top: -40px;
  148. }
  149. #success {
  150. background-color: #5bb973;
  151. color: white;
  152. }
  153. .text-over {
  154. overflow: hidden;
  155. text-overflow: ellipsis;
  156. vertical-align: middle;
  157. white-space: nowrap;
  158. }
  159. .image_title {
  160. display: inline-block;
  161. width: 80%;
  162. cursor: default;
  163. color: rgb(66, 98, 144);
  164. }
  165. .image_desc {
  166. -webkit-line-clamp: 2;
  167. -webkit-box-orient: vertical;
  168. display: -webkit-box;
  169. text-overflow: ellipsis;
  170. overflow: hidden;
  171. }
  172. .heart-stroke {
  173. stroke: #666;
  174. stroke-width: 2;
  175. fill: #fff
  176. }
  177. .stars_active {
  178. fill: #FA8C16 !important;
  179. stroke: #FA8C16 !important
  180. }
  181. </style>