lu-lowcode-package-form 0.9.69 → 0.9.71
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 +3 -3
- package/dist/index.es.js +300 -296
- package/package.json +1 -1
- package/src/App.jsx +56 -11
- package/src/components/editor/quill.jsx +1 -1
- package/src/components/field/date-picker/index.jsx +12 -7
- package/src/components/field/select/search-select.jsx +0 -2
- package/src/components/field/select/select.jsx +1 -1
- package/src/components/field/upload/upload-image.jsx +1 -1
- package/src/components/form-container/index.jsx +23 -7
- package/src/utils/formula.js +2 -2
package/package.json
CHANGED
package/src/App.jsx
CHANGED
@@ -16,7 +16,7 @@ const searchSelectOptions = [
|
|
16
16
|
{ id: 9, name: "9999" },
|
17
17
|
]
|
18
18
|
const searchSelectRequest = async (params) => {
|
19
|
-
console.log("params", params)
|
19
|
+
// console.log("params", params)
|
20
20
|
return await new Promise((resolve) => {
|
21
21
|
setTimeout(() => {
|
22
22
|
if (params && params?.name) {
|
@@ -76,7 +76,7 @@ function App() {
|
|
76
76
|
const formRef = React.createRef();
|
77
77
|
const testRef = React.useRef()
|
78
78
|
useEffect(() => {
|
79
|
-
console.log("testRef //////", testRef.current)
|
79
|
+
// console.log("testRef //////", testRef.current)
|
80
80
|
}, [testRef.current])
|
81
81
|
const [cols, setCols] = React.useState(3);
|
82
82
|
|
@@ -138,9 +138,10 @@ function App() {
|
|
138
138
|
<FormContainerWrapper cols={cols} className="" ref={formRef} >
|
139
139
|
<Field.UserSelect label="选择用户" __id="userselect" defaultValue={[{ id: 1, username: "十天" }]} />
|
140
140
|
<Layout.FormGroupTitle title={"基本信息"} />
|
141
|
+
<Field.Number label="税率(%)" __id="shuilv" />
|
141
142
|
<Layout.FormRow layout={'1'}>
|
142
143
|
<Field.Table label="子表格" __id="table" >
|
143
|
-
<Field.DatePicker defaultNow={true}
|
144
|
+
<Field.DatePicker defaultNow={true} label="日期时间" prompt="" datetype="date" __id="datetime2" />
|
144
145
|
<Field.WithSingleSelect ref={testRef} fillRules={[
|
145
146
|
{
|
146
147
|
"id": "636d3924-0298-4e9b-809a-26d4a10d7b89",
|
@@ -173,8 +174,52 @@ function App() {
|
|
173
174
|
]} label="测试关联单选" options={[{ label: '选项1', value: '1', product_price11: "1111", product_price12: "2222", product_price1: 111 }, { label: '选项2', value: '2' }]} __id="remark11" />
|
174
175
|
|
175
176
|
<Field.Switch label="开关" __id="switch_table"></Field.Switch>
|
176
|
-
<Field.Input defaultValue={3} isRequired={true} label="
|
177
|
-
<Field.Input isRequired={true} label="
|
177
|
+
<Field.Input defaultValue={3} isRequired={true} label="含税单价" __id="product_price11" />
|
178
|
+
<Field.Input isRequired={true} label="未税单价" __id="product_price12"
|
179
|
+
withIds={[
|
180
|
+
"table.product_price11",
|
181
|
+
"shuilv"
|
182
|
+
]}
|
183
|
+
withFill={{
|
184
|
+
"value": [
|
185
|
+
{
|
186
|
+
"insert": "("
|
187
|
+
},
|
188
|
+
{
|
189
|
+
"insert": {
|
190
|
+
"span": true
|
191
|
+
},
|
192
|
+
"attributes": {
|
193
|
+
"id": "table.product_price11",
|
194
|
+
"color": "blue",
|
195
|
+
"tagKey": "fieldsValue",
|
196
|
+
"content": "当前表单.产品列表.含税单价"
|
197
|
+
}
|
198
|
+
},
|
199
|
+
{
|
200
|
+
"insert": "/(1+"
|
201
|
+
},
|
202
|
+
{
|
203
|
+
"insert": {
|
204
|
+
"span": true
|
205
|
+
},
|
206
|
+
"attributes": {
|
207
|
+
"id": "shuilv",
|
208
|
+
"color": "blue",
|
209
|
+
"tagKey": "fieldsValue",
|
210
|
+
"content": "当前表单.税率(%)"
|
211
|
+
}
|
212
|
+
},
|
213
|
+
{
|
214
|
+
"insert": "/ 100)).toFixed(2)\n\n\n"
|
215
|
+
}
|
216
|
+
],
|
217
|
+
"version": 1723016911807,
|
218
|
+
"withData": [
|
219
|
+
|
220
|
+
]
|
221
|
+
}}
|
222
|
+
/>
|
178
223
|
<Field.Input isRequired={true} label="商品价格" __id="product_price13" />
|
179
224
|
<Field.Input isRequired={true} label="商品价格" __id="product_price14" />
|
180
225
|
<Field.Input isRequired={true} label="商品价格" __id="product_price1" />
|
@@ -325,10 +370,10 @@ function App() {
|
|
325
370
|
return fieldsValue?.switch ? true : false
|
326
371
|
}}
|
327
372
|
/>
|
328
|
-
<Field.DatePicker defaultNow={true} label="
|
329
|
-
<Field.DatePicker label="
|
330
|
-
<Field.DatePicker disabled={true} defaultNow={true} label="
|
331
|
-
<Field.DatePicker defaultNow={true} label="
|
373
|
+
<Field.DatePicker defaultNow={true} label="datetime" prompt="" datetype="month" value='2022-10-22' __id="datetime" />
|
374
|
+
<Field.DatePicker label="datetime2" prompt="" datetype="date" __id="datetime2" />
|
375
|
+
<Field.DatePicker isRequired={true} disabled={true} defaultNow={true} label="datetime3" prompt="" datetype="datetime" value={'2022-10-22'} __id="datetime3" />
|
376
|
+
<Field.DatePicker defaultNow={true} label="datetime4" prompt="" datetype="year" value={'2022-10-22'} __id="datetime4" />
|
332
377
|
<Field.Input label="角色名称" __id="name" />
|
333
378
|
<Layout.FormRow layout={'1,1'}>
|
334
379
|
<Field.Input label="角色名称布局" __id="name1" />
|
@@ -336,7 +381,7 @@ function App() {
|
|
336
381
|
</Layout.FormRow>
|
337
382
|
<Field.CheckboxTree label="角色权限" __id="permissions" addRoot={false} treeData={treeData} />
|
338
383
|
<Layout.FormGroupTitle title={"关联信息"} />
|
339
|
-
<Field.WithSingleSelect ref={testRef} fillRules={[
|
384
|
+
<Field.WithSingleSelect ref={testRef} disabled={true} fillRules={[
|
340
385
|
{
|
341
386
|
"id": "636d3924-0298-4e9b-809a-26d4a10d7b89",
|
342
387
|
"type": 0,
|
@@ -368,7 +413,7 @@ function App() {
|
|
368
413
|
]
|
369
414
|
}
|
370
415
|
]} label="测试关联单选" options={[{ label: '选项1', value: '1', name: "1111", table: "[{\"price\":1,\"num\":2},{\"price\":2,\"num\":2}]" }, { label: '选项2', value: '2' }]} __id="remark11" />
|
371
|
-
<Field.WithMultipleSelect label="测试关联多选" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]} __id="remark12" />
|
416
|
+
<Field.WithMultipleSelect disabled={true} label="测试关联多选" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]} __id="remark12" />
|
372
417
|
<Layout.FormRow > <Field.TextArea label="备注" __id="remark" /></Layout.FormRow>
|
373
418
|
|
374
419
|
<Layout.FormRow layout={'1'}>
|
@@ -6,8 +6,9 @@ import 'dayjs/locale/zh-cn';
|
|
6
6
|
import zh from 'antd/es/date-picker/locale/zh_CN';
|
7
7
|
|
8
8
|
import updateLocale from 'dayjs/plugin/updateLocale';
|
9
|
-
|
9
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
10
10
|
dayjs.extend(updateLocale);
|
11
|
+
dayjs.extend(customParseFormat);
|
11
12
|
dayjs.updateLocale('zh-cn', {
|
12
13
|
weekStart: 0,
|
13
14
|
});
|
@@ -20,14 +21,18 @@ const DatePicker = ({ datetype, value, defaultNow, onChange, ...props }) => {
|
|
20
21
|
const [needConfirm, setNeedConfirm] = useState(false)
|
21
22
|
const isChanged = useRef(false)
|
22
23
|
useEffect(() => {
|
24
|
+
// console.log(`${props?.__id} defaultNow `, defaultNow)
|
25
|
+
// console.log(`${props?.__id} value `, value)
|
26
|
+
// console.log(`${props?.__id} value type `, typeof value)
|
23
27
|
if (defaultNow && !value && !isChanged.current) {
|
24
|
-
|
25
|
-
|
26
|
-
}
|
27
|
-
if (value && typeof value === "string" && dayjs(value).isValid()) {
|
28
|
-
typeof onChange === "function" && onChange(dayjs(value))
|
28
|
+
const now = dayjs().format("YYYY-MM-DD HH:mm:ss")
|
29
|
+
typeof onChange == "function" && onChange(now)
|
29
30
|
return
|
30
31
|
}
|
32
|
+
// if (value && typeof value === "string" && dayjs(value).isValid()) {
|
33
|
+
// typeof onChange === "function" && onChange(dayjs(value))
|
34
|
+
// return
|
35
|
+
// }
|
31
36
|
}, [value,onChange, format, picker])
|
32
37
|
|
33
38
|
const handleChange = (value, dateString) => {
|
@@ -70,7 +75,7 @@ const DatePicker = ({ datetype, value, defaultNow, onChange, ...props }) => {
|
|
70
75
|
}, [datetype])
|
71
76
|
return (
|
72
77
|
<BaseWrapper {...props}>
|
73
|
-
<OriginalDatePicker locale={zh} {...props} picker={picker} format={format} style={{ width: '100%' }} onChange={handleChange} value={
|
78
|
+
<OriginalDatePicker locale={zh} {...props} picker={picker} format={format} style={{ width: '100%' }} onChange={handleChange} value={value && dayjs(value).isValid() ? dayjs(value) : undefined} showTime={showTime} needConfirm={needConfirm} />
|
74
79
|
</BaseWrapper>
|
75
80
|
);
|
76
81
|
}
|
@@ -93,7 +93,6 @@ const SearchSelect = ({ addWrapper = true, value, type, defaultValue, onChange,
|
|
93
93
|
notFoundContent={fetching ? <Spin size="small" /> : null}
|
94
94
|
value={value}
|
95
95
|
{...props}
|
96
|
-
disabled={false}
|
97
96
|
filterOption={false}
|
98
97
|
showSearch={request && option_search ? true : false}
|
99
98
|
onSearch={request && option_search ? handleSearch : null}
|
@@ -110,7 +109,6 @@ const SearchSelect = ({ addWrapper = true, value, type, defaultValue, onChange,
|
|
110
109
|
notFoundContent={fetching ? <Spin size="small" /> : null}
|
111
110
|
value={value}
|
112
111
|
{...props}
|
113
|
-
disabled={false}
|
114
112
|
filterOption={false}
|
115
113
|
showSearch={request && option_search ? true : false}
|
116
114
|
onSearch={request && option_search ? handleSearch : null}
|
@@ -124,7 +124,7 @@ const WithMultipleSelect = ({ readItemRender, readonly, onChange, value, ...prop
|
|
124
124
|
|
125
125
|
// 选择用户组件
|
126
126
|
const UserSelect = ({ customComponent: CustomComponent, ...props }) => {
|
127
|
-
console.log("UserSelect ////// props",props)
|
127
|
+
// console.log("UserSelect ////// props",props)
|
128
128
|
if (!CustomComponent) return <BaseWrapper {...props}><Input {...props} /></BaseWrapper>
|
129
129
|
else return <BaseWrapper {...props}><CustomComponent {...props} /></BaseWrapper>
|
130
130
|
}
|
@@ -5,7 +5,7 @@ import { DeleteOutlined, EyeOutlined, PlusOutlined } from "@ant-design/icons";
|
|
5
5
|
import React, { useEffect, useRef, useState, version } from "react";
|
6
6
|
|
7
7
|
const UploadImage = ({ maxCount, value, onChange, ...props }) => {
|
8
|
-
console.log("uploadimage props", props)
|
8
|
+
// console.log("uploadimage props", props)
|
9
9
|
useEffect(() => {
|
10
10
|
if (value) {
|
11
11
|
console.log("value", value)
|
@@ -122,6 +122,8 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
122
122
|
if (dependencyMap.current.has(identifier)) {
|
123
123
|
const dependent = dependencyMap.current.get(identifier)
|
124
124
|
const dependentChildren = dependent.children;
|
125
|
+
// console.log("identifier", identifier)
|
126
|
+
// console.log("dependentChildren", dependentChildren)
|
125
127
|
if (!init && dependent?.fillRules && Array.isArray(dependent?.fillRules) && dependent?.fillRules.length > 0) {
|
126
128
|
handleFillRules(identifier, parentIdentifier, fieldValues, dependent?.fillRules)
|
127
129
|
}
|
@@ -140,8 +142,6 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
140
142
|
|
141
143
|
// 处理填充规则
|
142
144
|
const handleFillRules = (current_identifier, parentIdentifier, fieldValues, fillRules) => {
|
143
|
-
|
144
|
-
|
145
145
|
// 获取当前变更的字段数据
|
146
146
|
let current_value = getParamValue("fieldsValue", current_identifier, fieldValues, null)
|
147
147
|
for (let index = 0; index < fillRules.length; index++) {
|
@@ -161,13 +161,13 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
161
161
|
|
162
162
|
if (!Array.isArray(source_value)) return
|
163
163
|
let target_value = source_value.map(item => {
|
164
|
-
let
|
164
|
+
let target_item_value = {}
|
165
165
|
if (rule?.subRules && Array.isArray(rule?.subRules) && rule?.subRules.length > 0)
|
166
166
|
for (let index = 0; index < rule?.subRules.length; index++) {
|
167
167
|
const { source: subSource, target: subTarget } = rule?.subRules[index];
|
168
168
|
target_value[subTarget] = item?.[subSource]
|
169
169
|
}
|
170
|
-
return
|
170
|
+
return target_item_value
|
171
171
|
})
|
172
172
|
setValue = target_value
|
173
173
|
}
|
@@ -187,7 +187,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
187
187
|
form.setFieldValue(target, setValue)
|
188
188
|
handleFieldsWith(target, form.getFieldsValue())
|
189
189
|
}
|
190
|
-
console.log("current value", current_value)
|
190
|
+
// console.log("current value", current_value)
|
191
191
|
}
|
192
192
|
// 处理级联显示隐藏 @return {boolean} 是否需要重新渲染表单的字段
|
193
193
|
const handleFieldsVisible = (fieldValues, child, parentIdentifier) => {
|
@@ -207,6 +207,10 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
207
207
|
// 处理级联数据源
|
208
208
|
// 处理级联填充
|
209
209
|
const handleFieldsWithFill = async (fieldValues, child, parentIdentifier, componentName) => {
|
210
|
+
// console.log("handleFieldsWithFill fieldValues", fieldValues)
|
211
|
+
// console.log("handleFieldsWithFill child", child)
|
212
|
+
// console.log("handleFieldsWithFill parentIdentifier", parentIdentifier)
|
213
|
+
// console.log("handleFieldsWithFill componentName", componentName)
|
210
214
|
const withFill = child?.component?.props.withFill;
|
211
215
|
const withDataFetch = child?.component?.props.withDataFetch;
|
212
216
|
let withFillIndex = 0
|
@@ -219,8 +223,19 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
219
223
|
childIdentifier = [...parentIdentifier, childIdentifier.replace(`${withFillGroup}.`, "")]
|
220
224
|
}
|
221
225
|
}
|
226
|
+
// 被依赖字段不是子表字段,依赖字段是子表字段的情况
|
227
|
+
else if (childIdentifier.indexOf(".") >= 0) {
|
228
|
+
childIdentifier = childIdentifier.split(".")
|
229
|
+
let table_values = getParamValue("fieldsValue", childIdentifier[0], fieldValues, [])
|
230
|
+
// console.log("table_values", table_values)
|
231
|
+
if (Array.isArray(table_values) && table_values.length > 0)
|
232
|
+
for (let index = 0; index < table_values.length; index++) {
|
233
|
+
await handleFieldsWithFill(fieldValues, child, [childIdentifier[0], index], componentName)
|
234
|
+
}
|
235
|
+
return
|
236
|
+
|
237
|
+
}
|
222
238
|
let withDatas = [];
|
223
|
-
console.log("componentName", componentName)
|
224
239
|
// 先处理依赖数据
|
225
240
|
if (withFill?.withData && withFill?.withData.length > 0 && withDataFetch && typeof withDataFetch === 'function') {
|
226
241
|
for (let index = 0; index < withFill?.withData.length; index++) {
|
@@ -278,6 +293,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
278
293
|
if (formula && formula.length > 0) {
|
279
294
|
const formulaResult = evalFormula(formula);
|
280
295
|
// console.log("formulaResult", formulaResult)
|
296
|
+
// console.log("setFieldValue setFieldValue", childIdentifier)
|
281
297
|
form.setFieldValue(childIdentifier, formulaResult)
|
282
298
|
handleFieldsWith(childIdentifier, form.getFieldsValue())
|
283
299
|
}
|
@@ -312,7 +328,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
312
328
|
const handleFieldsChange = debounce((changedFields, allFields) => {
|
313
329
|
const fieldValues = form.getFieldsValue();
|
314
330
|
let needRefresh = false;
|
315
|
-
console.log("changedFields", changedFields)
|
331
|
+
// console.log("changedFields", changedFields)
|
316
332
|
changedFields.forEach(field => {
|
317
333
|
if (field.name && field.name.length > 0) {
|
318
334
|
needRefresh = handleFieldsWith(field.name, fieldValues);
|
package/src/utils/formula.js
CHANGED
@@ -4,9 +4,9 @@ const evalFormula =(formula) => {
|
|
4
4
|
try {
|
5
5
|
result = eval(formula.join(""));
|
6
6
|
} catch (error) {
|
7
|
-
console.error("formula error", error);
|
7
|
+
// console.error("formula error", error);
|
8
8
|
}
|
9
|
-
console.log("formula result", result);
|
9
|
+
// console.log("formula result", result);
|
10
10
|
return result.toString();
|
11
11
|
};
|
12
12
|
|