materialListInMaterialSelector.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141
  1. <template>
  2. <div
  3. class="material-list"
  4. :class="{
  5. dark: isDarkTheme,
  6. }"
  7. >
  8. <crumbs
  9. class="crumbs"
  10. v-if="!searchKey"
  11. :isDarkTheme="isDarkTheme"
  12. :list="folderPath"
  13. :rootName="$i18n.t(`gather.${materialTypeAlias}`)"
  14. @click-path="onClickPath"
  15. />
  16. <div v-if="searchKey" class="crumbs">
  17. {{ $i18n.t(`gather.${materialTypeAlias}`) }}
  18. </div>
  19. <div class="table">
  20. <!-- <div class="table-head-row">
  21. <span
  22. class="table-head"
  23. :style="{
  24. width: '50px',
  25. }"
  26. >
  27. 1
  28. </span>
  29. <span
  30. class="table-head"
  31. v-for="(item, idx) in tableHeaders"
  32. :key="idx"
  33. :style="{
  34. width: columnWidthList[idx],
  35. }"
  36. >
  37. </span>
  38. </div> -->
  39. <div
  40. v-show="listLocalLength !== 0 || hasMoreData"
  41. class="table-body"
  42. v-infinite-scroll="requestMoreData"
  43. :infinite-scroll-disabled="!hasMoreData || isRequestingMoreData"
  44. >
  45. <!-- vuex中的上传中数据 -->
  46. <div v-for="(item, i) in uploadStatusList" :key="item.uid">
  47. <div
  48. class="table-body-row"
  49. v-if="item.parentFolderId === currentFolderId && !searchKey"
  50. @click="onClickRow"
  51. >
  52. <!-- 如果已经上传成功 -->
  53. <template v-if="item.status === 'SUCCESS'">
  54. <span class="table-data">
  55. <RadioOrCheckbox
  56. class="checkbox"
  57. :isLightTheme="!isDarkTheme"
  58. :isMultiSelection="isMultiSelection"
  59. :isCheckedInitial="
  60. select.some((i) => i.id === item.successInfo.id)
  61. "
  62. @change="(v) => selectItem(item.successInfo, v)"
  63. />
  64. </span>
  65. <span
  66. class="table-data"
  67. :style="{
  68. width: columnWidthList[idx] || '',
  69. }"
  70. v-for="(tableItemStructure, idx) in tableHeaders"
  71. :key="idx"
  72. >
  73. <div v-if="tableItemStructure.type" class="list-img">
  74. <slot
  75. name="materialUploadSuccessIcon"
  76. :uploadInfo="item"
  77. :tableItemStructure="tableItemStructure"
  78. >
  79. </slot>
  80. </div>
  81. <span
  82. v-else-if="tableItemStructure.key === 'name'"
  83. class="name"
  84. >
  85. <div
  86. class="name-inner ellipsis"
  87. v-title="item.successInfo[tableItemStructure.key]"
  88. >
  89. {{ item.successInfo[tableItemStructure.key] }}
  90. </div>
  91. </span>
  92. <span v-else class="ellipsis">
  93. {{ item.successInfo[tableItemStructure.key] }}
  94. </span>
  95. </span>
  96. </template>
  97. <!-- 如果还在上传或切图处理中 -->
  98. <template v-else-if="item.status === 'LOADING'">
  99. <span class="table-data">
  100. <RadioOrCheckbox
  101. class="checkbox"
  102. :isLightTheme="!isDarkTheme"
  103. :isMultiSelection="isMultiSelection"
  104. :isDisabled="true"
  105. />
  106. </span>
  107. <span
  108. class="table-data"
  109. :style="{
  110. width: columnWidthList[idx],
  111. }"
  112. v-for="(tableItemStructure, idx) in tableHeaders"
  113. :key="idx"
  114. >
  115. <div v-if="tableItemStructure.type" class="list-img">
  116. <slot name="materialUploadingIcon"> </slot>
  117. </div>
  118. <span
  119. v-if="tableItemStructure.key === 'name'"
  120. class="name upload-status-wrap"
  121. >
  122. <div class="name-inner ellipsis" v-title="item.title">
  123. {{ item.title }}
  124. </div>
  125. <div v-if="item.ifKnowProgress" class="upload-status">
  126. {{ $i18n.t(`gather.upload_material`) }}
  127. {{ Math.round(item.progress * 100) }}%
  128. </div>
  129. <div v-else class="upload-status">
  130. {{ item.statusText }}
  131. </div>
  132. </span>
  133. <span v-else></span>
  134. </span>
  135. </template>
  136. <!-- 如果上传失败了 -->
  137. <template v-else-if="item.status === 'FAIL'">
  138. <span class="table-data">
  139. <RadioOrCheckbox
  140. class="checkbox"
  141. :isLightTheme="!isDarkTheme"
  142. :isMultiSelection="isMultiSelection"
  143. :isDisabled="true"
  144. />
  145. </span>
  146. <span
  147. class="table-data"
  148. :style="{
  149. width: columnWidthList[idx],
  150. }"
  151. v-for="(tableItemStructure, idx) in tableHeaders"
  152. :key="idx"
  153. >
  154. <div v-if="tableItemStructure.type" class="list-img">
  155. <slot name="materialUploadFailIcon"> </slot>
  156. </div>
  157. <span
  158. v-if="tableItemStructure.key === 'name'"
  159. class="name upload-status-wrap"
  160. >
  161. <div class="name-inner ellipsis" v-title="item.title">
  162. {{ item.title }}
  163. </div>
  164. <div class="upload-status">
  165. {{ item.statusText }}
  166. </div>
  167. </span>
  168. <span v-if="tableItemStructure.key === 'fileSize'">{{
  169. $i18n.t(`tips_code.FAILURE_3025`)
  170. }}</span>
  171. <span
  172. v-if="
  173. tableItemStructure.key !== 'name' &&
  174. tableItemStructure.key !== 'fileSize'
  175. "
  176. ></span>
  177. </span>
  178. </template>
  179. </div>
  180. </div>
  181. <!-- 本组件内的列表数据 -->
  182. <div
  183. class="table-body-row"
  184. v-for="(item, i) in showList"
  185. :key="i"
  186. @click="
  187. (e) => {
  188. if (item.type === 'dir') {
  189. onClickFolder(item);
  190. } else {
  191. onClickRow(e);
  192. }
  193. }
  194. "
  195. >
  196. <span class="table-data">
  197. <RadioOrCheckbox
  198. class="checkbox"
  199. :isLightTheme="!isDarkTheme"
  200. :isDisabled="item.type === 'dir'"
  201. :isMultiSelection="isMultiSelection"
  202. :isCheckedInitial="select.some((i) => i.id === item.id)"
  203. @change="(v) => selectItem(item, v)"
  204. />
  205. </span>
  206. <span
  207. class="table-data"
  208. v-for="(tableItemStructure, idx) in tableHeaders"
  209. :style="{
  210. width: columnWidthList[idx],
  211. }"
  212. :key="idx"
  213. >
  214. <div v-if="tableItemStructure.type" class="list-img">
  215. <img
  216. v-if="item.type === 'dir'"
  217. class="folderIcon"
  218. src="@/assets/images/icons/folder-blue.png"
  219. alt=""
  220. />
  221. <slot
  222. v-else
  223. name="materialIcon"
  224. :materialInfo="item"
  225. :tableItemStructure="tableItemStructure"
  226. >
  227. </slot>
  228. </div>
  229. <span
  230. v-else-if="tableItemStructure.key === 'name'"
  231. class="name"
  232. :class="{
  233. searchRes: latestUsedSearchKey,
  234. }"
  235. >
  236. <div
  237. class="name-inner ellipsis"
  238. v-title="item[tableItemStructure.key]"
  239. >
  240. {{ item[tableItemStructure.key] }}
  241. </div>
  242. <div v-if="latestUsedSearchKey" class="parent-info">
  243. {{ $i18n.t("gather.dir") }}
  244. <span
  245. class="parent-name"
  246. @click.stop="onClickParentFolder(item)"
  247. >{{
  248. item.dirId === 1 ? $i18n.t("gather.root_dir") : item.dirName
  249. }}</span
  250. >
  251. </div>
  252. </span>
  253. <span v-else class="ellipsis">
  254. {{ item[tableItemStructure.key] }}
  255. </span>
  256. </span>
  257. </div>
  258. <LoadingPoints
  259. v-show="isRequestingMoreData"
  260. :isDarkTheme="isDarkTheme"
  261. />
  262. <!-- <div class="no-more-data" v-show="!hasMoreData">
  263. - {{ $i18n.t("gather.no_more_data") }} -
  264. </div> -->
  265. </div>
  266. <!-- 无数据时的提示 -->
  267. <div v-show="!(listLocalLength !== 0 || hasMoreData)" class="no-data">
  268. <div v-if="latestUsedSearchKey">
  269. <img
  270. :src="
  271. require(`@/assets/images/default/empty_search_${
  272. isDarkTheme ? 'dark' : 'bright'
  273. }.png`)
  274. "
  275. alt=""
  276. />
  277. <span>{{ $i18n.t("gather.no_serch_result") }}</span>
  278. </div>
  279. <div v-if="!latestUsedSearchKey">
  280. <img
  281. :src="
  282. require(`@/assets/images/default/empty_${
  283. isDarkTheme ? 'dark' : 'bright'
  284. }.png`)
  285. "
  286. alt=""
  287. />
  288. <span>{{ $i18n.t("gather.no_material_result") }}</span>
  289. <a v-if="!canUpload" href="/#/">
  290. <button class="ui-button">
  291. {{ $i18n.t("gather.how_to_shoot") }}
  292. </button>
  293. </a>
  294. </div>
  295. </div>
  296. </div>
  297. <div class="btns">
  298. <button
  299. v-if="canUpload && !searchKey"
  300. class="ui-button upload-btn"
  301. @click="onClickUpload"
  302. >
  303. <span>{{ $i18n.t("gather.upload_material") }}</span>
  304. <i
  305. class="iconfont icon-help_i tool-tip-for-editor"
  306. v-tooltip="fileInputBtnTip"
  307. />
  308. <FileInput
  309. ref="file-input"
  310. :failString="fileInputFailString"
  311. :limitFailStr="fileInputLimitFailStr"
  312. :acceptType="fileInputAcceptType"
  313. :mediaType="fileInputMediaType"
  314. :limit="fileInputLimit"
  315. @file-change="onFileInputChange"
  316. />
  317. </button>
  318. </div>
  319. </div>
  320. </template>
  321. <script>
  322. import {
  323. getMaterialList,
  324. get3DSceneList,
  325. searchInAll3DScenes,
  326. uploadMaterial,
  327. checkUserSize,
  328. } from "@/api";
  329. import { changeByteUnit } from "@/utils/file";
  330. import { debounce, capitalize } from "@/utils/other.js";
  331. import config from "@/config";
  332. import FileInput from "@/components/shared/uploads/UploadMultiple.vue";
  333. import RadioOrCheckbox from "@/components/shared/RadioOrCheckbox.vue";
  334. import LoadingPoints from "@/components/shared/LoadingPoints.vue";
  335. import folderMixin from "./materialSelectorFolderMixin.js";
  336. export default {
  337. components: {
  338. FileInput,
  339. RadioOrCheckbox,
  340. LoadingPoints,
  341. },
  342. mixins: [folderMixin],
  343. props: {
  344. isDarkTheme: {
  345. type: Boolean,
  346. default: true,
  347. },
  348. currentMaterialType: {
  349. type: String,
  350. required: true,
  351. },
  352. materialType: {
  353. type: String,
  354. required: true,
  355. },
  356. materialItemCustomProcess: {
  357. type: Function,
  358. default: (item) => {
  359. return;
  360. },
  361. },
  362. tableHeaderKeyList: {
  363. type: Array,
  364. default: () => {
  365. return [];
  366. },
  367. },
  368. columnWidthList: {
  369. type: Array,
  370. default: () => {
  371. return [];
  372. },
  373. },
  374. isMultiSelection: {
  375. type: Boolean,
  376. default: false,
  377. },
  378. select: {
  379. type: Array,
  380. required: true,
  381. },
  382. searchKey: {
  383. type: String,
  384. default: "",
  385. },
  386. canUpload: {
  387. type: Boolean,
  388. defaut: false,
  389. },
  390. fileInputBtnTip: {
  391. type: String,
  392. },
  393. fileInputCustomCheck: {
  394. type: Function,
  395. default: async () => {
  396. return true;
  397. },
  398. },
  399. fileUploadLongPollingCb: {
  400. type: Function || null,
  401. default: null,
  402. },
  403. fileUploadLongPollingStatusText: {
  404. type: String,
  405. default: "",
  406. },
  407. fileInputFailString: {
  408. type: String,
  409. },
  410. fileInputLimitFailStr: {
  411. type: String,
  412. },
  413. fileInputAcceptType: {
  414. type: String,
  415. },
  416. fileInputMediaType: {
  417. type: String,
  418. },
  419. fileInputLimit: {
  420. type: Number,
  421. },
  422. },
  423. data() {
  424. return {
  425. list: [],
  426. latestUsedSearchKey: "",
  427. isRequestingMoreData: false,
  428. hasMoreData: true,
  429. longPollingIntervalId: null,
  430. };
  431. },
  432. computed: {
  433. showList() {
  434. return this.list.filter((i) => i.status === 3);
  435. },
  436. materialTypeAlias() {
  437. if (this.materialType === "3D") {
  438. return "scene";
  439. } else {
  440. return this.materialType;
  441. }
  442. },
  443. tableHeaders() {
  444. /*
  445. [
  446. {
  447. en: "素材", // 暂时没用到
  448. key: "icon",
  449. name: "素材",
  450. type: "image",
  451. width: 150, // 暂时没用到
  452. },
  453. {
  454. en: "名称",
  455. key: "name",
  456. name: "名称",
  457. width: 240,
  458. },
  459. {
  460. en: "大小",
  461. key: "fileSize",
  462. name: "大小",
  463. width: 80,
  464. }
  465. ]
  466. */
  467. return this.$MAPTABLEHEADER[this.materialTypeAlias].filter((item) => {
  468. return this.tableHeaderKeyList.includes(item.key);
  469. });
  470. },
  471. uploadStatusList() {
  472. if (this.canUpload) {
  473. return this.$store.state[
  474. `uploadStatusList${capitalize(this.materialType)}`
  475. ];
  476. } else {
  477. return [];
  478. }
  479. },
  480. listRealLength() {
  481. return (
  482. this.list.length +
  483. this.uploadStatusList.filter((item) => {
  484. return item.status === "SUCCESS";
  485. }).length
  486. );
  487. },
  488. listLocalLength() {
  489. return this.list.length + this.uploadStatusList.length;
  490. },
  491. needLongPolling() {
  492. return this.uploadStatusList.some((item) => {
  493. return item.status === "LOADING" && item.ifKnowProgress === false;
  494. });
  495. },
  496. },
  497. watch: {
  498. searchKey: {
  499. handler: function () {
  500. if (this.currentMaterialType === this.materialType) {
  501. this.refreshMaterialList();
  502. }
  503. },
  504. immediate: false,
  505. },
  506. currentMaterialType: {
  507. handler: function (newVal) {
  508. if (newVal === this.materialType && this.list.length === 0) {
  509. this.refreshMaterialList();
  510. }
  511. },
  512. immediate: false,
  513. },
  514. needLongPolling: {
  515. handler: function (newVal, oldValue) {
  516. if (!newVal) {
  517. clearInterval(this.longPollingIntervalId);
  518. this.longPollingIntervalId = null;
  519. // 最后上传成功能状态
  520. if (!newVal && oldValue) {
  521. // debugger;
  522. this.refreshMaterialList();
  523. }
  524. } else {
  525. clearInterval(this.longPollingIntervalId);
  526. this.longPollingIntervalId = null;
  527. this.longPollingIntervalId = setInterval(() => {
  528. this.fileUploadLongPollingCb(this.uploadStatusList);
  529. }, 3000);
  530. }
  531. },
  532. immediate: true,
  533. },
  534. },
  535. methods: {
  536. selectItem(item, v) {
  537. item.materialType = this.materialType; // 三维场景数据没有type字段来表明自己是三维场景。所以统一加一个字段。
  538. if (this.isMultiSelection) {
  539. if (v) {
  540. this.select.push(item);
  541. } else {
  542. const toDeleteIdx = this.select.findIndex((eachSelect) => {
  543. return eachSelect.id === item.id;
  544. });
  545. if (toDeleteIdx >= 0) {
  546. this.select.splice(toDeleteIdx, 1);
  547. }
  548. }
  549. } else {
  550. this.select.splice(0, this.select.length);
  551. if (v) {
  552. this.select.push(item);
  553. }
  554. }
  555. },
  556. requestMoreData() {
  557. this.isRequestingMoreData = true;
  558. const latestUsedSearchKey = this.searchKey;
  559. let getListFn = null;
  560. let params = null;
  561. if (this.materialType === "3D") {
  562. if (!this.searchKey) {
  563. getListFn = get3DSceneList;
  564. params = {
  565. pathLevel2Id: this.folderPath[1]?.id,
  566. folderId: this.currentFolderId,
  567. pageNum: Math.floor(this.list.length / config.PAGE_SIZE) + 1,
  568. pageSize: config.PAGE_SIZE,
  569. searchKey: this.searchKey,
  570. };
  571. } else {
  572. getListFn = searchInAll3DScenes;
  573. params = {
  574. searchKey: this.searchKey,
  575. };
  576. }
  577. } else {
  578. getListFn = getMaterialList;
  579. params = {
  580. dirId: this.currentFolderId,
  581. pageNum: Math.floor(this.listRealLength / config.PAGE_SIZE) + 1,
  582. pageSize: config.PAGE_SIZE,
  583. searchKey: this.searchKey,
  584. type: this.materialType,
  585. };
  586. }
  587. getListFn(
  588. params,
  589. (data) => {
  590. const newData = data.data.list.map((i) => {
  591. if (i.fileSize) {
  592. i.fileSize = changeByteUnit(Number(i.fileSize));
  593. } else {
  594. i.fileSize = "";
  595. }
  596. this.materialItemCustomProcess(i);
  597. return i;
  598. });
  599. this.preProessData(newData);
  600. if (this.listRealLength === data.data.total) {
  601. this.hasMoreData = false;
  602. }
  603. this.isRequestingMoreData = false;
  604. this.latestUsedSearchKey = latestUsedSearchKey;
  605. },
  606. () => {
  607. this.isRequestingMoreData = false;
  608. this.latestUsedSearchKey = latestUsedSearchKey;
  609. }
  610. );
  611. },
  612. preProessData(newData) {
  613. this.list = this.list.concat(newData);
  614. const uploadlist = this.list
  615. .filter((i) => i.status < 3)
  616. .map((item) => {
  617. let itemInUploadList = {
  618. title: item.name,
  619. ifKnowProgress: false,
  620. progress: 0,
  621. status: "LOADING",
  622. statusText: this.$i18n.t(`gather.cutting`),
  623. uid: `u_${this.$randomWord(true, 8, 8)}`,
  624. abortHandler: null,
  625. backendId: item.id, // 只用于全景图上传
  626. parentFolderId: item.dirId,
  627. };
  628. return itemInUploadList;
  629. });
  630. const res = new Map();
  631. const latestUploadlist = this.uploadStatusList
  632. .concat(uploadlist)
  633. .filter((a) => !res.has(a.backendId) && res.set(a.backendId, 1));
  634. console.log("latestUploadlist", latestUploadlist);
  635. const capitalizedMaterialType = capitalize(this.materialType);
  636. this.$store.commit(
  637. `setUploadStatusList${capitalizedMaterialType}`,
  638. latestUploadlist
  639. );
  640. },
  641. refreshMaterialList: debounce(
  642. function (type) {
  643. this.isRequestingMoreData = false;
  644. this.hasMoreData = true;
  645. this.list = [];
  646. if (this.canUpload) {
  647. let filterResult = this.uploadStatusList.filter((item) => {
  648. return item.status === "LOADING";
  649. });
  650. const capitalizedMaterialType = capitalize(this.materialType);
  651. this.$store.commit(
  652. `setUploadStatusList${capitalizedMaterialType}`,
  653. filterResult
  654. );
  655. }
  656. this.requestMoreData();
  657. },
  658. 500,
  659. false
  660. ),
  661. onFileInputChange(e) {
  662. e.files.forEach(async (eachFile, i) => {
  663. const extension = eachFile.name.split(".").pop();
  664. console.log("extension", extension, this.fileInputAcceptType);
  665. if (
  666. this.fileInputAcceptType.indexOf(
  667. String(extension).toLocaleLowerCase()
  668. ) <= -1
  669. ) {
  670. console.log("格式不对!");
  671. setTimeout(() => {
  672. this.$msg({
  673. message: `“${eachFile.name}”${this.fileInputFailString}`,
  674. type: "warning",
  675. });
  676. }, i * 100);
  677. return;
  678. }
  679. if (
  680. eachFile.name.substring(0, eachFile.name.lastIndexOf(".")).length > 50
  681. ) {
  682. setTimeout(() => {
  683. this.$msg({
  684. message: `“${eachFile.name}”${this.$i18n.t(
  685. `gather.too_long_word`
  686. )}`,
  687. type: "warning",
  688. });
  689. }, i * 100);
  690. return;
  691. }
  692. const customCheckRes = await this.fileInputCustomCheck(eachFile, i);
  693. if (!customCheckRes) {
  694. return;
  695. }
  696. let itemInUploadList = {
  697. title: eachFile.name,
  698. ifKnowProgress: true,
  699. progress: 0,
  700. status: "LOADING",
  701. statusText: this.$i18n.t(`gather.uploading_material`),
  702. uid: `u_${this.$randomWord(true, 8, 8)}`,
  703. abortHandler: null,
  704. backendId: "", // 只用于全景图上传
  705. parentFolderId: this.currentFolderId,
  706. };
  707. itemInUploadList.abortHandler = uploadMaterial(
  708. {
  709. dirId: this.currentFolderId,
  710. file: eachFile,
  711. tempId: itemInUploadList.uid,
  712. type: this.materialType,
  713. },
  714. (response) => {
  715. // 上传成功
  716. if (response.code !== 0) {
  717. console.error("上传接口响应异常:", response);
  718. return;
  719. }
  720. console.log("上传成功1");
  721. if (this.fileUploadLongPollingCb) {
  722. itemInUploadList.statusText =
  723. this.fileUploadLongPollingStatusText;
  724. itemInUploadList.ifKnowProgress = false;
  725. itemInUploadList.backendId = response.data.id;
  726. } else {
  727. itemInUploadList.status = "SUCCESS";
  728. if (response.data.fileSize) {
  729. response.data.fileSize = changeByteUnit(
  730. Number(response.fileSize)
  731. );
  732. } else {
  733. response.data.fileSize = "";
  734. }
  735. itemInUploadList.successInfo = response.data;
  736. // 非pano上传refresh
  737. this.refreshMaterialList();
  738. }
  739. },
  740. (err) => {
  741. if (err.statusText === "abort") {
  742. // 用户取消了上传任务。
  743. console.log("用户取消了任务!");
  744. const index = this.uploadStatusList.findIndex((eachItem) => {
  745. return eachItem.uid === itemInUploadList.uid;
  746. });
  747. this.uploadStatusList.splice(index, 1);
  748. } else {
  749. console.log("上传失败!");
  750. itemInUploadList.status = "FAIL";
  751. itemInUploadList.statusText = this.$i18n.t(
  752. `gather.material_upload_fail`
  753. );
  754. }
  755. },
  756. (progress) => {
  757. console.log("进度:", progress);
  758. itemInUploadList.progress = progress;
  759. }
  760. );
  761. this.uploadStatusList.unshift(itemInUploadList);
  762. });
  763. },
  764. onClickRow(e) {
  765. const checkboxNodeList = e.currentTarget.getElementsByClassName(
  766. "selection-click-target"
  767. );
  768. if (checkboxNodeList && checkboxNodeList[0]) {
  769. checkboxNodeList[0].click();
  770. }
  771. },
  772. async onClickUpload() {
  773. const res = await checkUserSize();
  774. if (res)
  775. if (Number(res.useSpace) > Number(res.totalSpace)) {
  776. this.$alert({ content: this.$i18n.t("tips_code.FAILURE_3024") });
  777. } else {
  778. this.$refs["file-input"].click();
  779. }
  780. },
  781. // onClickUpload() {
  782. // checkUserSize({}, ({ useSpace, totalSpace }) => {
  783. // //判断已用是否大于3G
  784. // if (Number(useSpace) > Number(totalSpace)) {
  785. // this.$alert({ content: this.$i18n.t("tips_code.FAILURE_3024") });
  786. // } else {
  787. // de
  788. // this.$refs["file-input"].click();
  789. // }
  790. // });
  791. // },
  792. // 1.3.0插入排序
  793. insertListBySort(newData) {
  794. const firstNotDirItem = this.uploadStatusList.slice
  795. .filter((i) => i.dir !== "dir")
  796. .shift();
  797. console.log("firstNotDirItem", firstNotDirItem);
  798. const firstNotDirItemIndex = this.uploadStatusList.findIndex(
  799. (i) => i.id === firstNotDirItem.id
  800. );
  801. console.log("firstNotDirItemIndex", firstNotDirItemIndex);
  802. this.uploadStatusList.unshift(newData);
  803. },
  804. },
  805. mounted() {},
  806. beforeDestroy() {
  807. if (this.canUpload) {
  808. const capitalizedMaterialType = capitalize(this.materialType);
  809. this.$store.commit(
  810. `setUploadStatusList${capitalizedMaterialType}`,
  811. this.uploadStatusList.filter((item) => {
  812. return item.status === "LOADING";
  813. })
  814. );
  815. }
  816. },
  817. };
  818. </script>
  819. <style lang="less" scoped>
  820. .material-list {
  821. position: relative;
  822. .ellipsis {
  823. text-overflow: ellipsis;
  824. overflow: hidden;
  825. white-space: nowrap;
  826. width: 100%;
  827. display: inline-block;
  828. }
  829. .crumbs {
  830. margin-top: 10px;
  831. }
  832. // @table-height: 420px;
  833. // @table-head-row-height: 40px;
  834. // @table-border-size: 1px;
  835. @table-height: 420px;
  836. @table-head-row-height: 0px;
  837. @table-border-size: 0px;
  838. .table {
  839. margin-top: 10px;
  840. // border: @table-border-size solid #EBEDF0;
  841. width: 100%;
  842. height: @table-height;
  843. // >.table-head-row {
  844. // width: 100%;
  845. // height: @table-head-row-height;
  846. // background: #F5F7FA;
  847. // color: #646566;
  848. // .table-head {
  849. // font-size: 16px;
  850. // line-height: @table-head-row-height;
  851. // height: 100%;
  852. // display: inline-block;
  853. // &:nth-of-type(1) {
  854. // color: transparent;
  855. // }
  856. // }
  857. // }
  858. > .table-body {
  859. height: calc(
  860. @table-height - @table-head-row-height - @table-border-size -
  861. @table-border-size
  862. );
  863. overflow: auto;
  864. display: inline-block;
  865. width: 100%;
  866. .table-body-row {
  867. height: 50px;
  868. // border-bottom: 1px solid #EBEDF0;
  869. display: flex;
  870. align-items: center;
  871. border-radius: 4px;
  872. cursor: pointer;
  873. &:hover {
  874. background: #f7f8fa;
  875. }
  876. > .table-data {
  877. font-size: 14px;
  878. line-height: 50px;
  879. height: 100%;
  880. color: #323233;
  881. &:nth-of-type(1) {
  882. width: 50px;
  883. }
  884. &:nth-of-type(2) {
  885. width: 96px;
  886. }
  887. &:nth-of-type(3) {
  888. width: calc(100% - 50px - 96px);
  889. }
  890. &:last-of-type {
  891. padding-right: 10px;
  892. }
  893. > .list-img {
  894. position: relative;
  895. height: 100%;
  896. display: inline-block;
  897. width: 100%;
  898. > img,
  899. .audio-player {
  900. position: absolute;
  901. top: 50%;
  902. transform: translateY(-50%);
  903. width: 40px;
  904. height: 40px;
  905. object-fit: cover;
  906. &.folderIcon {
  907. object-fit: contain;
  908. }
  909. }
  910. }
  911. > .name:not(.searchRes) {
  912. display: inline-block;
  913. height: 100%;
  914. width: 100%;
  915. display: flex;
  916. align-items: center;
  917. > .name-inner {
  918. flex: 0 0 auto;
  919. display: inline-block;
  920. height: 100%;
  921. width: 50%;
  922. }
  923. > .upload-status {
  924. flex: 0 0 auto;
  925. display: inline-block;
  926. height: 100%;
  927. margin-left: 20px;
  928. }
  929. }
  930. > .name.searchRes {
  931. height: 100%;
  932. width: 100%;
  933. display: flex;
  934. flex-direction: column;
  935. justify-content: center;
  936. align-items: flex-start;
  937. line-height: initial;
  938. > .name-inner {
  939. flex: 0 0 auto;
  940. display: inline-block;
  941. width: 100%;
  942. }
  943. > .parent-info {
  944. > .parent-name {
  945. color: @color;
  946. }
  947. }
  948. }
  949. > .name:not(.upload-status-wrap):hover {
  950. > .name-inner {
  951. width: 100%;
  952. }
  953. }
  954. }
  955. }
  956. .no-more-data {
  957. margin-top: 16px;
  958. margin-bottom: 16px;
  959. text-align: center;
  960. font-size: 12px;
  961. color: #969799;
  962. }
  963. }
  964. > .no-data {
  965. height: calc(
  966. @table-height - @table-head-row-height - @table-border-size -
  967. @table-border-size
  968. );
  969. width: 100%;
  970. position: relative;
  971. > div {
  972. position: absolute;
  973. top: 50%;
  974. left: 50%;
  975. transform: translate(-50%, -50%);
  976. text-align: center;
  977. > img {
  978. width: 116px;
  979. }
  980. > span {
  981. margin-top: 20px;
  982. display: block;
  983. font-size: 14px;
  984. color: #646566;
  985. }
  986. > a {
  987. > button {
  988. margin-top: 20px;
  989. }
  990. }
  991. }
  992. }
  993. }
  994. .checkbox {
  995. width: 100%;
  996. height: 100%;
  997. }
  998. .btns {
  999. left: 0;
  1000. margin-top: 29px;
  1001. .upload-btn {
  1002. display: flex;
  1003. align-items: center;
  1004. > span {
  1005. display: inline-block;
  1006. margin-right: 4px;
  1007. }
  1008. i.tool-tip-for-editor {
  1009. font-size: 12px;
  1010. transform: scale(0.923) translateY(1px);
  1011. cursor: default;
  1012. }
  1013. }
  1014. }
  1015. }
  1016. .material-list.dark {
  1017. .ellipsis {
  1018. }
  1019. .crumbs {
  1020. ul > li .name {
  1021. max-width: 80px;
  1022. display: block;
  1023. }
  1024. }
  1025. .table {
  1026. // border: @table-border-size solid #EBEDF0;
  1027. // >.table-head-row {
  1028. // background: #F5F7FA;
  1029. // color: #646566;
  1030. // .table-head {
  1031. // &:nth-of-type(1) {
  1032. // color: transparent;
  1033. // }
  1034. // }
  1035. // }
  1036. > .table-body {
  1037. .table-body-row {
  1038. // border-bottom: 1px solid #EBEDF0;
  1039. &:hover {
  1040. background: #252526;
  1041. }
  1042. > .table-data {
  1043. color: #fff;
  1044. > .list-img {
  1045. > img,
  1046. .audio-player {
  1047. &.folderIcon {
  1048. }
  1049. }
  1050. }
  1051. }
  1052. }
  1053. }
  1054. > .no-data {
  1055. > div {
  1056. > img {
  1057. }
  1058. > span {
  1059. color: rgba(255, 255, 255, 0.6);
  1060. }
  1061. > a {
  1062. > button {
  1063. }
  1064. }
  1065. }
  1066. }
  1067. }
  1068. .checkbox {
  1069. }
  1070. .btns {
  1071. .upload-btn {
  1072. > span {
  1073. }
  1074. i.tool-tip-for-editor {
  1075. }
  1076. }
  1077. }
  1078. }
  1079. </style>
  1080. <style lang="less">
  1081. .material-list,
  1082. .material-list.dark {
  1083. .crumbs {
  1084. // display: none;
  1085. ul > li {
  1086. display: flex;
  1087. justify-content: center;
  1088. align-items: center;
  1089. .name {
  1090. max-width: 180px;
  1091. display: block;
  1092. }
  1093. }
  1094. }
  1095. }
  1096. </style>