lu-lowcode-package-form 0.10.70 → 0.10.72

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.10.70",
3
+ "version": "0.10.72",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^4.8.1",
6
6
  "@dnd-kit/core": "^6.1.0",
package/src/App.jsx CHANGED
@@ -105,7 +105,7 @@ function App() {
105
105
  }
106
106
  }
107
107
  const setFormFields = () => {
108
- formRef?.current?.setFieldsValue({"__id":1,"userselect":"1213131","remark11":{"label":"选项1","value":"1","name":"1111","table":"[{\"price\":1,\"num\":2},{\"price\":2,\"num\":2},{\"price\":3,\"num\":3},{\"price\":3,\"num\":3}]"},"table2":[{}],"table":[{"product_num1":"123","product_sum1":"","node_oclxmzswzti":"","select2":"","switch_table":false,"remark11":{"label":"选项2","value":"2"},"product_price12":"","tianchong1":{"label":"选项1","value":"1","tianchong2":{"label":"选项2","value":"2"},"tcinput1":"1111"},"tianchong2":{"label":"选项2","value":"2","tcinput1":"8989","tcinput2":"2222"},"tcinput1":"8989","tcinput2":"2222","tcinput3":"1111"},{"product_num1":"213","product_sum1":"","node_oclxmzswzti":"","select2":"","switch_table":false,"datetime2":"2024-08-22 11:09:07","product_price13":1,"product_price14":2,"product_price12":"","remark11":{"label":"选项3","value":"3"},"product_price11":3}],"product_total_price":"0.00","DeptSelect":["leaf11"],"PostSelect":["parent 1-1","leaf11"],"searchuser":[{"id":2,"name":"2222","label":"2222","value":2},{"id":4,"name":"4444","label":"4444","value":4}],"product_price":"213","product_num":"21","product_num_range":[1,22],"product_sum":"4473","switch":false,"datetime":"2024-08-25","datetime2":"2024-08-25","datetime3":"","datetime4":"2024-08-22 11:09:04","remark12":[{"label":"选项1","value":"1"},{"label":"选项2","value":"2"}]})
108
+ formRef?.current?.setFieldsValue({ "__id": 1, "userselect": "1213131", "remark11": { "label": "选项1", "value": "1", "name": "1111", "table": "[{\"price\":1,\"num\":2},{\"price\":2,\"num\":2},{\"price\":3,\"num\":3},{\"price\":3,\"num\":3}]" }, "table2": [{}], "table": [{ "product_num1": "123", "product_sum1": "", "node_oclxmzswzti": "", "select2": "", "switch_table": false, "remark11": { "label": "选项2", "value": "2" }, "product_price12": "", "tianchong1": { "label": "选项1", "value": "1", "tianchong2": { "label": "选项2", "value": "2" }, "tcinput1": "1111" }, "tianchong2": { "label": "选项2", "value": "2", "tcinput1": "8989", "tcinput2": "2222" }, "tcinput1": "8989", "tcinput2": "2222", "tcinput3": "1111" }, { "product_num1": "213", "product_sum1": "", "node_oclxmzswzti": "", "select2": "", "switch_table": false, "datetime2": "2024-08-22 11:09:07", "product_price13": 1, "product_price14": 2, "product_price12": "", "remark11": { "label": "选项3", "value": "3" }, "product_price11": 3 }], "product_total_price": "0.00", "DeptSelect": ["leaf11"], "PostSelect": ["parent 1-1", "leaf11"], "searchuser": [{ "id": 2, "name": "2222", "label": "2222", "value": 2 }, { "id": 4, "name": "4444", "label": "4444", "value": 4 }], "product_price": "213", "product_num": "21", "product_num_range": [1, 22], "product_sum": "4473", "switch": false, "datetime": "2024-08-25", "datetime2": "2024-08-25", "datetime3": "", "datetime4": "2024-08-22 11:09:04", "remark12": JSON.stringify( [{ "label": "选项1", "value": "1" }, { "label": "选项2", "value": "2" }] )})
109
109
  // formRef?.current?.setFieldsValue({"tianchong1":{"label":"选项1","value":"1"}, })
110
110
  }
111
111
  const handleCols = () => {
@@ -135,7 +135,7 @@ function App() {
135
135
  }}>testwithref</Button>
136
136
  <Button type="primary" onClick={handleCols}>UpdateCol</Button>
137
137
  <Button type="primary" onClick={handleUpdateReadonly}>UpdateReadonly</Button>
138
- </div>
138
+ </div>
139
139
 
140
140
  <div className=" fflex fflex-col fitems-center fflex-1 foverflow-y-auto">
141
141
  <DraggableBtn />
@@ -186,11 +186,11 @@ function App() {
186
186
 
187
187
 
188
188
  <FormContainerWrapper cols={cols} className="" ref={formRef} >
189
- <Field.MultipleSelect mode="multiple" option_label={"label"} option_value={"value"} label="测试过滤条件" __id="selecta1" request={async (params) => {
189
+ <Field.MultipleSelect mode="multiple" option_label={"label"} option_value={"value"} label="测试过滤条件" __id="selecta1" request={async (params) => {
190
190
  return { code: 0, data: { list: [{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }] } }
191
191
  }}></Field.MultipleSelect>
192
192
  <Layout.FormRow layout={'1'}>
193
-
193
+
194
194
  <Show.WithTable label="测试关联子表" __id="withtable1"
195
195
  filterRules={[
196
196
  {
@@ -212,7 +212,7 @@ function App() {
212
212
  </Layout.FormRow>
213
213
  <Field.Number label="测试" __id="aa2" isRequired={true} />
214
214
  <Field.Number label="测试" __id="aa3" readonly={readonly} />
215
- <Field.Number label="测试" __id="aa1" calcHidden={true} readonly={readonly} />
215
+ <Field.Number label="测试" __id="aa1" calcHidden={true} readonly={readonly} />
216
216
  <Field.Number label="测试" __id="aa4" readonly={readonly} />
217
217
  <Field.UserSelect label="选择用户" __id="userselect" defaultValue={[{ id: 1, username: "十天" }]} readonly={readonly} />
218
218
  <Layout.FormGroupTitle title={"基本信息"} />
@@ -222,7 +222,7 @@ function App() {
222
222
  // console.log("rightIconRender fieldName", fieldName)
223
223
  return <><PrinterOutlined /></>
224
224
  }}
225
- ref={testRef} fillRules={[
225
+ ref={testRef} fillRules={[
226
226
  {
227
227
  "id": "636d3924-0298-4e9b-809a-26d4a10d7b89",
228
228
  "type": 0,
@@ -236,7 +236,7 @@ function App() {
236
236
 
237
237
  <Field.Number label="税率(%)" __id="shuilv" calcHidden={true} />
238
238
 
239
- <Field.WithSingleSelect ref={testRef} fillRules={[
239
+ <Field.WithSingleSelect ref={testRef} fillRules={[
240
240
  {
241
241
  "id": "636d3924-0298-4e9b-809a-26d4a10d7b89",
242
242
  "type": 0,
@@ -269,71 +269,71 @@ function App() {
269
269
  }
270
270
  ]} label="测试关联单选" options={[{ label: '选项1', value: '1', name: "1111", table: "[{\"price\":1,\"num\":2},{\"price\":2,\"num\":2},{\"price\":3,\"num\":3},{\"price\":3,\"num\":3}]" }, { label: '选项2', value: '2' }]} __id="remark11" />
271
271
  <Layout.FormRow layout={'1'}>
272
- <Field.Number label="测试规则" __id="ceshi_rule1" />
272
+ <Field.Number label="测试规则" __id="ceshi_rule1" />
273
273
  </Layout.FormRow>
274
274
  <Layout.FormRow layout={'1'}>
275
275
  <Field.Table label="子表格" __id="table2" isAllowCopy={true} >
276
- <Field.Number label="测试规则2" __id="ceshi_rule2" />
276
+ <Field.Number label="测试规则2" __id="ceshi_rule2" />
277
277
  </Field.Table>
278
278
  </Layout.FormRow>
279
-
279
+
280
280
  <Field.WithSingleSelect
281
- ref={testRef}
282
- request={async (params) => {
283
- console.log("request params", params);
284
- const { page = 1 ,pageSize = 10} = params; // 获取当前页码,默认为1
285
-
286
-
287
- // 模拟数据集
288
- const allData = [
289
- { label: '选项1', value: '1' },
290
- { label: '选项2', value: '2' },
291
- { label: '选项3', value: '3' },
292
- { label: '选项4', value: '4' },
293
- { label: '选项5', value: '5' },
294
- { label: '选项6', value: '6' },
295
- { label: '选项7', value: '7' },
296
- { label: '选项8', value: '8' },
297
- { label: '选项9', value: '9' },
298
- { label: '选项10', value: '10' },
299
- { label: '选项11', value: '11' },
300
- { label: '选项12', value: '12' },
301
- { label: '选项13', value: '13' },
302
- { label: '选项14', value: '14' },
303
- { label: '选项15', value: '15' },
304
- { label: '选项16', value: '16' },
305
- { label: '选项17', value: '17' },
306
- { label: '选项18', value: '18' },
307
- { label: '选项19', value: '19' },
308
- { label: '选项20', value: '20' },
309
- { label: '选项21', value: '21' },
310
- { label: '选项22', value: '22' },
311
- { label: '选项23', value: '23' },
312
- { label: '选项24', value: '24' }
313
- ];
314
-
315
- // 根据页码和每页数据量计算当前页的数据
316
- const startIndex = (page - 1) * pageSize;
317
- const endIndex = startIndex + pageSize;
318
- let pageData = []
319
- if (startIndex < allData.length) {
320
- pageData = allData.slice(startIndex, endIndex);
321
- }
322
-
323
- let result = { code: 0, data: { list: pageData } };
324
- console.log("request result", result)
325
- await new Promise(resolve => setTimeout(resolve, 200))
326
- return result
327
- }}
328
- option_label="label"
329
- option_value="value"
330
- label="测试请求" __id="ceshirequest" />
281
+ ref={testRef}
282
+ request={async (params) => {
283
+ console.log("request params", params);
284
+ const { page = 1, pageSize = 10 } = params; // 获取当前页码,默认为1
285
+
286
+
287
+ // 模拟数据集
288
+ const allData = [
289
+ { label: '选项1', value: '1' },
290
+ { label: '选项2', value: '2' },
291
+ { label: '选项3', value: '3' },
292
+ { label: '选项4', value: '4' },
293
+ { label: '选项5', value: '5' },
294
+ { label: '选项6', value: '6' },
295
+ { label: '选项7', value: '7' },
296
+ { label: '选项8', value: '8' },
297
+ { label: '选项9', value: '9' },
298
+ { label: '选项10', value: '10' },
299
+ { label: '选项11', value: '11' },
300
+ { label: '选项12', value: '12' },
301
+ { label: '选项13', value: '13' },
302
+ { label: '选项14', value: '14' },
303
+ { label: '选项15', value: '15' },
304
+ { label: '选项16', value: '16' },
305
+ { label: '选项17', value: '17' },
306
+ { label: '选项18', value: '18' },
307
+ { label: '选项19', value: '19' },
308
+ { label: '选项20', value: '20' },
309
+ { label: '选项21', value: '21' },
310
+ { label: '选项22', value: '22' },
311
+ { label: '选项23', value: '23' },
312
+ { label: '选项24', value: '24' }
313
+ ];
314
+
315
+ // 根据页码和每页数据量计算当前页的数据
316
+ const startIndex = (page - 1) * pageSize;
317
+ const endIndex = startIndex + pageSize;
318
+ let pageData = []
319
+ if (startIndex < allData.length) {
320
+ pageData = allData.slice(startIndex, endIndex);
321
+ }
322
+
323
+ let result = { code: 0, data: { list: pageData } };
324
+ console.log("request result", result)
325
+ await new Promise(resolve => setTimeout(resolve, 200))
326
+ return result
327
+ }}
328
+ option_label="label"
329
+ option_value="value"
330
+ label="测试请求" __id="ceshirequest" />
331
331
 
332
332
  <Layout.FormRow layout={'1'}>
333
333
  <Field.Table label="子表格" __id="table" isAllowAdd={true} isAllowCopy={false} >
334
334
 
335
335
  <Field.WithSingleSelect
336
- ref={testRef}
336
+ ref={testRef}
337
337
  request={async (params) => {
338
338
  console.log("request params", params)
339
339
  return { code: 0, data: { list: [{ label: '选项1', value: '1', tianchong2: { label: '选项2', value: '2' }, tcinput1: "1111", }, { label: '选项2', value: '2' }, { label: '选项3', value: '3' }] } }
@@ -360,7 +360,7 @@ function App() {
360
360
 
361
361
  ]} label="测试填充1" __id="tianchong1" />
362
362
  <Field.WithSingleSelect
363
- ref={testRef}
363
+ ref={testRef}
364
364
  request={async (params) => {
365
365
  if (!params?.value) return { code: 0, data: { list: [{ label: '选项1', value: '1', }] } }
366
366
  await new Promise(resolve => setTimeout(resolve, 200))
@@ -419,7 +419,7 @@ function App() {
419
419
  }}
420
420
  />
421
421
 
422
- <Field.Number label="税率(%)" calcHidden={true} __id="shuilv_table" withIds={[
422
+ <Field.Number label="税率(%)" calcHidden={true} __id="shuilv_table" withIds={[
423
423
  "shuilv"
424
424
  ]}
425
425
  withFill={{
@@ -493,8 +493,8 @@ function App() {
493
493
  ]} label="测试关联单选" __id="remark11" />
494
494
 
495
495
  <Field.Switch label="开关" __id="switch_table"></Field.Switch>
496
- <Field.Input defaultValue={3} label="含税单价" __id="product_price11" />
497
- <Field.Input label="未税单价" __id="product_price12"
496
+ <Field.Input defaultValue={3} label="含税单价" __id="product_price11" />
497
+ <Field.Input label="未税单价" __id="product_price12"
498
498
  withIds={[
499
499
  "table.product_price11",
500
500
  "shuilv"
@@ -539,10 +539,10 @@ function App() {
539
539
  ]
540
540
  }}
541
541
  />
542
- <Field.Input defaultValue={1} label="商品价格" __id="product_price13" />
543
- <Field.Input defaultValue={2} label="商品价格" __id="product_price14" />
544
- <Field.Input label="商品价格" __id="product_price1" />
545
- <Field.Input label="商品个数" __id="product_num1" />
542
+ <Field.Input defaultValue={1} label="商品价格" __id="product_price13" />
543
+ <Field.Input defaultValue={2} label="商品价格" __id="product_price14" />
544
+ <Field.Input label="商品价格" __id="product_price1" />
545
+ <Field.Input label="商品个数" __id="product_num1" />
546
546
  <Field.Input disabled={true} label="商品总价" __id="product_sum1"
547
547
  withIds={["table.product_price1", "table.product_num1"]}
548
548
  withFill={{
@@ -637,7 +637,7 @@ function App() {
637
637
  ],
638
638
  },]}></Field.PostSelect>
639
639
  <Field.SearchSelect mode='multiple' label="搜组件" __id="searchuser" request={searchSelectRequest} option_search={"name"} option_label="name" option_value="id"></Field.SearchSelect>
640
- <Field.Input label="商品价格" __id="product_price" defaultValue={"12"} disabled={true} />
640
+ <Field.Input label="商品价格" __id="product_price" defaultValue={"12"} disabled={true} />
641
641
  <Field.Input label="商品数量" __id="product_num" rules={"^(1[3-9]\\d{9})$"} />
642
642
  <Field.NumberRange label="数量范围" __id="product_num_range" />
643
643
  <Field.Input rules={["^(1[3-9]\\d{9})$", "^\\d+$"]} label="商品总价" __id="product_sum"
@@ -702,7 +702,7 @@ function App() {
702
702
  }}>1111</div>
703
703
  <Field.DatePicker defaultNow={true} label="datetime" prompt="" datetype="month" value='2022-10-22' __id="datetime" />
704
704
  <Field.DatePicker label="datetime2" prompt="" datetype="date" __id="datetime2" />
705
- <Field.DatePicker disabled={true} defaultNow={true} label="datetime3" prompt="" datetype="datetime" value={'2022-10-22'} __id="datetime3" />
705
+ <Field.DatePicker disabled={true} defaultNow={true} label="datetime3" prompt="" datetype="datetime" value={'2022-10-22'} __id="datetime3" />
706
706
  <Field.DatePicker defaultNow={true} label="datetime4" prompt="" datetype="year" value={'2022-10-22'} __id="datetime4" />
707
707
  <Field.Input label="角色名称" __id="name" />
708
708
  <Layout.FormRow layout={'1,1'}>
@@ -37,6 +37,8 @@ export const BaseWrapper = ({
37
37
  useEffect(()=>{
38
38
  if (calcHiddenRef.current != calcHidden)
39
39
  {
40
+ console.log(label+" calcHiddenRef.current", calcHiddenRef.current)
41
+ console.log(label+" calcHiddenRef.current", calcHidden)
40
42
  typeof initializeFormRender == "function" && initializeFormRender();
41
43
  calcHiddenRef.current = calcHidden;
42
44
  }
@@ -58,11 +58,20 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
58
58
  setFieldsValue: (values) => {
59
59
  lockStatus.current = 1;
60
60
  let formData = { ...values, __id: values?.id }
61
- form.setFieldsValue(formData)
62
61
  for (let key in values) {
63
62
  changedFieldsState.current[key] = { name: key, value: values[key] }
63
+ if (dependencyMap.current.has(key) && dependencyMap.current.get(key).componentName == "Field.Table" && Array.isArray(values[key]) ) {
64
+ for (let index = 0; index < values[key].length; index++) {
65
+ const element = values[key][index];
66
+ for (let elem_key in element) {
67
+ changedFieldsState.current[[key,index,elem_key]] = { name: [key,index,elem_key], value: element[elem_key] }
68
+ }
69
+ }
70
+ }
64
71
  }
65
- debounceHandleFieldsChange()
72
+ console.log("changedFieldsState", changedFieldsState.current)
73
+ form.setFieldsValue(formData)
74
+ // setTimeout(()=>{debounceHandleFieldsChange()},0)
66
75
  },
67
76
  initializeFieldVisibility,
68
77
  }), []);
@@ -428,6 +437,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
428
437
 
429
438
  const changedFieldsState = React.useRef({});
430
439
  const debounceHandleFieldsChange = debounce(() => {
440
+ console.log("debounceHandleFieldsChange")
431
441
  const fieldValues = form.getFieldsValue();
432
442
  const lockStatus_ = lockStatus.current;
433
443
  lockStatus.current = 0
@@ -440,6 +450,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
440
450
  console.log("!isEqual field.name", field.name)
441
451
  console.log("field.value", field.value)
442
452
  console.log("getLastFieldValue(field.name)", getLastFieldValue(field.name))
453
+ console.log("lockStatus_",lockStatus_)
443
454
  if (lockStatus_ != 1) {
444
455
  needRefresh = handleFieldsWith(field.name, fieldValues);
445
456
  }
@@ -496,6 +507,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
496
507
 
497
508
  const shouldUpdateKey = React.useRef({})
498
509
  const renderChildren = () => {
510
+ console.log("renderChildren")
499
511
  const childrenArray = React.Children.toArray(children);
500
512
  const groupedChildren = batchElements(
501
513
  childrenArray.filter(child => {
@@ -564,6 +576,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
564
576
  }
565
577
  if (result) {
566
578
  shouldUpdateKey.current[identifier] = nanoid()
579
+ console.log(identifier, nanoid())
567
580
  }
568
581
  return result;
569
582
  }}
@@ -610,10 +623,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
610
623
  };
611
624
 
612
625
  return (
613
- <Form form={form} className={"form-container fp-0 fw-full fh-full box-border fflex fflex-col fgap-y-2" + (mode == "desgin" ? " fp-6" : "")} onValuesChange={(changedValues, allValues) => {
614
- // console.log("changedValues", changedValues)
615
- // console.log("allValues", allValues)
616
- }} onFieldsChange={handleFieldsChange}>
626
+ <Form form={form} className={"form-container fp-0 fw-full fh-full box-border fflex fflex-col fgap-y-2" + (mode == "desgin" ? " fp-6" : "")} onFieldsChange={handleFieldsChange}>
617
627
  <Form.Item name="__id" hidden={true}>
618
628
  <input type="hidden" />
619
629
  </Form.Item>