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