ydb-components-material 0.1.147 → 0.1.149
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/docs/404.html +3 -3
- package/build/docs/_demos/:uuid +3 -3
- package/build/docs/colorful-button.html +3 -3
- package/build/docs/colorful-input.html +3 -3
- package/build/docs/index.html +3 -3
- package/build/docs/{umi.d9a95358.js → umi.40718ded.js} +1 -1
- package/build/docs/~demos/:uuid.html +3 -3
- package/build/docs/~demos/colorful-button-demo.html +3 -3
- package/build/docs/~demos/colorful-input-demo.html +3 -3
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +1 -1
- package/build/lowcode/view.js +1 -1
- package/dist/BizComps.js +1 -1
- package/dist/BizComps.js.map +1 -1
- package/es/components/file-list/item.js +77 -47
- package/es/components/file-list/merge.js +115 -34
- package/lib/components/file-list/item.js +77 -47
- package/lib/components/file-list/merge.js +116 -35
- package/lowcode_es/meta.js +1 -1
- package/lowcode_lib/meta.js +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _Dialog from "@alifd/next/es/dialog";
|
|
2
1
|
import _Message from "@alifd/next/es/message";
|
|
2
|
+
import _Dialog from "@alifd/next/es/dialog";
|
|
3
3
|
import _extends from "@babel/runtime/helpers/extends";
|
|
4
4
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
5
5
|
import _Radio from "@alifd/next/es/radio";
|
|
@@ -249,57 +249,87 @@ var FileItem = function FileItem(_ref) {
|
|
|
249
249
|
}();
|
|
250
250
|
var upload = function upload() {
|
|
251
251
|
if (disabled) return;
|
|
252
|
-
var
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
252
|
+
var ua = navigator.userAgent.toLowerCase();
|
|
253
|
+
var isAndroidWeChat = /android/.test(ua) && /micromessenger/.test(ua);
|
|
254
|
+
if (isAndroidWeChat) {
|
|
255
|
+
_Dialog.confirm({
|
|
256
|
+
title: '请选择',
|
|
257
|
+
content: '请选择文件上传方式',
|
|
258
|
+
footerAlign: 'center',
|
|
259
|
+
okProps: {
|
|
260
|
+
children: '拍照'
|
|
261
|
+
},
|
|
262
|
+
cancelProps: {
|
|
263
|
+
children: '选择文件'
|
|
264
|
+
},
|
|
265
|
+
onOk: function onOk() {
|
|
266
|
+
return doUpload(true);
|
|
267
|
+
},
|
|
268
|
+
onCancel: function onCancel() {
|
|
269
|
+
return doUpload(false);
|
|
270
|
+
},
|
|
271
|
+
onClose: function onClose() {}
|
|
272
|
+
});
|
|
273
|
+
} else {
|
|
274
|
+
doUpload(false);
|
|
275
|
+
}
|
|
276
|
+
function doUpload(isCamera) {
|
|
277
|
+
var inputEl = document.createElement('input');
|
|
278
|
+
inputEl.setAttribute('type', 'file');
|
|
279
|
+
if (isCamera) {
|
|
280
|
+
inputEl.setAttribute('accept', 'image/*');
|
|
281
|
+
inputEl.setAttribute('capture', 'camera');
|
|
264
282
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
283
|
+
inputEl.style.display = 'none';
|
|
284
|
+
document.body.appendChild(inputEl);
|
|
285
|
+
inputEl.addEventListener('change', function (e) {
|
|
286
|
+
console.log(e.target.files);
|
|
287
|
+
var fileData = e.target.files[0];
|
|
288
|
+
console.log('fileData----', fileData);
|
|
289
|
+
if (fileData.size > (maxFileSize || 50) * 1024 * 1024) {
|
|
290
|
+
_Message.notice("\u6587\u4EF6 \"" + fileData.name + "\" \u8D85\u8FC7" + maxFileSize + "MB\u9650\u5236");
|
|
269
291
|
return;
|
|
270
292
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
method: 'POST',
|
|
278
|
-
body: formData,
|
|
279
|
-
headers: {
|
|
280
|
-
Authorization: tokenTY || ''
|
|
281
|
-
}
|
|
282
|
-
}).then(function (response) {
|
|
283
|
-
return response.json();
|
|
284
|
-
}).then(function (res) {
|
|
285
|
-
document.body.removeChild(inputEl);
|
|
286
|
-
if (res.fileId) {
|
|
287
|
-
console.log('--------res', res);
|
|
288
|
-
valChange(_extends({}, res, {
|
|
289
|
-
fileName: fileData.name,
|
|
290
|
-
fileType: fileData.type
|
|
291
|
-
}), fileIndex, index, subIndex);
|
|
292
|
-
_Message.notice('上传成功');
|
|
293
|
-
} else {
|
|
294
|
-
_Message.error('上传失败,请重试');
|
|
293
|
+
if (spec) {
|
|
294
|
+
var type = getFileExtension(fileData.name);
|
|
295
|
+
if (!initFormat(spec).includes(type)) {
|
|
296
|
+
_Message.notice("\u6587\u4EF6 \"" + fileData.name + "\" \u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
295
299
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
300
|
+
var formData = new FormData();
|
|
301
|
+
formData.append('file', fileData);
|
|
302
|
+
formData.append('open', true);
|
|
303
|
+
openLoading();
|
|
304
|
+
fetch(baseUrl + "/declaration/material/file/files/api", {
|
|
305
|
+
method: 'POST',
|
|
306
|
+
body: formData,
|
|
307
|
+
headers: {
|
|
308
|
+
Authorization: tokenTY || ''
|
|
309
|
+
}
|
|
310
|
+
}).then(function (response) {
|
|
311
|
+
return response.json();
|
|
312
|
+
}).then(function (res) {
|
|
313
|
+
document.body.removeChild(inputEl);
|
|
314
|
+
if (res.fileId) {
|
|
315
|
+
console.log('--------res', res);
|
|
316
|
+
valChange(_extends({}, res, {
|
|
317
|
+
fileName: fileData.name,
|
|
318
|
+
fileType: fileData.type
|
|
319
|
+
}), fileIndex, index, subIndex);
|
|
320
|
+
_Message.notice('上传成功');
|
|
321
|
+
} else {
|
|
322
|
+
_Message.error('上传失败,请重试');
|
|
323
|
+
}
|
|
324
|
+
closeLoading();
|
|
325
|
+
})["catch"](function (err) {
|
|
326
|
+
console.error(err);
|
|
327
|
+
_Message.error('上传失败');
|
|
328
|
+
closeLoading();
|
|
329
|
+
});
|
|
301
330
|
});
|
|
302
|
-
|
|
331
|
+
inputEl.click();
|
|
332
|
+
}
|
|
303
333
|
};
|
|
304
334
|
|
|
305
335
|
// 预览材料
|
|
@@ -72,19 +72,97 @@ var Merge = function Merge(_ref) {
|
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
// File 文件转 Image 对象
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
75
|
+
// const getImageByFile = (file) => {
|
|
76
|
+
// return new Promise((resolve) => {
|
|
77
|
+
// const reader = new FileReader();
|
|
78
|
+
// reader.onload = (e) => {
|
|
79
|
+
// const img = new Image();
|
|
80
|
+
// img.src = e.target.result;
|
|
81
|
+
// img.onload = () => resolve(img);
|
|
82
|
+
// };
|
|
83
|
+
// reader.readAsDataURL(file);
|
|
84
|
+
// });
|
|
85
|
+
// };
|
|
86
|
+
var getImageByFile = /*#__PURE__*/function () {
|
|
87
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(file, maxSize) {
|
|
88
|
+
var bitmap, width, height, scale, newWidth, newHeight, canvas, ctx, dataUrl, img, _t;
|
|
89
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
90
|
+
while (1) switch (_context.prev = _context.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
if (maxSize === void 0) {
|
|
93
|
+
maxSize = 2000;
|
|
94
|
+
}
|
|
95
|
+
_context.prev = 1;
|
|
96
|
+
_context.next = 2;
|
|
97
|
+
return createImageBitmap(file, {
|
|
98
|
+
colorSpaceConversion: 'default'
|
|
99
|
+
});
|
|
100
|
+
case 2:
|
|
101
|
+
bitmap = _context.sent;
|
|
102
|
+
width = bitmap.width;
|
|
103
|
+
height = bitmap.height; // 如果图片太大,进行缩放(高清仪图片基本都会触发这里)
|
|
104
|
+
scale = 1;
|
|
105
|
+
if (width > maxSize || height > maxSize) {
|
|
106
|
+
scale = Math.min(maxSize / width, maxSize / height);
|
|
107
|
+
}
|
|
108
|
+
newWidth = Math.floor(width * scale);
|
|
109
|
+
newHeight = Math.floor(height * scale); // 绘制到 Canvas,此时像素已经被浏览器解码为纯 RGB 8-bit
|
|
110
|
+
canvas = document.createElement('canvas');
|
|
111
|
+
canvas.width = newWidth;
|
|
112
|
+
canvas.height = newHeight;
|
|
113
|
+
ctx = canvas.getContext('2d');
|
|
114
|
+
ctx.imageSmoothingEnabled = true;
|
|
115
|
+
ctx.imageSmoothingQuality = 'high';
|
|
116
|
+
ctx.drawImage(bitmap, 0, 0, newWidth, newHeight);
|
|
117
|
+
|
|
118
|
+
// 导出为普通的 JPEG(这一步会彻底丢掉原图的 ICC Profile)
|
|
119
|
+
dataUrl = canvas.toDataURL('image/jpeg', 0.92); // 转成 Image 对象以便兼容你原有代码逻辑
|
|
120
|
+
img = new Image();
|
|
121
|
+
img.src = dataUrl;
|
|
122
|
+
_context.next = 3;
|
|
123
|
+
return new Promise(function (resolve, reject) {
|
|
124
|
+
img.onload = resolve;
|
|
125
|
+
img.onerror = function () {
|
|
126
|
+
return reject(new Error('压缩后的 JPEG 加载失败'));
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
case 3:
|
|
130
|
+
// 释放内存
|
|
131
|
+
bitmap.close();
|
|
132
|
+
canvas.width = 0;
|
|
133
|
+
return _context.abrupt("return", img);
|
|
134
|
+
case 4:
|
|
135
|
+
_context.prev = 4;
|
|
136
|
+
_t = _context["catch"](1);
|
|
137
|
+
// 方案二(回退):如果 createImageBitmap 不支持或报错(极少见)
|
|
138
|
+
console.warn('createImageBitmap 失败,使用回退方案', _t);
|
|
139
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
140
|
+
var reader = new FileReader();
|
|
141
|
+
reader.onload = function (e) {
|
|
142
|
+
var img = new Image();
|
|
143
|
+
img.onload = function () {
|
|
144
|
+
return resolve(img);
|
|
145
|
+
};
|
|
146
|
+
img.onerror = function () {
|
|
147
|
+
return reject(new Error('回退方案加载失败'));
|
|
148
|
+
};
|
|
149
|
+
img.src = e.target.result;
|
|
150
|
+
};
|
|
151
|
+
reader.onerror = function () {
|
|
152
|
+
return reject(new Error('文件读取失败'));
|
|
153
|
+
};
|
|
154
|
+
reader.readAsDataURL(file);
|
|
155
|
+
}));
|
|
156
|
+
case 5:
|
|
157
|
+
case "end":
|
|
158
|
+
return _context.stop();
|
|
159
|
+
}
|
|
160
|
+
}, _callee, null, [[1, 4]]);
|
|
161
|
+
}));
|
|
162
|
+
return function getImageByFile(_x, _x2) {
|
|
163
|
+
return _ref2.apply(this, arguments);
|
|
164
|
+
};
|
|
165
|
+
}();
|
|
88
166
|
|
|
89
167
|
// 下载文件
|
|
90
168
|
var getBlob = function getBlob(url) {
|
|
@@ -108,43 +186,46 @@ var Merge = function Merge(_ref) {
|
|
|
108
186
|
|
|
109
187
|
// 核心:多张图片合并PDF
|
|
110
188
|
var imgsToPdf = /*#__PURE__*/function () {
|
|
111
|
-
var
|
|
189
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
112
190
|
var pdf, i, fileUrl, _blob, file, img, targetWidth, scale, targetHeight, pdfBlob, blobUrl;
|
|
113
|
-
return _regeneratorRuntime.wrap(function (
|
|
114
|
-
while (1) switch (
|
|
191
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
192
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
115
193
|
case 0:
|
|
116
194
|
// 初始化PDF,纵向、A4
|
|
117
195
|
pdf = new jsPDF({
|
|
118
196
|
orientation: 'portrait',
|
|
119
197
|
unit: 'px',
|
|
120
198
|
format: 'a4'
|
|
121
|
-
});
|
|
199
|
+
});
|
|
200
|
+
console.log('materialList---', materialList);
|
|
201
|
+
// 遍历所有图片
|
|
122
202
|
i = 0;
|
|
123
203
|
case 1:
|
|
124
204
|
if (!(i < materialList.length)) {
|
|
125
|
-
|
|
205
|
+
_context2.next = 5;
|
|
126
206
|
break;
|
|
127
207
|
}
|
|
128
208
|
fileUrl = materialList[i].fileUrl;
|
|
129
|
-
|
|
209
|
+
_context2.next = 2;
|
|
130
210
|
return getBlob(fileUrl);
|
|
131
211
|
case 2:
|
|
132
|
-
_blob =
|
|
133
|
-
console.log(_blob);
|
|
212
|
+
_blob = _context2.sent;
|
|
213
|
+
console.log('blob----', _blob);
|
|
134
214
|
file = new File([_blob], "img" + i, {
|
|
135
215
|
type: 'image/png'
|
|
136
216
|
});
|
|
137
217
|
console.log(file);
|
|
138
|
-
|
|
218
|
+
_context2.next = 3;
|
|
139
219
|
return getImageByFile(file);
|
|
140
220
|
case 3:
|
|
141
|
-
img =
|
|
221
|
+
img = _context2.sent;
|
|
142
222
|
// 3. 计算可用宽度(保留边距)
|
|
143
223
|
targetWidth = 400; // 4. 按比例计算高度
|
|
144
224
|
scale = targetWidth / img.width;
|
|
145
225
|
targetHeight = img.height * scale; // 第一张不加新页,后续图片新增一页
|
|
146
226
|
if (i > 0) pdf.addPage();
|
|
147
|
-
|
|
227
|
+
console.log('targetWidth', targetWidth);
|
|
228
|
+
console.log('targetHeight', targetHeight);
|
|
148
229
|
// 图片写入PDF
|
|
149
230
|
pdf.addImage(img, 'PNG',
|
|
150
231
|
// 格式 JPEG/PNG
|
|
@@ -154,7 +235,7 @@ var Merge = function Merge(_ref) {
|
|
|
154
235
|
targetWidth, targetHeight);
|
|
155
236
|
case 4:
|
|
156
237
|
i++;
|
|
157
|
-
|
|
238
|
+
_context2.next = 1;
|
|
158
239
|
break;
|
|
159
240
|
case 5:
|
|
160
241
|
// 1. 获取 Blob
|
|
@@ -166,19 +247,19 @@ var Merge = function Merge(_ref) {
|
|
|
166
247
|
setViewPdfUrl(blobUrl);
|
|
167
248
|
case 6:
|
|
168
249
|
case "end":
|
|
169
|
-
return
|
|
250
|
+
return _context2.stop();
|
|
170
251
|
}
|
|
171
|
-
},
|
|
252
|
+
}, _callee2);
|
|
172
253
|
}));
|
|
173
254
|
return function imgsToPdf() {
|
|
174
|
-
return
|
|
255
|
+
return _ref3.apply(this, arguments);
|
|
175
256
|
};
|
|
176
257
|
}();
|
|
177
258
|
var uploadPdf = /*#__PURE__*/function () {
|
|
178
|
-
var
|
|
259
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
179
260
|
var formData;
|
|
180
|
-
return _regeneratorRuntime.wrap(function (
|
|
181
|
-
while (1) switch (
|
|
261
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
262
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
182
263
|
case 0:
|
|
183
264
|
openLoading();
|
|
184
265
|
formData = new FormData();
|
|
@@ -201,12 +282,12 @@ var Merge = function Merge(_ref) {
|
|
|
201
282
|
});
|
|
202
283
|
case 1:
|
|
203
284
|
case "end":
|
|
204
|
-
return
|
|
285
|
+
return _context3.stop();
|
|
205
286
|
}
|
|
206
|
-
},
|
|
287
|
+
}, _callee3);
|
|
207
288
|
}));
|
|
208
289
|
return function uploadPdf() {
|
|
209
|
-
return
|
|
290
|
+
return _ref4.apply(this, arguments);
|
|
210
291
|
};
|
|
211
292
|
}();
|
|
212
293
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -4,8 +4,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports["default"] = void 0;
|
|
6
6
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
|
-
var _dialog = _interopRequireDefault(require("@alifd/next/lib/dialog"));
|
|
8
7
|
var _message = _interopRequireDefault(require("@alifd/next/lib/message"));
|
|
8
|
+
var _dialog = _interopRequireDefault(require("@alifd/next/lib/dialog"));
|
|
9
9
|
var _extends3 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
11
|
var _radio = _interopRequireDefault(require("@alifd/next/lib/radio"));
|
|
@@ -255,57 +255,87 @@ var FileItem = function FileItem(_ref) {
|
|
|
255
255
|
}();
|
|
256
256
|
var upload = function upload() {
|
|
257
257
|
if (disabled) return;
|
|
258
|
-
var
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
258
|
+
var ua = navigator.userAgent.toLowerCase();
|
|
259
|
+
var isAndroidWeChat = /android/.test(ua) && /micromessenger/.test(ua);
|
|
260
|
+
if (isAndroidWeChat) {
|
|
261
|
+
_dialog["default"].confirm({
|
|
262
|
+
title: '请选择',
|
|
263
|
+
content: '请选择文件上传方式',
|
|
264
|
+
footerAlign: 'center',
|
|
265
|
+
okProps: {
|
|
266
|
+
children: '拍照'
|
|
267
|
+
},
|
|
268
|
+
cancelProps: {
|
|
269
|
+
children: '选择文件'
|
|
270
|
+
},
|
|
271
|
+
onOk: function onOk() {
|
|
272
|
+
return doUpload(true);
|
|
273
|
+
},
|
|
274
|
+
onCancel: function onCancel() {
|
|
275
|
+
return doUpload(false);
|
|
276
|
+
},
|
|
277
|
+
onClose: function onClose() {}
|
|
278
|
+
});
|
|
279
|
+
} else {
|
|
280
|
+
doUpload(false);
|
|
281
|
+
}
|
|
282
|
+
function doUpload(isCamera) {
|
|
283
|
+
var inputEl = document.createElement('input');
|
|
284
|
+
inputEl.setAttribute('type', 'file');
|
|
285
|
+
if (isCamera) {
|
|
286
|
+
inputEl.setAttribute('accept', 'image/*');
|
|
287
|
+
inputEl.setAttribute('capture', 'camera');
|
|
270
288
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
289
|
+
inputEl.style.display = 'none';
|
|
290
|
+
document.body.appendChild(inputEl);
|
|
291
|
+
inputEl.addEventListener('change', function (e) {
|
|
292
|
+
console.log(e.target.files);
|
|
293
|
+
var fileData = e.target.files[0];
|
|
294
|
+
console.log('fileData----', fileData);
|
|
295
|
+
if (fileData.size > (maxFileSize || 50) * 1024 * 1024) {
|
|
296
|
+
_message["default"].notice("\u6587\u4EF6 \"" + fileData.name + "\" \u8D85\u8FC7" + maxFileSize + "MB\u9650\u5236");
|
|
275
297
|
return;
|
|
276
298
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
method: 'POST',
|
|
284
|
-
body: formData,
|
|
285
|
-
headers: {
|
|
286
|
-
Authorization: tokenTY || ''
|
|
287
|
-
}
|
|
288
|
-
}).then(function (response) {
|
|
289
|
-
return response.json();
|
|
290
|
-
}).then(function (res) {
|
|
291
|
-
document.body.removeChild(inputEl);
|
|
292
|
-
if (res.fileId) {
|
|
293
|
-
console.log('--------res', res);
|
|
294
|
-
valChange((0, _extends3["default"])({}, res, {
|
|
295
|
-
fileName: fileData.name,
|
|
296
|
-
fileType: fileData.type
|
|
297
|
-
}), fileIndex, index, subIndex);
|
|
298
|
-
_message["default"].notice('上传成功');
|
|
299
|
-
} else {
|
|
300
|
-
_message["default"].error('上传失败,请重试');
|
|
299
|
+
if (spec) {
|
|
300
|
+
var type = (0, _file2.getFileExtension)(fileData.name);
|
|
301
|
+
if (!(0, _file2.initFormat)(spec).includes(type)) {
|
|
302
|
+
_message["default"].notice("\u6587\u4EF6 \"" + fileData.name + "\" \u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
301
305
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
306
|
+
var formData = new FormData();
|
|
307
|
+
formData.append('file', fileData);
|
|
308
|
+
formData.append('open', true);
|
|
309
|
+
openLoading();
|
|
310
|
+
fetch(baseUrl + "/declaration/material/file/files/api", {
|
|
311
|
+
method: 'POST',
|
|
312
|
+
body: formData,
|
|
313
|
+
headers: {
|
|
314
|
+
Authorization: tokenTY || ''
|
|
315
|
+
}
|
|
316
|
+
}).then(function (response) {
|
|
317
|
+
return response.json();
|
|
318
|
+
}).then(function (res) {
|
|
319
|
+
document.body.removeChild(inputEl);
|
|
320
|
+
if (res.fileId) {
|
|
321
|
+
console.log('--------res', res);
|
|
322
|
+
valChange((0, _extends3["default"])({}, res, {
|
|
323
|
+
fileName: fileData.name,
|
|
324
|
+
fileType: fileData.type
|
|
325
|
+
}), fileIndex, index, subIndex);
|
|
326
|
+
_message["default"].notice('上传成功');
|
|
327
|
+
} else {
|
|
328
|
+
_message["default"].error('上传失败,请重试');
|
|
329
|
+
}
|
|
330
|
+
closeLoading();
|
|
331
|
+
})["catch"](function (err) {
|
|
332
|
+
console.error(err);
|
|
333
|
+
_message["default"].error('上传失败');
|
|
334
|
+
closeLoading();
|
|
335
|
+
});
|
|
307
336
|
});
|
|
308
|
-
|
|
337
|
+
inputEl.click();
|
|
338
|
+
}
|
|
309
339
|
};
|
|
310
340
|
|
|
311
341
|
// 预览材料
|