|
@@ -81,13 +81,18 @@ import {
|
|
|
watch,
|
|
|
} from 'vue'
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
-import { useDialogStore, useDictionaryStore } from '@/stores'
|
|
|
+import { useAppStore, useDialogStore, useDictionaryStore } from '@/stores'
|
|
|
import { useRouter } from 'vue-router'
|
|
|
import modelConfig from './model-config.vue'
|
|
|
-import { datasetsCreate, datasetsDetail } from '@/api/modules/knowledge'
|
|
|
+import {
|
|
|
+ datasetsCreate,
|
|
|
+ datasetsDetail,
|
|
|
+ datasetsUpdate,
|
|
|
+} from '@/api/modules/knowledge'
|
|
|
import { debounce } from 'lodash'
|
|
|
|
|
|
const router = useRouter()
|
|
|
+const AppStore = useAppStore()
|
|
|
const DictionaryStore = useDictionaryStore()
|
|
|
const DialogStore = useDialogStore()
|
|
|
const emit = defineEmits(['update:show', 'refresh'])
|
|
@@ -136,7 +141,18 @@ watch(
|
|
|
)
|
|
|
const initDictionary = () => {}
|
|
|
const initData = () => {
|
|
|
- datasetsDetail(props.transfer.id).then((data) => {})
|
|
|
+ state.loading = true
|
|
|
+ datasetsDetail(props.transfer.id)
|
|
|
+ .then(({ data }: any) => {
|
|
|
+ state.form = data
|
|
|
+ ref_modelConfig.value.init(data)
|
|
|
+ })
|
|
|
+ .catch(({ message }: any) => {
|
|
|
+ ElMessage.error(message)
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ state.loading = false
|
|
|
+ })
|
|
|
}
|
|
|
const onSubmit = (isImport) => {
|
|
|
ref_form.value
|
|
@@ -146,36 +162,54 @@ const onSubmit = (isImport) => {
|
|
|
content: `请确认是否${titleCpt.value}?${isImport ? '创建成功后将自动跳转至文档上传页面!' : ''}`,
|
|
|
onSubmit: () => {
|
|
|
state.loading = true
|
|
|
- datasetsCreate({
|
|
|
- ...state.form,
|
|
|
- ...ref_modelConfig.value.getData(),
|
|
|
- contentConfig: {
|
|
|
- maxParentSize: 500,
|
|
|
- overlapSize: 20,
|
|
|
- parentSeparator: '\n\n',
|
|
|
- splitType: 'CustomSymbolSplitter',
|
|
|
- },
|
|
|
- })
|
|
|
- .then(({ data }: any) => {
|
|
|
- // ElMessage.success(`${titleCpt.value}成功!`)
|
|
|
- // if (isImport) {
|
|
|
- // router.push({
|
|
|
- // name: '18e6009c-a72c-4359-864b-e7725fccca69',
|
|
|
- // params: {
|
|
|
- // id: '知识库ID',
|
|
|
- // },
|
|
|
- // })
|
|
|
- // } else {
|
|
|
- // emit('update:show', false)
|
|
|
- // emit('refresh')
|
|
|
- // }
|
|
|
- })
|
|
|
- .catch(({ message }: any) => {
|
|
|
- ElMessage.error(message)
|
|
|
+ if (props.transfer.mode === 'add') {
|
|
|
+ datasetsCreate({
|
|
|
+ ...state.form,
|
|
|
+ ...ref_modelConfig.value.getData(),
|
|
|
+ tenantId: AppStore.tenantInfo?.id,
|
|
|
+ contentConfig: {
|
|
|
+ maxParentSize: 500,
|
|
|
+ overlapSize: 20,
|
|
|
+ parentSeparator: '\n\n',
|
|
|
+ splitType: 'CustomSymbolSplitter',
|
|
|
+ },
|
|
|
})
|
|
|
- .finally(() => {
|
|
|
- state.loading = false
|
|
|
+ .then(({ data }: any) => {
|
|
|
+ ElMessage.success(`${titleCpt.value}成功!`)
|
|
|
+ if (isImport) {
|
|
|
+ router.push({
|
|
|
+ name: '18e6009c-a72c-4359-864b-e7725fccca69',
|
|
|
+ params: {
|
|
|
+ id: data.id,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ emit('update:show', false)
|
|
|
+ emit('refresh')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(({ message }: any) => {
|
|
|
+ ElMessage.error(message)
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ state.loading = false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ datasetsUpdate({
|
|
|
+ ...state.form,
|
|
|
+ ...ref_modelConfig.value.getData(),
|
|
|
+ tenantId: AppStore.tenantInfo?.id,
|
|
|
})
|
|
|
+ .then(({ data }: any) => {
|
|
|
+ ElMessage.success(`${titleCpt.value}成功!`)
|
|
|
+ })
|
|
|
+ .catch(({ message }: any) => {
|
|
|
+ ElMessage.error(message)
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ state.loading = false
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
})
|
|
|
})
|