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
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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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. >{{i18n.image_label}}</label
  11. >
  12. <label v-else>{{i18n.image_label}}</label>
  13. <input
  14. v-if="benchmarkNew"
  15. type="text"
  16. name="image"
  17. :value="imageAddress"
  18. style="width: 48.5%"
  19. :placeholder="i18n.image_select_placeholder"
  20. />
  21. <input
  22. v-else
  23. type="text"
  24. name="image"
  25. :value="imageAddress"
  26. :placeholder="i18n.image_select_placeholder"
  27. />
  28. <el-button
  29. type="text"
  30. @click="dialogVisible = true"
  31. icon="el-icon-plus"
  32. style="color: #0366d6"
  33. >{{i18n.image_select}}
  34. </el-button>
  35. <el-dialog :title="i18n.image_select" :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="i18n.image_search_placeholder"
  47. v-model="search"
  48. />
  49. </div>
  50. <el-tabs v-model="activeName" @tab-click="handleClick">
  51. <el-tab-pane :label="i18n.image_public" 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. {{i18n.image_use}}
  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. i18n: {},
  170. };
  171. },
  172. methods: {
  173. handleClick(tab, event) {
  174. this.search = "";
  175. if (tab.name == "first") {
  176. this.paramsPublic.q = "";
  177. this.getImageListPublic();
  178. }
  179. },
  180. tableHeaderStyle({ row, column, rowIndex, columnIndex }) {
  181. if (rowIndex === 0) {
  182. return "background:#f5f5f6;color:#606266";
  183. }
  184. },
  185. handleCurrentChangePublic(val) {
  186. this.paramsPublic.page = val;
  187. this.getImageListPublic();
  188. },
  189. getImageListPublic() {
  190. this.loadingPublic = true;
  191. this.$axios
  192. .get("/explore/images/public", {
  193. params: this.paramsPublic,
  194. })
  195. .then((res) => {
  196. this.totalNumPublic = res.data.count;
  197. this.tableDataPublic = res.data.images;
  198. this.loadingPublic = false;
  199. });
  200. },
  201. searchName() {
  202. if (this.activeName == "first") {
  203. this.paramsPublic.q = this.search;
  204. this.paramsPublic.page = 1;
  205. this.getImageListPublic();
  206. }
  207. },
  208. selectImages(place) {
  209. this.imageAddress = place;
  210. this.dialogVisible = false;
  211. },
  212. },
  213. watch: {
  214. search(val) {
  215. if (this.activeName == "first") {
  216. this.paramsPublic.q = val;
  217. this.getImageListPublic();
  218. }
  219. },
  220. },
  221. mounted() {
  222. if (document.getElementById("ai_image_name")) {
  223. this.imageAddress = document.getElementById("ai_image_name").value;
  224. }
  225. this.getImageListPublic();
  226. if (
  227. location.href.indexOf("benchmark") !== -1 ||
  228. location.href.indexOf("train-job") !== -1
  229. ) {
  230. this.benchmarkNew = true;
  231. }
  232. },
  233. created() {
  234. if (document.documentElement.attributes["lang"].nodeValue == "en-US") {
  235. this.i18n = this.$locale.US;
  236. } else {
  237. this.i18n = this.$locale.CN;
  238. }
  239. },
  240. };
  241. </script>
  242. <style scoped>
  243. .header-wrapper {
  244. background-color: #f5f5f6;
  245. padding-top: 15px;
  246. }
  247. .image_text {
  248. padding: 25px 0 55px 0;
  249. }
  250. #header {
  251. position: relative;
  252. top: -40px;
  253. }
  254. #success {
  255. background-color: #5bb973;
  256. color: white;
  257. }
  258. .text-over {
  259. overflow: hidden;
  260. text-overflow: ellipsis;
  261. vertical-align: middle;
  262. white-space: nowrap;
  263. }
  264. .image_title {
  265. display: inline-block;
  266. width: 80%;
  267. cursor: default;
  268. color: rgb(66, 98, 144);
  269. }
  270. .image_desc {
  271. -webkit-line-clamp: 2;
  272. -webkit-box-orient: vertical;
  273. display: -webkit-box;
  274. text-overflow: ellipsis;
  275. overflow: hidden;
  276. }
  277. .heart-stroke {
  278. stroke: #666;
  279. stroke-width: 2;
  280. fill: #fff;
  281. }
  282. .stars_active {
  283. fill: #fa8c16 !important;
  284. stroke: #fa8c16 !important;
  285. }
  286. </style>