HighSearch.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <div class="container">
  3. <div class="logo">
  4. <img src="@/assets/images/Frame_427319127.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. placeholder="请输入要查询的内容"
  43. />
  44. <div class="search_btn" @click="doSearch">搜索</div>
  45. </div>
  46. <div class="result_box">
  47. <div class="left_box" v-if="listData.length">
  48. <div class="dataNum">共查询到{{ total }}个相关结果</div>
  49. </div>
  50. <div
  51. class="content_box"
  52. v-infinite-scroll="setScroll"
  53. infinite-scroll-distance="30"
  54. v-if="listData.length"
  55. >
  56. <!-- <el-scrollbar height="200px" ref="scrollRef" id="scrollRef"> -->
  57. <div class="oneBox" v-for="item in listData" :key="item.id">
  58. <span class="fileName">{{ item.content.docInfo.fileName }}</span>
  59. <div class="flieTime">
  60. <img src="@/assets/images/bx:bx-time-five.png" alt="" />
  61. <span>{{ item.content.docInfo.createTime }}</span>
  62. </div>
  63. <div
  64. class="flieContent"
  65. v-for="par in item.highlightFields.content"
  66. :key="par"
  67. v-html="par"
  68. ></div>
  69. </div>
  70. <div class="showAll" v-if="beEnd">已经到达底部~</div>
  71. <!-- </el-scrollbar> -->
  72. </div>
  73. <div class="error" v-if="noData">
  74. <img src="@/assets/images/blankPage.png" alt="" />
  75. <span>没有关于“{{ noFound }}”的结果 </span>
  76. </div>
  77. </div>
  78. <!-- <IdentifyFont :openFile="openFile"></IdentifyFont> -->
  79. </div>
  80. </template>
  81. <script setup>
  82. import { onMounted, ref } from "vue";
  83. import { search } from "@/api/search/search.js";
  84. // import IdentifyFont from "@/components/IdentifyFont/IdentifyFont.vue";
  85. const searchText = ref(""); //搜索ipt的值
  86. const selectValue = ref(1); //文档空间类型
  87. const page = ref(1); //页数
  88. const size = ref(10); //每页大小
  89. const total = ref(0); //数据总条数
  90. const noData = ref(false); //没有搜索出数据
  91. const beEnd = ref(false); //拉到最底部了
  92. const listData = ref([]);
  93. const noFound = ref(); //没有结果的text
  94. const selectOptions = [
  95. { label: "公共文档", value: 1 },
  96. { label: "部门文档", value: 2 },
  97. { label: "个人文档", value: 3 },
  98. ];
  99. // ----------------------------
  100. const openFile = ref(true);
  101. // ----------------------------
  102. onMounted(async () => {});
  103. const doSearch = async () => {
  104. if (!searchText.value) {
  105. return;
  106. }
  107. // console.log("searchText", searchText.value);
  108. // console.log("selectValue", selectValue.value);
  109. const query = {
  110. keyword: searchText.value,
  111. page: page.value,
  112. size: size.value,
  113. type: selectValue.value,
  114. };
  115. const res = await search(query);
  116. // console.log('res',res);
  117. if (res.data) {
  118. if (res.data.length < 1) {
  119. // 没找到数据
  120. listData.value = [];
  121. noData.value = true;
  122. noFound.value = searchText.value;
  123. return;
  124. }
  125. listData.value = res.data;
  126. total.value = res.data.length;
  127. noData.value = false;
  128. if (res.data.length < size.value) {
  129. beEnd.value = true;
  130. }
  131. } else {
  132. // console.log(1);
  133. listData.value = [];
  134. noData.value = true;
  135. noFound.value = searchText.value;
  136. }
  137. };
  138. const setScroll = async () => {
  139. console.log("到底啦");
  140. if (beEnd.value) return;
  141. page.value += 1;
  142. const query = {
  143. keyword: searchText.value,
  144. page: page.value,
  145. size: size.value,
  146. type: selectValue.value,
  147. };
  148. const res = await search(query);
  149. console.log(res);
  150. if (res.data.length > 0) {
  151. // 如果返回的有数据
  152. total.value += res.data.length;
  153. noData.value = false;
  154. res.data.forEach((item) => listData.value.push(item));
  155. if (res.data.length < size.value) {
  156. //如果返回的数组长度小于size说明查完了
  157. beEnd.value = true;
  158. }
  159. } else {
  160. beEnd.value = true;
  161. }
  162. };
  163. </script>
  164. <style lang="scss" scoped>
  165. .container {
  166. height: 100%;
  167. background-color: #fff;
  168. overflow: hidden;
  169. }
  170. .logo {
  171. margin: 8px auto;
  172. width: 500px;
  173. height: 80px;
  174. font-weight: 900;
  175. // border: 1px solid #000;
  176. display: flex;
  177. align-items: center;
  178. img {
  179. width: 80px;
  180. height: 80px;
  181. }
  182. .font {
  183. font-size: 32px;
  184. font-weight: normal;
  185. color: #06286c;
  186. line-height: 30px;
  187. font-family: Inter-ExtraBold;
  188. -webkit-transform: skew(-10deg);
  189. }
  190. }
  191. .search_box {
  192. box-sizing: border-box;
  193. margin: 8px auto;
  194. width: 560px;
  195. height: 40px;
  196. border-radius: 4px 4px 4px 4px;
  197. border: 2px solid #2e6bc8;
  198. display: flex;
  199. align-items: center;
  200. .line {
  201. color: #2e6bc8;
  202. }
  203. .search_btn {
  204. width: 88px;
  205. height: 100%;
  206. background: #2e6bc8;
  207. display: flex;
  208. justify-content: center;
  209. align-items: center;
  210. font-size: 16px;
  211. font-weight: 400;
  212. color: #ffffff;
  213. line-height: 22px;
  214. }
  215. }
  216. .result_box {
  217. margin-top: 8px;
  218. padding-left: 16px;
  219. height: calc(100% - 180px);
  220. .left_box {
  221. display: flex;
  222. align-items: center;
  223. .dataNum {
  224. margin-left: 4px;
  225. font-size: 14px;
  226. font-weight: 400;
  227. }
  228. }
  229. .content_box {
  230. width: 100%;
  231. height: 100%;
  232. overflow: auto;
  233. // box-sizing: border-box;
  234. .oneBox {
  235. width: 100%;
  236. // height: 120px;
  237. border-bottom: 1px dashed #c1cce3;
  238. padding-bottom: 16px;
  239. padding-top: 16px;
  240. .fileName {
  241. font-size: 16px;
  242. color: #2e6bc8;
  243. text-decoration: underline;
  244. font-family: Inter-SemiBold;
  245. }
  246. .flieTime {
  247. font-size: 12px;
  248. font-weight: 400;
  249. color: #06286c;
  250. // line-height: 20px;
  251. vertical-align: middle;
  252. display: flex;
  253. align-items: center;
  254. margin: 4px 0;
  255. span {
  256. margin-left: 4px;
  257. }
  258. }
  259. .flieContent {
  260. width: 100%;
  261. font-size: 14px;
  262. color: #000000;
  263. font-weight: 400;
  264. line-height: 22px;
  265. display: -webkit-box;
  266. -webkit-box-orient: vertical;
  267. text-overflow: ellipsis;
  268. -webkit-line-clamp: 3; //超过3行显示省略号
  269. overflow: hidden;
  270. }
  271. }
  272. .showAll {
  273. margin-top: 8px;
  274. font-size: 14px;
  275. font-weight: 400;
  276. color: #6f85b5;
  277. line-height: 22px;
  278. display: flex;
  279. justify-content: center;
  280. }
  281. }
  282. .error {
  283. margin-top: 120px;
  284. display: flex;
  285. flex-direction: column;
  286. align-items: center;
  287. font-size: 12px;
  288. font-weight: 400;
  289. color: #06286c;
  290. img {
  291. width: 320px;
  292. height: 320px;
  293. }
  294. }
  295. }
  296. ::v-deep em {
  297. color: #dd2025;
  298. }
  299. //选择框样式
  300. ::v-deep .el-select .el-input {
  301. width: 112px;
  302. height: 38px;
  303. color: #06286c !important;
  304. font-size: 14px !important;
  305. }
  306. ::v-deep .el-select .el-input__wrapper {
  307. background-color: rgba(0, 0, 0, 0) !important;
  308. box-shadow: none !important;
  309. }
  310. ::v-deep .el-select .el-input.is-focus .el-input__wrapper {
  311. box-shadow: none !important;
  312. }
  313. ::v-deep .el-select .el-input__wrapper .el-input__inner {
  314. color: #06286c !important;
  315. }
  316. // 搜索框样式
  317. ::v-deep .search_ipt .el-input__wrapper {
  318. box-shadow: none !important;
  319. }
  320. ::v-deep .search_ipt .el-input__inner {
  321. color: #06286c !important;
  322. }
  323. ::v-deep .search_ipt .el-input__inner::placeholder {
  324. color: #a4b0d8;
  325. }
  326. </style>
  327. <style lang="scss">
  328. //鼠标移动上去的选中色
  329. .typeSelect {
  330. .el-select-dropdown__item.hover,
  331. .el-select-dropdown__item:hover {
  332. background: #f5f7f9 !important;
  333. }
  334. //下拉框的文本颜色
  335. .el-select-dropdown__item {
  336. color: #06286c !important;
  337. }
  338. //选中之后的颜色
  339. .el-select-dropdown__item.selected {
  340. background: #f5f7f9 !important;
  341. color: #000 !important;
  342. }
  343. }
  344. </style>