Merge branch 'main' of github.com:maxkb-dev/maxkb

This commit is contained in:
shaohuzhang1 2024-03-04 10:12:38 +08:00
commit ab79abce9c
5 changed files with 31 additions and 3 deletions

View File

@ -63,6 +63,7 @@
<script setup lang="ts">
import { ref, watch, nextTick } from 'vue'
import { cloneDeep } from 'lodash'
import { arraySort } from '@/utils/utils'
const emit = defineEmits(['refresh'])
const ParagraphDialogRef = ref()
@ -80,6 +81,7 @@ const open = (data: any, id?: string) => {
detail.value.paragraph_list = id
? detail.value.paragraph_list.filter((v: any) => v.dataset_id === id)
: detail.value.paragraph_list
detail.value.paragraph_list = arraySort(detail.value.paragraph_list, 'similarity', true)
dialogVisible.value = true
}

View File

@ -17,6 +17,8 @@
:auto-upload="false"
:show-file-list="false"
accept=".txt, .md"
limit="50"
:on-exceed="onExceed"
>
<img src="@/assets/upload-icon.svg" alt="" />
<div class="el-upload__text">
@ -77,6 +79,9 @@ function deleteFlie(index: number) {
form.value.fileList.splice(index, 1)
}
const onExceed = () => {
MsgError('每次最多上传50个文件')
}
/*
表单校验
*/
@ -86,6 +91,7 @@ function validate() {
return valid
})
}
onMounted(() => {
if (documentsFiles.value) {
form.value.fileList = documentsFiles.value

View File

@ -36,7 +36,7 @@
<template #default="{ node, data }">
<span class="flex align-center">
<AppAvatar
v-if="!node.isLeaf && data.type === '1'"
v-if="!data.dataset_id && data.type === '1'"
class="mr-12 avatar-purple"
shape="square"
:size="24"
@ -44,7 +44,7 @@
<img src="@/assets/icon_web.svg" style="width: 58%" alt="" />
</AppAvatar>
<AppAvatar
v-else-if="!node.isLeaf && data.type === '0'"
v-else-if="!data.dataset_id && data.type === '0'"
class="mr-12"
shape="square"
:size="24"

View File

@ -21,7 +21,7 @@
</div>
</el-scrollbar>
<div class="text-right p-24 pt-0" v-if="problemId && isEdit">
<el-button @click.prevent="isEdit = false"> 取消 </el-button>
<el-button @click.prevent="cancelEdit"> 取消 </el-button>
<el-button type="primary" :disabled="loading" @click="submitHandle"> 保存 </el-button>
</div>
</el-col>
@ -46,6 +46,7 @@
<script setup lang="ts">
import { ref, watch, nextTick } from 'vue'
import { useRoute } from 'vue-router'
import { cloneDeep } from 'lodash'
import ParagraphForm from '@/views/paragraph/component/ParagraphForm.vue'
import ProblemComponent from '@/views/paragraph/component/ProblemComponent.vue'
import paragraphApi from '@/api/paragraph'
@ -75,6 +76,7 @@ const detail = ref<any>({})
const isEdit = ref(false)
const document_id = ref('')
const dataset_id = ref('')
const cloneData = ref(null)
watch(dialogVisible, (bool) => {
if (!bool) {
@ -83,13 +85,20 @@ watch(dialogVisible, (bool) => {
isEdit.value = false
document_id.value = ''
dataset_id.value = ''
cloneData.value = null
}
})
const cancelEdit = () => {
isEdit.value = false
detail.value = cloneDeep(cloneData.value)
}
const open = (data: any) => {
if (data) {
detail.value.title = data.title
detail.value.content = data.content
cloneData.value = cloneDeep(detail.value)
problemId.value = data.id
document_id.value = data.document_id
dataset_id.value = data.dataset_id || id

View File

@ -61,6 +61,17 @@ watch(
immediate: true
}
)
watch(
() => props.isEdit,
(value) => {
if (!value) {
paragraphFormRef.value?.clearValidate()
}
},
{
immediate: true
}
)
/*
表单校验