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.3 kB

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