DocRefItem.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <div>
  3. <a-popover :title="knowledge.doc_name" position="left">
  4. <div @click="openDocuementPage(knowledge)" class="doc-ref-container">
  5. <span class="doc-ref-index">{{ knowledgeIndex + 1 }}</span>
  6. <span class="doc-ref-label">{{ knowledge.doc_name }}</span>
  7. </div>
  8. <template #content>
  9. <div class="knowledge-detail">
  10. <div class="knowledge-content">
  11. {{ knowledge.content_ltks }}
  12. </div>
  13. <div class="knowledge-footer">
  14. <p>检索片段</p>
  15. <p>
  16. <span v-for="(content, contentIndex) in knowledge.content_ltks" :key="contentIndex"
  17. :class="{ active: knowledge.page === contentIndex }" @click="() => {
  18. knowledge.page = contentIndex;
  19. }
  20. ">{{ contentIndex + 1 }}</span>
  21. </p>
  22. <!-- TODO详情暂时注释 -->
  23. <p @click="goKnowledge(knowledge)">查看详情></p>
  24. </div>
  25. </div>
  26. </template>
  27. </a-popover>
  28. </div>
  29. </template>
  30. <script setup>
  31. import { defineComponent, ref, onBeforeUnmount, onMounted, reactive, nextTick, inject } from "vue";
  32. import { defineEmits } from 'vue'
  33. import { getDocumentUrl } from '../../ajax/document';
  34. const props = defineProps({
  35. knowledge: Object,
  36. knowledgeIndex: Number
  37. });
  38. const emit = defineEmits(['go-document']);
  39. const openDocuementPage = (knowledge) => {
  40. const doc_name = knowledge.doc_name;
  41. const doc_id = knowledge.id;
  42. // const pdf_url = `http://192.168.20.119:11080/v1/document/get/${doc_id}`;
  43. const pdf_url = getDocumentUrl(doc_id);
  44. window.open(pdf_url);
  45. }
  46. const goKnowledge = (knowledge) => {
  47. emit('go-document', knowledge)
  48. }
  49. </script>
  50. <style scoped>
  51. .knowledge-detail {
  52. width: 320px;
  53. padding-top: 20px;
  54. .knowledge-content {
  55. height: 300px;
  56. overflow-y: auto;
  57. line-height: 30px;
  58. }
  59. .knowledge-footer {
  60. border-top: 1px solid rgba(229, 229, 229, 1);
  61. margin-top: 20px;
  62. padding-top: 20px;
  63. display: flex;
  64. justify-content: space-between;
  65. align-items: center;
  66. p {
  67. &:nth-child(1) {
  68. opacity: 0.8;
  69. }
  70. &:nth-child(2) {
  71. flex: 1;
  72. display: flex;
  73. justify-content: left;
  74. margin: 0 30px;
  75. >span {
  76. margin: 0 5px;
  77. cursor: pointer;
  78. &:hover,
  79. &.active {
  80. color: #00aea3;
  81. }
  82. }
  83. }
  84. &:nth-child(3) {
  85. font-weight: bold;
  86. cursor: pointer;
  87. &:hover {
  88. color: #00aea3;
  89. }
  90. }
  91. }
  92. }
  93. }
  94. .doc-ref-container {
  95. height: 40px;
  96. display: inline-flex;
  97. align-items: center;
  98. }
  99. .doc-ref-index {
  100. display: inline-block;
  101. background-color: #00aea333;
  102. color: #00aea3;
  103. padding: 1px 5px;
  104. border-radius: 2px;
  105. margin-right: 5px;
  106. font-size: 12px;
  107. /* margin: 0 5px; */
  108. cursor: pointer;
  109. }
  110. .doc-ref-label {
  111. /* margin: 0 5px; */
  112. cursor: pointer;
  113. }
  114. .doc-ref-label:hover {
  115. color: #00aea3;
  116. }
  117. </style>