lu-lowcode-package-form 0.11.39 → 0.11.40

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.11.39",
3
+ "version": "0.11.40",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^4.8.1",
6
6
  "@dnd-kit/core": "^6.1.0",
package/src/App.jsx CHANGED
@@ -631,7 +631,8 @@ function App() {
631
631
  <Field.DatePicker defaultNow={true} label="日期时间" prompt="" datetype="date" __id="datetime2" />
632
632
 
633
633
  <Field.WithSingleSelect ref={testRef}
634
- request={async (params) => {
634
+ request={async (params, ruleParams, fieldName) => {
635
+ console.log("request params", params, ruleParams, fieldName)
635
636
  if (params?.ruleParams?.node_ocm009lpxt2 == 111)
636
637
  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' }] } }
637
638
  else return { code: 0, data: { list: [{ label: '选项1', value: '1', product_price11: "1111", product_price12: "2222", product_price1: 111 }, { label: '选项2', value: '2' },] } }
@@ -19,10 +19,6 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
19
19
  }, []);
20
20
  const callbackQueue = useRef([]);
21
21
 
22
- useEffect(() => {
23
- console.log("fieldName change props", fieldName)
24
- }, [fieldName])
25
-
26
22
  useEffect(() => {
27
23
  // console.log("SearchSelect useEffect props", props)
28
24
  if (value) {
@@ -109,8 +105,8 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
109
105
  await debounceFetchOptions(params)
110
106
  }
111
107
 
112
- const debounceFetchOptions = debounce((params, ruleParams) => {
113
- fetchOptions(params, ruleParams).then(result => {
108
+ const debounceFetchOptions = useCallback(debounce((params, ruleParams) => {
109
+ fetchOptions(params, ruleParams, fieldName).then(result => {
114
110
  // console.log(`[${props?.label}]debounceFetchOptions result`, result);
115
111
  while (callbackQueue.current.length > 0) {
116
112
  const callback = callbackQueue.current.shift();
@@ -119,13 +115,13 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
119
115
  }
120
116
  }
121
117
  });
122
- }, 200)
118
+ }, 200), [fieldName]);
123
119
 
124
- const fetchList = async (params, ruleParams) => {
120
+ const fetchList = async (params, ruleParams, newFieldName) => {
125
121
  let list = []
126
122
  if (!(ruleParams && Object.values(ruleParams).some(value => value === "##norequest##"))) {
127
123
  setFetching(true)
128
- const response = await request({ ...params, ruleParams }, form, fieldName);
124
+ const response = await request({ ...params, ruleParams }, form, newFieldName);
129
125
  setFetching(false)
130
126
  if (response.code > 0) {
131
127
  callError && typeof callError === 'function' && callError(response.message);
@@ -155,9 +151,9 @@ const SearchSelect = forwardRef(({ addWrapper = true, form, fieldName, fieldsVal
155
151
  return list
156
152
  }
157
153
 
158
- const fetchOptions = async (params, ruleParams) => {
154
+ const fetchOptions = async (params, ruleParams, newFieldName) => {
159
155
  try {
160
- let list = await fetchList(params, ruleParams)
156
+ let list = await fetchList(params, ruleParams, newFieldName)
161
157
  list = await handleOptions(list)
162
158
  setNOptions(Array.isArray(list) ? list : [])
163
159
  return list