ConversationBoardContainer.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <div class="conversation-board-container">
  3. <div class="conversation-board-left"></div>
  4. <div class="conversation-board-main">
  5. <BoardWelcome />
  6. <BoardTags @change="handleTagChange" />
  7. <template v-if="api_status === 2">
  8. <div class="infomations-container">
  9. <a-spin :size="32" />
  10. </div>
  11. </template>
  12. <template v-if="api_status === 3">
  13. <BoardAgentList @itemActive="handleItemActive" :list="list_agents" />
  14. <div class="infomations-container" v-if="list_agents.length === 0">
  15. <a-empty> {{ $t('conversation.history_empty') }} </a-empty>
  16. </div>
  17. </template>
  18. <template v-if="api_status === 4">
  19. <div class="infomations-container">
  20. <a-result status="warning" :title="api_message"> </a-result>
  21. </div>
  22. </template>
  23. <template v-if="api_status === 5">
  24. <div class="infomations-container">
  25. <a-result status="error" :title="api_message"> </a-result>
  26. </div>
  27. </template>
  28. <div class="conversation-board-placeholder"></div>
  29. </div>
  30. <div class="conversation-board-right"></div>
  31. </div>
  32. </template>
  33. <script setup>
  34. import { ref, onMounted } from 'vue';
  35. import BoardWelcome from '../../modules/conversation-board/BoardWelcome.vue';
  36. import BoardTags from '../../modules/conversation-board/BoardTags.vue';
  37. import BoardAgentList from '../../modules/conversation-board/BoardAgentList.vue';
  38. import useAgentList4Board from '../../modules/conversation-board/use-agent-list-4-board';
  39. import { useRecentAgentStore } from '../../base/store/use-recent-agents';
  40. import { useAllAgentStore } from '../../base/store/use-all-agents';
  41. const emit = defineEmits(['agentActive']);
  42. const selected_id = ref('');
  43. const { api_status, api_message, list_agents, getAgentList } = useAgentList4Board();
  44. const recentAgents = useRecentAgentStore();
  45. const allAgents = useAllAgentStore();
  46. const handleItemActive = (target_id) => {
  47. const target_info = allAgents.getInfo(target_id);
  48. // 添加记录
  49. recentAgents.addItem(target_id, 'name', 'icon');
  50. emit('agentActive', target_id);
  51. };
  52. /**
  53. * 处理请求参数
  54. */
  55. const formatListOptions = () => {
  56. const obj = {};
  57. if (selected_id.value) {
  58. obj.label = selected_id.value;
  59. }
  60. return obj;
  61. };
  62. const handleRequest = () => {
  63. const opts = formatListOptions();
  64. getAgentList(opts);
  65. };
  66. const handleTagChange = (tag_id) => {
  67. selected_id.value = tag_id;
  68. handleRequest();
  69. };
  70. onMounted(() => {
  71. // 调用api
  72. handleRequest();
  73. });
  74. </script>
  75. <style lang="css" scoped>
  76. .conversation-board-container {
  77. display: flex;
  78. justify-content: center;
  79. margin-left: auto;
  80. margin-right: auto;
  81. }
  82. .conversation-board-left {
  83. width: 25%;
  84. flex-shrink: 0;
  85. }
  86. .conversation-board-right {
  87. width: 25%;
  88. flex-shrink: 0;
  89. }
  90. .conversation-board-main {
  91. /* width: 60%; */
  92. flex-grow: 1;
  93. height: 100%;
  94. margin-left: auto;
  95. margin-right: auto;
  96. margin-top: 150px;
  97. display: flex;
  98. flex-direction: column;
  99. justify-content: center;
  100. }
  101. /* 底部占位元素 */
  102. .conversation-board-placeholder {
  103. height: 50px;
  104. }
  105. .conversation-board-main .infomations-container {
  106. display: flex;
  107. justify-content: center;
  108. align-items: center;
  109. min-height: 200px;
  110. }
  111. </style>