lu-lowcode-package-form 0.10.1 → 0.10.2
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 +550 -550
- package/dist/index.es.js +83931 -83930
- package/package.json +2 -1
- package/src/App copy.jsx +619 -0
- package/src/utils/formula.js +8 -4
package/package.json
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "lu-lowcode-package-form",
|
3
|
-
"version": "0.10.
|
3
|
+
"version": "0.10.2",
|
4
4
|
"dependencies": {
|
5
5
|
"@ant-design/icons": "^4.8.1",
|
6
6
|
"@dnd-kit/core": "^6.1.0",
|
7
|
+
"@dnd-kit/sortable": "^8.0.0",
|
7
8
|
"@testing-library/jest-dom": "^5.17.0",
|
8
9
|
"@testing-library/react": "^13.4.0",
|
9
10
|
"@testing-library/user-event": "^13.5.0",
|
package/src/App copy.jsx
ADDED
@@ -0,0 +1,619 @@
|
|
1
|
+
import { FormContainer, Field, FormContainerWrapper, Layout, Setter, EditorQuill, EditorWang, EditorWang2, EditorWang3, WangEditor, WangEditorNext } from './components';
|
2
|
+
import './App.css';
|
3
|
+
import { Button, Input, Select } from 'antd';
|
4
|
+
import React, { useEffect, useState } from 'react';
|
5
|
+
import Draggable from 'react-draggable';
|
6
|
+
import { throttle } from 'lodash';
|
7
|
+
import { SortList } from "./components"
|
8
|
+
import { TinyMCEEditor } from './components'
|
9
|
+
import { PrinterOutlined } from '@ant-design/icons';
|
10
|
+
const searchSelectOptions = [
|
11
|
+
{ id: 1, name: "1111" },
|
12
|
+
{ id: 2, name: "2222" },
|
13
|
+
{ id: 3, name: "3333" },
|
14
|
+
{ id: 4, name: "4444" },
|
15
|
+
{ id: 5, name: "5555" },
|
16
|
+
{ id: 6, name: "6666" },
|
17
|
+
{ id: 7, name: "7777" },
|
18
|
+
{ id: 8, name: "8888" },
|
19
|
+
{ id: 9, name: "9999" },
|
20
|
+
]
|
21
|
+
const searchSelectRequest = async (params) => {
|
22
|
+
// console.log("params", params)
|
23
|
+
return await new Promise((resolve) => {
|
24
|
+
setTimeout(() => {
|
25
|
+
if (params && params?.name) {
|
26
|
+
resolve({ code: 0, data: searchSelectOptions.filter(item => item.name.includes(params.name)) })
|
27
|
+
}
|
28
|
+
resolve({ code: 0, data: searchSelectOptions })
|
29
|
+
}, 20);
|
30
|
+
})
|
31
|
+
}
|
32
|
+
const DraggableBtn = () => {
|
33
|
+
const [dragging, setDragging] = useState(false);
|
34
|
+
|
35
|
+
const handleStart = (e) => {
|
36
|
+
e.preventDefault();
|
37
|
+
setDragging(false);
|
38
|
+
};
|
39
|
+
|
40
|
+
const handleDrag = () => {
|
41
|
+
setDragging(true);
|
42
|
+
};
|
43
|
+
|
44
|
+
const handleStop = (e) => {
|
45
|
+
e.preventDefault();
|
46
|
+
if (!dragging) {
|
47
|
+
alert('Button clicked!');
|
48
|
+
}
|
49
|
+
};
|
50
|
+
|
51
|
+
return (
|
52
|
+
<Draggable
|
53
|
+
onStart={handleStart}
|
54
|
+
onDrag={handleDrag}
|
55
|
+
onStop={handleStop}
|
56
|
+
>
|
57
|
+
<button className="floating-button">Drag me!</button>
|
58
|
+
</Draggable>
|
59
|
+
);
|
60
|
+
}
|
61
|
+
|
62
|
+
const treeData = [
|
63
|
+
{
|
64
|
+
title: '0-1',
|
65
|
+
key: '0-1',
|
66
|
+
children: [
|
67
|
+
{ title: '0-1-0-0', key: '0-1-0-0' },
|
68
|
+
{ title: '0-1-0-1', key: '0-1-0-1' },
|
69
|
+
{ title: '0-1-0-2', key: '0-1-0-2' },
|
70
|
+
],
|
71
|
+
},
|
72
|
+
{
|
73
|
+
title: '0-2',
|
74
|
+
key: '0-2',
|
75
|
+
},
|
76
|
+
];
|
77
|
+
|
78
|
+
function App() {
|
79
|
+
const formRef = React.createRef();
|
80
|
+
const testRef = React.useRef()
|
81
|
+
useEffect(() => {
|
82
|
+
// console.log("testRef //////", testRef.current)
|
83
|
+
}, [testRef.current])
|
84
|
+
const [cols, setCols] = React.useState(3);
|
85
|
+
|
86
|
+
const getFormFields = () => {
|
87
|
+
console.log("formRef?.current", formRef)
|
88
|
+
const formData = formRef?.current?.formRef?.getFieldsValue();
|
89
|
+
console.log("formData", JSON.stringify(formData));
|
90
|
+
}
|
91
|
+
// 验证
|
92
|
+
const validateFields = async () => {
|
93
|
+
try {
|
94
|
+
var values = await formRef?.current?.formRef?.validateFields({
|
95
|
+
validateOnly: false,
|
96
|
+
})
|
97
|
+
console.log("values", values)
|
98
|
+
|
99
|
+
} catch (error) {
|
100
|
+
console.log("error", error)
|
101
|
+
console.log(error.errorFields[0].errors[0])
|
102
|
+
}
|
103
|
+
}
|
104
|
+
const setFormFields = () => {
|
105
|
+
formRef?.current?.setFieldsValue({ "userselect": "1213131","tianchong1":{"label":"选项1","value":"1"}, "remark11": { "label": "选项1", "value": "1", "name": "1111", "table": "[{\"price\":1,\"num\":2, \"remark11\":\"{ label: '选项3', value: '3' }\"},{\"price\":2,\"num\":2},{\"price\":3,\"num\":3},{\"price\":3,\"num\":3}]" }, "table": [{ "product_num1": "123", "product_sum1": "", "node_oclxmzswzti": "", "select2": "", "switch_table": false, "remark11": { "label": "选项2", "value": "2" }, "product_price12": "" }, { "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_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": [{ "label": "选项1", "value": "1" }, { "label": "选项2", "value": "2" }] })
|
106
|
+
// formRef?.current?.setFieldsValue({"tianchong1":{"label":"选项1","value":"1"}, })
|
107
|
+
}
|
108
|
+
const handleCols = () => {
|
109
|
+
setCols(cols - 1)
|
110
|
+
}
|
111
|
+
|
112
|
+
const [items, setItems] = useState(['Item 1', 'Item 2', 'Item 3', 'Item 4']);
|
113
|
+
|
114
|
+
|
115
|
+
const [sortItems, setSortItems] = useState([{ id: 1, content: "sdfsfd" }, { id: 2, content: "sdfsfd2" }, { id: 3, content: "sdfsfd3" }]);
|
116
|
+
return (
|
117
|
+
<div className='fflex fflex-col fitems-center fh-screen '>
|
118
|
+
<div className='fflex fgap-2 fitems-center fjustify-center fw-full'>
|
119
|
+
<Button type="primary" onClick={validateFields}>validateFields</Button>
|
120
|
+
<Button type="primary" onClick={getFormFields}>GetValues</Button>
|
121
|
+
<Button type="primary" onClick={setFormFields}>SetValues</Button>
|
122
|
+
<Button type="primary" onClick={() => {
|
123
|
+
console.log("testRef.current", testRef.current)
|
124
|
+
testRef.current?.handleChange({ label: '选项1', value: '1', name: "1111", table: "[{\"price\":1,\"num\":2},{\"price\":2,\"num\":2}]" })
|
125
|
+
}}>testwithref</Button>
|
126
|
+
<Button type="primary" onClick={handleCols}>UpdateCol</Button></div>
|
127
|
+
|
128
|
+
<div className=" fflex fflex-col fitems-center fflex-1 foverflow-y-auto">
|
129
|
+
<DraggableBtn />
|
130
|
+
{/* <MyPureComponentWithRef ref={testRef} />; */}
|
131
|
+
{/* <div className=' fp-4 fflex fjustify-center fw-[1336px]'>
|
132
|
+
<div className='fflex fflex-col'>
|
133
|
+
<SortList
|
134
|
+
items={sortItems}
|
135
|
+
setItems={setSortItems}
|
136
|
+
renderItem={(item, index, isDragging) => (
|
137
|
+
<div
|
138
|
+
style={{
|
139
|
+
padding: '8px',
|
140
|
+
margin: '4px',
|
141
|
+
border: '1px solid gray',
|
142
|
+
cursor: 'move',
|
143
|
+
opacity: isDragging ? 0.2 : 1,
|
144
|
+
|
145
|
+
}}
|
146
|
+
>
|
147
|
+
{item.content}
|
148
|
+
</div>
|
149
|
+
)}
|
150
|
+
/></div>
|
151
|
+
</div> */}
|
152
|
+
{/* <div className=' fp-4 fflex fjustify-center fw-[1336px]'>
|
153
|
+
<WangEditorNext />
|
154
|
+
</div> */}
|
155
|
+
{/* <div className='fw-full fp-4 fflex fjustify-center'>
|
156
|
+
<TinyMCEEditor />
|
157
|
+
</div> */}
|
158
|
+
{/* <div className='fw-full fp-4 fflex fjustify-center'>
|
159
|
+
<EditorWang />
|
160
|
+
</div> */}
|
161
|
+
{/* <div className='fw-full fp-4'>
|
162
|
+
<EditorQuill value={"[{\"insert\":\"sdfsd\"}]"} />
|
163
|
+
</div>
|
164
|
+
<div className='fw-full fp-4'>
|
165
|
+
<Select
|
166
|
+
mode="tags"
|
167
|
+
style={{ width: '100%' }}
|
168
|
+
placeholder="Tags Mode"
|
169
|
+
options={[{ label: '标签1', value: '1' }, { label: '标签2', value: '2' }]}
|
170
|
+
/>
|
171
|
+
<Setter.OptionSetter />
|
172
|
+
</div> */}
|
173
|
+
<div className='fw-[960px] frounded fbg-slate-50 fflex fflex-col fitems-center fpb-10'>
|
174
|
+
|
175
|
+
|
176
|
+
<FormContainerWrapper cols={cols} className="" ref={formRef} >
|
177
|
+
<Field.WithSingleSelect
|
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
|
+
|
232
|
+
<Field.UserSelect label="选择用户" __id="userselect" defaultValue={[{ id: 1, username: "十天" }]} />
|
233
|
+
<Layout.FormGroupTitle title={"基本信息"} />
|
234
|
+
<Field.WithSingleSelect
|
235
|
+
rightIconRender={({ form, fieldName }) => {
|
236
|
+
// console.log("rightIconRender form", form,)
|
237
|
+
// console.log("rightIconRender fieldName", fieldName)
|
238
|
+
return <><PrinterOutlined /></>
|
239
|
+
}}
|
240
|
+
isRequired={true} ref={testRef} fillRules={[
|
241
|
+
{
|
242
|
+
"id": "636d3924-0298-4e9b-809a-26d4a10d7b89",
|
243
|
+
"type": 0,
|
244
|
+
"source": "shuilv",
|
245
|
+
"target": "shuilv",
|
246
|
+
"subRules": [
|
247
|
+
]
|
248
|
+
},
|
249
|
+
|
250
|
+
]} label="发票类型" options={[{ label: '选项1', value: '1', shuilv: 15, }, { label: '选项2', value: '2', shuilv: 50 }, { label: '选项3', value: '3', shuilv: 2 }]} __id="fapiaoleixing" />
|
251
|
+
|
252
|
+
<Field.Number label="税率(%)" __id="shuilv" />
|
253
|
+
|
254
|
+
<Field.WithSingleSelect isRequired={true} ref={testRef} fillRules={[
|
255
|
+
{
|
256
|
+
"id": "636d3924-0298-4e9b-809a-26d4a10d7b89",
|
257
|
+
"type": 0,
|
258
|
+
"source": "name",
|
259
|
+
"target": "name",
|
260
|
+
"subRules": [
|
261
|
+
|
262
|
+
]
|
263
|
+
},
|
264
|
+
{
|
265
|
+
"id": "93401e38-60a4-4acf-84a6-8958785a4a30",
|
266
|
+
"type": 1,
|
267
|
+
"source": "table",
|
268
|
+
"target": "table",
|
269
|
+
"subRules": [
|
270
|
+
{
|
271
|
+
"id": "c4a65ae5-58ff-4d7f-8738-a04de1acab61",
|
272
|
+
"type": 0,
|
273
|
+
"source": "price",
|
274
|
+
"target": "product_price1"
|
275
|
+
},
|
276
|
+
|
277
|
+
{
|
278
|
+
"id": "c4a65ae5-58ff-4d7f-8738-a04de1acab61",
|
279
|
+
"type": 0,
|
280
|
+
"source": "num",
|
281
|
+
"target": "product_num1"
|
282
|
+
},
|
283
|
+
]
|
284
|
+
}
|
285
|
+
]} label="测试关联单选" options={[{ label: '选项1', value: '1', name: "1111", table: "[{\"price\":1,\"num\":2},{\"price\":2,\"num\":2},{\"price\":3,\"num\":3},{\"price\":3,\"num\":3}]" }, { label: '选项2', value: '2' }]} __id="remark11" />
|
286
|
+
<Layout.FormRow layout={'1'}>
|
287
|
+
<Field.Number label="测试规则" isRequired={true} __id="ceshi_rule1" />
|
288
|
+
</Layout.FormRow>
|
289
|
+
<Layout.FormRow layout={'1'}>
|
290
|
+
<Field.Table label="子表格" __id="table" >
|
291
|
+
<Field.Number label="税率(%)" __id="shuilv_table" withIds={[
|
292
|
+
"shuilv"
|
293
|
+
]}
|
294
|
+
withFill={{
|
295
|
+
"value": [
|
296
|
+
{
|
297
|
+
"insert": {
|
298
|
+
"span": true
|
299
|
+
},
|
300
|
+
"attributes": {
|
301
|
+
"id": "shuilv",
|
302
|
+
"color": "blue",
|
303
|
+
"tagKey": "fieldsValue",
|
304
|
+
"content": "当前表单.税率(%)"
|
305
|
+
}
|
306
|
+
},
|
307
|
+
|
308
|
+
],
|
309
|
+
"version": 1723016911807,
|
310
|
+
"withData": [
|
311
|
+
|
312
|
+
]
|
313
|
+
}} />
|
314
|
+
<Field.DatePicker defaultNow={true} label="日期时间" prompt="" datetype="date" __id="datetime2" />
|
315
|
+
|
316
|
+
<Field.WithSingleSelect ref={testRef}
|
317
|
+
request={async (params) => {
|
318
|
+
console.log("WithSingleSelect params", params)
|
319
|
+
if (params?.ruleParams?.node_ocm009lpxt2 == 111)
|
320
|
+
return { code: 0, data: { list: [{ label: '选项1', value: '1', product_price11: "1111", product_price12: "2222", product_price1: 111 }, { label: '选项2', value: '2' }, { label: '选项3', value: '3' }] } }
|
321
|
+
else return { code: 0, data: { list: [{ label: '选项1', value: '1', product_price11: "1111", product_price12: "2222", product_price1: 111 }, { label: '选项2', value: '2' },] } }
|
322
|
+
}}
|
323
|
+
option_label="label"
|
324
|
+
option_value="value"
|
325
|
+
filterRules={[
|
326
|
+
{
|
327
|
+
"value": {
|
328
|
+
"parent": "",
|
329
|
+
"field_key": "shuilv",
|
330
|
+
"group_key": "fieldsValue",
|
331
|
+
"field_name": "当前表单.税率"
|
332
|
+
},
|
333
|
+
"column": {
|
334
|
+
"label": "库存表.所在仓库",
|
335
|
+
"value": "node_ocm009lpxt2",
|
336
|
+
"column_name": "node_ocm009lpxt2",
|
337
|
+
"column_type": ""
|
338
|
+
}
|
339
|
+
}
|
340
|
+
]}
|
341
|
+
|
342
|
+
fillRules={[
|
343
|
+
{
|
344
|
+
"id": "636d3924-0298-4e9b-809a-26d4a10d7b89",
|
345
|
+
"type": 0,
|
346
|
+
"source": "product_price11",
|
347
|
+
"target": "product_price11",
|
348
|
+
"subRules": [
|
349
|
+
|
350
|
+
]
|
351
|
+
},
|
352
|
+
{
|
353
|
+
"id": "636d3924-0298-4e9b-809a-26d4a10d7b89",
|
354
|
+
"type": 0,
|
355
|
+
"source": "product_price1",
|
356
|
+
"target": "product_price1",
|
357
|
+
"subRules": [
|
358
|
+
|
359
|
+
]
|
360
|
+
},
|
361
|
+
|
362
|
+
]} label="测试关联单选" __id="remark11" />
|
363
|
+
|
364
|
+
<Field.Switch label="开关" __id="switch_table"></Field.Switch>
|
365
|
+
<Field.Input defaultValue={3} isRequired={true} label="含税单价" __id="product_price11" />
|
366
|
+
<Field.Input isRequired={true} label="未税单价" __id="product_price12"
|
367
|
+
withIds={[
|
368
|
+
"table.product_price11",
|
369
|
+
"shuilv"
|
370
|
+
]}
|
371
|
+
withFill={{
|
372
|
+
"value": [
|
373
|
+
{
|
374
|
+
"insert": "("
|
375
|
+
},
|
376
|
+
{
|
377
|
+
"insert": {
|
378
|
+
"span": true
|
379
|
+
},
|
380
|
+
"attributes": {
|
381
|
+
"id": "table.product_price11",
|
382
|
+
"color": "blue",
|
383
|
+
"tagKey": "fieldsValue",
|
384
|
+
"content": "当前表单.产品列表.含税单价"
|
385
|
+
}
|
386
|
+
},
|
387
|
+
{
|
388
|
+
"insert": "/(1+"
|
389
|
+
},
|
390
|
+
{
|
391
|
+
"insert": {
|
392
|
+
"span": true
|
393
|
+
},
|
394
|
+
"attributes": {
|
395
|
+
"id": "shuilv",
|
396
|
+
"color": "blue",
|
397
|
+
"tagKey": "fieldsValue",
|
398
|
+
"content": "当前表单.税率(%)"
|
399
|
+
}
|
400
|
+
},
|
401
|
+
{
|
402
|
+
"insert": "/ 100)).toFixed(2)\n\n\n"
|
403
|
+
}
|
404
|
+
],
|
405
|
+
"version": 1723016911807,
|
406
|
+
"withData": [
|
407
|
+
|
408
|
+
]
|
409
|
+
}}
|
410
|
+
/>
|
411
|
+
<Field.Input isRequired={true} defaultValue={1} label="商品价格" __id="product_price13" />
|
412
|
+
<Field.Input isRequired={true} defaultValue={2} label="商品价格" __id="product_price14" />
|
413
|
+
<Field.Input isRequired={true} label="商品价格" __id="product_price1" />
|
414
|
+
<Field.Input isRequired={true} label="商品个数" __id="product_num1" />
|
415
|
+
<Field.Input disabled={true} label="商品总价" __id="product_sum1"
|
416
|
+
withIds={["table.product_price1", "table.product_num1"]}
|
417
|
+
withFill={{
|
418
|
+
"value": [
|
419
|
+
{
|
420
|
+
"insert": {
|
421
|
+
"span": true
|
422
|
+
},
|
423
|
+
"attributes": {
|
424
|
+
"id": "table.product_price1",
|
425
|
+
"color": "blue",
|
426
|
+
"tagKey": "fieldsValue",
|
427
|
+
"content": "当前表单.商品价格"
|
428
|
+
}
|
429
|
+
},
|
430
|
+
{
|
431
|
+
"insert": "*"
|
432
|
+
},
|
433
|
+
{
|
434
|
+
"insert": {
|
435
|
+
"span": true
|
436
|
+
},
|
437
|
+
"attributes": {
|
438
|
+
"id": "table.product_num1",
|
439
|
+
"color": "blue",
|
440
|
+
"tagKey": "fieldsValue",
|
441
|
+
"content": "当前表单.商品个数"
|
442
|
+
}
|
443
|
+
},
|
444
|
+
{
|
445
|
+
"insert": "\n\n"
|
446
|
+
}
|
447
|
+
],
|
448
|
+
"version": 1719296886283,
|
449
|
+
"withData": [
|
450
|
+
|
451
|
+
]
|
452
|
+
}} />
|
453
|
+
<Field.Input label="分组名" __id="node_oclxmzswzti" />
|
454
|
+
<Field.MultipleSelect mode="multiple" label="测多选" __id="select2" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]}></Field.MultipleSelect>
|
455
|
+
|
456
|
+
</Field.Table>
|
457
|
+
</Layout.FormRow>
|
458
|
+
<Field.Input label="总价" disabled={true} __id="product_total_price" withIds={[
|
459
|
+
"table.product_sum1"
|
460
|
+
]}
|
461
|
+
withFill={{
|
462
|
+
"value": [
|
463
|
+
{
|
464
|
+
"insert": {
|
465
|
+
"span": true
|
466
|
+
},
|
467
|
+
"attributes": {
|
468
|
+
"id": "table.product_sum1",
|
469
|
+
"color": "blue",
|
470
|
+
"tagKey": "fieldsValue",
|
471
|
+
"content": "当前表单.标签.小计"
|
472
|
+
}
|
473
|
+
},
|
474
|
+
{
|
475
|
+
"insert": ".reduce((acc, curr) => parseFloat(acc||0) + parseFloat(curr||0), 0).toFixed(2)"
|
476
|
+
},
|
477
|
+
{
|
478
|
+
"insert": "\n"
|
479
|
+
}
|
480
|
+
],
|
481
|
+
"version": 1719383786677,
|
482
|
+
"withData": [
|
483
|
+
|
484
|
+
]
|
485
|
+
}}
|
486
|
+
/>
|
487
|
+
<Field.UserSelect label="选择用户" __id="userselect" customComponent={Input} />
|
488
|
+
<Field.DeptSelect label="DeptSelect" __id="DeptSelect" treeData={[{
|
489
|
+
value: 'parent 1-1',
|
490
|
+
title: 'parent 1-1',
|
491
|
+
children: [
|
492
|
+
{
|
493
|
+
value: 'leaf11',
|
494
|
+
title: <b style={{ color: '#08c' }}>leaf11</b>,
|
495
|
+
},
|
496
|
+
],
|
497
|
+
},]}></Field.DeptSelect>
|
498
|
+
<Field.PostSelect multiple={true} label="PostSelect" __id="PostSelect" treeData={[{
|
499
|
+
value: 'parent 1-1',
|
500
|
+
title: 'parent 1-1',
|
501
|
+
children: [
|
502
|
+
{
|
503
|
+
value: 'leaf11',
|
504
|
+
title: <b style={{ color: '#08c' }}>leaf11</b>,
|
505
|
+
},
|
506
|
+
],
|
507
|
+
},]}></Field.PostSelect>
|
508
|
+
<Field.SearchSelect mode='multiple' label="搜组件" __id="searchuser" request={searchSelectRequest} option_search={"name"} option_label="name" option_value="id"></Field.SearchSelect>
|
509
|
+
<Field.Input isRequired={true} label="商品价格" __id="product_price" defaultValue={"12"} disabled={true} />
|
510
|
+
<Field.Input label="商品数量" __id="product_num" rules={"^(1[3-9]\\d{9})$"} />
|
511
|
+
<Field.NumberRange label="数量范围" __id="product_num_range" />
|
512
|
+
<Field.Input rules={["^(1[3-9]\\d{9})$", "^\\d+$"]} label="商品总价" __id="product_sum"
|
513
|
+
withIds={["product_price", "product_num"]}
|
514
|
+
withFill={{
|
515
|
+
"value": [
|
516
|
+
{
|
517
|
+
"insert": {
|
518
|
+
"span": true
|
519
|
+
},
|
520
|
+
"attributes": {
|
521
|
+
"id": "product_price",
|
522
|
+
"color": "blue",
|
523
|
+
"tagKey": "fieldsValue",
|
524
|
+
"content": "当前表单.商品价格"
|
525
|
+
}
|
526
|
+
},
|
527
|
+
{
|
528
|
+
"insert": "* "
|
529
|
+
},
|
530
|
+
{
|
531
|
+
"insert": {
|
532
|
+
"span": true
|
533
|
+
},
|
534
|
+
"attributes": {
|
535
|
+
"id": "product_num",
|
536
|
+
"color": "blue",
|
537
|
+
"tagKey": "fieldsValue",
|
538
|
+
"content": "当前表单.商品个数"
|
539
|
+
}
|
540
|
+
},
|
541
|
+
{
|
542
|
+
"insert": "\n\n"
|
543
|
+
}
|
544
|
+
],
|
545
|
+
"version": 1719296886283,
|
546
|
+
"withData": [
|
547
|
+
|
548
|
+
]
|
549
|
+
}} />
|
550
|
+
<Field.SingleSelect mode="single" label="测试单选" __id="select1" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]}></Field.SingleSelect>
|
551
|
+
<Field.MultipleSelect mode="multiple" label="测多选" __id="select2" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]}></Field.MultipleSelect>
|
552
|
+
<Field.TreeSelect label="分组名" __id="title11"></Field.TreeSelect>
|
553
|
+
<Field.Switch label="开关" __id="switch"></Field.Switch>
|
554
|
+
<Layout.FormGroupTitle title={"嘟嘟嘟嘟嘟"} />
|
555
|
+
<Field.CodeMachine label="角色编号" prompt="" __id="code"
|
556
|
+
withIds={["switch"]}
|
557
|
+
withFunc={(fieldsValue) => {
|
558
|
+
return fieldsValue?.switch ? true : false
|
559
|
+
}}
|
560
|
+
/>
|
561
|
+
<Field.DatePicker defaultNow={true} label="datetime" prompt="" datetype="month" value='2022-10-22' __id="datetime" />
|
562
|
+
<Field.DatePicker label="datetime2" prompt="" datetype="date" __id="datetime2" />
|
563
|
+
<Field.DatePicker isRequired={true} disabled={true} defaultNow={true} label="datetime3" prompt="" datetype="datetime" value={'2022-10-22'} __id="datetime3" />
|
564
|
+
<Field.DatePicker defaultNow={true} label="datetime4" prompt="" datetype="year" value={'2022-10-22'} __id="datetime4" />
|
565
|
+
<Field.Input label="角色名称" __id="name" />
|
566
|
+
<Layout.FormRow layout={'1,1'}>
|
567
|
+
<Field.Input label="角色名称布局" __id="name1" />
|
568
|
+
<Field.Input label="角色名称布局2" __id="name2" />
|
569
|
+
</Layout.FormRow>
|
570
|
+
<Field.CheckboxTree label="角色权限" __id="permissions" addRoot={false} treeData={treeData} />
|
571
|
+
<Layout.FormGroupTitle title={"关联信息"} />
|
572
|
+
<Field.WithMultipleSelect disabled={true} label="测试关联多选" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]} __id="remark12" />
|
573
|
+
<Layout.FormRow > <Field.TextArea label="备注" __id="remark" /></Layout.FormRow>
|
574
|
+
|
575
|
+
<Layout.FormRow layout={'1'}>
|
576
|
+
<Field.RadioGroup withIds={["remark11"]}
|
577
|
+
withFill={{
|
578
|
+
"value": [
|
579
|
+
{
|
580
|
+
"insert": {
|
581
|
+
"span": true
|
582
|
+
},
|
583
|
+
"attributes": {
|
584
|
+
"id": "remark11",
|
585
|
+
"color": "blue",
|
586
|
+
"tagKey": "fieldsValue",
|
587
|
+
"content": "测试关联单选"
|
588
|
+
}
|
589
|
+
},
|
590
|
+
],
|
591
|
+
"version": 1719296886283,
|
592
|
+
"withData": [
|
593
|
+
|
594
|
+
]
|
595
|
+
}} options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]} label="单选框" __id="radio" ></Field.RadioGroup>
|
596
|
+
</Layout.FormRow>
|
597
|
+
<Layout.FormRow layout={'1'}>
|
598
|
+
<Field.CheckboxGroup options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]} label="多选框" __id="CheckboxGroup" ></Field.CheckboxGroup>
|
599
|
+
</Layout.FormRow>
|
600
|
+
<Field.UploadFile label="上传文件" __id="UploadFile" ></Field.UploadFile>
|
601
|
+
<Field.UploadImage label="上传图片" __id="UploadImage" ></Field.UploadImage>
|
602
|
+
|
603
|
+
</FormContainerWrapper>
|
604
|
+
<div class="fgroup">11111
|
605
|
+
<div class="fbg-red-500 group-hover:fbg-blue-500">
|
606
|
+
Hover over me or my parent!
|
607
|
+
</div>
|
608
|
+
</div>
|
609
|
+
|
610
|
+
</div>
|
611
|
+
|
612
|
+
</div>
|
613
|
+
</div>
|
614
|
+
);
|
615
|
+
}
|
616
|
+
|
617
|
+
export default App;
|
618
|
+
|
619
|
+
export { FormContainer, Field, FormContainerWrapper } from './components'
|
package/src/utils/formula.js
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
// 不安全的eval函数,有时间的话需要重新编写公式编译器
|
2
2
|
const evalFormula =(formula) => {
|
3
3
|
let result = "";
|
4
|
+
let funcCode = "";
|
4
5
|
try {
|
5
|
-
|
6
|
+
funcCode =`return ${formula.join("")}`
|
7
|
+
// console.log("funcCode",funcCode)
|
8
|
+
const func = new Function(funcCode);
|
9
|
+
result = func()
|
10
|
+
// result = eval(formula.join(""));
|
6
11
|
result = result.toString();
|
7
12
|
} catch (error) {
|
8
|
-
|
13
|
+
console.error(`formula (${funcCode}) error`, error);
|
9
14
|
}
|
10
15
|
// console.log("formula result", result);
|
11
16
|
return result
|
12
17
|
};
|
13
18
|
|
14
|
-
export {evalFormula};
|
15
|
-
|
19
|
+
export {evalFormula};
|