diff --git a/ui/src/api/dataset.ts b/ui/src/api/dataset.ts index df06d2768..6e61db1df 100644 --- a/ui/src/api/dataset.ts +++ b/ui/src/api/dataset.ts @@ -129,11 +129,12 @@ const getDatasetDetail: (dataset_id: string, loading?: Ref) => Promise< "desc": true } */ -const putDataset: (dataset_id: string, data: any) => Promise> = ( - dataset_id, - data: any -) => { - return put(`${prefix}/${dataset_id}`, data) +const putDataset: ( + dataset_id: string, + data: any, + loading?: Ref +) => Promise> = (dataset_id, data, loading) => { + return put(`${prefix}/${dataset_id}`, data, undefined, loading) } /** * 获取知识库 可关联的应用列表 diff --git a/ui/src/components/card-checkbox/index.vue b/ui/src/components/card-checkbox/index.vue index fad15107c..fb5e2f296 100644 --- a/ui/src/components/card-checkbox/index.vue +++ b/ui/src/components/card-checkbox/index.vue @@ -18,7 +18,8 @@ - + + @@ -40,7 +41,7 @@ const toModelValue = computed(() => (props.valueField ? props.data[props.valueFi // set: (val) => val // }) -const emit = defineEmits(['update:modelValue']) +const emit = defineEmits(['update:modelValue', 'change']) const checked = () => { const value = props.modelValue ? props.modelValue : [] @@ -53,6 +54,10 @@ const checked = () => { emit('update:modelValue', [...value, toModelValue.value]) } } + +function checkboxChange() { + emit('change') +} + diff --git a/ui/src/views/dataset/DatasetSetting.vue b/ui/src/views/dataset/DatasetSetting.vue index 2ede13ba5..803508184 100644 --- a/ui/src/views/dataset/DatasetSetting.vue +++ b/ui/src/views/dataset/DatasetSetting.vue @@ -105,7 +105,7 @@ import { useRoute } from 'vue-router' import BaseForm from '@/views/dataset/component/BaseForm.vue' import datasetApi from '@/api/dataset' import type { ApplicationFormType } from '@/api/type/application' -import { MsgSuccess } from '@/utils/message' +import { MsgSuccess, MsgConfirm } from '@/utils/message' import { isAppIcon } from '@/utils/application' import useStore from '@/stores' const route = useRoute() @@ -120,6 +120,8 @@ const loading = ref(false) const detail = ref({}) const application_list = ref>([]) const application_id_list = ref([]) +const cloneModelId = ref('') + const form = ref({ source_url: '', selector: '' @@ -133,7 +135,6 @@ async function submit() { if (await BaseFormRef.value?.validate()) { await webFormRef.value.validate((valid: any) => { if (valid) { - loading.value = true const obj = detail.value.type === '1' ? { @@ -145,27 +146,49 @@ async function submit() { application_id_list: application_id_list.value, ...BaseFormRef.value.form } - datasetApi - .putDataset(id, obj) - .then((res) => { + + if (cloneModelId.value !== BaseFormRef.value.form.embedding_mode_id) { + MsgConfirm(`提示`, `修改知识库向量模型后,需要对知识库重新向量化,是否继续保存?`, { + confirmButtonText: '重新向量化', + confirmButtonClass: 'primary' + }) + .then(() => { + datasetApi.putDataset(id, obj, loading).then((res) => { + datasetApi.putReEmbeddingDataset(id).then(() => { + MsgSuccess('保存成功') + }) + }) + }) + .catch(() => {}) + } else { + datasetApi.putDataset(id, obj, loading).then((res) => { MsgSuccess('保存成功') - loading.value = false - }) - .catch(() => { - loading.value = false }) + } } }) } } +function reEmbeddingDataset(row: any) { + datasetApi.putReEmbeddingDataset(row.id).then(() => { + MsgSuccess('提交成功') + }) +} + +function saveDataset(data: any) { + datasetApi.putDataset(id, data, loading).then((res) => { + MsgSuccess('保存成功') + }) +} + function getDetail() { dataset.asyncGetDatasetDetail(id, loading).then((res: any) => { detail.value = res.data + cloneModelId.value = res.data?.embedding_mode_id if (detail.value.type === '1') { form.value = res.data.meta } - application_id_list.value = res.data?.application_id_list datasetApi.listUsableApplication(id, loading).then((ok) => { application_list.value = ok.data diff --git a/ui/src/views/dataset/component/BaseForm.vue b/ui/src/views/dataset/component/BaseForm.vue index 88b7d22dd..debe81d63 100644 --- a/ui/src/views/dataset/component/BaseForm.vue +++ b/ui/src/views/dataset/component/BaseForm.vue @@ -5,6 +5,7 @@ :rules="rules" label-position="top" require-asterisk-position="right" + v-loading="loading" > - + + +
+ + {{ item.name }} +
+ +
+ + +
+ + {{ item.name }} + {{ + $t('views.application.applicationForm.form.aiModel.unavailable') + }} +
+ +
+
- +