docs:table demo optimize (#5142)

1.x
Jeminas 2022-01-11 16:14:31 +08:00 committed by GitHub
parent 115ca4d8ec
commit 441024b993
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -91,7 +91,7 @@ export default {
methods: {
handleChange(value, key, column) {
const newData = [...this.data];
const target = newData.filter(item => key === item.key)[0];
const target = newData.find(item => key === item.key);
if (target) {
target[column] = value;
this.data = newData;
@ -99,7 +99,7 @@ export default {
},
edit(key) {
const newData = [...this.data];
const target = newData.filter(item => key === item.key)[0];
const target = newData.find(item => key === item.key);
this.editingKey = key;
if (target) {
target.editable = true;
@ -109,8 +109,8 @@ export default {
save(key) {
const newData = [...this.data];
const newCacheData = [...this.cacheData];
const target = newData.filter(item => key === item.key)[0];
const targetCache = newCacheData.filter(item => key === item.key)[0];
const target = newData.find(item => key === item.key);
const targetCache = newCacheData.find(item => key === item.key);
if (target && targetCache) {
delete target.editable;
this.data = newData;
@ -121,10 +121,10 @@ export default {
},
cancel(key) {
const newData = [...this.data];
const target = newData.filter(item => key === item.key)[0];
const target = newData.find(item => key === item.key);
this.editingKey = '';
if (target) {
Object.assign(target, this.cacheData.filter(item => key === item.key)[0]);
Object.assign(target, this.cacheData.find(item => key === item.key));
delete target.editable;
this.data = newData;
}