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