Commit f36021bd authored by zhengke's avatar zhengke

no message

parent c64ee919
......@@ -71,8 +71,8 @@
function RenewalImg() {
var str = '<div class="FillincommentsImgF">'
var center = ''
var end = `<div class="FillincommentsAdd" onclick="uploadFile">
<input type="file" accept="image/*" multiple style="opacity:0" id="upload"/>
var end = `<div class="FillincommentsAdd">
<input type="file" accept="image/*" multiple style="opacity:0" id="upload" onchange="uploadFile(event)"/>
</div>
</div>`
var textHtml = ''
......@@ -86,49 +86,43 @@
textHtml = str+center+end
$(`#FillincommentsImgF`).html(textHtml)
}
function uploadFile(){
// 获取文件输入元素
const fileInput = document.getElementById('upload');
// fileInput.click()
// 监听文件输入的变化
fileInput.addEventListener('change', function(e) {
for(let i=0;i<e.target.files.length;i++){
const file = e.target.files[i]; // 获取文件对象
const formData = new FormData(); // 创建FormData对象
formData.append('file', file); // 将文件添加到FormData对象中
// 1 文档 2 数据 3 图片
let typeArr = [{
stringArr: 'GIF|JPG|JPEG|PNG|BMP',
type: 3
},
{
stringArr: 'DOCX|DOC|XLSX|XLS|PPT|PPTX|PDF',
type: 1
},
]
let ft = file.name.substring(file.name.lastIndexOf('.') + 1, file.name.length).toUpperCase();
let fileTypeNumber = 2;
let typeOk = false;
typeArr.forEach(x => {
if (x.stringArr.indexOf(ft) != '-1') {
fileTypeNumber = x.type;
typeOk = true;
}
})
var path = '/Upload/car/'
let newArr = [];
newArr.push(file)
UploadSelfFile(path, newArr, x => {
importData.push({
Content: x.FilePath,
ID: 0,
Type: fileTypeNumber,
Url: getApiUrl().ViittoFileUrl + x.FilePath,
})
RenewalImg()
}, 1);
function uploadFile(e){
for(let i=0;i<e.target.files.length;i++){
const file = e.target.files[i]; // 获取文件对象
const formData = new FormData(); // 创建FormData对象
formData.append('file', file); // 将文件添加到FormData对象中
// 1 文档 2 数据 3 图片
let typeArr = [{
stringArr: 'GIF|JPG|JPEG|PNG|BMP',
type: 3
},
{
stringArr: 'DOCX|DOC|XLSX|XLS|PPT|PPTX|PDF',
type: 1
},
]
let ft = file.name.substring(file.name.lastIndexOf('.') + 1, file.name.length).toUpperCase();
let fileTypeNumber = 2;
let typeOk = false;
typeArr.forEach(x => {
if (x.stringArr.indexOf(ft) != '-1') {
fileTypeNumber = x.type;
typeOk = true;
}
});
})
var path = '/Upload/car/'
let newArr = [];
newArr.push(file)
UploadSelfFile(path, newArr, x => {
importData.push({
Content: x.FilePath,
ID: 0,
Type: fileTypeNumber,
Url: getApiUrl().ViittoFileUrl + x.FilePath,
})
RenewalImg()
}, 1);
}
}
function clickRadio(i) {
......@@ -354,7 +348,7 @@
var fileHtml = `<h4 class="uploadProof">上传凭证</h4>
<div class="FillincommentsImgF" id="FillincommentsImgF">
<div class="FillincommentsAdd">
<input type="file" accept="image/*" multiple style="opacity:0" id="upload" onclick="uploadFile()"/>
<input type="file" accept="image/*" multiple style="opacity:0" id="upload" onchange="uploadFile(event)"/>
</div>
</div>`
var list = []
......@@ -428,9 +422,9 @@
</div>`
}
var textHtml = str + mark + singleChoice + MultipleChoice + inputText + end
if(i==(dataList.length-1)){
textHtml+=fileHtml
}
// if(i==(dataList.length-1)){
// textHtml+=fileHtml
// }
element.innerHTML = textHtml
list.push(element)
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment