@vtx/components 4.0.0-beta.7 → 4.0.0-beta.9
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/es/utils/filterSpecialCharacters.js +47 -46
- 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 +11 -6
- package/es/vtx-combogrid/style/index.js +4 -4
- package/es/vtx-datagrid/Store/Provide.js +5 -4
- package/es/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +8 -3
- 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/index.js +14 -9
- package/es/vtx-datagrid/style/index.js +2 -2
- package/es/vtx-ellipsis-text/index.js +6 -1
- package/es/vtx-export/index.js +5 -0
- package/es/vtx-export-async/index.js +28 -8
- 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 +2 -1
- package/es/vtx-form-layout/Pane.js +23 -12
- package/es/vtx-image/Preview.js +11 -6
- package/es/vtx-import/index.js +73 -33
- package/es/vtx-import2/index.js +2 -1
- package/es/vtx-import2/style/index.js +1 -1
- package/es/vtx-input/TextArea/index.js +11 -6
- package/es/vtx-modal/style/index.js +5 -3
- package/es/vtx-page-layout/Content.js +1 -1
- package/es/vtx-page-layout/TabLayout.js +1 -7
- package/es/vtx-page-layout/TableLayout.js +14 -4
- package/es/vtx-page-layout/TableWrap.js +3 -2
- package/es/vtx-page-layout/TreeLayout.js +2 -8
- package/es/vtx-page-layout/container.js +6 -5
- package/es/vtx-provider/index.js +18 -10
- package/es/vtx-provider/locale/en_US.js +10 -2
- package/es/vtx-provider/locale/zh_CN.js +20 -2
- package/es/vtx-provider/useStyle/index.js +8 -4
- package/es/vtx-scrollable-row/index.js +38 -28
- package/es/vtx-search/index.js +5 -4
- package/es/vtx-search/style/index.js +2 -1
- package/es/vtx-select/index.js +25 -11
- package/es/vtx-signature/index.js +5 -4
- package/es/vtx-signature/style/index.js +1 -1
- package/es/vtx-tree/index.js +80 -34
- package/es/vtx-tree-select/index.js +4 -0
- package/es/vtx-wang-editor/index.js +278 -108
- package/es/vtx-wang-editor/wangEditorUtil.js +59 -9
- package/lib/utils/filterSpecialCharacters.js +48 -46
- 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 +11 -6
- package/lib/vtx-combogrid/style/index.js +4 -4
- package/lib/vtx-datagrid/Store/Provide.js +5 -4
- package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +8 -4
- 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/index.js +15 -9
- package/lib/vtx-datagrid/style/index.js +2 -2
- package/lib/vtx-ellipsis-text/index.js +6 -1
- package/lib/vtx-export/index.js +5 -0
- package/lib/vtx-export-async/index.js +26 -6
- 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 +2 -1
- package/lib/vtx-form-layout/Pane.js +22 -11
- package/lib/vtx-image/Preview.js +11 -6
- package/lib/vtx-import/index.js +73 -33
- package/lib/vtx-import2/index.js +2 -1
- package/lib/vtx-import2/style/index.js +1 -1
- package/lib/vtx-input/TextArea/index.js +11 -6
- package/lib/vtx-modal/style/index.js +5 -3
- package/lib/vtx-page-layout/Content.js +1 -1
- package/lib/vtx-page-layout/TabLayout.js +3 -9
- package/lib/vtx-page-layout/TableLayout.js +14 -4
- package/lib/vtx-page-layout/TableWrap.js +3 -2
- package/lib/vtx-page-layout/TreeLayout.js +4 -10
- package/lib/vtx-page-layout/container.js +6 -5
- package/lib/vtx-provider/index.js +17 -10
- package/lib/vtx-provider/locale/en_US.js +10 -2
- package/lib/vtx-provider/locale/zh_CN.js +20 -2
- package/lib/vtx-provider/useStyle/index.js +8 -4
- package/lib/vtx-scrollable-row/index.js +38 -28
- package/lib/vtx-search/index.js +5 -4
- package/lib/vtx-search/style/index.js +2 -1
- package/lib/vtx-select/index.js +25 -11
- package/lib/vtx-signature/index.js +4 -3
- package/lib/vtx-signature/style/index.js +1 -1
- package/lib/vtx-tree/index.js +78 -32
- package/lib/vtx-tree-select/index.js +4 -0
- package/lib/vtx-wang-editor/index.js +277 -109
- package/lib/vtx-wang-editor/wangEditorUtil.js +59 -10
- package/package.json +38 -23
|
@@ -4,6 +4,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.DEFAULT_HEIGHTS = void 0;
|
|
7
8
|
exports.VtxDatagrid = VtxDatagrid;
|
|
8
9
|
exports.indexColumnKey = exports.default = void 0;
|
|
9
10
|
var _ahooks = require("ahooks");
|
|
@@ -18,6 +19,7 @@ var _ToolBar = _interopRequireDefault(require("./ToolBar"));
|
|
|
18
19
|
var _Provide = require("./Store/Provide");
|
|
19
20
|
var _index = require("./style/index");
|
|
20
21
|
var _reactAntdColumnResize = require("react-antd-column-resize");
|
|
22
|
+
var _vtxProvider = require("../vtx-provider");
|
|
21
23
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
24
|
var _excluded = ["toolbar", "toolbarClassName", "toolbarTilte", "buttonGroup", "refreshIconVisible", "hideColumnSetting", "hideColumnHeight", "onRefresh", "bordered", "startIndex", "autoFit", "headFootHeight", "columnResizable", "components", "className", "style", "emptyText", "onRowSelectionClear", "onColumnsSave", "uniqueKey", "prefixUrl", "hideSelectionClear", "customEnumText"];
|
|
23
25
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -38,8 +40,14 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
38
40
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
39
41
|
var isMac = navigator.userAgent.indexOf('Mac OS') !== -1;
|
|
40
42
|
var indexColumnKey = exports.indexColumnKey = '_serialNum';
|
|
43
|
+
var DEFAULT_HEIGHTS = exports.DEFAULT_HEIGHTS = {
|
|
44
|
+
HEAD_FOOT: 115,
|
|
45
|
+
ALERT: 49,
|
|
46
|
+
TOOLBAR: 56
|
|
47
|
+
};
|
|
41
48
|
function VtxTable(props) {
|
|
42
49
|
var _rest$dataSource, _rest$rowSelection, _rest$rowSelection3, _rest$rowSelection4;
|
|
50
|
+
var intl = (0, _vtxProvider.useIntl)();
|
|
43
51
|
var _useContext = (0, _react.useContext)(_antd.ConfigProvider.ConfigContext),
|
|
44
52
|
getPrefixCls = _useContext.getPrefixCls;
|
|
45
53
|
var prefixCls = getPrefixCls('', 'vtx-datagrid');
|
|
@@ -75,7 +83,7 @@ function VtxTable(props) {
|
|
|
75
83
|
toolbar = _props$toolbar === void 0 ? true : _props$toolbar,
|
|
76
84
|
toolbarClassName = props.toolbarClassName,
|
|
77
85
|
_props$toolbarTilte = props.toolbarTilte,
|
|
78
|
-
toolbarTilte = _props$toolbarTilte === void 0 ? '查询结果' : _props$toolbarTilte,
|
|
86
|
+
toolbarTilte = _props$toolbarTilte === void 0 ? intl.getMessage('datagrid.queryResults', '查询结果') : _props$toolbarTilte,
|
|
79
87
|
buttonGroup = props.buttonGroup,
|
|
80
88
|
_props$refreshIconVis = props.refreshIconVisible,
|
|
81
89
|
refreshIconVisible = _props$refreshIconVis === void 0 ? true : _props$refreshIconVis,
|
|
@@ -89,14 +97,14 @@ function VtxTable(props) {
|
|
|
89
97
|
_props$autoFit = props.autoFit,
|
|
90
98
|
autoFit = _props$autoFit === void 0 ? true : _props$autoFit,
|
|
91
99
|
_props$headFootHeight = props.headFootHeight,
|
|
92
|
-
headFootHeight = _props$headFootHeight === void 0 ?
|
|
100
|
+
headFootHeight = _props$headFootHeight === void 0 ? DEFAULT_HEIGHTS.HEAD_FOOT : _props$headFootHeight,
|
|
93
101
|
_props$columnResizabl = props.columnResizable,
|
|
94
102
|
columnResizable = _props$columnResizabl === void 0 ? true : _props$columnResizabl,
|
|
95
103
|
components = props.components,
|
|
96
104
|
className = props.className,
|
|
97
105
|
style = props.style,
|
|
98
106
|
_props$emptyText = props.emptyText,
|
|
99
|
-
emptyText = _props$emptyText === void 0 ? '暂无数据' : _props$emptyText,
|
|
107
|
+
emptyText = _props$emptyText === void 0 ? intl.getMessage('select.empty', '暂无数据') : _props$emptyText,
|
|
100
108
|
onRowSelectionClear = props.onRowSelectionClear,
|
|
101
109
|
onColumnsSave = props.onColumnsSave,
|
|
102
110
|
uniqueKey = props.uniqueKey,
|
|
@@ -132,14 +140,12 @@ function VtxTable(props) {
|
|
|
132
140
|
var resizeObserver = new ResizeObserver(function () {
|
|
133
141
|
calculateHeight();
|
|
134
142
|
});
|
|
135
|
-
// componentDidMount
|
|
136
143
|
if (autoFit && rootDomRef.current) {
|
|
137
144
|
resizeObserver.observe(rootDomRef.current, {
|
|
138
145
|
box: 'border-box'
|
|
139
146
|
});
|
|
140
147
|
}
|
|
141
148
|
return function () {
|
|
142
|
-
// componentWillUnmount
|
|
143
149
|
if (autoFit) {
|
|
144
150
|
resizeObserver.disconnect();
|
|
145
151
|
}
|
|
@@ -161,7 +167,7 @@ function VtxTable(props) {
|
|
|
161
167
|
showSizeChanger: true,
|
|
162
168
|
showQuickJumper: true,
|
|
163
169
|
showTotal: function showTotal(total) {
|
|
164
|
-
return "".concat(TextEnum.
|
|
170
|
+
return "".concat(TextEnum.paginationTotalText, " ").concat(total, " ").concat(TextEnum.paginationItemText);
|
|
165
171
|
}
|
|
166
172
|
}, pagination);
|
|
167
173
|
};
|
|
@@ -236,8 +242,8 @@ function VtxTable(props) {
|
|
|
236
242
|
selectedRowKeys: (_rest$rowSelection4 = rest.rowSelection) === null || _rest$rowSelection4 === void 0 ? void 0 : _rest$rowSelection4.selectedRowKeys,
|
|
237
243
|
onRowSelectionClear: onRowSelectionClear
|
|
238
244
|
}) : null;
|
|
239
|
-
alertHeight.current = !hideSelectionClear && hasAlert ?
|
|
240
|
-
toolbarHeight.current = toolbar ?
|
|
245
|
+
alertHeight.current = !hideSelectionClear && hasAlert ? DEFAULT_HEIGHTS.ALERT : 0;
|
|
246
|
+
toolbarHeight.current = toolbar ? DEFAULT_HEIGHTS.TOOLBAR : 0;
|
|
241
247
|
var _useAntdColumnResize = (0, _reactAntdColumnResize.useAntdColumnResize)(function () {
|
|
242
248
|
return {
|
|
243
249
|
columns: columns,
|
|
@@ -288,7 +294,7 @@ function VtxTable(props) {
|
|
|
288
294
|
hideColumnHeight: hideColumnHeight,
|
|
289
295
|
hideColumnSetting: hideColumnSetting,
|
|
290
296
|
onRefresh: onRefresh,
|
|
291
|
-
columns:
|
|
297
|
+
columns: tableColumn,
|
|
292
298
|
onColumnsSave: onColumnsSave,
|
|
293
299
|
uniqueKey: uniqueKey,
|
|
294
300
|
prefixUrl: prefixUrl,
|
|
@@ -56,7 +56,7 @@ var genVtxStyle = function genVtxStyle(token) {
|
|
|
56
56
|
}
|
|
57
57
|
}))))), "&.vtx-datagrid-striped", _defineProperty({}, "".concat(antCls, "-table-wrapper"), _defineProperty({}, "".concat(antCls, "-table"), _defineProperty({}, '>.ant-table-container', _defineProperty({}, '.ant-table-body', {
|
|
58
58
|
'>table >tbody>tr:nth-child(odd)>td': {
|
|
59
|
-
backgroundColor: token.
|
|
59
|
+
backgroundColor: token.colorBgLayoutTable,
|
|
60
60
|
'&.ant-table-cell-row-hover': {
|
|
61
61
|
backgroundColor: token.colorFillAlterSolid
|
|
62
62
|
}
|
|
@@ -72,7 +72,7 @@ var genVtxStyle = function genVtxStyle(token) {
|
|
|
72
72
|
}
|
|
73
73
|
}))))), "&.vtx-datagrid-header-background", _defineProperty({}, "".concat(antCls, "-table-wrapper"), _defineProperty({}, '.ant-table', _defineProperty({}, '.ant-table-header', _defineProperty({}, '.ant-table-thead', {
|
|
74
74
|
'>tr>th': {
|
|
75
|
-
background: token.
|
|
75
|
+
background: token.colorBgLayoutTable
|
|
76
76
|
}
|
|
77
77
|
}))))));
|
|
78
78
|
};
|
|
@@ -28,6 +28,11 @@ function VtxEllipsisText(props) {
|
|
|
28
28
|
tooltip = _props$tooltip === void 0 ? {} : _props$tooltip,
|
|
29
29
|
className = props.className,
|
|
30
30
|
style = props.style;
|
|
31
|
+
|
|
32
|
+
// 边界检查
|
|
33
|
+
if (!text) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
31
36
|
var _useContext = (0, _react.useContext)(_antd.ConfigProvider.ConfigContext),
|
|
32
37
|
getPrefixCls = _useContext.getPrefixCls;
|
|
33
38
|
var prefixCls = getPrefixCls('vtx-ellipsis-text');
|
|
@@ -35,7 +40,7 @@ function VtxEllipsisText(props) {
|
|
|
35
40
|
wrapSSR = _useStyle.wrapSSR,
|
|
36
41
|
hashId = _useStyle.hashId;
|
|
37
42
|
var textStyle = {};
|
|
38
|
-
if (lineClamp
|
|
43
|
+
if (lineClamp >= 2) {
|
|
39
44
|
textStyle['WebkitLineClamp'] = lineClamp;
|
|
40
45
|
}
|
|
41
46
|
return wrapSSR( /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Tooltip, _objectSpread(_objectSpread({
|
package/lib/vtx-export/index.js
CHANGED
|
@@ -131,8 +131,13 @@ var VtxExport = exports.VtxExport = function VtxExport(props) {
|
|
|
131
131
|
// 关闭loading,执行回调
|
|
132
132
|
document.body.removeChild(div);
|
|
133
133
|
if (afterExport && typeof afterExport === 'function') {
|
|
134
|
+
console.log('Export status:', status);
|
|
134
135
|
afterExport(status);
|
|
135
136
|
}
|
|
137
|
+
}).catch(function (err) {
|
|
138
|
+
console.error('Export failed:', err);
|
|
139
|
+
_antd.message.error('导出失败');
|
|
140
|
+
document.body.removeChild(div);
|
|
136
141
|
});
|
|
137
142
|
}
|
|
138
143
|
/* 下载并 兼容IE */
|
|
@@ -18,6 +18,8 @@ var _index = require("./style/index");
|
|
|
18
18
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
19
19
|
var _vtxProvider = require("../vtx-provider");
|
|
20
20
|
var _vtxModal = _interopRequireDefault(require("../vtx-modal"));
|
|
21
|
+
var _vtxInput = _interopRequireDefault(require("../vtx-input"));
|
|
22
|
+
var _filterSpecialCharacters = require("../utils/filterSpecialCharacters");
|
|
21
23
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
25
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -33,7 +35,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
33
35
|
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; }
|
|
34
36
|
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; } }
|
|
35
37
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
36
|
-
var
|
|
38
|
+
var Includes = ['\\\\', '\\/', ':', '*', '?', '"', '<', '>', '|'];
|
|
37
39
|
var VtxExportAsync = exports.VtxExportAsync = function VtxExportAsync(props) {
|
|
38
40
|
var intl = (0, _vtxProvider.useIntl)();
|
|
39
41
|
var _useContext = (0, _react.useContext)(_antd.ConfigProvider.ConfigContext),
|
|
@@ -42,6 +44,7 @@ var VtxExportAsync = exports.VtxExportAsync = function VtxExportAsync(props) {
|
|
|
42
44
|
var _useStyle = (0, _index.useStyle)(prefixCls),
|
|
43
45
|
wrapSSR = _useStyle.wrapSSR,
|
|
44
46
|
hashId = _useStyle.hashId;
|
|
47
|
+
var timerRef = (0, _react.useRef)(null);
|
|
45
48
|
var uniqueKey = props.uniqueKey,
|
|
46
49
|
_props$title = props.title,
|
|
47
50
|
title = _props$title === void 0 ? '' : _props$title,
|
|
@@ -168,9 +171,9 @@ var VtxExportAsync = exports.VtxExportAsync = function VtxExportAsync(props) {
|
|
|
168
171
|
});
|
|
169
172
|
}, [state.visible]);
|
|
170
173
|
function close() {
|
|
171
|
-
if (
|
|
172
|
-
clearInterval(
|
|
173
|
-
|
|
174
|
+
if (timerRef.current) {
|
|
175
|
+
clearInterval(timerRef.current);
|
|
176
|
+
timerRef.current = null;
|
|
174
177
|
}
|
|
175
178
|
form.resetFields();
|
|
176
179
|
setState({
|
|
@@ -180,6 +183,15 @@ var VtxExportAsync = exports.VtxExportAsync = function VtxExportAsync(props) {
|
|
|
180
183
|
timer: null
|
|
181
184
|
});
|
|
182
185
|
}
|
|
186
|
+
|
|
187
|
+
// 组件卸载时也要清理
|
|
188
|
+
(0, _react.useEffect)(function () {
|
|
189
|
+
return function () {
|
|
190
|
+
if (timerRef.current) {
|
|
191
|
+
clearInterval(timerRef.current);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}, []);
|
|
183
195
|
function showHistory() {
|
|
184
196
|
setState({
|
|
185
197
|
showHistoryModal: true
|
|
@@ -261,6 +273,8 @@ var VtxExportAsync = exports.VtxExportAsync = function VtxExportAsync(props) {
|
|
|
261
273
|
} else {
|
|
262
274
|
_antd.message.error((res === null || res === void 0 ? void 0 : res.msg) || "".concat(intl.getMessage('export.exportText', '导出')).concat(intl.getMessage('export.failure', '失败')));
|
|
263
275
|
}
|
|
276
|
+
}).catch(function (err) {
|
|
277
|
+
_antd.message.error('导出失败:' + (err.message || '网络错误'));
|
|
264
278
|
});
|
|
265
279
|
}
|
|
266
280
|
});
|
|
@@ -321,8 +335,14 @@ var VtxExportAsync = exports.VtxExportAsync = function VtxExportAsync(props) {
|
|
|
321
335
|
required: true,
|
|
322
336
|
message: TextEnum.requireFieldMsgText
|
|
323
337
|
}],
|
|
324
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
325
|
-
placeholder: TextEnum.placeholderFileName
|
|
338
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_vtxInput.default, {
|
|
339
|
+
placeholder: TextEnum.placeholderFileName,
|
|
340
|
+
specialCharactersFilter: {
|
|
341
|
+
include: Includes,
|
|
342
|
+
exclude: _filterSpecialCharacters.SpecialCharacters.filter(function (v) {
|
|
343
|
+
return !Includes.includes(v);
|
|
344
|
+
})
|
|
345
|
+
}
|
|
326
346
|
})
|
|
327
347
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Form.Item, {
|
|
328
348
|
label: TextEnum.fieldTypeText,
|
|
@@ -31,17 +31,17 @@ function VtxCard(props) {
|
|
|
31
31
|
_props$expand = props.expand,
|
|
32
32
|
expand = _props$expand === void 0 ? true : _props$expand,
|
|
33
33
|
extra = props.extra,
|
|
34
|
-
onExpandChange = props.onExpandChange
|
|
34
|
+
onExpandChange = props.onExpandChange,
|
|
35
|
+
children = props.children;
|
|
35
36
|
var _useState = (0, _react.useState)(expand),
|
|
36
37
|
_useState2 = _slicedToArray(_useState, 2),
|
|
37
38
|
visible = _useState2[0],
|
|
38
39
|
setVisible = _useState2[1];
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
style = {
|
|
40
|
+
var iconStyle = (0, _react.useMemo)(function () {
|
|
41
|
+
return visible ? {
|
|
42
42
|
transform: 'rotate(90deg)'
|
|
43
|
-
};
|
|
44
|
-
}
|
|
43
|
+
} : {};
|
|
44
|
+
}, [visible]);
|
|
45
45
|
(0, _react.useEffect)(function () {
|
|
46
46
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
47
47
|
onExpandChange && onExpandChange(visible);
|
|
@@ -59,8 +59,8 @@ function VtxCard(props) {
|
|
|
59
59
|
},
|
|
60
60
|
children: extra
|
|
61
61
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.RightOutlined, {
|
|
62
|
-
className: "".concat(prefixCls, "-expand-icon
|
|
63
|
-
style:
|
|
62
|
+
className: "".concat(prefixCls, "-expand-icon"),
|
|
63
|
+
style: iconStyle,
|
|
64
64
|
onClick: function onClick() {
|
|
65
65
|
return setVisible(function (pre) {
|
|
66
66
|
return !pre;
|
|
@@ -69,7 +69,7 @@ function VtxCard(props) {
|
|
|
69
69
|
}),
|
|
70
70
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
71
71
|
className: (0, _classnames2.default)("".concat(prefixCls, "-content"), _defineProperty({}, "".concat(prefixCls, "-content-hide"), !visible)),
|
|
72
|
-
children:
|
|
72
|
+
children: children
|
|
73
73
|
})
|
|
74
74
|
});
|
|
75
75
|
}
|
|
@@ -22,7 +22,7 @@ function VtxDivider(props) {
|
|
|
22
22
|
var prefixCls = getPrefixCls('', 'vtx-form-layout-divider');
|
|
23
23
|
var size = props.size;
|
|
24
24
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Divider, {
|
|
25
|
-
className: (0, _classnames2.default)(prefixCls, _defineProperty({}, "".concat(prefixCls, "--small
|
|
25
|
+
className: (0, _classnames2.default)(prefixCls, _defineProperty({}, "".concat(prefixCls, "--small"), size === 'small'))
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
VtxDivider.propTypes = {
|
|
@@ -106,7 +106,8 @@ function FormItem(props) {
|
|
|
106
106
|
children: label
|
|
107
107
|
}),
|
|
108
108
|
required: required,
|
|
109
|
-
hidden: hidden
|
|
109
|
+
hidden: hidden,
|
|
110
|
+
colon: label ? true : false
|
|
110
111
|
}, formItemLayout), {}, {
|
|
111
112
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Form.Item, _objectSpread(_objectSpread(_objectSpread({
|
|
112
113
|
noStyle: true
|
|
@@ -17,18 +17,29 @@ function Pane(props) {
|
|
|
17
17
|
var _useContext = (0, _react.useContext)(_antd.ConfigProvider.ConfigContext),
|
|
18
18
|
getPrefixCls = _useContext.getPrefixCls;
|
|
19
19
|
var prefixCls = getPrefixCls('', 'vtx-form-layout-pane');
|
|
20
|
-
var title = props.title
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}),
|
|
27
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
20
|
+
var title = props.title,
|
|
21
|
+
children = props.children;
|
|
22
|
+
|
|
23
|
+
// 无标题时直接渲染内容
|
|
24
|
+
if (!title) {
|
|
25
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
28
26
|
className: "".concat(prefixCls, "-content"),
|
|
29
|
-
children:
|
|
30
|
-
})
|
|
31
|
-
}
|
|
27
|
+
children: children
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
var items = (0, _react.useMemo)(function () {
|
|
31
|
+
return [{
|
|
32
|
+
key: '1',
|
|
33
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
34
|
+
className: "".concat(prefixCls, "-title"),
|
|
35
|
+
children: title
|
|
36
|
+
}),
|
|
37
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
38
|
+
className: "".concat(prefixCls, "-content"),
|
|
39
|
+
children: children
|
|
40
|
+
})
|
|
41
|
+
}];
|
|
42
|
+
}, [title, children, prefixCls]);
|
|
32
43
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Collapse, {
|
|
33
44
|
className: prefixCls,
|
|
34
45
|
bordered: false,
|
package/lib/vtx-image/Preview.js
CHANGED
|
@@ -28,15 +28,12 @@ var VIEWER = 'viewer';
|
|
|
28
28
|
// 多张
|
|
29
29
|
var GALLERY = 'gallery';
|
|
30
30
|
function checkMode(x) {
|
|
31
|
-
var mode = '';
|
|
32
|
-
if ((0, _utils.isObject)(x)) {
|
|
33
|
-
mode = VIEWER;
|
|
34
|
-
}
|
|
35
31
|
if (Array.isArray(x)) {
|
|
36
32
|
var len = x.length;
|
|
37
|
-
|
|
33
|
+
if (len === 0) return null;
|
|
34
|
+
return len === 1 ? VIEWER : GALLERY;
|
|
38
35
|
}
|
|
39
|
-
return
|
|
36
|
+
return (0, _utils.isObject)(x) ? VIEWER : null;
|
|
40
37
|
}
|
|
41
38
|
function Preview(props) {
|
|
42
39
|
var _useState = (0, _react.useState)(),
|
|
@@ -93,6 +90,9 @@ function Preview(props) {
|
|
|
93
90
|
setContainer(container);
|
|
94
91
|
setViewer(viewer);
|
|
95
92
|
return function () {
|
|
93
|
+
if (container) {
|
|
94
|
+
container.innerHTML = '';
|
|
95
|
+
}
|
|
96
96
|
viewer && viewer.destroy();
|
|
97
97
|
};
|
|
98
98
|
}, []);
|
|
@@ -102,6 +102,7 @@ function Preview(props) {
|
|
|
102
102
|
container.innerHTML = '';
|
|
103
103
|
}
|
|
104
104
|
var mode = checkMode(photo);
|
|
105
|
+
if (!mode) return null;
|
|
105
106
|
var newIndex = index;
|
|
106
107
|
// 单张
|
|
107
108
|
if (mode === VIEWER) {
|
|
@@ -132,6 +133,10 @@ function Preview(props) {
|
|
|
132
133
|
}
|
|
133
134
|
viewer.update();
|
|
134
135
|
viewer.view(newIndex);
|
|
136
|
+
} else {
|
|
137
|
+
if (container) {
|
|
138
|
+
container.innerHTML = '';
|
|
139
|
+
}
|
|
135
140
|
}
|
|
136
141
|
}, [visible]);
|
|
137
142
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
|
package/lib/vtx-import/index.js
CHANGED
|
@@ -41,14 +41,19 @@ function VtxImport(props) {
|
|
|
41
41
|
var _useStyle = (0, _index.useStyle)(prefixCls),
|
|
42
42
|
wrapSSR = _useStyle.wrapSSR,
|
|
43
43
|
hashId = _useStyle.hashId;
|
|
44
|
+
|
|
45
|
+
// 用 useRef 管理 DOM 引用,而不是 state
|
|
46
|
+
var fileInputRef = (0, _react.useRef)(null);
|
|
47
|
+
var iframeRef = (0, _react.useRef)(null);
|
|
48
|
+
var formRef = (0, _react.useRef)(null);
|
|
49
|
+
|
|
50
|
+
// 用于追踪当前 XHR 请求,方便取消
|
|
51
|
+
var xhrRef = (0, _react.useRef)(null);
|
|
44
52
|
var indexRef = (0, _react.useRef)(0);
|
|
45
53
|
var _useSet = (0, _useSet3.default)({
|
|
46
|
-
fileForm: null,
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
// 保存上传的文件
|
|
50
|
-
iframe: null,
|
|
51
|
-
// form表单提交之后跳转的
|
|
54
|
+
// fileForm: null, // form表单
|
|
55
|
+
// fileInput: null, // 保存上传的文件
|
|
56
|
+
// iframe: null, // form表单提交之后跳转的
|
|
52
57
|
useFormData: window.FormData ? true : false,
|
|
53
58
|
// 是否查看
|
|
54
59
|
uploading: false,
|
|
@@ -111,7 +116,7 @@ function VtxImport(props) {
|
|
|
111
116
|
data.append('chunkNo', i + 1);
|
|
112
117
|
data.append('chunkId', state.chunkId);
|
|
113
118
|
data.append('tenantId', (0, _utils.getVtxToken)('tenantId'));
|
|
114
|
-
data.append('file', new File([e],
|
|
119
|
+
data.append('file', new File([e], fileInputRef.current.files[0].name));
|
|
115
120
|
dataArr.push(data);
|
|
116
121
|
});
|
|
117
122
|
uploadAsync(dataArr);
|
|
@@ -121,6 +126,7 @@ function VtxImport(props) {
|
|
|
121
126
|
function uploadAsync(list) {
|
|
122
127
|
if (indexRef.current < list.length) {
|
|
123
128
|
var xhr = new XMLHttpRequest();
|
|
129
|
+
xhrRef.current = xhr;
|
|
124
130
|
xhr.onload = function () {
|
|
125
131
|
if (xhr.status === 200) {
|
|
126
132
|
setState({
|
|
@@ -144,15 +150,27 @@ function VtxImport(props) {
|
|
|
144
150
|
// 合并分片
|
|
145
151
|
function mergeFile() {
|
|
146
152
|
var xhr = new XMLHttpRequest();
|
|
153
|
+
xhrRef.current = xhr;
|
|
147
154
|
// 当上传完成时调用
|
|
148
155
|
xhr.onload = function () {
|
|
149
156
|
if (xhr.status === 200) {
|
|
150
|
-
var
|
|
151
|
-
|
|
157
|
+
var _res;
|
|
158
|
+
var res;
|
|
159
|
+
try {
|
|
160
|
+
res = JSON.parse(xhr.responseText);
|
|
161
|
+
} catch (e) {
|
|
162
|
+
_antd.message.error(intl.getMessage('import.error', '解析响应失败'));
|
|
163
|
+
setState({
|
|
164
|
+
uploading: false
|
|
165
|
+
});
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (((_res = res) === null || _res === void 0 ? void 0 : _res.result) == 0) {
|
|
152
169
|
_antd.message.success(intl.getMessage('import.success', '上传成功'));
|
|
153
170
|
chunkUpload(res.data);
|
|
154
171
|
} else {
|
|
155
|
-
|
|
172
|
+
var _res2;
|
|
173
|
+
_antd.message.error(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.msg) || intl.getMessage('import.error', '上传失败'));
|
|
156
174
|
}
|
|
157
175
|
}
|
|
158
176
|
};
|
|
@@ -165,7 +183,7 @@ function VtxImport(props) {
|
|
|
165
183
|
data.append('chunkId', state.chunkId);
|
|
166
184
|
data.append('tenantId', (0, _utils.getVtxToken)('tenantId'));
|
|
167
185
|
data.append('chunkSize', state.chunks.length);
|
|
168
|
-
data.append('fileName',
|
|
186
|
+
data.append('fileName', fileInputRef.current.files[0].name);
|
|
169
187
|
xhr.send(data);
|
|
170
188
|
}
|
|
171
189
|
|
|
@@ -175,6 +193,7 @@ function VtxImport(props) {
|
|
|
175
193
|
var postData = props.postData || {};
|
|
176
194
|
if (state.useFormData) {
|
|
177
195
|
var request = new XMLHttpRequest();
|
|
196
|
+
xhrRef.current = request;
|
|
178
197
|
// 发送请求
|
|
179
198
|
request.open('POST', postUrl);
|
|
180
199
|
request.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
|
|
@@ -205,6 +224,7 @@ function VtxImport(props) {
|
|
|
205
224
|
var postData = props.postData || {};
|
|
206
225
|
if (state.useFormData) {
|
|
207
226
|
var request = new XMLHttpRequest();
|
|
227
|
+
xhrRef.current = request;
|
|
208
228
|
// 发送请求
|
|
209
229
|
request.open('POST', postUrl);
|
|
210
230
|
request.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
|
|
@@ -225,7 +245,7 @@ function VtxImport(props) {
|
|
|
225
245
|
};
|
|
226
246
|
//创建formdata对象
|
|
227
247
|
var fmd = new FormData();
|
|
228
|
-
fmd.append(state.fileKey,
|
|
248
|
+
fmd.append(state.fileKey, fileInputRef.current.files[0]);
|
|
229
249
|
request.send(fmd);
|
|
230
250
|
}
|
|
231
251
|
}
|
|
@@ -256,7 +276,9 @@ function VtxImport(props) {
|
|
|
256
276
|
return postArray.length > 0 ? "".concat(postUrl, "?").concat(postArray.join('&')) : postUrl;
|
|
257
277
|
};
|
|
258
278
|
var closeModal = function closeModal() {
|
|
259
|
-
|
|
279
|
+
if (fileInputRef.current) {
|
|
280
|
+
fileInputRef.current.value = '';
|
|
281
|
+
}
|
|
260
282
|
if (typeof props.close === 'function') {
|
|
261
283
|
props.close();
|
|
262
284
|
} else {
|
|
@@ -267,15 +289,24 @@ function VtxImport(props) {
|
|
|
267
289
|
};
|
|
268
290
|
// 上传之后的回调 - 展示报错信息
|
|
269
291
|
var uploadSuccess = function uploadSuccess(data) {
|
|
270
|
-
|
|
292
|
+
var _parseData;
|
|
293
|
+
if (fileInputRef.current) {
|
|
294
|
+
fileInputRef.current.value = '';
|
|
295
|
+
}
|
|
271
296
|
setState({
|
|
272
297
|
uploading: false
|
|
273
298
|
});
|
|
299
|
+
var parseData;
|
|
300
|
+
try {
|
|
301
|
+
parseData = JSON.parse(data);
|
|
302
|
+
} catch (e) {
|
|
303
|
+
_antd.message.error(intl.getMessage('import.error', '解析响应数据失败'));
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
274
306
|
if (typeof props.afterUpload === 'function') {
|
|
275
307
|
afterUpload(data);
|
|
276
308
|
}
|
|
277
|
-
|
|
278
|
-
if (Array.isArray(parseData === null || parseData === void 0 ? void 0 : parseData.data)) {
|
|
309
|
+
if (Array.isArray((_parseData = parseData) === null || _parseData === void 0 ? void 0 : _parseData.data)) {
|
|
279
310
|
setState({
|
|
280
311
|
resultVisible: true,
|
|
281
312
|
resultData: parseData.data.map(function (item, index) {
|
|
@@ -290,7 +321,8 @@ function VtxImport(props) {
|
|
|
290
321
|
} else {
|
|
291
322
|
// 新增其他错误提示
|
|
292
323
|
if (parseData.result !== 0) {
|
|
293
|
-
|
|
324
|
+
var _parseData2;
|
|
325
|
+
_antd.message.error(((_parseData2 = parseData) === null || _parseData2 === void 0 ? void 0 : _parseData2.msg) || intl.getMessage('import.success', '上传成功'));
|
|
294
326
|
}
|
|
295
327
|
}
|
|
296
328
|
};
|
|
@@ -315,22 +347,21 @@ function VtxImport(props) {
|
|
|
315
347
|
type: "primary",
|
|
316
348
|
loading: state.uploading,
|
|
317
349
|
onClick: function onClick() {
|
|
350
|
+
var _fileInputRef$current2;
|
|
318
351
|
if (typeof props.beforeUpload === 'function') {
|
|
319
|
-
var
|
|
352
|
+
var _fileInputRef$current;
|
|
353
|
+
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]);
|
|
320
354
|
if (!flag) {
|
|
321
|
-
|
|
322
|
-
setState({
|
|
323
|
-
fileInput: null
|
|
324
|
-
});
|
|
355
|
+
fileInputRef.current.value = '';
|
|
325
356
|
return;
|
|
326
357
|
}
|
|
327
358
|
}
|
|
328
|
-
if (
|
|
359
|
+
if ((_fileInputRef$current2 = fileInputRef.current) !== null && _fileInputRef$current2 !== void 0 && _fileInputRef$current2.value) {
|
|
329
360
|
setState({
|
|
330
361
|
uploading: true
|
|
331
362
|
});
|
|
332
363
|
// 上传文件
|
|
333
|
-
checkFile(
|
|
364
|
+
checkFile(fileInputRef.current.files[0]);
|
|
334
365
|
// const postUrl = getPostURL();
|
|
335
366
|
// if (state.useFormData) {
|
|
336
367
|
// const request = new XMLHttpRequest();
|
|
@@ -372,6 +403,21 @@ function VtxImport(props) {
|
|
|
372
403
|
},
|
|
373
404
|
modalWidth: state.modalWidth
|
|
374
405
|
};
|
|
406
|
+
|
|
407
|
+
// 组件卸载时清理
|
|
408
|
+
(0, _react.useEffect)(function () {
|
|
409
|
+
return function () {
|
|
410
|
+
// 取消进行中的 XHR 请求
|
|
411
|
+
if (xhrRef.current) {
|
|
412
|
+
xhrRef.current.abort();
|
|
413
|
+
xhrRef.current = null;
|
|
414
|
+
}
|
|
415
|
+
// 清理文件输入
|
|
416
|
+
if (fileInputRef.current) {
|
|
417
|
+
fileInputRef.current.value = '';
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
}, []);
|
|
375
421
|
(0, _react.useEffect)(function () {
|
|
376
422
|
if (state.chunkId) {
|
|
377
423
|
startUpload();
|
|
@@ -383,25 +429,19 @@ function VtxImport(props) {
|
|
|
383
429
|
method: "post",
|
|
384
430
|
target: "tmp",
|
|
385
431
|
action: uploadURL,
|
|
386
|
-
ref:
|
|
387
|
-
if (dom) state.fileForm = dom;
|
|
388
|
-
},
|
|
432
|
+
ref: formRef,
|
|
389
433
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
390
434
|
type: "file",
|
|
391
435
|
name: state.fileKey,
|
|
392
436
|
accept: state.accept,
|
|
393
|
-
ref:
|
|
394
|
-
if (dom) state.fileInput = dom;
|
|
395
|
-
}
|
|
437
|
+
ref: fileInputRef
|
|
396
438
|
})
|
|
397
439
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("iframe", {
|
|
398
440
|
name: "tmp",
|
|
399
441
|
style: {
|
|
400
442
|
display: 'none'
|
|
401
443
|
},
|
|
402
|
-
ref:
|
|
403
|
-
if (dom) state.iframe = dom;
|
|
404
|
-
}
|
|
444
|
+
ref: iframeRef
|
|
405
445
|
}), state.resultVisible && /*#__PURE__*/(0, _jsxRuntime.jsx)(_result.default, _objectSpread({}, resultProps))]
|
|
406
446
|
})));
|
|
407
447
|
}
|
package/lib/vtx-import2/index.js
CHANGED
|
@@ -221,7 +221,7 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
|
|
|
221
221
|
if (xhr.status === 200) {
|
|
222
222
|
var res = JSON.parse(xhr.responseText);
|
|
223
223
|
if ((res === null || res === void 0 ? void 0 : res.result) == 0) {
|
|
224
|
-
_antd.message.success('上传成功');
|
|
224
|
+
_antd.message.success(intl.getMessage('import.success', '上传成功'));
|
|
225
225
|
chunkUpload(res.data);
|
|
226
226
|
} else {
|
|
227
227
|
_antd.message.error((res === null || res === void 0 ? void 0 : res.msg) || intl.getMessage('import.error', '上传失败'));
|
|
@@ -253,6 +253,7 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
|
|
|
253
253
|
}
|
|
254
254
|
request.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
|
|
255
255
|
request.setRequestHeader('access_token', token ? "".concat(token) : '');
|
|
256
|
+
request.setRequestHeader('systemCode', getUrlParam('systemCode') ? getUrlParam('systemCode') : '');
|
|
256
257
|
// 添加操作日志
|
|
257
258
|
request.setRequestHeader('operation', encodeURIComponent(JSON.stringify({
|
|
258
259
|
menuId: sessionStorage.getItem('vtxmenuselectedKeys'),
|
|
@@ -32,7 +32,7 @@ var genVtxImport2Style = function genVtxImport2Style(token) {
|
|
|
32
32
|
padding: '16px 16px 16px 48px',
|
|
33
33
|
color: token.colorPrimary,
|
|
34
34
|
fontSize: '14px',
|
|
35
|
-
backgroundColor: token.
|
|
35
|
+
backgroundColor: token.colorBgLayoutTable,
|
|
36
36
|
borderRadius: '4px'
|
|
37
37
|
}, "".concat(componentCls, "-download"), {
|
|
38
38
|
marginLeft: '16px'
|