| | |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import { ElMessageBox } from 'element-plus'; |
| | | import { ElMessage, ElMessageBox } from 'element-plus'; |
| | | import { computed, onMounted, reactive, ref } from 'vue'; |
| | | import { addUserSample, deleteUserSample, listUserSample, updateUserSample } from '/@/api/ai/chat'; |
| | | import { activeGroupType, activeRoomId, activeSampleId, setRoomConfig } from '/@/stores/chatRoom'; |
| | |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | dangerouslyUseHTMLString: true, |
| | | closeOnClickModal: false, |
| | | type: 'warning', |
| | | }).then(async () => { |
| | | const res = await deleteUserSample({ |
| | |
| | | handleClose(); |
| | | } |
| | | } else { |
| | | const res = await addUserSample({ |
| | | addCommonPhrasesData(); |
| | | } |
| | | }; |
| | | //添加一条数据源 |
| | | const addCommonPhrasesData = async () => { |
| | | const res = await addUserSample({ |
| | | question: state.inputCommonPhrases, |
| | | group_type: activeGroupType.value, |
| | | }); |
| | | if (res.json_ok) { |
| | | commonPhrases.value.push({ |
| | | id: res.sample_id, |
| | | question: state.inputCommonPhrases, |
| | | group_type: activeGroupType.value, |
| | | }); |
| | | if (res.json_ok) { |
| | | commonPhrases.value.push({ |
| | | id: res.sample_id, |
| | | question: state.inputCommonPhrases, |
| | | }); |
| | | handleClose(); |
| | | } |
| | | handleClose(); |
| | | } |
| | | }; |
| | | //#endregion |
| | |
| | | activeSampleId.value = item.id; |
| | | }; |
| | | const commonChatByUser = (data) => { |
| | | commonPhrases.value.push(data); |
| | | const question = data.question; |
| | | const isCommon = commonPhrases.value.findIndex((item) => item.question === question) > -1; |
| | | if (isCommon) { |
| | | return ElMessage.warning('该问题已存在常用语中'); |
| | | } else { |
| | | state.inputCommonPhrases = question; |
| | | addCommonPhrasesData(); |
| | | } |
| | | }; |
| | | //#endregion |
| | | onMounted(() => { |
| | | getCommonPhrases(); |
| | | }); |
| | | defineExpose({ commonChatByUser }); |
| | | defineExpose({ commonChatByUser, getCommonPhrases }); |
| | | </script> |
| | | <style scoped lang="scss"> |
| | | .container { |