| | |
| | | ref="uploadRef" |
| | | @change="onChange" |
| | | multiple |
| | | :limit="1" |
| | | /> |
| | | <div style="width: 100%;margin-top: 10px;display: flex; justify-content: space-between;"> |
| | | <div style="width: 100%;margin-top: 10px;display: flex; justify-content: space-between;" class="upload-wrap"> |
| | | <div> |
| | | <span>解析方法: </span> |
| | | <a-radio-group v-model="parser_id"> |
| | | <a-radio-group v-model="parser_id" style="width: 400px;" @change="parserChange"> |
| | | <a-popover title="" |
| | | v-for="item in parser_ids" |
| | | :key="item.value" |
| | | v-for="item in filterData" |
| | | :key="item.value" |
| | | > |
| | | <a-radio |
| | | :value="item.value" |
| | |
| | | </a-popover> |
| | | </a-radio-group> |
| | | </div> |
| | | <a-select :style="{width:'100px', margin: '0 10px'}" :default-value="['通用', '多模态']" v-model="parser_configs" multiple size="small"> |
| | | <a-option v-for="item in parser_ids" :key="item.value">{{ item.name }}</a-option> |
| | | </a-select> |
| | | <p class="config-text">更多配置</p> |
| | | <a-button |
| | | :loading="onFileSelectedLoading" |
| | | @click="upDataFile" |
| | |
| | | import { onMounted, onBeforeMount, reactive, ref, computed, watch } from "vue"; |
| | | import axios from "axios"; |
| | | import { Message } from "@arco-design/web-vue"; |
| | | import { uploadWithoutKb } from "@/api/session"; |
| | | import { addSessionApi, getParseMethodsListApi, getSessionDetailsApi, uploadWithoutKb } from "@/api/session"; |
| | | |
| | | const visible = ref(false); |
| | | const loading = ref(false); |
| | |
| | | const filesBtn = ref(null); |
| | | const onFileSelectedLoading = ref(false); |
| | | const parser_id = ref(""); |
| | | const parseridConfig = ref(false); |
| | | const uploaditemList = ref([]); |
| | | const activeSessionId = ref(''); |
| | | let kbtenantInfo = reactive({ |
| | |
| | | "random_seed": 1500 |
| | | } |
| | | }, // 用户名 |
| | | qa: {}, |
| | | qa: { |
| | | "entity_types": [ |
| | | "organization", |
| | | "person", |
| | | "location", |
| | | "event", |
| | | "time" |
| | | ], |
| | | "raptor": { |
| | | "use_raptor": false |
| | | } |
| | | }, |
| | | resume: {}, |
| | | manual: {}, |
| | | table: {}, |
| | |
| | | one: {}, |
| | | |
| | | }); |
| | | const parser_configs = ref(['通用', '多模态']); |
| | | const parser_ids = ref([ |
| | | { |
| | | name: '通用', |
| | |
| | | parser_config_str: '支持的文件格式为DOCX、EXCEL、PDF、TXT' |
| | | }, |
| | | ]); |
| | | const parser_idsArr = ref([]); |
| | | const uploadList = ref([]); |
| | | const props = defineProps(["sessionId"]); |
| | | const emit = defineEmits(["selectFileCallback"]); |
| | |
| | | const files = ref([]); |
| | | const acceptNameList = computed(() => { |
| | | return ".word, .pdf, .ppt, .excel, .txt, .zip, .rar, .7z, .doc, .docx, .xls, .xlsx, .pptx, .ppt, .pdf, .mp4, .avi, .mp3,.wav, .wma, .wmv, .rm,"; |
| | | }); |
| | | |
| | | const filterData = computed(() => { |
| | | const result = parser_ids.value.filter(val => parser_configs.value.includes(val.name)).reverse().slice(0,4).reverse(); |
| | | result.unshift({ |
| | | name: '智能识别', |
| | | value: '', |
| | | parser_config_str: '', |
| | | parser_config: '' |
| | | }); |
| | | return result; |
| | | }); |
| | | |
| | | const init = () => { |
| | |
| | | // value: value1 |
| | | // }; |
| | | // }); |
| | | getParseMethodsList(); |
| | | } |
| | | |
| | | const chooseParser = (item) => { |
| | | console.log(item); |
| | | }; |
| | | |
| | | const onChange = (fileList) => { |
| | | files.value = fileList; |
| | | files.value.forEach((item) => { |
| | | |
| | | }); |
| | | |
| | | }; |
| | | const parserChange = ()=>{ |
| | | parseridConfig.value = false; |
| | | } |
| | | |
| | | const visibleChange = (e) => { |
| | | e.stopPropagation(); |
| | | visible.value = !visible.value; |
| | | } |
| | | |
| | | const upDataFile = () => { |
| | | |
| | | const getIconByExtension = (extension) => { |
| | | const fileExtension = ref(''); |
| | | fileExtension.value = extension.split('.').pop(); |
| | | let type = ''; |
| | | parser_idsArr.value.forEach((item)=>{ |
| | | // 包含元素 |
| | | if (item.formats.includes(fileExtension.value)){ |
| | | type = item.id; |
| | | } |
| | | }) |
| | | return type; |
| | | }; |
| | | |
| | | const upDataFile = async () => { |
| | | // if (!activeSessionId.value) { |
| | | // //新建会话 |
| | | // const res = await addSessionApi({ |
| | | // dialog_id: '', |
| | | // conversation_desc: '', |
| | | // }); |
| | | // // console.log(res, "res"); |
| | | // if (res.code == 200) { |
| | | // // console.log(res.data.conversation_id); |
| | | // activeSessionId.value = res.data?.conversation_id; |
| | | // const { code, data } = await getSessionDetailsApi(res.data?.conversation_id); |
| | | // if (code === 200) { |
| | | // console.log(data, '新建会话详情'); |
| | | // } |
| | | // } else { |
| | | // Message.error('创建会话失败,请重试'); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | |
| | | |
| | | console.log(files.value, "files"); |
| | | console.log(parser_ids.value, "解析方法"); |
| | | if(files.value.length == 0){ |
| | |
| | | size: (item.file.size/1024).toFixed(2) + 'K', |
| | | } |
| | | }) |
| | | // onFileSelectedLoading.value = true; |
| | | // const formData = new FormData(); |
| | | // for (let i = 0; i < files.value.length; i++) { |
| | | // formData.append('file', files.value[i].file); |
| | | // formData.append('conversation_id', activeSessionId.value); |
| | | // formData.append('parser_id', parser_id.value); |
| | | // formData.append('parser_config', ''); |
| | | // } |
| | | // uploadWithoutKb(formData).then((res) => { |
| | | // onFileSelectedLoading.value = false; |
| | | // if (res.code == 200) { |
| | | // cancel(); |
| | | // // uploaditemList.value = []; |
| | | // emit('selectFileCallback', uploaditemList.value); |
| | | // Message.success('上传成功'); |
| | | // } else { |
| | | // Message.error('上传失败'); |
| | | // } |
| | | // }); |
| | | |
| | | cancel(); |
| | | emit('selectFileCallback', uploaditemList.value); |
| | | onFileSelectedLoading.value = true; |
| | | const formData = new FormData(); |
| | | for (let i = 0; i < files.value.length; i++) { |
| | | formData.append('file', files.value[i].file); |
| | | formData.append('conversation_id', activeSessionId.value); |
| | | formData.append('parser_config', ''); |
| | | if(!parser_id.value){ |
| | | formData.append('parser_id', getIconByExtension(files.value[i].name)); |
| | | }else{ |
| | | formData.append('parser_id', parser_id.value); |
| | | } |
| | | } |
| | | uploadWithoutKb(formData).then((res) => { |
| | | onFileSelectedLoading.value = false; |
| | | if (res.code == 200) { |
| | | cancel(); |
| | | // uploaditemList.value = []; |
| | | emit('selectFileCallback', uploaditemList.value); |
| | | Message.success('上传成功'); |
| | | } else { |
| | | Message.error('上传失败'); |
| | | } |
| | | }); |
| | | |
| | | |
| | | |
| | |
| | | defineExpose({ |
| | | cancel |
| | | }) |
| | | |
| | | const getParseMethodsList = async () => { |
| | | let res = await getParseMethodsListApi(); |
| | | parser_ids.value = res.data.map((item) => { |
| | | return { |
| | | name: item.name, |
| | | value: item.id, |
| | | parser_config: '', |
| | | parser_config_str: item.parser_config_str |
| | | }; |
| | | }); |
| | | parser_idsArr.value = res.data; |
| | | } |
| | | |
| | | |
| | | onBeforeMount(() => { |
| | |
| | | |
| | | |
| | | </script> |
| | | |
| | | <style> |
| | | .upload-wrap .arco-select-view-inner{ |
| | | display: none; |
| | | } |
| | | </style> |
| | | <style scoped lang="less"> |
| | | .aUpload { |
| | | width: 100%; |
| | |
| | | overflow: hidden; |
| | | overflow-y: auto; |
| | | } |
| | | .upload-wrap { |
| | | position: relative; |
| | | } |
| | | .config-text { |
| | | position: absolute; |
| | | right: 70px; |
| | | bottom: -11px; |
| | | font-size: 12px; |
| | | } |
| | | </style> |