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