lu-lowcode-package-form 0.9.62 → 0.9.63

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lu-lowcode-package-form",
3
- "version": "0.9.62",
3
+ "version": "0.9.63",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^4.8.1",
6
6
  "@testing-library/jest-dom": "^5.17.0",
package/src/App.jsx CHANGED
@@ -139,6 +139,28 @@ 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
+ ]} label="测试关联单选" options={[{ label: '选项1', value: '1', product_price11:"1111", product_price12:"2222"}, { label: '选项2', value: '2' }]} __id="remark11" />
163
+
142
164
  <Field.Switch label="开关" __id="switch_table"></Field.Switch>
143
165
  <Field.Input isRequired={true} label="商品价格" __id="product_price11" />
144
166
  <Field.Input isRequired={true} label="商品价格" __id="product_price12" />
@@ -303,7 +325,7 @@ function App() {
303
325
  </Layout.FormRow>
304
326
  <Field.CheckboxTree label="角色权限" __id="permissions" addRoot={false} treeData={treeData} />
305
327
  <Layout.FormGroupTitle title={"关联信息"} />
306
- <Field.WithSingleSelect fillRules={[
328
+ <Field.WithSingleSelect ref={testRef} fillRules={[
307
329
  {
308
330
  "id": "636d3924-0298-4e9b-809a-26d4a10d7b89",
309
331
  "type": 0,
@@ -375,6 +397,10 @@ function App() {
375
397
  <Button type="primary" onClick={validateFields}>validateFields</Button>
376
398
  <Button type="primary" onClick={getFormFields}>GetValues</Button>
377
399
  <Button type="primary" onClick={setFormFields}>SetValues</Button>
400
+ <Button type="primary" onClick={()=>{
401
+ console.log("testRef.current",testRef.current)
402
+ testRef.current?.handleChange({ label: '选项1', value: '1', name:"1111",table:"[{\"price\":1,\"num\":2},{\"price\":2,\"num\":2}]"})
403
+ }}>testwithref</Button>
378
404
  <Button type="primary" onClick={handleCols}>UpdateCol</Button>
379
405
  </div>
380
406
 
@@ -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
- const { source, target } = rule
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,22 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
166
169
  }
167
170
  return target_value
168
171
  })
169
- form.setFieldValue(target, target_value)
172
+ setValue = target_value
170
173
  }
171
174
  // 同级字段
172
- else form.setFieldValue(target, source_value)
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)
173
188
  }
174
189
  console.log("current value", current_value)
175
190
  }