lu-lowcode-package-form 0.9.30 → 0.9.31
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 +2 -2
- package/dist/index.es.js +3638 -3615
- package/package.json +1 -1
- package/src/App.jsx +42 -22
- package/src/components/field/select/select.jsx +44 -19
package/package.json
CHANGED
package/src/App.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FormContainer, Field, FormContainerWrapper, Layout, Setter, EditorQuill, EditorWang } from './components';
|
|
2
2
|
import './App.css';
|
|
3
|
-
import { Button
|
|
3
|
+
import { Button, Input, Select } from 'antd';
|
|
4
4
|
import React, { useState } from 'react';
|
|
5
5
|
import Draggable from 'react-draggable';
|
|
6
6
|
|
|
@@ -61,19 +61,19 @@ function App() {
|
|
|
61
61
|
}
|
|
62
62
|
// 验证
|
|
63
63
|
const validateFields = async () => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
console.log("error",error)
|
|
64
|
+
try {
|
|
65
|
+
var values = await formRef?.current?.formRef?.validateFields({
|
|
66
|
+
validateOnly: false,
|
|
67
|
+
})
|
|
68
|
+
console.log("values", values)
|
|
69
|
+
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.log("error", error)
|
|
72
72
|
console.log(error.errorFields[0].errors[0])
|
|
73
|
-
|
|
73
|
+
}
|
|
74
74
|
}
|
|
75
75
|
const setFormFields = () => {
|
|
76
|
-
formRef?.current?.formRef?.setFieldsValue({ "userselect":"1213131","table": [{ "product_price1": "12", "product_num1": "123", "product_sum1": "1476", "node_oclxmzswzti": "", "select2": "" }, { "product_price1": "123", "product_num1": "213", "product_sum1": "26199", "node_oclxmzswzti": "", "select2": "" }], "product_total_price": "0.00", "product_price": "213", "product_num": "21", "product_num_range": [1, 22], "product_sum": "4473", "switch": false })
|
|
76
|
+
formRef?.current?.formRef?.setFieldsValue({ "userselect": "1213131","DeptSelect":["leaf11"],"PostSelect":'["parent 1-1","leaf11"]', "table": [{ "product_price1": "12", "product_num1": "123", "product_sum1": "1476", "node_oclxmzswzti": "", "select2": "" }, { "product_price1": "123", "product_num1": "213", "product_sum1": "26199", "node_oclxmzswzti": "", "select2": "" }], "product_total_price": "0.00", "product_price": "213", "product_num": "21", "product_num_range": [1, 22], "product_sum": "4473", "switch": false })
|
|
77
77
|
}
|
|
78
78
|
const handleCols = () => {
|
|
79
79
|
setCols(cols - 1)
|
|
@@ -89,22 +89,22 @@ function App() {
|
|
|
89
89
|
<EditorQuill value={"[{\"insert\":\"sdfsd\"}]"} />
|
|
90
90
|
</div>
|
|
91
91
|
<div className='fw-full fp-4'>
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
<Select
|
|
93
|
+
mode="tags"
|
|
94
|
+
style={{ width: '100%' }}
|
|
95
|
+
placeholder="Tags Mode"
|
|
96
|
+
options={[{ label: '标签1', value: '1' }, { label: '标签2', value: '2' }]}
|
|
97
|
+
/>
|
|
98
98
|
<Setter.OptionSetter />
|
|
99
99
|
</div>
|
|
100
100
|
<div className='fw-[960px] frounded fbg-slate-50 fflex fflex-col fitems-center fpb-10'>
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
|
|
103
103
|
<FormContainerWrapper cols={cols} className="" ref={formRef} >
|
|
104
104
|
<Layout.FormGroupTitle title={"基本信息"} />
|
|
105
105
|
<Layout.FormRow layout={'1'}>
|
|
106
106
|
<Field.Table label="子表格" __id="table" >
|
|
107
|
-
<Field.Input isRequired={true}
|
|
107
|
+
<Field.Input isRequired={true} label="商品价格" __id="product_price1" />
|
|
108
108
|
<Field.Input label="商品总价" __id="product_sum1"
|
|
109
109
|
withIds={["table.product_price1", "table.product_num1"]}
|
|
110
110
|
withFill={{
|
|
@@ -178,11 +178,31 @@ function App() {
|
|
|
178
178
|
}}
|
|
179
179
|
/>
|
|
180
180
|
<Field.UserSelect label="选择用户" __id="userselect" customComponent={Input} />
|
|
181
|
+
<Field.DeptSelect label="DeptSelect" __id="DeptSelect" treeData={[{
|
|
182
|
+
value: 'parent 1-1',
|
|
183
|
+
title: 'parent 1-1',
|
|
184
|
+
children: [
|
|
185
|
+
{
|
|
186
|
+
value: 'leaf11',
|
|
187
|
+
title: <b style={{ color: '#08c' }}>leaf11</b>,
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
},]}></Field.DeptSelect>
|
|
191
|
+
<Field.PostSelect multiple={true} label="PostSelect" __id="PostSelect" treeData={[{
|
|
192
|
+
value: 'parent 1-1',
|
|
193
|
+
title: 'parent 1-1',
|
|
194
|
+
children: [
|
|
195
|
+
{
|
|
196
|
+
value: 'leaf11',
|
|
197
|
+
title: <b style={{ color: '#08c' }}>leaf11</b>,
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
},]}></Field.PostSelect>
|
|
181
201
|
<Field.SearchSelect isRequired={true} label="搜组件" __id="searchuser" option_search="username" option_label="username" setValue={() => { }} option_value="id"></Field.SearchSelect>
|
|
182
|
-
<Field.Input
|
|
183
|
-
<Field.Input
|
|
202
|
+
<Field.Input rules={"^(1[3-9]\\d{9})$"} isRequired={true} label="商品价格" __id="product_price" />
|
|
203
|
+
<Field.Input label="商品数量" __id="product_num" />
|
|
184
204
|
<Field.NumberRange label="数量范围" __id="product_num_range" />
|
|
185
|
-
<Field.Input
|
|
205
|
+
<Field.Input rules={["^(1[3-9]\\d{9})$", "^\\d+$"]} label="商品总价" __id="product_sum"
|
|
186
206
|
withIds={["product_price", "product_num"]}
|
|
187
207
|
withFill={{
|
|
188
208
|
"value": [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Select as OriginalSelect, Tree
|
|
1
|
+
import { Select as OriginalSelect, Tree, Input } from "antd";
|
|
2
2
|
|
|
3
3
|
import { BaseWrapper } from "../base"
|
|
4
4
|
import React, { useEffect, useState } from 'react';
|
|
@@ -30,35 +30,35 @@ const Select = ({ request, option_label = "label", option_value = "id", disabled
|
|
|
30
30
|
|
|
31
31
|
// setFirstLoad(true)
|
|
32
32
|
}
|
|
33
|
-
return addWrapper ?(
|
|
33
|
+
return addWrapper ? (
|
|
34
34
|
<BaseWrapper {...props}>
|
|
35
35
|
<OriginalSelect {...props} options={nOptions} style={{ width: '100%' }} />
|
|
36
36
|
</BaseWrapper>
|
|
37
37
|
) : <OriginalSelect {...props} options={nOptions} style={{ width: '100%' }} />
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
const SingleSelect =
|
|
40
|
+
const SingleSelect = ({ ...props }) => {
|
|
41
41
|
return (
|
|
42
42
|
<Select {...props} mode="single" />
|
|
43
43
|
)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const MultipleSelect =
|
|
46
|
+
const MultipleSelect = ({ onChange, value, ...props }) => {
|
|
47
47
|
const [nValue, setNValue] = React.useState([])
|
|
48
48
|
|
|
49
|
-
useEffect(()=>{
|
|
49
|
+
useEffect(() => {
|
|
50
50
|
if (value && typeof value === "string") {
|
|
51
51
|
try {
|
|
52
52
|
value = JSON.parse(value)
|
|
53
53
|
onChange(value)
|
|
54
54
|
} catch (error) {
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
if(value) setNValue(value)
|
|
60
|
-
},[value])
|
|
61
|
-
|
|
58
|
+
|
|
59
|
+
if (value) setNValue(value)
|
|
60
|
+
}, [value])
|
|
61
|
+
|
|
62
62
|
return (
|
|
63
63
|
<Select {...props} onChange={onChange} mode="multiple" value={nValue} />
|
|
64
64
|
)
|
|
@@ -80,7 +80,7 @@ const WithSingleSelect = ({ onChange, value, ...props }) => {
|
|
|
80
80
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
if(value) setNValue(value)
|
|
83
|
+
if (value) setNValue(value)
|
|
84
84
|
}, [value])
|
|
85
85
|
|
|
86
86
|
|
|
@@ -111,7 +111,7 @@ const WithMultipleSelect = ({ onChange, value, ...props }) => {
|
|
|
111
111
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
|
|
114
|
+
|
|
115
115
|
if (Array.isArray(value)) setNValue(value)
|
|
116
116
|
}, [value])
|
|
117
117
|
|
|
@@ -126,17 +126,42 @@ const WithMultipleSelect = ({ onChange, value, ...props }) => {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
// 选择用户组件
|
|
129
|
-
const UserSelect = ({customComponent:CustomComponent
|
|
130
|
-
if (!CustomComponent) return
|
|
129
|
+
const UserSelect = ({ customComponent: CustomComponent, ...props }) => {
|
|
130
|
+
if (!CustomComponent) return <BaseWrapper {...props}><Input {...props} /></BaseWrapper>
|
|
131
131
|
else return <BaseWrapper {...props}><CustomComponent {...props} /></BaseWrapper>
|
|
132
132
|
}
|
|
133
|
+
const ArrayTreeSelect = ( {onChange, value, multiple, ...props} )=>{
|
|
134
|
+
const [nValue, setNValue] = React.useState()
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (value && typeof value === "string") {
|
|
137
|
+
try {
|
|
138
|
+
value = JSON.parse(value)
|
|
139
|
+
onChange(value)
|
|
140
|
+
return
|
|
141
|
+
}
|
|
142
|
+
catch (error) { }
|
|
143
|
+
}
|
|
144
|
+
if (multiple) {
|
|
145
|
+
if (Array.isArray(value)) setNValue(value)
|
|
146
|
+
} else {
|
|
147
|
+
if (Array.isArray(value))
|
|
148
|
+
value = value[0]
|
|
149
|
+
setNValue(value)
|
|
150
|
+
}
|
|
151
|
+
}, [value])
|
|
152
|
+
const handleChange = (_value)=>{
|
|
153
|
+
if (!Array.isArray(_value)) _value = [_value]
|
|
154
|
+
onChange && typeof onChange == "function" && onChange(_value)
|
|
155
|
+
}
|
|
156
|
+
return <TreeSelect {...props} onChange={handleChange} value={nValue} multiple={multiple} />
|
|
157
|
+
}
|
|
133
158
|
// 选择部门组件
|
|
134
|
-
const DeptSelect = ({FetchDeptList,...props})=>{
|
|
135
|
-
return <
|
|
159
|
+
const DeptSelect = ({ FetchDeptList,...props }) => {
|
|
160
|
+
return <ArrayTreeSelect {...props} title={"deptName"} request={FetchDeptList} />
|
|
136
161
|
}
|
|
137
162
|
// 选择岗位组件
|
|
138
|
-
const PostSelect = ({FetchPostList
|
|
139
|
-
return <
|
|
163
|
+
const PostSelect = ({ FetchPostList, ...props }) => {
|
|
164
|
+
return <ArrayTreeSelect {...props} title={"postName"} request={FetchPostList} />
|
|
140
165
|
}
|
|
141
166
|
|
|
142
|
-
export { WithSingleSelect, WithMultipleSelect, MultipleSelect, SingleSelect, Select,UserSelect,DeptSelect,PostSelect };
|
|
167
|
+
export { WithSingleSelect, WithMultipleSelect, MultipleSelect, SingleSelect, Select, UserSelect, DeptSelect, PostSelect };
|