@vtx/components 4.0.0-beta.7 → 4.0.0-beta.70

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.
Files changed (161) hide show
  1. package/es/index.js +3 -0
  2. package/es/utils/filterSpecialCharacters.js +47 -46
  3. package/es/utils/index.js +1 -2
  4. package/es/vtx-color-picker/index.js +138 -33
  5. package/es/vtx-color-picker/style/index.js +36 -12
  6. package/es/vtx-combogrid/Combogrid.js +16 -10
  7. package/es/vtx-combogrid/index.js +7 -4
  8. package/es/vtx-combogrid/style/index.js +4 -4
  9. package/es/vtx-datagrid/Store/Provide.js +109 -132
  10. package/es/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +11 -5
  11. package/es/vtx-datagrid/ToolBar/components/ColumnSetting/style.js +5 -2
  12. package/es/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
  13. package/es/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
  14. package/es/vtx-datagrid/ToolBar/index.js +2 -2
  15. package/es/vtx-datagrid/columnState.js +64 -0
  16. package/es/vtx-datagrid/index.js +114 -35
  17. package/es/vtx-datagrid/mergeComponents.js +15 -0
  18. package/es/vtx-datagrid/renderColumnButtons.js +30 -11
  19. package/es/vtx-datagrid/style/index.js +102 -20
  20. package/es/vtx-date-picker/QdatePicker.js +1 -1
  21. package/es/vtx-descriptions/Descriptions.js +29 -0
  22. package/es/vtx-descriptions/index.js +3 -0
  23. package/es/vtx-descriptions/style/index.js +19 -0
  24. package/es/vtx-ellipsis-text/index.js +7 -2
  25. package/es/vtx-ellipsis-text/style/index.js +3 -1
  26. package/es/vtx-export/index.js +25 -25
  27. package/es/vtx-export-async/History.js +7 -3
  28. package/es/vtx-export-async/index.js +42 -14
  29. package/es/vtx-form-layout/Card.js +10 -10
  30. package/es/vtx-form-layout/Divider.js +1 -1
  31. package/es/vtx-form-layout/FormItem.js +18 -17
  32. package/es/vtx-form-layout/Pane.js +23 -12
  33. package/es/vtx-icon/index.js +54 -45
  34. package/es/vtx-icon/index.js1 +90 -0
  35. package/es/vtx-image/Preview.js +11 -6
  36. package/es/vtx-image/style/index.js +0 -1
  37. package/es/vtx-import/index.js +155 -43
  38. package/es/vtx-import/result.js +6 -2
  39. package/es/vtx-import/style/index.js +16 -1
  40. package/es/vtx-import2/Content.js +2 -1
  41. package/es/vtx-import2/index.js +31 -20
  42. package/es/vtx-import2/style/index.js +60 -9
  43. package/es/vtx-input/TextArea/index.js +11 -6
  44. package/es/vtx-modal/index.js +9 -4
  45. package/es/vtx-modal/style/index.js +5 -3
  46. package/es/vtx-page-layout/Content.js +1 -1
  47. package/es/vtx-page-layout/TabLayout.js +1 -7
  48. package/es/vtx-page-layout/TableLayout.js +14 -4
  49. package/es/vtx-page-layout/TableWrap.js +3 -2
  50. package/es/vtx-page-layout/TreeLayout.js +2 -8
  51. package/es/vtx-page-layout/container.js +6 -5
  52. package/es/vtx-page-layout/style/index.js +4 -2
  53. package/es/vtx-provider/index.js +20 -10
  54. package/es/vtx-provider/locale/en_US.js +65 -5
  55. package/es/vtx-provider/locale/zh_CN.js +75 -5
  56. package/es/vtx-provider/useStyle/index.js +8 -4
  57. package/es/vtx-scrollable-row/index.js +38 -28
  58. package/es/vtx-search/index.js +18 -13
  59. package/es/vtx-search/style/index.js +2 -1
  60. package/es/vtx-select/index.js +132 -46
  61. package/es/vtx-select/style/index.js +11 -56
  62. package/es/vtx-signature/index.js +5 -4
  63. package/es/vtx-signature/style/index.js +1 -1
  64. package/es/vtx-split-pane/Resizer.js +0 -1
  65. package/es/vtx-split-pane/SplitPane.js +34 -25
  66. package/es/vtx-split-pane/style/index.js +8 -112
  67. package/es/vtx-time-picker/index.js +27 -1
  68. package/es/vtx-transfer/Transfer.js +29 -0
  69. package/es/vtx-transfer/index.js +3 -0
  70. package/es/vtx-transfer/style/index.js +19 -0
  71. package/es/vtx-transfer-select/TransferSelect.js +143 -0
  72. package/es/vtx-transfer-select/index.js +3 -0
  73. package/es/vtx-transfer-select/style/index.js +19 -0
  74. package/es/vtx-tree/index.js +104 -40
  75. package/es/vtx-tree-select/index.js +75 -105
  76. package/es/vtx-tree-select/style/index.js +9 -3
  77. package/es/vtx-upload/FilePreview.js +2 -1
  78. package/es/vtx-wang-editor/index.js +291 -113
  79. package/es/vtx-wang-editor/wangEditorUtil.js +59 -9
  80. package/lib/index.js +36 -0
  81. package/lib/utils/filterSpecialCharacters.js +48 -46
  82. package/lib/utils/index.js +0 -7
  83. package/lib/vtx-color-picker/index.js +139 -34
  84. package/lib/vtx-color-picker/style/index.js +36 -12
  85. package/lib/vtx-combogrid/Combogrid.js +16 -10
  86. package/lib/vtx-combogrid/index.js +7 -4
  87. package/lib/vtx-combogrid/style/index.js +4 -4
  88. package/lib/vtx-datagrid/Store/Provide.js +116 -138
  89. package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +11 -6
  90. package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/style.js +5 -2
  91. package/lib/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
  92. package/lib/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
  93. package/lib/vtx-datagrid/ToolBar/index.js +2 -2
  94. package/lib/vtx-datagrid/columnState.js +73 -0
  95. package/lib/vtx-datagrid/index.js +115 -35
  96. package/lib/vtx-datagrid/mergeComponents.js +21 -0
  97. package/lib/vtx-datagrid/renderColumnButtons.js +30 -11
  98. package/lib/vtx-datagrid/style/index.js +102 -20
  99. package/lib/vtx-date-picker/QdatePicker.js +1 -1
  100. package/lib/vtx-descriptions/Descriptions.js +38 -0
  101. package/lib/vtx-descriptions/index.js +15 -0
  102. package/lib/vtx-descriptions/style/index.js +25 -0
  103. package/lib/vtx-ellipsis-text/index.js +7 -2
  104. package/lib/vtx-ellipsis-text/style/index.js +3 -1
  105. package/lib/vtx-export/index.js +26 -26
  106. package/lib/vtx-export-async/History.js +7 -3
  107. package/lib/vtx-export-async/index.js +40 -12
  108. package/lib/vtx-form-layout/Card.js +9 -9
  109. package/lib/vtx-form-layout/Divider.js +1 -1
  110. package/lib/vtx-form-layout/FormItem.js +18 -17
  111. package/lib/vtx-form-layout/Pane.js +22 -11
  112. package/lib/vtx-icon/index.js +54 -52
  113. package/lib/vtx-icon/index.js1 +90 -0
  114. package/lib/vtx-image/Preview.js +11 -6
  115. package/lib/vtx-image/style/index.js +0 -1
  116. package/lib/vtx-import/index.js +154 -42
  117. package/lib/vtx-import/result.js +6 -2
  118. package/lib/vtx-import/style/index.js +16 -1
  119. package/lib/vtx-import2/Content.js +2 -1
  120. package/lib/vtx-import2/index.js +30 -19
  121. package/lib/vtx-import2/style/index.js +60 -9
  122. package/lib/vtx-input/TextArea/index.js +11 -6
  123. package/lib/vtx-modal/index.js +9 -4
  124. package/lib/vtx-modal/style/index.js +5 -3
  125. package/lib/vtx-page-layout/Content.js +1 -1
  126. package/lib/vtx-page-layout/TabLayout.js +3 -9
  127. package/lib/vtx-page-layout/TableLayout.js +14 -4
  128. package/lib/vtx-page-layout/TableWrap.js +3 -2
  129. package/lib/vtx-page-layout/TreeLayout.js +4 -10
  130. package/lib/vtx-page-layout/container.js +6 -5
  131. package/lib/vtx-page-layout/style/index.js +4 -2
  132. package/lib/vtx-provider/index.js +19 -10
  133. package/lib/vtx-provider/locale/en_US.js +65 -5
  134. package/lib/vtx-provider/locale/zh_CN.js +75 -5
  135. package/lib/vtx-provider/useStyle/index.js +8 -4
  136. package/lib/vtx-scrollable-row/index.js +38 -28
  137. package/lib/vtx-search/index.js +18 -13
  138. package/lib/vtx-search/style/index.js +2 -1
  139. package/lib/vtx-select/index.js +134 -48
  140. package/lib/vtx-select/style/index.js +11 -56
  141. package/lib/vtx-signature/index.js +4 -3
  142. package/lib/vtx-signature/style/index.js +1 -1
  143. package/lib/vtx-split-pane/Resizer.js +0 -1
  144. package/lib/vtx-split-pane/SplitPane.js +32 -23
  145. package/lib/vtx-split-pane/style/index.js +8 -112
  146. package/lib/vtx-time-picker/index.js +27 -1
  147. package/lib/vtx-transfer/Transfer.js +38 -0
  148. package/lib/vtx-transfer/index.js +15 -0
  149. package/lib/vtx-transfer/style/index.js +25 -0
  150. package/lib/vtx-transfer-select/TransferSelect.js +151 -0
  151. package/lib/vtx-transfer-select/index.js +15 -0
  152. package/lib/vtx-transfer-select/style/index.js +25 -0
  153. package/lib/vtx-tree/index.js +102 -38
  154. package/lib/vtx-tree-select/index.js +75 -105
  155. package/lib/vtx-tree-select/style/index.js +9 -3
  156. package/lib/vtx-upload/FilePreview.js +2 -1
  157. package/lib/vtx-wang-editor/index.js +289 -113
  158. package/lib/vtx-wang-editor/wangEditorUtil.js +59 -10
  159. package/package.json +44 -28
  160. package/es/utils/hooks/useFetchData/index.js +0 -82
  161. package/lib/utils/hooks/useFetchData/index.js +0 -89
@@ -14,9 +14,9 @@ var _result = _interopRequireDefault(require("./result"));
14
14
  var _getToken = _interopRequireDefault(require("../utils/getToken"));
15
15
  var _md = _interopRequireDefault(require("md5"));
16
16
  var _utils = require("@vtx/utils");
17
- var _classnames = _interopRequireDefault(require("classnames"));
18
17
  var _index = require("./style/index");
19
18
  var _vtxProvider = require("../vtx-provider");
19
+ var _vtxModal = _interopRequireDefault(require("../vtx-modal"));
20
20
  var _jsxRuntime = require("react/jsx-runtime");
21
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
22
  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); }
@@ -32,8 +32,12 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
32
32
  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; }
33
33
  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; } }
34
34
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
35
- var token = (0, _getToken.default)();
35
+ function _readOnlyError(name) { throw new TypeError("\"" + name + "\" is read-only"); }
36
36
  function VtxImport(props) {
37
+ var token = (0, _getToken.default)();
38
+ if (props.token) {
39
+ props.token, _readOnlyError("token");
40
+ }
37
41
  var intl = (0, _vtxProvider.useIntl)();
38
42
  var _useContext = (0, _react.useContext)(_vtxProvider.VtxProvider),
39
43
  getPrefixCls = _useContext.getPrefixCls;
@@ -41,14 +45,19 @@ function VtxImport(props) {
41
45
  var _useStyle = (0, _index.useStyle)(prefixCls),
42
46
  wrapSSR = _useStyle.wrapSSR,
43
47
  hashId = _useStyle.hashId;
48
+
49
+ // 用 useRef 管理 DOM 引用,而不是 state
50
+ var fileInputRef = (0, _react.useRef)(null);
51
+ var iframeRef = (0, _react.useRef)(null);
52
+ var formRef = (0, _react.useRef)(null);
53
+
54
+ // 用于追踪当前 XHR 请求,方便取消
55
+ var xhrRef = (0, _react.useRef)(null);
44
56
  var indexRef = (0, _react.useRef)(0);
45
57
  var _useSet = (0, _useSet3.default)({
46
- fileForm: null,
47
- // form表单
48
- fileInput: null,
49
- // 保存上传的文件
50
- iframe: null,
51
- // form表单提交之后跳转的
58
+ // fileForm: null, // form表单
59
+ // fileInput: null, // 保存上传的文件
60
+ // iframe: null, // form表单提交之后跳转的
52
61
  useFormData: window.FormData ? true : false,
53
62
  // 是否查看
54
63
  uploading: false,
@@ -76,7 +85,8 @@ function VtxImport(props) {
76
85
  currentIndex: 0,
77
86
  chunkId: '',
78
87
  chunks: [],
79
- operation: props.operation || intl.getMessage('import.operation', '导入')
88
+ operation: props.operation || intl.getMessage('import.operation', '导入'),
89
+ fileName: ''
80
90
  }),
81
91
  _useSet2 = _slicedToArray(_useSet, 2),
82
92
  state = _useSet2[0],
@@ -111,7 +121,7 @@ function VtxImport(props) {
111
121
  data.append('chunkNo', i + 1);
112
122
  data.append('chunkId', state.chunkId);
113
123
  data.append('tenantId', (0, _utils.getVtxToken)('tenantId'));
114
- data.append('file', new File([e], state.fileInput.files[0].name));
124
+ data.append('file', new File([e], fileInputRef.current.files[0].name));
115
125
  dataArr.push(data);
116
126
  });
117
127
  uploadAsync(dataArr);
@@ -121,6 +131,7 @@ function VtxImport(props) {
121
131
  function uploadAsync(list) {
122
132
  if (indexRef.current < list.length) {
123
133
  var xhr = new XMLHttpRequest();
134
+ xhrRef.current = xhr;
124
135
  xhr.onload = function () {
125
136
  if (xhr.status === 200) {
126
137
  setState({
@@ -144,15 +155,27 @@ function VtxImport(props) {
144
155
  // 合并分片
145
156
  function mergeFile() {
146
157
  var xhr = new XMLHttpRequest();
158
+ xhrRef.current = xhr;
147
159
  // 当上传完成时调用
148
160
  xhr.onload = function () {
149
161
  if (xhr.status === 200) {
150
- var res = JSON.parse(xhr.responseText);
151
- if ((res === null || res === void 0 ? void 0 : res.result) == 0) {
162
+ var _res;
163
+ var res;
164
+ try {
165
+ res = JSON.parse(xhr.responseText);
166
+ } catch (e) {
167
+ _antd.message.error(intl.getMessage('import.error', '解析响应失败'));
168
+ setState({
169
+ uploading: false
170
+ });
171
+ return;
172
+ }
173
+ if (((_res = res) === null || _res === void 0 ? void 0 : _res.result) == 0) {
152
174
  _antd.message.success(intl.getMessage('import.success', '上传成功'));
153
175
  chunkUpload(res.data);
154
176
  } else {
155
- _antd.message.error((res === null || res === void 0 ? void 0 : res.msg) || intl.getMessage('import.error', '上传失败'));
177
+ var _res2;
178
+ _antd.message.error(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.msg) || intl.getMessage('import.error', '上传失败'));
156
179
  }
157
180
  }
158
181
  };
@@ -161,11 +184,13 @@ function VtxImport(props) {
161
184
  };
162
185
  // 发送请求
163
186
  xhr.open('POST', '/cloudFile/common/mergeChunk', true);
187
+ xhr.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
188
+ xhr.setRequestHeader('access_token', token ? "".concat(token) : '');
164
189
  var data = new FormData();
165
190
  data.append('chunkId', state.chunkId);
166
191
  data.append('tenantId', (0, _utils.getVtxToken)('tenantId'));
167
192
  data.append('chunkSize', state.chunks.length);
168
- data.append('fileName', state.fileInput.files[0].name);
193
+ data.append('fileName', fileInputRef.current.files[0].name);
169
194
  xhr.send(data);
170
195
  }
171
196
 
@@ -175,6 +200,7 @@ function VtxImport(props) {
175
200
  var postData = props.postData || {};
176
201
  if (state.useFormData) {
177
202
  var request = new XMLHttpRequest();
203
+ xhrRef.current = request;
178
204
  // 发送请求
179
205
  request.open('POST', postUrl);
180
206
  request.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
@@ -205,6 +231,7 @@ function VtxImport(props) {
205
231
  var postData = props.postData || {};
206
232
  if (state.useFormData) {
207
233
  var request = new XMLHttpRequest();
234
+ xhrRef.current = request;
208
235
  // 发送请求
209
236
  request.open('POST', postUrl);
210
237
  request.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
@@ -225,7 +252,7 @@ function VtxImport(props) {
225
252
  };
226
253
  //创建formdata对象
227
254
  var fmd = new FormData();
228
- fmd.append(state.fileKey, state.fileInput.files[0]);
255
+ fmd.append(state.fileKey, fileInputRef.current.files[0]);
229
256
  request.send(fmd);
230
257
  }
231
258
  }
@@ -256,7 +283,9 @@ function VtxImport(props) {
256
283
  return postArray.length > 0 ? "".concat(postUrl, "?").concat(postArray.join('&')) : postUrl;
257
284
  };
258
285
  var closeModal = function closeModal() {
259
- state.fileInput.value = '';
286
+ if (fileInputRef.current) {
287
+ fileInputRef.current.value = '';
288
+ }
260
289
  if (typeof props.close === 'function') {
261
290
  props.close();
262
291
  } else {
@@ -267,15 +296,24 @@ function VtxImport(props) {
267
296
  };
268
297
  // 上传之后的回调 - 展示报错信息
269
298
  var uploadSuccess = function uploadSuccess(data) {
270
- state.fileInput.value = '';
299
+ var _parseData;
300
+ if (fileInputRef.current) {
301
+ fileInputRef.current.value = '';
302
+ }
271
303
  setState({
272
304
  uploading: false
273
305
  });
306
+ var parseData;
307
+ try {
308
+ parseData = JSON.parse(data);
309
+ } catch (e) {
310
+ _antd.message.error(intl.getMessage('import.error', '解析响应数据失败'));
311
+ return;
312
+ }
274
313
  if (typeof props.afterUpload === 'function') {
275
314
  afterUpload(data);
276
315
  }
277
- var parseData = JSON.parse(data);
278
- if (Array.isArray(parseData === null || parseData === void 0 ? void 0 : parseData.data)) {
316
+ if (Array.isArray((_parseData = parseData) === null || _parseData === void 0 ? void 0 : _parseData.data)) {
279
317
  setState({
280
318
  resultVisible: true,
281
319
  resultData: parseData.data.map(function (item, index) {
@@ -290,7 +328,8 @@ function VtxImport(props) {
290
328
  } else {
291
329
  // 新增其他错误提示
292
330
  if (parseData.result !== 0) {
293
- _antd.message.error((parseData === null || parseData === void 0 ? void 0 : parseData.msg) || intl.getMessage('import.success', '上传成功'));
331
+ var _parseData2;
332
+ _antd.message.error(((_parseData2 = parseData) === null || _parseData2 === void 0 ? void 0 : _parseData2.msg) || intl.getMessage('import.success', '上传成功'));
294
333
  }
295
334
  }
296
335
  };
@@ -305,7 +344,10 @@ function VtxImport(props) {
305
344
  onCancel: function onCancel() {
306
345
  return closeModal();
307
346
  },
308
- maskClosable: false,
347
+ // maskClosable: false,
348
+ mask: {
349
+ closable: false
350
+ },
309
351
  footer: [templateURL ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
310
352
  onClick: function onClick() {
311
353
  window.open(templateURL);
@@ -315,22 +357,21 @@ function VtxImport(props) {
315
357
  type: "primary",
316
358
  loading: state.uploading,
317
359
  onClick: function onClick() {
360
+ var _fileInputRef$current2;
318
361
  if (typeof props.beforeUpload === 'function') {
319
- var flag = beforeUpload(state.fileInput.files[0]);
362
+ var _fileInputRef$current;
363
+ 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
364
  if (!flag) {
321
- state.fileInput.value = '';
322
- setState({
323
- fileInput: null
324
- });
365
+ fileInputRef.current.value = '';
325
366
  return;
326
367
  }
327
368
  }
328
- if (state.fileInput.value) {
369
+ if ((_fileInputRef$current2 = fileInputRef.current) !== null && _fileInputRef$current2 !== void 0 && _fileInputRef$current2.value) {
329
370
  setState({
330
371
  uploading: true
331
372
  });
332
373
  // 上传文件
333
- checkFile(state.fileInput.files[0]);
374
+ checkFile(fileInputRef.current.files[0]);
334
375
  // const postUrl = getPostURL();
335
376
  // if (state.useFormData) {
336
377
  // const request = new XMLHttpRequest();
@@ -359,7 +400,8 @@ function VtxImport(props) {
359
400
  closeModal();
360
401
  },
361
402
  children: intl.getMessage('switch.close', '关闭')
362
- }, "closeWindow")]
403
+ }, "closeWindow")],
404
+ width: 520
363
405
  };
364
406
  var resultProps = {
365
407
  visible: state.resultVisible,
@@ -372,36 +414,106 @@ function VtxImport(props) {
372
414
  },
373
415
  modalWidth: state.modalWidth
374
416
  };
417
+
418
+ // 组件卸载时清理
419
+ (0, _react.useEffect)(function () {
420
+ return function () {
421
+ // 取消进行中的 XHR 请求
422
+ if (xhrRef.current) {
423
+ xhrRef.current.abort();
424
+ xhrRef.current = null;
425
+ }
426
+ // 清理文件输入
427
+ if (fileInputRef.current) {
428
+ fileInputRef.current.value = '';
429
+ }
430
+ };
431
+ }, []);
375
432
  (0, _react.useEffect)(function () {
376
433
  if (state.chunkId) {
377
434
  startUpload();
378
435
  }
379
436
  }, [state.chunkId]);
380
- return wrapSSR( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Modal, _objectSpread(_objectSpread({}, modalProps), {}, {
381
- children: [props.children, /*#__PURE__*/(0, _jsxRuntime.jsx)("form", {
437
+ var truncateFileName = function truncateFileName(fileName) {
438
+ var maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 28;
439
+ if (fileName.length <= maxLength) return fileName;
440
+ var extIndex = fileName.lastIndexOf('.');
441
+ var ext = extIndex !== -1 ? fileName.slice(extIndex) : '';
442
+ var name = extIndex !== -1 ? fileName.slice(0, extIndex) : fileName;
443
+ var availableLength = maxLength - ext.length - 3; // 3 是 "..."
444
+ if (availableLength <= 0) return "...".concat(ext);
445
+ var startLength = Math.ceil(availableLength / 2);
446
+ var endLength = Math.floor(availableLength / 2);
447
+ var start = name.slice(0, startLength);
448
+ var end = name.slice(-endLength);
449
+ return "".concat(start, "...").concat(end).concat(ext);
450
+ };
451
+
452
+ // 处理文件选择变化
453
+ var handleFileChange = function handleFileChange(event) {
454
+ var _event$target$files;
455
+ var file = (_event$target$files = event.target.files) === null || _event$target$files === void 0 ? void 0 : _event$target$files[0];
456
+ if (file) {
457
+ setState(function (prev) {
458
+ return _objectSpread(_objectSpread({}, prev), {}, {
459
+ fileName: truncateFileName(file.name)
460
+ });
461
+ });
462
+ // 这里可以添加文件上传或其他处理逻辑
463
+ // 例如:uploadFile(file);
464
+ } else {
465
+ setState(function (prev) {
466
+ return _objectSpread(_objectSpread({}, prev), {}, {
467
+ fileName: ''
468
+ });
469
+ });
470
+ }
471
+ };
472
+ var handleSelectFile = function handleSelectFile() {
473
+ var _fileInputRef$current3;
474
+ (_fileInputRef$current3 = fileInputRef.current) === null || _fileInputRef$current3 === void 0 || _fileInputRef$current3.click();
475
+ };
476
+ return wrapSSR( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_vtxModal.default, _objectSpread(_objectSpread({}, modalProps), {}, {
477
+ children: [props.children, /*#__PURE__*/(0, _jsxRuntime.jsxs)("form", {
382
478
  encType: "multipart/form-data",
383
479
  method: "post",
384
480
  target: "tmp",
385
481
  action: uploadURL,
386
- ref: function ref(dom) {
387
- if (dom) state.fileForm = dom;
388
- },
389
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
482
+ ref: formRef,
483
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
484
+ className: "".concat(prefixCls, "-btn"),
485
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
486
+ onClick: handleSelectFile,
487
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
488
+ className: "".concat(prefixCls, "-label"),
489
+ children: intl.getMessage('import.selectFile', '选择文件')
490
+ })
491
+ }), state.fileName ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Tooltip, {
492
+ title: state.fileName,
493
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
494
+ className: "".concat(prefixCls, "-file-name"),
495
+ children: state.fileName
496
+ })
497
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
498
+ className: "".concat(prefixCls, "-file-name"),
499
+ children: intl.getMessage('import.noFileSelected', '未选择任何文件')
500
+ })]
501
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
390
502
  type: "file",
391
503
  name: state.fileKey,
392
504
  accept: state.accept,
393
- ref: function ref(dom) {
394
- if (dom) state.fileInput = dom;
395
- }
396
- })
505
+ ref: fileInputRef,
506
+ style: {
507
+ display: 'none'
508
+ },
509
+ onChange: handleFileChange
510
+ })]
397
511
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("iframe", {
398
512
  name: "tmp",
399
513
  style: {
400
514
  display: 'none'
401
515
  },
402
- ref: function ref(dom) {
403
- if (dom) state.iframe = dom;
404
- }
516
+ ref: iframeRef
405
517
  }), state.resultVisible && /*#__PURE__*/(0, _jsxRuntime.jsx)(_result.default, _objectSpread({}, resultProps))]
406
518
  })));
407
519
  }
@@ -11,6 +11,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
  var _useSet3 = _interopRequireDefault(require("../utils/useSet"));
12
12
  var _vtxDatagrid = _interopRequireDefault(require("../vtx-datagrid"));
13
13
  var _vtxProvider = require("../vtx-provider");
14
+ var _vtxModal = _interopRequireDefault(require("../vtx-modal"));
14
15
  var _jsxRuntime = require("react/jsx-runtime");
15
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -46,7 +47,10 @@ function VtxImportResult(props) {
46
47
  }
47
48
  },
48
49
  width: state.modalWidth,
49
- maskClosable: false,
50
+ // maskClosable: false,
51
+ mask: {
52
+ closable: false
53
+ },
50
54
  footer: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
51
55
  onClick: function onClick() {
52
56
  if (typeof props.hideVisible === 'function') {
@@ -65,7 +69,7 @@ function VtxImportResult(props) {
65
69
  pagination: false,
66
70
  autoFit: false
67
71
  };
68
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Modal, _objectSpread(_objectSpread({}, modalProps), {}, {
72
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_vtxModal.default, _objectSpread(_objectSpread({}, modalProps), {}, {
69
73
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
70
74
  style: {
71
75
  maxHeight: 600,
@@ -13,7 +13,22 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
13
13
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
14
  var genVtxImportStyle = function genVtxImportStyle(token) {
15
15
  var componentCls = token.componentCls;
16
- return _defineProperty({}, componentCls, {});
16
+ return _defineProperty({}, componentCls, _defineProperty({
17
+ '.ant-modal-container': {
18
+ padding: 0,
19
+ '.ant-modal-header': {
20
+ padding: 20
21
+ },
22
+ '.ant-modal-body': {
23
+ padding: 20
24
+ }
25
+ }
26
+ }, '&-btn', {
27
+ display: 'flex',
28
+ justifyContent: 'flex-start',
29
+ alignItems: 'center',
30
+ gap: 8
31
+ }));
17
32
  };
18
33
  function useStyle(prefixCls) {
19
34
  return (0, _vtxProvider.useStyle)('VtxImport', function (token) {
@@ -107,6 +107,7 @@ Content.propTypes = {
107
107
  customText: _propTypes.default.string,
108
108
  extraText: _propTypes.default.string,
109
109
  TextEnum: _propTypes.default.object,
110
- extraDom: [_propTypes.default.string, _propTypes.default.node]
110
+ // extraDom: [PropTypes.string, PropTypes.node],
111
+ extraDom: _propTypes.default.object
111
112
  };
112
113
  var _default = exports.default = Content;
@@ -18,6 +18,7 @@ var _utils = require("@vtx/utils");
18
18
  var _classnames = _interopRequireDefault(require("classnames"));
19
19
  var _index = require("./style/index");
20
20
  var _vtxProvider = require("../vtx-provider");
21
+ var _vtxModal = _interopRequireDefault(require("../vtx-modal"));
21
22
  var _jsxRuntime = require("react/jsx-runtime");
22
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
24
  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); }
@@ -40,7 +41,8 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
40
41
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
41
42
  function getFileName() {
42
43
  var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
43
- var intl = (0, _vtxProvider.useIntl)();
44
+ var _ref = arguments.length > 1 ? arguments[1] : undefined,
45
+ intl = _ref.intl;
44
46
  var index = name.lastIndexOf('.');
45
47
  var suffix = name.substring(index);
46
48
  return name.substring(0, index) + "(".concat(intl.getMessage('import.errorFile', '错误文件'), ")") + suffix;
@@ -49,17 +51,20 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
49
51
  var intl = (0, _vtxProvider.useIntl)();
50
52
  var _useContext = (0, _react.useContext)(_vtxProvider.VtxProvider),
51
53
  getPrefixCls = _useContext.getPrefixCls;
52
- var prefixCls = getPrefixCls('import2', props.prefixCls);
54
+ var prefixCls = getPrefixCls('', 'vtx-import2');
53
55
  var _useStyle = (0, _index.useStyle)(prefixCls),
54
56
  wrapSSR = _useStyle.wrapSSR,
55
57
  hashId = _useStyle.hashId;
56
58
  var visible = props.visible,
57
59
  close = props.close,
58
60
  title = props.title,
59
- accept = props.accept,
60
- fileKey = props.fileKey,
61
+ _props$accept = props.accept,
62
+ accept = _props$accept === void 0 ? 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,text/csv' : _props$accept,
63
+ _props$fileKey = props.fileKey,
64
+ fileKey = _props$fileKey === void 0 ? 'file' : _props$fileKey,
61
65
  uploadURL = props.uploadURL,
62
- postData = props.postData,
66
+ _props$postData = props.postData,
67
+ postData = _props$postData === void 0 ? {} : _props$postData,
63
68
  errorURL = props.errorURL,
64
69
  templateURL = props.templateURL,
65
70
  afterUpload = props.afterUpload,
@@ -138,7 +143,7 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
138
143
  state = _useSet2[0],
139
144
  setState = _useSet2[1];
140
145
  var token = (0, _getToken.default)();
141
- if (!token) {
146
+ if (props.token) {
142
147
  token = props.token;
143
148
  }
144
149
  var newErrorDownloadName = errorDownloadName;
@@ -153,7 +158,9 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
153
158
  }, interval);
154
159
  (0, _react.useEffect)(function () {
155
160
  if (fileList.length !== 0) {
156
- fileName.current = getFileName(fileList[0].name);
161
+ fileName.current = getFileName(fileList[0].name, {
162
+ intl: intl
163
+ });
157
164
  }
158
165
  }, [fileList]);
159
166
 
@@ -208,6 +215,8 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
208
215
  };
209
216
  // 发送请求
210
217
  xhr.open('POST', '/cloudFile/common/uploadChunk', true);
218
+ xhr.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
219
+ xhr.setRequestHeader('access_token', token ? "".concat(token) : '');
211
220
  xhr.send(list[indexRef.current]);
212
221
  } else {
213
222
  mergeFile();
@@ -221,7 +230,7 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
221
230
  if (xhr.status === 200) {
222
231
  var res = JSON.parse(xhr.responseText);
223
232
  if ((res === null || res === void 0 ? void 0 : res.result) == 0) {
224
- _antd.message.success('上传成功');
233
+ _antd.message.success(intl.getMessage('import.success', '上传成功'));
225
234
  chunkUpload(res.data);
226
235
  } else {
227
236
  _antd.message.error((res === null || res === void 0 ? void 0 : res.msg) || intl.getMessage('import.error', '上传失败'));
@@ -233,6 +242,8 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
233
242
  };
234
243
  // 发送请求
235
244
  xhr.open('POST', '/cloudFile/common/mergeChunk', true);
245
+ xhr.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
246
+ xhr.setRequestHeader('access_token', token ? "".concat(token) : '');
236
247
  var data = new FormData();
237
248
  data.append('chunkId', state.chunkId);
238
249
  data.append('tenantId', (0, _utils.getVtxToken)('tenantId'));
@@ -253,6 +264,7 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
253
264
  }
254
265
  request.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
255
266
  request.setRequestHeader('access_token', token ? "".concat(token) : '');
267
+ request.setRequestHeader('systemCode', (0, _utils.getUrlParam)('systemCode') ? (0, _utils.getUrlParam)('systemCode') : '');
256
268
  // 添加操作日志
257
269
  request.setRequestHeader('operation', encodeURIComponent(JSON.stringify({
258
270
  menuId: sessionStorage.getItem('vtxmenuselectedKeys'),
@@ -335,9 +347,9 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
335
347
  }
336
348
  }
337
349
  };
338
- var onUpload = function onUpload(_ref) {
339
- var _ref$files = _ref.files,
340
- files = _ref$files === void 0 ? fileList : _ref$files;
350
+ var onUpload = function onUpload(_ref2) {
351
+ var _ref2$files = _ref2.files,
352
+ files = _ref2$files === void 0 ? fileList : _ref2$files;
341
353
  if (typeof props.beforeUpload === 'function') {
342
354
  var flag = beforeUpload(files[0]);
343
355
  if (!flag) {
@@ -372,7 +384,10 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
372
384
  var modelProps = {
373
385
  open: visible,
374
386
  width: width || 392,
375
- maskClosable: false,
387
+ // maskClosable: false,
388
+ mask: {
389
+ closable: false
390
+ },
376
391
  footer: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
377
392
  onClick: close,
378
393
  children: "".concat(TextEnum.btnCloseText).concat(status === 1 && result ? '(' + countdown + ')' : '')
@@ -394,7 +409,7 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
394
409
  })]
395
410
  })
396
411
  };
397
- return wrapSSR( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Modal, _objectSpread(_objectSpread({}, modelProps), {}, {
412
+ return wrapSSR( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_vtxModal.default, _objectSpread(_objectSpread({}, modelProps), {}, {
398
413
  children: [status === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Content.default, {
399
414
  prefixCls: prefixCls,
400
415
  fileList: fileList,
@@ -428,11 +443,6 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
428
443
  })]
429
444
  })));
430
445
  };
431
- VtxImport2.defaultProps = {
432
- fileKey: 'file',
433
- accept: 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,text/csv',
434
- postData: {}
435
- };
436
446
  VtxImport2.propTypes = {
437
447
  visible: _propTypes.default.bool,
438
448
  templateURL: _propTypes.default.string,
@@ -453,6 +463,7 @@ VtxImport2.propTypes = {
453
463
  beforeUpload: _propTypes.default.func,
454
464
  chunkSize: _propTypes.default.number,
455
465
  width: _propTypes.default.number,
456
- extraDom: [_propTypes.default.string, _propTypes.default.node]
466
+ // extraDom: [PropTypes.string, PropTypes.node],
467
+ extraDom: _propTypes.default.object
457
468
  };
458
469
  var _default = exports.default = VtxImport2;