index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <div class="container">
  3. <!-- 搜索标题 -->
  4. <div class="searchTitle">
  5. <el-icon @click="goBack">
  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="space.spaceName" label="所属空间" width="180" />
  98. <el-table-column prop="createTime" label="时间" width="200" />
  99. <el-table-column prop="fileType" label="类型" width="80" />
  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?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,useRouter } 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 router = useRouter(); //注册路由
  143. const reload = inject("reload");
  144. onMounted(() => {
  145. let route = useRoute();
  146. searchText.value = route.query.searchText;
  147. let searchData = route.query.searchData;
  148. // console.log("searchData", searchData);
  149. baseData.value = JSON.parse(searchData).rows;
  150. tableData.value = JSON.parse(searchData).rows;
  151. total.value = JSON.parse(searchData).total;
  152. // console.log("tableData", toRaw(tableData.value));
  153. changeSearchFor(searchFor.value);
  154. // console.log("total", total.value );
  155. });
  156. const tableData = ref([]);
  157. // 切换搜索范围
  158. const changeSearchFor = (name) => {
  159. // console.log('searchFor',searchFor.value);
  160. const typeArr = setType(searchType.value);
  161. let baseDataObj = toRaw(baseData.value);
  162. // console.log("baseDataObj", baseDataObj);
  163. tableData.value = toRaw(baseDataObj).filter(
  164. (item) => item.space.spaceType == name && typeArr.includes(item.fileType)
  165. );
  166. };
  167. // 切换搜索分类
  168. const changeSearchType = (name) => {
  169. let baseDataObj = toRaw(baseData.value);
  170. // 获取分类具体数据
  171. const typeArr = setType(name);
  172. tableData.value = toRaw(baseDataObj).filter(
  173. (item) =>
  174. typeArr.includes(item.fileType) && item.space.spaceType == searchFor.value
  175. );
  176. };
  177. const changeShow = () => {
  178. isList.value = !isList.value;
  179. };
  180. const changeSort = async () => {
  181. isAsc.value == "asc" ? (isAsc.value = "desc") : (isAsc.value = "asc");
  182. const query = {
  183. keyword: searchText.value,
  184. isAsc: isAsc.value,
  185. orderByColumn: "createTime",
  186. };
  187. const res = await flieSearch(query);
  188. baseData.value = res.rows;
  189. tableData.value = res.rows;
  190. changeSearchFor(searchFor.value);
  191. console.log("res", res);
  192. };
  193. // 根据选项对数据处理,返回处理后的数据
  194. const fliterListData = (dataList) => {
  195. return dataList;
  196. };
  197. // 回退
  198. const goBack = ()=>{
  199. router.back()
  200. }
  201. // 设置图标
  202. const setIcon = (fileType) => {
  203. switch (fileType) {
  204. case ".docx":
  205. return "src/assets/images/fileType/file_DOC.png";
  206. break;
  207. case ".pdf":
  208. return "src/assets/images/fileType/file_pdf.png";
  209. break;
  210. case ".ppt":
  211. return "src/assets/images/fileType/file_PPT.png";
  212. break;
  213. case ".txt":
  214. return "src/assets/images/fileType/file_TXT.png";
  215. break;
  216. case ".xlsx":
  217. return "src/assets/images/fileType/file_XLSX.png";
  218. break;
  219. case ".csv":
  220. return "src/assets/images/fileType/file_XLSX.png";
  221. break;
  222. case ".png":
  223. return "src/assets/images/fileType/file_pic.png";
  224. break;
  225. case ".mp3":
  226. return "src/assets/images/fileType/file_audio.png";
  227. break;
  228. case ".mp4":
  229. return "src/assets/images/fileType/file_video.png";
  230. break;
  231. case ".zip":
  232. return "src/assets/images/fileType/file_zip.png";
  233. break;
  234. default:
  235. return "src/assets/images/fileType/file_DOC.png";
  236. break;
  237. }
  238. };
  239. // 设置分类
  240. const setType = (fileType) => {
  241. switch (fileType) {
  242. case "doc":
  243. return ['.txt',".ppd", ".pdf", ".docx", ".csv"];
  244. break;
  245. case "img":
  246. return [".png", ".jpg", ".jpeg"];
  247. break;
  248. case "audio":
  249. return [".mp3"];
  250. break;
  251. case "video":
  252. return [".mp4"];
  253. break;
  254. case "zip":
  255. return [".zip",'rar','.7z'];
  256. break;
  257. default:
  258. return [''];
  259. break;
  260. }
  261. };
  262. </script>
  263. <style lang="scss" scoped>
  264. .container {
  265. height: 100%;
  266. background-color: #fff;
  267. border-radius: 4px;
  268. }
  269. .searchTitle {
  270. width: 100%;
  271. height: 40px;
  272. padding-left: 8px;
  273. display: flex;
  274. align-items: center;
  275. .colLine {
  276. margin-left: 5px;
  277. height: 100%;
  278. border-right: 1px solid #c1cce3;
  279. }
  280. .searchTitle_text {
  281. font-size: 16px;
  282. font-weight: 400;
  283. line-height: 24px;
  284. margin-left: 16px;
  285. }
  286. }
  287. .searchType {
  288. width: 100%;
  289. height: 40px;
  290. box-sizing: border-box;
  291. background-color: #f5f7f9;
  292. border-top: 1px solid #c1cce3;
  293. border-bottom: 1px solid #c1cce3;
  294. padding-left: 16px;
  295. display: flex;
  296. align-items: center;
  297. .searchFor {
  298. height: 100%;
  299. display: flex;
  300. // align-items: center;
  301. .search_title {
  302. height: 100%;
  303. line-height: 40px;
  304. font-size: 14px;
  305. font-weight: 500;
  306. font-family: Inter-Medium;
  307. }
  308. }
  309. .line {
  310. width: 1px;
  311. height: 24px;
  312. border-left: 1px solid #c1cce3;
  313. margin: 0 16px;
  314. }
  315. }
  316. .statistics {
  317. width: 100%;
  318. height: 40px;
  319. // background-color: #ccc;
  320. padding-left: 16px;
  321. display: flex;
  322. justify-content: space-between;
  323. align-items: center;
  324. .left_box {
  325. display: flex;
  326. align-items: center;
  327. .dataNum {
  328. margin-left: 4px;
  329. font-size: 14px;
  330. font-weight: 400;
  331. }
  332. }
  333. .right_box {
  334. width: 50px;
  335. display: flex;
  336. justify-content: space-between;
  337. margin-right: 30px;
  338. img {
  339. cursor: pointer;
  340. }
  341. }
  342. }
  343. .fileList {
  344. height: 100%;
  345. .content_box {
  346. width: 100%;
  347. height: 100%;
  348. padding: 16px;
  349. .oneBox {
  350. width: 100%;
  351. height: 120px;
  352. border-bottom: 1px dashed #c1cce3;
  353. .fileName {
  354. font-size: 16px;
  355. color: #2e6bc8;
  356. text-decoration: underline;
  357. font-family: Inter-SemiBold;
  358. }
  359. .flieTime {
  360. font-size: 12px;
  361. font-weight: 400;
  362. color: #06286c;
  363. line-height: 20px;
  364. }
  365. .flieContent {
  366. width: 100%;
  367. font-size: 14px;
  368. color: #000000;
  369. font-weight: 400;
  370. line-height: 22px;
  371. display: -webkit-box;
  372. -webkit-box-orient: vertical;
  373. text-overflow: ellipsis;
  374. -webkit-line-clamp: 3; //例如超过3行显示省略号
  375. overflow: hidden;
  376. em {
  377. color: #dd2025;
  378. }
  379. }
  380. }
  381. }
  382. }
  383. //表格文本超出隐藏
  384. ::v-deep .flie_name,
  385. .folder {
  386. /*第一步: 溢出隐藏 */
  387. overflow: hidden;
  388. /* 第二步:让文本不会换行, 在同一行继续 */
  389. white-space: nowrap;
  390. /* 第三步:用省略号来代表未显示完的文本 */
  391. text-overflow: ellipsis;
  392. }
  393. // tag间距
  394. ::v-deep .el-tabs__item {
  395. padding: 0 16px !important;
  396. color: #505870 !important;
  397. font-weight: 400 !important;
  398. }
  399. ::v-deep .el-tabs--top .el-tabs__item.is-top:nth-child(2) {
  400. padding-left: 0 !important;
  401. }
  402. ::v-deep .el-tabs--top .el-tabs__item.is-top:last-child {
  403. padding-right: 0 !important;
  404. }
  405. // tag选中颜色
  406. ::v-deep .el-tabs__item.is-active {
  407. color: #2e6bc8 !important;
  408. font-weight: normal;
  409. font-family: Inter-SemiBold;
  410. }
  411. ::v-deep .el-tabs__active-bar {
  412. background-color: #2e6bc8;
  413. }
  414. ::v-deep .el-table__inner-wrapper::before {
  415. background-color: #fff !important;
  416. }
  417. ::v-deep .el-collapse,
  418. .el-collapse-item__wrap {
  419. border: none;
  420. }
  421. .table_icon {
  422. height: 27px;
  423. width: 27px;
  424. vertical-align: middle;
  425. }
  426. ::v-deep .el-collapse-item__content {
  427. padding-bottom: 0;
  428. }
  429. ::v-deep .el-collapse-item__header {
  430. background-color: #ebeff6 !important;
  431. width: 100% !important;
  432. height: 24px !important;
  433. }
  434. ::v-deep .el-collapse-item__arrow {
  435. position: relative;
  436. color: #2e6bc8;
  437. right: 97%;
  438. }
  439. ::v-deep .el-table td.el-table__cell {
  440. border: none;
  441. font-size: 14px !important;
  442. font-weight: 400 !important;
  443. color: #000 !important;
  444. }
  445. ::v-deep .el-table__row {
  446. height: 35px !important;
  447. }
  448. ::v-deep .el-table .el-table__header-wrapper th {
  449. border-bottom: none;
  450. border-right: 1px solid #c1cce3;
  451. background-color: #fff !important;
  452. color: #505870;
  453. font-size: 14px;
  454. }
  455. .collapseItem_title {
  456. position: relative;
  457. left: 40px;
  458. color: #2e6bc8;
  459. font-family: Inter-Medium;
  460. font-size: 12px;
  461. }
  462. // 表格右边3个靠右对齐
  463. ::v-deep .el-table__header thead tr th {
  464. font-family: Inter-Medium;
  465. font-size: 14px;
  466. color: #505870;
  467. text-align: right;
  468. &:nth-child(1) {
  469. text-align: left;
  470. }
  471. }
  472. // ::v-deep .el-table__body tbody [class*="column_2"] {
  473. // text-align: right;
  474. // }
  475. // ::v-deep .el-table__body tbody [class*="column_3"] {
  476. // text-align: right;
  477. // }
  478. // ::v-deep .el-table__body tbody [class*="column_4"] {
  479. // text-align: right;
  480. // }
  481. // ::v-deep .el-table__body tbody [class*="column_6"] {
  482. // text-align: right;
  483. // }
  484. // ::v-deep .el-table__body tbody [class*="column_7"] {
  485. // text-align: right;
  486. // }
  487. ::v-deep .el-table__body tbody [class*="column_"] {
  488. text-align: right;
  489. &:nth-child(4n + 1) {
  490. text-align: left;
  491. }
  492. }
  493. //平铺
  494. .tile_box {
  495. width: 100%;
  496. height: 300px;
  497. display: flex;
  498. flex-wrap: wrap;
  499. .file_box {
  500. width: 116px;
  501. min-height: 138px;
  502. // border: 1px solid #000;
  503. display: flex;
  504. flex-direction: column;
  505. align-items: center;
  506. .big_file_img {
  507. width: 100px;
  508. height: 100px;
  509. }
  510. span {
  511. font-size: 14px;
  512. font-weight: 400;
  513. line-height: 22px;
  514. }
  515. }
  516. }
  517. </style>