lu-lowcode-package-form 0.10.76 → 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/dist/index.cjs.js +257 -257
- package/dist/index.es.js +21221 -21182
- package/package.json +2 -1
- package/src/App.jsx +141 -92
- package/src/components/field/select/search-select.jsx +39 -57
- package/src/components/field/table/index.jsx +9 -3
- package/src/components/form-container/index.jsx +10 -5
- package/src/utils/index.jsx +2 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "lu-lowcode-package-form",
|
3
|
-
"version": "0.10.
|
3
|
+
"version": "0.10.78",
|
4
4
|
"dependencies": {
|
5
5
|
"@ant-design/icons": "^4.8.1",
|
6
6
|
"@dnd-kit/core": "^6.1.0",
|
@@ -14,6 +14,7 @@
|
|
14
14
|
"@wangeditor-next/editor-for-react": "^1.0.7",
|
15
15
|
"@wangeditor/editor": "^5.1.23",
|
16
16
|
"@wangeditor/editor-for-react": "^1.0.6",
|
17
|
+
"ahooks": "^3.8.4",
|
17
18
|
"antd": "^5.13.2",
|
18
19
|
"dayjs": "^1.11.11",
|
19
20
|
"eventemitter3": "^5.0.1",
|
package/src/App.jsx
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import { FormContainer, Field, FormContainerWrapper, Layout, Setter, EditorQuill, EditorWang, EditorWang2, EditorWang3, WangEditor, WangEditorNext, Show } from './components';
|
2
2
|
import './App.css';
|
3
3
|
import { Button, Input, Select } from 'antd';
|
4
|
-
import React, { useEffect, useState } from 'react';
|
4
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
5
5
|
import Draggable from 'react-draggable';
|
6
|
-
import { throttle } from 'lodash';
|
6
|
+
import { throttle , debounce} from 'lodash';
|
7
7
|
import { SortList } from "./components"
|
8
8
|
import { TinyMCEEditor } from './components'
|
9
9
|
import { PrinterOutlined } from '@ant-design/icons';
|
@@ -81,7 +81,16 @@ function App() {
|
|
81
81
|
const [testCalcHidden, setTestCalcHidden] = useState(false);
|
82
82
|
const [readonly, setReadonly] = useState(true);
|
83
83
|
|
84
|
+
const testdebounce = useCallback( debounce((param1,param2)=>{
|
85
|
+
console.log("testdebounce param1",param1)
|
86
|
+
console.log("testdebounce param2",param2)
|
87
|
+
},200))
|
88
|
+
|
89
|
+
|
84
90
|
useEffect(() => {
|
91
|
+
testdebounce(1,2)
|
92
|
+
testdebounce(11,22)
|
93
|
+
testdebounce(111,222)
|
85
94
|
// console.log("testRef //////", testRef.current)
|
86
95
|
}, [testRef.current])
|
87
96
|
const [cols, setCols] = React.useState(3);
|
@@ -105,7 +114,7 @@ function App() {
|
|
105
114
|
}
|
106
115
|
}
|
107
116
|
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": "
|
117
|
+
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": "2222" }, { "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
118
|
// formRef?.current?.setFieldsValue({"tianchong1":{"label":"选项1","value":"1"}, })
|
110
119
|
}
|
111
120
|
const handleCols = () => {
|
@@ -186,6 +195,133 @@ function App() {
|
|
186
195
|
|
187
196
|
|
188
197
|
<FormContainerWrapper cols={cols} className="" ref={formRef} >
|
198
|
+
|
199
|
+
<Field.WithSingleSelect
|
200
|
+
ref={testRef}
|
201
|
+
request={async (params) => {
|
202
|
+
console.log("request params", params)
|
203
|
+
return {
|
204
|
+
code: 0, data: {
|
205
|
+
list:
|
206
|
+
[
|
207
|
+
{ label: '选项1', value: '1', table_fill: [{ fill_tianchong1:{ label: '选项1', value: '1'}, fill_tianchong2:{ label: '选项2', value: '2'} }] },
|
208
|
+
{ label: '选项2', value: '2' },
|
209
|
+
{ label: '选项3', value: '3' }
|
210
|
+
]
|
211
|
+
}
|
212
|
+
}
|
213
|
+
}}
|
214
|
+
option_label="label"
|
215
|
+
option_value="value"
|
216
|
+
fillRules={[
|
217
|
+
{
|
218
|
+
"id": "636d3924-0298-4e9b-809a-26d4a10d7b19",
|
219
|
+
"type": 1,
|
220
|
+
"source": "table_fill",
|
221
|
+
"target": "table_fill",
|
222
|
+
"subRules": [
|
223
|
+
{
|
224
|
+
"id": "636d3924-0298-4e9b-809a-26d4a10d7b11",
|
225
|
+
"type": 0,
|
226
|
+
"source": "fill_tianchong1",
|
227
|
+
"target": "fill_tianchong1",
|
228
|
+
},
|
229
|
+
]
|
230
|
+
},
|
231
|
+
|
232
|
+
]} label="子表填充数据源" __id="fill_datasource1" />
|
233
|
+
<Layout.FormRow layout={'1'}>
|
234
|
+
<Field.Table label="测试主子表填充" __id="table_fill" isAllowAdd={true} isAllowCopy={false} >
|
235
|
+
|
236
|
+
<Field.WithSingleSelect
|
237
|
+
ref={testRef}
|
238
|
+
request={async (params) => {
|
239
|
+
console.log("request params", params)
|
240
|
+
return { code: 0, data: { list: [{ label: '选项1', value: '1', fill_tianchong2: { label: '选项2', value: '2' }, fill_tcinput1: "1111", }, { label: '选项2', value: '2' }, { label: '选项3', value: '3' }] } }
|
241
|
+
}}
|
242
|
+
option_label="label"
|
243
|
+
option_value="value"
|
244
|
+
fillRules={[
|
245
|
+
{
|
246
|
+
"id": "636d3924-0298-4e9b-809a-26d4a10d7b19",
|
247
|
+
"type": 0,
|
248
|
+
"source": "fill_tianchong2",
|
249
|
+
"target": "fill_tianchong2",
|
250
|
+
"subRules": [
|
251
|
+
]
|
252
|
+
},
|
253
|
+
{
|
254
|
+
"id": "636d3924-0298-4e9b-809a-26d4a10d7b11",
|
255
|
+
"type": 0,
|
256
|
+
"source": "fill_tcinput1",
|
257
|
+
"target": "fill_tcinput1",
|
258
|
+
"subRules": [
|
259
|
+
]
|
260
|
+
},
|
261
|
+
|
262
|
+
]} label="测试填充1" __id="fill_tianchong1" />
|
263
|
+
<Field.WithSingleSelect
|
264
|
+
ref={testRef}
|
265
|
+
request={async (params) => {
|
266
|
+
if (!params?.value) return { code: 0, data: { list: [{ label: '选项1', value: '1', }] } }
|
267
|
+
await new Promise(resolve => setTimeout(resolve, 200))
|
268
|
+
return { code: 0, data: { list: [{ label: '选项1', value: '1', }, { label: '选项2', value: '2', fill_tcinput1: "8989", fill_tcinput2: "2222" }, { label: '选项3', value: '3' }] } }
|
269
|
+
}}
|
270
|
+
option_label="label"
|
271
|
+
option_value="value"
|
272
|
+
option_search="label"
|
273
|
+
fillRules={[
|
274
|
+
{
|
275
|
+
"id": "636d3924-0298-4e9b-809a-16d4a10d7b29",
|
276
|
+
"type": 0,
|
277
|
+
"source": "fill_tcinput1",
|
278
|
+
"target": "fill_tcinput1",
|
279
|
+
"subRules": [
|
280
|
+
]
|
281
|
+
},
|
282
|
+
{
|
283
|
+
"id": "636d3924-0298-4e9b-809a-26d4a10d7b29",
|
284
|
+
"type": 0,
|
285
|
+
"source": "fill_tcinput2",
|
286
|
+
"target": "fill_tcinput2",
|
287
|
+
"subRules": [
|
288
|
+
]
|
289
|
+
},
|
290
|
+
|
291
|
+
]} label="测试填充2" __id="fill_tianchong2" />
|
292
|
+
<Field.Input label="测试被填充1" __id="fill_tcinput1" />
|
293
|
+
<Field.Input label="测试被填充2" __id="fill_tcinput2" />
|
294
|
+
<Field.Input label="测试被填充计算" __id="fill_tcinput3"
|
295
|
+
withIds={["table_fill.fill_tcinput2"]}
|
296
|
+
withFill={{
|
297
|
+
"value": [
|
298
|
+
{
|
299
|
+
"insert": {
|
300
|
+
"span": true
|
301
|
+
},
|
302
|
+
"attributes": {
|
303
|
+
"id": "table_fill.fill_tcinput2",
|
304
|
+
"color": "blue",
|
305
|
+
"tagKey": "fieldsValue",
|
306
|
+
"content": "当前表单.测试被填充2"
|
307
|
+
}
|
308
|
+
},
|
309
|
+
{
|
310
|
+
"insert": "* 0.5"
|
311
|
+
},
|
312
|
+
{
|
313
|
+
"insert": "\n\n"
|
314
|
+
}
|
315
|
+
],
|
316
|
+
"version": 1719296886283,
|
317
|
+
"withData": [
|
318
|
+
|
319
|
+
]
|
320
|
+
}}
|
321
|
+
/>
|
322
|
+
|
323
|
+
</Field.Table>
|
324
|
+
</Layout.FormRow>
|
189
325
|
<Field.MultipleSelect mode="multiple" option_label={"label"} option_value={"value"} label="测试过滤条件" __id="selecta1" request={async (params) => {
|
190
326
|
return { code: 0, data: { list: [{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }] } }
|
191
327
|
}}></Field.MultipleSelect>
|
@@ -234,7 +370,7 @@ function App() {
|
|
234
370
|
|
235
371
|
]} label="发票类型" options={[{ label: '选项1', value: '1', shuilv: 15, }, { label: '选项2', value: '2', shuilv: 50 }, { label: '选项3', value: '3', shuilv: 2 }]} __id="fapiaoleixing" />
|
236
372
|
|
237
|
-
<Field.Number label="税率(%)" __id="shuilv"
|
373
|
+
<Field.Number label="税率(%)" __id="shuilv" />
|
238
374
|
|
239
375
|
<Field.WithSingleSelect ref={testRef} fillRules={[
|
240
376
|
{
|
@@ -332,94 +468,7 @@ function App() {
|
|
332
468
|
<Layout.FormRow layout={'1'}>
|
333
469
|
<Field.Table label="子表格" __id="table" isAllowAdd={true} isAllowCopy={false} >
|
334
470
|
|
335
|
-
<Field.
|
336
|
-
ref={testRef}
|
337
|
-
request={async (params) => {
|
338
|
-
console.log("request params", params)
|
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' }] } }
|
340
|
-
}}
|
341
|
-
option_label="label"
|
342
|
-
option_value="value"
|
343
|
-
fillRules={[
|
344
|
-
{
|
345
|
-
"id": "636d3924-0298-4e9b-809a-26d4a10d7b19",
|
346
|
-
"type": 0,
|
347
|
-
"source": "tianchong2",
|
348
|
-
"target": "tianchong2",
|
349
|
-
"subRules": [
|
350
|
-
]
|
351
|
-
},
|
352
|
-
{
|
353
|
-
"id": "636d3924-0298-4e9b-809a-26d4a10d7b11",
|
354
|
-
"type": 0,
|
355
|
-
"source": "tcinput1",
|
356
|
-
"target": "tcinput1",
|
357
|
-
"subRules": [
|
358
|
-
]
|
359
|
-
},
|
360
|
-
|
361
|
-
]} label="测试填充1" __id="tianchong1" />
|
362
|
-
<Field.WithSingleSelect
|
363
|
-
ref={testRef}
|
364
|
-
request={async (params) => {
|
365
|
-
if (!params?.value) return { code: 0, data: { list: [{ label: '选项1', value: '1', }] } }
|
366
|
-
await new Promise(resolve => setTimeout(resolve, 200))
|
367
|
-
return { code: 0, data: { list: [{ label: '选项1', value: '1', }, { label: '选项2', value: '2', tcinput1: "8989", tcinput2: "2222" }, { label: '选项3', value: '3' }] } }
|
368
|
-
}}
|
369
|
-
option_label="label"
|
370
|
-
option_value="value"
|
371
|
-
option_search="label"
|
372
|
-
fillRules={[
|
373
|
-
{
|
374
|
-
"id": "636d3924-0298-4e9b-809a-16d4a10d7b29",
|
375
|
-
"type": 0,
|
376
|
-
"source": "tcinput1",
|
377
|
-
"target": "tcinput1",
|
378
|
-
"subRules": [
|
379
|
-
]
|
380
|
-
},
|
381
|
-
{
|
382
|
-
"id": "636d3924-0298-4e9b-809a-26d4a10d7b29",
|
383
|
-
"type": 0,
|
384
|
-
"source": "tcinput2",
|
385
|
-
"target": "tcinput2",
|
386
|
-
"subRules": [
|
387
|
-
]
|
388
|
-
},
|
389
|
-
|
390
|
-
]} label="测试填充2" __id="tianchong2" />
|
391
|
-
<Field.Input label="测试被填充1" __id="tcinput1" />
|
392
|
-
<Field.Input label="测试被填充2" __id="tcinput2" />
|
393
|
-
<Field.Input label="测试被填充计算" __id="tcinput3"
|
394
|
-
withIds={["table.tcinput2"]}
|
395
|
-
withFill={{
|
396
|
-
"value": [
|
397
|
-
{
|
398
|
-
"insert": {
|
399
|
-
"span": true
|
400
|
-
},
|
401
|
-
"attributes": {
|
402
|
-
"id": "table.tcinput2",
|
403
|
-
"color": "blue",
|
404
|
-
"tagKey": "fieldsValue",
|
405
|
-
"content": "当前表单.测试被填充2"
|
406
|
-
}
|
407
|
-
},
|
408
|
-
{
|
409
|
-
"insert": "* 0.5"
|
410
|
-
},
|
411
|
-
{
|
412
|
-
"insert": "\n\n"
|
413
|
-
}
|
414
|
-
],
|
415
|
-
"version": 1719296886283,
|
416
|
-
"withData": [
|
417
|
-
|
418
|
-
]
|
419
|
-
}}
|
420
|
-
/>
|
421
|
-
|
422
|
-
<Field.Number label="税率(%)" calcHidden={true} __id="shuilv_table" withIds={[
|
471
|
+
<Field.Number label="税率(%)" __id="shuilv_table" withIds={[
|
423
472
|
"shuilv"
|
424
473
|
]}
|
425
474
|
withFill={{
|
@@ -4,9 +4,11 @@ import { Input, Select as OriginalSelect, Spin } from 'antd';
|
|
4
4
|
import React, { useEffect, useState, forwardRef, useCallback, useRef } from 'react';
|
5
5
|
import { BaseWrapper } from "../base"
|
6
6
|
import { debounce, isEqual } from 'lodash';
|
7
|
+
import { createPromiseWrapper } from "../../../utils"
|
8
|
+
import { useCreation } from 'ahooks';
|
7
9
|
|
8
10
|
|
9
|
-
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) => {
|
10
12
|
const [nOptions, setNOptions] = React.useState([])
|
11
13
|
const [fetching, setFetching] = useState(false);
|
12
14
|
|
@@ -14,7 +16,9 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
14
16
|
const currentPageSize = 10
|
15
17
|
const isAllLoadedRef = useRef(false)
|
16
18
|
const isLoadingRef = useRef(false);
|
17
|
-
|
19
|
+
const promiseRef = useCreation(() => {
|
20
|
+
return createPromiseWrapper();
|
21
|
+
}, []);
|
18
22
|
useEffect(() => {
|
19
23
|
// console.log("SearchSelect useEffect props", props)
|
20
24
|
if (value) {
|
@@ -29,46 +33,46 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
29
33
|
}
|
30
34
|
|
31
35
|
// 没有找到与value相等的选项,说明该项数据可能尚未加载,此时需要重新加载数据
|
32
|
-
if (!item) loadSelectOptions()
|
36
|
+
if (!item) loadSelectOptions(value)
|
33
37
|
}
|
34
38
|
}, [value])
|
35
39
|
|
36
|
-
|
37
|
-
// initData(requestParams)
|
38
|
-
// }, [requestParams, fieldsValue])
|
40
|
+
|
39
41
|
|
40
42
|
useEffect(() => {
|
41
|
-
// console.log("SearchSelect useEffect shouldUpdateKey", shouldUpdateKey)
|
42
|
-
// console.log("SearchSelect useEffect requestParams", requestParams)
|
43
43
|
initData(requestParams)
|
44
44
|
}, [shouldUpdateKey, requestParams])
|
45
|
-
|
46
|
-
|
47
|
-
//
|
48
|
-
//
|
49
|
-
//
|
50
|
-
//
|
51
|
-
//
|
52
|
-
//
|
53
|
-
//
|
54
|
-
//
|
55
|
-
//
|
56
|
-
//
|
57
|
-
//
|
58
|
-
//
|
59
|
-
//
|
60
|
-
//
|
45
|
+
|
46
|
+
|
47
|
+
// const loadSelectOptions = useCallback(debounce( async (loadValue) => {
|
48
|
+
// if (request && option_value) {
|
49
|
+
// console.log("loadSelectOptions debounceFetchOptions params" + props?.__id,loadValue)
|
50
|
+
// await promiseRef.promise
|
51
|
+
// debounceFetchOptions({ ...requestParams, [option_value]: loadValue?.value }, null,(selectOptions) => {
|
52
|
+
// console.log("loadSelectOptions selectOptions", selectOptions)
|
53
|
+
// if (selectOptions && selectOptions.length > 0) {
|
54
|
+
// let item = selectOptions.find(item => item.value == loadValue?.value || item.value == loadValue)
|
55
|
+
// console.log("loadSelectOptions item", item)
|
56
|
+
// if (item && !isEqual(item, loadValue)) {
|
57
|
+
// console.log("new value /////", item)
|
58
|
+
// typeof onChange === 'function' && onChange(item)
|
59
|
+
// }
|
60
|
+
// }
|
61
|
+
// })
|
62
|
+
|
61
63
|
// }
|
62
|
-
// },[
|
64
|
+
// },100), [])
|
63
65
|
|
64
|
-
|
66
|
+
|
67
|
+
|
68
|
+
const loadSelectOptions = async (loadValue) => {
|
65
69
|
if (request && option_value) {
|
66
|
-
|
67
|
-
|
70
|
+
// 等initData调用后,再调用loadSelectOptions,防止传入参数和回调被覆盖
|
71
|
+
await promiseRef.promise
|
72
|
+
debounceFetchOptions({ ...requestParams, [option_value]: loadValue?.value }, null, (selectOptions) => {
|
68
73
|
if (selectOptions && selectOptions.length > 0) {
|
69
|
-
let item = selectOptions.find(item => item.value ==
|
70
|
-
|
71
|
-
if (item && !isEqual(item, value)) {
|
74
|
+
let item = selectOptions.find(item => item.value == loadValue?.value || item.value == loadValue)
|
75
|
+
if (item && !isEqual(item, loadValue)) {
|
72
76
|
console.log("new value /////", item)
|
73
77
|
typeof onChange === 'function' && onChange(item)
|
74
78
|
}
|
@@ -77,6 +81,7 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
77
81
|
|
78
82
|
}
|
79
83
|
}
|
84
|
+
|
80
85
|
const initData = async (params) => {
|
81
86
|
|
82
87
|
let item = null
|
@@ -85,36 +90,13 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
85
90
|
isAllLoadedRef.current = false
|
86
91
|
if (request && typeof request === 'function') {
|
87
92
|
debounceFetchOptions(params, ruleParams)
|
93
|
+
promiseRef?.resolve(true);
|
88
94
|
}
|
89
|
-
|
90
95
|
if (options && options.length > 0) {
|
91
96
|
setNOptions(options)
|
92
97
|
}
|
93
|
-
|
94
|
-
|
95
|
-
|
96
98
|
}
|
97
99
|
|
98
|
-
// useEffect(() => {
|
99
|
-
// console.log("useEffect SearchSelect value", value)
|
100
|
-
// if (value && nOptions.length > 0) {
|
101
|
-
// let item = value
|
102
|
-
// if (Array.isArray(value)) {
|
103
|
-
// item = nOptions.filter(item => {
|
104
|
-
// return value.filter(v => item.value == v?.value || item.value == v).length > 0
|
105
|
-
// })
|
106
|
-
// }
|
107
|
-
// else {
|
108
|
-
// item = nOptions.find(item => item.value == value?.value || item.value == value)
|
109
|
-
// }
|
110
|
-
|
111
|
-
// if (item && !isEqual(item, value)) {
|
112
|
-
// onChange(item)
|
113
|
-
// console.log("SearchSelect onChange value", item)
|
114
|
-
// }
|
115
|
-
|
116
|
-
// }
|
117
|
-
// }, [value, nOptions])
|
118
100
|
|
119
101
|
const handleSearch = async (value) => {
|
120
102
|
const params = { ...requestParams }
|
@@ -239,7 +221,7 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
239
221
|
|
240
222
|
</OriginalSelect>
|
241
223
|
{!props?.disabled && rightIcon}
|
242
|
-
{!props?.disabled && typeof rightIconRender === 'function' && rightIconRender({ value, onChange, form, fieldName, recordFieldsChange })}
|
224
|
+
{!props?.disabled && typeof rightIconRender === 'function' && rightIconRender({ value, onChange, form, fieldName, recordFieldsChange,getAllWithIds })}
|
243
225
|
</BaseWrapper>
|
244
226
|
) : (<>
|
245
227
|
<OriginalSelect
|
@@ -258,7 +240,7 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
258
240
|
|
259
241
|
</OriginalSelect>
|
260
242
|
{!props?.disabled && rightIcon}
|
261
|
-
{!props?.disabled && typeof rightIconRender === 'function' && rightIconRender({ value, onChange, form, fieldName, recordFieldsChange })}
|
243
|
+
{!props?.disabled && typeof rightIconRender === 'function' && rightIconRender({ value, onChange, form, fieldName, recordFieldsChange,getAllWithIds })}
|
262
244
|
</>
|
263
245
|
)
|
264
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
|
@@ -446,7 +448,6 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
446
448
|
const delay = lockStatus.current === 1 ? 500 : 100;
|
447
449
|
|
448
450
|
timeoutRef.current = setTimeout(() => {
|
449
|
-
console.log("debounceHandleFieldsChange begin")
|
450
451
|
const fieldValues = form.getFieldsValue();
|
451
452
|
const lockStatus_ = lockStatus.current;
|
452
453
|
lockStatus.current = 0
|
@@ -471,7 +472,6 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
471
472
|
}, []);
|
472
473
|
|
473
474
|
const handleFieldsChange = (changedFields) => {
|
474
|
-
console.log("changedFields", changedFields)
|
475
475
|
changedFields.filter(field => {
|
476
476
|
if (field.name && field.name.length > 0) {
|
477
477
|
// const fieldKey = field.name.filter(item => typeof item == "string").join(".")
|
@@ -481,7 +481,8 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
481
481
|
|
482
482
|
debounceHandleFieldsChange();
|
483
483
|
}
|
484
|
-
|
484
|
+
|
485
|
+
const getTableWithIds = (ids) => {
|
485
486
|
let withAllIds = []
|
486
487
|
ids.forEach(id => {
|
487
488
|
if (!dependencyMap.current.has(id)) return
|
@@ -494,6 +495,10 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
494
495
|
if (typeof withValue != "number" && !withValue) return false
|
495
496
|
return true
|
496
497
|
})
|
498
|
+
return withAllIds
|
499
|
+
}
|
500
|
+
const handleTableAddRow = (ids) => {
|
501
|
+
let withAllIds = getTableWithIds(ids)
|
497
502
|
const fieldValues = form.getFieldsValue();
|
498
503
|
setTimeout(() => {
|
499
504
|
withAllIds.forEach(withid => {
|
@@ -555,7 +560,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
555
560
|
|
556
561
|
let childComponent
|
557
562
|
if (isTable || isLayoutComponent) {
|
558
|
-
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 })
|
559
564
|
}
|
560
565
|
else if (componentName === "Field.WithSingleSelect" || componentName === "Field.WithMultipleSelect" || componentName === "Show.WithTable") {
|
561
566
|
childComponent = <Form.Item
|