km-fullsearch-cotent.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <div :class="$style.fullsearchContent">
  3. <a-card>
  4. <div :class="$style.searchResult">
  5. <span :class="$style.result"
  6. >为您找到相关结果<i>{{ total }}</i
  7. >条</span
  8. >
  9. <div :class="$style.option">
  10. 搜索方式:
  11. <a-select default-value="splitWrod" @change="handleSearchChange">
  12. <a-select-option value="splitWrod">
  13. 模糊搜索
  14. </a-select-option>
  15. <a-select-option value="fullword">
  16. 精准搜索
  17. </a-select-option>
  18. </a-select>
  19. 排序:
  20. <a-select default-value="score" @change="handleSearchsort">
  21. <a-select-option value="score">
  22. 按相关性
  23. </a-select-option>
  24. <a-select-option value="dateAsc">
  25. 按时间顺序
  26. </a-select-option>
  27. <a-select-option value="dateDesc">
  28. 按时间倒序
  29. </a-select-option>
  30. </a-select>
  31. <a-button @click="handleExcel">导出Excel</a-button>
  32. </div>
  33. </div>
  34. <div :class="$style.fullResult">
  35. <a-list size="large" :pagination="pagination" :data-source="searchList" :loading="loading">
  36. <a-list-item slot="renderItem" key="item.title" slot-scope="item" :class="$style.item">
  37. <span slot="extra" :class="$style.btn" @click="fnSeeAtlas(item)"
  38. >查看图谱<a-icon type="fullscreen"
  39. /></span>
  40. <a-list-item-meta>
  41. <p slot="title" :class="$style.title">
  42. <a href="javascript:;" @click="fnReadDoc(item)">
  43. <span
  44. v-for="(s, key) in item.title"
  45. :key="key"
  46. :class="{ [$style.searchColor]: s[0] === '1' }"
  47. >{{ s[1] }}</span
  48. >
  49. </a>
  50. </p>
  51. <p slot="title" :class="$style.message"
  52. >摘要:
  53. <span
  54. v-for="(s, key) in item.abstractMessage"
  55. :key="key"
  56. :class="{ [$style.searchColor]: s[0] === '1' }"
  57. >{{ s[1] }}</span
  58. >
  59. </p>
  60. <p slot="title" :class="$style.category"
  61. >所属分类:
  62. <span>{{ item.categoryName }}</span>
  63. 投稿人:<span>{{ item.creatorName }} </span> 创建时间:<span>
  64. {{ item.creationTime }}
  65. </span>
  66. </p>
  67. <div slot="title" :class="$style.label">
  68. <span v-for="(tag, index) in item.tagNames" :key="index">{{ tag }}</span>
  69. </div>
  70. </a-list-item-meta>
  71. </a-list-item>
  72. </a-list>
  73. </div>
  74. </a-card>
  75. </div>
  76. </template>
  77. <script>
  78. import { Message } from 'ant-design-vue'
  79. import download from '@/common/services/download'
  80. import KmKnowledageService from '../km-knowledage-service'
  81. import components from './_import-components/km-fullsearch-cotent-import'
  82. export default {
  83. name: 'KmFullsearchCotent',
  84. components,
  85. props: {
  86. searchList: {
  87. type: Array,
  88. default: () => [],
  89. },
  90. searchVal: {
  91. type: String,
  92. default: '',
  93. },
  94. total: {
  95. type: Number,
  96. default: 0,
  97. },
  98. params: {
  99. type: Array,
  100. default: () => [],
  101. },
  102. },
  103. data() {
  104. return {
  105. pagination: {
  106. onChange: (page) => {
  107. this.pagination.current = page
  108. const startPosition = page === 1 ? '1' : (5 * (page - 1)).toString()
  109. this.$emit('onSearch', startPosition, 'startPosition')
  110. },
  111. current: 1,
  112. pageSize: 5,
  113. total: this.total,
  114. },
  115. loading: false,
  116. atlasUrl: '', // 图谱系统配置
  117. }
  118. },
  119. watch: {
  120. total(val) {
  121. this.pagination.total = val
  122. },
  123. },
  124. created() {
  125. this.fnGetAtlasUrl()
  126. },
  127. methods: {
  128. // 排序
  129. handleSearchsort(val) {
  130. this.$emit('onSearch', val, 'searchSort')
  131. },
  132. // 搜索方式
  133. handleSearchChange(val) {
  134. this.$emit('onSearch', val, 'searchType')
  135. },
  136. // 导出Excel
  137. handleExcel() {
  138. const newParams = JSON.parse(JSON.stringify(this.params))
  139. const tar = { exportCount: this.total }
  140. if (newParams.length > 1) {
  141. Object.assign(newParams[newParams.length - 1], tar)
  142. } else {
  143. Object.assign(newParams[0], tar)
  144. }
  145. KmKnowledageService.searchExport(newParams).then((res) => {
  146. const queryParams = {}
  147. queryParams.pathInfo = '/formfile/tmp/' + parseInt(res.id) + '.xls'
  148. KmKnowledageService.exportDownload(queryParams).then((r) => {
  149. // 下载
  150. const url = URL.createObjectURL(r)
  151. const fname = res.name
  152. download(url, fname)
  153. })
  154. })
  155. },
  156. // 查看知识
  157. fnReadDoc(record) {
  158. window.open(`#/km-knowledage-view?id=${record.beanId}&title=${record.title}`, '_blank')
  159. },
  160. // 获取图谱系统配置
  161. fnGetAtlasUrl() {
  162. const params = { name: 'we-km$knowledgeGraph' }
  163. KmKnowledageService.getKmSystemConfig(params).then((res) => {
  164. this.atlasUrl = res.data
  165. })
  166. },
  167. // 查看图谱
  168. fnSeeAtlas(record) {
  169. if (this.atlasUrl) {
  170. window.open(`${this.atlasUrl}${record.beanId}`, '_blank')
  171. } else {
  172. Message.warning('未找到知识图谱配置信息,请联系管理员。')
  173. }
  174. },
  175. },
  176. }
  177. </script>
  178. <style module lang="scss">
  179. @use '@/common/design' as *;
  180. $line-height: 30px;
  181. $label-color: #989898;
  182. $label-background-color: #f1f2f6;
  183. .fullsearch-content {
  184. .search-result {
  185. padding: 20px 0;
  186. overflow: hidden;
  187. border-bottom: 1px solid $border-color-base;
  188. .result {
  189. float: left;
  190. line-height: $line-height;
  191. i {
  192. padding: 0 5px;
  193. font-style: normal;
  194. color: $primary-color;
  195. }
  196. }
  197. .option {
  198. float: right;
  199. :global(.ant-select) {
  200. margin-right: 20px;
  201. }
  202. }
  203. }
  204. .full-result {
  205. .item {
  206. :global(.ant-list-item-meta) {
  207. width: 80%;
  208. }
  209. :global(.ant-list-item-meta-content) {
  210. width: 100%;
  211. }
  212. }
  213. .search-color {
  214. font-style: normal;
  215. background: #fbcecb;
  216. }
  217. p {
  218. font-size: $font-size-base;
  219. line-height: $font-size-base;
  220. }
  221. .title {
  222. color: $primary-color;
  223. }
  224. .message {
  225. display: inline-block;
  226. width: 100%;
  227. overflow: hidden;
  228. text-overflow: ellipsis;
  229. white-space: nowrap;
  230. }
  231. .category {
  232. span {
  233. margin: 0 20px 0 0;
  234. }
  235. }
  236. .label {
  237. span {
  238. display: inline-block;
  239. padding: 5px 10px;
  240. margin: 2px 5px;
  241. font-size: $font-size-base;
  242. color: $label-color;
  243. background-color: $label-background-color;
  244. border-radius: 15px;
  245. }
  246. }
  247. .btn {
  248. color: $primary-color;
  249. cursor: pointer;
  250. i {
  251. padding-left: 10px;
  252. }
  253. }
  254. }
  255. }
  256. </style>