@lingxiteam/ebe-utils 0.2.21 → 0.2.23

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 (144) hide show
  1. package/lib/h5public/yarn.lock +7 -8
  2. package/lib/pcpublic/src/components/pcfactory/src/Button/index.tsx +11 -10
  3. package/lib/pcpublic/src/components/pcfactory/src/Card/CardTitle/index.tsx +31 -24
  4. package/lib/pcpublic/src/components/pcfactory/src/Card/index.tsx +32 -14
  5. package/lib/pcpublic/src/components/pcfactory/src/Card/useExtendBtn.tsx +85 -48
  6. package/lib/pcpublic/src/components/pcfactory/src/ChartLine/ChartLine.tsx +24 -6
  7. package/lib/pcpublic/src/components/pcfactory/src/ChartLine/PropsType.ts +31 -5
  8. package/lib/pcpublic/src/components/pcfactory/src/ChartLine/index.tsx +3 -2
  9. package/lib/pcpublic/src/components/pcfactory/src/ChartLine/loader.tsx +1 -1
  10. package/lib/pcpublic/src/components/pcfactory/src/Form/Form.tsx +153 -129
  11. package/lib/pcpublic/src/components/pcfactory/src/Form/index.tsx +2 -5
  12. package/lib/pcpublic/src/components/pcfactory/src/Form/useFormStatus.ts +8 -4
  13. package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/LXPieChart.tsx +15 -3
  14. package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/PropsType.ts +4 -3
  15. package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/index.tsx +1 -1
  16. package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/loader.tsx +1 -1
  17. package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/LXRadarChat.tsx +18 -4
  18. package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/PropsType.ts +2 -1
  19. package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/index.tsx +1 -1
  20. package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/loader.tsx +1 -1
  21. package/lib/pcpublic/src/components/pcfactory/src/ModalSelect/BaseModalSelect.tsx +7 -2
  22. package/lib/pcpublic/src/components/pcfactory/src/ModalSelect/index.tsx +60 -26
  23. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/LcdpUeditorMain.tsx +62 -55
  24. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/RichTextEditor.tsx +2 -6
  25. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/RichTextEditorMain.tsx +5 -5
  26. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/index.tsx +9 -2
  27. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/loader.ts +1 -1
  28. package/lib/pcpublic/src/components/pcfactory/src/Select/index.tsx +145 -66
  29. package/lib/pcpublic/src/components/pcfactory/src/Select/selectUtils.ts +13 -9
  30. package/lib/pcpublic/src/components/pcfactory/src/Table/BodyCell/index.tsx +36 -26
  31. package/lib/pcpublic/src/components/pcfactory/src/Table/EditComponent/index.tsx +69 -94
  32. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/GhostTag/index.tsx +12 -5
  33. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/Hyperlink/index.tsx +9 -5
  34. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/PointTag/index.tsx +11 -5
  35. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/PureColourFill/index.tsx +11 -5
  36. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/PureFadeColourTag/index.tsx +14 -7
  37. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/Thumbnail/index.tsx +30 -31
  38. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/index.tsx +89 -41
  39. package/lib/pcpublic/src/components/pcfactory/src/Table/HeaderCell/HeaderCellTitle/index.tsx +25 -12
  40. package/lib/pcpublic/src/components/pcfactory/src/Table/HeaderCell/index.tsx +12 -5
  41. package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/PopoverWrapper.tsx +220 -0
  42. package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/SingleBtn.tsx +39 -32
  43. package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/index.tsx +178 -148
  44. package/lib/pcpublic/src/components/pcfactory/src/Table/Table.tsx +439 -0
  45. package/lib/pcpublic/src/components/pcfactory/src/Table/TableHead/index.tsx +159 -72
  46. package/lib/pcpublic/src/components/pcfactory/src/Table/TableSummaryRow/index.tsx +12 -20
  47. package/lib/pcpublic/src/components/pcfactory/src/Table/constant.ts +3 -0
  48. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/index.ts +4 -4
  49. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCMDActions.ts +32 -28
  50. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCheckStrict.ts +44 -57
  51. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useColumns.tsx +306 -276
  52. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCommon.ts +9 -6
  53. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useDataSource.ts +30 -21
  54. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useExpandable.tsx +33 -27
  55. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useFilter.tsx +84 -77
  56. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useFormatCell.tsx +33 -16
  57. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/usePagination.ts +15 -5
  58. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useRowEdit.ts +33 -33
  59. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useRowMerge.ts +13 -5
  60. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useScroll.ts +94 -28
  61. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSelection.ts +108 -99
  62. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSort.ts +8 -5
  63. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSummaryCol.ts +27 -43
  64. package/lib/pcpublic/src/components/pcfactory/src/Table/index.tsx +73 -394
  65. package/lib/pcpublic/src/components/pcfactory/src/Table/loader.tsx +15 -0
  66. package/lib/pcpublic/src/components/pcfactory/src/Table/types/OperationCell.d.ts +2 -2
  67. package/lib/pcpublic/src/components/pcfactory/src/Table/types/event.d.ts +12 -8
  68. package/lib/pcpublic/src/components/pcfactory/src/Table/types/headerCell.d.ts +2 -1
  69. package/lib/pcpublic/src/components/pcfactory/src/Table/types/prop.d.ts +24 -11
  70. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/SequenceId.ts +2 -1
  71. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/index.ts +90 -82
  72. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/indexedDBHelper.ts +9 -22
  73. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/translate.ts +59 -0
  74. package/lib/pcpublic/src/components/pcfactory/src/Transfer/Transfer.tsx +644 -0
  75. package/lib/pcpublic/src/components/pcfactory/src/Transfer/index.tsx +49 -637
  76. package/lib/pcpublic/src/components/pcfactory/src/Transfer/loader.tsx +11 -0
  77. package/lib/pcpublic/src/components/pcfactory/src/Tree/TreeEllipsisIcon.tsx +38 -0
  78. package/lib/pcpublic/src/components/pcfactory/src/Tree/TreeNodeMenu/index.tsx +34 -35
  79. package/lib/pcpublic/src/components/pcfactory/src/Tree/index.tsx +213 -149
  80. package/lib/pcpublic/src/components/pcfactory/src/TreeSelect/index.tsx +47 -43
  81. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/TreeTable.tsx +264 -0
  82. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/hooks/index.ts +4 -1
  83. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/hooks/useCMDAction.ts +9 -3
  84. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/hooks/useExpandable.tsx +9 -3
  85. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/index.tsx +52 -191
  86. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/loader.tsx +16 -0
  87. package/lib/pcpublic/src/components/pcfactory/src/assets/index.tsx +34 -0
  88. package/lib/pcpublic/src/components/pcfactory/src/assets/svg/quadrate.tsx +20 -0
  89. package/lib/pcpublic/src/components/pcfactory/src/assets/svg/roundness.tsx +14 -0
  90. package/lib/pcpublic/src/components/pcfactory/src/assets/svg/semicircle.tsx +15 -0
  91. package/lib/pcpublic/src/components/pcfactory/src/assets/svg/verticalLine.tsx +12 -0
  92. package/lib/pcpublic/src/components/pcfactory/src/styles/common.less +17 -0
  93. package/lib/pcpublic/src/components/pcfactory/src/styles/components/Card.less +57 -11
  94. package/lib/pcpublic/src/components/pcfactory/src/styles/components/Form.less +101 -12
  95. package/lib/pcpublic/src/components/pcfactory/src/styles/components/ModalSelect.less +6 -0
  96. package/lib/pcpublic/src/components/pcfactory/src/styles/components/Select.less +70 -6
  97. package/lib/pcpublic/src/components/pcfactory/src/utils/ChannelContainer.tsx +20 -14
  98. package/lib/pcpublic/src/components/pcfactory/src/utils/ChildRender.ts +6 -8
  99. package/lib/pcpublic/src/components/pcfactory/src/utils/CustomModule.tsx +4 -6
  100. package/lib/pcpublic/src/components/pcfactory/src/utils/DummyFormContext.ts +9 -13
  101. package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/empty.tsx +5 -17
  102. package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/index.tsx +3 -3
  103. package/lib/pcpublic/src/components/pcfactory/src/utils/Holidays.ts +11 -39
  104. package/lib/pcpublic/src/components/pcfactory/src/utils/HolidaysFormat.ts +83 -0
  105. package/lib/pcpublic/src/components/pcfactory/src/utils/IdleContainer/index.tsx +47 -0
  106. package/lib/pcpublic/src/components/pcfactory/src/utils/IdleContainer/scheduler.ts +74 -0
  107. package/lib/pcpublic/src/components/pcfactory/src/utils/LoaderHelper.tsx +4 -1
  108. package/lib/pcpublic/src/components/pcfactory/src/utils/Spin/index.tsx +8 -7
  109. package/lib/pcpublic/src/components/pcfactory/src/utils/WithSyncValue.ts +25 -23
  110. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/index.ts +10 -7
  111. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useMap.ts +9 -6
  112. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useMemoizedFn.ts +4 -1
  113. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/usePersistFn.ts +17 -0
  114. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useSafeState.ts +2 -2
  115. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useSetState.ts +7 -5
  116. package/lib/pcpublic/src/components/pcfactory/src/utils/common.ts +23 -50
  117. package/lib/pcpublic/src/components/pcfactory/src/utils/constant.ts +53 -57
  118. package/lib/pcpublic/src/components/pcfactory/src/utils/dynamicUtils/DynamicContext.tsx +12 -17
  119. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormContext.tsx +22 -12
  120. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormFields.tsx +50 -19
  121. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/WrapperContainer.tsx +58 -37
  122. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/cmdHelper.ts +33 -30
  123. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/common.ts +2 -0
  124. package/lib/pcpublic/src/components/pcfactory/src/utils/generatorDisabledCallback.ts +121 -113
  125. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useCommonImperativeHandle.ts +16 -14
  126. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useCompState.tsx +1 -1
  127. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useDataMask.ts +7 -2
  128. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useDoubleClick.ts +3 -1
  129. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useFuncExpExecute.ts +16 -14
  130. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useGetStaticAttrData.ts +9 -3
  131. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useHiddenStyle.ts +4 -5
  132. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useInit.ts +11 -0
  133. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useInitReactQuill.ts +3 -1
  134. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useListenState.ts +1 -0
  135. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useLocale.ts +5 -3
  136. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/usePrintMode.tsx +2 -2
  137. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useRules.ts +1 -1
  138. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useTestHelper.ts +2 -0
  139. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useToggleBoolean.ts +8 -4
  140. package/lib/pcpublic/src/components/pcfactory/src/utils/index.ts +10 -10
  141. package/lib/pcpublic/src/components/pcfactory/src/utils/polyfill.js +29 -31
  142. package/lib/pcpublic/src/components/pcfactory/src/utils/renderReadOnly.tsx +29 -26
  143. package/lib/public/public/iconfont.js +1 -0
  144. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
- import _ from 'lodash';
2
1
  import { useState } from 'react';
2
+ import { deleteTempRowProperties, EMPTY_ROW_TEMP_KEY_ATTR, getFormItemFieldName, LATEST_EMPTY_ROW_FLAG_ATTR, UPDATE_DATA_SOURCE_FLAG } from '../utils';
3
3
  import { EDIT_COMPONENT_STOP_PROPAGATION_CLS } from '../constant';
4
- import { deleteTempRowProperties, EMPTY_ROW_TEMP_KEY_ATTR, getFormItemFieldName, LATEST_EMPTY_ROW_FLAG_ATTR } from '../utils';
4
+ import _ from 'lodash';
5
5
 
6
6
  const useRowEdit = (props: any) => {
7
7
  const {
@@ -55,12 +55,15 @@ const useRowEdit = (props: any) => {
55
55
  }
56
56
 
57
57
  const trow: any = innerDataSource.find((i: any) => i[currentRowKey] === nowInlineEditKey);
58
+ // 存在更新数据源标识时或者是381之前的版本,需要同步到数据源
59
+ const needUpdateDataSource = !tableUpdateInnerDataSource || trow[UPDATE_DATA_SOURCE_FLAG];
58
60
  if (trow) {
59
61
  Object.assign(trow, nowEditingData);
62
+ // 清除新增时增加的临时属性
60
63
  deleteTempRowProperties(trow);
61
64
  }
62
65
 
63
- if (!tableUpdateInnerDataSource) {
66
+ if (needUpdateDataSource) {
64
67
  // 单行保存编辑时,需要将修改后的值同步到绑定的数据源
65
68
  const syncPropsDataSourceRow = props.dataSource?.find((r: any) => r[currentRowKey] === nowInlineEditKey);
66
69
  if (syncPropsDataSourceRow) {
@@ -101,15 +104,13 @@ const useRowEdit = (props: any) => {
101
104
  // 取消时重置为原始数据
102
105
  if (typeof form?.setFieldsValue === 'function') {
103
106
  const originRow: Record<string, any> = {};
104
- Object.keys(row).forEach(key => {
107
+ Object.keys(row).forEach((key) => {
105
108
  // 表单项名称
106
- const fieldName = getFormItemFieldName({
107
- compId,
109
+ const fieldName = getFormItemFieldName({ compId,
108
110
  currentRowKey,
109
111
  rowData: row,
110
112
  rowId: row[currentRowKey],
111
- dataIndex: key,
112
- });
113
+ dataIndex: key });
113
114
  originRow[fieldName] = row[key];
114
115
  });
115
116
  form.setFieldsValue(originRow);
@@ -118,16 +119,13 @@ const useRowEdit = (props: any) => {
118
119
  setNowInlineEditKey(null);
119
120
  // 取消编辑的时候,如果当前行是刚刚新增的空白行,则过滤当前行
120
121
  const isLatestCreationTempRow = row?.[LATEST_EMPTY_ROW_FLAG_ATTR] && row?.[EMPTY_ROW_TEMP_KEY_ATTR];
121
- setInnerDataSource(
122
- innerDataSource.filter((i: any) => (isLatestCreationTempRow ? row?.[EMPTY_ROW_TEMP_KEY_ATTR] !== i?.[EMPTY_ROW_TEMP_KEY_ATTR] : true))
123
- );
122
+ setInnerDataSource(innerDataSource
123
+ .filter((i: any) => isLatestCreationTempRow ? row?.[EMPTY_ROW_TEMP_KEY_ATTR] !== i?.[EMPTY_ROW_TEMP_KEY_ATTR] : true));
124
+
124
125
 
125
126
  // 同样的,需要移除选中数据中的当前行
126
127
  if (isLatestCreationTempRow) {
127
- onRowSelected(
128
- selectedRows.filter((r: any) => row?.[currentRowKey] !== r?.[currentRowKey]),
129
- false
130
- );
128
+ onRowSelected(selectedRows.filter((r: any) => row?.[currentRowKey] !== r?.[currentRowKey]), false);
131
129
  }
132
130
 
133
131
  // 倘若绑定了数据源,需要通过引用的方式,移除对应的临时数据
@@ -167,17 +165,14 @@ const useRowEdit = (props: any) => {
167
165
  const onRowAttrValsChange = (row: any, attr: string, newAttrVal: any, otherAttrVals: any) => {
168
166
  if (editMode === 'multiple') {
169
167
  const editRow = innerDataSource.find((r: any) => r[currentRowKey] === row[currentRowKey]);
170
- let syncPropsDataSourceRow: Record<string, any> = {};
171
- if (!tableUpdateInnerDataSource) {
172
- // 整表编辑时,需要将修改后的值同步到绑定的数据源
173
- syncPropsDataSourceRow = outerDataSource?.find((r: any) => r[currentRowKey] === row[currentRowKey]);
174
- }
168
+ // 整表编辑时,需要将修改后的值同步到绑定的数据源
169
+ const syncPropsDataSourceRow = outerDataSource?.find((r: any) => r[currentRowKey] === row[currentRowKey]) || {};
175
170
 
176
171
  // 兼容attr(表格的dataIndex)为层级的情况
177
172
  _.set(editRow, attr, newAttrVal);
178
173
  _.set(syncPropsDataSourceRow, attr, newAttrVal);
179
174
 
180
- Object.keys(otherAttrVals).forEach(op => {
175
+ Object.keys(otherAttrVals).forEach((op) => {
181
176
  editRow[op] = otherAttrVals[op];
182
177
  syncPropsDataSourceRow[op] = otherAttrVals[op];
183
178
  });
@@ -186,7 +181,7 @@ const useRowEdit = (props: any) => {
186
181
  }
187
182
 
188
183
  _.set(nowEditingData, attr, newAttrVal);
189
- Object.keys(otherAttrVals).forEach(op => {
184
+ Object.keys(otherAttrVals).forEach((op) => {
190
185
  nowEditingData[op] = otherAttrVals[op];
191
186
  });
192
187
  setNowEditingData({ ...nowEditingData });
@@ -198,12 +193,15 @@ const useRowEdit = (props: any) => {
198
193
 
199
194
  // 当处于编辑状态时,需要过滤来自编辑控件内部触发的 click
200
195
  while (target?.className !== curentTarget?.className) {
201
- if (!target) break;
196
+ if (!target) break;
202
197
  // 非当前行内元素,不再遍历
203
198
  if (!curentTarget.contains(target)) {
204
199
  return false;
205
200
  }
206
- if (typeof target?.className === 'string' && target.className.includes(EDIT_COMPONENT_STOP_PROPAGATION_CLS)) {
201
+ if (
202
+ typeof target?.className === 'string' &&
203
+ target.className.includes(EDIT_COMPONENT_STOP_PROPAGATION_CLS)
204
+ ) {
207
205
  return true;
208
206
  }
209
207
  target = target?.parentNode as HTMLBaseElement;
@@ -225,13 +223,16 @@ const useRowEdit = (props: any) => {
225
223
  // 当处于编辑状态时,需要过滤来自编辑控件内部触发的 doubleclick
226
224
  let stopDoubleClick = false;
227
225
  while (target?.className !== curentTarget?.className) {
228
- if (!target) break;
226
+ if (!target) break;
229
227
  // 非当前行内元素,不再遍历,不触发点击事件
230
228
  if (!curentTarget.contains(target)) {
231
229
  stopDoubleClick = true;
232
230
  break;
233
231
  }
234
- if (typeof target?.className === 'string' && target.className.includes(EDIT_COMPONENT_STOP_PROPAGATION_CLS)) {
232
+ if (
233
+ typeof target?.className === 'string' &&
234
+ target.className.includes(EDIT_COMPONENT_STOP_PROPAGATION_CLS)
235
+ ) {
235
236
  stopDoubleClick = true;
236
237
  break;
237
238
  }
@@ -245,11 +246,11 @@ const useRowEdit = (props: any) => {
245
246
  };
246
247
 
247
248
  /**
248
- * 判断表格可编辑时,里面是否可以操作
249
- * @param row 某行数据对象
250
- * @param index 某行所处当前页行索引
251
- * @returns
252
- */
249
+ * 判断表格可编辑时,里面是否可以操作
250
+ * @param row 某行数据对象
251
+ * @param index 某行所处当前页行索引
252
+ * @returns
253
+ */
253
254
  const handleIsRowEditableCanUse = (row: any, index?: number) => {
254
255
  // 存量:配置态生成的DSL是包含的完整代码的对象
255
256
  if (funcExpExecute && rowEditableRule?.code) {
@@ -263,8 +264,7 @@ const useRowEdit = (props: any) => {
263
264
  value: index,
264
265
  },
265
266
  ]);
266
- }
267
- if (funcExpExecute && rowEditableRule) {
267
+ } if (funcExpExecute && rowEditableRule) {
268
268
  /**
269
269
  * 新版:配置态生成的DSL就是一个$$包含函数的表达式
270
270
  * 但会经过预处理移除 $$
@@ -1,8 +1,13 @@
1
- import _ from 'lodash';
2
1
  import { useMemo } from 'react';
2
+ import _ from 'lodash';
3
3
 
4
4
  const useRowMerge = (props: any) => {
5
- const { currentPageDataSource, columns, nowInlineEditKey, currentRowKey } = props;
5
+ const {
6
+ currentPageDataSource,
7
+ columns,
8
+ nowInlineEditKey,
9
+ currentRowKey,
10
+ } = props;
6
11
 
7
12
  // 记录所有设置了行合并的列
8
13
  const rowSpanColMap = useMemo(() => {
@@ -35,10 +40,13 @@ const useRowMerge = (props: any) => {
35
40
  newD.children = recursiveSet(newD.children);
36
41
  }
37
42
  // 正在编辑的或者有子节点的不算入合并行计算中
38
- if ((nowInlineEditKey && currentRowKey && nowInlineEditKey === d[currentRowKey]) || newD?.children?.length > 0) {
43
+ if (
44
+ (nowInlineEditKey && currentRowKey && nowInlineEditKey === d[currentRowKey]) ||
45
+ newD?.children?.length > 0
46
+ ) {
39
47
  return newD;
40
48
  }
41
- Object.keys(rowSpanColMap).forEach(rowIndex => {
49
+ Object.keys(rowSpanColMap).forEach((rowIndex) => {
42
50
  __rowSpan[rowIndex] = 1;
43
51
  if (!parentSpanRowsMap[rowIndex]) {
44
52
  parentSpanRowsMap[rowIndex] = {
@@ -65,7 +73,7 @@ const useRowMerge = (props: any) => {
65
73
  parentSpanRowsMap[rowIndex].preIndex = i;
66
74
  }
67
75
  });
68
-
76
+
69
77
  tableRowSpan.set(newD, __rowSpan);
70
78
  tableRowClass.set(newD, __rowClass);
71
79
 
@@ -1,13 +1,21 @@
1
1
  import { useEventListener } from 'ahooks';
2
2
  import { useEffect, useMemo, useRef, useState } from 'react';
3
+ import { usePersistFn } from '../../utils/ahooks';
3
4
 
5
+ const DYNAMIC_PAGE_ROOT_CLASS = 'lcdp-renderer';
4
6
  const useScroll = (props: any) => {
5
- const { initLoadColWidth, finalcolumns, columnWidth, adjustModel, scroll: tableScroll } = props;
7
+ const {
8
+ initLoadColWidth,
9
+ finalcolumns,
10
+ columnWidth,
11
+ adjustModel,
12
+ scroll: tableScroll,
13
+ } = props;
6
14
 
7
15
  const tableWrapRef = useRef<any>();
8
16
  const initTableWrapWidthRef = useRef<any>();
9
- const initTableWrapPosition = useRef<any>();
10
-
17
+ const pageRootRef = useRef<Element>();
18
+
11
19
  const [tableScrollY, setTableScrollY] = useState<number | 'auto'>(0);
12
20
 
13
21
  /**
@@ -20,7 +28,7 @@ const useScroll = (props: any) => {
20
28
  const colWidths = finalcolumns.reduce(
21
29
  // 没有配置宽度的,计算时,默认给一个缺省值100
22
30
  (prev: any, next: any) => Number(prev) + Number(next.width || 100),
23
- [0]
31
+ [0],
24
32
  );
25
33
  const tableScrollX = tableScroll.x || 0;
26
34
 
@@ -36,56 +44,114 @@ const useScroll = (props: any) => {
36
44
  }, [finalcolumns, tableScroll]);
37
45
 
38
46
  const getTableWrapWidth = () => {
39
- return columnWidth.reduce((acc: number, width: number) => acc + width, 0);
47
+ return Object.keys(columnWidth).reduce((acc: number, key: string) => acc + columnWidth[key], 0);
48
+ };
49
+
50
+ const getCompOtherHeight = (comp: HTMLElement, propList: string[] = ['margin-bottom']) => {
51
+ if (!comp) return 0;
52
+ const computedStyle = window.getComputedStyle(comp);
53
+ const bottom = propList.reduce((p, n) => {
54
+ const num = Number(computedStyle.getPropertyValue(n).replace(/\D+/, '')) || 0;
55
+ return p + num;
56
+ }, 0);
57
+ return bottom;
40
58
  };
41
59
 
42
- const getTablePosition = () => {
43
- const initPosition = initTableWrapPosition.current;
44
- if (!initPosition) {
45
- const tableWrapPosition = tableWrapRef?.current?.getBoundingClientRect?.() || {};
46
- initTableWrapPosition.current = tableWrapPosition;
60
+ /**
61
+ * 获取组件到根节点的底部距离,包括了父级的paddingBottom和marginBottom
62
+ * @param comp 计算节点
63
+ * @param root 根节点
64
+ * @param ifContinue 是否继续遍历
65
+ */
66
+ const getCompBottomInPage = (comp: HTMLElement, ifContinue?: (currentNode: HTMLElement | null) => boolean) => {
67
+ let pageRoot: HTMLElement | null = null;
68
+ if (comp) {
69
+ let current: HTMLElement | null = comp;
70
+ let bottom = 0;
71
+ // 是否停止
72
+ let stop = false;
73
+ // 往上递归找到第一个引擎节点,视为根节点
74
+ while (current && !current.classList.contains(DYNAMIC_PAGE_ROOT_CLASS) && !stop) {
75
+ bottom += getCompOtherHeight(current, current === comp ? ['margin-bottom'] : ['margin-bottom', 'padding-bottom']);
76
+ stop = !ifContinue?.(current);
77
+ current = current.parentElement;
78
+ }
79
+ if (current?.classList.contains(DYNAMIC_PAGE_ROOT_CLASS)) {
80
+ pageRoot = current;
81
+ }
82
+ return {
83
+ bottom,
84
+ pageRoot,
85
+ };
47
86
  }
48
87
  return {
49
- initPosition: initTableWrapPosition.current,
88
+ bottom: 0,
89
+ pageRoot: null,
50
90
  };
51
91
  };
52
92
 
53
- const getCompOtherHeight = (comp: HTMLElement) => {
54
- if (!comp) return 0;
55
- const computedStyle = window.getComputedStyle(comp);
56
- const bottom = Number(computedStyle.getPropertyValue('margin-bottom').replace(/\D+/, '')) || 0;
57
- return bottom;
93
+ // 判断元素在父级是否最后一个元素
94
+ const checkIfLast = (comp: HTMLElement | null) => {
95
+ const parent = comp?.parentElement;
96
+ if (!parent) return true;
97
+ return Array.prototype.indexOf.call(parent?.children, comp) === (parent.children?.length - 1);
98
+ };
99
+
100
+ const setTimeoutUpdate = (update: FrameRequestCallback) => {
101
+ if (typeof requestAnimationFrame === 'function') {
102
+ window.requestAnimationFrame(update);
103
+ } else {
104
+ setTimeout(update);
105
+ }
58
106
  };
59
107
 
60
- const computedTablePosition = () => {
108
+ // 高度适配计算逻辑
109
+ const computedTablePosition = usePersistFn(() => {
110
+ let newScroll: typeof tableScrollY = 0;
61
111
  if (tableWrapRef.current) {
112
+ // 重置数据
62
113
  (tableWrapRef.current as HTMLElement).classList.remove('ued-table-fill-content');
63
114
  (tableWrapRef.current as HTMLElement).style.height = '';
64
115
  }
65
116
  if (tableWrapRef.current && !tableScroll?.y && adjustModel === 'fill') {
66
117
  // 当前表格所在位置
67
- const { initPosition } = getTablePosition();
118
+ const initPosition = tableWrapRef?.current?.getBoundingClientRect?.() || {};
68
119
  // 表格位置超过屏幕 1/2不自适应
69
- if (initPosition.y <= window.innerHeight / 2) {
70
- (tableWrapRef.current as HTMLElement).classList.add('ued-table-fill-content');
120
+ if (initPosition.top <= window.innerHeight / 2) {
71
121
  // 表格最后高度,要求表格为最后一个元素
72
- const tableHeight = window.innerHeight - initPosition.y;
73
- const otherHeight = getCompOtherHeight(tableWrapRef.current);
122
+ let isLast = true;
123
+ const { bottom: otherHeight, pageRoot } = getCompBottomInPage(tableWrapRef.current, (comp) => {
124
+ const parentIsRoot = comp?.parentElement?.classList.contains(DYNAMIC_PAGE_ROOT_CLASS);
125
+ if (!parentIsRoot && isLast) {
126
+ // 判断表格是否位于当前页面底部,当父级为dynamicPage根节点或者已经检索到不是最后一个元素时停止
127
+ isLast = checkIfLast(comp);
128
+ }
129
+ return isLast;
130
+ });
131
+ if (!isLast || !pageRoot) {
132
+ // 不是页面最后一个元素,不进行动态计算
133
+ return;
134
+ }
135
+ const { height, top, bottom: rootBottom } = pageRoot.getBoundingClientRect();
136
+ const tableHeight = height - (initPosition.top - top);
137
+ (tableWrapRef.current as HTMLElement).classList.add('ued-table-fill-content');
74
138
  tableWrapRef.current.style.height = `${tableHeight - otherHeight}px`;
75
- window.requestAnimationFrame(() => {
139
+ setTimeoutUpdate(() => {
76
140
  const { bottom } = tableWrapRef?.current?.getBoundingClientRect?.() || {};
77
- const bottomHeight = window.innerHeight - bottom;
141
+ const bottomHeight = height - (bottom - rootBottom);
78
142
  // 减去外层边距
79
143
  tableWrapRef.current.style.height = `${tableHeight - otherHeight - bottomHeight}px`;
80
144
  });
81
- setTableScrollY('auto');
145
+ newScroll = 'auto';
82
146
  }
83
147
  }
84
- };
148
+ setTableScrollY(newScroll);
149
+ });
150
+
85
151
 
86
152
  useEventListener('resize', () => {
87
153
  computedTablePosition();
88
- });
154
+ }, { target: pageRootRef.current });
89
155
 
90
156
  useEffect(() => {
91
157
  if (tableWrapRef.current) {
@@ -95,7 +161,7 @@ const useScroll = (props: any) => {
95
161
  }, [tableWrapRef.current]);
96
162
 
97
163
  const scroll: any = initLoadColWidth ? { ...tableScroll, x: getTableWrapWidth() } : realScroll;
98
- if (tableWrapRef.current && !tableScroll?.y && adjustModel === 'fill') {
164
+ if (tableWrapRef.current && !tableScroll?.y && adjustModel === 'fill' && tableScrollY) {
99
165
  scroll.y = tableScrollY;
100
166
  }
101
167