Skip to content

Commit

Permalink
fix(table): 修复action只赋值一次的导致弹窗刷新失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Sep 5, 2020
1 parent dca4986 commit df19646
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"release": "release-it "
},
"dependencies": {
"@vue/composition-api": "^1.0.0-beta.10",
"@vue/composition-api": "^1.0.0-beta.11",
"ant-design-vue": "^1.6.5",
"axios": "^0.20.0",
"core-js": "^3.6.5",
Expand Down
53 changes: 31 additions & 22 deletions src/components/table/src/hooks/useColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function useColumns(
if (!columns) {
return [];
}
let pushActionColumns = false;
// let pushActionColumns = false;
let pushIndexColumns = false;
columns.forEach((item) => {
const { key, dataIndex } = item;
Expand All @@ -45,12 +45,12 @@ export function useColumns(
});
}
}
const actionIndex = columns.findIndex((column) => column.flag === 'ACTION');
if (actionColumn) {
pushActionColumns = actionIndex === -1;
} else if (actionIndex !== -1) {
columns.splice(actionIndex, 1);
}
// const actionIndex = columns.findIndex((column) => column.flag === 'ACTION');
// if (actionColumn) {
// pushActionColumns = actionIndex === -1;
// } else if (actionIndex !== -1) {
// columns.splice(actionIndex, 1);
// }
const indIndex = columns.findIndex((column) => column.flag === 'INDEX');
if (showIndexColumn && !isTreeTable) {
pushIndexColumns = indIndex === -1;
Expand Down Expand Up @@ -84,12 +84,13 @@ export function useColumns(
// ...indexColumnProps,
// });
// }
pushActionColumns &&
columns.push({
fixed: 'right',
...actionColumn,
flag: 'ACTION',
});

// pushActionColumns &&
// columns.push({
// fixed: 'right',
// ...actionColumn,
// flag: 'ACTION',
// });
if (pushIndexColumns) {
const isFixedLeft = columns.some((item) => item.fixed === 'left');

Expand Down Expand Up @@ -129,15 +130,23 @@ export function useColumns(
// });
// }

// if (actionColumn) {
// const hasIndex = columns.find((column) => column.flag === 'ACTION');
// !hasIndex &&
// columns.push({
// fixed: 'right',
// ...actionColumn,
// flag: 'ACTION',
// });
// }
if (actionColumn) {
const hasIndex = columns.findIndex((column) => column.flag === 'ACTION');
if (hasIndex === -1) {
columns.push({
fixed: 'right',
...actionColumn,
flag: 'ACTION',
});
} else {
columns[hasIndex] = {
...columns[hasIndex],
fixed: 'right',
...actionColumn,
flag: 'ACTION',
};
}
}
return columns;
});

Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2199,7 +2199,7 @@
optionalDependencies:
prettier "^1.18.2"

"@vue/composition-api@^1.0.0-beta.10":
"@vue/composition-api@^1.0.0-beta.11":
version "1.0.0-beta.11"
resolved "https://registry.npmjs.org/@vue/composition-api/-/composition-api-1.0.0-beta.11.tgz#260e9d23d59078d7a6358fec53c77a9adc0cd5b5"
integrity sha512-WHwX8e1V2NxQtFn7DsgET3QKAfA8kIm13hT4lCdGMAtxbM1dZ/lczF4wdhmkKtKrZiv657aanXV+cgGFF71krg==
Expand Down Expand Up @@ -6499,6 +6499,7 @@ forever-agent@~0.6.1:
integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=

"fork-ts-checker-webpack-plugin-v5@npm:fork-ts-checker-webpack-plugin@^5.0.11", fork-ts-checker-webpack-plugin@^5.0.13:
name fork-ts-checker-webpack-plugin-v5
version "5.1.0"
resolved "https://registry.npmjs.org/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-5.1.0.tgz#586fbee24aeea950c53bab529e32017f543e71cf"
integrity sha512-vuKyEjSLGbhQbEr5bifXXOkr9iV73L6n72mHoHIv7okvrf7O7z6RKeplM6C6ATPsukoQivij+Ba1vcptL60Z2g==
Expand Down

0 comments on commit df19646

Please sign in to comment.