xydata-tools 1.1.23 → 1.1.24
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.
|
@@ -13,8 +13,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
13
13
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
14
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
15
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
-
import React, { useState } from
|
|
17
|
-
import { Button, ButtonProps } from
|
|
16
|
+
import React, { useState } from 'react';
|
|
17
|
+
import { Button, ButtonProps } from 'antd';
|
|
18
18
|
import DownloadFileTool from "../../utils/downloadFile";
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -36,7 +36,7 @@ import DownloadFileTool from "../../utils/downloadFile";
|
|
|
36
36
|
* @param {Object} [props.queryOption.customField] 自定义接口取值字段
|
|
37
37
|
* @param {string} [props.queryOption.customField.url] 自定义文件地址字段(表示取值res.data.[传入的参数])
|
|
38
38
|
* @param {string} [props.queryOption.customField.fileName] 自定义文件名字段(表示取值res.data.[传入的参数])
|
|
39
|
-
* @param {(error: Error) => void} [props.queryOption.onError] 接口异常回调函数
|
|
39
|
+
* @param {(error: Error) => void} [props.queryOption.onError] 接口异常回调函数
|
|
40
40
|
*/
|
|
41
41
|
var DownloadFile = function DownloadFile(props) {
|
|
42
42
|
var _useState = useState(false),
|
|
@@ -53,26 +53,39 @@ var DownloadFile = function DownloadFile(props) {
|
|
|
53
53
|
while (1) switch (_context.prev = _context.next) {
|
|
54
54
|
case 0:
|
|
55
55
|
if (!((_props$queryOption = props.queryOption) !== null && _props$queryOption !== void 0 && _props$queryOption.url)) {
|
|
56
|
-
_context.next =
|
|
56
|
+
_context.next = 16;
|
|
57
57
|
break;
|
|
58
58
|
}
|
|
59
59
|
setLoading(true);
|
|
60
60
|
mergedParams = props.queryOption.params || {};
|
|
61
|
-
if (typeof props.queryOption.onBeforeDownload ===
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
if (!(typeof props.queryOption.onBeforeDownload === 'function')) {
|
|
62
|
+
_context.next = 11;
|
|
63
|
+
break;
|
|
64
64
|
}
|
|
65
65
|
_context.next = 6;
|
|
66
|
+
return props.queryOption.onBeforeDownload(mergedParams);
|
|
67
|
+
case 6:
|
|
68
|
+
dynamicParams = _context.sent;
|
|
69
|
+
if (dynamicParams) {
|
|
70
|
+
_context.next = 10;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
setLoading(false);
|
|
74
|
+
return _context.abrupt("return");
|
|
75
|
+
case 10:
|
|
76
|
+
mergedParams = _objectSpread(_objectSpread({}, mergedParams), dynamicParams);
|
|
77
|
+
case 11:
|
|
78
|
+
_context.next = 13;
|
|
66
79
|
return DownloadFileTool(_objectSpread(_objectSpread({}, props.queryOption || {}), {}, {
|
|
67
80
|
params: mergedParams
|
|
68
81
|
}));
|
|
69
|
-
case
|
|
82
|
+
case 13:
|
|
70
83
|
setLoading(false);
|
|
71
|
-
_context.next =
|
|
84
|
+
_context.next = 17;
|
|
72
85
|
break;
|
|
73
|
-
case
|
|
74
|
-
console.error(
|
|
75
|
-
case
|
|
86
|
+
case 16:
|
|
87
|
+
console.error('请传入下载参数');
|
|
88
|
+
case 17:
|
|
76
89
|
case "end":
|
|
77
90
|
return _context.stop();
|
|
78
91
|
}
|
|
@@ -84,6 +97,6 @@ var DownloadFile = function DownloadFile(props) {
|
|
|
84
97
|
return onClick;
|
|
85
98
|
}()
|
|
86
99
|
}, props);
|
|
87
|
-
return /*#__PURE__*/React.createElement(Button, defaultProps, props.text
|
|
100
|
+
return /*#__PURE__*/React.createElement(Button, defaultProps, props.text ? props.text : props.icon ? null : '下载');
|
|
88
101
|
};
|
|
89
102
|
export default DownloadFile;
|
|
@@ -796,7 +796,6 @@ export default {
|
|
|
796
796
|
file,
|
|
797
797
|
name: 'file',
|
|
798
798
|
success: (uploadFileRes) => {
|
|
799
|
-
// 1. 先检查 HTTP 状态码
|
|
800
799
|
if (uploadFileRes.statusCode !== 200) {
|
|
801
800
|
console.error('HTTP状态码错误:', uploadFileRes.statusCode);
|
|
802
801
|
uni.showToast({ title: `服务器响应异常(${uploadFileRes.statusCode})`, icon: 'none' });
|
|
@@ -804,10 +803,8 @@ export default {
|
|
|
804
803
|
}
|
|
805
804
|
|
|
806
805
|
try {
|
|
807
|
-
// 2. 尝试解析 JSON
|
|
808
806
|
const result = JSON.parse(uploadFileRes.data);
|
|
809
807
|
|
|
810
|
-
// 3. 检查后端定义的业务 Code (假设 200 为成功)
|
|
811
808
|
if (result.rspCode === '000000') {
|
|
812
809
|
const fileInfo = {
|
|
813
810
|
fileName: result.data.fileName,
|