Skip to content

Commit

Permalink
refactor: 功能优化
Browse files Browse the repository at this point in the history
  • Loading branch information
xaboy committed Aug 8, 2024
1 parent a0a2238 commit d80514d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/core/src/components/formCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ export default function $FormCreate(FormCreate, components, directives) {

watch(modelValue, (n) => {
if (JSON.stringify(n || {}) === data.updateValue) return;
fapi.config.forceCoverValue ? fapi.coverValue(n || {}) : fapi.setValue(n || {});
if(fapi.config.forceCoverValue){
fc.$handle.appendData = {};
fapi.coverValue(n || {});
}else{
fapi.setValue(n || {});
}
}, {deep: true});

return {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/handler/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default function useContext(Handler) {
} else if (!condition[one.condition]) {
flag = false;
} else {
flag = (new Function('_$', '_$val', '$form', 'group', `with($form){with(this){with(group){ return _$['${one.condition}'](${one.field}, ${one.compare ? one.compare : '_$val'}); }}}`)).call(this.api.form, condition, one.value, this.api.top.form, group ? (this.subRuleData[group.id] || {}) : {});
flag = (new Function('_$', '_$val', '$form', '_group', `with($form){with(this){with(_group){ return _$['${one.condition}'](${one.field}, ${one.compare ? one.compare : '_$val'}); }}}`)).call(this.api.form, condition, one.value, this.api.top.form, group ? (this.subRuleData[group.id] || {}) : {});
}
if (or && flag) {
return true;
Expand All @@ -184,7 +184,7 @@ export default function useContext(Handler) {
fn = () => item(this.api.form, this.api);
} else {
const group = ctx.getParentGroup();
fn = () => (new Function('formulas', '$form', 'group', '$rule', '$api', `with($form){with(this){with(group){with(formulas){ return ${item} }}}}`)).call(this.api.form, this.fc.formulas, this.api.top.form, group ? (this.subRuleData[group.id] || {}) : {}, ctx.rule, this.api);
fn = () => (new Function('_formulas', '$form', '_group', '$rule', '$api', `with($form){with(this){with(_group){with(_formulas){ return ${item} }}}}`)).call(this.api.form, this.fc.formulas, this.api.top.form, group ? (this.subRuleData[group.id] || {}) : {}, ctx.rule, this.api);
}
return invoke(fn, undefined);
}, (n) => {
Expand Down

0 comments on commit d80514d

Please sign in to comment.