index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. <template>
  2. <div class="panorama con">
  3. <div class="top">
  4. <crumbs
  5. v-if="!lastestUsedSearchKey"
  6. :list="folderPath"
  7. :rootName="$i18n.t('gather.pano')"
  8. @click-path="onClickPath"
  9. />
  10. <div v-if="lastestUsedSearchKey" class="">{{$i18n.t("gather.pano")}}</div>
  11. </div>
  12. <div class="second-line">
  13. <template v-if="!searchKey">
  14. <div class="btn">
  15. <button @mouseover.stop="showList = true" @click="onUploadFile" class="ui-button submit">
  16. <span>{{ upload_material }}</span>
  17. <i
  18. class="iconfont icon-material_prompt"
  19. v-tooltip="pano_size"
  20. />
  21. <upload ref="uploadFile" :failString="pano_fail" :limitFailStr="pano_limit" accept-type=".jpg"
  22. media-type="image" :limit="120" @file-change="onFileChange"></upload>
  23. </button>
  24. </div>
  25. <button
  26. class="ui-button submit"
  27. @click="isShowNewFolder = true"
  28. >
  29. {{$i18n.t(`gather.new_folder`)}}
  30. </button>
  31. <button
  32. class="ui-button cancel"
  33. :class="{disable: selectedList.length === 0}"
  34. @click="onClickMoveFolder"
  35. >
  36. {{$i18n.t(`gather.move_folder`)}}
  37. </button>
  38. </template>
  39. <div class="filter">
  40. <div :class="{ active: isFilterFocus }" @focusin="onFilterFocus" @focusout="onFilterBlur">
  41. <i class="iconfont icon-works_search search"></i>
  42. <input type="text" v-model="searchKey" :placeholder="serch_material" />
  43. <i v-if="searchKey" @click="searchKey = ''" class="iconfont icontoast_red del"></i>
  44. </div>
  45. </div>
  46. </div>
  47. <div class="list">
  48. <tableList
  49. @selection-change="
  50. (data) => {
  51. selectedList = data;
  52. }
  53. "
  54. @request-more-data="getMoreMaterialItem"
  55. :canRequestMoreData="hasMoreData && !isRequestingMoreData"
  56. :header="tabHeader"
  57. :showLine="true"
  58. :selection="lastestUsedSearchKey ? false : true"
  59. :data="list"
  60. class="table-list"
  61. ref="table-list"
  62. >
  63. <!-- 插到tableList组件各个header插槽,并通过插槽的headerItem作用域拿到表头各项 -->
  64. <div slot-scope="{ headerItem }" slot="header">
  65. {{ headerItem.name && $i18n.t(`zh_key.${headerItem.name}`) }}
  66. </div>
  67. <!-- 内容各单元格 -->
  68. <div slot-scope="{ itemData, lineData, headerItem }" slot="tableItem" style="width: 100%">
  69. <!-- 操作型单元格 -->
  70. <div class="handle" v-if="headerItem.canclick">
  71. <i
  72. v-if="lineData.type !== 'dir'"
  73. class="iconfont icon-material_operation_image hover-tips"
  74. @click="(showCover = true), (popupItem = lineData)"
  75. >
  76. <div>
  77. <div class="remark">{{ edit_cover }}</div>
  78. </div>
  79. </i>
  80. <i
  81. class="iconfont icon-material_operation_editor hover-tips"
  82. @click="onClickRename(lineData)"
  83. >
  84. <div>
  85. <div class="remark">{{ rename }}</div>
  86. </div>
  87. </i>
  88. <i
  89. class="iconfont icon-material_operation_delete hover-tips-warn"
  90. @click="del(lineData)"
  91. >
  92. <div>
  93. <div class="remark">{{ deltips }}</div>
  94. </div>
  95. </i>
  96. </div>
  97. <!-- 图片型单元格 -->
  98. <div
  99. v-else-if="headerItem.type == 'image' && lineData.type !== 'dir'"
  100. class="img"
  101. @click="previewImage(lineData)"
  102. >
  103. <img :src="itemData + $imgsuffix"
  104. alt="" />
  105. </div>
  106. <div
  107. v-else-if="headerItem.type == 'image' && lineData.type === 'dir'"
  108. class="img dirIcon"
  109. >
  110. <img
  111. :src="require('@/assets/images/icons/folder-blue.png')"
  112. alt=""
  113. @click="onClickFolder(lineData)"
  114. />
  115. </div>
  116. <!-- 文字型单元格 -->
  117. <div
  118. v-else
  119. class="textItem"
  120. >
  121. <!-- 名称 -->
  122. <div v-if="headerItem.key === 'name'" class="name">
  123. <!-- 不是搜索出来的 -->
  124. <div v-if="!lastestUsedSearchKey" class="not-search-res">
  125. <!-- 文件夹名称 -->
  126. <div
  127. v-if="lineData.type === 'dir'"
  128. class="dirName"
  129. @click="onClickFolder(lineData)"
  130. >
  131. {{ itemData || "-" }}
  132. </div>
  133. <!-- 素材名称 -->
  134. <div v-else class="not-dir">
  135. {{ itemData || "-" }}
  136. </div>
  137. </div>
  138. <!-- end of 不是搜索出来的 -->
  139. <!-- 搜索出来的 -->
  140. <div v-if="lastestUsedSearchKey" class="search-res">
  141. <!-- 文件夹名称 -->
  142. <div
  143. v-if="lineData.type === 'dir'"
  144. class="dirName"
  145. >
  146. <div
  147. class="self-name"
  148. @click="onClickFolder(lineData)"
  149. >
  150. {{ itemData || "-" }}
  151. </div>
  152. <div class="parent-name-wrap">
  153. {{$i18n.t('gather.dir')}} <span class="parent-name" @click="onClickParentFolder(lineData)">{{lineData.dirId === 1 ? $i18n.t('gather.root_dir') : lineData.dirName}}</span>
  154. </div>
  155. </div>
  156. <!-- 素材名称 -->
  157. <div v-else class="not-dir">
  158. <div class="self-name">
  159. {{ itemData || "-" }}
  160. </div>
  161. <div class="parent-name-wrap">
  162. {{$i18n.t('gather.dir')}} <span class="parent-name" @click="onClickParentFolder(lineData)">{{lineData.dirId === 1 ? $i18n.t('gather.root_dir') : lineData.dirName}}</span>
  163. </div>
  164. </div>
  165. </div>
  166. <!-- end of 搜索出来的 -->
  167. </div>
  168. <!-- end of 名称 -->
  169. <!-- 不是名称 -->
  170. <div v-else class="not-name">
  171. {{ itemData || "-" }}
  172. </div>
  173. <!-- end of 不是名称 -->
  174. </div>
  175. <!-- end of 文字型单元格 -->
  176. </div>
  177. </tableList>
  178. <UploadTaskList
  179. class="upload-task-list"
  180. fileType="IMAGE"
  181. :taskList="uploadListForUI"
  182. :targetFolderId="lastestUsedSearchKey ? -1 : currentFolderId"
  183. @cancel-task="onCancelTask"
  184. />
  185. <div class="total-number" v-if="list.length !== 0 || hasMoreData">{{ had_load }}</div>
  186. <div class="nodata" v-if="list.length == 0 && !hasMoreData && lastestUsedSearchKey">
  187. <img :src="$noresult" alt="" />
  188. <span>{{ no_serch_result }}</span>
  189. </div>
  190. <div class="nodata" v-if="list.length == 0 && !hasMoreData && !lastestUsedSearchKey">
  191. <img :src="config.empty" alt="" />
  192. <span>{{ no_material_result }}</span>
  193. <button @click="$refs.uploadFile.click()" class="upload-btn-in-table">{{ upload_material }}</button>
  194. </div>
  195. </div>
  196. <CreateFolder
  197. v-if="isShowNewFolder"
  198. :validate=validateNewFolderName
  199. @close="isShowNewFolder = false"
  200. @submit="onSubmitNewFolder"
  201. />
  202. <RenameFolder
  203. v-if="isShowRenameFolder"
  204. :oldName="popupItem.name"
  205. :validate=validateRenameFolderName
  206. @close="isShowRenameFolder = false"
  207. @submit="onSubmitRenameFolder"
  208. />
  209. <MoveFolder
  210. v-if="isShowMoveFolder"
  211. :folderTree="folderTree"
  212. :selectedList="selectedList"
  213. @close="isShowMoveFolder = false"
  214. @submit="onSubmitMoveFolder"
  215. />
  216. <rename
  217. v-if="showRename"
  218. :item="popupItem"
  219. @rename="handleRename"
  220. @close="showRename = false"
  221. />
  222. <preview
  223. ref="image-previewer"
  224. :sceneCodeList="list.map(item => item.sceneCode)"
  225. :imageTitleList="list.map(item => item.name)"
  226. @click-delete="onClickDeleteInPreview"
  227. />
  228. <cover
  229. @panocover="handlePanoCover"
  230. :item="popupItem"
  231. v-if="showCover"
  232. @close="showCover = false"
  233. />
  234. </div>
  235. </template>
  236. <script>
  237. import config from "@/config";
  238. import tableList from "@/components/table/index.vue";
  239. import crumbs from "@/components/crumbs/index.vue";
  240. import { data } from "./pano";
  241. import rename from "../popup/rename";
  242. import preview from "../popup/panoImagePreviewer.vue";
  243. import cover from "../popup/cover";
  244. import Upload from "@/components/shared/uploads/UploadMultiple";
  245. import { getImgWH, changeByteUnit } from "@/utils/file";
  246. import UploadTaskList from "../components/uploadList1.1.0.vue";
  247. import { debounce } from "@/utils/other.js"
  248. import { mapState } from 'vuex';
  249. import { i18n } from "@/lang"
  250. import folderMixinFactory from "../folderMixinFactory.js";
  251. import {
  252. getMaterialList,
  253. uploadMaterial,
  254. editMaterial,
  255. delMaterial,
  256. uploadCover,
  257. checkMStatus,
  258. checkUserSize
  259. } from "@/api";
  260. const TYPE = "pano";
  261. const LONG_POLLING_INTERVAL = 5;
  262. const folderMixin = folderMixinFactory(TYPE)
  263. export default {
  264. mixins: [
  265. folderMixin,
  266. ],
  267. name: 'Pano',
  268. components: {
  269. tableList,
  270. crumbs,
  271. rename,
  272. cover,
  273. preview,
  274. Upload,
  275. UploadTaskList,
  276. },
  277. data() {
  278. return {
  279. upload_material: i18n.t("gather.upload_material"),
  280. serch_material: i18n.t("gather.serch_material"),
  281. no_serch_result: i18n.t("gather.no_serch_result"),
  282. no_material_result: i18n.t("gather.no_material_result"),
  283. pano_size: i18n.t("gather.pano_size"),
  284. pano_fail: i18n.t("gather.pano_fail"),
  285. pano_limit: i18n.t("gather.pano_limit"),
  286. edit_cover: i18n.t("gather.edit_cover"),
  287. rename: i18n.t("gather.rename"),
  288. deltips: i18n.t("gather.delete"),
  289. config,
  290. showRename: false,
  291. showCover: false,
  292. showList: false,
  293. popupItem: null,
  294. tabHeader: data,
  295. // 因为searchKey的变化经过debounce、异步请求的延时,才会反映到数据列表的变化上,所以是否显示、显示哪种无数据提示,也要等到数据列表变化后,根据数据列表是否为空,以及引发本次变化的那个searchKey瞬时值来决定。本变量就是用来保存那个瞬时值。
  296. lastestUsedSearchKey: '',
  297. isFilterFocus: false,
  298. searchKey: "",
  299. list: [],
  300. hasMoreData: true,
  301. isRequestingMoreData: false,
  302. };
  303. },
  304. computed: {
  305. ...mapState({
  306. uploadListForUI: 'uploadStatusListPano',
  307. }),
  308. needLongPolling() {
  309. return this.uploadListForUI.some((item) => {
  310. return item.status === 'LOADING' && item.ifKnowProgress === false
  311. })
  312. },
  313. had_load() {
  314. return i18n.t("gather.had_load", { msg: this.list.length })
  315. }
  316. },
  317. mounted() {
  318. },
  319. watch: {
  320. needLongPolling: {
  321. handler: function (newVal) {
  322. if (!newVal) {
  323. this.clearinter();
  324. } else {
  325. this.clearinter();
  326. this.interval = setInterval(() => {
  327. this._checkMStatus();
  328. }, LONG_POLLING_INTERVAL * 1000);
  329. }
  330. },
  331. immediate: true,
  332. },
  333. searchKey: {
  334. handler: function () {
  335. this.refreshListDebounced()
  336. },
  337. immediate: false,
  338. },
  339. },
  340. methods: {
  341. onUploadFile() {
  342. checkUserSize({}, (data) => {
  343. //判断已用是否大于3G
  344. if ((data.data / 1024 / 1024) > 3) {
  345. this.$alert({ content: i18n.t("tips_code.FAILURE_3024") });
  346. } else {
  347. this.$refs.uploadFile.click()
  348. }
  349. })
  350. },
  351. onFilterFocus() {
  352. this.isFilterFocus = true
  353. },
  354. onFilterBlur() {
  355. this.isFilterFocus = false
  356. },
  357. refreshListDebounced: debounce(function () {
  358. this.list = []
  359. this.isRequestingMoreData = false
  360. this.hasMoreData = true
  361. this.$refs['table-list'].requestMoreData()
  362. }, 500, false),
  363. clearinter() {
  364. this.interval && clearInterval(this.interval);
  365. this.interval = null;
  366. },
  367. handleRename(newName) {
  368. editMaterial(
  369. {
  370. id: this.popupItem.id,
  371. name: newName,
  372. },
  373. () => {
  374. this.$msg.success(i18n.t("gather.edit_success"));
  375. const index = this.list.findIndex((eachItem) => {
  376. return eachItem.id === this.popupItem.id
  377. })
  378. if (index >= 0) {
  379. this.list[index].name = newName
  380. } else {
  381. console.error('在素材列表里没找到要重命名的那一项!');
  382. }
  383. this.showRename = false;
  384. this.popupItem = null;
  385. }
  386. );
  387. },
  388. handlePanoCover(data) {
  389. if (data.indexOf("http") > -1) {
  390. this.showCover = false;
  391. this.popupItem = "";
  392. return;
  393. }
  394. uploadCover({ file: data, filename: "cover.jpg" }, (res) => {
  395. if (res.code == 0) {
  396. editMaterial(
  397. {
  398. id: this.popupItem.id,
  399. icon: res.data,
  400. },
  401. () => {
  402. this.$msg.success(i18n.t("gather.setting_success"));
  403. const index = this.list.findIndex((eachItem) => {
  404. return eachItem.id === this.popupItem.id
  405. })
  406. if (index >= 0) {
  407. this.isRequestingMoreData = true
  408. const lastestUsedSearchKey = this.searchKey
  409. getMaterialList(
  410. {
  411. dirId: this.currentFolderId,
  412. pageNum: index + 1,
  413. pageSize: 1,
  414. type: TYPE,
  415. },
  416. (data) => {
  417. const newData = data.data.list.map((i) => {
  418. i.fileSize = changeByteUnit(Number(i.fileSize));
  419. return i;
  420. });
  421. this.list.splice(index, 1, newData[0])
  422. this.showCover = false;
  423. this.popupItem = "";
  424. this.isRequestingMoreData = false
  425. this.lastestUsedSearchKey = lastestUsedSearchKey
  426. },
  427. () => {
  428. this.isRequestingMoreData = false
  429. this.lastestUsedSearchKey = lastestUsedSearchKey
  430. this.showCover = false;
  431. this.popupItem = "";
  432. }
  433. )
  434. } else {
  435. console.error('在素材列表里没找到要编辑封面的那一项!');
  436. this.showCover = false;
  437. this.popupItem = "";
  438. }
  439. }
  440. );
  441. }
  442. });
  443. },
  444. _checkMStatus() {
  445. let needPollingTaskList = this.uploadListForUI.filter((item) => item.status === 'LOADING' && item.ifKnowProgress === false);
  446. if (needPollingTaskList.length > 0) {
  447. checkMStatus(
  448. {
  449. ids: needPollingTaskList.map((item) => item.backendId),
  450. islongpolling: true,
  451. },
  452. (res) => {
  453. // 1切图中,2失败,3成功
  454. res.data.forEach(eachRes => {
  455. if (eachRes.status === 2) {
  456. const index = this.uploadListForUI.findIndex(eachTask => eachTask.backendId === eachRes.id)
  457. index >= 0 && (this.uploadListForUI[index].status = 'FAIL')
  458. index >= 0 && (this.uploadListForUI[index].statusText = this.$msg.success(i18n.t("gather.material_cutting_fail")))
  459. } else if (eachRes.status === 3) {
  460. const index = this.uploadListForUI.findIndex(eachTask => eachTask.backendId === eachRes.id)
  461. index >= 0 && (this.uploadListForUI.splice(index, 1))
  462. index >= 0 && this.refreshListDebounced()
  463. }
  464. });
  465. }
  466. );
  467. }
  468. },
  469. onClickRename(lineData) {
  470. this.popupItem = lineData
  471. if (lineData.type !== 'dir') {
  472. this.showRename = true
  473. } else {
  474. this.isShowRenameFolder = true
  475. }
  476. },
  477. del(item) {
  478. if (item.type === 'dir') {
  479. this.delFolder(item.id, (lastestUsedSearchKey) => {
  480. getMaterialList(
  481. {
  482. dirId: this.currentFolderId,
  483. pageNum: this.list.length,
  484. pageSize: 1,
  485. searchKey: this.searchKey,
  486. type: TYPE,
  487. },
  488. (data) => {
  489. const index = this.list.findIndex((eachItem) => {
  490. return eachItem.id === item.id
  491. })
  492. if (index >= 0) {
  493. this.list.splice(index, 1)
  494. const newData = data.data.list.map((i) => {
  495. i.fileSize = changeByteUnit(Number(i.fileSize));
  496. return i;
  497. });
  498. this.list = this.list.concat(newData)
  499. if (this.list.length === data.data.total) {
  500. this.hasMoreData = false
  501. }
  502. if (this.list.length === 0) {
  503. this.$refs['image-previewer'].onClickClose()
  504. }
  505. } else {
  506. console.error('在素材列表里没找到要删除的那一项!');
  507. }
  508. this.isRequestingMoreData = false
  509. this.lastestUsedSearchKey = lastestUsedSearchKey
  510. },
  511. () => {
  512. this.isRequestingMoreData = false
  513. this.lastestUsedSearchKey = lastestUsedSearchKey
  514. }
  515. )
  516. })
  517. } else {
  518. this.$confirm({
  519. title: i18n.t("gather.delete_material"),
  520. content: i18n.t("gather.comfirm_delete_material"),
  521. okText: i18n.t("gather.delete"),
  522. ok: () => {
  523. delMaterial(item.id, () => {
  524. this.$msg.success(i18n.t("gather.delete_success"));
  525. this.isRequestingMoreData = true
  526. const lastestUsedSearchKey = this.searchKey
  527. getMaterialList(
  528. {
  529. dirId: this.currentFolderId,
  530. pageNum: this.list.length,
  531. pageSize: 1,
  532. searchKey: this.searchKey,
  533. type: TYPE,
  534. },
  535. (data) => {
  536. const index = this.list.findIndex((eachItem) => {
  537. return eachItem.id === item.id
  538. })
  539. if (index >= 0) {
  540. this.list.splice(index, 1)
  541. const newData = data.data.list.map((i) => {
  542. i.fileSize = changeByteUnit(Number(i.fileSize));
  543. return i;
  544. });
  545. this.list = this.list.concat(newData)
  546. if (this.list.length === data.data.total) {
  547. this.hasMoreData = false
  548. }
  549. if (this.list.length === 0) {
  550. this.$refs['image-previewer'].onClickClose()
  551. }
  552. } else {
  553. console.error('在素材列表里没找到要删除的那一项!');
  554. }
  555. this.isRequestingMoreData = false
  556. this.lastestUsedSearchKey = lastestUsedSearchKey
  557. },
  558. () => {
  559. this.isRequestingMoreData = false
  560. this.lastestUsedSearchKey = lastestUsedSearchKey
  561. }
  562. )
  563. });
  564. },
  565. });
  566. }
  567. },
  568. previewImage(targetItem) {
  569. const index = this.list.findIndex((eachItem) => {
  570. return eachItem.id === targetItem.id
  571. })
  572. this.$refs['image-previewer'].show(index)
  573. },
  574. onFileChange(e) {
  575. e.files.forEach(async (eachFile, i) => {
  576. if (
  577. eachFile.type.indexOf("jpeg") <= -1
  578. ) {
  579. setTimeout(() => {
  580. this.$msg({
  581. message: `“${eachFile.name}”${i18n.t("gather.pano_fail")}`,
  582. type: "warning",
  583. });
  584. }, i * 100);
  585. return;
  586. }
  587. if (eachFile.name.substring(0, eachFile.name.lastIndexOf(".")).length > 50) {
  588. setTimeout(() => {
  589. this.$msg({
  590. message: `“${eachFile.name}”${i18n.t("gather.too_long_word")}`,
  591. type: "warning",
  592. });
  593. }, i * 100);
  594. return;
  595. }
  596. let WHRate = null
  597. try {
  598. const { width, height } = await getImgWH(eachFile)
  599. WHRate = width / height
  600. } catch (e) {
  601. console.error('获取图像宽高失败:', e)
  602. setTimeout(() => {
  603. this.$msg({
  604. message: `“${eachFile.name}”${i18n.t("gather.pano_fail")}`,
  605. type: "warning",
  606. });
  607. }, i * 100);
  608. return
  609. }
  610. if (WHRate !== 2) {
  611. setTimeout(() => {
  612. this.$msg({
  613. message: `“${eachFile.name}”${i18n.t("gather.pano_fail")}`,
  614. type: "warning",
  615. });
  616. }, i * 100);
  617. return
  618. }
  619. let itemInUploadList = {
  620. title: eachFile.name,
  621. ifKnowProgress: true,
  622. progress: 0,
  623. status: 'LOADING',
  624. statusText: i18n.t("gather.uploading_material"),
  625. uid: `u_${this.$randomWord(true, 8, 8)}`,
  626. abortHandler: null,
  627. backendId: '',
  628. parentFolderId: this.currentFolderId,
  629. };
  630. itemInUploadList.abortHandler = uploadMaterial(
  631. {
  632. dirId: this.currentFolderId,
  633. file: eachFile,
  634. tempId: itemInUploadList.uid,
  635. type: TYPE,
  636. },
  637. (response) => { // 上传成功
  638. itemInUploadList.statusText = i18n.t("gather.cutting")
  639. itemInUploadList.ifKnowProgress = false
  640. itemInUploadList.backendId = response.data.id
  641. },
  642. (err) => {
  643. if (err.statusText === 'abort') { // 用户取消了上传任务。
  644. const index = this.uploadListForUI.findIndex((eachItem) => {
  645. return eachItem.uid === itemInUploadList.uid
  646. })
  647. this.uploadListForUI.splice(index, 1)
  648. } else {
  649. itemInUploadList.status = 'FAIL'
  650. itemInUploadList.statusText = i18n.t("gather.material_upload_fail")
  651. }
  652. },
  653. (progress) => {
  654. itemInUploadList.progress = progress
  655. }
  656. )
  657. this.uploadListForUI.push(itemInUploadList);
  658. })
  659. },
  660. onCancelTask(uid) {
  661. const index = this.uploadListForUI.findIndex((eachItem) => {
  662. return eachItem.uid === uid
  663. })
  664. if (this.uploadListForUI[index].status === 'LOADING') {
  665. this.uploadListForUI[index].abortHandler.abort()
  666. } else {
  667. this.uploadListForUI.splice(index, 1)
  668. }
  669. },
  670. getMoreMaterialItem(islongpolling = null) {
  671. this.isRequestingMoreData = true
  672. const lastestUsedSearchKey = this.searchKey
  673. getMaterialList(
  674. {
  675. dirId: this.currentFolderId,
  676. pageNum: Math.floor(this.list.length / config.PAGE_SIZE) + 1,
  677. pageSize: config.PAGE_SIZE,
  678. searchKey: this.searchKey,
  679. type: TYPE,
  680. islongpolling
  681. },
  682. (data) => {
  683. const newData = data.data.list.map((i) => {
  684. if (i.type !== 'dir') {
  685. i.fileSize = changeByteUnit(Number(i.fileSize));
  686. }
  687. return i;
  688. });
  689. this.list = this.list.concat(newData)
  690. if (this.list.length === data.data.total) {
  691. this.hasMoreData = false
  692. }
  693. this.isRequestingMoreData = false
  694. this.lastestUsedSearchKey = lastestUsedSearchKey
  695. },
  696. () => {
  697. this.isRequestingMoreData = false
  698. this.lastestUsedSearchKey = lastestUsedSearchKey
  699. }
  700. );
  701. },
  702. onClickDeleteInPreview(index) {
  703. this.del(this.list[index])
  704. },
  705. },
  706. };
  707. </script>
  708. <style lang="less" scoped>
  709. </style>
  710. <style lang="less" scoped>
  711. @import "../style.less";
  712. </style>