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.

selectDataset.vue 38 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
2 years ago
3 years ago
2 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
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 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
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 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
2 years ago
3 years ago
3 years ago
2 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
2 years ago
3 years ago
2 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
2 years ago
3 years ago
2 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
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 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
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 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
2 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
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 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
2 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
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
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 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
3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216
  1. <template>
  2. <div
  3. class="inline field"
  4. :class="{
  5. dataset_flex: confirmDatasetList && confirmFlag,
  6. required: required,
  7. margin_b_0: benchmarkNew,
  8. }"
  9. >
  10. <label
  11. v-if="benchmarkNew"
  12. class="label-fix-width"
  13. style="font-weight: normal"
  14. >{{ i18n.dataset_label }}</label
  15. >
  16. <label v-else>{{ i18n.dataset_label }}</label>
  17. <span
  18. :class="
  19. benchmarkNew === true ? 'dataset-train-span' : 'dataset-debug-span'
  20. "
  21. v-if="confirmDatasetList && confirmFlag"
  22. >
  23. <input type="hidden" name="attachment" :value="confirmDatasetList" />
  24. <div class="multi-dataset-box">
  25. <span
  26. v-for="(item, index) in confirmChecklist"
  27. :key="index"
  28. class="select-dataset-label"
  29. :title="item"
  30. style="padding: 0.2rem 0"
  31. >{{ item }};
  32. </span>
  33. </div>
  34. </span>
  35. <span v-else>
  36. <input
  37. v-if="benchmarkNew"
  38. type="text"
  39. class="disabled"
  40. style="width: 48.5%"
  41. :placeholder="i18n.dataset_select_placeholder"
  42. required
  43. />
  44. <input
  45. v-else
  46. type="text"
  47. class="disabled"
  48. :required="required"
  49. :placeholder="i18n.dataset_select_placeholder"
  50. />
  51. </span>
  52. <el-button
  53. type="text"
  54. @click="openDataset"
  55. icon="el-icon-plus"
  56. :class="
  57. confirmFlag && confirmDatasetList
  58. ? 'select-dataset-button'
  59. : 'select-dataset-button-color'
  60. "
  61. >{{ i18n.dataset_select }}
  62. </el-button>
  63. <el-dialog
  64. :title="i18n.dataset_select"
  65. :visible.sync="dialogVisible"
  66. :width="dialogWidth"
  67. >
  68. <div class="ui icon input dataset-search-vue">
  69. <i
  70. class="search icon"
  71. style="cursor: pointer; pointer-events: auto"
  72. @click="searchName"
  73. ></i>
  74. <input
  75. type="text"
  76. :placeholder="i18n.dataset_search_placeholder"
  77. v-model="search"
  78. @keydown.enter.stop.prevent="searchName"
  79. />
  80. </div>
  81. <el-row>
  82. <el-col
  83. :span="17"
  84. style="
  85. padding-right: 1rem;
  86. border-right: 1px solid #f5f5f6;
  87. position: relative;
  88. "
  89. >
  90. <el-tabs v-model="activeName" @tab-click="handleClick">
  91. <!-- 当前项目的数据集 -->
  92. <el-tab-pane
  93. :label="i18n.dataset_current_repo"
  94. name="first"
  95. v-loading="loadingCurrent"
  96. >
  97. <el-row>
  98. <el-tree
  99. :data="currentDatasetList"
  100. ref="currentTree"
  101. highlight-current
  102. show-checkbox
  103. node-key="id"
  104. :default-expanded-keys="initCurrentTreeNode"
  105. :props="defaultProps"
  106. :index="20"
  107. accordion
  108. @check="onCheck"
  109. >
  110. <span slot-scope="{ node, data }" class="slot-wrap">
  111. <span v-if="data.parent" class="custom-tree-node">
  112. <el-tooltip v-if="data.Description" placement="top-start">
  113. <div slot="content" class="multiple-wrap">
  114. {{ data.Description }}
  115. </div>
  116. <span class="dataset-title dataset-nowrap"
  117. ><div class="dataset_flex">
  118. <span
  119. style="flex: inherit"
  120. class="dataset-nowrap"
  121. >{{ node.label }}</span
  122. >
  123. <img
  124. v-if="data.Recommend"
  125. style="margin-left: 0.4rem"
  126. src="/img/jian.svg"
  127. />
  128. </div>
  129. </span>
  130. </el-tooltip>
  131. <span v-else class="dataset-title dataset-nowrap"
  132. ><div class="dataset_flex">
  133. <span style="flex: inherit" class="dataset-nowrap">{{
  134. node.label
  135. }}</span>
  136. <img
  137. v-if="data.Recommend"
  138. style="margin-left: 0.4rem"
  139. src="/img/jian.svg"
  140. />
  141. </div>
  142. </span>
  143. <span
  144. class="dataset-repolink dataset-nowrap"
  145. @click.stop="return false;"
  146. >
  147. <i
  148. class="ri-links-line"
  149. style="color: #21ba45; margin-right: 0.3rem"
  150. :title="i18n.dataset_relate"
  151. v-if="
  152. '/' + data.Repo.OwnerName + '/' + data.Repo.Name !==
  153. repoLink
  154. "
  155. ></i>
  156. <a
  157. :href="
  158. '/' +
  159. data.Repo.OwnerName +
  160. '/' +
  161. data.Repo.Name +
  162. '/datasets'
  163. "
  164. target="_blank"
  165. :title="data.Repo.OwnerName + '/' + data.Repo.Alias"
  166. >{{ data.Repo.OwnerName }}/{{ data.Repo.Alias }}</a
  167. >
  168. </span>
  169. </span>
  170. <span v-else style="display: flex">
  171. <span class="dataset-nowrap" :title="node.label">
  172. {{ node.label }}
  173. </span>
  174. <span
  175. class="zip-loading"
  176. v-if="data.DecompressState === 2"
  177. >
  178. {{ i18n.dataset_unziping }}
  179. </span>
  180. <span
  181. class="unzip-failed"
  182. v-if="data.DecompressState === 3"
  183. >
  184. {{ i18n.dataset_unzip_failed }}
  185. </span>
  186. </span>
  187. </span>
  188. </el-tree>
  189. <div></div>
  190. </el-row>
  191. <div
  192. class="ui container"
  193. style="margin-top: 25px; text-align: center"
  194. >
  195. <el-pagination
  196. background
  197. @current-change="currentChangePage"
  198. :current-page="initCurrentPage"
  199. :page-size="5"
  200. layout="total, prev, pager, next"
  201. :total="totalNumCurrent"
  202. >
  203. </el-pagination>
  204. </div>
  205. </el-tab-pane>
  206. <!-- 我上传的数据集 -->
  207. <el-tab-pane
  208. :label="i18n.dataset_my_upload"
  209. name="second"
  210. v-loading="loadingMy"
  211. >
  212. <el-row>
  213. <el-tree
  214. :data="myDatasetList"
  215. ref="myTree"
  216. highlight-current
  217. show-checkbox
  218. node-key="id"
  219. :default-expanded-keys="initMyTreeNode"
  220. :props="defaultProps"
  221. :index="20"
  222. accordion
  223. @check="onCheck"
  224. >
  225. <span slot-scope="{ node, data }" class="slot-wrap">
  226. <span v-if="data.parent" class="custom-tree-node">
  227. <el-tooltip v-if="data.Description" placement="top-start">
  228. <div slot="content" class="multiple-wrap">
  229. {{ data.Description }}
  230. </div>
  231. <span class="dataset-title dataset-nowrap"
  232. ><div class="dataset_flex">
  233. <span
  234. style="flex: inherit"
  235. class="dataset-nowrap"
  236. >{{ node.label }}</span
  237. >
  238. <img
  239. v-if="data.Recommend"
  240. style="margin-left: 0.4rem"
  241. src="/img/jian.svg"
  242. />
  243. </div>
  244. </span>
  245. </el-tooltip>
  246. <span v-else class="dataset-title dataset-nowrap"
  247. ><div class="dataset_flex">
  248. <span style="flex: inherit" class="dataset-nowrap">{{
  249. node.label
  250. }}</span>
  251. <img
  252. v-if="data.Recommend"
  253. style="margin-left: 0.4rem"
  254. src="/img/jian.svg"
  255. />
  256. </div>
  257. </span>
  258. <span
  259. class="dataset-repolink dataset-nowrap"
  260. @click.stop="return false;"
  261. >
  262. <a
  263. :href="
  264. '/' +
  265. data.Repo.OwnerName +
  266. '/' +
  267. data.Repo.Name +
  268. '/datasets'
  269. "
  270. target="_blank"
  271. :title="data.Repo.OwnerName + '/' + data.Repo.Alias"
  272. >{{ data.Repo.OwnerName }}/{{ data.Repo.Alias }}</a
  273. >
  274. </span>
  275. </span>
  276. <span v-else style="display: flex">
  277. <span class="dataset-nowrap" :title="node.label">
  278. {{ node.label }}
  279. </span>
  280. <span
  281. class="zip-loading"
  282. v-if="data.DecompressState === 2"
  283. >
  284. {{ i18n.dataset_unziping }}
  285. </span>
  286. <span
  287. class="unzip-failed"
  288. v-if="data.DecompressState === 3"
  289. >
  290. {{ i18n.dataset_unzip_failed }}
  291. </span>
  292. </span>
  293. </span>
  294. </el-tree>
  295. <div></div>
  296. </el-row>
  297. <div
  298. class="ui container"
  299. style="margin-top: 25px; text-align: center"
  300. >
  301. <el-pagination
  302. background
  303. @current-change="myChangePage"
  304. :current-page="initMyPage"
  305. :page-size="5"
  306. layout="total, prev, pager, next"
  307. :total="totalNumMy"
  308. >
  309. </el-pagination>
  310. </div>
  311. </el-tab-pane>
  312. <!-- 公开的数据集 -->
  313. <el-tab-pane
  314. :label="i18n.dataset_public"
  315. name="third"
  316. v-loading="loadingPublic"
  317. >
  318. <el-row>
  319. <el-tree
  320. :data="publicDatasetList"
  321. ref="publicTree"
  322. highlight-current
  323. show-checkbox
  324. node-key="id"
  325. :default-expanded-keys="initPublicTreeNode"
  326. :props="defaultProps"
  327. :index="20"
  328. accordion
  329. @check="onCheck"
  330. >
  331. <span slot-scope="{ node, data }" class="slot-wrap">
  332. <span v-if="data.parent" class="custom-tree-node">
  333. <el-tooltip v-if="data.Description" placement="top-start">
  334. <div slot="content" class="multiple-wrap">
  335. {{ data.Description }}
  336. </div>
  337. <span class="dataset-title dataset-nowrap"
  338. ><div class="dataset_flex">
  339. <span
  340. style="flex: inherit"
  341. class="dataset-nowrap"
  342. >{{ node.label }}</span
  343. >
  344. <img
  345. v-if="data.Recommend"
  346. style="margin-left: 0.4rem"
  347. src="/img/jian.svg"
  348. />
  349. </div>
  350. </span>
  351. </el-tooltip>
  352. <span v-else class="dataset-title dataset-nowrap"
  353. ><div class="dataset_flex">
  354. <span style="flex: inherit" class="dataset-nowrap">{{
  355. node.label
  356. }}</span>
  357. <img
  358. v-if="data.Recommend"
  359. style="margin-left: 0.4rem"
  360. src="/img/jian.svg"
  361. />
  362. </div>
  363. </span>
  364. <span
  365. class="dataset-repolink dataset-nowrap"
  366. @click.stop="return false;"
  367. >
  368. <a
  369. :href="
  370. '/' +
  371. data.Repo.OwnerName +
  372. '/' +
  373. data.Repo.Name +
  374. '/datasets'
  375. "
  376. target="_blank"
  377. :title="data.Repo.OwnerName + '/' + data.Repo.Alias"
  378. >{{ data.Repo.OwnerName }}/{{ data.Repo.Alias }}</a
  379. >
  380. </span>
  381. </span>
  382. <span v-else style="display: flex">
  383. <span class="dataset-nowrap" :title="node.label">
  384. {{ node.label }}
  385. </span>
  386. <span
  387. class="zip-loading"
  388. v-if="data.DecompressState === 2"
  389. >
  390. {{ i18n.dataset_unziping }}
  391. </span>
  392. <span
  393. class="unzip-failed"
  394. v-if="data.DecompressState === 3"
  395. >
  396. {{ i18n.dataset_unzip_failed }}
  397. </span>
  398. </span>
  399. </span>
  400. </el-tree>
  401. <div></div>
  402. </el-row>
  403. <div
  404. class="ui container"
  405. style="margin-top: 25px; text-align: center"
  406. >
  407. <el-pagination
  408. background
  409. @current-change="publicChangePage"
  410. :current-page="initPublicPage"
  411. :page-size="5"
  412. layout="total, prev, pager, next"
  413. :total="totalNumPublic"
  414. >
  415. </el-pagination>
  416. </div>
  417. </el-tab-pane>
  418. <!-- 我点赞的数据集 -->
  419. <el-tab-pane
  420. :label="i18n.dataset_collected"
  421. name="four"
  422. v-loading="loadingFavorite"
  423. >
  424. <el-row>
  425. <el-tree
  426. :data="MyFavoriteDatasetList"
  427. ref="favoriteTree"
  428. highlight-current
  429. show-checkbox
  430. node-key="id"
  431. :default-expanded-keys="initFavoriteTreeNode"
  432. :props="defaultProps"
  433. :index="20"
  434. accordion
  435. @check="onCheck"
  436. >
  437. <span slot-scope="{ node, data }" class="slot-wrap">
  438. <span v-if="data.parent" class="custom-tree-node">
  439. <el-tooltip v-if="data.Description" placement="top-start">
  440. <div slot="content" class="multiple-wrap">
  441. {{ data.Description }}
  442. </div>
  443. <span class="dataset-title dataset-nowrap"
  444. ><div class="dataset_flex">
  445. <span
  446. style="flex: inherit"
  447. class="dataset-nowrap"
  448. >{{ node.label }}</span
  449. >
  450. <img
  451. v-if="data.Recommend"
  452. style="margin-left: 0.4rem"
  453. src="/img/jian.svg"
  454. />
  455. </div>
  456. </span>
  457. </el-tooltip>
  458. <span v-else class="dataset-title dataset-nowrap"
  459. ><div class="dataset_flex">
  460. <span style="flex: inherit" class="dataset-nowrap">{{
  461. node.label
  462. }}</span>
  463. <img
  464. v-if="data.Recommend"
  465. style="margin-left: 0.4rem"
  466. src="/img/jian.svg"
  467. />
  468. </div>
  469. </span>
  470. <span
  471. class="dataset-repolink dataset-nowrap"
  472. @click.stop="return false;"
  473. >
  474. <a
  475. :href="
  476. '/' +
  477. data.Repo.OwnerName +
  478. '/' +
  479. data.Repo.Name +
  480. '/datasets'
  481. "
  482. target="_blank"
  483. :title="data.Repo.OwnerName + '/' + data.Repo.Alias"
  484. >{{ data.Repo.OwnerName }}/{{ data.Repo.Alias }}</a
  485. >
  486. </span>
  487. </span>
  488. <span v-else style="display: flex">
  489. <span class="dataset-nowrap" :title="node.label">
  490. {{ node.label }}
  491. </span>
  492. <span
  493. class="zip-loading"
  494. v-if="data.DecompressState === 2"
  495. >
  496. {{ i18n.dataset_unziping }}
  497. </span>
  498. <span
  499. class="unzip-failed"
  500. v-if="data.DecompressState === 3"
  501. >
  502. {{ i18n.dataset_unzip_failed }}
  503. </span>
  504. </span>
  505. </span>
  506. </el-tree>
  507. <div></div>
  508. </el-row>
  509. <div
  510. class="ui container"
  511. style="margin-top: 25px; text-align: center"
  512. >
  513. <el-pagination
  514. background
  515. @current-change="favoriteChangePage"
  516. :current-page="initFavoritePage"
  517. :page-size="5"
  518. layout="total, prev, pager, next"
  519. :total="totalNumFavorite"
  520. >
  521. </el-pagination>
  522. </div>
  523. </el-tab-pane>
  524. </el-tabs>
  525. </el-col>
  526. <el-col
  527. :span="7"
  528. style="
  529. display: flex;
  530. flex-direction: column;
  531. height: 100%;
  532. right: 0;
  533. position: absolute;
  534. padding: 0 1.5rem;
  535. "
  536. >
  537. <div
  538. style="
  539. font-size: 14px;
  540. height: 40px;
  541. text-align: left;
  542. color: #0066ff;
  543. line-height: 40px;
  544. "
  545. >
  546. {{ i18n.dataset_selected }}
  547. </div>
  548. <div style="flex: 1; margin: 1.5rem 0; overflow-y: auto">
  549. <el-checkbox-group v-model="checkList">
  550. <el-checkbox
  551. v-for="(item, index) in selectDatasetArray"
  552. :key="index"
  553. :label="item.label"
  554. :title="item.label"
  555. @change="(checked) => changeCheckbox(checked, item)"
  556. ></el-checkbox>
  557. </el-checkbox-group>
  558. </div>
  559. <div style="text-align: end">
  560. <el-button
  561. @click.native="confirmDataset"
  562. size="small"
  563. style="
  564. background: #389e0d;
  565. color: #fff;
  566. border: 1px solid #389e0d;
  567. "
  568. >{{ i18n.dataset_ok }}</el-button
  569. >
  570. </div>
  571. </el-col>
  572. </el-row>
  573. </el-dialog>
  574. </div>
  575. </template>
  576. <script>
  577. const { _AppSubUrl, _StaticUrlPrefix, csrf } = window.config;
  578. export default {
  579. components: {},
  580. data() {
  581. return {
  582. defaultProps: {
  583. children: "Attachments",
  584. label: "label",
  585. },
  586. dialogWidth: "65%",
  587. dialogVisible: false,
  588. benchmarkNew: false,
  589. imageAddress: "",
  590. activeName: "first",
  591. search: "",
  592. required: true,
  593. i18n: {},
  594. type: 0,
  595. repoLink: "",
  596. selectDatasetArray: [],
  597. checkList: [],
  598. confirmChecklist: [],
  599. confirmDatasetList: "",
  600. confirmFlag: false,
  601. saveStatusList: [],
  602. // 初始化已选择的数据集列表
  603. hasSelectDatasetList: [],
  604. //当前项目数据集页面配置的初始化
  605. initCurrentPage: 1,
  606. totalNumCurrent: 0,
  607. paramsCurrent: { page: 1, q: "" },
  608. currentDatasetList: [],
  609. loadingCurrent: false,
  610. initCurrentTreeNode: [],
  611. //我上传的数据集页面配置的初始化
  612. initMyPage: 1,
  613. totalNumMy: 0,
  614. paramsMy: { page: 1, q: "" },
  615. myDatasetList: [],
  616. loadingMy: false,
  617. initMyTreeNode: [],
  618. //公开的数据集页面配置的初始化
  619. initPublicPage: 1,
  620. totalNumPublic: 0,
  621. paramsPublics: { page: 1, q: "" },
  622. publicDatasetList: [],
  623. loadingPublic: false,
  624. initPublicTreeNode: [],
  625. //我点赞的数据集页面配置的初始化
  626. initFavoritePage: 1,
  627. totalNumFavorite: 0,
  628. MyFavoriteDatasetList: [],
  629. paramsFavorite: { page: 1, q: "" },
  630. loadingFavorite: false,
  631. initFavoriteTreeNode: [],
  632. };
  633. },
  634. methods: {
  635. openDataset() {
  636. this.dialogVisible = true;
  637. if (!this.confirmDatasetList) {
  638. this.confirmFlag = false;
  639. }
  640. this.getCurrentRepoDataset();
  641. },
  642. handleClick(tab, event) {
  643. this.search = "";
  644. if (tab.name == "first") {
  645. // this.paramsPublic.q = "";
  646. this.getCurrentRepoDataset();
  647. }
  648. if (tab.name == "second") {
  649. this.getMyUploadDataset();
  650. }
  651. if (tab.name == "third") {
  652. this.getPublicDataset();
  653. }
  654. if (tab.name == "four") {
  655. this.getMyFavoriteDataset();
  656. }
  657. },
  658. //tree 勾选触发事件
  659. onCheck(data, checkedInfo) {
  660. this.hasSelectDatasetList = [];
  661. if (
  662. this.selectDatasetArray.length === 0 ||
  663. this.selectDatasetArray.every((item) => item.id !== data.id)
  664. ) {
  665. if (
  666. this.selectDatasetArray.some((item) => {
  667. return item.label.split(".")[0] === data.label.split(".")[0];
  668. })
  669. ) {
  670. this.$refs[data.ref].setChecked(data.id, false, false);
  671. this.$message.warning(this.i18n.dataset_not_equal_file);
  672. } else if (this.selectDatasetArray.length === 5) {
  673. this.$refs[data.ref].setChecked(data.id, false, false);
  674. this.$message.error(this.i18n.dataset_most);
  675. } else {
  676. this.selectDatasetArray.push(data);
  677. }
  678. } else {
  679. let index = this.selectDatasetArray.findIndex((item) => {
  680. return item.id === data.id;
  681. });
  682. this.selectDatasetArray.splice(index, 1);
  683. }
  684. this.checkList = this.selectDatasetArray.map((item) => {
  685. return item.label;
  686. });
  687. this.saveStatusList = this.selectDatasetArray.map((item) => {
  688. return item.id;
  689. });
  690. },
  691. //已选择数据集checkbox group 勾选事件
  692. changeCheckbox(checked, data) {
  693. this.$refs.currentTree.setChecked(data.id, false, false);
  694. this.$refs.myTree.setChecked(data.id, false, false);
  695. this.$refs.publicTree.setChecked(data.id, false, false);
  696. this.$refs.favoriteTree.setChecked(data.id, false, false);
  697. let index = this.selectDatasetArray.findIndex((item) => {
  698. return item.id === data.id;
  699. });
  700. this.selectDatasetArray.splice(index, 1);
  701. this.saveStatusList.splice(index, 1);
  702. },
  703. tableHeaderStyle({ row, column, rowIndex, columnIndex }) {
  704. if (rowIndex === 0) {
  705. return "background:#f5f5f6;color:#606266";
  706. }
  707. },
  708. currentChangePage(val) {
  709. this.paramsCurrent.page = val;
  710. this.getCurrentRepoDataset();
  711. },
  712. myChangePage(val) {
  713. this.paramsMy.page = val;
  714. this.getMyUploadDataset();
  715. },
  716. publicChangePage(val) {
  717. this.paramsPublics.page = val;
  718. this.getPublicDataset();
  719. },
  720. favoriteChangePage(val) {
  721. this.paramsFavorite.page = val;
  722. this.getMyFavoriteDataset();
  723. },
  724. getCurrentRepoDataset() {
  725. this.loadingCurrent = true;
  726. let url = this.repoLink + "/datasets/current_repo_m";
  727. this.paramsCurrent.type = this.type;
  728. this.$axios
  729. .get(url, {
  730. params: this.paramsCurrent,
  731. })
  732. .then((res) => {
  733. this.loadingCurrent = false;
  734. let data = JSON.parse(res.data.data);
  735. this.currentDatasetList = this.transformeTreeData(
  736. data,
  737. "currentTree",
  738. this.paramsCurrent.page
  739. );
  740. this.initCurrentTreeNode = this.currentDatasetList[0]?.id
  741. ? [this.currentDatasetList[0].id]
  742. : [];
  743. this.totalNumCurrent = parseInt(res.data.count);
  744. let setCheckedKeysList = this.currentDatasetList.reduce(
  745. (pre, cur) => {
  746. cur.Attachments.forEach((item) => {
  747. if (
  748. this.saveStatusList.includes(item.id) ||
  749. this.hasSelectDatasetList.includes(item.id)
  750. ) {
  751. pre.push(item.id);
  752. }
  753. });
  754. return pre;
  755. },
  756. []
  757. );
  758. this.$refs.currentTree.setCheckedKeys(setCheckedKeysList);
  759. })
  760. .catch((error) => {
  761. this.loadingCurrent = false;
  762. console.log(error);
  763. });
  764. },
  765. getMyUploadDataset() {
  766. this.loadingMy = true;
  767. let url = this.repoLink + "/datasets/my_datasets_m";
  768. this.paramsMy.type = this.type;
  769. this.$axios
  770. .get(url, {
  771. params: this.paramsMy,
  772. })
  773. .then((res) => {
  774. this.loadingMy = false;
  775. let data = JSON.parse(res.data.data);
  776. this.myDatasetList = this.transformeTreeData(
  777. data,
  778. "myTree",
  779. this.paramsMy.page
  780. );
  781. this.initMyTreeNode = this.myDatasetList[0]?.id
  782. ? [this.myDatasetList[0].id]
  783. : [];
  784. this.totalNumMy = parseInt(res.data.count);
  785. let setCheckedKeysList = this.myDatasetList.reduce((pre, cur) => {
  786. cur.Attachments.forEach((item) => {
  787. if (this.saveStatusList.includes(item.id)) {
  788. pre.push(item.id);
  789. }
  790. });
  791. return pre;
  792. }, []);
  793. this.$refs.myTree.setCheckedKeys(setCheckedKeysList);
  794. })
  795. .catch((error) => {
  796. console.log(error);
  797. });
  798. },
  799. getPublicDataset() {
  800. this.loadingPublic = true;
  801. let url = this.repoLink + "/datasets/public_datasets_m";
  802. this.paramsPublics.type = this.type;
  803. this.$axios
  804. .get(url, {
  805. params: this.paramsPublics,
  806. })
  807. .then((res) => {
  808. this.loadingPublic = false;
  809. let data = JSON.parse(res.data.data);
  810. this.publicDatasetList = this.transformeTreeData(
  811. data,
  812. "publicTree",
  813. this.paramsPublics.page
  814. );
  815. this.initPublicTreeNode = this.publicDatasetList[0]?.id
  816. ? [this.publicDatasetList[0].id]
  817. : [];
  818. this.totalNumPublic = parseInt(res.data.count);
  819. let setCheckedKeysList = this.publicDatasetList.reduce((pre, cur) => {
  820. cur.Attachments.forEach((item) => {
  821. if (this.saveStatusList.includes(item.id)) {
  822. pre.push(item.id);
  823. }
  824. });
  825. return pre;
  826. }, []);
  827. this.$refs.publicTree.setCheckedKeys(setCheckedKeysList);
  828. })
  829. .catch((error) => {
  830. this.loadingPublic = false;
  831. console.log(error);
  832. });
  833. },
  834. getMyFavoriteDataset() {
  835. this.loadingFavorite = true;
  836. let url = this.repoLink + "/datasets/my_favorite_m";
  837. this.paramsFavorite.type = this.type;
  838. this.$axios
  839. .get(url, {
  840. params: this.paramsFavorite,
  841. })
  842. .then((res) => {
  843. this.loadingFavorite = false;
  844. let data = JSON.parse(res.data.data);
  845. this.MyFavoriteDatasetList = this.transformeTreeData(
  846. data,
  847. "favoriteTree",
  848. this.paramsFavorite.page
  849. );
  850. this.initFavoriteTreeNode = this.MyFavoriteDatasetList[0]?.id
  851. ? [this.MyFavoriteDatasetList[0].id]
  852. : [];
  853. this.totalNumFavorite = parseInt(res.data.count);
  854. let setCheckedKeysList = this.MyFavoriteDatasetList.reduce(
  855. (pre, cur) => {
  856. cur.Attachments.forEach((item) => {
  857. if (this.saveStatusList.includes(item.id)) {
  858. pre.push(item.id);
  859. }
  860. });
  861. return pre;
  862. },
  863. []
  864. );
  865. this.$refs.favoriteTree.setCheckedKeys(setCheckedKeysList);
  866. })
  867. .catch((error) => {
  868. this.loadingFavorite = false;
  869. console.log(error);
  870. });
  871. },
  872. transformeTreeData(data, ref, page) {
  873. return data.reduce((preParent, curParent) => {
  874. curParent.id = curParent.ID;
  875. curParent.disabled = true;
  876. curParent.parent = true;
  877. curParent.label = curParent.Title;
  878. let childrenData = curParent.Attachments.reduce(
  879. (preChild, curchild) => {
  880. curchild.id = curchild.UUID;
  881. if (curchild.DecompressState !== 1) {
  882. curchild.disabled = true;
  883. }
  884. curchild.ref = ref;
  885. curchild.label = curchild.Name;
  886. preChild.push(curchild);
  887. return preChild;
  888. },
  889. []
  890. );
  891. preParent.push(curParent);
  892. return preParent;
  893. }, []);
  894. },
  895. searchName() {
  896. if (this.activeName == "first") {
  897. this.paramsCurrent.q = this.search;
  898. this.paramsCurrent.page = 1;
  899. this.getCurrentRepoDataset();
  900. }
  901. if (this.activeName == "second") {
  902. this.paramsMy.q = this.search;
  903. this.paramsMy.page = 1;
  904. this.getMyUploadDataset();
  905. }
  906. if (this.activeName == "third") {
  907. this.paramsPublics.q = this.search;
  908. this.paramsPublics.page = 1;
  909. this.getPublicDataset();
  910. }
  911. if (this.activeName == "four") {
  912. this.paramsFavorite.q = this.search;
  913. this.paramsFavorite.page = 1;
  914. this.getMyFavoriteDataset();
  915. }
  916. return false;
  917. },
  918. confirmDataset() {
  919. this.confirmDatasetList = this.saveStatusList.join(";");
  920. this.confirmChecklist = this.checkList;
  921. this.dialogVisible = false;
  922. this.confirmFlag = true;
  923. },
  924. setDialogWidth() {
  925. const cWidth = document.body.clientWidth;
  926. if (cWidth > 1600) {
  927. this.dialogWidth = "1200px";
  928. } else if (cWidth < 1600 && 1200 < cWidth) {
  929. this.dialogWidth = "1127px";
  930. } else if (992 < cWidth && cWidth < 1200) {
  931. this.dialogWidth = "993px";
  932. } else {
  933. this.dialogWidth = "723px";
  934. }
  935. },
  936. },
  937. watch: {
  938. search(val) {
  939. if (!val) {
  940. switch (this.activeName) {
  941. case "first": {
  942. this.paramsCurrent.q = val;
  943. this.getCurrentRepoDataset();
  944. break;
  945. }
  946. case "second": {
  947. this.paramsMy.q = val;
  948. this.getMyUploadDataset();
  949. break;
  950. }
  951. case "third": {
  952. this.paramsPublics.q = val;
  953. this.getPublicDataset();
  954. break;
  955. }
  956. case "four": {
  957. this.paramsFavorite.q = val;
  958. this.getMyFavoriteDataset();
  959. break;
  960. }
  961. default:
  962. console.log("error");
  963. }
  964. }
  965. },
  966. },
  967. mounted() {
  968. this.type = $(".cloudbrain-type").data("cloudbrain-type");
  969. this.repoLink = $(".cloudbrain-type").data("repo-link");
  970. if ($(".cloudbrain-type").data("dataset-uuid")) {
  971. this.hasSelectDatasetList = $(".cloudbrain-type")
  972. .data("dataset-uuid")
  973. .split(";");
  974. let hasSelectDatasetName = $(".cloudbrain-type")
  975. .data("dataset-name")
  976. .split(";");
  977. if (
  978. this.hasSelectDatasetList.length !== 0 &&
  979. hasSelectDatasetName[0] !== ""
  980. ) {
  981. this.saveStatusList = this.hasSelectDatasetList;
  982. this.checkList = hasSelectDatasetName;
  983. this.hasSelectDatasetList.forEach((item, index) => {
  984. this.selectDatasetArray.push({
  985. id: item,
  986. label: hasSelectDatasetName[index],
  987. });
  988. });
  989. }
  990. this.confirmDataset();
  991. }
  992. if (
  993. location.href.indexOf("benchmark") !== -1 ||
  994. location.href.indexOf("train-job") !== -1 ||
  995. location.href.indexOf("inference") !== -1
  996. ) {
  997. this.benchmarkNew = true;
  998. }
  999. if (
  1000. location.href.indexOf("modelarts/notebook/create") !== -1 ||
  1001. location.href.indexOf("/cloudbrain/create") !== -1
  1002. ) {
  1003. this.required = false;
  1004. }
  1005. window.onresize = () => {
  1006. return (() => {
  1007. this.setDialogWidth();
  1008. })();
  1009. };
  1010. },
  1011. created() {
  1012. this.setDialogWidth();
  1013. if (document.documentElement.attributes["lang"].nodeValue == "en-US") {
  1014. this.i18n = this.$locale.US;
  1015. } else {
  1016. this.i18n = this.$locale.CN;
  1017. }
  1018. },
  1019. };
  1020. </script>
  1021. <style scoped>
  1022. .header-wrapper {
  1023. background-color: #f5f5f6;
  1024. padding-top: 15px;
  1025. }
  1026. .image_text {
  1027. padding: 25px 0 55px 0;
  1028. }
  1029. #header {
  1030. position: relative;
  1031. top: -40px;
  1032. }
  1033. #success {
  1034. background-color: #5bb973;
  1035. color: white;
  1036. }
  1037. .text-over {
  1038. overflow: hidden;
  1039. text-overflow: ellipsis;
  1040. vertical-align: middle;
  1041. white-space: nowrap;
  1042. }
  1043. .image_title {
  1044. display: inline-block;
  1045. width: 80%;
  1046. cursor: default;
  1047. color: rgb(66, 98, 144);
  1048. }
  1049. .image_desc {
  1050. -webkit-line-clamp: 2;
  1051. -webkit-box-orient: vertical;
  1052. display: -webkit-box;
  1053. text-overflow: ellipsis;
  1054. overflow: hidden;
  1055. }
  1056. .heart-stroke {
  1057. stroke: #666;
  1058. stroke-width: 2;
  1059. fill: #fff;
  1060. }
  1061. .stars_active {
  1062. fill: #fa8c16 !important;
  1063. stroke: #fa8c16 !important;
  1064. }
  1065. /deep/ .el-dialog__body {
  1066. position: relative;
  1067. }
  1068. .el-tree {
  1069. max-height: 400px;
  1070. overflow-y: auto;
  1071. overflow-x: hidden;
  1072. position: relative;
  1073. cursor: default;
  1074. background: #fff;
  1075. color: #606266;
  1076. font-family: SourceHanSansSC-medium;
  1077. }
  1078. .custom-tree-node {
  1079. display: flex;
  1080. align-items: center;
  1081. justify-content: space-between;
  1082. }
  1083. .custom-tree-node .dataset-title {
  1084. font-size: 14px;
  1085. color: #101010;
  1086. font-weight: 600;
  1087. flex: 1;
  1088. }
  1089. .custom-tree-node .dataset-repolink {
  1090. flex: 1;
  1091. text-align: right;
  1092. font-size: 12px;
  1093. }
  1094. .el-tree /deep/ .el-tree-node__content {
  1095. height: 40px;
  1096. background-color: #f5f5f6;
  1097. }
  1098. .el-tree /deep/ .el-tree-node__children .el-tree-node__content {
  1099. height: 30px;
  1100. background-color: #fff;
  1101. line-height: 20px;
  1102. font-size: 12px;
  1103. }
  1104. /deep/ .el-checkbox-group .el-checkbox {
  1105. max-width: 100%;
  1106. min-width: 80%;
  1107. }
  1108. /deep/ .el-checkbox-group .el-checkbox .el-checkbox__label {
  1109. max-width: 100%;
  1110. overflow: hidden;
  1111. vertical-align: middle;
  1112. text-overflow: ellipsis;
  1113. }
  1114. .dataset-nowrap {
  1115. overflow: hidden;
  1116. text-overflow: ellipsis;
  1117. }
  1118. .slot-wrap {
  1119. flex: 1;
  1120. padding-right: 2rem;
  1121. max-width: 93%;
  1122. }
  1123. .multiple-wrap {
  1124. -webkit-line-clamp: 3;
  1125. -webkit-box-orient: vertical;
  1126. display: -webkit-box;
  1127. max-width: 400px;
  1128. overflow: hidden;
  1129. }
  1130. .unzip-failed {
  1131. margin-left: 1rem;
  1132. color: red;
  1133. }
  1134. .zip-loading {
  1135. margin-left: 1rem;
  1136. color: #fcca00;
  1137. }
  1138. .dataset-search-vue {
  1139. z-index: 9999;
  1140. position: absolute;
  1141. right: 31%;
  1142. height: 30px;
  1143. top: 6px;
  1144. }
  1145. .select-dataset-label {
  1146. max-width: 100%;
  1147. overflow: hidden;
  1148. text-overflow: ellipsis;
  1149. margin-right: 1rem;
  1150. white-space: nowrap;
  1151. }
  1152. .dataset_flex {
  1153. display: flex;
  1154. align-items: center;
  1155. }
  1156. .dataset-debug-span {
  1157. display: inline-block;
  1158. width: 50%;
  1159. margin-left: 0.3rem;
  1160. }
  1161. .dataset-train-span {
  1162. display: inline-block;
  1163. width: 48.5%;
  1164. margin-left: 0.3rem;
  1165. }
  1166. .margin_b_0 {
  1167. margin-bottom: 0 !important;
  1168. }
  1169. .select-dataset-button {
  1170. margin-left: 0.3rem;
  1171. color: #0366d6;
  1172. }
  1173. .select-dataset-button-color {
  1174. color: #0366d6;
  1175. }
  1176. .multi-dataset-box {
  1177. border: 1px solid rgba(34, 36, 38, 0.15);
  1178. padding: 0.678571em 1em;
  1179. border-radius: 0.285714rem;
  1180. background: rgb(255, 255, 255);
  1181. display: flex;
  1182. flex-direction: column;
  1183. }
  1184. @media screen and (min-width: 1200px) and (max-width: 1600px) {
  1185. .dataset-search-vue {
  1186. top: -36px;
  1187. }
  1188. }
  1189. @media screen and (min-width: 1200px) and (max-width: 1400px) {
  1190. .multiple-wrap {
  1191. max-width: 200px;
  1192. }
  1193. }
  1194. </style>