$(function () { autoFlashHeight(); handleFileList(fileList); $('#file-ok').click(function () { const files = Array.from($('#file-modal')[0].files) const valiData = files.map(v => { const ext = v.name.substring(v.name.lastIndexOf('.') + 1) return { size: v.size, ext } }); if (validateFiles(valiData)) { if (files.length) { const formData = new FormData(); files.forEach(file => { formData.append('name', file.name); formData.append('size', file.size); formData.append('file', file); }) postDataWithFile(preUrl + '/file/upload', formData, function (result) { handleFileList(result); $('#file-cancel').click(); }); } } }) function handleFileList(files = []) { $('#file-content').empty(); // const { uncheck, checkNo } = auditConst.status const newFiles = files.map(file => { let showDel = false; if (file.uid === cur_uid) { if (financialPay.status === auditConst.status.checked) { showDel = false } else { showDel = true } } return {...file, showDel} }) let html = financialPay.filePermission ? `
请选择退回流程
'); // } // return false; // } // if ($('#warning-text').length) $('#warning-text').remove() // } return true; } /** * 校验文件大小、格式 * @param {Array} files 文件数组 */ function validateFiles(files) { if (files.length > 10) { toastr.error('至多同时上传10个文件'); return false } return files.every(file => { if (file.size > 1024 * 1024 * 30) { toastr.error('文件大小限制为30MB'); return false } if (whiteList.indexOf('.' + file.ext.toLowerCase()) === -1) { toastr.error('请上传正确的格式文件'); return false } return true }) } const is_numeric = (value) => { if (typeof(value) === 'object') { return false; } else { return !Number.isNaN(Number(value)) && value.toString().trim() !== ''; } };