materialListInMaterialSelector.vue 30 KB

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