1.组件change添加参数,添加支持function格式2.多选框bug修复

This commit is contained in:
825299534@qq.com
2025-06-06 15:01:13 +08:00
parent ef3183e435
commit 1280a48b9a
4 changed files with 17 additions and 6 deletions

View File

@ -192,7 +192,7 @@
}
function displayText() {
const _checked = checked.value;;
const _checked = checked.value || [];
const labelArr = [];
(getOptions.value || []).forEach((opt) => {
if (_checked.includes(opt.value)) {

View File

@ -438,9 +438,14 @@
if (schema.componentProps?.['events']) {
for (const eventKey in schema.componentProps['events']) {
if (eventKey !== 'change') return;
const handler = schema.componentProps['events'][eventKey];
try {
const event = new Function('schema', 'formModel', 'formActionType', 'extParams', `${schema.componentProps['events'][eventKey]}`);
event(schema, formModel, formApi, { formData });
if (typeof handler === 'string') {
const event = new Function('schema', 'formModel', 'formActionType', 'extParams', handler);
event(schema, formModel, formApi, { formData, allSchemas });
} else if (typeof handler === 'function') {
handler(schema, formModel, formApi, { formData, allSchemas });
}
} catch (error) {
console.log('error', error);
notification.error({

View File

@ -438,9 +438,14 @@
if (schema.componentProps?.['events']) {
for (const eventKey in schema.componentProps['events']) {
if (eventKey !== 'change') return;
const handler = schema.componentProps['events'][eventKey];
try {
const event = new Function('schema', 'formModel', 'formActionType', 'extParams', `${schema.componentProps['events'][eventKey]}`);
event(schema, formModel, formApi, { formData });
if (typeof handler === 'string') {
const event = new Function('schema', 'formModel', 'formActionType', 'extParams', handler);
event(schema, formModel, formApi, { formData, allSchemas });
} else if (typeof handler === 'function') {
handler(schema, formModel, formApi, { formData, allSchemas });
}
} catch (error) {
console.log('error', error);
notification.error({

View File

@ -275,6 +275,7 @@
}) ?? {};
} else {
if (componentProps['events']) {
const allSchemas = formProps.value.schemas;
for (const eventKey in componentProps['events']) {
try {
const fun = componentProps['events'][eventKey];
@ -290,7 +291,7 @@
let field = camelCaseString(item);
if (field) cloneFormModel[field] = cloneFormModel[item];
}
event(props.schema, isCamelCase ? cloneFormModel : formModel, props.formApi, { value, selectedOptions });
event(props.schema, isCamelCase ? cloneFormModel : formModel, props.formApi, {formData, value, selectedOptions, allSchemas: allSchemas});
if (isCamelCase) {
for (let item in formModel) {