lu-lowcode-package-form 0.10.77 → 0.10.78

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.77",
3
+ "version": "0.10.78",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^4.8.1",
6
6
  "@dnd-kit/core": "^6.1.0",
package/src/App.jsx CHANGED
@@ -370,7 +370,7 @@ function App() {
370
370
 
371
371
  ]} label="发票类型" options={[{ label: '选项1', value: '1', shuilv: 15, }, { label: '选项2', value: '2', shuilv: 50 }, { label: '选项3', value: '3', shuilv: 2 }]} __id="fapiaoleixing" />
372
372
 
373
- <Field.Number label="税率(%)" __id="shuilv" calcHidden={true} />
373
+ <Field.Number label="税率(%)" __id="shuilv" />
374
374
 
375
375
  <Field.WithSingleSelect ref={testRef} fillRules={[
376
376
  {
@@ -468,94 +468,7 @@ function App() {
468
468
  <Layout.FormRow layout={'1'}>
469
469
  <Field.Table label="子表格" __id="table" isAllowAdd={true} isAllowCopy={false} >
470
470
 
471
- <Field.WithSingleSelect
472
- ref={testRef}
473
- request={async (params) => {
474
- console.log("request params", params)
475
- return { code: 0, data: { list: [{ label: '选项1', value: '1', tianchong2: { label: '选项2', value: '2' }, tcinput1: "1111", }, { label: '选项2', value: '2' }, { label: '选项3', value: '3' }] } }
476
- }}
477
- option_label="label"
478
- option_value="value"
479
- fillRules={[
480
- {
481
- "id": "636d3924-0298-4e9b-809a-26d4a10d7b19",
482
- "type": 0,
483
- "source": "tianchong2",
484
- "target": "tianchong2",
485
- "subRules": [
486
- ]
487
- },
488
- {
489
- "id": "636d3924-0298-4e9b-809a-26d4a10d7b11",
490
- "type": 0,
491
- "source": "tcinput1",
492
- "target": "tcinput1",
493
- "subRules": [
494
- ]
495
- },
496
-
497
- ]} label="测试填充1" __id="tianchong1" />
498
- <Field.WithSingleSelect
499
- ref={testRef}
500
- request={async (params) => {
501
- if (!params?.value) return { code: 0, data: { list: [{ label: '选项1', value: '1', }] } }
502
- await new Promise(resolve => setTimeout(resolve, 200))
503
- return { code: 0, data: { list: [{ label: '选项1', value: '1', }, { label: '选项2', value: '2', tcinput1: "8989", tcinput2: "2222" }, { label: '选项3', value: '3' }] } }
504
- }}
505
- option_label="label"
506
- option_value="value"
507
- option_search="label"
508
- fillRules={[
509
- {
510
- "id": "636d3924-0298-4e9b-809a-16d4a10d7b29",
511
- "type": 0,
512
- "source": "tcinput1",
513
- "target": "tcinput1",
514
- "subRules": [
515
- ]
516
- },
517
- {
518
- "id": "636d3924-0298-4e9b-809a-26d4a10d7b29",
519
- "type": 0,
520
- "source": "tcinput2",
521
- "target": "tcinput2",
522
- "subRules": [
523
- ]
524
- },
525
-
526
- ]} label="测试填充2" __id="tianchong2" />
527
- <Field.Input label="测试被填充1" __id="tcinput1" />
528
- <Field.Input label="测试被填充2" __id="tcinput2" />
529
- <Field.Input label="测试被填充计算" __id="tcinput3"
530
- withIds={["table.tcinput2"]}
531
- withFill={{
532
- "value": [
533
- {
534
- "insert": {
535
- "span": true
536
- },
537
- "attributes": {
538
- "id": "table.tcinput2",
539
- "color": "blue",
540
- "tagKey": "fieldsValue",
541
- "content": "当前表单.测试被填充2"
542
- }
543
- },
544
- {
545
- "insert": "* 0.5"
546
- },
547
- {
548
- "insert": "\n\n"
549
- }
550
- ],
551
- "version": 1719296886283,
552
- "withData": [
553
-
554
- ]
555
- }}
556
- />
557
-
558
- <Field.Number label="税率(%)" calcHidden={true} __id="shuilv_table" withIds={[
471
+ <Field.Number label="税率(%)" __id="shuilv_table" withIds={[
559
472
  "shuilv"
560
473
  ]}
561
474
  withFill={{
@@ -8,7 +8,7 @@ import { createPromiseWrapper } from "../../../utils"
8
8
  import { useCreation } from 'ahooks';
9
9
 
10
10
 
11
- const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsValue, shouldUpdateKey, value, type, defaultValue, onChange, option_label, option_value, option_search, options, request, requestParams, callError, subRequest, sub_option_label = "label", mode = "single", sub_option_value = "id", rightIconRender, rightIcon, rightIconClick, recordFieldsChange, ...props }, ref) => {
11
+ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsValue, shouldUpdateKey, value, type, defaultValue, onChange, option_label, option_value, option_search, options, request, requestParams, callError, subRequest, sub_option_label = "label", mode = "single", sub_option_value = "id", rightIconRender, rightIcon, rightIconClick, recordFieldsChange, getAllWithIds, ...props }, ref) => {
12
12
  const [nOptions, setNOptions] = React.useState([])
13
13
  const [fetching, setFetching] = useState(false);
14
14
 
@@ -221,7 +221,7 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
221
221
 
222
222
  </OriginalSelect>
223
223
  {!props?.disabled && rightIcon}
224
- {!props?.disabled && typeof rightIconRender === 'function' && rightIconRender({ value, onChange, form, fieldName, recordFieldsChange })}
224
+ {!props?.disabled && typeof rightIconRender === 'function' && rightIconRender({ value, onChange, form, fieldName, recordFieldsChange,getAllWithIds })}
225
225
  </BaseWrapper>
226
226
  ) : (<>
227
227
  <OriginalSelect
@@ -240,7 +240,7 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
240
240
 
241
241
  </OriginalSelect>
242
242
  {!props?.disabled && rightIcon}
243
- {!props?.disabled && typeof rightIconRender === 'function' && rightIconRender({ value, onChange, form, fieldName, recordFieldsChange })}
243
+ {!props?.disabled && typeof rightIconRender === 'function' && rightIconRender({ value, onChange, form, fieldName, recordFieldsChange,getAllWithIds })}
244
244
  </>
245
245
  )
246
246
 
@@ -33,7 +33,7 @@ const TableCol = ({ children, width, hidden, ...props }) => {
33
33
  </div>
34
34
  }
35
35
 
36
- const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow, form, fieldName, initializeFormRender, recordFieldsChange, mode, isAllowCopy=false, isAllowAdd=true, ...props }) => {
36
+ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow, form, fieldName, initializeFormRender, recordFieldsChange, getTableWithIds, mode, isAllowCopy=false, isAllowAdd=true, ...props }) => {
37
37
  useEffect(() => {
38
38
  // console.log("Table form reload", form)
39
39
  }, [form])
@@ -61,7 +61,12 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
61
61
  }
62
62
 
63
63
  }, [])
64
-
64
+ const getAllWithIds = () => {
65
+ if (typeof getTableWithIds === 'function') {
66
+ return getTableWithIds(childrenIds)
67
+ }
68
+ return []
69
+ }
65
70
  if (props.isRequired)
66
71
  rules.push({ required: true, message: `子表[${props.label}]必须填写` });
67
72
  return <Form.List name={name} rules={rules}>
@@ -164,7 +169,8 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
164
169
  fieldName: [fieldName, field.name, col_id],
165
170
  fieldsValue: fieldsValue,
166
171
  initializeFormRender,
167
- recordFieldsChange
172
+ recordFieldsChange,
173
+ getAllWithIds: getAllWithIds,
168
174
  })}
169
175
  </Form.Item>
170
176
  }}
@@ -167,8 +167,8 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
167
167
 
168
168
  // 计算字段级联关系
169
169
  const handleFieldsWith = (identifier, fieldValues, init = false) => {
170
+ console.log("handleFieldsWith identifier", identifier)
170
171
  let needRefresh = false;
171
-
172
172
  let parentIdentifier = [];
173
173
  if (Array.isArray(identifier)) {
174
174
  parentIdentifier = [...(identifier.slice(0, -1))]
@@ -322,6 +322,8 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
322
322
  // 处理级联数据源
323
323
  // 处理级联填充
324
324
  const handleFieldsWithFill = async (fieldValues, child, parentIdentifier, componentName) => {
325
+ console.log("handleFieldsWithFill child.identifier", child.identifier)
326
+ console.log("handleFieldsWithFill parentIdentifier", parentIdentifier)
325
327
  const withFill = child?.component?.props.withFill;
326
328
  const withDataFetch = child?.component?.props.withDataFetch;
327
329
  let withFillIndex = 0
@@ -479,7 +481,8 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
479
481
 
480
482
  debounceHandleFieldsChange();
481
483
  }
482
- const handleTableAddRow = (ids) => {
484
+
485
+ const getTableWithIds = (ids) => {
483
486
  let withAllIds = []
484
487
  ids.forEach(id => {
485
488
  if (!dependencyMap.current.has(id)) return
@@ -492,6 +495,10 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
492
495
  if (typeof withValue != "number" && !withValue) return false
493
496
  return true
494
497
  })
498
+ return withAllIds
499
+ }
500
+ const handleTableAddRow = (ids) => {
501
+ let withAllIds = getTableWithIds(ids)
495
502
  const fieldValues = form.getFieldsValue();
496
503
  setTimeout(() => {
497
504
  withAllIds.forEach(withid => {
@@ -553,7 +560,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
553
560
 
554
561
  let childComponent
555
562
  if (isTable || isLayoutComponent) {
556
- childComponent = React.cloneElement(child, { onTableAddRow: handleTableAddRow, onTableRemoveRow: handleTableRemoveRow, form: form, fieldName: identifier, onCustomChange, initializeFormRender, mode, recordFieldsChange })
563
+ childComponent = React.cloneElement(child, { onTableAddRow: handleTableAddRow, getTableWithIds, onTableRemoveRow: handleTableRemoveRow, form: form, fieldName: identifier, onCustomChange, initializeFormRender, mode, recordFieldsChange })
557
564
  }
558
565
  else if (componentName === "Field.WithSingleSelect" || componentName === "Field.WithMultipleSelect" || componentName === "Show.WithTable") {
559
566
  childComponent = <Form.Item