HighSearch.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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. <div v-else class="preview">
  83. <FileEdit
  84. :docId="clickRowId"
  85. :copyRow="copyRow"
  86. :historyPrew="historyPrew"
  87. :historycopyRow="historycopyRow"
  88. :onlyView="onlyView"
  89. ></FileEdit>
  90. </div>
  91. </template>
  92. <script setup>
  93. import { onMounted, ref, inject } 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. const addTab = inject("addTab");
  182. // 预览事件
  183. const toPreview = (item) => {
  184. addTab(item.content.docInfo);
  185. console.log("item", item);
  186. clickRowId.value = item.content.docInfo.docId;
  187. copyRow.value = item.content.docInfo;
  188. showPreview.value = true;
  189. };
  190. </script>
  191. <style lang="scss" scoped>
  192. .preview {
  193. width: 100%;
  194. height: 100%;
  195. background-color: #fff;
  196. overflow: hidden;
  197. }
  198. .container {
  199. height: 100%;
  200. background-color: #fff;
  201. overflow: hidden;
  202. }
  203. .logo {
  204. margin: 8px auto;
  205. width: 500px;
  206. height: 80px;
  207. font-weight: 900;
  208. // border: 1px solid #000;
  209. display: flex;
  210. align-items: center;
  211. img {
  212. width: 80px;
  213. height: 80px;
  214. }
  215. .font {
  216. font-size: 32px;
  217. font-weight: normal;
  218. color: #06286c;
  219. line-height: 30px;
  220. font-family: Inter-ExtraBold;
  221. -webkit-transform: skew(-10deg);
  222. }
  223. }
  224. .search_box {
  225. box-sizing: border-box;
  226. margin: 8px auto;
  227. width: 560px;
  228. height: 40px;
  229. border-radius: 4px 4px 4px 4px;
  230. border: 2px solid #2e6bc8;
  231. display: flex;
  232. align-items: center;
  233. .line {
  234. color: #2e6bc8;
  235. }
  236. .search_btn {
  237. width: 88px;
  238. height: 100%;
  239. background: #2e6bc8;
  240. display: flex;
  241. justify-content: center;
  242. align-items: center;
  243. font-size: 16px;
  244. font-weight: 400;
  245. color: #ffffff;
  246. line-height: 22px;
  247. }
  248. }
  249. .result_box {
  250. margin-top: 8px;
  251. padding-left: 16px;
  252. height: calc(100% - 180px);
  253. .left_box {
  254. display: flex;
  255. align-items: center;
  256. .dataNum {
  257. margin-left: 4px;
  258. font-size: 14px;
  259. font-weight: 400;
  260. }
  261. }
  262. .content_box {
  263. width: 100%;
  264. height: 100%;
  265. overflow: auto;
  266. // box-sizing: border-box;
  267. .oneBox {
  268. width: 100%;
  269. // height: 120px;
  270. border-bottom: 1px dashed #c1cce3;
  271. padding-bottom: 16px;
  272. padding-top: 16px;
  273. .fileName {
  274. font-size: 16px;
  275. color: #2e6bc8;
  276. text-decoration: underline;
  277. font-family: Inter-SemiBold;
  278. }
  279. .flieTime {
  280. font-size: 12px;
  281. font-weight: 400;
  282. color: #06286c;
  283. // line-height: 20px;
  284. vertical-align: middle;
  285. display: flex;
  286. align-items: center;
  287. margin: 4px 0;
  288. span {
  289. margin-left: 4px;
  290. }
  291. }
  292. .flieContent {
  293. width: 100%;
  294. font-size: 14px;
  295. color: #000000;
  296. font-weight: 400;
  297. line-height: 22px;
  298. display: -webkit-box;
  299. -webkit-box-orient: vertical;
  300. text-overflow: ellipsis;
  301. -webkit-line-clamp: 3; //超过3行显示省略号
  302. overflow: hidden;
  303. }
  304. }
  305. .showAll {
  306. margin-top: 8px;
  307. font-size: 14px;
  308. font-weight: 400;
  309. color: #6f85b5;
  310. line-height: 22px;
  311. display: flex;
  312. justify-content: center;
  313. }
  314. }
  315. .error {
  316. margin-top: 120px;
  317. display: flex;
  318. flex-direction: column;
  319. align-items: center;
  320. font-size: 12px;
  321. font-weight: 400;
  322. color: #06286c;
  323. img {
  324. width: 320px;
  325. height: 320px;
  326. }
  327. }
  328. }
  329. ::v-deep em {
  330. color: #dd2025;
  331. }
  332. //选择框样式
  333. ::v-deep .el-select .el-input {
  334. width: 112px;
  335. height: 38px;
  336. color: #06286c !important;
  337. font-size: 14px !important;
  338. }
  339. ::v-deep .el-select .el-input__wrapper {
  340. background-color: rgba(0, 0, 0, 0) !important;
  341. box-shadow: none !important;
  342. }
  343. ::v-deep .el-select .el-input.is-focus .el-input__wrapper {
  344. box-shadow: none !important;
  345. }
  346. ::v-deep .el-select .el-input__wrapper .el-input__inner {
  347. color: #06286c !important;
  348. }
  349. // 搜索框样式
  350. ::v-deep .search_ipt .el-input__wrapper {
  351. box-shadow: none !important;
  352. }
  353. ::v-deep .search_ipt .el-input__inner {
  354. color: #06286c !important;
  355. }
  356. ::v-deep .search_ipt .el-input__inner::placeholder {
  357. color: #a4b0d8;
  358. }
  359. </style>
  360. <style lang="scss">
  361. //鼠标移动上去的选中色
  362. .typeSelect {
  363. .el-select-dropdown__item.hover,
  364. .el-select-dropdown__item:hover {
  365. background: #f5f7f9 !important;
  366. }
  367. //下拉框的文本颜色
  368. .el-select-dropdown__item {
  369. color: #06286c !important;
  370. }
  371. //选中之后的颜色
  372. .el-select-dropdown__item.selected {
  373. background: #f5f7f9 !important;
  374. color: #000 !important;
  375. }
  376. }
  377. </style>