HighSearch.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <template>
  2. <div class="container">
  3. <div class="logo">
  4. <img src="@/assets/images/logos.png" alt="" />
  5. <div class="font">聚合智慧文档管理系统</div>
  6. </div>
  7. <div class="search_box">
  8. <el-select
  9. v-model="selectValue"
  10. class="m-2"
  11. popper-class="typeSelect"
  12. placeholder="Select"
  13. size="large"
  14. >
  15. <el-option
  16. v-for="item in selectOptions"
  17. :key="item.value"
  18. :label="item.label"
  19. :value="item.value"
  20. >
  21. <span style="float: left">{{ item.label }}</span>
  22. <div
  23. v-if="item.value === selectValue"
  24. style="
  25. position: relative;
  26. right: -13px;
  27. color: #000;
  28. font-weight: 700;
  29. font-size: 13px;
  30. text-align: right;
  31. box-sizing: border-box;
  32. "
  33. >
  34. </div>
  35. </el-option>
  36. </el-select>
  37. <div class="line">|</div>
  38. <el-input
  39. class="search_ipt"
  40. v-model="searchText"
  41. maxlength="32"
  42. @keydown.enter="doSearch"
  43. placeholder="请输入要查询的内容"
  44. />
  45. <div class="search_btn" @click="doSearch" style="cursor: pointer">搜索</div>
  46. </div>
  47. <div class="result_box">
  48. <div class="left_box" v-if="listData.length">
  49. <div class="dataNum">共查询到{{ total }}个相关结果</div>
  50. </div>
  51. <div
  52. class="content_box"
  53. v-infinite-scroll="setScroll"
  54. infinite-scroll-distance="30"
  55. v-if="listData.length"
  56. >
  57. <!-- <el-scrollbar height="200px" ref="scrollRef" id="scrollRef"> -->
  58. <div class="oneBox" v-for="item in listData" :key="item.id">
  59. <span class="fileName" @click="toPreview(item)">{{
  60. item.content.docInfo.fileName
  61. }}</span>
  62. <div class="flieTime">
  63. <img src="@/assets/images/bx:bx-time-five.png" alt="" />
  64. <span>{{ item.content.docInfo.createTime }}</span>
  65. </div>
  66. <div
  67. class="flieContent"
  68. v-for="par in item.highlightFields.content"
  69. :key="par"
  70. v-html="par"
  71. ></div>
  72. </div>
  73. <div class="showAll" v-if="beEnd">已经到达底部~</div>
  74. <!-- </el-scrollbar> -->
  75. </div>
  76. <div class="error" v-if="noData">
  77. <img src="@/assets/images/blankPage.png" alt="" />
  78. <span>没有关于“{{ noFound }}”的结果 </span>
  79. </div>
  80. </div>
  81. </div>
  82. <ImgPreview
  83. :previewData="previewData"
  84. :copyFileType="copyFileType"
  85. :showPreview="showPreview"
  86. @closeImgPreview="closeImgPreview"
  87. ></ImgPreview>
  88. <div v-loading.fullscreen="loadingPreview" v-if="loadingPreview" class="lodingBox"></div>
  89. </template>
  90. <script setup>
  91. import { onMounted, ref, inject } from "vue";
  92. import { search } from "@/api/search/search.js";
  93. import FileEdit from "@/views/myfile/components/FileEdit.vue";
  94. import iFrame from "@/components/iFrame/index.vue";
  95. import ImgPreview from "@/components/ImgPreview/ImgPreview.vue";
  96. import { preview } from "@/api/common/common.js";
  97. // import IdentifyFont from "@/components/IdentifyFont/IdentifyFont.vue";
  98. const searchText = ref(""); //搜索ipt的值
  99. const selectValue = ref(3); //文档空间类型
  100. const page = ref(1); //页数
  101. const size = ref(10); //每页大小
  102. const total = ref(0); //数据总条数
  103. const noData = ref(false); //没有搜索出数据
  104. const beEnd = ref(false); //拉到最底部了
  105. const listData = ref([]);
  106. const noFound = ref(); //没有结果的text
  107. const clickRowId = ref();
  108. const copyRow = ref();
  109. const historyPrew = ref();
  110. const historycopyRow = ref(false);
  111. const onlyView = ref(false);
  112. const showPreview = ref(false);
  113. const loadingPreview = ref(false)
  114. const previewData = ref(); //需要预览的文件的数据
  115. const copyFileType = ref()
  116. const addFileTab = inject("addFileTab");
  117. const imgTypeArr = [".png", ".jpg", ".jpeg", ".JPG", ".PNG"];
  118. const selectOptions = [
  119. { label: "公共文档", value: 1 },
  120. { label: "部门文档", value: 2 },
  121. { label: "个人文档", value: 3 },
  122. ];
  123. // ----------------------------
  124. const openFile = ref(true);
  125. // ----------------------------
  126. onMounted(async () => {});
  127. const doSearch = async () => {
  128. if (!searchText.value) {
  129. listData.value = []
  130. noData.value = false
  131. return;
  132. }
  133. // console.log("searchText", searchText.value);
  134. // console.log("selectValue", selectValue.value);
  135. const query = {
  136. keyword: searchText.value,
  137. page: page.value,
  138. size: size.value,
  139. type: selectValue.value,
  140. };
  141. const res = await search(query);
  142. // console.log('res',res);
  143. if (res.data) {
  144. if (res.data.length < 1) {
  145. // 没找到数据
  146. listData.value = [];
  147. noData.value = true;
  148. noFound.value = searchText.value;
  149. return;
  150. }
  151. listData.value = res.data;
  152. total.value = res.total;
  153. noData.value = false;
  154. if (res.data.length < size.value) {
  155. beEnd.value = true;
  156. }
  157. } else {
  158. // console.log(1);
  159. listData.value = [];
  160. noData.value = true;
  161. noFound.value = searchText.value;
  162. }
  163. };
  164. const setScroll = async () => {
  165. console.log("到底啦");
  166. if (beEnd.value) return;
  167. page.value += 1;
  168. const query = {
  169. keyword: searchText.value,
  170. page: page.value,
  171. size: size.value,
  172. type: selectValue.value,
  173. };
  174. const res = await search(query);
  175. console.log(res);
  176. if (res.data.length > 0) {
  177. // 如果返回的有数据
  178. // total.value += res.total;
  179. noData.value = false;
  180. res.data.forEach((item) => listData.value.push(item));
  181. if (res.data.length < size.value) {
  182. //如果返回的数组长度小于size说明查完了
  183. beEnd.value = true;
  184. }
  185. } else {
  186. beEnd.value = true;
  187. }
  188. };
  189. const addTab = inject("addTab");
  190. // 预览事件
  191. const toPreview = async (item) => {
  192. console.log("item", item);
  193. loadingPreview.value = true
  194. if (imgTypeArr.some((par) => par == item.content.docInfo.fileType)) {
  195. const res = await preview(item.content.docInfo.docId);
  196. showPreview.value = true;
  197. previewData.value = URL.createObjectURL(res);
  198. copyFileType.value = item.content.docInfo.fileType
  199. loadingPreview.value = false
  200. }else{
  201. loadingPreview.value = false
  202. addFileTab(item.content.docInfo);
  203. }
  204. };
  205. //关闭图片预览事件
  206. const closeImgPreview = () => {
  207. // console.log('close');
  208. showPreview.value = false
  209. }
  210. </script>
  211. <style lang="scss" scoped>
  212. .preview {
  213. width: 100%;
  214. height: 100%;
  215. background-color: #fff;
  216. overflow: hidden;
  217. }
  218. .container {
  219. // height: 100%;
  220. height: calc(98vh - 48px - 8px - 32px - 8px);
  221. background-color: #fff;
  222. overflow: hidden;
  223. }
  224. .logo {
  225. margin: 8px auto;
  226. width: 500px;
  227. height: 80px;
  228. font-weight: 900;
  229. // border: 1px solid #000;
  230. display: flex;
  231. align-items: center;
  232. img {
  233. width: 100px;
  234. height: 40px;
  235. margin-right: 10px;
  236. }
  237. .font {
  238. font-size: 32px;
  239. font-weight: normal;
  240. color: #06286c;
  241. line-height: 30px;
  242. font-family: Inter-ExtraBold;
  243. -webkit-transform: skew(-10deg);
  244. }
  245. }
  246. .search_box {
  247. box-sizing: border-box;
  248. margin: 8px auto;
  249. width: 560px;
  250. height: 40px;
  251. border-radius: 4px 4px 4px 4px;
  252. border: 2px solid #2e6bc8;
  253. display: flex;
  254. align-items: center;
  255. .line {
  256. color: #2e6bc8;
  257. }
  258. .search_btn {
  259. width: 88px;
  260. height: 100%;
  261. background: #2e6bc8;
  262. display: flex;
  263. justify-content: center;
  264. align-items: center;
  265. font-size: 16px;
  266. font-weight: 400;
  267. color: #ffffff;
  268. line-height: 22px;
  269. }
  270. }
  271. .result_box {
  272. margin-top: 8px;
  273. padding-left: 16px;
  274. height: calc(100% - 180px);
  275. .left_box {
  276. display: flex;
  277. align-items: center;
  278. .dataNum {
  279. margin-left: 4px;
  280. font-size: 14px;
  281. font-weight: 400;
  282. }
  283. }
  284. .content_box {
  285. width: 100%;
  286. height: 100%;
  287. overflow: auto;
  288. // box-sizing: border-box;
  289. .oneBox {
  290. width: 100%;
  291. // height: 120px;
  292. border-bottom: 1px dashed #c1cce3;
  293. padding-bottom: 16px;
  294. padding-top: 16px;
  295. .fileName {
  296. font-size: 16px;
  297. color: #2e6bc8;
  298. text-decoration: underline;
  299. font-family: Inter-SemiBold;
  300. }
  301. .flieTime {
  302. font-size: 12px;
  303. font-weight: 400;
  304. color: #06286c;
  305. // line-height: 20px;
  306. vertical-align: middle;
  307. display: flex;
  308. align-items: center;
  309. margin: 4px 0;
  310. span {
  311. margin-left: 4px;
  312. }
  313. }
  314. .flieContent {
  315. width: 100%;
  316. font-size: 14px;
  317. color: #000000;
  318. font-weight: 400;
  319. line-height: 22px;
  320. display: -webkit-box;
  321. -webkit-box-orient: vertical;
  322. text-overflow: ellipsis;
  323. -webkit-line-clamp: 3; //超过3行显示省略号
  324. overflow: hidden;
  325. }
  326. }
  327. .showAll {
  328. margin-top: 8px;
  329. font-size: 14px;
  330. font-weight: 400;
  331. color: #6f85b5;
  332. line-height: 22px;
  333. display: flex;
  334. justify-content: center;
  335. }
  336. }
  337. .error {
  338. margin-top: 120px;
  339. display: flex;
  340. flex-direction: column;
  341. align-items: center;
  342. font-size: 12px;
  343. font-weight: 400;
  344. color: #06286c;
  345. img {
  346. width: 320px;
  347. height: 320px;
  348. }
  349. }
  350. }
  351. ::v-deep em {
  352. color: #dd2025;
  353. }
  354. //选择框样式
  355. ::v-deep .el-select .el-input {
  356. width: 112px;
  357. height: 38px;
  358. color: #06286c !important;
  359. font-size: 14px !important;
  360. }
  361. ::v-deep .el-select .el-input__wrapper {
  362. background-color: rgba(0, 0, 0, 0) !important;
  363. box-shadow: none !important;
  364. }
  365. ::v-deep .el-select .el-input.is-focus .el-input__wrapper {
  366. box-shadow: none !important;
  367. }
  368. ::v-deep .el-select .el-input__wrapper .el-input__inner {
  369. color: #06286c !important;
  370. }
  371. // 搜索框样式
  372. ::v-deep .search_ipt .el-input__wrapper {
  373. box-shadow: none !important;
  374. }
  375. ::v-deep .search_ipt .el-input__inner {
  376. color: #06286c !important;
  377. }
  378. ::v-deep .search_ipt .el-input__inner::placeholder {
  379. color: #a4b0d8;
  380. }
  381. </style>
  382. <style lang="scss">
  383. //鼠标移动上去的选中色
  384. .typeSelect {
  385. .el-select-dropdown__item.hover,
  386. .el-select-dropdown__item:hover {
  387. background: #f5f7f9 !important;
  388. }
  389. //下拉框的文本颜色
  390. .el-select-dropdown__item {
  391. color: #06286c !important;
  392. }
  393. //选中之后的颜色
  394. .el-select-dropdown__item.selected {
  395. background: #f5f7f9 !important;
  396. color: #000 !important;
  397. }
  398. }
  399. </style>