@lingxiteam/ebe-utils 0.0.25 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/index.js CHANGED
@@ -250,7 +250,7 @@ var getIsIncrementalConstruction = function getIsIncrementalConstruction(ic) {
250
250
  export var fetchData = /*#__PURE__*/function () {
251
251
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
252
252
  var _ref6, _attrSpecPage;
253
- var appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, incrementalConstruction, isIncrementalConstruction, attrSpecPage, incrementalConstructionPageList, globalDataInfo, busiData, themeCss, frontendHookList, pageTypeMap, globalDataMap, appInfo, appPageList, temCompAssetList, compAssetList, _globalDataInfo, dataSourceList, pageIdMapping, lastPageId, data, needFindDataPages, pages, _yield$services$qryBu, itemLists, _incrementalConstruct, itemHash, _itemLists, alllBusiComp, busiPages, getTranslateName, chinese, translateNames, key, _translateNames, pagePathEnglishMapping, pagePathEnglishSet, getName, pagesChinese, pagesTranslateNames, findPageKeyByPageId, _key2, _appPageList$_key2$pa, _pagePathEnglishMappi, _pagesTranslateNames, safeTranslateName, pageKey, pageDSLS, getPlatform, options, cleanedTree;
253
+ var appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, incrementalConstruction, isIncrementalConstruction, attrSpecPage, incrementalConstructionPageList, globalDataInfo, busiData, themeCss, frontendHookList, pageTypeMap, globalDataMap, appInfo, appPageList, temCompAssetList, compAssetList, _globalDataInfo, dataSourceList, pageIdMapping, lastPageId, data, needFindDataPages, pages, _yield$services$qryBu, itemLists, _incrementalConstruct, itemHash, _itemLists, alllBusiComp, busiPages, getTranslateName, chinese, translateNames, key, _translateNames, translateName, pagePathEnglishMapping, pagePathEnglishSet, getName, pagesChinese, pagesTranslateNames, findPageKeyByPageId, _key2, _appPageList$_key2$pa, _pagePathEnglishMappi, _pagesTranslateNames, safeTranslateName, pageKey, pageDSLS, getPlatform, options, cleanedTree;
254
254
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
255
255
  while (1) switch (_context3.prev = _context3.next) {
256
256
  case 0:
@@ -559,8 +559,11 @@ export var fetchData = /*#__PURE__*/function () {
559
559
  log: '翻译业务组件名称',
560
560
  progress: 6 + key / busiPages.length
561
561
  });
562
- busiPages[key]._pageName = busiPages[key].pageName;
563
- busiPages[key].pageName = ((_translateNames = translateNames) === null || _translateNames === void 0 ? void 0 : _translateNames[getSafeTypeName(busiPages[key].pageName)]) || busiPages[key].pageName;
562
+ translateName = (_translateNames = translateNames) === null || _translateNames === void 0 ? void 0 : _translateNames[getSafeTypeName(busiPages[key].pageName)]; // 翻译可能失败
563
+ if (translateName) {
564
+ busiPages[key]._pageName = busiPages[key].pageName;
565
+ busiPages[key].pageName = translateName;
566
+ }
564
567
  }
565
568
  pagePathEnglishMapping = {};
566
569
  if (!needTranslatePagePathToEnglish) {
@@ -8,10 +8,11 @@ import {
8
8
  getFormValueByFormId,
9
9
  validateFields,
10
10
  } from '@/utils/formUtils';
11
- import { useContext } from 'react';
11
+ import { useContext, useState } from 'react';
12
12
 
13
13
  const usePageForm = (refs: Record<string, any>) => {
14
14
  const { refs: renderRefs } = useContext(Context);
15
+ const [, forceUpdate] = useState({});
15
16
 
16
17
  /**
17
18
  * 重置表单值
@@ -94,11 +95,12 @@ const usePageForm = (refs: Record<string, any>) => {
94
95
  });
95
96
 
96
97
  forms.forEach((form) => {
97
- form?.setFieldsValue(formValues);
98
+ form?.setFieldsValue(formValues, refs);
98
99
  });
99
100
  } else {
100
- refs[compId]?.setFieldsValue?.(formValues);
101
+ refs[compId]?.setFieldsValue?.(formValues, refs);
101
102
  }
103
+ forceUpdate({});
102
104
  };
103
105
 
104
106
  /**
@@ -117,6 +119,30 @@ const usePageForm = (refs: Record<string, any>) => {
117
119
  const getAllFormValues = () =>
118
120
  validateFields({ refs, renderRefs }, getFieldsValueByCode);
119
121
 
122
+ /**
123
+ * 设置表单是否可编辑
124
+ * @param compId 组件id
125
+ * @param editor 是否可编辑
126
+ */
127
+ const setFormDisabled = async (compId: string, editor: boolean) => {
128
+ if (!refs[compId]) return;
129
+ const compName = refs[compId].compName;
130
+
131
+ if (compName === 'BOFramer') {
132
+ const forms = getFormsByBoframerId({
133
+ refs,
134
+ renderRefs,
135
+ compId,
136
+ });
137
+
138
+ forms.forEach((form) => {
139
+ form?.setDisabled(editor);
140
+ });
141
+ } else {
142
+ refs[compId]?.setDisabled?.(editor);
143
+ }
144
+ forceUpdate({});
145
+ };
120
146
  return {
121
147
  getFormValue,
122
148
  validateForm,
@@ -124,6 +150,7 @@ const usePageForm = (refs: Record<string, any>) => {
124
150
  getAllFormValues,
125
151
  resetForm,
126
152
  setFormValues,
153
+ setFormDisabled,
127
154
  };
128
155
  };
129
156