HighSearch.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <div class="container">
  3. <div class="logo">
  4. <img src="@/assets/images/Frame_427319127.png" alt="" />
  5. <div class="font">Domino’s File</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 :showIdentify="showIdentify"></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 showIdentify = 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: 290px;
  173. height: 80px;
  174. // border: 1px solid #000;
  175. display: flex;
  176. align-items: center;
  177. img {
  178. width: 80px;
  179. height: 80px;
  180. }
  181. .font {
  182. font-size: 32px;
  183. font-weight: normal;
  184. color: #06286c;
  185. line-height: 30px;
  186. font-family: Inter-ExtraBold;
  187. -webkit-transform: skew(-10deg);
  188. }
  189. }
  190. .search_box {
  191. box-sizing: border-box;
  192. margin: 8px auto;
  193. width: 560px;
  194. height: 40px;
  195. border-radius: 4px 4px 4px 4px;
  196. border: 2px solid #2e6bc8;
  197. display: flex;
  198. align-items: center;
  199. .line {
  200. color: #2e6bc8;
  201. }
  202. .search_btn {
  203. width: 88px;
  204. height: 100%;
  205. background: #2e6bc8;
  206. display: flex;
  207. justify-content: center;
  208. align-items: center;
  209. font-size: 16px;
  210. font-weight: 400;
  211. color: #ffffff;
  212. line-height: 22px;
  213. }
  214. }
  215. .result_box {
  216. margin-top: 8px;
  217. padding-left: 16px;
  218. .left_box {
  219. display: flex;
  220. align-items: center;
  221. .dataNum {
  222. margin-left: 4px;
  223. font-size: 14px;
  224. font-weight: 400;
  225. }
  226. }
  227. .content_box {
  228. width: 100%;
  229. height: 100%;
  230. overflow: auto;
  231. .oneBox {
  232. width: 100%;
  233. // height: 120px;
  234. border-bottom: 1px dashed #c1cce3;
  235. padding-bottom: 16px;
  236. padding-top: 16px;
  237. .fileName {
  238. font-size: 16px;
  239. color: #2e6bc8;
  240. text-decoration: underline;
  241. font-family: Inter-SemiBold;
  242. }
  243. .flieTime {
  244. font-size: 12px;
  245. font-weight: 400;
  246. color: #06286c;
  247. // line-height: 20px;
  248. vertical-align: middle;
  249. display: flex;
  250. align-items: center;
  251. margin: 4px 0;
  252. span {
  253. margin-left: 4px;
  254. }
  255. }
  256. .flieContent {
  257. width: 100%;
  258. font-size: 14px;
  259. color: #000000;
  260. font-weight: 400;
  261. line-height: 22px;
  262. display: -webkit-box;
  263. -webkit-box-orient: vertical;
  264. text-overflow: ellipsis;
  265. -webkit-line-clamp: 3; //超过3行显示省略号
  266. overflow: hidden;
  267. }
  268. }
  269. .showAll {
  270. margin-top: 8px;
  271. font-size: 14px;
  272. font-weight: 400;
  273. color: #6f85b5;
  274. line-height: 22px;
  275. display: flex;
  276. justify-content: center;
  277. }
  278. }
  279. .error {
  280. margin-top: 120px;
  281. display: flex;
  282. flex-direction: column;
  283. align-items: center;
  284. font-size: 12px;
  285. font-weight: 400;
  286. color: #06286c;
  287. img {
  288. width: 320px;
  289. height: 320px;
  290. }
  291. }
  292. }
  293. ::v-deep em {
  294. color: #dd2025;
  295. }
  296. //选择框样式
  297. ::v-deep .el-select .el-input {
  298. width: 112px;
  299. height: 38px;
  300. color: #06286c !important;
  301. font-size: 14px !important;
  302. }
  303. ::v-deep .el-select .el-input__wrapper {
  304. background-color: rgba(0, 0, 0, 0) !important;
  305. box-shadow: none !important;
  306. }
  307. ::v-deep .el-select .el-input.is-focus .el-input__wrapper {
  308. box-shadow: none !important;
  309. }
  310. ::v-deep .el-select .el-input__wrapper .el-input__inner {
  311. color: #06286c !important;
  312. }
  313. // 搜索框样式
  314. ::v-deep .search_ipt .el-input__wrapper {
  315. box-shadow: none !important;
  316. }
  317. ::v-deep .search_ipt .el-input__inner {
  318. color: #06286c !important;
  319. }
  320. ::v-deep .search_ipt .el-input__inner::placeholder {
  321. color: #a4b0d8;
  322. }
  323. </style>
  324. <style lang="scss">
  325. //鼠标移动上去的选中色
  326. .typeSelect {
  327. .el-select-dropdown__item.hover,
  328. .el-select-dropdown__item:hover {
  329. background: #f5f7f9 !important;
  330. }
  331. //下拉框的文本颜色
  332. .el-select-dropdown__item {
  333. color: #06286c !important;
  334. }
  335. //选中之后的颜色
  336. .el-select-dropdown__item.selected {
  337. background: #f5f7f9 !important;
  338. color: #000 !important;
  339. }
  340. }
  341. </style>