@bit-sun/business-component 4.2.0-alpha.6.9 → 4.2.5-per-alpha.1

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 (88) hide show
  1. package/.umirc.ts +14 -10
  2. package/dist/components/Business/AddSelectBusiness/index.d.ts +3 -4
  3. package/dist/components/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +1 -2
  4. package/dist/components/Business/BsLayouts/Components/ChooseStore/index.d.ts +1 -2
  5. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +1 -1
  6. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.d.ts +1 -1
  7. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.d.ts +2 -2
  8. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.d.ts +1 -2
  9. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.d.ts +1 -2
  10. package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +1 -1
  11. package/dist/components/Business/BsLayouts/Components/GlobalHeader/index.d.ts +1 -2
  12. package/dist/components/Business/BsLayouts/Components/RightContent/LoginModal.d.ts +1 -2
  13. package/dist/components/Business/BsLayouts/index.d.ts +1 -1
  14. package/dist/components/Business/BsSulaQueryTable/SearchItemSetting.d.ts +19 -8
  15. package/dist/components/Business/BsSulaQueryTable/index.d.ts +1 -2
  16. package/dist/components/Business/BsSulaQueryTable/setting.d.ts +9 -17
  17. package/dist/components/Business/BsSulaQueryTable/utils.d.ts +14 -15
  18. package/dist/components/Business/CommodityEntry/index.d.ts +1 -2
  19. package/dist/components/Business/CommonAlert/index.d.ts +1 -2
  20. package/dist/components/Business/CommonGuideWrapper/index.d.ts +3 -3
  21. package/dist/components/Business/DetailPageWrapper/index.d.ts +11 -12
  22. package/dist/components/Business/HomePageWrapper/index.d.ts +1 -2
  23. package/dist/components/Business/ItemPropertySelector/index.d.ts +1 -2
  24. package/dist/components/Business/JsonQueryTable/components/FieldsModifyModal.d.ts +1 -2
  25. package/dist/components/Business/JsonQueryTable/components/FieldsSettingsTable.d.ts +1 -2
  26. package/dist/components/Business/JsonQueryTable/components/Formula.d.ts +1 -2
  27. package/dist/components/Business/JsonQueryTable/components/MaintainOptions.d.ts +1 -2
  28. package/dist/components/Business/JsonQueryTable/drawer/index.d.ts +1 -2
  29. package/dist/components/Business/PropertyModal/index.d.ts +1 -2
  30. package/dist/components/Business/PropertyModal/propertyGroup.d.ts +1 -1
  31. package/dist/components/Business/SearchSelect/index.d.ts +1 -1
  32. package/dist/components/Business/StateFlow/index.d.ts +1 -2
  33. package/dist/components/Business/TreeSearchSelect/index.d.ts +1 -1
  34. package/dist/components/Business/columnSettingTable/columnSetting.d.ts +6 -6
  35. package/dist/components/Business/columnSettingTable/components/TableSumComponent.d.ts +1 -2
  36. package/dist/components/Business/columnSettingTable/index.d.ts +3 -3
  37. package/dist/components/Business/columnSettingTable/sulaSettingTable.d.ts +3 -3
  38. package/dist/components/Business/columnSettingTable/utils.d.ts +1 -2
  39. package/dist/components/Business/moreTreeTable/FixedScrollBar.d.ts +1 -1
  40. package/dist/components/Common/ParagraphCopier/index.d.ts +1 -1
  41. package/dist/components/Common/Section/index.d.ts +1 -1
  42. package/dist/components/Functional/AddSelect/index.d.ts +1 -2
  43. package/dist/components/Functional/AuthButton/index.d.ts +1 -2
  44. package/dist/components/Functional/DataImport/index.d.ts +4 -4
  45. package/dist/components/Functional/DataValidation/index.d.ts +5 -5
  46. package/dist/components/Functional/ExportFunctions/ExportIcon/index.d.ts +1 -2
  47. package/dist/components/Functional/QueryMutipleInput/index.d.ts +1 -2
  48. package/dist/components/Functional/QueryMutipleSelect/index.d.ts +1 -2
  49. package/dist/components/Functional/SearchSelect/index.d.ts +1 -1
  50. package/dist/components/Functional/SearchSelect/utils.d.ts +2 -3
  51. package/dist/components/Functional/TreeSearchSelect/index.d.ts +1 -2
  52. package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/CustomSelectorModal.d.ts +1 -1
  53. package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/index.d.ts +1 -2
  54. package/dist/components/Solution/RuleComponent/Formula.d.ts +1 -2
  55. package/dist/components/Solution/RuleComponent/InnerSelect.d.ts +1 -2
  56. package/dist/components/Solution/RuleComponent/RenderCompItem.d.ts +1 -2
  57. package/dist/components/Solution/RuleSetter/RuleInstance.d.ts +1 -2
  58. package/dist/components/Solution/RuleSetter/baseRule.d.ts +1 -1
  59. package/dist/components/Solution/RuleSetter/index.d.ts +1 -1
  60. package/dist/index.d.ts +0 -1
  61. package/dist/index.esm.js +2349 -1832
  62. package/dist/index.js +2341 -1826
  63. package/dist/plugin/TableColumnSetting/index.d.ts +5 -5
  64. package/dist/utils/TableUtils.d.ts +18 -19
  65. package/dist/utils/luckysheetLoader.d.ts +21 -0
  66. package/dist/utils/utils.d.ts +0 -41
  67. package/package.json +1 -1
  68. package/src/components/Business/BsLayouts/index.tsx +485 -129
  69. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +144 -4
  70. package/src/components/Business/BsSulaQueryTable/index.md +120 -0
  71. package/src/components/Business/BsSulaQueryTable/index.tsx +236 -22
  72. package/src/components/Business/BsSulaQueryTable/setting.tsx +232 -17
  73. package/src/components/Business/DetailPageWrapper/index.tsx +30 -27
  74. package/src/components/Business/HomePageWrapper/index.tsx +10 -8
  75. package/src/components/Business/SearchSelect/BusinessUtils.tsx +38 -234
  76. package/src/components/Business/columnSettingTable/index.tsx +6 -7
  77. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +22 -23
  78. package/src/components/Functional/AddSelect/index.tsx +0 -92
  79. package/src/components/Functional/DataImport/index.tsx +76 -3
  80. package/src/components/Functional/DataValidation/index.tsx +81 -3
  81. package/src/components/Functional/SearchSelect/index.tsx +2 -5
  82. package/src/components/Solution/RuleComponent/index.js +0 -1
  83. package/src/index.ts +0 -2
  84. package/src/utils/luckysheetLoader.ts +164 -0
  85. package/src/utils/utils.ts +1 -41
  86. package/dist/components/Business/SystemLog/index.d.ts +0 -78
  87. package/src/components/Business/SystemLog/index.md +0 -37
  88. package/src/components/Business/SystemLog/index.tsx +0 -87
@@ -222,98 +222,6 @@ const AddSelect = (props: any) => {
222
222
  acc[key] = typeof value === 'function' ? value?.(record) : value;
223
223
  return acc;
224
224
  }, {});
225
-
226
- // 可输入非数字字符
227
- if(item.canInputString) {
228
- return (
229
- <InputNumber
230
- min={0}
231
- precision={0}
232
- controls={false}
233
- {...inputProps}
234
- value={text || ''}
235
- keyboard={false}
236
- onPressEnter={(e: any) => {
237
- e.target.blur();
238
- }}
239
- onBlur={async (e: any) => {
240
- const {
241
- target: { value },
242
- } = e;
243
- record[item.dataIndex] = value
244
- editRecord(record)
245
- }}
246
- onKeyDown={(e) => {
247
- if(e.keyCode === 13 && e.ctrlKey) {
248
- handleOk(true)
249
- document.getElementById("first-query")?.focus()
250
- }
251
- if(e.keyCode === 8 && e.ctrlKey) {
252
- message.success('删除当前行')
253
- e.stopPropagation();
254
- e.preventDefault();
255
- let dom = e.nativeEvent.path[5].children[index + 2]?.getElementsByTagName('input')[currentIndex]
256
- if (dom) {
257
- dom.select();
258
- dom.focus();
259
- dom.scrollIntoView(false)
260
- }
261
- dom = null
262
- deleteRecord(record, popvalue);
263
- }
264
- if (e.keyCode === 37 && e.shiftKey) { // 左滑动
265
- e.stopPropagation();
266
- e.preventDefault();
267
- let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex - 1]
268
- if (dom) {
269
- dom.select();
270
- dom.focus();
271
- dom.scrollIntoView(false)
272
- }
273
- dom = null
274
- }
275
- if (e.keyCode === 39 && e.shiftKey) { // 右滑
276
- e.stopPropagation();
277
- e.preventDefault();
278
- let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex + 1]
279
- if (dom) {
280
- dom.select();
281
- dom.focus();
282
- dom.scrollIntoView(false)
283
- }
284
- dom = null
285
- }
286
- if (e.keyCode === 40) {
287
- e.stopPropagation();
288
- e.preventDefault();
289
- let dom = e.nativeEvent.path[5].children[index + 2]?.getElementsByTagName('input')[currentIndex]
290
- if (dom) {
291
- dom.select();
292
- dom.focus();
293
- dom.scrollIntoView(false)
294
- }
295
- dom = null
296
- } else if (e.keyCode === 38) {
297
- e.stopPropagation();
298
- e.preventDefault();
299
- let dom1 = e.nativeEvent.path[5].children[index]?.getElementsByTagName('input')[currentIndex]
300
- if (dom1) {
301
- // dom1.value=""
302
- // dom1.setSelectionRange(100, 0);
303
- dom1.select();
304
- dom1.focus();
305
- dom1.scrollIntoViewIfNeeded(false)
306
- // dom1.value=record['count']
307
- }
308
- dom1 = null
309
- } else if (e.keyCode === 9 && index === selectedRowKeys.length - 1 && currentIndex === inputLength - 1) {
310
- e.stopPropagation();
311
- e.preventDefault();
312
- }
313
- }}
314
- />
315
- );
316
- }
317
225
 
318
226
  return (
319
227
  <InputNumber
@@ -17,7 +17,8 @@ import {
17
17
  Menu,
18
18
  Tooltip,
19
19
  message,
20
- Upload
20
+ Upload,
21
+ Spin
21
22
  } from 'antd';
22
23
  import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
23
24
  import {
@@ -31,6 +32,7 @@ import './index.less';
31
32
  import _ from "lodash"
32
33
  import { judgeIsRequestError } from '@/utils/requestUtils';
33
34
  import { readerXlsxToList } from '@/utils/xlsxUtil';
35
+ import { loadLuckysheet } from '@/utils/luckysheetLoader';
34
36
 
35
37
  // const luckysheet = window.luckysheet;
36
38
 
@@ -154,6 +156,9 @@ class DataImport extends React.Component {
154
156
  items: [...itemsTemp],
155
157
  resultData: [],
156
158
  errorListCheck: false,
159
+ luckysheetLoading: false,
160
+ luckysheetLoadError: null,
161
+ luckysheetReady: false,
157
162
  };
158
163
  }
159
164
 
@@ -376,8 +381,32 @@ class DataImport extends React.Component {
376
381
  };
377
382
  };
378
383
 
379
- componentDidMount() {
380
- luckysheet.create(this.setConfig([]));
384
+ async componentDidMount() {
385
+ this.setState({ luckysheetLoading: true });
386
+
387
+ try {
388
+ await loadLuckysheet();
389
+
390
+ // 重新获取luckysheet实例
391
+ luckysheet = window.luckysheet || window.top.luckysheet;
392
+
393
+ if (luckysheet) {
394
+ luckysheet.create(this.setConfig([]));
395
+ this.setState({
396
+ luckysheetReady: true,
397
+ luckysheetLoading: false,
398
+ luckysheetLoadError: null
399
+ });
400
+ } else {
401
+ throw new Error('Luckysheet 加载失败');
402
+ }
403
+ } catch (error) {
404
+ console.error('加载 Luckysheet 失败:', error);
405
+ this.setState({
406
+ luckysheetLoading: false,
407
+ luckysheetLoadError: error.message || '加载失败'
408
+ });
409
+ }
381
410
  }
382
411
 
383
412
  componentWillUnmount() {
@@ -760,6 +789,50 @@ class DataImport extends React.Component {
760
789
  </div>
761
790
 
762
791
  <div style={{ position: 'relative', height: '400px' }}>
792
+ {this.state.luckysheetLoading && (
793
+ <div style={{
794
+ position: 'absolute',
795
+ top: 0,
796
+ left: 0,
797
+ right: 0,
798
+ bottom: 0,
799
+ display: 'flex',
800
+ alignItems: 'center',
801
+ justifyContent: 'center',
802
+ backgroundColor: 'rgba(255, 255, 255, 0.8)',
803
+ zIndex: 1000
804
+ }}>
805
+ <Spin size="large" tip="正在加载 Luckysheet..." />
806
+ </div>
807
+ )}
808
+ {this.state.luckysheetLoadError && (
809
+ <div style={{
810
+ position: 'absolute',
811
+ top: 0,
812
+ left: 0,
813
+ right: 0,
814
+ bottom: 0,
815
+ display: 'flex',
816
+ flexDirection: 'column',
817
+ alignItems: 'center',
818
+ justifyContent: 'center',
819
+ backgroundColor: 'rgba(255, 255, 255, 0.9)',
820
+ zIndex: 1000
821
+ }}>
822
+ <div style={{ marginBottom: 16, color: '#ff4d4f' }}>
823
+ 加载失败: {this.state.luckysheetLoadError}
824
+ </div>
825
+ <Button
826
+ type="primary"
827
+ onClick={() => {
828
+ this.setState({ luckysheetLoadError: null });
829
+ this.componentDidMount();
830
+ }}
831
+ >
832
+ 重新加载
833
+ </Button>
834
+ </div>
835
+ )}
763
836
  <div id="luckysheet" style={luckyCss}></div>
764
837
  </div>
765
838
  {!this.props.notValid && <div className="sheet_table_footer">
@@ -17,7 +17,8 @@ import {
17
17
  Menu,
18
18
  Tooltip,
19
19
  message,
20
- Upload
20
+ Upload,
21
+ Spin
21
22
  } from 'antd';
22
23
  import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
23
24
  import {
@@ -31,6 +32,7 @@ import './index.less';
31
32
  import _, { ceil, isNumber } from "lodash"
32
33
  import { judgeIsRequestError } from '@/utils/requestUtils';
33
34
  import { readerXlsxToList } from '@/utils/xlsxUtil';
35
+ import { loadLuckysheet } from '@/utils/luckysheetLoader';
34
36
 
35
37
  // const luckysheet = window.luckysheet;
36
38
 
@@ -154,6 +156,9 @@ class DataValidation extends React.Component {
154
156
  items: [...itemsTemp],
155
157
  resultData: [],
156
158
  errorListCheck: false,
159
+ luckysheetLoading: false,
160
+ luckysheetLoadError: null,
161
+ luckysheetReady: false,
157
162
  };
158
163
  }
159
164
 
@@ -387,9 +392,38 @@ class DataValidation extends React.Component {
387
392
  };
388
393
  };
389
394
 
390
- componentDidMount() {
395
+ async componentDidMount() {
391
396
  this.props.onRef(this);
392
- luckysheet.create(this.setConfig([]));
397
+
398
+ try {
399
+ // 开始加载 luckysheet
400
+ this.setState({ luckysheetLoading: true, luckysheetLoadError: null });
401
+
402
+ // 动态加载 luckysheet 资源
403
+ await loadLuckysheet();
404
+
405
+ // 更新 luckysheet 引用
406
+ luckysheet = window.luckysheet || window.top.luckysheet;
407
+
408
+ if (!luckysheet) {
409
+ throw new Error('Luckysheet 加载失败,请检查网络连接');
410
+ }
411
+
412
+ // 初始化 luckysheet
413
+ luckysheet.create(this.setConfig([]));
414
+
415
+ this.setState({
416
+ luckysheetLoading: false,
417
+ luckysheetReady: true
418
+ });
419
+
420
+ } catch (error) {
421
+ console.error('DataValidation 组件初始化失败:', error);
422
+ this.setState({
423
+ luckysheetLoading: false,
424
+ luckysheetLoadError: error.message || '加载失败'
425
+ });
426
+ }
393
427
  }
394
428
 
395
429
  componentWillUnmount() {
@@ -878,6 +912,50 @@ customSort = (a, b) => {
878
912
  </div>
879
913
 
880
914
  <div style={{ position: 'relative', height: '400px' }}>
915
+ {this.state.luckysheetLoading && (
916
+ <div style={{
917
+ position: 'absolute',
918
+ top: 0,
919
+ left: 0,
920
+ right: 0,
921
+ bottom: 0,
922
+ display: 'flex',
923
+ alignItems: 'center',
924
+ justifyContent: 'center',
925
+ backgroundColor: 'rgba(255, 255, 255, 0.8)',
926
+ zIndex: 1000
927
+ }}>
928
+ <Spin size="large" tip="正在加载 Luckysheet..." />
929
+ </div>
930
+ )}
931
+ {this.state.luckysheetLoadError && (
932
+ <div style={{
933
+ position: 'absolute',
934
+ top: 0,
935
+ left: 0,
936
+ right: 0,
937
+ bottom: 0,
938
+ display: 'flex',
939
+ alignItems: 'center',
940
+ justifyContent: 'center',
941
+ backgroundColor: 'rgba(255, 255, 255, 0.9)',
942
+ zIndex: 1000,
943
+ flexDirection: 'column'
944
+ }}>
945
+ <div style={{ color: 'red', marginBottom: 16 }}>
946
+ 加载失败: {this.state.luckysheetLoadError}
947
+ </div>
948
+ <Button
949
+ type="primary"
950
+ onClick={() => {
951
+ this.setState({ luckysheetLoadError: null });
952
+ this.componentDidMount();
953
+ }}
954
+ >
955
+ 重新加载
956
+ </Button>
957
+ </div>
958
+ )}
881
959
  <div id="luckysheet" style={luckyCss}></div>
882
960
  </div>
883
961
  {!this.props.notValid && !!totalSummary.total && <div className="sheet_table_footer">
@@ -32,7 +32,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
32
32
  highestPopContainer = undefined,
33
33
  fieldComponent,
34
34
  onSaveCallback,
35
- returnFormat = [],
36
35
  selectBusinessType,
37
36
  } = props;
38
37
  const {
@@ -67,8 +66,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
67
66
  const selectParamsKey = requestConfig?.filter || 'qp-codeAndName-like'
68
67
  const selectParamsInitKey = requestConfig?.filterInit || selectParamsKey
69
68
  const currentSelectProps = {
70
- // 回显字段可自定义
71
- optionLabelProp: "label",
72
69
  ...selectProps,
73
70
  // 以下属性不可更改----设计配置项
74
71
  showArrow: true,
@@ -76,6 +73,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
76
73
  filterOption: false,
77
74
  allowClear: true,
78
75
  listHeight: 160,
76
+ optionLabelProp: "label",
79
77
  autoClearSearchValue: false,
80
78
  placement: 'bottomRight'
81
79
  }
@@ -433,8 +431,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
433
431
 
434
432
  const formaData = (value: any, source: any) => {
435
433
  if (labelInValue) {
436
- const getFromat = (format, val) => format.map(({key,value})=> ({[key]:val[value]}))
437
- const formatResult = value.map((i: any) => (Object.assign({ key: i[mappingValueField] || i.key, label: i[mappingTextField] || i.label, value: i[mappingValueField] || i.value }, ...getFromat(returnFormat, i))))
434
+ const formatResult = value.map((i: any) => ({ key: i[mappingValueField] || i.key, label: i[mappingTextField] || i.label, value: i[mappingValueField] || i.value }))
438
435
  onChange(selectMode ? formatResult : formatResult[0], value,source)
439
436
  } else {
440
437
  const formatResult = selectMode ? value.map((i: any) => i.value) : _.get(value[0], 'value')
@@ -748,7 +748,6 @@ class RuleObjectComponent extends Component {
748
748
  <div
749
749
  className={'rule_line_content'}
750
750
  style={{ display: 'flex', marginBottom: '0px', padding: '10px 0px' }}
751
- key={itemDetail.elementId}
752
751
  >
753
752
  <div
754
753
  className={'logical_operate_content'}
package/src/index.ts CHANGED
@@ -48,5 +48,3 @@ export { default as RuleSetter} from './components/Solution/RuleSetter';
48
48
  export { default as ExtendedCollapse } from './components/Common/ExtendedCollapse';
49
49
  export { default as Section } from './components/Common/Section';
50
50
  export { default as ParagraphCopier } from './components/Common/ParagraphCopier';
51
-
52
- export { default as SystemLog } from './components/Business/SystemLog';
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Luckysheet 动态加载器
3
+ * 实现按需加载 luckysheet 的 CSS 和 JS 资源
4
+ */
5
+
6
+ interface LoaderCache {
7
+ loaded: boolean;
8
+ loading: Promise<void> | null;
9
+ }
10
+
11
+ const cache: LoaderCache = {
12
+ loaded: false,
13
+ loading: null
14
+ };
15
+
16
+ // Luckysheet 资源配置
17
+ const LUCKYSHEET_RESOURCES = {
18
+ css: [
19
+ 'https://bitsun-website.oss-cn-shanghai.aliyuncs.com/cdn/dist/plugins/css/pluginsCss.css',
20
+ 'https://bitsun-website.oss-cn-shanghai.aliyuncs.com/cdn/dist/plugins/plugins.css',
21
+ 'https://bitsun-website.oss-cn-shanghai.aliyuncs.com/cdn/dist/css/luckysheet.css',
22
+ 'https://bitsun-website.oss-cn-shanghai.aliyuncs.com/cdn/dist/assets/iconfont/iconfont.css'
23
+ ],
24
+ js: [
25
+ 'https://bitsun-website.oss-cn-shanghai.aliyuncs.com/cdn/dist/plugins/js/plugin.js',
26
+ 'https://bitsun-website.oss-cn-shanghai.aliyuncs.com/cdn/dist/luckysheet.umd.js'
27
+ ]
28
+ };
29
+
30
+ /**
31
+ * 动态加载 CSS 文件
32
+ * @param url CSS 文件 URL
33
+ * @returns Promise
34
+ */
35
+ function loadCSS(url: string): Promise<void> {
36
+ return new Promise((resolve, reject) => {
37
+ // 检查是否已经加载过该 CSS
38
+ const existingLink = document.querySelector(`link[href="${url}"]`);
39
+ if (existingLink) {
40
+ resolve();
41
+ return;
42
+ }
43
+
44
+ const link = document.createElement('link');
45
+ link.rel = 'stylesheet';
46
+ link.type = 'text/css';
47
+ link.href = url;
48
+
49
+ link.onload = () => resolve();
50
+ link.onerror = () => reject(new Error(`Failed to load CSS: ${url}`));
51
+
52
+ document.head.appendChild(link);
53
+ });
54
+ }
55
+
56
+ /**
57
+ * 动态加载 JS 文件
58
+ * @param url JS 文件 URL
59
+ * @returns Promise
60
+ */
61
+ function loadJS(url: string): Promise<void> {
62
+ return new Promise((resolve, reject) => {
63
+ // 检查是否已经加载过该 JS
64
+ const existingScript = document.querySelector(`script[src="${url}"]`);
65
+ if (existingScript) {
66
+ resolve();
67
+ return;
68
+ }
69
+
70
+ const script = document.createElement('script');
71
+ script.type = 'text/javascript';
72
+ script.src = url;
73
+
74
+ script.onload = () => resolve();
75
+ script.onerror = () => reject(new Error(`Failed to load JS: ${url}`));
76
+
77
+ document.head.appendChild(script);
78
+ });
79
+ }
80
+
81
+ /**
82
+ * 检查 luckysheet 是否可用
83
+ * @returns boolean
84
+ */
85
+ function isLuckysheetAvailable(): boolean {
86
+ return typeof window !== 'undefined' &&
87
+ (window as any).luckysheet !== undefined;
88
+ }
89
+
90
+ /**
91
+ * 动态加载 Luckysheet 资源
92
+ * @returns Promise<void>
93
+ */
94
+ export async function loadLuckysheet(): Promise<void> {
95
+ // 如果已经加载完成,直接返回
96
+ if (cache.loaded && isLuckysheetAvailable()) {
97
+ return Promise.resolve();
98
+ }
99
+
100
+ // 如果正在加载中,返回正在进行的 Promise
101
+ if (cache.loading) {
102
+ return cache.loading;
103
+ }
104
+
105
+ // 开始加载
106
+ cache.loading = (async () => {
107
+ try {
108
+ console.log('开始动态加载 Luckysheet 资源...');
109
+
110
+ // 并行加载所有 CSS 文件
111
+ const cssPromises = LUCKYSHEET_RESOURCES.css.map(url => loadCSS(url));
112
+ await Promise.all(cssPromises);
113
+ console.log('Luckysheet CSS 文件加载完成');
114
+
115
+ // 顺序加载 JS 文件(保证依赖顺序)
116
+ for (const url of LUCKYSHEET_RESOURCES.js) {
117
+ await loadJS(url);
118
+ }
119
+ console.log('Luckysheet JS 文件加载完成');
120
+
121
+ // 等待 luckysheet 对象可用
122
+ let retryCount = 0;
123
+ const maxRetries = 50; // 最多等待 5 秒
124
+
125
+ while (!isLuckysheetAvailable() && retryCount < maxRetries) {
126
+ await new Promise(resolve => setTimeout(resolve, 100));
127
+ retryCount++;
128
+ }
129
+
130
+ if (!isLuckysheetAvailable()) {
131
+ throw new Error('Luckysheet 加载超时,请检查网络连接');
132
+ }
133
+
134
+ cache.loaded = true;
135
+ console.log('Luckysheet 动态加载完成');
136
+
137
+ } catch (error) {
138
+ console.error('Luckysheet 加载失败:', error);
139
+ cache.loading = null; // 重置加载状态,允许重试
140
+ throw error;
141
+ }
142
+ })();
143
+
144
+ return cache.loading;
145
+ }
146
+
147
+ /**
148
+ * 重置加载状态(用于测试或强制重新加载)
149
+ */
150
+ export function resetLuckysheetLoader(): void {
151
+ cache.loaded = false;
152
+ cache.loading = null;
153
+ }
154
+
155
+ /**
156
+ * 获取加载状态
157
+ * @returns 加载状态信息
158
+ */
159
+ export function getLuckysheetLoadStatus(): { loaded: boolean; loading: boolean } {
160
+ return {
161
+ loaded: cache.loaded,
162
+ loading: cache.loading !== null
163
+ };
164
+ }
@@ -267,44 +267,4 @@ export const handleConvertResponse = (items: any, total: number): object => {
267
267
 
268
268
  export const noEmptyArray = (targetObj: any) => {
269
269
  return Array.isArray(targetObj) && targetObj.length !== 0;
270
- };
271
-
272
- export const formContainerAndItemLayout = (type: string, title: any, name: string) => {
273
- return type === 'form' ? {
274
- container: {
275
- type: 'card',
276
- props: {
277
- title,
278
- id: Math.random(),
279
- level: 1,
280
- name
281
- },
282
- },
283
- itemLayout: {
284
- span: 8, // span表示每项所占的栅格数
285
- labelCol: {
286
- span: 8,
287
- },
288
- wrapperCol: {
289
- span: 18,
290
- },
291
- },
292
- } : {
293
- container: {
294
- type: 'card',
295
- props: {
296
- title,
297
- id: Math.random(),
298
- level: 1,
299
- bordered: null,
300
- isWhiteCard: true,
301
- name
302
- },
303
- },
304
- itemLayout: {
305
- wrapperCol: {
306
- span: 0,
307
- },
308
- },
309
- }
310
- }
270
+ };
@@ -1,78 +0,0 @@
1
- declare const SystemLog: ({ modeType, code, containerName, renderLogRef, extraParams, }: {
2
- modeType: string;
3
- code: any;
4
- containerName: string;
5
- renderLogRef: object;
6
- extraParams?: object | undefined;
7
- }) => {
8
- initialVisible: boolean;
9
- fields: {
10
- name: string;
11
- label: boolean;
12
- itemLayout: {
13
- span: number;
14
- labelCol: {
15
- span: number;
16
- };
17
- wrapperCol: {
18
- span: number;
19
- };
20
- };
21
- field: (ctx: any) => any;
22
- }[];
23
- container: {
24
- type: string;
25
- props: {
26
- title: any;
27
- id: number;
28
- level: number;
29
- name: string;
30
- bordered?: undefined;
31
- isWhiteCard?: undefined;
32
- };
33
- };
34
- itemLayout: {
35
- span: number;
36
- labelCol: {
37
- span: number;
38
- };
39
- wrapperCol: {
40
- span: number;
41
- };
42
- };
43
- } | {
44
- initialVisible: boolean;
45
- fields: {
46
- name: string;
47
- label: boolean;
48
- itemLayout: {
49
- span: number;
50
- labelCol: {
51
- span: number;
52
- };
53
- wrapperCol: {
54
- span: number;
55
- };
56
- };
57
- field: (ctx: any) => any;
58
- }[];
59
- container: {
60
- type: string;
61
- props: {
62
- title: any;
63
- id: number;
64
- level: number;
65
- bordered: null;
66
- isWhiteCard: boolean;
67
- name: string;
68
- };
69
- };
70
- itemLayout: {
71
- wrapperCol: {
72
- span: number;
73
- };
74
- span?: undefined;
75
- labelCol?: undefined;
76
- };
77
- };
78
- export default SystemLog;