From 88b1281f51f590f88ae581d2a14b877da9439250 Mon Sep 17 00:00:00 2001 From: zhangxiao <898441624@qq.com> Date: 星期一, 12 八月 2024 14:55:37 +0800 Subject: [PATCH] fix: 只能体修改样式 --- src/views/dmx/knowledgeLib/config.vue | 123 +++++++++++++++-------------------------- 1 files changed, 45 insertions(+), 78 deletions(-) diff --git a/src/views/dmx/knowledgeLib/config.vue b/src/views/dmx/knowledgeLib/config.vue index 16fdf1a..5e6af51 100644 --- a/src/views/dmx/knowledgeLib/config.vue +++ b/src/views/dmx/knowledgeLib/config.vue @@ -1,5 +1,5 @@ <template> - <div class="main-container"> + <div ref="scrollContainer" class="main-container"> <div style="position: absolute;top: 0;left: 0;width: 100%;padding: 0 20px"> <h4 style="margin-bottom: 10px"></h4> <div style="color: #666666;">鍦ㄨ繖閲屾洿鏂版偍鐨勭煡璇嗗簱璇︾粏淇℃伅锛屽挨鍏舵槸瑙f瀽鏂规硶銆�</div> @@ -14,49 +14,14 @@ </a-form-item> <a-form-item field="section" label="鐭ヨ瘑搴撳浘鐗�"> <a-space direction="vertical" :style="{ width: '100%' }"> - <a-upload - :auto-upload="false" - :fileList="file ? [file] : []" - :show-file-list="false" - @change="onChange" - @progress="onProgress" - > - <template #upload-button> - <div - :class="`arco-upload-list-item${ - file && file.status === 'error' ? ' arco-upload-list-item-error' : '' - }`" - > - <div - class="arco-upload-list-picture custom-upload-avatar" - v-if="file && file.url" - > - <img :src="file.url" /> - <div class="arco-upload-list-picture-mask"> - <IconEdit /> - </div> - <a-progress - v-if="file.status === 'uploading' && file.percent < 100" - :percent="file.percent" - type="circle" - size="mini" - :style="{ - position: 'absolute', - left: '50%', - top: '50%', - transform: 'translateX(-50%) translateY(-50%)', - }" - /> - </div> - <div class="arco-upload-picture-card" v-else> - <div class="arco-upload-picture-card-text"> - <IconPlus /> - <div style="margin-top: 10px; font-weight: 600">涓婁紶</div> - </div> - </div> - </div> - </template> - </a-upload> + <Upload + v-if="avatarShow" + :action="uploadAction" + :limit="1" + :url="httpUrl + form.avatar" + @update:fileList="updateFileList" + @success="handleSuccess" + ></Upload> </a-space> </a-form-item> <a-form-item field="section" label="鎻忚堪"> @@ -131,7 +96,7 @@ <div style="width: 100%;text-align: right"> <a-space> <a-button @click="cancelConfig">鍙栨秷</a-button> - <a-button type="primary" html-type="submit">淇濆瓨</a-button> + <a-button :loading="loading" type="primary" html-type="submit">淇濆瓨</a-button> </a-space> </div> </a-form-item> @@ -193,8 +158,9 @@ import { Message } from "@arco-design/web-vue"; import { queryModelList,kbUpdate } from "@/api/kbList"; import message from "@arco-design/web-vue/es/message"; - - +import useLoading from "@/hooks/loading"; +const { loading,setLoading } = useLoading(true); +const scrollContainer = ref(); const props = defineProps(['kbtenantInfo']) const emit = defineEmits(['cancleConfig','saveConfig']) // 瑙f瀽鏂规硶鍒楄〃 @@ -207,10 +173,11 @@ }); let kbObj = reactive({}); +let avatarShow = ref(true); const form = reactive({ - name: kbObj.name, - avatar: '',// + name: '', + avatar: '',//澶村儚 max_token: 600, threshold: 0.32, max_cluster: 233, @@ -225,7 +192,7 @@ language: "English", permission: "", embd_id: "BAAI/bge-large-zh-v1.5", - parser_id: kbObj.parser_id, + parser_id: '', layout_recognize: true }); @@ -255,34 +222,24 @@ }, ], } - - let visible = ref(false); -let loading = ref(false); const formRef = ref(null); const modelList = ref({}); const file = ref(); -const onChange = (_, currentFile) => { - file.value = currentFile; - convertImageToBase64(file.value.file).then((result)=>{ - form.avatar = result; - }) +const uploadAction = '/api/v1/llm/upload'; // 鏇挎崲涓轰綘鐨勪笂浼燗PI +const fileList = ref([]); +const imageUrls = ref([]); +const httpUrl = localStorage.getItem('httpUrl'); + +const updateFileList = (newFileList) => { + fileList.value = newFileList; + console.log(newFileList, 88); }; -function convertImageToBase64(file) { - return new Promise((resolve, reject) => { - const reader = new FileReader(); - reader.onloadend = function() { - resolve(reader.result); - }; - reader.onerror = reject; - reader.readAsDataURL(file); - }); -} - -const onProgress = (currentFile) => { - file.value = currentFile; +const handleSuccess = (urls) => { + imageUrls.value = urls; // 鎷垮埌涓婁紶鐨勫浘鐗囧湴鍧� + form.avatar = urls[0]; }; @@ -315,7 +272,7 @@ }; } try { - + setLoading(true) const data = await kbUpdate(parms); if(data.code == '0'){ Message.success("閰嶇疆鎴愬姛"); @@ -323,10 +280,11 @@ emit('saveConfig') } - // emit('upTabdateItem') + setLoading(false) } catch (err) { Message.error(err.message); + setLoading(false) } @@ -379,13 +337,11 @@ formRef.value.resetFields(); kbObj = value; console.log(kbObj, 'kbObj'); - // if(kbObj.avatar){ - // file.value.url = kbObj.avatar - // } let configObj = { name: kbObj.name, avatar: kbObj.avatar, pages: kbObj.parser_config.pages, + chunk_token_num: kbObj.parser_config.chunk_token_num, description: kbObj.description, language: "English", permission: kbObj.permission, @@ -402,9 +358,19 @@ use_raptor: kbObj.parser_config.raptor.use_raptor, }); }else{ - Object.assign(form,configObj); + Object.assign(form,{ + ...configObj, + use_raptor: false, + }); } + imageUrls.value = [kbObj.avatar]; console.log(form,'閰嶇疆椤甸潰琛ㄥ崟淇℃伅'); + avatarShow.value = false; + setTimeout(() => { + avatarShow.value = true; + },100); + scrollContainer.value.scrollTop = 0; + } defineExpose({ @@ -413,6 +379,7 @@ onBeforeMount(()=>{ + setLoading(false) queryModel({}) }) onMounted(()=>{ @@ -438,7 +405,7 @@ justify-content: space-between; height: 100%; overflow: auto; - //background: #626aea; + border-radius: 8px; background: var(--color-bg-2); padding-top: 80px; -- Gitblit v1.8.0