docs:table demo optimize (#5142)
parent
115ca4d8ec
commit
441024b993
|
@ -91,7 +91,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
handleChange(value, key, column) {
|
handleChange(value, key, column) {
|
||||||
const newData = [...this.data];
|
const newData = [...this.data];
|
||||||
const target = newData.filter(item => key === item.key)[0];
|
const target = newData.find(item => key === item.key);
|
||||||
if (target) {
|
if (target) {
|
||||||
target[column] = value;
|
target[column] = value;
|
||||||
this.data = newData;
|
this.data = newData;
|
||||||
|
@ -99,7 +99,7 @@ export default {
|
||||||
},
|
},
|
||||||
edit(key) {
|
edit(key) {
|
||||||
const newData = [...this.data];
|
const newData = [...this.data];
|
||||||
const target = newData.filter(item => key === item.key)[0];
|
const target = newData.find(item => key === item.key);
|
||||||
this.editingKey = key;
|
this.editingKey = key;
|
||||||
if (target) {
|
if (target) {
|
||||||
target.editable = true;
|
target.editable = true;
|
||||||
|
@ -109,8 +109,8 @@ export default {
|
||||||
save(key) {
|
save(key) {
|
||||||
const newData = [...this.data];
|
const newData = [...this.data];
|
||||||
const newCacheData = [...this.cacheData];
|
const newCacheData = [...this.cacheData];
|
||||||
const target = newData.filter(item => key === item.key)[0];
|
const target = newData.find(item => key === item.key);
|
||||||
const targetCache = newCacheData.filter(item => key === item.key)[0];
|
const targetCache = newCacheData.find(item => key === item.key);
|
||||||
if (target && targetCache) {
|
if (target && targetCache) {
|
||||||
delete target.editable;
|
delete target.editable;
|
||||||
this.data = newData;
|
this.data = newData;
|
||||||
|
@ -121,10 +121,10 @@ export default {
|
||||||
},
|
},
|
||||||
cancel(key) {
|
cancel(key) {
|
||||||
const newData = [...this.data];
|
const newData = [...this.data];
|
||||||
const target = newData.filter(item => key === item.key)[0];
|
const target = newData.find(item => key === item.key);
|
||||||
this.editingKey = '';
|
this.editingKey = '';
|
||||||
if (target) {
|
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;
|
delete target.editable;
|
||||||
this.data = newData;
|
this.data = newData;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue