TopSetting.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <a-space size="large">
  3. <a-input
  4. v-model="searchText"
  5. :placeholder="$t('management.search')"
  6. style="width: 300px"
  7. allow-clear
  8. @input="handleSearch"
  9. >
  10. <template #prefix>
  11. <icon-search />
  12. </template>
  13. </a-input>
  14. <a-button type="primary" size="large" @click="handleCreate">
  15. <template #icon>
  16. <icon-plus />
  17. </template>
  18. {{ $t('management.createIntelligent') }}
  19. </a-button>
  20. </a-space>
  21. <ModalAddIntel
  22. v-model:visible="visible"
  23. @add_intelligent="addIntelligent"
  24. @createRAGFLOWIntelligent="createRAGFLOWIntelligent"
  25. ></ModalAddIntel>
  26. <ModelAddItem
  27. v-model:show_model_item="show_model_item"
  28. :target_icon="target_icon"
  29. :target_intell_type="target_intell_type"
  30. @select_icon="selectIcon"
  31. @updateIntelligentList="updateIntelligentList"
  32. >
  33. </ModelAddItem>
  34. <ModelSelectIcon v-model:show_select_icon="show_select_icon" @sendIcon="sendIcon"></ModelSelectIcon>
  35. <!-- v-if="show_rg_config" -->
  36. <AgentConfig
  37. v-model:show_rg_config="show_rg_config"
  38. ref="editAgentKuai"
  39. :typeAngint="add_type"
  40. :formData="itemObj"
  41. @queryList="queryList"
  42. @updateIntelligentList="updateIntelligentList"
  43. ></AgentConfig>
  44. </template>
  45. <script setup>
  46. import { ref, reactive } from 'vue';
  47. import { useRouter } from 'vue-router';
  48. import ModalAddIntel from './ModalAddIntel.vue';
  49. import ModelAddItem from './ModelAddItem.vue';
  50. import ModelSelectIcon from './ModalSelectIcon.vue';
  51. import AgentConfig from './rgflow/agentConfig.vue';
  52. import { funcDebounce } from '../../utils/utils';
  53. import { getRagFlowData } from '../../apis/rgflow-dify';
  54. import { bus_intelligentSearch, bus_intelligentEdit } from '../../base/event-bus';
  55. const router = useRouter();
  56. const searchText = ref('');
  57. const visible = ref(false);
  58. const show_model_item = ref(false);
  59. const show_select_icon = ref(false);
  60. const target_icon = ref('');
  61. // 当前新建智能体类型
  62. const target_intell_type = ref('');
  63. // ragflow配置
  64. const show_rg_config = ref(false);
  65. const editAgentKuai = ref(null);
  66. let add_type = ref('add');
  67. let itemObj = reactive({});
  68. const queryList = async (params = {}) => {
  69. // setLoading(true);
  70. // try {
  71. // const { data } = await querydialogList(params);
  72. // console.log(data, 'data');
  73. // agentList.value = data.map((item) => {
  74. // return {
  75. // ...item,
  76. // off: true,
  77. // };
  78. // });
  79. // } catch (err) {
  80. // // you can report use errorHandler or other
  81. // } finally {
  82. // setLoading(false);
  83. // }
  84. };
  85. // 搜索
  86. const handleSearch = funcDebounce(
  87. () => {
  88. bus_intelligentSearch.emit(searchText.value);
  89. },
  90. 300,
  91. false
  92. );
  93. // 创建智能体
  94. const handleCreate = () => {
  95. visible.value = true;
  96. };
  97. // 创建rgflow智能体
  98. const createRAGFLOWIntelligent = () => {
  99. show_rg_config.value = true;
  100. };
  101. const addIntelligent = (data) => {
  102. //根据智能体类型,打开不同的配置面板data.type
  103. show_model_item.value = true;
  104. target_intell_type.value = data.type;
  105. };
  106. const selectIcon = () => {
  107. show_select_icon.value = true;
  108. };
  109. const sendIcon = (icon) => {
  110. console.log('sendIcon', icon);
  111. target_icon.value = icon;
  112. };
  113. const updateIntelligentList = () => {
  114. bus_intelligentSearch.emit('');
  115. target_icon.value = '';
  116. };
  117. const getRagFlowDataFunc = async (id) => {
  118. try {
  119. const res = await getRagFlowData(id);
  120. Object.assign(itemObj, res.data);
  121. editAgentKuai.value.editClick();
  122. } catch (err) {
  123. // you can report use errorHandler or other
  124. } finally {
  125. }
  126. };
  127. /**
  128. * 监听编辑智能体事件
  129. * @param {Object} item 编辑智能体对象
  130. * case 1: 编辑ragflow智能体
  131. * case 2: 编辑bs智能体
  132. * case 3: 编辑basic智能体
  133. * case 4: 编辑Dify智能体
  134. * */
  135. bus_intelligentEdit.on((item) => {
  136. switch (item.agentType) {
  137. case '1':
  138. // TODO: 编辑rgflow智能体
  139. // itemObj = item;
  140. show_rg_config.value = true;
  141. add_type = 'edit';
  142. getRagFlowDataFunc(item.id);
  143. break;
  144. case '4':
  145. // TODO: 进入Dify智能体配置
  146. router.push({ path: '/intelligent/detail', query: { id: item.id, name: item.name } });
  147. break;
  148. default:
  149. console.log('暂不支持该智能体类型');
  150. }
  151. });
  152. </script>
  153. <style scoped lang="css">
  154. .arco-input-wrapper {
  155. background-color: var(--color-bg-5);
  156. }
  157. </style>