@lingxiteam/ebe-utils 0.0.10 → 0.0.11

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 (93) hide show
  1. package/README.md +6 -0
  2. package/es/index.d.ts +11 -6
  3. package/es/index.js +63 -52
  4. package/es/node/babel/getAllImportFiles.d.ts +1 -1
  5. package/es/node/babel/getAllImportFiles.js +4 -4
  6. package/es/node/move.d.ts +1 -0
  7. package/es/node/move.js +21 -13
  8. package/lib/h5public/src/components/factory/package.json +4 -0
  9. package/lib/h5public/src/components/factory/src/BlockSelect/index.tsx +9 -1
  10. package/lib/h5public/src/components/factory/src/DynamicDataContainer/index.tsx +24 -5
  11. package/lib/h5public/src/components/factory/src/DynamicList/MySwipe/index.tsx +1 -1
  12. package/lib/h5public/src/hooks/usePageForm.ts +108 -4
  13. package/lib/h5public/src/utils/LcdpSpin/index.tsx +15 -3
  14. package/lib/h5public/src/utils/formUtils.ts +336 -0
  15. package/lib/node/babel/getAllImportFiles.d.ts +1 -1
  16. package/lib/node/babel/getAllImportFiles.js +3 -3
  17. package/lib/node/move.d.ts +1 -0
  18. package/lib/node/move.js +19 -8
  19. package/lib/pcpublic/src/components/common/PreviewFile/index.less +200 -0
  20. package/lib/pcpublic/src/components/common/PreviewFile/index.tsx +787 -0
  21. package/lib/pcpublic/src/components/common/PreviewFile/utils.ts +90 -0
  22. package/lib/pcpublic/src/components/pcfactory/package.json +4 -0
  23. package/lib/pcpublic/src/components/pcfactory/src/Audio/index.tsx +6 -6
  24. package/lib/pcpublic/src/components/pcfactory/src/Cascader/index.tsx +15 -0
  25. package/lib/pcpublic/src/components/pcfactory/src/Checkbox/index.tsx +2 -2
  26. package/lib/pcpublic/src/components/pcfactory/src/DynamicDataContainer/index.tsx +301 -0
  27. package/lib/pcpublic/src/components/pcfactory/src/DynamicDataContainer/useDynamicDataContainer.ts +27 -0
  28. package/lib/pcpublic/src/components/pcfactory/src/Form/Form.tsx +1 -0
  29. package/lib/pcpublic/src/components/pcfactory/src/GridView/GridView.tsx +1 -1
  30. package/lib/pcpublic/src/components/pcfactory/src/Img/assets/placeholder.png +0 -0
  31. package/lib/pcpublic/src/components/pcfactory/src/Input/index.tsx +1 -1
  32. package/lib/pcpublic/src/components/pcfactory/src/LoopList/index.tsx +1 -1
  33. package/lib/pcpublic/src/components/pcfactory/src/ModalSelect/index.tsx +1 -1
  34. package/lib/pcpublic/src/components/pcfactory/src/PictureVerifyCode/assets/placeholder.png +0 -0
  35. package/lib/pcpublic/src/components/pcfactory/src/PictureVerifyCode/index.tsx +6 -6
  36. package/lib/pcpublic/src/components/pcfactory/src/QuillEditor/index.tsx +11 -0
  37. package/lib/pcpublic/src/components/pcfactory/src/RemoteComponent/components/ReactRender.tsx +5 -1
  38. package/lib/pcpublic/src/components/pcfactory/src/RemoteComponent/constant.ts +36 -0
  39. package/lib/pcpublic/src/components/pcfactory/src/RemoteComponent/index.tsx +28 -16
  40. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/RichTextEditor.tsx +12 -5
  41. package/lib/pcpublic/src/components/pcfactory/src/Select/index.tsx +65 -39
  42. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/default.png +0 -0
  43. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/js.png +0 -0
  44. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/pdf.png +0 -0
  45. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/ppt.png +0 -0
  46. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/txt.png +0 -0
  47. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/word.png +0 -0
  48. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/xls.png +0 -0
  49. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/zip.png +0 -0
  50. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/index.tsx +11 -1
  51. package/lib/pcpublic/src/components/pcfactory/src/SuperSelect/ComSelect.tsx +1 -2
  52. package/lib/pcpublic/src/components/pcfactory/src/Table/TableSummaryRow/index.tsx +8 -1
  53. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCMDActions.ts +4 -4
  54. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useColumns.tsx +91 -34
  55. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSelection.ts +22 -11
  56. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSummaryCol.ts +51 -8
  57. package/lib/pcpublic/src/components/pcfactory/src/Table/index.tsx +28 -6
  58. package/lib/pcpublic/src/components/pcfactory/src/Table/types/bodyCell.d.ts +22 -0
  59. package/lib/pcpublic/src/components/pcfactory/src/Table/types/contentStyle.d.ts +41 -0
  60. package/lib/pcpublic/src/components/pcfactory/src/Table/types/event.d.ts +129 -0
  61. package/lib/pcpublic/src/components/pcfactory/src/Table/types/headerCell.d.ts +37 -0
  62. package/lib/pcpublic/src/components/pcfactory/src/Table/types/prop.d.ts +301 -0
  63. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/index.ts +83 -31
  64. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/indexedDBHelper.ts +119 -0
  65. package/lib/pcpublic/src/components/pcfactory/src/Transfer/index.tsx +8 -3
  66. package/lib/pcpublic/src/components/pcfactory/src/Tree/index.tsx +4 -1
  67. package/lib/pcpublic/src/components/pcfactory/src/TreeSelect/index.tsx +12 -1
  68. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/index.tsx +28 -3
  69. package/lib/pcpublic/src/components/pcfactory/src/VerificationCode/assets/placeholder.png +0 -0
  70. package/lib/pcpublic/src/components/pcfactory/src/VerificationCode/index.tsx +6 -6
  71. package/lib/pcpublic/src/components/pcfactory/src/VideoPlayer/index.tsx +12 -12
  72. package/lib/pcpublic/src/components/pcfactory/src/View/index.tsx +18 -4
  73. package/lib/pcpublic/src/components/pcfactory/src/index.component.ts +3 -0
  74. package/lib/pcpublic/src/components/pcfactory/src/styles/common.less +6 -1
  75. package/lib/pcpublic/src/components/pcfactory/src/styles/components/Form.less +4 -0
  76. package/lib/pcpublic/src/components/pcfactory/src/styles/components/Input.less +3 -0
  77. package/lib/pcpublic/src/components/pcfactory/src/styles/components/InputNumber.less +1 -1
  78. package/lib/pcpublic/src/components/pcfactory/src/styles/components/ModalSelect.less +3 -0
  79. package/lib/pcpublic/src/components/pcfactory/src/styles/components/Table.less +5 -0
  80. package/lib/pcpublic/src/components/pcfactory/src/utils/DummyFormContext.ts +2 -2
  81. package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/empty.tsx +29 -28
  82. package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/index.tsx +36 -0
  83. package/lib/pcpublic/src/components/pcfactory/src/utils/Spin/index.tsx +29 -0
  84. package/lib/pcpublic/src/components/pcfactory/src/utils/common.ts +18 -2
  85. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormContext.tsx +10 -0
  86. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormFields.tsx +10 -5
  87. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/common.ts +46 -0
  88. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useCompState.tsx +44 -0
  89. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useLocale.ts +1 -0
  90. package/lib/pcpublic/src/utils/formUtils.ts +458 -0
  91. package/lib/public/src/components/WaterMark/index.tsx +1 -1
  92. package/lib/public/src/services/api/index.ts +7 -0
  93. package/package.json +2 -2
package/README.md CHANGED
@@ -65,6 +65,12 @@ const Page = () => {
65
65
  queryFrontendHookList,
66
66
  findApplication,
67
67
  },
68
+ // 为 true 时,会自动翻译页面名称作为路由 path
69
+ needTranslatePagePathToEnglish: true,
70
+ // 默认为 true,会自动发起浏览器下载 zip 文件
71
+ autoDownloadOnBower: true,
72
+ // 默认为 true,忽略静态文件生成,通过 ebe setup 命令下载静态文件
73
+ useEbeSetup: true,
68
74
  });
69
75
  };
70
76
  return <></>;
package/es/index.d.ts CHANGED
@@ -8,7 +8,6 @@ export declare const treeForEach: (tree: any, callback: (item: any, root: boolea
8
8
  children: string;
9
9
  }) => void;
10
10
  export declare const getPageDsls: (resultObjects: any[]) => any[];
11
- export declare function findAllItem<T = any>(target: T[], callback: (item: T, index: number, list: T[]) => boolean, itemHash: any): void;
12
11
  export declare function findItem<T = any>(target: T[], callback: (item: T, index: number, list: T[]) => boolean): T | null;
13
12
  export declare const cleanTree: (tree: any, fields: any) => any;
14
13
  export declare const clearLXPagesDSL: (pages: any[]) => any[];
@@ -29,6 +28,14 @@ interface CodeServices {
29
28
  chinese: string[];
30
29
  rule: string;
31
30
  }) => Promise<any>;
31
+ qryBusiCompPage: (params: {
32
+ appId: string;
33
+ appIds?: string[];
34
+ statusCd?: string;
35
+ pageNum?: number;
36
+ pageSize?: number;
37
+ terminalType?: string;
38
+ }) => Promise<any>;
32
39
  }
33
40
  export declare const getSafeTypeName: (name: any) => any;
34
41
  interface CodeOptions {
@@ -41,6 +48,8 @@ interface CodeOptions {
41
48
  progress: number;
42
49
  }) => void;
43
50
  needTranslatePagePathToEnglish?: boolean;
51
+ autoDownloadOnBower?: boolean;
52
+ useEbeSetup?: boolean;
44
53
  }
45
54
  export declare const setWorkerJsUrl: (url: string) => void;
46
55
  export declare const init: () => Promise<void>;
@@ -49,7 +58,6 @@ export declare const fetchData: ({ appId, services, platform, baseUrl, onProgres
49
58
  platform: string;
50
59
  appId: string;
51
60
  pageIdMapping: any;
52
- busiCompMapping: any;
53
61
  compAssetList: any;
54
62
  baseUrl: string;
55
63
  appConfig: {
@@ -63,10 +71,7 @@ export declare const fetchData: ({ appId, services, platform, baseUrl, onProgres
63
71
  };
64
72
  cleanedTree: any;
65
73
  }>;
66
- export declare const codeCreate: ({ appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, }: CodeOptions) => Promise<{
67
- success: boolean;
68
- msg?: undefined;
69
- } | {
74
+ export declare const codeCreate: ({ appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, autoDownloadOnBower, useEbeSetup, }: CodeOptions) => Promise<import("@lingxiteam/ebe/types/core").IPublisherResponse<string | import("../../types/core/publisher/zip").ZipBuffer> | {
70
75
  msg: unknown;
71
76
  success: boolean;
72
77
  }>;
package/es/index.js CHANGED
@@ -179,25 +179,28 @@ export var getPageDsls = function getPageDsls(resultObjects) {
179
179
  }
180
180
  }).filter(Boolean);
181
181
  };
182
- export function findAllItem(target, callback, itemHash) {
183
- var list = target;
184
- // Makes sures is always has an positive integer as length.
185
- // eslint-disable-next-line
186
- var length = list.length >>> 0;
187
- // eslint-disable-next-line
188
- var thisArg = arguments[1];
189
- for (var i = 0; i < length;) {
190
- var element = list[i];
191
- if (callback.call(thisArg, element, i, list)) {
192
- var _element$props$busiCo, _element$props;
193
- itemHash[(_element$props$busiCo = element === null || element === void 0 || (_element$props = element.props) === null || _element$props === void 0 ? void 0 : _element$props.busiCompId) !== null && _element$props$busiCo !== void 0 ? _element$props$busiCo : ''] = 1;
194
- }
195
- i += 1;
196
- if (element !== null && element !== void 0 && element.components) {
197
- findAllItem(element === null || element === void 0 ? void 0 : element.components, callback, itemHash);
198
- }
199
- }
200
- }
182
+ // export function findAllItem<T = any>(
183
+ // target: T[],
184
+ // callback: (item: T, index: number, list: T[]) => boolean,
185
+ // itemHash: any,
186
+ // ) {
187
+ // const list = target;
188
+ // // Makes sures is always has an positive integer as length.
189
+ // // eslint-disable-next-line
190
+ // const length = list.length >>> 0;
191
+ // // eslint-disable-next-line
192
+ // const thisArg = arguments[1];
193
+ // for (let i = 0; i < length; ) {
194
+ // const element = list[i] as any;
195
+ // if (callback.call(thisArg, element, i, list)) {
196
+ // itemHash[element?.props?.busiCompId ?? ''] = 1;
197
+ // }
198
+ // i += 1;
199
+ // if (element?.components) {
200
+ // findAllItem(element?.components, callback, itemHash);
201
+ // }
202
+ // }
203
+ // }
201
204
  export function findItem(target, callback) {
202
205
  var list = target;
203
206
  // Makes sures is always has an positive integer as length.
@@ -269,7 +272,7 @@ export var init = /*#__PURE__*/function () {
269
272
  }();
270
273
  export var fetchData = /*#__PURE__*/function () {
271
274
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
272
- var appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, appInfo, attrSpecPage, resultObject, frontendHookList, themeCss, temCompAssetList, compAssetList, globalDataInfo, dataSourceList, globalDataMap, pageIdMapping, appPageList, lastPageId, data, pages, itemHash, itemLists, busiData, busiCompMapping, busiPages, getTranslateName, chinese, translateNames, key, _translateNames, _translateNames2, pagePathEnglishMapping, pagePathEnglishSet, getName, pagesChinese, pagesTranslateNames, _key, _pages$_key$pageConta, _pagePathEnglishMappi, _pagesTranslateNames, safeTranslateName, pageDSLS, getPlatform, options, cleanedTree;
275
+ var appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, appInfo, attrSpecPage, resultObject, frontendHookList, themeCss, temCompAssetList, compAssetList, globalDataInfo, dataSourceList, globalDataMap, pageIdMapping, appPageList, lastPageId, data, pages, _yield$services$qryBu, itemLists, busiData, busiPages, getTranslateName, chinese, translateNames, key, _translateNames, pagePathEnglishMapping, pagePathEnglishSet, getName, pagesChinese, pagesTranslateNames, _key, _pages$_key$pageConta, _pagePathEnglishMappi, _pagesTranslateNames, safeTranslateName, pageDSLS, getPlatform, options, cleanedTree;
273
276
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
274
277
  while (1) switch (_context3.prev = _context3.next) {
275
278
  case 0:
@@ -328,7 +331,7 @@ export var fetchData = /*#__PURE__*/function () {
328
331
  })]);
329
332
  case 19:
330
333
  themeCss = _context3.sent;
331
- console.log('====获取主题成功', themeCss);
334
+ console.log('====获取主题成功');
332
335
  _context3.next = 26;
333
336
  break;
334
337
  case 23:
@@ -401,33 +404,43 @@ export var fetchData = /*#__PURE__*/function () {
401
404
  }));
402
405
  case 45:
403
406
  data = _context3.sent;
404
- pages = getPageDsls(data); // busiCompId 过滤重复
405
- itemHash = {}; // 找到所有页面使用到的 业务组件
406
- findAllItem(pages, function (item) {
407
- return item.compName === 'BOFramer';
408
- }, itemHash);
409
- itemLists = Object.keys(itemHash); // 请求所有业务组件的 dsl
407
+ pages = getPageDsls(data);
410
408
  onProgress({
411
409
  log: '获取所有业务组件dsl',
412
410
  progress: 6
413
411
  });
414
- _context3.next = 53;
412
+
413
+ // 业务组件从被使用才生成改为全部生成
414
+ _context3.next = 50;
415
+ return services.qryBusiCompPage({
416
+ appIds: [appId],
417
+ appId: appId,
418
+ statusCd: '00A',
419
+ pageNum: 1,
420
+ pageSize: 999999,
421
+ terminalType: platform
422
+ });
423
+ case 50:
424
+ _yield$services$qryBu = _context3.sent;
425
+ itemLists = _yield$services$qryBu.list;
426
+ _context3.next = 54;
415
427
  return Promise.all(itemLists.map(function (i) {
416
428
  return services.findBusiCompById({
417
- busiCompId: i,
429
+ busiCompId: i.busiCompId,
418
430
  appId: appId,
419
431
  pageId: lastPageId
420
432
  });
421
433
  }));
422
- case 53:
434
+ case 54:
423
435
  busiData = _context3.sent;
424
- busiCompMapping = {}; // 过滤为空
436
+ // 过滤为空
425
437
  busiPages = busiData.filter(Boolean).map(function (i, index) {
426
438
  var _i$busiCompVersion;
427
439
  // 业务组件为空,返回一个 fallback
428
440
  var busiData = JSON.parse((i === null || i === void 0 || (_i$busiCompVersion = i.busiCompVersion) === null || _i$busiCompVersion === void 0 ? void 0 : _i$busiCompVersion.sourceCodeJson) || '{"id":"100101","pageContainerType":"BusiComp","pageName":"错误组件","pagePath":"","objType":"app","busiCompCode":"Custom","callbacks":["onChange"],"compState":"","events":[],"actions":[],"pageDynamicFlag":true,"setEvents":[{"dataName":"event","dataId":"798407","path":[],"value":"useEffect","params":[],"children":[]}],"layout":"BaseLayout","searchParams":[{"name":"业务主键","code":"bizId"},{"name":"业务场景","code":"sceneCode"},{"name":"业务数据","code":"bizData"}],"catalogItemId":"-1","platformType":"LowCode","editorVersion":"3.6.1.04251034","createdEditorVersion":"0.2.1130.05051011","busiCompObjectRelDTOList":[],"platform":"pc","appId":"1064722784465846272","components":[{"id":"Icon_2609852","label":"图标","compName":"Icon","type":"Icon","compType":1,"compLib":"@/components","props":{"name":"图标","mode":"normal","rotate":0,"basicStatus":1,"icon":{"theme":"outlined","type":"smile","isIconFont":false},"popoverSetting":{"page":{"pagePath":"/ceshiqipao2781","pageId":"1049616591121936384","pageName":"测试气泡1206","options":[{"name":"业务主键","code":"bizId"},{"name":"业务场景","code":"sceneCode"},{"name":"业务数据","code":"bizData"}],"tipType":"1","trigger":"click"}}},"style":{},"isContainer":false,"isBusiObjContainer":false,"cmdgroup":["basic"],"platform":"pc","icon":"Icon","description":"","image":"","groupsName":"通用","isInlineBlock":true,"setEvents":[],"isLabelDropBoxChild":false,"components":[],"path":["965041"]}],"path":[]}');
441
+ // 业务组件原始 dsl 里面没有 busiCompId
429
442
  busiData.busiCompId = i === null || i === void 0 ? void 0 : i.busiCompId;
430
- busiCompMapping[itemLists[index]] = busiData.id;
443
+ busiData.id = i === null || i === void 0 ? void 0 : i.busiCompId;
431
444
  return busiData;
432
445
  });
433
446
  /**
@@ -507,8 +520,7 @@ export var fetchData = /*#__PURE__*/function () {
507
520
  progress: 6 + key / busiPages.length
508
521
  });
509
522
  busiPages[key]._pageName = busiPages[key].pageName;
510
- console.log('====翻译成功', ((_translateNames = translateNames) === null || _translateNames === void 0 ? void 0 : _translateNames[getSafeTypeName(busiPages[key].pageName)]) || busiPages[key].pageName);
511
- busiPages[key].pageName = ((_translateNames2 = translateNames) === null || _translateNames2 === void 0 ? void 0 : _translateNames2[getSafeTypeName(busiPages[key].pageName)]) || busiPages[key].pageName;
523
+ busiPages[key].pageName = ((_translateNames = translateNames) === null || _translateNames === void 0 ? void 0 : _translateNames[getSafeTypeName(busiPages[key].pageName)]) || busiPages[key].pageName;
512
524
  }
513
525
  pagePathEnglishMapping = {};
514
526
  if (!needTranslatePagePathToEnglish) {
@@ -575,7 +587,6 @@ export var fetchData = /*#__PURE__*/function () {
575
587
  platform: getPlatform(platform),
576
588
  appId: appId,
577
589
  pageIdMapping: pageIdMapping,
578
- busiCompMapping: busiCompMapping,
579
590
  compAssetList: compAssetList || [],
580
591
  baseUrl: baseUrl,
581
592
  appConfig: {
@@ -612,11 +623,11 @@ export var fetchData = /*#__PURE__*/function () {
612
623
  }();
613
624
  export var codeCreate = /*#__PURE__*/function () {
614
625
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref7) {
615
- var appId, services, platform, baseUrl, _onProgress, _ref7$needTranslatePa, needTranslatePagePathToEnglish, _yield$fetchData, cleanedTree, options, result;
626
+ var appId, services, platform, baseUrl, _onProgress, _ref7$needTranslatePa, needTranslatePagePathToEnglish, _ref7$autoDownloadOnB, autoDownloadOnBower, _ref7$useEbeSetup, useEbeSetup, _yield$fetchData, cleanedTree, options, result, zipRes;
616
627
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
617
628
  while (1) switch (_context4.prev = _context4.next) {
618
629
  case 0:
619
- appId = _ref7.appId, services = _ref7.services, platform = _ref7.platform, baseUrl = _ref7.baseUrl, _onProgress = _ref7.onProgress, _ref7$needTranslatePa = _ref7.needTranslatePagePathToEnglish, needTranslatePagePathToEnglish = _ref7$needTranslatePa === void 0 ? false : _ref7$needTranslatePa;
630
+ appId = _ref7.appId, services = _ref7.services, platform = _ref7.platform, baseUrl = _ref7.baseUrl, _onProgress = _ref7.onProgress, _ref7$needTranslatePa = _ref7.needTranslatePagePathToEnglish, needTranslatePagePathToEnglish = _ref7$needTranslatePa === void 0 ? false : _ref7$needTranslatePa, _ref7$autoDownloadOnB = _ref7.autoDownloadOnBower, autoDownloadOnBower = _ref7$autoDownloadOnB === void 0 ? true : _ref7$autoDownloadOnB, _ref7$useEbeSetup = _ref7.useEbeSetup, useEbeSetup = _ref7$useEbeSetup === void 0 ? true : _ref7$useEbeSetup;
620
631
  _context4.prev = 1;
621
632
  _context4.next = 4;
622
633
  return fetchData({
@@ -631,13 +642,12 @@ export var codeCreate = /*#__PURE__*/function () {
631
642
  _yield$fetchData = _context4.sent;
632
643
  cleanedTree = _yield$fetchData.cleanedTree;
633
644
  options = _yield$fetchData.options;
634
- console.log(cleanedTree);
635
- console.log(options);
636
- _context4.next = 11;
645
+ _context4.next = 9;
637
646
  return generateCode({
638
647
  solution: 'alita',
639
648
  // 出码方案
640
649
  options: options,
650
+ useEbeSetup: useEbeSetup,
641
651
  schema: cleanedTree,
642
652
  // 编排搭建出来的 schema
643
653
  onProgress: function onProgress(log) {
@@ -663,30 +673,31 @@ export var codeCreate = /*#__PURE__*/function () {
663
673
  },
664
674
  workerJsUrl: workerJsUrl
665
675
  });
666
- case 11:
676
+ case 9:
667
677
  result = _context4.sent;
668
- console.log(result);
669
- // 出码结果(默认是递归结构描述的,可以传 flattenResult: true 以生成扁平结构的结果)
670
- publishers.zip().publish({
678
+ _context4.next = 12;
679
+ return publishers.zip().publish({
671
680
  project: result,
672
681
  // 上一步生成的 project
673
- projectSlug: appId // 项目标识
682
+ projectSlug: appId,
683
+ // 项目标识
684
+ autoDownloadOnBower: autoDownloadOnBower
674
685
  });
675
- return _context4.abrupt("return", {
676
- success: true
677
- });
678
- case 17:
679
- _context4.prev = 17;
686
+ case 12:
687
+ zipRes = _context4.sent;
688
+ return _context4.abrupt("return", zipRes);
689
+ case 16:
690
+ _context4.prev = 16;
680
691
  _context4.t0 = _context4["catch"](1);
681
692
  return _context4.abrupt("return", {
682
693
  msg: _context4.t0,
683
694
  success: false
684
695
  });
685
- case 20:
696
+ case 19:
686
697
  case "end":
687
698
  return _context4.stop();
688
699
  }
689
- }, _callee4, null, [[1, 17]]);
700
+ }, _callee4, null, [[1, 16]]);
690
701
  }));
691
702
  return function codeCreate(_x5) {
692
703
  return _ref8.apply(this, arguments);
@@ -1 +1 @@
1
- export declare const getAllImportFiles: (target: string, allImportFiles?: any) => any;
1
+ export declare const getAllImportFiles: (cwd: string, target: string, allImportFiles?: any) => any;
@@ -3,8 +3,8 @@ import { existsSync, readFileSync } from 'fs';
3
3
  import { dirname, resolve } from 'path';
4
4
  import { getRealPath, isJsFile, isLessFile } from "./getRealPath";
5
5
  import { parse } from "./parse";
6
- export var getAllImportFiles = function getAllImportFiles(target) {
7
- var allImportFiles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6
+ export var getAllImportFiles = function getAllImportFiles(cwd, target) {
7
+ var allImportFiles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
8
8
  if (!existsSync(target)) {
9
9
  return allImportFiles;
10
10
  }
@@ -22,12 +22,12 @@ export var getAllImportFiles = function getAllImportFiles(target) {
22
22
  // @/ 是别名到 ${cwd}/src
23
23
  var nextPath = resolve(dirname(target), importName);
24
24
  if (isAlias) {
25
- nextPath = importName.replace('@/', "".concat(process.cwd(), "/src/"));
25
+ nextPath = importName.replace('@/', "".concat(cwd, "/src/"));
26
26
  }
27
27
  var nextTarget = getRealPath(nextPath);
28
28
  if (!allImportFiles[nextTarget]) {
29
29
  allImportFiles[nextTarget] = true;
30
- getAllImportFiles(nextTarget, allImportFiles);
30
+ getAllImportFiles(cwd, nextTarget, allImportFiles);
31
31
  }
32
32
  }
33
33
  };
package/es/node/move.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export interface MoveConfig {
2
2
  target: string;
3
3
  outDir: string;
4
+ cwd?: string;
4
5
  }
5
6
  export declare function move(moveConfig: MoveConfig): Promise<any>;
package/es/node/move.js CHANGED
@@ -2,10 +2,10 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
3
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
4
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
- import { existsSync, mkdirpSync, readFileSync, writeFileSync } from 'fs-extra';
5
+ import { existsSync, mkdirpSync, readFileSync, readJSONSync, writeFileSync, writeJSONSync } from 'fs-extra';
6
6
  import { dirname, isAbsolute, join, relative } from 'path';
7
7
  import { getAllImportFiles } from "./babel/getAllImportFiles";
8
- var copyFileSyncAlias = function copyFileSyncAlias(from, to) {
8
+ var copyFileSyncAlias = function copyFileSyncAlias(cwd, from, to) {
9
9
  var _context$match;
10
10
  // copyFileSync(file, absTarget);
11
11
  var context = readFileSync(from, 'utf-8');
@@ -13,7 +13,7 @@ var copyFileSyncAlias = function copyFileSyncAlias(from, to) {
13
13
  return match.slice(8, -1);
14
14
  })) || [];
15
15
  importList.forEach(function (source) {
16
- var absolute = join(process.cwd(), 'src', source);
16
+ var absolute = join(cwd, 'src', source);
17
17
  var filePath = relative(dirname(from), absolute);
18
18
  context = context.replace("@/".concat(source), filePath);
19
19
  });
@@ -24,20 +24,19 @@ export function move(_x) {
24
24
  }
25
25
  function _move() {
26
26
  _move = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(moveConfig) {
27
- var target, outDir, cwd, resolvedTarget, allImportFiles, keys, count;
27
+ var target, outDir, _moveConfig$cwd, cwd, resolvedTarget, allImportFiles, keys, count, pkg, context;
28
28
  return _regeneratorRuntime().wrap(function _callee$(_context) {
29
29
  while (1) switch (_context.prev = _context.next) {
30
30
  case 0:
31
- target = moveConfig.target, outDir = moveConfig.outDir;
32
- cwd = process.cwd();
31
+ target = moveConfig.target, outDir = moveConfig.outDir, _moveConfig$cwd = moveConfig.cwd, cwd = _moveConfig$cwd === void 0 ? process.cwd() : _moveConfig$cwd;
33
32
  resolvedTarget = isAbsolute(target) ? target : join(cwd, target);
34
33
  if (existsSync(resolvedTarget)) {
35
- _context.next = 5;
34
+ _context.next = 4;
36
35
  break;
37
36
  }
38
- throw new Error("\u6307\u5B9A\u7684\u6587\u4EF6\u4E0D\u5B58\u5728: ".concat(resolvedTarget));
39
- case 5:
40
- allImportFiles = getAllImportFiles(resolvedTarget); // 拷贝入口文件
37
+ throw new Error("\u6307\u5B9A\u7684\u5165\u53E3\u6587\u4EF6\u4E0D\u5B58\u5728: ".concat(resolvedTarget));
38
+ case 4:
39
+ allImportFiles = getAllImportFiles(cwd, resolvedTarget); // 拷贝入口文件
41
40
  allImportFiles[resolvedTarget] = true;
42
41
  keys = Object.keys(allImportFiles);
43
42
  count = keys.length;
@@ -48,13 +47,22 @@ function _move() {
48
47
  return;
49
48
  }
50
49
  var filePath = relative(cwd, file);
51
- var absTarget = join(cwd, outDir, filePath);
50
+ var absTarget = isAbsolute(outDir) ? join(outDir, filePath) : join(cwd, outDir, filePath);
52
51
  // console.log(`[COPY] 拷贝 ${absTarget}`);
53
52
  mkdirpSync(dirname(absTarget));
54
- copyFileSyncAlias(file, absTarget);
53
+ copyFileSyncAlias(cwd, file, absTarget);
55
54
  });
56
55
  console.log("[COPY] \u5171\u62F7\u8D1D\u6587\u4EF6\u6570 ".concat(count));
57
- case 11:
56
+ pkg = join(cwd, 'package.json');
57
+ if (existsSync(pkg)) {
58
+ // package 存在,则写一个记录
59
+ context = readJSONSync(pkg, 'utf-8');
60
+ writeJSONSync(join(outDir, 'package.json'), {
61
+ name: context.name,
62
+ version: context.version
63
+ }, 'utf-8');
64
+ }
65
+ case 12:
58
66
  case "end":
59
67
  return _context.stop();
60
68
  }
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "@lingxiteam/factory",
3
+ "version": "3.7.1"
4
+ }
@@ -9,6 +9,7 @@ import React, {
9
9
  useState,
10
10
  } from 'react';
11
11
  import MySwipe, { SwipeActionProps } from '../DynamicList/MySwipe';
12
+ import Icon from '../Icon';
12
13
  import { useDeepCompareEffect } from '../utils/ahooks';
13
14
  import useStyle from '../View/useStyle';
14
15
  import ActionView from './components/ActionView';
@@ -518,10 +519,17 @@ const BlockSelect = LingxiForwardRef<any, MyBlockSelectProps>((props, ref) => {
518
519
  isEdit={false}
519
520
  swipeAction={swipeAction}
520
521
  getEngineApis={getEngineApis}
521
- $$componentItem={$$componentItem}
522
522
  rowData={item}
523
523
  index={i}
524
524
  swipActionClick={swipActionClick}
525
+ renderIcon={(p) => (
526
+ <Icon
527
+ {...p}
528
+ $$componentItem={$$componentItem}
529
+ getEngineApis={getEngineApis}
530
+ className=""
531
+ />
532
+ )}
525
533
  >
526
534
  <MemoLoopItem {...renderProps} />
527
535
  </MySwipe>
@@ -1,5 +1,9 @@
1
1
  import Form, { type FormInstance } from '@lingxiteam/dform';
2
- import { DynamicDataType, LingxiForwardRef } from '@lingxiteam/types';
2
+ import {
3
+ DynamicDataFieldItem,
4
+ DynamicDataType,
5
+ LingxiForwardRef,
6
+ } from '@lingxiteam/types';
3
7
  import { SpinLoading } from 'antd-mobile-5';
4
8
  import {
5
9
  CSSProperties,
@@ -36,6 +40,7 @@ export interface DynamicDataContainerProps {
36
40
  dynamicCode: string;
37
41
  visible?: boolean;
38
42
  scene?: 'edit' | 'readonly';
43
+ boxSpace?: string;
39
44
  }
40
45
 
41
46
  const DynamicDataContainer = LingxiForwardRef<any, DynamicDataContainerProps>(
@@ -49,6 +54,7 @@ const DynamicDataContainer = LingxiForwardRef<any, DynamicDataContainerProps>(
49
54
  name,
50
55
  onValuesChange,
51
56
  dynamicCode,
57
+ boxSpace,
52
58
  } = props || {};
53
59
  const engineApis = getEngineApis?.() || {};
54
60
  const [loading, setLoading] = useState<boolean>(false);
@@ -88,10 +94,23 @@ const DynamicDataContainer = LingxiForwardRef<any, DynamicDataContainerProps>(
88
94
  });
89
95
  if (res) {
90
96
  if (res && typeof dynamicData2DSL === 'function') {
91
- const dataHelper = dynamicData2DSL(res as DynamicDataType[], {
92
- uid: $$componentItem.uid,
93
- name,
94
- });
97
+ const dataHelper = dynamicData2DSL(
98
+ res as DynamicDataType[],
99
+ { uid: $$componentItem.uid, name },
100
+ (
101
+ DSLCore,
102
+ dynamicData: DynamicDataType | DynamicDataFieldItem,
103
+ ) => {
104
+ if ('dataId' in dynamicData) {
105
+ const node = DSLCore?.query?.(`Card_${dynamicData.dataId}`);
106
+ if (node && boxSpace) {
107
+ node?.setStyle?.({
108
+ margin: `0 0 ${boxSpace} 0`,
109
+ });
110
+ }
111
+ }
112
+ },
113
+ );
95
114
  setPageData(dataHelper.pageDSL);
96
115
  dynamicHelperRef.current = dataHelper;
97
116
  }
@@ -67,7 +67,7 @@ const CustomButton: React.FC<MySwipeProps> = (props) => {
67
67
  ...icon,
68
68
  svgContent,
69
69
  name: value,
70
- });
70
+ }) ?? <></>;
71
71
  }
72
72
  if (!isEdit) {
73
73
  viewDisabled = false;
@@ -1,16 +1,54 @@
1
+ import { Context } from '@/utils/Context/context';
2
+ import {
3
+ formCodeSubmit,
4
+ getComponentsByCompId,
5
+ getFieldsValueByCode,
6
+ getFormsByBoframerId,
7
+ getFormValueByBOFramerId,
8
+ getFormValueByFormId,
9
+ validateFields,
10
+ } from '@/utils/formUtils';
11
+ import { useContext } from 'react';
12
+
1
13
  const usePageForm = (refs: Record<string, any>) => {
14
+ const { refs: renderRefs } = useContext(Context);
15
+
16
+ /**
17
+ * 重置表单值
18
+ * @param compId
19
+ */
20
+ const resetForm = (compId: string) => {
21
+ if (!refs[compId]) return;
22
+ const compName = refs[compId].compName;
23
+ if (compName === 'BOFramer') {
24
+ const forms = getFormsByBoframerId({
25
+ refs,
26
+ renderRefs,
27
+ compId,
28
+ });
29
+
30
+ forms.forEach((form) => {
31
+ form?.resetFields?.();
32
+ });
33
+ } else {
34
+ const forms = getComponentsByCompId({ compId, refs });
35
+ // 支持循环容器中的表单重置
36
+ (Array.isArray(forms) ? forms : [forms]).forEach((form) =>
37
+ form?.resetFields(),
38
+ );
39
+ }
40
+ };
41
+
2
42
  /**
3
43
  * 获取当前表单值
4
44
  */
5
45
  const getFormValue = async (compId: string): Promise<any> => {
46
+ if (!refs[compId]) return Promise.reject(new Error(`表单${compId}不存在`));
6
47
  return new Promise((resolve, reject) => {
7
- // 为了兼容动态渲染引擎,表单不存在 就返回空对象
8
- if (!refs[compId]) return resolve({});
9
-
10
48
  // 表单的情况 可能是循环容器
11
49
  if (refs[compId].compName === 'DForm') {
12
50
  if (refs[compId]?.getFieldsValue) {
13
- refs[compId].getFieldsValue(resolve, reject);
51
+ return refs[compId].getFieldsValue(resolve, reject);
14
52
  }
15
53
  }
16
54
 
@@ -18,8 +56,74 @@ const usePageForm = (refs: Record<string, any>) => {
18
56
  });
19
57
  };
20
58
 
59
+ /**
60
+ * 验证并取值
61
+ * @param compId
62
+ */
63
+ const validateForm = async (compId: string): Promise<any> => {
64
+ if (!refs[compId]) return Promise.reject(new Error(`表单不存在`));
65
+ const { compName } = refs[compId];
66
+ if (!['BOFramer', 'DForm'].includes(compName))
67
+ return Promise.reject(new Error(`表单校验并取值不支持 ${compName} 组件`));
68
+
69
+ if (compName === 'DForm') {
70
+ return getFormValueByFormId({ refs, compId });
71
+ }
72
+
73
+ // 业务组件
74
+ return getFormValueByBOFramerId({ refs, renderRefs, compId });
75
+ };
76
+
77
+ /**
78
+ * 设置表单值
79
+ * @param compId 组件id
80
+ * @param formValues 表单值
81
+ */
82
+ const setFormValues = (
83
+ compId: string,
84
+ formValues: Record<string, any> = {},
85
+ ) => {
86
+ if (!refs[compId]) return;
87
+ const compName = refs[compId].compName;
88
+
89
+ if (compName === 'BOFramer') {
90
+ const forms = getFormsByBoframerId({
91
+ refs,
92
+ renderRefs,
93
+ compId,
94
+ });
95
+
96
+ forms.forEach((form) => {
97
+ form?.setFieldsValue(formValues);
98
+ });
99
+ } else {
100
+ refs[compId]?.setFieldsValue?.(formValues);
101
+ }
102
+ };
103
+
104
+ /**
105
+ * 校验并获取所有表单值
106
+ * 获取页面下的所有表单,包含当前页面下的表单、页面容器下的表单、业务组件下的表单。
107
+ * 不包含所有弹窗类组件的表单数据
108
+ */
109
+ const validateAllForm = () =>
110
+ validateFields({ refs, renderRefs }, formCodeSubmit);
111
+
112
+ /**
113
+ * 获取所有表单值 但不校验
114
+ * 获取页面下的所有表单,包含当前页面下的表单、页面容器下的表单、业务组件下的表单。
115
+ * 不包含所有弹窗类组件的表单数据
116
+ */
117
+ const getAllFormValues = () =>
118
+ validateFields({ refs, renderRefs }, getFieldsValueByCode);
119
+
21
120
  return {
22
121
  getFormValue,
122
+ validateForm,
123
+ validateAllForm,
124
+ getAllFormValues,
125
+ resetForm,
126
+ setFormValues,
23
127
  };
24
128
  };
25
129