HighSearch.vue 9.2 KB

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