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