Skip to content

Commit 465ef97

Browse files
authored
Merge pull request #319 from lljj-x/fix/github-317
Fix/GitHub 317
2 parents 35d20b5 + 6e48d27 commit 465ef97

File tree

4 files changed

+26
-7
lines changed
  • packages/lib

4 files changed

+26
-7
lines changed

packages/lib/utils/schema/validate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ export function getMatchingIndex(formData, options, rootSchema, haveAllFields =
305305
if (isValid(augmentedSchema, formData)) {
306306
return i;
307307
}
308-
} else if (isValid(options[i], formData)) {
308+
} else if (isValid(option, formData)) {
309309
return i;
310310
}
311311
}

packages/lib/vue2/vue2-core/src/components/Widget.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,11 @@ export default {
255255
required: self.required,
256256
propPath: path2prop(curNodePath)
257257
});
258-
if (errors.length > 0) return callback(errors[0].message);
258+
if (errors.length > 0) {
259+
const errMsg = errors[0].message;
260+
if (callback) callback(errMsg);
261+
return Promise.reject(errMsg);
262+
}
259263

260264
// customRule 如果存在自定义校验
261265
const curCustomRule = self.$props.customRule;
@@ -268,7 +272,8 @@ export default {
268272
});
269273
}
270274

271-
return callback();
275+
if (callback) return callback();
276+
return Promise.resolve();
272277
},
273278
trigger: 'change'
274279
}

packages/lib/vue2/vue2-core/src/fields/combiningSchemas/SelectLinkageField/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515

1616
import retrieveSchema from '@lljj/vjsf-utils/schema/retriev';
1717
import getDefaultFormState from '@lljj/vjsf-utils/schema/getDefaultFormState';
18-
import { getMatchingOption } from '@lljj/vjsf-utils/schema/validate';
18+
import { getMatchingOption, isValid } from '@lljj/vjsf-utils/schema/validate';
1919

2020
import vueProps from '../../props';
2121
import Widget from '../../../components/Widget';
@@ -165,7 +165,14 @@ export default {
165165
}
166166
});
167167
} else {
168-
setPathVal(this.rootFormData, this.curNodePath, newOptionData === undefined ? curFormData : newOptionData);
168+
setPathVal(
169+
this.rootFormData,
170+
this.curNodePath,
171+
(newOptionData === undefined && isValid(retrieveSchema(
172+
this.selectList[newVal],
173+
this.rootSchema
174+
), curFormData)) ? curFormData : newOptionData
175+
);
169176
}
170177

171178
// 可添加一个配置通知外部这里变更

packages/lib/vue3/vue3-core/src/fields/combiningSchemas/SelectLinkageField/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717

1818
import retrieveSchema from '@lljj/vjsf-utils/schema/retriev';
1919
import getDefaultFormState from '@lljj/vjsf-utils/schema/getDefaultFormState';
20-
import { getMatchingOption } from '@lljj/vjsf-utils/schema/validate';
20+
import { getMatchingOption, isValid } from '@lljj/vjsf-utils/schema/validate';
2121

2222
import vueProps from '../../props';
2323
import Widget from '../../../components/Widget';
@@ -160,7 +160,14 @@ export default {
160160
}
161161
});
162162
} else {
163-
setPathVal(props.rootFormData, props.curNodePath, newOptionData === undefined ? curFormData : newOptionData);
163+
setPathVal(
164+
props.rootFormData,
165+
props.curNodePath,
166+
(newOptionData === undefined && isValid(retrieveSchema(
167+
props.selectList[newVal],
168+
props.rootSchema
169+
), curFormData)) ? curFormData : newOptionData
170+
);
164171
}
165172
});
166173

0 commit comments

Comments
 (0)