HighSearch.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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. return;
  130. }
  131. // console.log("searchText", searchText.value);
  132. // console.log("selectValue", selectValue.value);
  133. const query = {
  134. keyword: searchText.value,
  135. page: page.value,
  136. size: size.value,
  137. type: selectValue.value,
  138. };
  139. const res = await search(query);
  140. // console.log('res',res);
  141. if (res.data) {
  142. if (res.data.length < 1) {
  143. // 没找到数据
  144. listData.value = [];
  145. noData.value = true;
  146. noFound.value = searchText.value;
  147. return;
  148. }
  149. listData.value = res.data;
  150. total.value = res.total;
  151. noData.value = false;
  152. if (res.data.length < size.value) {
  153. beEnd.value = true;
  154. }
  155. } else {
  156. // console.log(1);
  157. listData.value = [];
  158. noData.value = true;
  159. noFound.value = searchText.value;
  160. }
  161. };
  162. const setScroll = async () => {
  163. console.log("到底啦");
  164. if (beEnd.value) return;
  165. page.value += 1;
  166. const query = {
  167. keyword: searchText.value,
  168. page: page.value,
  169. size: size.value,
  170. type: selectValue.value,
  171. };
  172. const res = await search(query);
  173. console.log(res);
  174. if (res.data.length > 0) {
  175. // 如果返回的有数据
  176. // total.value += res.total;
  177. noData.value = false;
  178. res.data.forEach((item) => listData.value.push(item));
  179. if (res.data.length < size.value) {
  180. //如果返回的数组长度小于size说明查完了
  181. beEnd.value = true;
  182. }
  183. } else {
  184. beEnd.value = true;
  185. }
  186. };
  187. const addTab = inject("addTab");
  188. // 预览事件
  189. const toPreview = async (item) => {
  190. console.log("item", item);
  191. loadingPreview.value = true
  192. if (imgTypeArr.some((par) => par == item.content.docInfo.fileType)) {
  193. const res = await preview(item.content.docInfo.docId);
  194. showPreview.value = true;
  195. previewData.value = URL.createObjectURL(res);
  196. copyFileType.value = item.content.docInfo.fileType
  197. loadingPreview.value = false
  198. }else{
  199. loadingPreview.value = false
  200. addFileTab(item.content.docInfo);
  201. }
  202. };
  203. //关闭图片预览事件
  204. const closeImgPreview = () => {
  205. // console.log('close');
  206. showPreview.value = false
  207. }
  208. </script>
  209. <style lang="scss" scoped>
  210. .preview {
  211. width: 100%;
  212. height: 100%;
  213. background-color: #fff;
  214. overflow: hidden;
  215. }
  216. .container {
  217. // height: 100%;
  218. height: calc(98vh - 48px - 8px - 32px - 8px);
  219. background-color: #fff;
  220. overflow: hidden;
  221. }
  222. .logo {
  223. margin: 8px auto;
  224. width: 500px;
  225. height: 80px;
  226. font-weight: 900;
  227. // border: 1px solid #000;
  228. display: flex;
  229. align-items: center;
  230. img {
  231. width: 100px;
  232. height: 40px;
  233. margin-right: 10px;
  234. }
  235. .font {
  236. font-size: 32px;
  237. font-weight: normal;
  238. color: #06286c;
  239. line-height: 30px;
  240. font-family: Inter-ExtraBold;
  241. -webkit-transform: skew(-10deg);
  242. }
  243. }
  244. .search_box {
  245. box-sizing: border-box;
  246. margin: 8px auto;
  247. width: 560px;
  248. height: 40px;
  249. border-radius: 4px 4px 4px 4px;
  250. border: 2px solid #2e6bc8;
  251. display: flex;
  252. align-items: center;
  253. .line {
  254. color: #2e6bc8;
  255. }
  256. .search_btn {
  257. width: 88px;
  258. height: 100%;
  259. background: #2e6bc8;
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. font-size: 16px;
  264. font-weight: 400;
  265. color: #ffffff;
  266. line-height: 22px;
  267. }
  268. }
  269. .result_box {
  270. margin-top: 8px;
  271. padding-left: 16px;
  272. height: calc(100% - 180px);
  273. .left_box {
  274. display: flex;
  275. align-items: center;
  276. .dataNum {
  277. margin-left: 4px;
  278. font-size: 14px;
  279. font-weight: 400;
  280. }
  281. }
  282. .content_box {
  283. width: 100%;
  284. height: 100%;
  285. overflow: auto;
  286. // box-sizing: border-box;
  287. .oneBox {
  288. width: 100%;
  289. // height: 120px;
  290. border-bottom: 1px dashed #c1cce3;
  291. padding-bottom: 16px;
  292. padding-top: 16px;
  293. .fileName {
  294. font-size: 16px;
  295. color: #2e6bc8;
  296. text-decoration: underline;
  297. font-family: Inter-SemiBold;
  298. }
  299. .flieTime {
  300. font-size: 12px;
  301. font-weight: 400;
  302. color: #06286c;
  303. // line-height: 20px;
  304. vertical-align: middle;
  305. display: flex;
  306. align-items: center;
  307. margin: 4px 0;
  308. span {
  309. margin-left: 4px;
  310. }
  311. }
  312. .flieContent {
  313. width: 100%;
  314. font-size: 14px;
  315. color: #000000;
  316. font-weight: 400;
  317. line-height: 22px;
  318. display: -webkit-box;
  319. -webkit-box-orient: vertical;
  320. text-overflow: ellipsis;
  321. -webkit-line-clamp: 3; //超过3行显示省略号
  322. overflow: hidden;
  323. }
  324. }
  325. .showAll {
  326. margin-top: 8px;
  327. font-size: 14px;
  328. font-weight: 400;
  329. color: #6f85b5;
  330. line-height: 22px;
  331. display: flex;
  332. justify-content: center;
  333. }
  334. }
  335. .error {
  336. margin-top: 120px;
  337. display: flex;
  338. flex-direction: column;
  339. align-items: center;
  340. font-size: 12px;
  341. font-weight: 400;
  342. color: #06286c;
  343. img {
  344. width: 320px;
  345. height: 320px;
  346. }
  347. }
  348. }
  349. ::v-deep em {
  350. color: #dd2025;
  351. }
  352. //选择框样式
  353. ::v-deep .el-select .el-input {
  354. width: 112px;
  355. height: 38px;
  356. color: #06286c !important;
  357. font-size: 14px !important;
  358. }
  359. ::v-deep .el-select .el-input__wrapper {
  360. background-color: rgba(0, 0, 0, 0) !important;
  361. box-shadow: none !important;
  362. }
  363. ::v-deep .el-select .el-input.is-focus .el-input__wrapper {
  364. box-shadow: none !important;
  365. }
  366. ::v-deep .el-select .el-input__wrapper .el-input__inner {
  367. color: #06286c !important;
  368. }
  369. // 搜索框样式
  370. ::v-deep .search_ipt .el-input__wrapper {
  371. box-shadow: none !important;
  372. }
  373. ::v-deep .search_ipt .el-input__inner {
  374. color: #06286c !important;
  375. }
  376. ::v-deep .search_ipt .el-input__inner::placeholder {
  377. color: #a4b0d8;
  378. }
  379. </style>
  380. <style lang="scss">
  381. //鼠标移动上去的选中色
  382. .typeSelect {
  383. .el-select-dropdown__item.hover,
  384. .el-select-dropdown__item:hover {
  385. background: #f5f7f9 !important;
  386. }
  387. //下拉框的文本颜色
  388. .el-select-dropdown__item {
  389. color: #06286c !important;
  390. }
  391. //选中之后的颜色
  392. .el-select-dropdown__item.selected {
  393. background: #f5f7f9 !important;
  394. color: #000 !important;
  395. }
  396. }
  397. </style>