更新
This commit is contained in:
@ -37,7 +37,7 @@
|
||||
<p>上传文件提取文本内容(支持 .png, .jpg )</p>
|
||||
<div class="container flex" style="height: 248px;">
|
||||
<div class="mr10">
|
||||
<el-upload :headers="headers" accept=".png,.jpg,jpeg" action="/mosty-api/mosty-base/minio/file/upload" :show-file-list="false" :on-success="handlerSuccess" :on-change="onHandleChange" >
|
||||
<el-upload :headers="headers" accept=".png,.jpg,jpeg" action="/mosty-api/mosty-base/minio/image/upload/id" :show-file-list="false" :on-success="handlerSuccess" :on-change="onHandleChange" >
|
||||
<el-button size="medium" type="primary">上传图片</el-button>
|
||||
</el-upload>
|
||||
<p id="file-info">{{ files.name || '未选择文件' }} </p>
|
||||
@ -105,6 +105,7 @@ const headers = ref({
|
||||
Authorization: store.getters.token
|
||||
});
|
||||
const fjdz = ref('') //附件地址
|
||||
const fjmc = ref('') //附件地址
|
||||
|
||||
const initDemo = () =>{
|
||||
loading.value = imgIsLoad ? false : true;
|
||||
@ -119,6 +120,7 @@ const initDemo = () =>{
|
||||
selectedFile = e.target.files[0];
|
||||
fileText.value = `已选择: ${selectedFile.name} (${( selectedFile.size / 1024 ).toFixed(2)} KB)`;
|
||||
extractBtn.disabled = false;
|
||||
fjmc.value = selectedFile.name;
|
||||
uploadFile(selectedFile); //上传附件
|
||||
} else {
|
||||
selectedFile = null;
|
||||
@ -215,15 +217,11 @@ async function extractTextFromDocx(file) {
|
||||
|
||||
reader.onload = function (event) {
|
||||
const arrayBuffer = event.target.result;
|
||||
|
||||
mammoth
|
||||
.extractRawText({ arrayBuffer: arrayBuffer })
|
||||
.then(function (result) {
|
||||
resolve(result.value);
|
||||
})
|
||||
.catch(function (error) {
|
||||
reject(error);
|
||||
});
|
||||
mammoth.extractRawText({ arrayBuffer: arrayBuffer }).then(function (result) {
|
||||
resolve(result.value);
|
||||
}).catch(function (error) {
|
||||
reject(error);
|
||||
});
|
||||
};
|
||||
|
||||
reader.onerror = reject;
|
||||
@ -237,6 +235,7 @@ const handlerSuccess = (file) =>{
|
||||
|
||||
/**@Descripttion:图片上传事件*/
|
||||
const onHandleChange = (file) => {
|
||||
fjmc.value = file.name;
|
||||
files.value = file;
|
||||
image.value = URL.createObjectURL(file.raw);
|
||||
linadingImg.value = true;
|
||||
@ -263,10 +262,11 @@ const getRecognize = async () => {
|
||||
const changeRadio = (val) =>{
|
||||
content.value = "请先上传文件...";
|
||||
fileText.value = "选择文件";
|
||||
files.value = {}
|
||||
files.value = {};
|
||||
alertText.value = '请先上传文件...';
|
||||
texts.value = []
|
||||
image.value = ''
|
||||
texts.value = [];
|
||||
image.value = '';
|
||||
fjmc.value = '';
|
||||
if(val == '图片解析'){
|
||||
if(!imgIsLoad) proxy.$message({ type: "error", message: "加载失败,请刷新页面" });
|
||||
}
|
||||
@ -276,10 +276,10 @@ const changeRadio = (val) =>{
|
||||
const onComfirm = () => {
|
||||
if(active.value == '文件解析'){
|
||||
if(content.value == '请先上传文件...') return proxy.$message({ type: "warning", message: "请解析文件" });
|
||||
emits("change", { text: content.value,fjdz:fjdz.value });
|
||||
emits("change", { text: content.value,fjdz:fjdz.value,fjmc:fjmc.value });
|
||||
}else{
|
||||
if(texts.value.length == 0) return proxy.$message({ type: "warning", message: "请解析文件" });
|
||||
emits("change", {text:texts.value.join(',\n'),fjdz:fjdz.value});
|
||||
emits("change", {text:texts.value.join(',\n'),fjdz:fjdz.value,fjmc:fjmc.value});
|
||||
}
|
||||
handleClose()
|
||||
};
|
||||
@ -303,7 +303,7 @@ const uploadFile = (file) =>{
|
||||
let token = localStorage.getItem('token');
|
||||
axios({
|
||||
method: 'post',
|
||||
url: '/mosty-api/mosty-base/minio/file/upload',
|
||||
url: '/mosty-api/mosty-base/minio/image/upload/id',
|
||||
data:formData,
|
||||
headers: { "Content-type": "multipart/form-data",'Authorization': token }
|
||||
}).then( (res) => {
|
||||
|
@ -107,11 +107,19 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isAll:{
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
});
|
||||
|
||||
const actionUrl = computed(() =>
|
||||
props.isImg ? "/mosty-api/mosty-base/minio/image/upload/id" : "/mosty-api/mosty-base/minio/file/upload"
|
||||
);
|
||||
const actionUrl = computed(() =>{
|
||||
if(props.isAll){
|
||||
return "/mosty-api/mosty-base/minio/image/upload/id"
|
||||
}else{
|
||||
return props.isImg ? "/mosty-api/mosty-base/minio/image/upload/id" : "/mosty-api/mosty-base/minio/file/upload"
|
||||
}
|
||||
});
|
||||
|
||||
const emits = defineEmits(["update:modelValue", "handleChange"]);
|
||||
|
||||
@ -179,11 +187,19 @@ watch(
|
||||
if (arr && arr.length > 0) {
|
||||
if (!props.sfUrl) {
|
||||
fileList.value = arr.map((el) => {
|
||||
return { url: `/mosty-api/mosty-base/minio/image/download/` + el,name:'生活时尚' };
|
||||
if(Object.prototype.toString.call(el) === '[object Object]'){
|
||||
return { url: `/mosty-api/mosty-base/minio/image/download/` + el,name:el.name };
|
||||
}else{
|
||||
return { url: `/mosty-api/mosty-base/minio/image/download/` + el };
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fileList.value = arr.map((el) => {
|
||||
return { url: el ,name:'生活时尚'};
|
||||
if(Object.prototype.toString.call(el) === '[object Object]'){
|
||||
return { url: el,name:el.name };
|
||||
}else{
|
||||
return { url: el };
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user