| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <template>
- <a-modal v-model:visible="show_modal" :align-center="false" top="15vh" @ok="handleOk" @cancel="handleCancel">
- <template #title> 新建 </template>
- <div class="section">
- <div class="form-item">
- <div class="label">图标&名称</div>
- <div class="value">
- <img class="icon" :src="getIconIntelligent(props.target_icon)" alt="" @click="handleSelectIcon" />
- <a-input v-model="form.name" placeholder="请输入名称" />
- </div>
- </div>
- <div class="form-item">
- <div class="label">描述</div>
- <a-textarea v-model="form.description" placeholder="描述" :auto-size="{ minRows: 2, maxRows: 5 }" />
- </div>
- </div>
- </a-modal>
- </template>
- <script setup>
- import { ref, computed } from 'vue';
- import { createDify } from '../../apis/rgflow-dify';
- import { createDialog } from '../../apis/intelligent';
- import { getIconIntelligent, dialogType } from '../../views/manage/common';
- const props = defineProps({
- show_model_item: {
- type: Boolean,
- default: false
- },
- target_intell_type: {
- type: String,
- default: 'advanced-chat'
- },
- target_icon: {
- type: String,
- default: 'intellFrame1'
- }
- });
- const formInit = {
- name: '',
- description: ''
- };
- const form = ref(Object.assign({}, formInit));
- const emit = defineEmits(['update:show_model_item', 'select_icon', 'updateIntelligentList']);
- let show_modal = computed(() => props.show_model_item);
- const handleOk = () => {
- if (form.value.name.trim().length) {
- const data = {
- name: form.value.name,
- description: form.value.description,
- mode: props.target_intell_type
- };
- createDify(data)
- .then((res) => {
- if (res.id && res.id.length) {
- const dialogData = {
- id: res.id,
- name: form.value.name,
- description: form.value.description,
- icon: props.target_icon,
- dialogType: dialogType.DIFY,
- mode: props.target_intell_type
- };
- createOwnDialog(dialogData);
- }
- })
- .catch((err) => {
- console.log('新建失败', err);
- })
- .finally(() => {});
- }
- };
- const createOwnDialog = async (data) => {
- try {
- const res = await createDialog(data);
- if (res.code == 200) {
- form.value = Object.assign({}, formInit);
- emit('update:show_model_item', false);
- emit('updateIntelligentList');
- }
- } catch (err) {
- console.log('创建对话失败', err);
- }
- };
- const handleCancel = () => {
- form.value = Object.assign({}, formInit);
- emit('update:show_model_item', false);
- };
- const handleSelectIcon = () => {
- emit('select_icon');
- };
- </script>
- <style scoped lang="css">
- .section {
- padding: 0 20px;
- }
- .form-item {
- display: flex;
- flex-direction: column;
- gap: 10px;
- margin-top: 20px;
- }
- .value {
- display: flex;
- align-items: center;
- gap: 10px;
- }
- .value .icon {
- width: 44px;
- cursor: pointer;
- }
- .arco-input-wrapper {
- height: 32px;
- background-color: var(--color-neutral-2);
- }
- </style>
|