RefferenceFileBlocks.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <div>
  3. <header class="client-formated-markdown-element-item client-formated-markdown-refference-header">
  4. <div>来源</div>
  5. <div class="btn-show-related-all" @click="showAllRelated">查看全部关联 <icon-double-right /></div>
  6. </header>
  7. <RefferenceFileNameList :document_list="document_list" @showDocDetail="handleShowDocDetail" />
  8. <a-drawer
  9. :width="'90%'"
  10. :height="340"
  11. :visible="visible"
  12. :placement="position"
  13. data-flag="reffernce-file-block-drawer"
  14. @ok="handleOk"
  15. @cancel="handleCancel"
  16. unmountOnClose
  17. >
  18. <template #title> 文档详情 </template>
  19. <div>
  20. <RefferenceDocDetail :targetDocument="targetDocument" @back="handleBackQA" />
  21. </div>
  22. </a-drawer>
  23. </div>
  24. </template>
  25. <script setup>
  26. import { ref, computed } from 'vue';
  27. import RefferenceFileNameList from './RefferenceFileNameList.vue';
  28. import RefferenceDocDetail from './RefferenceDocDetail.vue';
  29. const props = defineProps({
  30. doc_aggs: Array,
  31. chunks: Array
  32. });
  33. const visible = ref(false);
  34. const position = ref('right');
  35. const document_list = computed(() => {
  36. const doc_list = props.doc_aggs;
  37. const chunks = props.chunks;
  38. const res_list = [];
  39. if (Array.isArray(doc_list)) {
  40. const len = doc_list.length;
  41. for (let i = 0; i < len; i++) {
  42. if (i >= 3) {
  43. break;
  44. }
  45. const doc = doc_list[i];
  46. const res_doc = {
  47. doc_id: doc.doc_id,
  48. doc_name: doc.doc_name,
  49. count: doc.count,
  50. page: i
  51. };
  52. const cur_doc_id = doc.doc_id;
  53. const cur_doc_peaces = [];
  54. if (chunks && Array.isArray(chunks)) {
  55. chunks.forEach((item, index) => {
  56. const chunk_doc_id = item.doc_id;
  57. if (cur_doc_id === chunk_doc_id) {
  58. cur_doc_peaces.push(item.content_ltks);
  59. }
  60. });
  61. }
  62. res_doc.content_ltks = cur_doc_peaces;
  63. res_list.push(res_doc);
  64. }
  65. }
  66. return res_list;
  67. });
  68. /**
  69. * 目标数据
  70. */
  71. const targetDocument = ref({
  72. doc_aggs: props.doc_aggs,
  73. chunks: props.chunks
  74. });
  75. const handleClick = () => {
  76. visible.value = true;
  77. };
  78. const handleOk = () => {
  79. visible.value = false;
  80. };
  81. const handleCancel = () => {
  82. visible.value = false;
  83. };
  84. const handleShowDocDetail = (item) => {
  85. // TODO:组装参数数据
  86. const cur_tar = targetDocument.value;
  87. const obj = {
  88. doc_aggs: cur_tar.doc_aggs,
  89. chunks: cur_tar.chunks,
  90. doc_id: item.doc_id,
  91. doc_name: item.doc_name,
  92. count: item.count,
  93. content_ltks: item.content_ltks
  94. };
  95. targetDocument.value = obj;
  96. // 展示文档详情
  97. handleClick();
  98. };
  99. /**
  100. * 显示第一个
  101. */
  102. const showAllRelated = () => {
  103. const item = document_list.value[0];
  104. const cur_tar = targetDocument.value;
  105. const obj = {
  106. doc_aggs: cur_tar.doc_aggs,
  107. chunks: cur_tar.chunks,
  108. doc_id: item.doc_id,
  109. doc_name: item.doc_name,
  110. count: item.count,
  111. content_ltks: item.content_ltks
  112. };
  113. targetDocument.value = obj;
  114. handleClick();
  115. };
  116. // 返回
  117. const handleBackQA = () => {
  118. handleCancel();
  119. };
  120. </script>
  121. <style scoped>
  122. .btn-show-related-all {
  123. cursor: pointer;
  124. }
  125. .btn-show-related-all:hover {
  126. color: #00aea3;
  127. }
  128. </style>
  129. <style>
  130. div.arco-drawer-container[data-flag='reffernce-file-block-drawer'] .arco-drawer-body {
  131. height: calc(100vh - 48px - 65px);
  132. overflow: hidden;
  133. }
  134. </style>