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