lu-lowcode-package-form 0.9.62 → 0.9.65
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 +119 -119
- package/dist/index.es.js +2266 -2258
- package/package.json +1 -1
- package/src/App.jsx +37 -2
- package/src/components/field/select/select.jsx +1 -0
- package/src/components/form-container/index.jsx +19 -3
package/package.json
CHANGED
package/src/App.jsx
CHANGED
@@ -139,8 +139,39 @@ function App() {
|
|
139
139
|
<Layout.FormGroupTitle title={"基本信息"} />
|
140
140
|
<Layout.FormRow layout={'1'}>
|
141
141
|
<Field.Table label="子表格" __id="table" >
|
142
|
+
<Field.WithSingleSelect ref={testRef} fillRules={[
|
143
|
+
{
|
144
|
+
"id": "636d3924-0298-4e9b-809a-26d4a10d7b89",
|
145
|
+
"type": 0,
|
146
|
+
"source": "product_price11",
|
147
|
+
"target": "product_price11",
|
148
|
+
"subRules": [
|
149
|
+
|
150
|
+
]
|
151
|
+
},
|
152
|
+
{
|
153
|
+
"id": "636d3924-0298-4e9b-809a-26d4a10d7b89",
|
154
|
+
"type": 0,
|
155
|
+
"source": "product_price12",
|
156
|
+
"target": "product_price12",
|
157
|
+
"subRules": [
|
158
|
+
|
159
|
+
]
|
160
|
+
},
|
161
|
+
{
|
162
|
+
"id": "636d3924-0298-4e9b-809a-26d4a10d7b89",
|
163
|
+
"type": 0,
|
164
|
+
"source": "product_price1",
|
165
|
+
"target": "product_price1",
|
166
|
+
"subRules": [
|
167
|
+
|
168
|
+
]
|
169
|
+
},
|
170
|
+
|
171
|
+
]} label="测试关联单选" options={[{ label: '选项1', value: '1', product_price11:"1111", product_price12:"2222",product_price1:111}, { label: '选项2', value: '2' }]} __id="remark11" />
|
172
|
+
|
142
173
|
<Field.Switch label="开关" __id="switch_table"></Field.Switch>
|
143
|
-
<Field.Input isRequired={true} label="商品价格" __id="product_price11" />
|
174
|
+
<Field.Input defaultValue={3} isRequired={true} label="商品价格" __id="product_price11" />
|
144
175
|
<Field.Input isRequired={true} label="商品价格" __id="product_price12" />
|
145
176
|
<Field.Input isRequired={true} label="商品价格" __id="product_price13" />
|
146
177
|
<Field.Input isRequired={true} label="商品价格" __id="product_price14" />
|
@@ -303,7 +334,7 @@ function App() {
|
|
303
334
|
</Layout.FormRow>
|
304
335
|
<Field.CheckboxTree label="角色权限" __id="permissions" addRoot={false} treeData={treeData} />
|
305
336
|
<Layout.FormGroupTitle title={"关联信息"} />
|
306
|
-
<Field.WithSingleSelect fillRules={[
|
337
|
+
<Field.WithSingleSelect ref={testRef} fillRules={[
|
307
338
|
{
|
308
339
|
"id": "636d3924-0298-4e9b-809a-26d4a10d7b89",
|
309
340
|
"type": 0,
|
@@ -375,6 +406,10 @@ function App() {
|
|
375
406
|
<Button type="primary" onClick={validateFields}>validateFields</Button>
|
376
407
|
<Button type="primary" onClick={getFormFields}>GetValues</Button>
|
377
408
|
<Button type="primary" onClick={setFormFields}>SetValues</Button>
|
409
|
+
<Button type="primary" onClick={()=>{
|
410
|
+
console.log("testRef.current",testRef.current)
|
411
|
+
testRef.current?.handleChange({ label: '选项1', value: '1', name:"1111",table:"[{\"price\":1,\"num\":2},{\"price\":2,\"num\":2}]"})
|
412
|
+
}}>testwithref</Button>
|
378
413
|
<Button type="primary" onClick={handleCols}>UpdateCol</Button>
|
379
414
|
</div>
|
380
415
|
|
@@ -124,6 +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
128
|
if (!CustomComponent) return <BaseWrapper {...props}><Input {...props} /></BaseWrapper>
|
128
129
|
else return <BaseWrapper {...props}><CustomComponent {...props} /></BaseWrapper>
|
129
130
|
}
|
@@ -140,12 +140,15 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
140
140
|
|
141
141
|
// 处理填充规则
|
142
142
|
const handleFillRules = (current_identifier, parentIdentifier, fieldValues, fillRules) => {
|
143
|
+
|
144
|
+
|
143
145
|
// 获取当前变更的字段数据
|
144
146
|
let current_value = getParamValue("fieldsValue", current_identifier, fieldValues, null)
|
145
147
|
for (let index = 0; index < fillRules.length; index++) {
|
146
148
|
const rule = fillRules[index];
|
147
|
-
|
149
|
+
let { source, target } = rule
|
148
150
|
let source_value = current_value?.[source]
|
151
|
+
let setValue = source_value
|
149
152
|
// 子表
|
150
153
|
if (rule?.type == 1) {
|
151
154
|
if (source_value && typeof source_value == "string") {
|
@@ -166,10 +169,23 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
|
|
166
169
|
}
|
167
170
|
return target_value
|
168
171
|
})
|
169
|
-
|
172
|
+
setValue = target_value
|
170
173
|
}
|
171
174
|
// 同级字段
|
172
|
-
else
|
175
|
+
else {
|
176
|
+
let withFillIndex = 0
|
177
|
+
let withFillGroup = ""
|
178
|
+
if (parentIdentifier && Array.isArray(parentIdentifier) && parentIdentifier.length > 1) {
|
179
|
+
withFillGroup = parentIdentifier.filter(item => typeof item == "string").join(".")
|
180
|
+
withFillIndex = parentIdentifier[parentIdentifier.length - 1]
|
181
|
+
target = [...parentIdentifier, target]
|
182
|
+
if (Array.isArray(current_value) && current_value.length > withFillIndex) {
|
183
|
+
setValue = current_value[withFillIndex]?.[source]
|
184
|
+
}
|
185
|
+
}
|
186
|
+
}
|
187
|
+
form.setFieldValue(target, setValue)
|
188
|
+
handleFieldsWith(target, form.getFieldsValue())
|
173
189
|
}
|
174
190
|
console.log("current value", current_value)
|
175
191
|
}
|