lu-lowcode-package-form 0.10.5 → 0.10.7
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 +249 -249
- package/dist/index.es.js +13062 -13057
- package/package.json +1 -1
- package/src/App.jsx +68 -56
- package/src/components/field/select/search-select.jsx +28 -2
- package/src/components/form-container/index.jsx +1 -0
package/package.json
CHANGED
package/src/App.jsx
CHANGED
@@ -174,61 +174,7 @@ function App() {
|
|
174
174
|
|
175
175
|
|
176
176
|
<FormContainerWrapper cols={cols} className="" ref={formRef} >
|
177
|
-
|
178
|
-
isRequired={true} ref={testRef}
|
179
|
-
request={async (params) => {
|
180
|
-
return { code: 0, data: { list: [{ label: '选项1', value: '1', tianchong2: { label: '选项2', value: '2'} ,tcinput1: "1111" , }, { label: '选项2', value: '2' }, { label: '选项3', value: '3' }] } }
|
181
|
-
}}
|
182
|
-
option_label="label"
|
183
|
-
option_value="value"
|
184
|
-
fillRules={[
|
185
|
-
{
|
186
|
-
"id": "636d3924-0298-4e9b-809a-26d4a10d7b19",
|
187
|
-
"type": 0,
|
188
|
-
"source": "tianchong2",
|
189
|
-
"target": "tianchong2",
|
190
|
-
"subRules": [
|
191
|
-
]
|
192
|
-
},
|
193
|
-
{
|
194
|
-
"id": "636d3924-0298-4e9b-809a-26d4a10d7b11",
|
195
|
-
"type": 0,
|
196
|
-
"source": "tcinput1",
|
197
|
-
"target": "tcinput1",
|
198
|
-
"subRules": [
|
199
|
-
]
|
200
|
-
},
|
201
|
-
|
202
|
-
]} label="测试填充1" __id="tianchong1" />
|
203
|
-
<Field.WithSingleSelect
|
204
|
-
isRequired={true} ref={testRef}
|
205
|
-
request={async (params) => {
|
206
|
-
return { code: 0, data: { list: [{ label: '选项1', value: '1', }, { label: '选项2', value: '2' ,tcinput1: "8989",tcinput2: "2222" }, { label: '选项3', value: '3' }] } }
|
207
|
-
}}
|
208
|
-
option_label="label"
|
209
|
-
option_value="value"
|
210
|
-
fillRules={[
|
211
|
-
{
|
212
|
-
"id": "636d3924-0298-4e9b-809a-16d4a10d7b29",
|
213
|
-
"type": 0,
|
214
|
-
"source": "tcinput1",
|
215
|
-
"target": "tcinput1",
|
216
|
-
"subRules": [
|
217
|
-
]
|
218
|
-
},
|
219
|
-
{
|
220
|
-
"id": "636d3924-0298-4e9b-809a-26d4a10d7b29",
|
221
|
-
"type": 0,
|
222
|
-
"source": "tcinput2",
|
223
|
-
"target": "tcinput2",
|
224
|
-
"subRules": [
|
225
|
-
]
|
226
|
-
},
|
227
|
-
|
228
|
-
]} label="测试填充2" __id="tianchong2" />
|
229
|
-
<Field.Input label="测试被填充1" __id="tcinput1" />
|
230
|
-
<Field.Input label="测试被填充2" __id="tcinput2" />
|
231
|
-
|
177
|
+
|
232
178
|
<Field.UserSelect label="选择用户" __id="userselect" defaultValue={[{ id: 1, username: "十天" }]} />
|
233
179
|
<Layout.FormGroupTitle title={"基本信息"} />
|
234
180
|
<Field.WithSingleSelect
|
@@ -286,8 +232,69 @@ function App() {
|
|
286
232
|
<Layout.FormRow layout={'1'}>
|
287
233
|
<Field.Number label="测试规则" isRequired={true} __id="ceshi_rule1" />
|
288
234
|
</Layout.FormRow>
|
235
|
+
|
236
|
+
|
289
237
|
<Layout.FormRow layout={'1'}>
|
290
238
|
<Field.Table label="子表格" __id="table" >
|
239
|
+
|
240
|
+
<Field.WithSingleSelect
|
241
|
+
isRequired={true} ref={testRef}
|
242
|
+
request={async (params) => {
|
243
|
+
return { code: 0, data: { list: [{ label: '选项1', value: '1', tianchong2: { label: '选项2', value: '2'} ,tcinput1: "1111" , }, { label: '选项2', value: '2' }, { label: '选项3', value: '3' }] } }
|
244
|
+
}}
|
245
|
+
option_label="label"
|
246
|
+
option_value="value"
|
247
|
+
fillRules={[
|
248
|
+
{
|
249
|
+
"id": "636d3924-0298-4e9b-809a-26d4a10d7b19",
|
250
|
+
"type": 0,
|
251
|
+
"source": "tianchong2",
|
252
|
+
"target": "tianchong2",
|
253
|
+
"subRules": [
|
254
|
+
]
|
255
|
+
},
|
256
|
+
{
|
257
|
+
"id": "636d3924-0298-4e9b-809a-26d4a10d7b11",
|
258
|
+
"type": 0,
|
259
|
+
"source": "tcinput1",
|
260
|
+
"target": "tcinput1",
|
261
|
+
"subRules": [
|
262
|
+
]
|
263
|
+
},
|
264
|
+
|
265
|
+
]} label="测试填充1" __id="tianchong1" />
|
266
|
+
<Field.WithSingleSelect
|
267
|
+
isRequired={true} ref={testRef}
|
268
|
+
request={async (params) => {
|
269
|
+
console.log("WithSingleSelect params", params)
|
270
|
+
if (!params?.label) return { code: 0, data: { list: [{ label: '选项1', value: '1', }] } }
|
271
|
+
await new Promise(resolve => setTimeout(resolve, 200))
|
272
|
+
return { code: 0, data: { list: [{ label: '选项1', value: '1', }, { label: '选项2', value: '2' ,tcinput1: "8989",tcinput2: "2222" }, { label: '选项3', value: '3' }] } }
|
273
|
+
}}
|
274
|
+
option_label="label"
|
275
|
+
option_value="value"
|
276
|
+
option_search="label"
|
277
|
+
fillRules={[
|
278
|
+
{
|
279
|
+
"id": "636d3924-0298-4e9b-809a-16d4a10d7b29",
|
280
|
+
"type": 0,
|
281
|
+
"source": "tcinput1",
|
282
|
+
"target": "tcinput1",
|
283
|
+
"subRules": [
|
284
|
+
]
|
285
|
+
},
|
286
|
+
{
|
287
|
+
"id": "636d3924-0298-4e9b-809a-26d4a10d7b29",
|
288
|
+
"type": 0,
|
289
|
+
"source": "tcinput2",
|
290
|
+
"target": "tcinput2",
|
291
|
+
"subRules": [
|
292
|
+
]
|
293
|
+
},
|
294
|
+
|
295
|
+
]} label="测试填充2" __id="tianchong2" />
|
296
|
+
<Field.Input label="测试被填充1" __id="tcinput1" />
|
297
|
+
<Field.Input label="测试被填充2" __id="tcinput2" />
|
291
298
|
<Field.Number label="税率(%)" __id="shuilv_table" withIds={[
|
292
299
|
"shuilv"
|
293
300
|
]}
|
@@ -547,8 +554,13 @@ function App() {
|
|
547
554
|
|
548
555
|
]
|
549
556
|
}} />
|
550
|
-
|
557
|
+
|
558
|
+
<Field.SingleSelect mode="single" option_value={"id"} label="测试单选" __id="select1" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]}></Field.SingleSelect>
|
551
559
|
<Field.MultipleSelect mode="multiple" label="测多选" __id="select2" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]}></Field.MultipleSelect>
|
560
|
+
<Field.MultipleSelect mode="multiple" option_label={"label"} option_value={"value"} label="测多选2" __id="select2222" request={async (params) => {
|
561
|
+
console.log("MultipleSelect params", params)
|
562
|
+
return { code: 0, data: { list: [{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }] } }
|
563
|
+
}}></Field.MultipleSelect>
|
552
564
|
<Field.TreeSelect label="分组名" __id="title11"></Field.TreeSelect>
|
553
565
|
<Field.Switch label="开关" __id="switch"></Field.Switch>
|
554
566
|
<Layout.FormGroupTitle title={"嘟嘟嘟嘟嘟"} />
|
@@ -11,18 +11,31 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
11
11
|
const [fetching, setFetching] = useState(false);
|
12
12
|
useEffect(() => {
|
13
13
|
// console.log("SearchSelect useEffect props", props)
|
14
|
-
|
14
|
+
console.log(`SearchSelect ${fieldName} value`, value)
|
15
15
|
if (value && nOptions.length > 0) {
|
16
16
|
let item = nOptions.find(item => item.value == value?.value || item.value == value)
|
17
17
|
if (item && !isEqual(item, value)){
|
18
18
|
console.log("new value /////",item)
|
19
19
|
typeof onChange === 'function' && onChange(item)
|
20
20
|
}
|
21
|
+
|
22
|
+
// 没有找到与value相等的选项,说明该项数据可能尚未加载,此时需要重新加载数据
|
23
|
+
if (!item) loadSelectOptions()
|
21
24
|
}
|
22
25
|
},[value])
|
26
|
+
// useEffect(() => {
|
27
|
+
// initData(requestParams)
|
28
|
+
// }, [requestParams, fieldsValue])
|
29
|
+
|
30
|
+
// useEffect(() => {
|
31
|
+
// console.log("SearchSelect useEffect fieldsValue", fieldsValue)
|
32
|
+
// initData(requestParams)
|
33
|
+
// }, [fieldsValue])
|
34
|
+
|
23
35
|
useEffect(() => {
|
36
|
+
console.log("SearchSelect useEffect requestParams", requestParams)
|
24
37
|
initData(requestParams)
|
25
|
-
}, [requestParams
|
38
|
+
}, [requestParams])
|
26
39
|
// useEffect(() => {
|
27
40
|
// console.log("WithSingleSelect useEffect fieldsValue",fieldsValue)
|
28
41
|
// if(fieldsValue)
|
@@ -32,6 +45,19 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
|
|
32
45
|
// onChange(undefined)
|
33
46
|
// }
|
34
47
|
// },[fieldsValue])
|
48
|
+
|
49
|
+
const loadSelectOptions = async () => {
|
50
|
+
if (request && option_search){
|
51
|
+
const selectOptions = await fetchOptions({...requestParams, [option_search]: value?.label})
|
52
|
+
if (selectOptions && selectOptions.length > 0) {
|
53
|
+
let item = selectOptions.find(item => item.value == value?.value || item.value == value)
|
54
|
+
if (item && !isEqual(item, value)){
|
55
|
+
console.log("new value /////",item)
|
56
|
+
typeof onChange === 'function' && onChange(item)
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
35
61
|
const initData = async (params) => {
|
36
62
|
let item = null
|
37
63
|
const ruleParams = {}
|