lu-lowcode-package-form 0.9.48 → 0.9.56
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 +75 -75
- package/dist/index.es.js +1652 -1634
- package/package.json +1 -1
- package/src/App.jsx +44 -19
- package/src/components/field/base.jsx +9 -4
- package/src/components/field/select/select.jsx +50 -25
- package/src/components/form-container/index.jsx +16 -6
- package/src/utils/formula.js +1 -0
package/package.json
CHANGED
package/src/App.jsx
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
import { FormContainer, Field, FormContainerWrapper, Layout, Setter, EditorQuill, EditorWang , EditorWang2 , EditorWang3 ,WangEditor , WangEditorNext} from './components';
|
2
2
|
import './App.css';
|
3
3
|
import { Button, Input, Select } from 'antd';
|
4
|
-
import React, { useState } from 'react';
|
4
|
+
import React, { useEffect, useState } from 'react';
|
5
5
|
import Draggable from 'react-draggable';
|
6
|
+
import {MyPureComponentWithRef} from "./components/field/select/index"
|
6
7
|
|
7
8
|
const searchSelectOptions = [
|
8
9
|
{id:1,name:"1111"},
|
@@ -74,6 +75,10 @@ const treeData = [
|
|
74
75
|
|
75
76
|
function App() {
|
76
77
|
const formRef = React.createRef();
|
78
|
+
const testRef = React.useRef()
|
79
|
+
useEffect(() => {
|
80
|
+
console.log("testRef //////", testRef.current)
|
81
|
+
},[testRef.current])
|
77
82
|
const [cols, setCols] = React.useState(3);
|
78
83
|
|
79
84
|
const getFormFields = () => {
|
@@ -105,7 +110,8 @@ function App() {
|
|
105
110
|
return (
|
106
111
|
|
107
112
|
<div className="App fflex fflex-col fitems-center">
|
108
|
-
<DraggableBtn />
|
113
|
+
<DraggableBtn />
|
114
|
+
{/* <MyPureComponentWithRef ref={testRef} />; */}
|
109
115
|
{/* <div className='fw-full fp-4 fflex fjustify-center'>
|
110
116
|
<WangEditorNext />
|
111
117
|
</div> */}
|
@@ -133,9 +139,9 @@ function App() {
|
|
133
139
|
<FormContainerWrapper cols={cols} className="" ref={formRef} >
|
134
140
|
<Layout.FormGroupTitle title={"基本信息"} />
|
135
141
|
<Layout.FormRow layout={'1'}>
|
136
|
-
<Field.Table label="子表格" __id="table"
|
142
|
+
<Field.Table label="子表格" __id="table" >
|
137
143
|
<Field.Switch label="开关" __id="switch_table"></Field.Switch>
|
138
|
-
<Field.Input
|
144
|
+
<Field.Input isRequired={true} label="商品价格" __id="product_price11" />
|
139
145
|
<Field.Input isRequired={true} label="商品价格" __id="product_price12" />
|
140
146
|
<Field.Input isRequired={true} label="商品价格" __id="product_price13" />
|
141
147
|
<Field.Input isRequired={true} label="商品价格" __id="product_price14" />
|
@@ -213,8 +219,8 @@ function App() {
|
|
213
219
|
]
|
214
220
|
}}
|
215
221
|
/>
|
216
|
-
<Field.UserSelect
|
217
|
-
<Field.DeptSelect
|
222
|
+
<Field.UserSelect label="选择用户" __id="userselect" customComponent={Input} />
|
223
|
+
<Field.DeptSelect label="DeptSelect" __id="DeptSelect" treeData={[{
|
218
224
|
value: 'parent 1-1',
|
219
225
|
title: 'parent 1-1',
|
220
226
|
children: [
|
@@ -234,7 +240,7 @@ function App() {
|
|
234
240
|
},
|
235
241
|
],
|
236
242
|
},]}></Field.PostSelect>
|
237
|
-
<Field.SearchSelect
|
243
|
+
<Field.SearchSelect mode='multiple' label="搜组件" __id="searchuser" request={searchSelectRequest} option_search={"name"} option_label="name" option_value="id"></Field.SearchSelect>
|
238
244
|
<Field.Input rules={"^(1[3-9]\\d{9})$"} isRequired={true} label="商品价格" __id="product_price" />
|
239
245
|
<Field.Input label="商品数量" __id="product_num" />
|
240
246
|
<Field.NumberRange label="数量范围" __id="product_num_range" />
|
@@ -276,19 +282,19 @@ function App() {
|
|
276
282
|
|
277
283
|
]
|
278
284
|
}} />
|
279
|
-
<Field.SingleSelect
|
280
|
-
<Field.MultipleSelect
|
281
|
-
<Field.TreeSelect
|
282
|
-
<Field.Switch
|
285
|
+
<Field.SingleSelect mode="single" label="测试单选" __id="select1" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]}></Field.SingleSelect>
|
286
|
+
<Field.MultipleSelect mode="multiple" label="测多选" __id="select2" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]}></Field.MultipleSelect>
|
287
|
+
<Field.TreeSelect label="分组名" __id="title11"></Field.TreeSelect>
|
288
|
+
<Field.Switch label="开关" __id="switch"></Field.Switch>
|
283
289
|
<Layout.FormGroupTitle title={"嘟嘟嘟嘟嘟"} />
|
284
|
-
<Field.CodeMachine
|
290
|
+
<Field.CodeMachine label="角色编号" prompt="" __id="code"
|
285
291
|
withIds={["switch"]}
|
286
292
|
withFunc={(fieldsValue) => {
|
287
293
|
return fieldsValue?.switch ? true : false
|
288
294
|
}}
|
289
295
|
/>
|
290
296
|
<Field.DatePicker label="日期时间" prompt="" datetype="month" value='2022-10-22' __id="datetime" />
|
291
|
-
<Field.DatePicker
|
297
|
+
<Field.DatePicker label="日期时间" prompt="" datetype="date" value='2022-10-22' __id="datetime2" />
|
292
298
|
<Field.DatePicker label="日期时间" prompt="" datetype="datetime" value={'2022-10-22'} __id="datetime3" />
|
293
299
|
<Field.DatePicker label="年" prompt="" datetype="year" value={'2022-10-22'} __id="datetime4" />
|
294
300
|
<Field.Input label="角色名称" __id="name" />
|
@@ -296,20 +302,39 @@ function App() {
|
|
296
302
|
<Field.Input label="角色名称布局" __id="name1" />
|
297
303
|
<Field.Input label="角色名称布局2" __id="name2" />
|
298
304
|
</Layout.FormRow>
|
299
|
-
<Field.CheckboxTree
|
305
|
+
<Field.CheckboxTree label="角色权限" __id="permissions" addRoot={false} treeData={treeData} />
|
300
306
|
<Layout.FormGroupTitle title={"关联信息"} />
|
301
|
-
<Field.WithSingleSelect
|
302
|
-
<Field.WithMultipleSelect
|
307
|
+
<Field.WithSingleSelect label="测试关联单选" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]} __id="remark11" />
|
308
|
+
<Field.WithMultipleSelect label="测试关联多选" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]} __id="remark12" />
|
303
309
|
<Layout.FormRow > <Field.TextArea label="备注" __id="remark" /></Layout.FormRow>
|
304
310
|
|
305
311
|
<Layout.FormRow layout={'1'}>
|
306
|
-
<Field.RadioGroup
|
312
|
+
<Field.RadioGroup withIds={["remark11"]}
|
313
|
+
withFill={{
|
314
|
+
"value": [
|
315
|
+
{
|
316
|
+
"insert": {
|
317
|
+
"span": true
|
318
|
+
},
|
319
|
+
"attributes": {
|
320
|
+
"id": "remark11",
|
321
|
+
"color": "blue",
|
322
|
+
"tagKey": "fieldsValue",
|
323
|
+
"content": "测试关联单选"
|
324
|
+
}
|
325
|
+
},
|
326
|
+
],
|
327
|
+
"version": 1719296886283,
|
328
|
+
"withData": [
|
329
|
+
|
330
|
+
]
|
331
|
+
}} options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]} label="单选框" __id="radio" ></Field.RadioGroup>
|
307
332
|
</Layout.FormRow>
|
308
333
|
<Layout.FormRow layout={'1'}>
|
309
|
-
<Field.CheckboxGroup
|
334
|
+
<Field.CheckboxGroup options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]} label="多选框" __id="CheckboxGroup" ></Field.CheckboxGroup>
|
310
335
|
</Layout.FormRow>
|
311
336
|
<Field.UploadFile label="上传文件" __id="UploadFile" ></Field.UploadFile>
|
312
|
-
<Field.UploadImage
|
337
|
+
<Field.UploadImage label="上传图片" __id="UploadImage" ></Field.UploadImage>
|
313
338
|
|
314
339
|
</FormContainerWrapper>
|
315
340
|
<div class="fgroup">11111
|
@@ -8,8 +8,12 @@ const FieldLable = ({ value, onChange }) => {
|
|
8
8
|
}, [value]);
|
9
9
|
return <>{text}</>
|
10
10
|
}
|
11
|
-
|
12
|
-
|
11
|
+
export function withWrap(Component) {
|
12
|
+
return forwardRef((props, ref) => {
|
13
|
+
return <Component {...props} ref={ref} forwardedRef={ref}/>
|
14
|
+
});
|
15
|
+
}
|
16
|
+
export const BaseWrapper = ({
|
13
17
|
label,
|
14
18
|
higLabel = false,
|
15
19
|
children,
|
@@ -24,11 +28,12 @@ export const BaseWrapper = forwardRef(({
|
|
24
28
|
readonly,
|
25
29
|
isRequired,
|
26
30
|
...otherProps
|
27
|
-
}
|
31
|
+
}) => {
|
28
32
|
React.useImperativeHandle(ref, () => ({
|
29
33
|
handleChange: ( value )=>{
|
30
34
|
console.log("change", otherProps?.onChange)
|
31
35
|
console.log("value", value)
|
36
|
+
otherProps?.onChange(value)
|
32
37
|
},
|
33
38
|
}), []);
|
34
39
|
|
@@ -67,4 +72,4 @@ export const BaseWrapper = forwardRef(({
|
|
67
72
|
)
|
68
73
|
|
69
74
|
return subTable ? tableWarpper : formWarpper;
|
70
|
-
}
|
75
|
+
};
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { Select as OriginalSelect, Tree, Input, Button } from "antd";
|
2
2
|
|
3
|
-
import { BaseWrapper } from "../base"
|
4
|
-
import {SearchSelect} from "./search-select"
|
5
|
-
import React, { useEffect, useState } from 'react';
|
3
|
+
import { BaseWrapper, withWrap } from "../base"
|
4
|
+
import { SearchSelect } from "./search-select"
|
5
|
+
import React, { useEffect, useState, forwardRef } from 'react';
|
6
6
|
import TreeSelect from './tree-select'
|
7
7
|
import { EditOutlined } from '@ant-design/icons';
|
8
8
|
|
9
|
-
const Select = ({ request,
|
9
|
+
const Select = ({ request, option_label = "label", option_value = "id", disabledValue, callError, options, addWrapper = true, ...props }) => {
|
10
10
|
// const [firstLoad, setFirstLoad] = React.useState(false)
|
11
11
|
const [nOptions, setNOptions] = React.useState([])
|
12
12
|
useEffect(() => {
|
@@ -71,8 +71,8 @@ const MultipleSelect = ({ onChange, value, ...props }) => {
|
|
71
71
|
* @param {*}
|
72
72
|
* @returns
|
73
73
|
*/
|
74
|
-
const WithSingleSelect = ({ readItemRender, readonly,onChange, value, ...props }) => {
|
75
|
-
|
74
|
+
const WithSingleSelect = ({ readItemRender, readonly, onChange, value, ...props }) => {
|
75
|
+
|
76
76
|
React.useEffect(() => {
|
77
77
|
if (value && typeof value === "string") {
|
78
78
|
try {
|
@@ -85,11 +85,11 @@ const WithSingleSelect = ({ readItemRender, readonly,onChange, value, ...props }
|
|
85
85
|
|
86
86
|
}, [value])
|
87
87
|
if (readonly) return <div className=" fh-8 fflex fitems-center fgap-2">
|
88
|
-
|
88
|
+
{value && value.label && <>{readItemRender && typeof readItemRender === "function" ? readItemRender(value) : <span key={`btn_${value?.value}`}>{value?.label}</span>}</>}
|
89
89
|
</div>
|
90
90
|
return (
|
91
|
-
|
92
|
-
|
91
|
+
<SearchSelect addWrapper={false} {...props} onChange={onChange} value={value} mode="single" className=" fflex-1 foverflow-hidden" />
|
92
|
+
|
93
93
|
)
|
94
94
|
}
|
95
95
|
|
@@ -98,8 +98,8 @@ const WithSingleSelect = ({ readItemRender, readonly,onChange, value, ...props }
|
|
98
98
|
* @param {*}
|
99
99
|
* @returns
|
100
100
|
*/
|
101
|
-
const WithMultipleSelect = ({
|
102
|
-
|
101
|
+
const WithMultipleSelect = ({ readItemRender, readonly, onChange, value, ...props }) => {
|
102
|
+
|
103
103
|
React.useEffect(() => {
|
104
104
|
if (value && typeof value === "string") {
|
105
105
|
try {
|
@@ -112,13 +112,13 @@ const WithMultipleSelect = ({ readItemRender, readonly, onChange, value, ...pro
|
|
112
112
|
|
113
113
|
}, [value])
|
114
114
|
if (readonly) return <div className=" fh-8 fflex fitems-center fgap-2">
|
115
|
-
{Array.isArray(value) && value.map((item,index) => <> {
|
115
|
+
{Array.isArray(value) && value.map((item, index) => <> {
|
116
116
|
readItemRender && typeof readItemRender === "function" ? readItemRender(item) : <span key={`btn_${item?.value}`}>{item?.label}</span>
|
117
117
|
|
118
|
-
}{index<value.length-1? <span className=" ftext-gray-400">,</span> : null}</>)}
|
118
|
+
}{index < value.length - 1 ? <span className=" ftext-gray-400">,</span> : null}</>)}
|
119
119
|
</div>
|
120
120
|
return (
|
121
|
-
<SearchSelect addWrapper={false} {...props} onChange={onChange} value={value} mode="multiple"
|
121
|
+
<SearchSelect addWrapper={false} {...props} onChange={onChange} value={value} mode="multiple" className=" fflex-1 foverflow-hidden" />
|
122
122
|
)
|
123
123
|
}
|
124
124
|
|
@@ -127,7 +127,7 @@ const UserSelect = ({ customComponent: CustomComponent, ...props }) => {
|
|
127
127
|
if (!CustomComponent) return <BaseWrapper {...props}><Input {...props} /></BaseWrapper>
|
128
128
|
else return <BaseWrapper {...props}><CustomComponent {...props} /></BaseWrapper>
|
129
129
|
}
|
130
|
-
const ArrayTreeSelect = (
|
130
|
+
const ArrayTreeSelect = ({ onChange, value, multiple, ...props }) => {
|
131
131
|
const [nValue, setNValue] = React.useState()
|
132
132
|
useEffect(() => {
|
133
133
|
if (value && typeof value === "string") {
|
@@ -146,28 +146,53 @@ const ArrayTreeSelect = ( {onChange, value, multiple, ...props} )=>{
|
|
146
146
|
setNValue(value)
|
147
147
|
}
|
148
148
|
}, [value])
|
149
|
-
const handleChange = (_value)=>{
|
149
|
+
const handleChange = (_value) => {
|
150
150
|
if (!Array.isArray(_value)) _value = [_value]
|
151
151
|
onChange && typeof onChange == "function" && onChange(_value)
|
152
152
|
}
|
153
153
|
return <TreeSelect {...props} onChange={handleChange} value={nValue} multiple={multiple} />
|
154
154
|
}
|
155
155
|
// 选择部门组件
|
156
|
-
const DeptSelect = ({ FetchDeptList
|
156
|
+
const DeptSelect = ({ FetchDeptList, ...props }) => {
|
157
157
|
return <ArrayTreeSelect {...props} title={"deptName"} request={FetchDeptList} />
|
158
158
|
}
|
159
159
|
// 选择岗位组件
|
160
160
|
const PostSelect = ({ FetchPostList, ...props }) => {
|
161
|
-
return <ArrayTreeSelect {...props} title={"postName"}
|
161
|
+
return <ArrayTreeSelect {...props} title={"postName"} request={FetchPostList} />
|
162
162
|
}
|
163
163
|
|
164
164
|
WithSingleSelect.displayName = "WithSingleSelect"
|
165
165
|
WithMultipleSelect.displayName = "WithMultipleSelect"
|
166
166
|
|
167
|
-
const WithSingleSelectWrapper = (props) => {
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
167
|
+
// const WithSingleSelectWrapper = withWrap(({ ref, ...props }) => <BaseWrapper ref={ref} {...props}><WithSingleSelect {...props} /></BaseWrapper>);
|
168
|
+
// const WithMultipleSelectWrapper = withWrap(({ ref, ...props }) => <BaseWrapper ref={ref} {...props}><WithMultipleSelect {...props} /></BaseWrapper>);
|
169
|
+
|
170
|
+
|
171
|
+
// export class WithSingleSelectClass extends React.PureComponent{
|
172
|
+
// render() {
|
173
|
+
// const { forwardedRef, ...otherProps } = this.props;
|
174
|
+
// return <BaseWrapper {...otherProps} ref={forwardedRef}><WithSingleSelect {...otherProps} /></BaseWrapper>
|
175
|
+
// }
|
176
|
+
// }
|
177
|
+
|
178
|
+
const WithSingleSelectForward = forwardRef((props, ref) => {
|
179
|
+
React.useImperativeHandle(ref, () => ({
|
180
|
+
handleChange: ( value )=>{
|
181
|
+
props?.onChange(value)
|
182
|
+
},
|
183
|
+
}), []);
|
184
|
+
|
185
|
+
return <BaseWrapper {...props} ><WithSingleSelect {...props} /></BaseWrapper>
|
186
|
+
})
|
187
|
+
const WithMultipleSelectForward = forwardRef((props, ref) => {
|
188
|
+
React.useImperativeHandle(ref, () => ({
|
189
|
+
handleChange: ( value )=>{
|
190
|
+
props?.onChange(value)
|
191
|
+
},
|
192
|
+
}), []);
|
193
|
+
|
194
|
+
return <BaseWrapper {...props} ><WithMultipleSelect {...props} /></BaseWrapper>
|
195
|
+
})
|
196
|
+
|
197
|
+
export { WithSingleSelectForward as WithSingleSelect, WithMultipleSelectForward as WithMultipleSelect, MultipleSelect, SingleSelect, Select, UserSelect, DeptSelect, PostSelect };
|
198
|
+
|
@@ -73,7 +73,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
73
73
|
if (props?.withIds)
|
74
74
|
withIds = [...withIds, ...props?.withIds]
|
75
75
|
|
76
|
-
fields.push({ identifier, withIds, component: currentNode });
|
76
|
+
fields.push({ identifier, withIds, component: currentNode,componentName });
|
77
77
|
}
|
78
78
|
|
79
79
|
if (props?.children) {
|
@@ -96,6 +96,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
96
96
|
// })),
|
97
97
|
children: fields.filter(item => item.withIds.some(item => item == identifier)),
|
98
98
|
show: true,
|
99
|
+
componentName: field.componentName
|
99
100
|
});
|
100
101
|
});
|
101
102
|
// console.log("dependencyMap", dependencyMap.current)
|
@@ -121,7 +122,8 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
121
122
|
}
|
122
123
|
if (dependencyMap.current.has(identifier)) {
|
123
124
|
// console.log("dependencyMap.current.get(identifier)",dependencyMap.current.get(identifier))
|
124
|
-
const
|
125
|
+
const dependent = dependencyMap.current.get(identifier)
|
126
|
+
const dependentChildren = dependent.children;
|
125
127
|
// console.log("dependentChildren", dependentChildren)
|
126
128
|
|
127
129
|
dependentChildren.forEach(child => {
|
@@ -130,7 +132,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
130
132
|
}
|
131
133
|
|
132
134
|
if (child.component.props.withFill)
|
133
|
-
handleFieldsWithFill(fieldValues, child, parentIdentifier)
|
135
|
+
handleFieldsWithFill(fieldValues, child, parentIdentifier,dependent?.componentName)
|
134
136
|
|
135
137
|
});
|
136
138
|
}
|
@@ -154,7 +156,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
154
156
|
}
|
155
157
|
// 处理级联数据源
|
156
158
|
// 处理级联填充
|
157
|
-
const handleFieldsWithFill = async (fieldValues, child, parentIdentifier) => {
|
159
|
+
const handleFieldsWithFill = async (fieldValues, child, parentIdentifier,componentName) => {
|
158
160
|
const withFill = child?.component?.props.withFill;
|
159
161
|
const withDataFetch = child?.component?.props.withDataFetch;
|
160
162
|
let withFillIndex = 0
|
@@ -165,9 +167,10 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
165
167
|
withFillIndex = parentIdentifier[parentIdentifier.length - 1]
|
166
168
|
if (childIdentifier.startsWith(`${withFillGroup}.`)) {
|
167
169
|
childIdentifier = [...parentIdentifier, childIdentifier.replace(`${withFillGroup}.`, "")]
|
168
|
-
}
|
170
|
+
}
|
169
171
|
}
|
170
172
|
let withDatas = [];
|
173
|
+
console.log("componentName",componentName)
|
171
174
|
// 先处理依赖数据
|
172
175
|
if (withFill?.withData && withFill?.withData.length > 0 && withDataFetch && typeof withDataFetch === 'function') {
|
173
176
|
for (let index = 0; index < withFill?.withData.length; index++) {
|
@@ -177,7 +180,14 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
177
180
|
params.filter = {}
|
178
181
|
for (let index = 0; index < element.withCondition.length; index++) {
|
179
182
|
const { value: condition_value, column: condition_column } = element.withCondition[index];
|
180
|
-
|
183
|
+
let filter_value = getParamValue(condition_value.group_key, condition_value.field_key, fieldValues, withDatas)
|
184
|
+
if (Array.isArray(filter_value)) {
|
185
|
+
if (Array.isArray(childIdentifier) && filter_value.length > withFillIndex) {
|
186
|
+
filter_value = filter_value[withFillIndex]
|
187
|
+
}
|
188
|
+
}
|
189
|
+
if (componentName == "Field.WithSingleSelect" && filter_value && filter_value?.value) filter_value = filter_value.value
|
190
|
+
params.filter[condition_column.column_name] = filter_value
|
181
191
|
}
|
182
192
|
|
183
193
|
// 访问接口获取数据
|