ListShow.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. <template>
  2. <div>
  3. <div class="topMenu">
  4. <div class="left_search">
  5. <div class="search_box">
  6. <el-input
  7. v-model="searchFire"
  8. @keyup.enter="fileBlur"
  9. @input="fileBlur"
  10. class="searchFire"
  11. size="large"
  12. placeholder="搜索文件"
  13. />
  14. <el-icon class="SearchIcon" @click="fileBlur">
  15. <Search />
  16. </el-icon>
  17. </div>
  18. <div class="line">|</div>
  19. <div class="searchFor">
  20. <div class="search_title">筛选:</div>
  21. <el-tabs
  22. v-model="searchType"
  23. class="demo-tabs"
  24. @tab-change="changeSearchType"
  25. >
  26. <el-tab-pane label="全部" name="all"></el-tab-pane>
  27. <el-tab-pane label="文档" name="doc"></el-tab-pane>
  28. <el-tab-pane label="图片" name="img"></el-tab-pane>
  29. <el-tab-pane label="音频" name="audio"></el-tab-pane>
  30. <el-tab-pane label="视频" name="video"></el-tab-pane>
  31. <el-tab-pane label="压缩包" name="zip"></el-tab-pane>
  32. </el-tabs>
  33. </div>
  34. </div>
  35. <div class="changeIcon">
  36. <img
  37. src="@/assets/images/sort.png"
  38. @click="changeSort"
  39. v-if="isAsc == 'asc'"
  40. alt=""
  41. />
  42. <img
  43. src="@/assets/images/Frame_188.png"
  44. @click="changeSort"
  45. v-else
  46. alt=""
  47. />
  48. </div>
  49. </div>
  50. <div class="table_box">
  51. <el-table
  52. :data="tableData"
  53. style="width: 100%; height: calc(88vh - 48px)"
  54. ref="container"
  55. @row-contextmenu="rightClick"
  56. @selection-change="SelectionChange"
  57. >
  58. <el-table-column type="selection" width="55" />
  59. <el-table-column label="名称" :show-overflow-tooltip="true">
  60. <template #default="scope">
  61. <div class="flie_name">
  62. <el-icon
  63. v-if="scope.row.isFavorite == 'N'"
  64. @click.stop="collect(scope.row, false)"
  65. style="margin-right: 7px"
  66. >
  67. <Star />
  68. </el-icon>
  69. <img
  70. v-else
  71. @click.stop="dCollect(scope.row, false)"
  72. src="../../assets/images/yellowstar.png"
  73. alt=""
  74. style="margin-right: 5px"
  75. />
  76. <img
  77. class="table_icon"
  78. :src="setIcon(scope.row.fileType)"
  79. alt=""
  80. style=""
  81. />
  82. {{ scope.row.fileName }}
  83. </div>
  84. </template>
  85. </el-table-column>
  86. <el-table-column prop="createTime" label="时间" width="200" />
  87. <el-table-column prop="fileType" label="类型" width="200" />
  88. <el-table-column prop="fileSize" label="大小" width="200">
  89. <template #default="scope">
  90. <div>{{ formatFileSize(scope.row.fileSize) }}</div>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. </div>
  95. </div>
  96. </template>
  97. <script setup>
  98. import { onMounted, ref, watch, nextTick, inject } from "vue";
  99. //---------------导入图片--------------------------
  100. import file_DOC from "@/assets/images/fileType/file_DOC.png";
  101. import file_pdf from "@/assets/images/fileType/file_pdf.png";
  102. import file_PPT from "@/assets/images/fileType/file_PPT.png";
  103. import file_TXT from "@/assets/images/fileType/file_TXT.png";
  104. import file_XLSX from "@/assets/images/fileType/file_XLSX.png";
  105. import file_pic from "@/assets/images/fileType/file_pic.png";
  106. import file_audio from "@/assets/images/fileType/file_audio.png";
  107. import file_video from "@/assets/images/fileType/file_video.png";
  108. import file_zip from "@/assets/images/fileType/file_zip.png";
  109. //----------------------------------------
  110. const searchType = ref("all");
  111. const baseData = ref(); //拿到的全部数据
  112. const typeData = ref(); //当前分类下的数据
  113. const tableData = ref(); // 表格展示的数据
  114. const searchFire = ref();
  115. const copyFileType = ref();
  116. const isAsc = ref("asc");
  117. const props = defineProps({
  118. fileList: {
  119. type: Array,
  120. default: () => [],
  121. },
  122. });
  123. const emit = defineEmits([
  124. "handleRowClick",
  125. "delCollect",
  126. "collectByStar",
  127. "changeListSort",
  128. 'handleSelectionChange'
  129. ]);
  130. // 排序
  131. const changeSort = async () => {
  132. isAsc.value == "asc" ? (isAsc.value = "desc") : (isAsc.value = "asc");
  133. // refreshFile();
  134. emit("changeListSort", isAsc.value);
  135. };
  136. // 切换搜索分类
  137. const changeSearchType = (name) => {
  138. let baseDataObj = props.fileList;
  139. // console.log("baseDataObj", baseDataObj);
  140. if (name == "all") {
  141. tableData.value = baseDataObj;
  142. } else {
  143. // 获取分类具体数据
  144. // console.log("name", name);
  145. const typeArr = setType(name);
  146. // console.log(typeArr, "类型");
  147. typeData.value = toRaw(baseDataObj).filter((item) => {
  148. return typeArr.includes(item.fileType);
  149. });
  150. tableData.value = typeData.value;
  151. // console.log(tableData.value, "数组");
  152. }
  153. };
  154. //搜索框模糊搜索事件
  155. const fileBlur = () => {
  156. const arr = typeData.value || props.fileList;
  157. tableData.value = arr.filter((item) => {
  158. if (item.fileName.includes(searchFire.value)) {
  159. return item;
  160. }
  161. });
  162. };
  163. // 勾选框发生改变
  164. const SelectionChange = (val)=>{
  165. emit('handleSelectionChange',val)
  166. }
  167. const rightClick = (row, col, e) => {
  168. emit("handleRowClick", row, null, e);
  169. };
  170. const collect = (row, bool) => {
  171. emit("collectByStar", row, bool);
  172. };
  173. const dCollect = (row, bool) => {
  174. emit("delCollect", row, bool);
  175. };
  176. //工具函数
  177. //对mouseCli数组进行筛选,实现菜单的区分显示
  178. const filterMouseCli = () => {
  179. const canPreviewArray = [
  180. ".doc",
  181. ".dps",
  182. ".et",
  183. ".wps",
  184. ".docm",
  185. ".docx",
  186. ".dot",
  187. ".dotm",
  188. ".dotx",
  189. ".epub",
  190. ".fodt",
  191. ".htm",
  192. ".html",
  193. ".mht",
  194. ".odt",
  195. ".ott",
  196. ".pdf",
  197. ".rtf",
  198. ".txt",
  199. ".djvu",
  200. ".xps",
  201. ".csv",
  202. ".fods",
  203. ".ods",
  204. ".ots",
  205. ".xls",
  206. ".xlsm",
  207. ".xlsx",
  208. ".xlt",
  209. ".xltm",
  210. ".xltx",
  211. ".fodp",
  212. ".odp",
  213. ".otp",
  214. ".pot",
  215. ".potm",
  216. ".potx",
  217. ".pps",
  218. ".ppsm",
  219. ".ppsx",
  220. ".ppt",
  221. ".pptm",
  222. ".pptx",
  223. ];
  224. const typeArr = [".png", ".jpg", ".jpeg", ".JPG", ".PNG", ".mp3", ".mp4"];
  225. const imgTypeArr = [".png", ".jpg", ".jpeg", ".JPG", ".PNG"];
  226. const canEditArr = [
  227. ".doc",
  228. ".docm",
  229. ".docx",
  230. ".dot",
  231. ".dotm",
  232. ".dotx",
  233. ".txt",
  234. ".djvu",
  235. ".xps",
  236. ".csv",
  237. ".fods",
  238. ".ods",
  239. ".ots",
  240. ".xls",
  241. ".xlsm",
  242. ".xlsx",
  243. ".xlt",
  244. ".xltm",
  245. ".xltx",
  246. ".fodp",
  247. ".odp",
  248. ".otp",
  249. ".doc",
  250. ".docm",
  251. ".docx",
  252. ".dot",
  253. ".dotm",
  254. ".dotx",
  255. ".epub",
  256. ".fodt",
  257. ".htm",
  258. ".html",
  259. ".mht",
  260. ".odt",
  261. ".ott",
  262. ".rtf",
  263. ".txt",
  264. ".djvu",
  265. ".xps",
  266. ".wps",
  267. ".dps",
  268. ".et",
  269. ".pptx",
  270. ];
  271. let arr = [];
  272. if (
  273. !(
  274. typeArr.includes(copyFileType.value) ||
  275. canPreviewArray.includes(copyFileType.value)
  276. )
  277. ) {
  278. arr = mouseCli.value.filter((item) => item.name !== "预览");
  279. } else {
  280. arr = toRaw(mouseCli.value);
  281. }
  282. if (!canEditArr.includes(copyFileType.value)) {
  283. arr = arr.filter(
  284. (item) =>
  285. item.name !== "在线编辑" &&
  286. item.name !== "协作" &&
  287. item.name !== "历史版本"
  288. );
  289. }
  290. if (clickRow.value.isFiled === "Y") {
  291. arr = arr.filter(
  292. (item) => item.name !== "在线编辑" && item.name !== "协作"
  293. );
  294. }
  295. if (!imgTypeArr.includes(copyFileType.value)) {
  296. arr = arr.filter((item) => item.name !== "文字识别");
  297. }
  298. // console.log('arr',arr);
  299. if (thisFolderRole.value) {
  300. arr = rightMenuRole(toRaw(thisFolderRole.value), arr);
  301. }
  302. return arr;
  303. };
  304. // 设置图标
  305. const setIcon = (fileType) => {
  306. switch (fileType) {
  307. case ".docx":
  308. return file_DOC;
  309. break;
  310. case ".pdf":
  311. return file_pdf;
  312. break;
  313. case ".ppt":
  314. return file_PPT;
  315. break;
  316. case ".txt":
  317. return file_TXT;
  318. break;
  319. case ".xlsx":
  320. return file_XLSX;
  321. break;
  322. case ".csv":
  323. return file_XLSX;
  324. break;
  325. case ".png":
  326. return file_pic;
  327. break;
  328. case ".mp3":
  329. return file_audio;
  330. break;
  331. case ".mp4":
  332. return file_video;
  333. break;
  334. case ".zip":
  335. return file_zip;
  336. break;
  337. default:
  338. return file_DOC;
  339. break;
  340. }
  341. };
  342. // 设置分类
  343. const setType = (fileType) => {
  344. switch (fileType) {
  345. case "doc":
  346. return [
  347. ".txt",
  348. ".ppt",
  349. ".pdf",
  350. ".docx",
  351. ".csv",
  352. ".wps",
  353. ".xls",
  354. ".pptxs",
  355. ".dll",
  356. ".pptx",
  357. ".doc",
  358. ];
  359. break;
  360. case "img":
  361. return [".png", ".PNG", ".jpg", ".jpeg"];
  362. break;
  363. case "audio":
  364. return [".mp3"];
  365. break;
  366. case "video":
  367. return [".mp4", ".qlv"];
  368. break;
  369. case "zip":
  370. return [".zip", ".rar", ".7z"];
  371. break;
  372. default:
  373. return [""];
  374. break;
  375. }
  376. };
  377. function formatFileSize(fileSize) {
  378. if (fileSize >= 1024 * 1024 * 1024) {
  379. // 大于等于1GB,显示GB
  380. return (fileSize / (1024 * 1024 * 1024)).toFixed(2) + "GB";
  381. } else if (fileSize >= 1024 * 1024) {
  382. // 大于等于1MB,显示MB
  383. return (fileSize / (1024 * 1024)).toFixed(2) + "MB";
  384. } else if (fileSize >= 1024) {
  385. // 大于等于1KB,显示KB
  386. return (fileSize / 1024).toFixed(2) + "KB";
  387. } else {
  388. // 小于1KB,显示字节
  389. return fileSize + "B";
  390. }
  391. }
  392. watch(
  393. () => props.fileList,
  394. (newValue, oldValue) => {
  395. tableData.value = newValue;
  396. changeSearchType(searchType.value);
  397. // console.log("watchtableData", tableData.value);
  398. },
  399. {
  400. immediate: true,
  401. deep: true,
  402. }
  403. );
  404. </script>
  405. <style lang="scss" scoped>
  406. .topMenu {
  407. width: 100%;
  408. height: 48px;
  409. border: 1px solid #c1cce3;
  410. background: #f5f7f9;
  411. padding: 0 16px;
  412. // box-sizing: border-box;
  413. display: flex;
  414. align-items: center;
  415. .left_search {
  416. width: 100%;
  417. height: 48px;
  418. display: flex;
  419. align-items: center;
  420. }
  421. .search_box {
  422. width: 320px;
  423. height: 48px;
  424. display: flex;
  425. align-items: center;
  426. position: relative;
  427. .SearchIcon {
  428. color: gray;
  429. position: absolute;
  430. right: 22px;
  431. }
  432. }
  433. .line {
  434. margin: 0 16px;
  435. color: #c1cce3;
  436. }
  437. .searchFor {
  438. height: 100%;
  439. display: flex;
  440. // align-items: center;
  441. .search_title {
  442. height: 100%;
  443. line-height: 48px;
  444. font-size: 14px;
  445. font-weight: 500;
  446. font-family: Inter-Medium;
  447. }
  448. }
  449. }
  450. .setCli {
  451. width: 156px;
  452. max-height: auto;
  453. position: absolute;
  454. top: -70px;
  455. left: 300px;
  456. flex-wrap: 400;
  457. background-color: white;
  458. border: 1px solid gray;
  459. border-radius: 4px;
  460. z-index: 3;
  461. overflow-y: auto;
  462. // font-size: 16px;
  463. }
  464. .setCli1 {
  465. width: 156px;
  466. height: auto;
  467. position: absolute;
  468. background-color: white;
  469. border: 1px solid gray;
  470. border-radius: 4px;
  471. z-index: 100;
  472. overflow-y: auto;
  473. }
  474. .chooseSet {
  475. width: 140px;
  476. height: 30px;
  477. line-height: 30px;
  478. margin: 5px auto;
  479. font-size: 13px;
  480. cursor: pointer;
  481. // display: flex;
  482. // align-items: center;
  483. // position: relative;
  484. img {
  485. margin-right: 4px;
  486. vertical-align: middle;
  487. }
  488. }
  489. .chooseSet:hover {
  490. width: 140px;
  491. height: 30px;
  492. line-height: 30px;
  493. margin: 5px auto;
  494. font-size: 13px;
  495. background-color: #f5f7f9;
  496. /* color: white; */
  497. }
  498. .table_box {
  499. height: calc(88vh - 48px);
  500. // border: 1px solid #000;
  501. }
  502. // tag间距
  503. :deep(.el-tabs) {
  504. --el-tabs-header-height: 48px !important;
  505. }
  506. :deep(.el-tabs__item) {
  507. padding: 0 16px !important;
  508. color: #505870 !important;
  509. font-weight: 400 !important;
  510. }
  511. // tag选中颜色
  512. :deep(.el-tabs__item.is-active) {
  513. color: #2e6bc8 !important;
  514. font-weight: normal;
  515. font-family: Inter-SemiBold;
  516. }
  517. :deep(.el-tabs__active-bar) {
  518. background-color: #2e6bc8;
  519. }
  520. :deep(.el-table__inner-wrapper::before) {
  521. background-color: #fff !important;
  522. }
  523. :deep(.el-collapse, .el-collapse-item__wrap) {
  524. border: none;
  525. }
  526. .table_icon {
  527. height: 27px;
  528. width: 27px;
  529. vertical-align: middle;
  530. }
  531. :deep(.el-collapse-item__content) {
  532. padding-bottom: 0;
  533. }
  534. :deep(.el-collapse-item__header) {
  535. background-color: #ebeff6 !important;
  536. width: 100% !important;
  537. height: 24px !important;
  538. }
  539. :deep(.el-collapse-item__arrow) {
  540. position: relative;
  541. color: #2e6bc8;
  542. right: 97%;
  543. }
  544. :deep(.el-table td.el-table__cell) {
  545. border: none;
  546. font-size: 14px !important;
  547. font-weight: 400 !important;
  548. color: #000 !important;
  549. }
  550. :deep(.el-table__row) {
  551. height: 35px !important;
  552. }
  553. :deep(.el-table .el-table__header-wrapper th) {
  554. border-bottom: none;
  555. border-right: 1px solid #c1cce3;
  556. background-color: #fff !important;
  557. color: #505870;
  558. font-size: 14px;
  559. }
  560. </style>