materialListInMaterialSelector.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  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="uniqueFolderList(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_search_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="/#/" target="_blank">
  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. uniqueFolderList() {
  434. return (arr) => {
  435. const tem = new Map();
  436. let res = arr.filter(
  437. (item) => !tem.has(item.id) && tem.set(item.id, 1)
  438. );
  439. return res;
  440. };
  441. },
  442. showList() {
  443. if (this.materialTypeAlias === "pano") {
  444. return this.list.filter((i) => {
  445. if (i.type !== "dir" && i.status < 3) {
  446. return false;
  447. } else {
  448. return true;
  449. }
  450. });
  451. }
  452. return this.list;
  453. },
  454. materialTypeAlias() {
  455. if (this.materialType === "3D") {
  456. return "scene";
  457. } else {
  458. return this.materialType;
  459. }
  460. },
  461. tableHeaders() {
  462. /*
  463. [
  464. {
  465. en: "素材", // 暂时没用到
  466. key: "icon",
  467. name: "素材",
  468. type: "image",
  469. width: 150, // 暂时没用到
  470. },
  471. {
  472. en: "名称",
  473. key: "name",
  474. name: "名称",
  475. width: 240,
  476. },
  477. {
  478. en: "大小",
  479. key: "fileSize",
  480. name: "大小",
  481. width: 80,
  482. }
  483. ]
  484. */
  485. return this.$MAPTABLEHEADER[this.materialTypeAlias].filter((item) => {
  486. return this.tableHeaderKeyList.includes(item.key);
  487. });
  488. },
  489. uploadStatusList() {
  490. if (this.canUpload) {
  491. return this.$store.state[
  492. `uploadStatusList${capitalize(this.materialType)}`
  493. ];
  494. } else {
  495. return [];
  496. }
  497. },
  498. listRealLength() {
  499. return (
  500. this.list.length +
  501. this.uploadStatusList.filter((item) => {
  502. return item.status === "SUCCESS";
  503. }).length
  504. );
  505. },
  506. listLocalLength() {
  507. return this.list.length + this.uploadStatusList.length;
  508. },
  509. needLongPolling() {
  510. return this.uploadStatusList.some((item) => {
  511. return item.status === "LOADING" && item.ifKnowProgress === false;
  512. });
  513. },
  514. },
  515. watch: {
  516. searchKey: {
  517. handler: function () {
  518. if (this.currentMaterialType === this.materialType) {
  519. this.refreshMaterialList();
  520. }
  521. },
  522. immediate: false,
  523. },
  524. currentMaterialType: {
  525. handler: function (newVal) {
  526. if (newVal === this.materialType && this.list.length === 0) {
  527. this.refreshMaterialList();
  528. }
  529. },
  530. immediate: false,
  531. },
  532. needLongPolling: {
  533. handler: function (newVal, oldValue) {
  534. if (!newVal) {
  535. clearInterval(this.longPollingIntervalId);
  536. this.longPollingIntervalId = null;
  537. // 最后上传成功能状态
  538. if (!newVal && oldValue) {
  539. this.refreshMaterialList();
  540. }
  541. } else {
  542. clearInterval(this.longPollingIntervalId);
  543. this.longPollingIntervalId = null;
  544. this.longPollingIntervalId = setInterval(() => {
  545. this.fileUploadLongPollingCb(this.uploadStatusList);
  546. }, 3000);
  547. }
  548. },
  549. immediate: true,
  550. },
  551. },
  552. methods: {
  553. selectItem(item, v) {
  554. item.materialType = this.materialType; // 三维场景数据没有type字段来表明自己是三维场景。所以统一加一个字段。
  555. if (this.isMultiSelection) {
  556. if (v) {
  557. // eslint-disable-next-line vue/no-mutating-props
  558. this.select.push(item);
  559. } else {
  560. const toDeleteIdx = this.select.findIndex((eachSelect) => {
  561. return eachSelect.id === item.id;
  562. });
  563. if (toDeleteIdx >= 0) {
  564. // eslint-disable-next-line vue/no-mutating-props
  565. this.select.splice(toDeleteIdx, 1);
  566. }
  567. }
  568. } else {
  569. // eslint-disable-next-line vue/no-mutating-props
  570. this.select.splice(0, this.select.length);
  571. if (v) {
  572. // eslint-disable-next-line vue/no-mutating-props
  573. this.select.push(item);
  574. }
  575. }
  576. },
  577. requestMoreData() {
  578. this.isRequestingMoreData = true;
  579. const latestUsedSearchKey = this.searchKey;
  580. let getListFn = null;
  581. let params = null;
  582. if (this.materialType === "3D") {
  583. if (!this.searchKey) {
  584. getListFn = get3DSceneList;
  585. params = {
  586. pathLevel2Id: this.folderPath[1]?.id,
  587. folderId: this.currentFolderId,
  588. pageNum: Math.floor(this.list.length / config.PAGE_SIZE) + 1,
  589. pageSize: config.PAGE_SIZE,
  590. searchKey: this.searchKey,
  591. };
  592. } else {
  593. getListFn = searchInAll3DScenes;
  594. params = {
  595. searchKey: this.searchKey,
  596. };
  597. }
  598. } else {
  599. getListFn = getMaterialList;
  600. params = {
  601. dirId: this.currentFolderId,
  602. pageNum: Math.floor(this.listRealLength / config.PAGE_SIZE) + 1,
  603. pageSize: config.PAGE_SIZE,
  604. searchKey: this.searchKey,
  605. type: this.materialType,
  606. };
  607. }
  608. getListFn(
  609. params,
  610. (data) => {
  611. const newData = data.data.list.map((i) => {
  612. if (i.fileSize) {
  613. i.fileSize = changeByteUnit(Number(i.fileSize));
  614. } else {
  615. i.fileSize = "";
  616. }
  617. this.materialItemCustomProcess(i);
  618. return i;
  619. });
  620. this.preProessData(newData);
  621. if (this.listRealLength === data.data.total) {
  622. this.hasMoreData = false;
  623. }
  624. this.isRequestingMoreData = false;
  625. this.latestUsedSearchKey = latestUsedSearchKey;
  626. },
  627. () => {
  628. this.isRequestingMoreData = false;
  629. this.latestUsedSearchKey = latestUsedSearchKey;
  630. }
  631. );
  632. },
  633. preProessData(newData) {
  634. this.list = this.list.concat(newData);
  635. //全景图
  636. if (this.materialTypeAlias === "pano") {
  637. const uploadlist = this.list
  638. .filter((i) => i.status < 3 && i.type !== "dir")
  639. .map((item) => {
  640. let itemInUploadList = {
  641. title: item.name,
  642. ifKnowProgress: false,
  643. progress: 0,
  644. status: "LOADING",
  645. statusText: this.$i18n.t(`gather.cutting`),
  646. uid: `u_${this.$randomWord(true, 8, 8)}`,
  647. abortHandler: null,
  648. backendId: item.id, // 只用于全景图上传
  649. parentFolderId: item.dirId,
  650. };
  651. return itemInUploadList;
  652. });
  653. const res = new Map();
  654. const lastItem = this.folderPath[this.folderPath.length - 1];
  655. const latestUploadlist = this.uploadStatusList
  656. .concat(uploadlist)
  657. .filter((a) => !res.has(a.backendId) && res.set(a.backendId, 1))
  658. .filter((i) => i.parentFolderId === lastItem.id);
  659. // console.log("latestUploadlist", latestUploadlist);
  660. console.log("lastItem", lastItem);
  661. const capitalizedMaterialType = capitalize(this.materialType);
  662. this.$store.commit(
  663. `setUploadStatusList${capitalizedMaterialType}`,
  664. latestUploadlist
  665. );
  666. }
  667. },
  668. refreshMaterialList: debounce(
  669. function (type) {
  670. this.isRequestingMoreData = false;
  671. this.hasMoreData = true;
  672. this.list = [];
  673. if (this.canUpload) {
  674. let filterResult = this.uploadStatusList.filter((item) => {
  675. return item.status === "LOADING";
  676. });
  677. const capitalizedMaterialType = capitalize(this.materialType);
  678. this.$store.commit(
  679. `setUploadStatusList${capitalizedMaterialType}`,
  680. filterResult
  681. );
  682. }
  683. this.requestMoreData();
  684. },
  685. 500,
  686. false
  687. ),
  688. onFileInputChange(e) {
  689. e.files.forEach(async (eachFile, i) => {
  690. const extension = eachFile.name.split(".").pop();
  691. console.log("extension", extension, this.fileInputAcceptType);
  692. if (
  693. this.fileInputAcceptType.indexOf(
  694. String(extension).toLocaleLowerCase()
  695. ) <= -1
  696. ) {
  697. console.log("格式不对!");
  698. setTimeout(() => {
  699. this.$msg({
  700. message: `“${eachFile.name}”${this.fileInputFailString}`,
  701. type: "warning",
  702. });
  703. }, i * 100);
  704. return;
  705. }
  706. if (
  707. eachFile.name.substring(0, eachFile.name.lastIndexOf(".")).length > 50
  708. ) {
  709. setTimeout(() => {
  710. this.$msg({
  711. message: `“${eachFile.name}”${this.$i18n.t(
  712. `gather.too_long_word`
  713. )}`,
  714. type: "warning",
  715. });
  716. }, i * 100);
  717. return;
  718. }
  719. const customCheckRes = await this.fileInputCustomCheck(eachFile, i);
  720. if (!customCheckRes) {
  721. return;
  722. }
  723. let itemInUploadList = {
  724. title: eachFile.name,
  725. ifKnowProgress: true,
  726. progress: 0,
  727. status: "LOADING",
  728. statusText: this.$i18n.t(`gather.uploading_material`),
  729. uid: `u_${this.$randomWord(true, 8, 8)}`,
  730. abortHandler: null,
  731. backendId: "", // 只用于全景图上传
  732. parentFolderId: this.currentFolderId,
  733. };
  734. itemInUploadList.abortHandler = uploadMaterial(
  735. {
  736. dirId: this.currentFolderId,
  737. file: eachFile,
  738. tempId: itemInUploadList.uid,
  739. type: this.materialType,
  740. },
  741. (response) => {
  742. // 上传成功
  743. if (response.code !== 0) {
  744. console.error("上传接口响应异常:", response);
  745. return;
  746. }
  747. console.log("上传成功1");
  748. if (this.fileUploadLongPollingCb) {
  749. itemInUploadList.statusText =
  750. this.fileUploadLongPollingStatusText;
  751. itemInUploadList.ifKnowProgress = false;
  752. itemInUploadList.backendId = response.data.id;
  753. } else {
  754. itemInUploadList.status = "SUCCESS";
  755. if (response.data.fileSize) {
  756. response.data.fileSize = changeByteUnit(
  757. Number(response.fileSize)
  758. );
  759. } else {
  760. response.data.fileSize = "";
  761. }
  762. itemInUploadList.successInfo = response.data;
  763. // 非pano上传refresh
  764. this.refreshMaterialList();
  765. }
  766. },
  767. (err) => {
  768. if (err.statusText === "abort") {
  769. // 用户取消了上传任务。
  770. console.log("用户取消了任务!");
  771. const index = this.uploadStatusList.findIndex((eachItem) => {
  772. return eachItem.uid === itemInUploadList.uid;
  773. });
  774. this.uploadStatusList.splice(index, 1);
  775. } else {
  776. console.log("上传失败!");
  777. itemInUploadList.status = "FAIL";
  778. itemInUploadList.statusText = this.$i18n.t(
  779. `gather.material_upload_fail`
  780. );
  781. }
  782. },
  783. (progress) => {
  784. console.log("进度:", progress);
  785. itemInUploadList.progress = progress;
  786. }
  787. );
  788. this.uploadStatusList.unshift(itemInUploadList);
  789. });
  790. },
  791. onClickRow(e) {
  792. const checkboxNodeList = e.currentTarget.getElementsByClassName(
  793. "selection-click-target"
  794. );
  795. if (checkboxNodeList && checkboxNodeList[0]) {
  796. checkboxNodeList[0].click();
  797. }
  798. },
  799. async onClickUpload() {
  800. const res = await checkUserSize();
  801. if (res)
  802. if (Number(res.useSpace) > Number(res.totalSpace)) {
  803. this.$alert({ content: this.$i18n.t("tips_code.FAILURE_3024") });
  804. } else {
  805. this.$refs["file-input"].click();
  806. }
  807. },
  808. // onClickUpload() {
  809. // checkUserSize({}, ({ useSpace, totalSpace }) => {
  810. // //判断已用是否大于3G
  811. // if (Number(useSpace) > Number(totalSpace)) {
  812. // this.$alert({ content: this.$i18n.t("tips_code.FAILURE_3024") });
  813. // } else {
  814. // de
  815. // this.$refs["file-input"].click();
  816. // }
  817. // });
  818. // },
  819. // 1.3.0插入排序
  820. insertListBySort(newData) {
  821. const firstNotDirItem = this.uploadStatusList.slice
  822. .filter((i) => i.dir !== "dir")
  823. .shift();
  824. console.log("firstNotDirItem", firstNotDirItem);
  825. const firstNotDirItemIndex = this.uploadStatusList.findIndex(
  826. (i) => i.id === firstNotDirItem.id
  827. );
  828. console.log("firstNotDirItemIndex", firstNotDirItemIndex);
  829. this.uploadStatusList.unshift(newData);
  830. },
  831. },
  832. mounted() {},
  833. beforeDestroy() {
  834. if (this.canUpload) {
  835. const capitalizedMaterialType = capitalize(this.materialType);
  836. this.$store.commit(
  837. `setUploadStatusList${capitalizedMaterialType}`,
  838. this.uploadStatusList.filter((item) => {
  839. return item.status === "LOADING";
  840. })
  841. );
  842. }
  843. },
  844. };
  845. </script>
  846. <style lang="less" scoped>
  847. .material-list {
  848. position: relative;
  849. .ellipsis {
  850. text-overflow: ellipsis;
  851. overflow: hidden;
  852. white-space: nowrap;
  853. width: 100%;
  854. display: inline-block;
  855. }
  856. .crumbs {
  857. margin-top: 10px;
  858. }
  859. // @table-height: 420px;
  860. // @table-head-row-height: 40px;
  861. // @table-border-size: 1px;
  862. @table-height: 420px;
  863. @table-head-row-height: 0px;
  864. @table-border-size: 0px;
  865. .table {
  866. margin-top: 10px;
  867. // border: @table-border-size solid #EBEDF0;
  868. width: 100%;
  869. height: @table-height;
  870. // >.table-head-row {
  871. // width: 100%;
  872. // height: @table-head-row-height;
  873. // background: #F5F7FA;
  874. // color: #646566;
  875. // .table-head {
  876. // font-size: 16px;
  877. // line-height: @table-head-row-height;
  878. // height: 100%;
  879. // display: inline-block;
  880. // &:nth-of-type(1) {
  881. // color: transparent;
  882. // }
  883. // }
  884. // }
  885. > .table-body {
  886. height: calc(
  887. @table-height - @table-head-row-height - @table-border-size -
  888. @table-border-size
  889. );
  890. overflow: auto;
  891. display: inline-block;
  892. width: 100%;
  893. .table-body-row {
  894. height: 50px;
  895. // border-bottom: 1px solid #EBEDF0;
  896. display: flex;
  897. align-items: center;
  898. border-radius: 4px;
  899. cursor: pointer;
  900. &:hover {
  901. background: #f7f8fa;
  902. }
  903. > .table-data {
  904. font-size: 14px;
  905. line-height: 50px;
  906. height: 100%;
  907. color: #323233;
  908. &:nth-of-type(1) {
  909. width: 50px;
  910. }
  911. &:nth-of-type(2) {
  912. width: 96px;
  913. }
  914. &:nth-of-type(3) {
  915. width: calc(100% - 50px - 96px);
  916. }
  917. &:last-of-type {
  918. padding-right: 10px;
  919. }
  920. > .list-img {
  921. position: relative;
  922. height: 100%;
  923. display: inline-block;
  924. width: 100%;
  925. > img,
  926. .audio-player {
  927. position: absolute;
  928. top: 50%;
  929. transform: translateY(-50%);
  930. width: 40px;
  931. height: 40px;
  932. object-fit: cover;
  933. &.folderIcon {
  934. object-fit: contain;
  935. }
  936. }
  937. }
  938. > .name:not(.searchRes) {
  939. display: inline-block;
  940. height: 100%;
  941. width: 100%;
  942. display: flex;
  943. align-items: center;
  944. > .name-inner {
  945. flex: 0 0 auto;
  946. display: inline-block;
  947. height: 100%;
  948. width: 50%;
  949. }
  950. > .upload-status {
  951. flex: 0 0 auto;
  952. display: inline-block;
  953. height: 100%;
  954. margin-left: 20px;
  955. }
  956. }
  957. > .name.searchRes {
  958. height: 100%;
  959. width: 100%;
  960. display: flex;
  961. flex-direction: column;
  962. justify-content: center;
  963. align-items: flex-start;
  964. line-height: initial;
  965. > .name-inner {
  966. flex: 0 0 auto;
  967. display: inline-block;
  968. width: 100%;
  969. }
  970. > .parent-info {
  971. > .parent-name {
  972. color: @color;
  973. }
  974. }
  975. }
  976. > .name:not(.upload-status-wrap):hover {
  977. > .name-inner {
  978. width: 100%;
  979. }
  980. }
  981. }
  982. }
  983. .no-more-data {
  984. margin-top: 16px;
  985. margin-bottom: 16px;
  986. text-align: center;
  987. font-size: 12px;
  988. color: #969799;
  989. }
  990. }
  991. > .no-data {
  992. height: calc(
  993. @table-height - @table-head-row-height - @table-border-size -
  994. @table-border-size
  995. );
  996. width: 100%;
  997. position: relative;
  998. > div {
  999. position: absolute;
  1000. top: 50%;
  1001. left: 50%;
  1002. transform: translate(-50%, -50%);
  1003. text-align: center;
  1004. > img {
  1005. width: 116px;
  1006. }
  1007. > span {
  1008. margin-top: 20px;
  1009. display: block;
  1010. font-size: 14px;
  1011. color: #646566;
  1012. }
  1013. > a {
  1014. > button {
  1015. margin-top: 20px;
  1016. }
  1017. }
  1018. }
  1019. }
  1020. }
  1021. .checkbox {
  1022. width: 100%;
  1023. height: 100%;
  1024. }
  1025. .btns {
  1026. left: 0;
  1027. margin-top: 29px;
  1028. .upload-btn {
  1029. display: flex;
  1030. align-items: center;
  1031. > span {
  1032. display: inline-block;
  1033. margin-right: 4px;
  1034. }
  1035. i.tool-tip-for-editor {
  1036. font-size: 12px;
  1037. transform: scale(0.923) translateY(1px);
  1038. cursor: default;
  1039. }
  1040. }
  1041. }
  1042. }
  1043. .material-list.dark {
  1044. .ellipsis {
  1045. }
  1046. .crumbs {
  1047. ul > li .name {
  1048. max-width: 80px;
  1049. display: block;
  1050. }
  1051. }
  1052. .table {
  1053. // border: @table-border-size solid #EBEDF0;
  1054. // >.table-head-row {
  1055. // background: #F5F7FA;
  1056. // color: #646566;
  1057. // .table-head {
  1058. // &:nth-of-type(1) {
  1059. // color: transparent;
  1060. // }
  1061. // }
  1062. // }
  1063. > .table-body {
  1064. .table-body-row {
  1065. // border-bottom: 1px solid #EBEDF0;
  1066. &:hover {
  1067. background: #252526;
  1068. }
  1069. > .table-data {
  1070. color: #fff;
  1071. > .list-img {
  1072. > img,
  1073. .audio-player {
  1074. &.folderIcon {
  1075. }
  1076. }
  1077. }
  1078. }
  1079. }
  1080. }
  1081. > .no-data {
  1082. > div {
  1083. > img {
  1084. }
  1085. > span {
  1086. color: rgba(255, 255, 255, 0.6);
  1087. }
  1088. > a {
  1089. > button {
  1090. }
  1091. }
  1092. }
  1093. }
  1094. }
  1095. .checkbox {
  1096. }
  1097. .btns {
  1098. .upload-btn {
  1099. > span {
  1100. }
  1101. i.tool-tip-for-editor {
  1102. }
  1103. }
  1104. }
  1105. }
  1106. </style>
  1107. <style lang="less">
  1108. .material-list,
  1109. .material-list.dark {
  1110. .crumbs {
  1111. // display: none;
  1112. ul > li {
  1113. display: flex;
  1114. justify-content: center;
  1115. align-items: center;
  1116. .name {
  1117. max-width: 180px;
  1118. display: block;
  1119. }
  1120. }
  1121. }
  1122. }
  1123. </style>