index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. <template>
  2. <div class="container">
  3. <!-- 搜索标题 -->
  4. <div class="searchTitle">
  5. <el-icon>
  6. <ArrowLeftBold />
  7. </el-icon>
  8. <div class="colLine"></div>
  9. <div class="searchTitle_text">“{{ searchText }}”的搜索结果</div>
  10. </div>
  11. <!-- 搜索选项 -->
  12. <div class="searchType">
  13. <div class="searchFor">
  14. <div class="search_title">搜索范围:</div>
  15. <el-tabs
  16. v-model="searchFor"
  17. class="demo-tabs"
  18. @tab-change="changeSearchFor"
  19. >
  20. <el-tab-pane label="公共" name="1"></el-tab-pane>
  21. <el-tab-pane label="部门" name="2"></el-tab-pane>
  22. <el-tab-pane label="个人" name="3"></el-tab-pane>
  23. </el-tabs>
  24. </div>
  25. <div class="line"></div>
  26. <div class="searchFor">
  27. <div class="search_title">分类:</div>
  28. <el-tabs
  29. v-model="searchType"
  30. class="demo-tabs"
  31. @tab-change="changeSearchType"
  32. >
  33. <el-tab-pane label="文档" name="doc"></el-tab-pane>
  34. <el-tab-pane label="图片" name="img"></el-tab-pane>
  35. <el-tab-pane label="音频" name="audio "></el-tab-pane>
  36. <el-tab-pane label="视频" name="video"></el-tab-pane>
  37. <el-tab-pane label="压缩包" name="zip"></el-tab-pane>
  38. </el-tabs>
  39. </div>
  40. </div>
  41. <!-- 排序显示 -->
  42. <div class="statistics">
  43. <div class="left_box">
  44. <div class="dataNum">共查询到{{ total }}个相关结果</div>
  45. </div>
  46. <div class="right_box">
  47. <img
  48. src="@/assets/images/sort.png"
  49. @click="changeSort"
  50. v-if="isAsc == 'asc'"
  51. alt=""
  52. />
  53. <img
  54. src="@/assets/images/Frame_188.png"
  55. @click="changeSort"
  56. v-else
  57. alt=""
  58. />
  59. <img
  60. v-if="isList"
  61. src="@/assets/images/squre.png"
  62. alt=""
  63. @click="changeShow"
  64. />
  65. <img
  66. v-else
  67. src="@/assets/images/Frame_187.png"
  68. alt=""
  69. @click="changeShow"
  70. />
  71. </div>
  72. </div>
  73. <!-- 文件列表 -->
  74. <div class="fileList">
  75. <div>
  76. <div v-if="isList">
  77. <!-- 表格 -->
  78. <el-table
  79. :data="tableData"
  80. style="width: 100%"
  81. height="100%"
  82. :scrollbar-always-on="true"
  83. >
  84. <el-table-column fixed prop="fileName" label="名称" width="500">
  85. <template #default="scope">
  86. <div class="flie_name">
  87. <img
  88. class="table_icon"
  89. :src="setIcon(scope.row.fileType)"
  90. alt=""
  91. style=""
  92. />
  93. {{ scope.row.fileName }}
  94. </div>
  95. </template>
  96. </el-table-column>
  97. <el-table-column prop="dir.dirName" label="所属空间" width="100" />
  98. <el-table-column prop="createTime" label="时间" width="200" />
  99. <el-table-column prop="fileType" label="类型" width="180" />
  100. <el-table-column prop="fileSize" label="大小" width="160">
  101. <template #default="scope">
  102. <div>{{ scope.row.fileSize }}KB</div>
  103. </template>
  104. </el-table-column>
  105. <el-table-column prop="dir.dirPath" label="文件夹" width="180">
  106. <template #default="scope">
  107. <div class="folder">
  108. {{ scope.row.dir.dirPath }}
  109. </div>
  110. </template>
  111. </el-table-column>
  112. </el-table>
  113. </div>
  114. <div v-else>
  115. <!-- 平铺 -->
  116. <div class="tile_box">
  117. <div class="file_box" v-for="item in tableData" :key="item">
  118. <img class="big_file_img" :src="setIcon(item.fileType)" alt="" />
  119. <span>{{ item.fileName }}</span>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. </template>
  127. <script setup>
  128. import { onMounted, ref, toRaw, inject } from "vue";
  129. import { search } from "@/api/search/search.js";
  130. import { flieSearch } from "@/api/search/search.js";
  131. import { useRoute } from "vue-router";
  132. const searchFor = ref("1"); //搜索范围
  133. const searchType = ref("doc"); //搜索对象
  134. const checkState = ref(false); //勾选框状态
  135. const activeNames = ref(["folder", "file"]);
  136. const isList = ref(true); //控制显示方式
  137. const isContent = ref(false); //内容搜索
  138. const total = ref(0); //数据总条数
  139. const searchText = ref(""); //搜索ipt的值
  140. const baseData = ref(); //搜索出的原始数据
  141. const isAsc = ref("asc");
  142. const reload = inject("reload");
  143. onMounted(() => {
  144. let route = useRoute();
  145. searchText.value = route.query.searchText;
  146. let searchData = route.query.searchData;
  147. // console.log("searchData", searchData);
  148. baseData.value = JSON.parse(searchData).rows;
  149. tableData.value = JSON.parse(searchData).rows;
  150. total.value = JSON.parse(searchData).total;
  151. // console.log("tableData", toRaw(tableData.value));
  152. changeSearchFor(searchFor.value);
  153. // console.log("total", total.value );
  154. });
  155. const tableData = ref([]);
  156. // 切换搜索范围
  157. const changeSearchFor = (name) => {
  158. // console.log('searchFor',searchFor.value);
  159. const typeArr = setType(searchType.value);
  160. let baseDataObj = toRaw(baseData.value);
  161. // console.log("baseDataObj", baseDataObj);
  162. tableData.value = toRaw(baseDataObj).filter(
  163. (item) => item.space.spaceType == name && typeArr.includes(item.fileType)
  164. );
  165. };
  166. // 切换搜索分类
  167. const changeSearchType = (name) => {
  168. let baseDataObj = toRaw(baseData.value);
  169. // 获取分类具体数据
  170. const typeArr = setType(name);
  171. tableData.value = toRaw(baseDataObj).filter(
  172. (item) =>
  173. typeArr.includes(item.fileType) && item.space.spaceType == searchFor.value
  174. );
  175. };
  176. const changeShow = () => {
  177. isList.value = !isList.value;
  178. };
  179. const changeSort = async () => {
  180. isAsc.value == "asc" ? (isAsc.value = "desc") : (isAsc.value = "asc");
  181. const query = {
  182. keyword: searchText.value,
  183. isAsc: isAsc.value,
  184. orderByColumn: "createTime",
  185. };
  186. const res = await flieSearch(query);
  187. baseData.value = res.rows;
  188. tableData.value = res.rows;
  189. changeSearchFor(searchFor.value);
  190. console.log("res", res);
  191. };
  192. // 根据选项对数据处理,返回处理后的数据
  193. const fliterListData = (dataList) => {
  194. return dataList;
  195. };
  196. // 设置图标
  197. const setIcon = (fileType) => {
  198. switch (fileType) {
  199. case ".docx":
  200. return "src/assets/images/fileType/file_DOC.png";
  201. break;
  202. case ".pdf":
  203. return "src/assets/images/fileType/file_pdf.png";
  204. break;
  205. case ".ppt":
  206. return "src/assets/images/fileType/file_PPT.png";
  207. break;
  208. case ".txt":
  209. return "src/assets/images/fileType/file_TXT.png";
  210. break;
  211. case ".xlsx":
  212. return "src/assets/images/fileType/file_XLSX.png";
  213. break;
  214. case ".csv":
  215. return "src/assets/images/fileType/file_XLSX.png";
  216. break;
  217. case ".png":
  218. return "src/assets/images/fileType/file_pic.png";
  219. break;
  220. case ".mp3":
  221. return "src/assets/images/fileType/file_audio.png";
  222. break;
  223. case ".mp4":
  224. return "src/assets/images/fileType/file_video.png";
  225. break;
  226. case ".zip":
  227. return "src/assets/images/fileType/file_zip.png";
  228. break;
  229. default:
  230. return "src/assets/images/fileType/file_DOC.png";
  231. break;
  232. }
  233. };
  234. // 设置分类
  235. const setType = (fileType) => {
  236. switch (fileType) {
  237. case "doc":
  238. return ['.txt',".ppd", ".pdf", ".docx", ".csv"];
  239. break;
  240. case "img":
  241. return [".png", ".jpg", ".jpeg"];
  242. break;
  243. case "audio":
  244. return [".mp3"];
  245. break;
  246. case "video":
  247. return [".mp4"];
  248. break;
  249. case "zip":
  250. return [".zip",'rar','.7z'];
  251. break;
  252. default:
  253. return [''];
  254. break;
  255. }
  256. };
  257. </script>
  258. <style lang="scss" scoped>
  259. .container {
  260. height: 100%;
  261. background-color: #fff;
  262. border-radius: 4px;
  263. }
  264. .searchTitle {
  265. width: 100%;
  266. height: 40px;
  267. padding-left: 8px;
  268. display: flex;
  269. align-items: center;
  270. .colLine {
  271. margin-left: 5px;
  272. height: 100%;
  273. border-right: 1px solid #c1cce3;
  274. }
  275. .searchTitle_text {
  276. font-size: 16px;
  277. font-weight: 400;
  278. line-height: 24px;
  279. margin-left: 16px;
  280. }
  281. }
  282. .searchType {
  283. width: 100%;
  284. height: 40px;
  285. box-sizing: border-box;
  286. background-color: #f5f7f9;
  287. border-top: 1px solid #c1cce3;
  288. border-bottom: 1px solid #c1cce3;
  289. padding-left: 16px;
  290. display: flex;
  291. align-items: center;
  292. .searchFor {
  293. height: 100%;
  294. display: flex;
  295. // align-items: center;
  296. .search_title {
  297. height: 100%;
  298. line-height: 40px;
  299. font-size: 14px;
  300. font-weight: 500;
  301. font-family: Inter-Medium;
  302. }
  303. }
  304. .line {
  305. width: 1px;
  306. height: 24px;
  307. border-left: 1px solid #c1cce3;
  308. margin: 0 16px;
  309. }
  310. }
  311. .statistics {
  312. width: 100%;
  313. height: 40px;
  314. // background-color: #ccc;
  315. padding-left: 16px;
  316. display: flex;
  317. justify-content: space-between;
  318. align-items: center;
  319. .left_box {
  320. display: flex;
  321. align-items: center;
  322. .dataNum {
  323. margin-left: 4px;
  324. font-size: 14px;
  325. font-weight: 400;
  326. }
  327. }
  328. .right_box {
  329. width: 50px;
  330. display: flex;
  331. justify-content: space-between;
  332. margin-right: 30px;
  333. img {
  334. cursor: pointer;
  335. }
  336. }
  337. }
  338. .fileList {
  339. height: 100%;
  340. .content_box {
  341. width: 100%;
  342. height: 100%;
  343. padding: 16px;
  344. .oneBox {
  345. width: 100%;
  346. height: 120px;
  347. border-bottom: 1px dashed #c1cce3;
  348. .fileName {
  349. font-size: 16px;
  350. color: #2e6bc8;
  351. text-decoration: underline;
  352. font-family: Inter-SemiBold;
  353. }
  354. .flieTime {
  355. font-size: 12px;
  356. font-weight: 400;
  357. color: #06286c;
  358. line-height: 20px;
  359. }
  360. .flieContent {
  361. width: 100%;
  362. font-size: 14px;
  363. color: #000000;
  364. font-weight: 400;
  365. line-height: 22px;
  366. display: -webkit-box;
  367. -webkit-box-orient: vertical;
  368. text-overflow: ellipsis;
  369. -webkit-line-clamp: 3; //例如超过3行显示省略号
  370. overflow: hidden;
  371. em {
  372. color: #dd2025;
  373. }
  374. }
  375. }
  376. }
  377. }
  378. //表格文本超出隐藏
  379. ::v-deep .flie_name,
  380. .folder {
  381. /*第一步: 溢出隐藏 */
  382. overflow: hidden;
  383. /* 第二步:让文本不会换行, 在同一行继续 */
  384. white-space: nowrap;
  385. /* 第三步:用省略号来代表未显示完的文本 */
  386. text-overflow: ellipsis;
  387. }
  388. // tag间距
  389. ::v-deep .el-tabs__item {
  390. padding: 0 16px !important;
  391. color: #505870 !important;
  392. font-weight: 400 !important;
  393. }
  394. ::v-deep .el-tabs--top .el-tabs__item.is-top:nth-child(2) {
  395. padding-left: 0 !important;
  396. }
  397. ::v-deep .el-tabs--top .el-tabs__item.is-top:last-child {
  398. padding-right: 0 !important;
  399. }
  400. // tag选中颜色
  401. ::v-deep .el-tabs__item.is-active {
  402. color: #2e6bc8 !important;
  403. font-weight: normal;
  404. font-family: Inter-SemiBold;
  405. }
  406. ::v-deep .el-tabs__active-bar {
  407. background-color: #2e6bc8;
  408. }
  409. ::v-deep .el-table__inner-wrapper::before {
  410. background-color: #fff !important;
  411. }
  412. ::v-deep .el-collapse,
  413. .el-collapse-item__wrap {
  414. border: none;
  415. }
  416. .table_icon {
  417. height: 27px;
  418. width: 27px;
  419. vertical-align: middle;
  420. }
  421. ::v-deep .el-collapse-item__content {
  422. padding-bottom: 0;
  423. }
  424. ::v-deep .el-collapse-item__header {
  425. background-color: #ebeff6 !important;
  426. width: 100% !important;
  427. height: 24px !important;
  428. }
  429. ::v-deep .el-collapse-item__arrow {
  430. position: relative;
  431. color: #2e6bc8;
  432. right: 97%;
  433. }
  434. ::v-deep .el-table td.el-table__cell {
  435. border: none;
  436. font-size: 14px !important;
  437. font-weight: 400 !important;
  438. color: #000 !important;
  439. }
  440. ::v-deep .el-table__row {
  441. height: 35px !important;
  442. }
  443. ::v-deep .el-table .el-table__header-wrapper th {
  444. border-bottom: none;
  445. border-right: 1px solid #c1cce3;
  446. background-color: #fff !important;
  447. color: #505870;
  448. font-size: 14px;
  449. }
  450. .collapseItem_title {
  451. position: relative;
  452. left: 40px;
  453. color: #2e6bc8;
  454. font-family: Inter-Medium;
  455. font-size: 12px;
  456. }
  457. // 表格右边3个靠右对齐
  458. ::v-deep .el-table__header thead tr th {
  459. font-family: Inter-Medium;
  460. font-size: 14px;
  461. color: #505870;
  462. text-align: right;
  463. &:nth-child(1) {
  464. text-align: left;
  465. }
  466. }
  467. // ::v-deep .el-table__body tbody [class*="column_2"] {
  468. // text-align: right;
  469. // }
  470. // ::v-deep .el-table__body tbody [class*="column_3"] {
  471. // text-align: right;
  472. // }
  473. // ::v-deep .el-table__body tbody [class*="column_4"] {
  474. // text-align: right;
  475. // }
  476. // ::v-deep .el-table__body tbody [class*="column_6"] {
  477. // text-align: right;
  478. // }
  479. // ::v-deep .el-table__body tbody [class*="column_7"] {
  480. // text-align: right;
  481. // }
  482. ::v-deep .el-table__body tbody [class*="column_"] {
  483. text-align: right;
  484. &:nth-child(4n + 1) {
  485. text-align: left;
  486. }
  487. }
  488. //平铺
  489. .tile_box {
  490. width: 100%;
  491. height: 300px;
  492. display: flex;
  493. flex-wrap: wrap;
  494. .file_box {
  495. width: 116px;
  496. min-height: 138px;
  497. // border: 1px solid #000;
  498. display: flex;
  499. flex-direction: column;
  500. align-items: center;
  501. .big_file_img {
  502. width: 100px;
  503. height: 100px;
  504. }
  505. span {
  506. font-size: 14px;
  507. font-weight: 400;
  508. line-height: 22px;
  509. }
  510. }
  511. }
  512. </style>