materialListInMaterialSelector.vue 29 KB

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