Skip to content

Table的【可编辑行】示例代码,"修改多行,仅保存1行时",逻辑有问题 #1700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
liangxinhui opened this issue Jan 8, 2020 · 3 comments · Fixed by liangxinhui/ant-design-vue#1 or #1704
Labels

Comments

@liangxinhui
Copy link
Contributor

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

1.4.10

Environment

windows10, Microsoft Edge 79.0.309.58 , Vue 2.6.10

Reproduction link

Edit on CodeSandbox

Steps to reproduce

  1. 复制官网 Table的【可编辑行】 示例代码
  2. 分别在两行上点击 Edit。并修改
  3. 其中1行点保存,另1行点取消。

What is expected?

1行保存修改,另1行返回原来的值。

What is actually happening?

两行都执行了修改。取消无效

@liangxinhui
Copy link
Contributor Author

Save 的时候,应该用 cacheData 作为基础数据。然后把当前行的修改刷新进去。

@liangxinhui
Copy link
Contributor Author

我尝试做了修改,目前看起来是正常的:

原代码:

      save(key) {
        const newData = [...this.data];
        const target = newData.filter(item => key === item.key)[0];
        if (target) {
          delete target.editable;
          this.data = newData;
          this.cacheData = newData.map(item => ({ ...item }));
        }
      },

修改为:

      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];
        if (target && targetCache) {
          delete target.editable;
          this.data = newData;
          Object.assign(
            targetCache,
            target
          );
          this.cacheData = newCacheData;
        }
      },

liangxinhui added a commit to liangxinhui/ant-design-vue that referenced this issue Jan 9, 2020
liangxinhui added a commit to liangxinhui/ant-design-vue that referenced this issue Jan 9, 2020
@liangxinhui liangxinhui mentioned this issue Jan 9, 2020
13 tasks
tangjinzhou pushed a commit that referenced this issue Jan 15, 2020
@github-actions
Copy link

github-actions bot commented Jan 9, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant