chore: 优化 input-kv 在编辑过程中不更换顺序 Close: #7201 (#7642)

This commit is contained in:
liaoxuezhi 2023-08-01 10:07:38 +08:00 committed by GitHub
parent 5cb15800f5
commit 150accdfac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -648,7 +648,7 @@ export function wrapControl<
if (pipeOut) {
const oldValue = this.model.value;
value = pipeOut(value, oldValue, data);
value = pipeOut.call(this, value, oldValue, data);
}
this.model.changeTmpValue(value, 'input');
@ -767,7 +767,7 @@ export function wrapControl<
} = this.props;
if (pipeOut) {
value = pipeOut(value, oldValue, data);
value = pipeOut.call(this, value, oldValue, data);
}
if (model.extraName) {
@ -784,7 +784,7 @@ export function wrapControl<
let value: any = this.model ? this.model.tmpValue : control.value;
if (control.pipeIn) {
value = control.pipeIn(value, data);
value = control.pipeIn.call(this, value, data);
}
return value;

View File

@ -14,10 +14,13 @@ addSchemaFilter(function (schema: Schema, renderer, props?: any) {
draggable: true,
...schema,
multiple: true,
pipeIn: (value: any) => {
pipeIn: function (this: any, value: any) {
if (!isObject(value)) {
return [];
}
if (isEqual(value, this.cachedValue)) {
return this.cachedValueArray;
}
const arr: Array<any> = [];
Object.keys(value).forEach(key => {
const valueType = typeof value[key];
@ -33,7 +36,7 @@ addSchemaFilter(function (schema: Schema, renderer, props?: any) {
});
return arr;
},
pipeOut: (value: any) => {
pipeOut: function (this: any, value: any) {
if (!Array.isArray(value)) {
return value;
}
@ -53,6 +56,8 @@ addSchemaFilter(function (schema: Schema, renderer, props?: any) {
obj[key] = value;
});
this.cachedValue = obj;
this.cachedValueArray = value;
return obj;
},
items: [