lu-lowcode-package-form 0.11.1 → 0.11.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lu-lowcode-package-form",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^4.8.1",
6
6
  "@dnd-kit/core": "^6.1.0",
package/src/App.jsx CHANGED
@@ -230,7 +230,7 @@ function App() {
230
230
 
231
231
  <Field.Input label="测试 withVisible" __id="withVisible"
232
232
  isRequired={true}
233
- withIds={["fill_datasource1"]}
233
+ withIds={["routeType"]}
234
234
  withVisible={{
235
235
  "value": [
236
236
  {
@@ -238,7 +238,7 @@ function App() {
238
238
  "span": true
239
239
  },
240
240
  "attributes": {
241
- "id": "fill_datasource1",
241
+ "id": "routeType",
242
242
  "color": "blue",
243
243
  "tagKey": "fieldsValue",
244
244
  "content": "当前表单.开关"
@@ -252,7 +252,8 @@ function App() {
252
252
  "withData": [
253
253
 
254
254
  ]
255
- }} />
255
+ }}
256
+ />
256
257
 
257
258
  <Field.Select label="绑定表单"
258
259
  option_label={"formTitle"}
@@ -157,17 +157,17 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
157
157
  };
158
158
 
159
159
  // 初始化字段的级联关系
160
- const initializeFieldVisibility = (reloadFields = false) => {
160
+ const initializeFieldVisibility = async (reloadFields = false) => {
161
161
  console.log("initializeFieldVisibility")
162
162
  const fieldValues = form.getFieldsValue();
163
163
  for (let key of dependencyMap.current.keys()) {
164
- handleFieldsWith(key, fieldValues, true);
164
+ handleFieldsWith(key, fieldValues, true);
165
165
  }
166
166
  if (reloadFields) setFormContent(renderChildren());
167
167
  };
168
168
 
169
169
  // 计算字段级联关系
170
- const handleFieldsWith = (identifier, fieldValues, init = false) => {
170
+ const handleFieldsWith = async (identifier, fieldValues, init = false) => {
171
171
  console.log("handleFieldsWith identifier", identifier)
172
172
  let needRefresh = false;
173
173
  let parentIdentifier = [];
@@ -183,14 +183,15 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
183
183
  if (!init && dependent?.fillRules && Array.isArray(dependent?.fillRules) && dependent?.fillRules.length > 0) {
184
184
  handleFillRules(identifier, parentIdentifier, fieldValues, dependent?.fillRules)
185
185
  }
186
- dependentChildren.forEach(child => {
186
+ for (let index = 0; index < dependentChildren.length; index++) {
187
+ const child = dependentChildren[index];
187
188
  if (child.component.props.withVisibleFunc && typeof child.component.props.withVisibleFunc === 'function') {
188
189
  let needRefresh_ = handleFieldsVisibleFunc(fieldValues, child, parentIdentifier)
189
190
  needRefresh = needRefresh || needRefresh_
190
191
  }
191
192
 
192
193
  if (child.component.props.withVisible) {
193
- let needRefresh_ = handleFieldsVisible(fieldValues, child, parentIdentifier, dependent?.componentName)
194
+ let needRefresh_ = await handleFieldsVisible(fieldValues, child, parentIdentifier, dependent?.componentName)
194
195
  needRefresh = needRefresh || needRefresh_
195
196
  }
196
197
 
@@ -198,7 +199,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
198
199
  if (!init && child.component.props.withFill)
199
200
  handleFieldsWithFill(fieldValues, child, parentIdentifier, dependent?.componentName)
200
201
 
201
- });
202
+ }
202
203
  }
203
204
  return needRefresh;
204
205
 
@@ -515,7 +516,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
515
516
  console.log(`${childIdentifier} 计算公式:`, formula)
516
517
  console.log(`${childIdentifier} 计算结果:`, formulaResult)
517
518
  form.setFieldValue(childIdentifier, formulaResult)
518
- handleFieldsWith(childIdentifier, form.getFieldsValue())
519
+ await handleFieldsWith(childIdentifier, form.getFieldsValue())
519
520
  }
520
521
  }
521
522
 
@@ -557,7 +558,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
557
558
 
558
559
  const delay = lockStatus.current === 1 ? 500 : 100;
559
560
 
560
- timeoutRef.current = setTimeout(() => {
561
+ timeoutRef.current = setTimeout(async () => {
561
562
 
562
563
  const fieldValues = form.getFieldsValue();
563
564
  const lockStatus_ = lockStatus.current;
@@ -570,7 +571,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
570
571
  if (!isEqual(field.value || "", getLastFieldValue(field.name) || "")) {
571
572
  if (lockStatus_ != 1) {
572
573
  console.log("handleFieldsWith field.name", field.name)
573
- needRefresh = handleFieldsWith(field.name, fieldValues);
574
+ needRefresh = await handleFieldsWith(field.name, fieldValues);
574
575
  }
575
576
  lastFormValues.current[field.name] = field.value;
576
577
  }
@@ -609,21 +610,23 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
609
610
  })
610
611
  return withAllIds
611
612
  }
612
- const handleTableAddRow = (ids) => {
613
+ const handleTableAddRow = (ids) => {
613
614
  let withAllIds = getTableWithIds(ids)
614
615
  const fieldValues = form.getFieldsValue();
615
- setTimeout(() => {
616
- withAllIds.forEach(withid => {
617
- handleFieldsWith(withid, fieldValues);
618
- })
616
+ setTimeout(async () => {
617
+ for (let index = 0; index < withAllIds.length; index++) {
618
+ const withid = withAllIds[index];
619
+ await handleFieldsWith(withid, fieldValues);
620
+ }
619
621
  }, 0);
620
622
  }
621
- const handleTableRemoveRow = (ids) => {
623
+ const handleTableRemoveRow = async (ids) => {
622
624
  const fieldValues = form.getFieldsValue();
623
- setTimeout(() => {
624
- ids.forEach(id => {
625
- handleFieldsWith(id, fieldValues);
626
- })
625
+ setTimeout(async () => {
626
+ for (let index = 0; index < ids.length; index++) {
627
+ const id = ids[index];
628
+ await handleFieldsWith(id, fieldValues);
629
+ }
627
630
  }, 0);
628
631
  }
629
632