|
@@ -16,22 +16,37 @@ function exportSheetExcel(luckysheet, images, name = "file") { // 参数为lucky
|
|
|
const buffer = workbook.xlsx.writeBuffer()
|
|
|
// 5.保存为文件
|
|
|
buffer.then(function(buf) {
|
|
|
- // saveFile(buf, name);
|
|
|
- var formData = new FormData();
|
|
|
- formData.append("file", buf);
|
|
|
- $.ajax({
|
|
|
- url: 'http://192.168.0.11:8084/api/uploadExcel',
|
|
|
- type:'POST',
|
|
|
- data: formData,
|
|
|
- contentType: false,
|
|
|
- processData: false,
|
|
|
- success: (res) => {
|
|
|
- console.log(res);
|
|
|
- }
|
|
|
- })
|
|
|
+ saveFile(buf, name);
|
|
|
+ uploadExcel(buf,'http://192.168.0.11:8084/api/uploadExcel')
|
|
|
+
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function uploadExcel(buffer, url) {
|
|
|
+ const formData = new FormData();
|
|
|
+ const randomId = GetQueryString('randomid')
|
|
|
+ formData.append('file', new Blob([buffer], {
|
|
|
+ type: 'application/octet-stream'
|
|
|
+ }));
|
|
|
+ formData.append("randomId", randomId);
|
|
|
+ $.ajax({
|
|
|
+ url: url,
|
|
|
+ type: 'POST',
|
|
|
+ data: formData,
|
|
|
+ processData: false, // 告诉jQuery不要处理发送的数据
|
|
|
+ contentType: false, // 告诉jQuery不要设置Content-Type请求头
|
|
|
+ success: function(response) {
|
|
|
+ // 上传成功
|
|
|
+ console.log('上传成功');
|
|
|
+ },
|
|
|
+ error: function(xhr, status, error) {
|
|
|
+ // 上传失败
|
|
|
+ console.error('上传失败');
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+
|
|
|
function arrayBufferToBase64(array) {
|
|
|
array = new Uint8Array(array);
|
|
|
var length = array.byteLength;
|