@vtx/components 4.0.0-beta.7 → 4.0.0-beta.71
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/README.md +19 -19
- package/es/index.js +3 -0
- package/es/utils/components/LabelIconTip/index.js +7 -7
- package/es/utils/conversionMomentValue/index.js +25 -25
- package/es/utils/filterSpecialCharacters.js +53 -52
- package/es/utils/genCopyable/index.js +6 -6
- package/es/utils/getFieldPropsOrFormItemProps/index.js +7 -7
- package/es/utils/hooks/useDebounceFn/index.js +4 -4
- package/es/utils/hooks/useDebounceValue/index.js +6 -6
- package/es/utils/hooks/useDeepCompareMemo/index.js +7 -7
- package/es/utils/hooks/useLatest/index.js +2 -2
- package/es/utils/hooks/useRefCallback/index.js +5 -5
- package/es/utils/index.js +1 -2
- package/es/utils/isBrowser/index.js +7 -7
- package/es/utils/isUrl/index.js +4 -4
- package/es/utils/merge/index.js +4 -4
- package/es/utils/nanoid/index.js +4 -4
- package/es/utils/omitBoolean/index.js +4 -4
- package/es/utils/parseValueToMoment/index.js +4 -4
- package/es/utils/proFieldParsingText/index.js +10 -10
- package/es/utils/transformKeySubmitValue/index.js +57 -57
- package/es/utils/useEditableArray/index.js +46 -46
- package/es/utils/useEditableMap/index.js +22 -22
- package/es/utils/useMediaQuery/index.js +5 -5
- package/es/vtx-color-picker/index.js +138 -33
- package/es/vtx-color-picker/style/index.js +36 -12
- package/es/vtx-combogrid/Combogrid.js +16 -10
- package/es/vtx-combogrid/index.js +7 -4
- package/es/vtx-combogrid/style/index.js +4 -4
- package/es/vtx-datagrid/Store/Provide.js +109 -132
- package/es/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +15 -9
- package/es/vtx-datagrid/ToolBar/components/ColumnSetting/style.js +5 -2
- package/es/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
- package/es/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
- package/es/vtx-datagrid/ToolBar/index.js +2 -2
- package/es/vtx-datagrid/columnState.js +64 -0
- package/es/vtx-datagrid/index.js +114 -35
- package/es/vtx-datagrid/mergeComponents.js +15 -0
- package/es/vtx-datagrid/renderColumnButtons.js +30 -11
- package/es/vtx-datagrid/style/index.js +102 -20
- package/es/vtx-datagrid/style/index.less +242 -242
- package/es/vtx-date-picker/QdatePicker.js +1 -1
- package/es/vtx-date-picker/style/index.less +39 -39
- package/es/vtx-descriptions/Descriptions.js +29 -0
- package/es/vtx-descriptions/index.js +3 -0
- package/es/vtx-descriptions/style/index.js +19 -0
- package/es/vtx-ellipsis-text/index.js +7 -2
- package/es/vtx-ellipsis-text/style/index.js +3 -1
- package/es/vtx-export/index.js +33 -33
- package/es/vtx-export-async/History.js +11 -3
- package/es/vtx-export-async/index.js +45 -15
- package/es/vtx-form-layout/Card.js +10 -10
- package/es/vtx-form-layout/Divider.js +1 -1
- package/es/vtx-form-layout/FormItem.js +18 -17
- package/es/vtx-form-layout/Pane.js +23 -12
- package/es/vtx-icon/index.js +54 -45
- package/es/vtx-icon/index.js1 +90 -0
- package/es/vtx-image/Preview.js +11 -6
- package/es/vtx-image/style/index.js +0 -1
- package/es/vtx-import/index.js +155 -43
- package/es/vtx-import/result.js +6 -2
- package/es/vtx-import/style/index.js +16 -1
- package/es/vtx-import2/Content.js +2 -1
- package/es/vtx-import2/index.js +31 -20
- package/es/vtx-import2/style/index.js +60 -9
- package/es/vtx-input/TextArea/index.js +11 -6
- package/es/vtx-modal/index.js +11 -6
- package/es/vtx-modal/style/index.js +5 -3
- package/es/vtx-page-layout/Basic.js +2 -2
- package/es/vtx-page-layout/Content.js +1 -1
- package/es/vtx-page-layout/TabLayout.js +7 -13
- package/es/vtx-page-layout/TableLayout.js +24 -14
- package/es/vtx-page-layout/TableWrap.js +3 -2
- package/es/vtx-page-layout/TreeLayout.js +8 -14
- package/es/vtx-page-layout/container.js +8 -7
- package/es/vtx-page-layout/style/index.js +4 -2
- package/es/vtx-provider/index.js +50 -40
- package/es/vtx-provider/intl.js +9 -9
- package/es/vtx-provider/locale/en_US.js +65 -5
- package/es/vtx-provider/locale/zh_CN.js +75 -5
- package/es/vtx-provider/useStyle/index.js +25 -21
- package/es/vtx-scrollable-row/index.js +38 -28
- package/es/vtx-search/index.js +18 -13
- package/es/vtx-search/style/index.js +2 -1
- package/es/vtx-select/index.js +132 -46
- package/es/vtx-select/style/index.js +11 -56
- package/es/vtx-signature/index.js +5 -4
- package/es/vtx-signature/style/index.js +1 -1
- package/es/vtx-split-pane/Resizer.js +0 -1
- package/es/vtx-split-pane/SplitPane.js +34 -25
- package/es/vtx-split-pane/style/index.js +8 -112
- package/es/vtx-time-picker/index.js +27 -1
- package/es/vtx-transfer/Transfer.js +29 -0
- package/es/vtx-transfer/index.js +3 -0
- package/es/vtx-transfer/style/index.js +19 -0
- package/es/vtx-transfer-select/TransferSelect.js +143 -0
- package/es/vtx-transfer-select/index.js +3 -0
- package/es/vtx-transfer-select/style/index.js +19 -0
- package/es/vtx-tree/index.js +104 -40
- package/es/vtx-tree-select/index.js +75 -105
- package/es/vtx-tree-select/style/index.js +9 -3
- package/es/vtx-upload/FilePreview.js +2 -1
- package/es/vtx-wang-editor/index.js +291 -113
- package/es/vtx-wang-editor/style/index.less +12 -12
- package/es/vtx-wang-editor/wangEditorUtil.js +59 -9
- package/lib/index.js +36 -0
- package/lib/utils/components/LabelIconTip/index.js +7 -7
- package/lib/utils/conversionMomentValue/index.js +25 -25
- package/lib/utils/filterSpecialCharacters.js +54 -52
- package/lib/utils/genCopyable/index.js +6 -6
- package/lib/utils/getFieldPropsOrFormItemProps/index.js +7 -7
- package/lib/utils/hooks/useDebounceFn/index.js +4 -4
- package/lib/utils/hooks/useDebounceValue/index.js +6 -6
- package/lib/utils/hooks/useDeepCompareMemo/index.js +7 -7
- package/lib/utils/hooks/useLatest/index.js +2 -2
- package/lib/utils/hooks/useRefCallback/index.js +5 -5
- package/lib/utils/index.js +0 -7
- package/lib/utils/isBrowser/index.js +7 -7
- package/lib/utils/isUrl/index.js +4 -4
- package/lib/utils/merge/index.js +4 -4
- package/lib/utils/nanoid/index.js +4 -4
- package/lib/utils/omitBoolean/index.js +4 -4
- package/lib/utils/parseValueToMoment/index.js +4 -4
- package/lib/utils/proFieldParsingText/index.js +10 -10
- package/lib/utils/transformKeySubmitValue/index.js +57 -57
- package/lib/utils/useEditableArray/index.js +46 -46
- package/lib/utils/useEditableMap/index.js +22 -22
- package/lib/utils/useMediaQuery/index.js +5 -5
- package/lib/vtx-color-picker/index.js +139 -34
- package/lib/vtx-color-picker/style/index.js +36 -12
- package/lib/vtx-combogrid/Combogrid.js +16 -10
- package/lib/vtx-combogrid/index.js +7 -4
- package/lib/vtx-combogrid/style/index.js +4 -4
- package/lib/vtx-datagrid/Store/Provide.js +116 -138
- package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +15 -10
- package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/style.js +5 -2
- package/lib/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
- package/lib/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
- package/lib/vtx-datagrid/ToolBar/index.js +2 -2
- package/lib/vtx-datagrid/columnState.js +73 -0
- package/lib/vtx-datagrid/index.js +115 -35
- package/lib/vtx-datagrid/mergeComponents.js +21 -0
- package/lib/vtx-datagrid/renderColumnButtons.js +30 -11
- package/lib/vtx-datagrid/style/index.js +102 -20
- package/lib/vtx-datagrid/style/index.less +242 -242
- package/lib/vtx-date-picker/QdatePicker.js +1 -1
- package/lib/vtx-date-picker/style/index.less +39 -39
- package/lib/vtx-descriptions/Descriptions.js +38 -0
- package/lib/vtx-descriptions/index.js +15 -0
- package/lib/vtx-descriptions/style/index.js +25 -0
- package/lib/vtx-ellipsis-text/index.js +7 -2
- package/lib/vtx-ellipsis-text/style/index.js +3 -1
- package/lib/vtx-export/index.js +34 -34
- package/lib/vtx-export-async/History.js +11 -3
- package/lib/vtx-export-async/index.js +43 -13
- package/lib/vtx-form-layout/Card.js +9 -9
- package/lib/vtx-form-layout/Divider.js +1 -1
- package/lib/vtx-form-layout/FormItem.js +18 -17
- package/lib/vtx-form-layout/Pane.js +22 -11
- package/lib/vtx-icon/index.js +54 -52
- package/lib/vtx-icon/index.js1 +90 -0
- package/lib/vtx-image/Preview.js +11 -6
- package/lib/vtx-image/style/index.js +0 -1
- package/lib/vtx-import/index.js +154 -42
- package/lib/vtx-import/result.js +6 -2
- package/lib/vtx-import/style/index.js +16 -1
- package/lib/vtx-import2/Content.js +2 -1
- package/lib/vtx-import2/index.js +30 -19
- package/lib/vtx-import2/style/index.js +60 -9
- package/lib/vtx-input/TextArea/index.js +11 -6
- package/lib/vtx-modal/index.js +11 -6
- package/lib/vtx-modal/style/index.js +5 -3
- package/lib/vtx-page-layout/Basic.js +2 -2
- package/lib/vtx-page-layout/Content.js +1 -1
- package/lib/vtx-page-layout/TabLayout.js +8 -14
- package/lib/vtx-page-layout/TableLayout.js +24 -14
- package/lib/vtx-page-layout/TableWrap.js +3 -2
- package/lib/vtx-page-layout/TreeLayout.js +9 -15
- package/lib/vtx-page-layout/container.js +8 -7
- package/lib/vtx-page-layout/style/index.js +4 -2
- package/lib/vtx-provider/index.js +49 -40
- package/lib/vtx-provider/intl.js +9 -9
- package/lib/vtx-provider/locale/en_US.js +65 -5
- package/lib/vtx-provider/locale/zh_CN.js +75 -5
- package/lib/vtx-provider/useStyle/index.js +25 -21
- package/lib/vtx-scrollable-row/index.js +38 -28
- package/lib/vtx-search/index.js +18 -13
- package/lib/vtx-search/style/index.js +2 -1
- package/lib/vtx-select/index.js +134 -48
- package/lib/vtx-select/style/index.js +11 -56
- package/lib/vtx-signature/index.js +4 -3
- package/lib/vtx-signature/style/index.js +1 -1
- package/lib/vtx-split-pane/Resizer.js +0 -1
- package/lib/vtx-split-pane/SplitPane.js +32 -23
- package/lib/vtx-split-pane/style/index.js +8 -112
- package/lib/vtx-time-picker/index.js +27 -1
- package/lib/vtx-transfer/Transfer.js +38 -0
- package/lib/vtx-transfer/index.js +15 -0
- package/lib/vtx-transfer/style/index.js +25 -0
- package/lib/vtx-transfer-select/TransferSelect.js +151 -0
- package/lib/vtx-transfer-select/index.js +15 -0
- package/lib/vtx-transfer-select/style/index.js +25 -0
- package/lib/vtx-tree/index.js +102 -38
- package/lib/vtx-tree-select/index.js +75 -105
- package/lib/vtx-tree-select/style/index.js +9 -3
- package/lib/vtx-upload/FilePreview.js +2 -1
- package/lib/vtx-wang-editor/index.js +289 -113
- package/lib/vtx-wang-editor/style/index.less +12 -12
- package/lib/vtx-wang-editor/wangEditorUtil.js +59 -10
- package/package.json +238 -222
- package/es/utils/hooks/useFetchData/index.js +0 -82
- package/lib/utils/hooks/useFetchData/index.js +0 -89
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { lazy, memo, Suspense, useMemo } from 'react';
|
|
2
|
+
import AlignRightOutlined from './svg/alignRightOutlined.js';
|
|
3
|
+
import ColumnHeightOutlined from './svg/columnHeightOutlined.js';
|
|
4
|
+
import DownOutlined from './svg/downOutlined.js';
|
|
5
|
+
import Fullscreen from './svg/fullscreen.js';
|
|
6
|
+
import RedoOutlined from './svg/redoOutlined.js';
|
|
7
|
+
import RightOutlined from './svg/rightOutlined.js';
|
|
8
|
+
import SettingOutlined from './svg/settingOutlined.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const iconComponents = {
|
|
12
|
+
alignRightOutlined: AlignRightOutlined,
|
|
13
|
+
columnHeightOutlined: ColumnHeightOutlined,
|
|
14
|
+
downOutlined: DownOutlined,
|
|
15
|
+
fullscreen: Fullscreen,
|
|
16
|
+
redoOutlined: RedoOutlined,
|
|
17
|
+
rightOutlined: RightOutlined,
|
|
18
|
+
settingOutlined: SettingOutlined,
|
|
19
|
+
// 低频图标如果确实需要,可以再考虑 lazy
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// const iconComponents = {
|
|
23
|
+
// // 核心:添加你需要的所有图标, 动态导入有的组件会失败
|
|
24
|
+
// alignRightOutlined: lazy(() => import('./svg/alignRightOutlined.js')),
|
|
25
|
+
// columnHeightOutlined: lazy(() => import('./svg/columnHeightOutlined.js')),
|
|
26
|
+
// downOutlined: lazy(() => import('./svg/downOutlined.js')),
|
|
27
|
+
// fullscreen: lazy(() => import('./svg/fullscreen.js')),
|
|
28
|
+
// redoOutlined: lazy(() => import('./svg/redoOutlined.js')),
|
|
29
|
+
// rightOutlined: lazy(() => import('./svg/rightOutlined.js')),
|
|
30
|
+
// settingOutlined: lazy(() => import('./svg/settingOutlined.js')),
|
|
31
|
+
// // 新增其他图标...
|
|
32
|
+
// };
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const VtxIcon = memo(({
|
|
36
|
+
type,
|
|
37
|
+
size = 16,
|
|
38
|
+
className = '',
|
|
39
|
+
style = {},
|
|
40
|
+
color,
|
|
41
|
+
fileType = 'webp',
|
|
42
|
+
...props
|
|
43
|
+
}) => {
|
|
44
|
+
const width = props.width || size;
|
|
45
|
+
const height = props.height || size;
|
|
46
|
+
if (!type) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
// const SvgComponent = useMemo(() => {
|
|
50
|
+
// // 动态导入并缓存结果
|
|
51
|
+
// return lazy(() => import(/* @vite-ignore */`./svg/${type}.js`));
|
|
52
|
+
// }, [type]);
|
|
53
|
+
|
|
54
|
+
const SvgComponent = useMemo(() => {
|
|
55
|
+
// 兜底:找不到对应图标时,返回一个空组件(避免报错)
|
|
56
|
+
return iconComponents[type] || lazy(() => Promise.resolve({ default: () => <svg width={width} height={height} /> }));
|
|
57
|
+
}, [type, width, height]);
|
|
58
|
+
|
|
59
|
+
// 默认返回空元素
|
|
60
|
+
if (fileType == 'svg') {
|
|
61
|
+
try {
|
|
62
|
+
// const SvgComponent = lazy(() => import(`./svg/${type}.js`));
|
|
63
|
+
return (
|
|
64
|
+
<Suspense fallback={<div style={{ width, height, ...style }} />}>
|
|
65
|
+
<SvgComponent
|
|
66
|
+
className={className}
|
|
67
|
+
style={{ width, height, ...style }}
|
|
68
|
+
fill={color}
|
|
69
|
+
{...props}
|
|
70
|
+
/>
|
|
71
|
+
</Suspense>
|
|
72
|
+
);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
// 如果动态导入失败,返回空的 SVG 元素
|
|
75
|
+
return (
|
|
76
|
+
<svg width={width} height={height} style={style} className={className} {...props} />
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
return (
|
|
81
|
+
// <img
|
|
82
|
+
// src={require(`./assets/${type}.${fileType}`)}
|
|
83
|
+
// style={{ width, height, ...style }}
|
|
84
|
+
// />
|
|
85
|
+
<></>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
export { VtxIcon }
|
|
90
|
+
export default VtxIcon;
|
package/es/vtx-image/Preview.js
CHANGED
|
@@ -22,15 +22,12 @@ var VIEWER = 'viewer';
|
|
|
22
22
|
// 多张
|
|
23
23
|
var GALLERY = 'gallery';
|
|
24
24
|
function checkMode(x) {
|
|
25
|
-
var mode = '';
|
|
26
|
-
if (isObject(x)) {
|
|
27
|
-
mode = VIEWER;
|
|
28
|
-
}
|
|
29
25
|
if (Array.isArray(x)) {
|
|
30
26
|
var len = x.length;
|
|
31
|
-
|
|
27
|
+
if (len === 0) return null;
|
|
28
|
+
return len === 1 ? VIEWER : GALLERY;
|
|
32
29
|
}
|
|
33
|
-
return
|
|
30
|
+
return isObject(x) ? VIEWER : null;
|
|
34
31
|
}
|
|
35
32
|
export default function Preview(props) {
|
|
36
33
|
var _useState = useState(),
|
|
@@ -87,6 +84,9 @@ export default function Preview(props) {
|
|
|
87
84
|
setContainer(container);
|
|
88
85
|
setViewer(viewer);
|
|
89
86
|
return function () {
|
|
87
|
+
if (container) {
|
|
88
|
+
container.innerHTML = '';
|
|
89
|
+
}
|
|
90
90
|
viewer && viewer.destroy();
|
|
91
91
|
};
|
|
92
92
|
}, []);
|
|
@@ -96,6 +96,7 @@ export default function Preview(props) {
|
|
|
96
96
|
container.innerHTML = '';
|
|
97
97
|
}
|
|
98
98
|
var mode = checkMode(photo);
|
|
99
|
+
if (!mode) return null;
|
|
99
100
|
var newIndex = index;
|
|
100
101
|
// 单张
|
|
101
102
|
if (mode === VIEWER) {
|
|
@@ -126,6 +127,10 @@ export default function Preview(props) {
|
|
|
126
127
|
}
|
|
127
128
|
viewer.update();
|
|
128
129
|
viewer.view(newIndex);
|
|
130
|
+
} else {
|
|
131
|
+
if (container) {
|
|
132
|
+
container.innerHTML = '';
|
|
133
|
+
}
|
|
129
134
|
}
|
|
130
135
|
}, [visible]);
|
|
131
136
|
return /*#__PURE__*/_jsx(_Fragment, {});
|
|
@@ -20,7 +20,6 @@ var center = function center() {
|
|
|
20
20
|
};
|
|
21
21
|
var genVtxImageStyle = function genVtxImageStyle(token) {
|
|
22
22
|
var componentCls = token.componentCls;
|
|
23
|
-
console.log('componentCls', componentCls);
|
|
24
23
|
return _defineProperty(_defineProperty(_defineProperty({}, componentCls, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, '&-aspectFit', {
|
|
25
24
|
position: 'relative',
|
|
26
25
|
height: '100%',
|
package/es/vtx-import/index.js
CHANGED
|
@@ -10,21 +10,25 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
10
10
|
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; }
|
|
11
11
|
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; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
function _readOnlyError(name) { throw new TypeError("\"" + name + "\" is read-only"); }
|
|
13
14
|
import React, { useRef, useEffect, useContext } from 'react';
|
|
14
|
-
import {
|
|
15
|
+
import { message, Button, Tooltip } from 'antd';
|
|
15
16
|
import PropTypes from 'prop-types';
|
|
16
17
|
import useSet from "../utils/useSet";
|
|
17
18
|
import VtxImportResult from "./result";
|
|
18
19
|
import getToken from "../utils/getToken";
|
|
19
|
-
var token = getToken();
|
|
20
20
|
import md5 from 'md5';
|
|
21
21
|
import { getVtxToken, getSignature } from '@vtx/utils';
|
|
22
|
-
import classnames from 'classnames';
|
|
23
22
|
import { useStyle } from "./style/index";
|
|
24
23
|
import { VtxProvider, useIntl } from "../vtx-provider";
|
|
24
|
+
import VtxModal from "../vtx-modal";
|
|
25
25
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
26
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
27
|
function VtxImport(props) {
|
|
28
|
+
var token = getToken();
|
|
29
|
+
if (props.token) {
|
|
30
|
+
props.token, _readOnlyError("token");
|
|
31
|
+
}
|
|
28
32
|
var intl = useIntl();
|
|
29
33
|
var _useContext = useContext(VtxProvider),
|
|
30
34
|
getPrefixCls = _useContext.getPrefixCls;
|
|
@@ -32,14 +36,19 @@ function VtxImport(props) {
|
|
|
32
36
|
var _useStyle = useStyle(prefixCls),
|
|
33
37
|
wrapSSR = _useStyle.wrapSSR,
|
|
34
38
|
hashId = _useStyle.hashId;
|
|
39
|
+
|
|
40
|
+
// 用 useRef 管理 DOM 引用,而不是 state
|
|
41
|
+
var fileInputRef = useRef(null);
|
|
42
|
+
var iframeRef = useRef(null);
|
|
43
|
+
var formRef = useRef(null);
|
|
44
|
+
|
|
45
|
+
// 用于追踪当前 XHR 请求,方便取消
|
|
46
|
+
var xhrRef = useRef(null);
|
|
35
47
|
var indexRef = useRef(0);
|
|
36
48
|
var _useSet = useSet({
|
|
37
|
-
fileForm: null,
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
// 保存上传的文件
|
|
41
|
-
iframe: null,
|
|
42
|
-
// form表单提交之后跳转的
|
|
49
|
+
// fileForm: null, // form表单
|
|
50
|
+
// fileInput: null, // 保存上传的文件
|
|
51
|
+
// iframe: null, // form表单提交之后跳转的
|
|
43
52
|
useFormData: window.FormData ? true : false,
|
|
44
53
|
// 是否查看
|
|
45
54
|
uploading: false,
|
|
@@ -67,7 +76,8 @@ function VtxImport(props) {
|
|
|
67
76
|
currentIndex: 0,
|
|
68
77
|
chunkId: '',
|
|
69
78
|
chunks: [],
|
|
70
|
-
operation: props.operation || intl.getMessage('import.operation', '导入')
|
|
79
|
+
operation: props.operation || intl.getMessage('import.operation', '导入'),
|
|
80
|
+
fileName: ''
|
|
71
81
|
}),
|
|
72
82
|
_useSet2 = _slicedToArray(_useSet, 2),
|
|
73
83
|
state = _useSet2[0],
|
|
@@ -102,7 +112,7 @@ function VtxImport(props) {
|
|
|
102
112
|
data.append('chunkNo', i + 1);
|
|
103
113
|
data.append('chunkId', state.chunkId);
|
|
104
114
|
data.append('tenantId', getVtxToken('tenantId'));
|
|
105
|
-
data.append('file', new File([e],
|
|
115
|
+
data.append('file', new File([e], fileInputRef.current.files[0].name));
|
|
106
116
|
dataArr.push(data);
|
|
107
117
|
});
|
|
108
118
|
uploadAsync(dataArr);
|
|
@@ -112,6 +122,7 @@ function VtxImport(props) {
|
|
|
112
122
|
function uploadAsync(list) {
|
|
113
123
|
if (indexRef.current < list.length) {
|
|
114
124
|
var xhr = new XMLHttpRequest();
|
|
125
|
+
xhrRef.current = xhr;
|
|
115
126
|
xhr.onload = function () {
|
|
116
127
|
if (xhr.status === 200) {
|
|
117
128
|
setState({
|
|
@@ -135,15 +146,27 @@ function VtxImport(props) {
|
|
|
135
146
|
// 合并分片
|
|
136
147
|
function mergeFile() {
|
|
137
148
|
var xhr = new XMLHttpRequest();
|
|
149
|
+
xhrRef.current = xhr;
|
|
138
150
|
// 当上传完成时调用
|
|
139
151
|
xhr.onload = function () {
|
|
140
152
|
if (xhr.status === 200) {
|
|
141
|
-
var
|
|
142
|
-
|
|
153
|
+
var _res;
|
|
154
|
+
var res;
|
|
155
|
+
try {
|
|
156
|
+
res = JSON.parse(xhr.responseText);
|
|
157
|
+
} catch (e) {
|
|
158
|
+
message.error(intl.getMessage('import.error', '解析响应失败'));
|
|
159
|
+
setState({
|
|
160
|
+
uploading: false
|
|
161
|
+
});
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (((_res = res) === null || _res === void 0 ? void 0 : _res.result) == 0) {
|
|
143
165
|
message.success(intl.getMessage('import.success', '上传成功'));
|
|
144
166
|
chunkUpload(res.data);
|
|
145
167
|
} else {
|
|
146
|
-
|
|
168
|
+
var _res2;
|
|
169
|
+
message.error(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.msg) || intl.getMessage('import.error', '上传失败'));
|
|
147
170
|
}
|
|
148
171
|
}
|
|
149
172
|
};
|
|
@@ -152,11 +175,13 @@ function VtxImport(props) {
|
|
|
152
175
|
};
|
|
153
176
|
// 发送请求
|
|
154
177
|
xhr.open('POST', '/cloudFile/common/mergeChunk', true);
|
|
178
|
+
xhr.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
|
|
179
|
+
xhr.setRequestHeader('access_token', token ? "".concat(token) : '');
|
|
155
180
|
var data = new FormData();
|
|
156
181
|
data.append('chunkId', state.chunkId);
|
|
157
182
|
data.append('tenantId', getVtxToken('tenantId'));
|
|
158
183
|
data.append('chunkSize', state.chunks.length);
|
|
159
|
-
data.append('fileName',
|
|
184
|
+
data.append('fileName', fileInputRef.current.files[0].name);
|
|
160
185
|
xhr.send(data);
|
|
161
186
|
}
|
|
162
187
|
|
|
@@ -166,6 +191,7 @@ function VtxImport(props) {
|
|
|
166
191
|
var postData = props.postData || {};
|
|
167
192
|
if (state.useFormData) {
|
|
168
193
|
var request = new XMLHttpRequest();
|
|
194
|
+
xhrRef.current = request;
|
|
169
195
|
// 发送请求
|
|
170
196
|
request.open('POST', postUrl);
|
|
171
197
|
request.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
|
|
@@ -196,6 +222,7 @@ function VtxImport(props) {
|
|
|
196
222
|
var postData = props.postData || {};
|
|
197
223
|
if (state.useFormData) {
|
|
198
224
|
var request = new XMLHttpRequest();
|
|
225
|
+
xhrRef.current = request;
|
|
199
226
|
// 发送请求
|
|
200
227
|
request.open('POST', postUrl);
|
|
201
228
|
request.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
|
|
@@ -216,7 +243,7 @@ function VtxImport(props) {
|
|
|
216
243
|
};
|
|
217
244
|
//创建formdata对象
|
|
218
245
|
var fmd = new FormData();
|
|
219
|
-
fmd.append(state.fileKey,
|
|
246
|
+
fmd.append(state.fileKey, fileInputRef.current.files[0]);
|
|
220
247
|
request.send(fmd);
|
|
221
248
|
}
|
|
222
249
|
}
|
|
@@ -247,7 +274,9 @@ function VtxImport(props) {
|
|
|
247
274
|
return postArray.length > 0 ? "".concat(postUrl, "?").concat(postArray.join('&')) : postUrl;
|
|
248
275
|
};
|
|
249
276
|
var closeModal = function closeModal() {
|
|
250
|
-
|
|
277
|
+
if (fileInputRef.current) {
|
|
278
|
+
fileInputRef.current.value = '';
|
|
279
|
+
}
|
|
251
280
|
if (typeof props.close === 'function') {
|
|
252
281
|
props.close();
|
|
253
282
|
} else {
|
|
@@ -258,15 +287,24 @@ function VtxImport(props) {
|
|
|
258
287
|
};
|
|
259
288
|
// 上传之后的回调 - 展示报错信息
|
|
260
289
|
var uploadSuccess = function uploadSuccess(data) {
|
|
261
|
-
|
|
290
|
+
var _parseData;
|
|
291
|
+
if (fileInputRef.current) {
|
|
292
|
+
fileInputRef.current.value = '';
|
|
293
|
+
}
|
|
262
294
|
setState({
|
|
263
295
|
uploading: false
|
|
264
296
|
});
|
|
297
|
+
var parseData;
|
|
298
|
+
try {
|
|
299
|
+
parseData = JSON.parse(data);
|
|
300
|
+
} catch (e) {
|
|
301
|
+
message.error(intl.getMessage('import.error', '解析响应数据失败'));
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
265
304
|
if (typeof props.afterUpload === 'function') {
|
|
266
305
|
afterUpload(data);
|
|
267
306
|
}
|
|
268
|
-
|
|
269
|
-
if (Array.isArray(parseData === null || parseData === void 0 ? void 0 : parseData.data)) {
|
|
307
|
+
if (Array.isArray((_parseData = parseData) === null || _parseData === void 0 ? void 0 : _parseData.data)) {
|
|
270
308
|
setState({
|
|
271
309
|
resultVisible: true,
|
|
272
310
|
resultData: parseData.data.map(function (item, index) {
|
|
@@ -281,7 +319,8 @@ function VtxImport(props) {
|
|
|
281
319
|
} else {
|
|
282
320
|
// 新增其他错误提示
|
|
283
321
|
if (parseData.result !== 0) {
|
|
284
|
-
|
|
322
|
+
var _parseData2;
|
|
323
|
+
message.error(((_parseData2 = parseData) === null || _parseData2 === void 0 ? void 0 : _parseData2.msg) || intl.getMessage('import.success', '上传成功'));
|
|
285
324
|
}
|
|
286
325
|
}
|
|
287
326
|
};
|
|
@@ -296,7 +335,10 @@ function VtxImport(props) {
|
|
|
296
335
|
onCancel: function onCancel() {
|
|
297
336
|
return closeModal();
|
|
298
337
|
},
|
|
299
|
-
maskClosable: false,
|
|
338
|
+
// maskClosable: false,
|
|
339
|
+
mask: {
|
|
340
|
+
closable: false
|
|
341
|
+
},
|
|
300
342
|
footer: [templateURL ? /*#__PURE__*/_jsx(Button, {
|
|
301
343
|
onClick: function onClick() {
|
|
302
344
|
window.open(templateURL);
|
|
@@ -306,22 +348,21 @@ function VtxImport(props) {
|
|
|
306
348
|
type: "primary",
|
|
307
349
|
loading: state.uploading,
|
|
308
350
|
onClick: function onClick() {
|
|
351
|
+
var _fileInputRef$current2;
|
|
309
352
|
if (typeof props.beforeUpload === 'function') {
|
|
310
|
-
var
|
|
353
|
+
var _fileInputRef$current;
|
|
354
|
+
var flag = beforeUpload((_fileInputRef$current = fileInputRef.current) === null || _fileInputRef$current === void 0 || (_fileInputRef$current = _fileInputRef$current.files) === null || _fileInputRef$current === void 0 ? void 0 : _fileInputRef$current[0]);
|
|
311
355
|
if (!flag) {
|
|
312
|
-
|
|
313
|
-
setState({
|
|
314
|
-
fileInput: null
|
|
315
|
-
});
|
|
356
|
+
fileInputRef.current.value = '';
|
|
316
357
|
return;
|
|
317
358
|
}
|
|
318
359
|
}
|
|
319
|
-
if (
|
|
360
|
+
if ((_fileInputRef$current2 = fileInputRef.current) !== null && _fileInputRef$current2 !== void 0 && _fileInputRef$current2.value) {
|
|
320
361
|
setState({
|
|
321
362
|
uploading: true
|
|
322
363
|
});
|
|
323
364
|
// 上传文件
|
|
324
|
-
checkFile(
|
|
365
|
+
checkFile(fileInputRef.current.files[0]);
|
|
325
366
|
// const postUrl = getPostURL();
|
|
326
367
|
// if (state.useFormData) {
|
|
327
368
|
// const request = new XMLHttpRequest();
|
|
@@ -350,7 +391,8 @@ function VtxImport(props) {
|
|
|
350
391
|
closeModal();
|
|
351
392
|
},
|
|
352
393
|
children: intl.getMessage('switch.close', '关闭')
|
|
353
|
-
}, "closeWindow")]
|
|
394
|
+
}, "closeWindow")],
|
|
395
|
+
width: 520
|
|
354
396
|
};
|
|
355
397
|
var resultProps = {
|
|
356
398
|
visible: state.resultVisible,
|
|
@@ -363,36 +405,106 @@ function VtxImport(props) {
|
|
|
363
405
|
},
|
|
364
406
|
modalWidth: state.modalWidth
|
|
365
407
|
};
|
|
408
|
+
|
|
409
|
+
// 组件卸载时清理
|
|
410
|
+
useEffect(function () {
|
|
411
|
+
return function () {
|
|
412
|
+
// 取消进行中的 XHR 请求
|
|
413
|
+
if (xhrRef.current) {
|
|
414
|
+
xhrRef.current.abort();
|
|
415
|
+
xhrRef.current = null;
|
|
416
|
+
}
|
|
417
|
+
// 清理文件输入
|
|
418
|
+
if (fileInputRef.current) {
|
|
419
|
+
fileInputRef.current.value = '';
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
}, []);
|
|
366
423
|
useEffect(function () {
|
|
367
424
|
if (state.chunkId) {
|
|
368
425
|
startUpload();
|
|
369
426
|
}
|
|
370
427
|
}, [state.chunkId]);
|
|
371
|
-
|
|
372
|
-
|
|
428
|
+
var truncateFileName = function truncateFileName(fileName) {
|
|
429
|
+
var maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 28;
|
|
430
|
+
if (fileName.length <= maxLength) return fileName;
|
|
431
|
+
var extIndex = fileName.lastIndexOf('.');
|
|
432
|
+
var ext = extIndex !== -1 ? fileName.slice(extIndex) : '';
|
|
433
|
+
var name = extIndex !== -1 ? fileName.slice(0, extIndex) : fileName;
|
|
434
|
+
var availableLength = maxLength - ext.length - 3; // 3 是 "..."
|
|
435
|
+
if (availableLength <= 0) return "...".concat(ext);
|
|
436
|
+
var startLength = Math.ceil(availableLength / 2);
|
|
437
|
+
var endLength = Math.floor(availableLength / 2);
|
|
438
|
+
var start = name.slice(0, startLength);
|
|
439
|
+
var end = name.slice(-endLength);
|
|
440
|
+
return "".concat(start, "...").concat(end).concat(ext);
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
// 处理文件选择变化
|
|
444
|
+
var handleFileChange = function handleFileChange(event) {
|
|
445
|
+
var _event$target$files;
|
|
446
|
+
var file = (_event$target$files = event.target.files) === null || _event$target$files === void 0 ? void 0 : _event$target$files[0];
|
|
447
|
+
if (file) {
|
|
448
|
+
setState(function (prev) {
|
|
449
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
450
|
+
fileName: truncateFileName(file.name)
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
// 这里可以添加文件上传或其他处理逻辑
|
|
454
|
+
// 例如:uploadFile(file);
|
|
455
|
+
} else {
|
|
456
|
+
setState(function (prev) {
|
|
457
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
458
|
+
fileName: ''
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
var handleSelectFile = function handleSelectFile() {
|
|
464
|
+
var _fileInputRef$current3;
|
|
465
|
+
(_fileInputRef$current3 = fileInputRef.current) === null || _fileInputRef$current3 === void 0 || _fileInputRef$current3.click();
|
|
466
|
+
};
|
|
467
|
+
return wrapSSR( /*#__PURE__*/_jsxs(VtxModal, _objectSpread(_objectSpread({}, modalProps), {}, {
|
|
468
|
+
children: [props.children, /*#__PURE__*/_jsxs("form", {
|
|
373
469
|
encType: "multipart/form-data",
|
|
374
470
|
method: "post",
|
|
375
471
|
target: "tmp",
|
|
376
472
|
action: uploadURL,
|
|
377
|
-
ref:
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
473
|
+
ref: formRef,
|
|
474
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
475
|
+
className: "".concat(prefixCls, "-btn"),
|
|
476
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
477
|
+
onClick: handleSelectFile,
|
|
478
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
479
|
+
className: "".concat(prefixCls, "-label"),
|
|
480
|
+
children: intl.getMessage('import.selectFile', '选择文件')
|
|
481
|
+
})
|
|
482
|
+
}), state.fileName ? /*#__PURE__*/_jsx(Tooltip, {
|
|
483
|
+
title: state.fileName,
|
|
484
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
485
|
+
className: "".concat(prefixCls, "-file-name"),
|
|
486
|
+
children: state.fileName
|
|
487
|
+
})
|
|
488
|
+
}) : /*#__PURE__*/_jsx("div", {
|
|
489
|
+
className: "".concat(prefixCls, "-file-name"),
|
|
490
|
+
children: intl.getMessage('import.noFileSelected', '未选择任何文件')
|
|
491
|
+
})]
|
|
492
|
+
}), /*#__PURE__*/_jsx("input", {
|
|
381
493
|
type: "file",
|
|
382
494
|
name: state.fileKey,
|
|
383
495
|
accept: state.accept,
|
|
384
|
-
ref:
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
496
|
+
ref: fileInputRef,
|
|
497
|
+
style: {
|
|
498
|
+
display: 'none'
|
|
499
|
+
},
|
|
500
|
+
onChange: handleFileChange
|
|
501
|
+
})]
|
|
388
502
|
}), /*#__PURE__*/_jsx("iframe", {
|
|
389
503
|
name: "tmp",
|
|
390
504
|
style: {
|
|
391
505
|
display: 'none'
|
|
392
506
|
},
|
|
393
|
-
ref:
|
|
394
|
-
if (dom) state.iframe = dom;
|
|
395
|
-
}
|
|
507
|
+
ref: iframeRef
|
|
396
508
|
}), state.resultVisible && /*#__PURE__*/_jsx(VtxImportResult, _objectSpread({}, resultProps))]
|
|
397
509
|
})));
|
|
398
510
|
}
|
package/es/vtx-import/result.js
CHANGED
|
@@ -16,6 +16,7 @@ import PropTypes from 'prop-types';
|
|
|
16
16
|
import useSet from "../utils/useSet";
|
|
17
17
|
import VtxDatagrid from "../vtx-datagrid";
|
|
18
18
|
import { useIntl } from "../vtx-provider";
|
|
19
|
+
import VtxModal from "../vtx-modal";
|
|
19
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
21
|
function VtxImportResult(props) {
|
|
21
22
|
var intl = useIntl();
|
|
@@ -39,7 +40,10 @@ function VtxImportResult(props) {
|
|
|
39
40
|
}
|
|
40
41
|
},
|
|
41
42
|
width: state.modalWidth,
|
|
42
|
-
maskClosable: false,
|
|
43
|
+
// maskClosable: false,
|
|
44
|
+
mask: {
|
|
45
|
+
closable: false
|
|
46
|
+
},
|
|
43
47
|
footer: [/*#__PURE__*/_jsx(Button, {
|
|
44
48
|
onClick: function onClick() {
|
|
45
49
|
if (typeof props.hideVisible === 'function') {
|
|
@@ -58,7 +62,7 @@ function VtxImportResult(props) {
|
|
|
58
62
|
pagination: false,
|
|
59
63
|
autoFit: false
|
|
60
64
|
};
|
|
61
|
-
return /*#__PURE__*/_jsx(
|
|
65
|
+
return /*#__PURE__*/_jsx(VtxModal, _objectSpread(_objectSpread({}, modalProps), {}, {
|
|
62
66
|
children: /*#__PURE__*/_jsx("div", {
|
|
63
67
|
style: {
|
|
64
68
|
maxHeight: 600,
|
|
@@ -7,7 +7,22 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
7
7
|
import { useStyle as useAntdStyle } from "../../vtx-provider";
|
|
8
8
|
var genVtxImportStyle = function genVtxImportStyle(token) {
|
|
9
9
|
var componentCls = token.componentCls;
|
|
10
|
-
return _defineProperty({}, componentCls, {
|
|
10
|
+
return _defineProperty({}, componentCls, _defineProperty({
|
|
11
|
+
'.ant-modal-container': {
|
|
12
|
+
padding: 0,
|
|
13
|
+
'.ant-modal-header': {
|
|
14
|
+
padding: 20
|
|
15
|
+
},
|
|
16
|
+
'.ant-modal-body': {
|
|
17
|
+
padding: 20
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}, '&-btn', {
|
|
21
|
+
display: 'flex',
|
|
22
|
+
justifyContent: 'flex-start',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
gap: 8
|
|
25
|
+
}));
|
|
11
26
|
};
|
|
12
27
|
export function useStyle(prefixCls) {
|
|
13
28
|
return useAntdStyle('VtxImport', function (token) {
|
|
@@ -98,6 +98,7 @@ Content.propTypes = {
|
|
|
98
98
|
customText: PropTypes.string,
|
|
99
99
|
extraText: PropTypes.string,
|
|
100
100
|
TextEnum: PropTypes.object,
|
|
101
|
-
extraDom: [PropTypes.string, PropTypes.node]
|
|
101
|
+
// extraDom: [PropTypes.string, PropTypes.node],
|
|
102
|
+
extraDom: PropTypes.object
|
|
102
103
|
};
|
|
103
104
|
export default Content;
|