lu-lowcode-package-form 0.10.33 → 0.10.35

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lu-lowcode-package-form",
3
- "version": "0.10.33",
3
+ "version": "0.10.35",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^4.8.1",
6
6
  "@dnd-kit/core": "^6.1.0",
@@ -71,18 +71,6 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
71
71
  const initData = async (params) => {
72
72
  let item = null
73
73
  const ruleParams = {}
74
- // if (Array.isArray(props?.filterRules)) {
75
- // // 验证关联表字段是否需要重新渲染
76
- // for (let rule of props?.filterRules) {
77
- // let ruleValue;
78
- // if (rule.value.parent === "")
79
- // ruleValue = fieldsValue?.[rule.value.field_key];
80
- // else
81
- // ruleValue = fieldsValue?.[rule.value.parent]?.[fieldName?.[1]]?.[rule.value.field_key];
82
- // if (ruleValue && ruleValue?.value) ruleValue = ruleValue.value;
83
- // ruleParams[rule.column.column_name] = ruleValue ?? "##norequest##";
84
- // }
85
- // }
86
74
  if (request && typeof request === 'function') {
87
75
  debounceFetchOptions(params, ruleParams)
88
76
  }
@@ -4,7 +4,7 @@ import { DeleteOutlined } from "@ant-design/icons";
4
4
  import { BaseWrapper } from "../base.jsx"
5
5
  import { type } from "@testing-library/user-event/dist/type/index.js";
6
6
  import { nanoid } from "nanoid";
7
- import {eventEmitter} from '../../../utils/events'
7
+ import { eventEmitter } from '../../../utils/events'
8
8
 
9
9
  const TableAction = ({ label, subTableIndex, children, subTableHead = false, ...props }) => {
10
10
  //fsticky fright-0
@@ -30,12 +30,12 @@ const TableCol = ({ children, width, hidden, ...props }) => {
30
30
  </div>
31
31
  }
32
32
 
33
- const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow, form, fieldName,initializeFormRender, mode, ...props }) => {
34
- useEffect(()=>{
35
- console.log("Table form reload",form)
36
- },[form])
37
-
38
- const newidRefs = useRef(React.Children.map(children, () =>nanoid()));
33
+ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow, form, fieldName, initializeFormRender, mode, ...props }) => {
34
+ useEffect(() => {
35
+ console.log("Table form reload", form)
36
+ }, [form])
37
+
38
+ const newidRefs = useRef(React.Children.map(children, () => nanoid()));
39
39
  const [init, setInit] = useState(false);
40
40
  const name = props.componentId || props.__id
41
41
  const childrenIds = React.Children.map(children, (child) => `${name}.${child.props.componentId || child.props.__id}`)
@@ -46,18 +46,18 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
46
46
  }
47
47
  const [tableId, setTableId] = useState()
48
48
  const handleReloadTable = (target) => {
49
- if(fieldName == target) {
50
- setTableId(nanoid())
49
+ if (fieldName == target) {
50
+ setTableId(nanoid())
51
51
  }
52
52
  }
53
53
  useEffect(() => {
54
- setTableId(nanoid())
54
+ setTableId(nanoid())
55
55
  eventEmitter.on('reloadTable', handleReloadTable);
56
56
  return () => {
57
57
  eventEmitter.off('reloadTable', handleReloadTable);
58
58
  }
59
59
 
60
- },[])
60
+ }, [])
61
61
 
62
62
  if (props.isRequired)
63
63
  rules.push({ required: true, message: `子表[${props.label}]必须填写` });
@@ -67,7 +67,7 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
67
67
  return <div className="fw-full ">
68
68
  <div className="fw-full frelative fmin-h-20 foverflow-x-auto">
69
69
  {fields.length === 0 && <div key={`tableHead`} className="fborder-b fflex flex-nowrap fmin-w-full ">
70
- {React.Children.map(children, ( child, childIndex) => {
70
+ {React.Children.map(children, (child, childIndex) => {
71
71
  const hidden = child?.props?.calcHidden;
72
72
  return <TableCol width={150} key={`row_${0}_col_${childIndex}`} hidden={hidden}>
73
73
  {hidden ? null : React.cloneElement(child, {
@@ -103,7 +103,7 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
103
103
  const { componentId, __id, _componentName, ...otherProps } = child.props;
104
104
  const componentName = child.type?.displayName || _componentName;
105
105
  const identifier = componentId || __id;
106
-
106
+
107
107
  const hidden = props.calcHidden && mode != "desgin";
108
108
  return <TableCol width={150} key={`row_${field.key}_col_${childIndex}`} hidden={hidden}>
109
109
  <Form.Item
@@ -119,40 +119,37 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
119
119
  // 验证关联表字段是否需要重新渲染
120
120
  for (let rule of otherProps.filterRules) {
121
121
  let prevFieldValue, curFieldValue;
122
-
123
- if (rule.value.parent === "") {
122
+ if (rule.valueType != "variable") continue
123
+ if ("parent" in rule?.value && rule.value.parent === "") {
124
124
  prevFieldValue = prevValues?.[rule.value.field_key];
125
125
  curFieldValue = curValues?.[rule.value.field_key];
126
126
  } else {
127
- prevFieldValue = prevValues?.[rule.value.parent]?.[field.name]?.[rule.value.field_key];
128
- curFieldValue = curValues?.[rule.value.parent]?.[field.name]?.[rule.value.field_key];
127
+ prevFieldValue = prevValues?.[rule?.value?.parent]?.[field.name]?.[rule?.value?.field_key];
128
+ curFieldValue = curValues?.[rule?.value?.parent]?.[field.name]?.[rule?.value?.field_key];
129
129
  }
130
130
 
131
131
  if (prevFieldValue !== curFieldValue) {
132
- // console.log(`[${child.props.label}]prevFieldValue`,prevFieldValue)
133
- // console.log(`[${child.props.label}]curFieldValue`,curFieldValue)
134
- // console.log(`[${child.props.label}]是否需要渲染`,true)
135
132
  result = true;
136
- break;
133
+ break;
137
134
  }
138
135
  }
139
136
  }
140
137
  if (result) {
141
- newidRefs.current[childIndex] = nanoid();
138
+ newidRefs.current[childIndex] = nanoid();
142
139
  console.log(`[${child.props.label}]newid`, newidRefs.current[childIndex]);
143
140
  }
144
141
  return result;
145
142
  }}
146
143
  >
147
- {( {getFieldsValue}) => {
144
+ {({ getFieldsValue }) => {
148
145
  const fieldsValue = getFieldsValue();
149
146
  // const newid = nanoid()
150
147
  // console.log(`[${child.props.label}] key`,`row_${field.key}_child_${childIndex}_${newidRefs.current[childIndex]}` )
151
- return <Form.Item
148
+ return <Form.Item
152
149
  label=""
153
150
  style={{ marginBottom: 0 }}
154
151
  name={[field.name, col_id]}
155
- rules={rules}
152
+ rules={rules}
156
153
  >
157
154
  {React.cloneElement(child, {
158
155
  key: `row_${field.key}_child_${childIndex}_${newidRefs.current[childIndex]}`,
@@ -161,7 +158,7 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
161
158
  subTableHead: index === 0,
162
159
  form,
163
160
  fieldName: [fieldName, field.name, col_id],
164
- fieldsValue:fieldsValue,
161
+ fieldsValue: fieldsValue,
165
162
  initializeFormRender,
166
163
  })}
167
164
  </Form.Item>
@@ -500,7 +500,8 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
500
500
  ) {
501
501
  // 验证关联表字段是否需要重新渲染
502
502
  for (let rule of props.filterRules) {
503
- if (rule.value.parent != "") continue
503
+ if (rule.valueType != "variable") continue
504
+ if ("parent" in rule?.value && rule.value.parent != "") continue
504
505
  let prevFieldValue, curFieldValue;
505
506
 
506
507
  prevFieldValue = prevValues?.[rule.value.field_key];