Skip to content

Commit c960020

Browse files
committed
fix(table): table setting error #174 #165
1 parent 3ad1a4f commit c960020

File tree

10 files changed

+43
-20
lines changed

10 files changed

+43
-20
lines changed

CHANGELOG.zh_CN.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- `ant-design-vue`组件注册移动到`components/registerComponent`
88
- 移除 `setup` 文件夹
99
- 升级到`vite2`
10+
- 图片预览改为`Image`组件实现,暂时移除函数式使用方式
1011

1112
### ✨ Features
1213

@@ -16,7 +17,7 @@
1617
- 新增`PageWrapper`组件。并应用于示例页面
1718
- 新增标签页折叠功能
1819
- 兼容旧版浏览器
19-
- tinymce 新增图片上传·
20+
- tinymce 新增图片上传
2021

2122
### 🐛 Bug Fixes
2223

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"vditor": "^3.7.5",
3636
"vue": "^3.0.5",
3737
"vue-i18n": "^9.0.0-rc.1",
38-
"vue-router": "^4.0.2",
38+
"vue-router": "^4.0.3",
3939
"vue-types": "^3.0.1",
4040
"vuex": "^4.0.0-rc.2",
4141
"vuex-module-decorators": "^1.0.1",

src/components/Table/src/BasicTable.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,14 @@
143143
emit
144144
);
145145
146-
const { getViewColumns, getColumns, setColumns, getColumnsRef, getCacheColumns } = useColumns(
147-
getProps,
148-
getPaginationInfo
149-
);
146+
const {
147+
getViewColumns,
148+
getColumns,
149+
setCacheColumnsByField,
150+
setColumns,
151+
getColumnsRef,
152+
getCacheColumns,
153+
} = useColumns(getProps, getPaginationInfo);
150154
151155
const { getScrollRef, redoHeight } = useTableScroll(
152156
getProps,
@@ -238,6 +242,7 @@
238242
updateTableData,
239243
setShowPagination,
240244
getShowPagination,
245+
setCacheColumnsByField,
241246
getSize: () => {
242247
return unref(getBindValues).size as SizeType;
243248
},

src/components/Table/src/components/settings/ColumnSetting.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@
326326
if (isFixed && !item.width) {
327327
item.width = 100;
328328
}
329-
329+
table.setCacheColumnsByField?.(item.dataIndex, { fixed: isFixed });
330330
table.setColumns(columns);
331331
}
332332

src/components/Table/src/hooks/useColumns.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,17 @@ export function useColumns(
173173
// cacheColumns = columns?.filter((item) => !item.flag) ?? [];
174174
// });
175175

176+
function setCacheColumnsByField(dataIndex: string | undefined, value: Partial<BasicColumn>) {
177+
if (!dataIndex || !value) {
178+
return;
179+
}
180+
cacheColumns.forEach((item) => {
181+
if (item.dataIndex === dataIndex) {
182+
Object.assign(item, value);
183+
return;
184+
}
185+
});
186+
}
176187
/**
177188
* set columns
178189
* @param columnList key|column
@@ -237,7 +248,14 @@ export function useColumns(
237248
return cacheColumns;
238249
}
239250

240-
return { getColumnsRef, getCacheColumns, getColumns, setColumns, getViewColumns };
251+
return {
252+
getColumnsRef,
253+
getCacheColumns,
254+
getColumns,
255+
setColumns,
256+
getViewColumns,
257+
setCacheColumnsByField,
258+
};
241259
}
242260

243261
function sortFixedColumn(columns: BasicColumn[]) {

src/components/Table/src/hooks/useTableScroll.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,10 @@ export function useTableScroll(
127127
width += 60;
128128
}
129129

130-
// TODO propsdth ?? 0;
130+
// TODO props ?? 0;
131131
const NORMAL_WIDTH = 150;
132132

133-
const columns = unref(columnsRef);
134-
133+
const columns = unref(columnsRef).filter((item) => !item.defaultHidden);
135134
columns.forEach((item) => {
136135
width += Number.parseInt(item.width as string) || 0;
137136
});
@@ -150,7 +149,6 @@ export function useTableScroll(
150149
const getScrollRef = computed(() => {
151150
const tableHeight = unref(tableHeightRef);
152151
const { canResize, scroll } = unref(propsRef);
153-
154152
return {
155153
x: unref(getScrollX),
156154
y: canResize ? tableHeight : null,

src/components/Table/src/types/table.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export interface TableActionType {
104104
updateTableData: (index: number, key: string, value: any) => Recordable;
105105
setShowPagination: (show: boolean) => Promise<void>;
106106
getShowPagination: () => boolean;
107+
setCacheColumnsByField?: (dataIndex: string | undefined, value: BasicColumn) => void;
107108
}
108109

109110
export interface FetchSetting {

src/utils/http/axios/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,8 @@ const transform: AxiosTransform = {
108108
const params = config.params || {};
109109
if (config.method?.toUpperCase() === RequestEnum.GET) {
110110
if (!isString(params)) {
111-
config.data = {
112-
// 给 get 请求加上时间戳参数,避免从缓存中拿数据。
113-
params: Object.assign(params || {}, createNow(joinTime, false)),
114-
};
111+
// 给 get 请求加上时间戳参数,避免从缓存中拿数据。
112+
config.params = Object.assign(params || {}, createNow(joinTime, false));
115113
} else {
116114
// 兼容restful风格
117115
config.url = config.url + params + `${createNow(joinTime, true)}`;

src/views/demo/table/CustomerCell.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
dataIndex: 'category',
3636
width: 80,
3737
align: 'center',
38+
defaultHidden: true,
3839
slots: { customRender: 'category' },
3940
},
4041
{
@@ -74,6 +75,7 @@
7475
api: demoListApi,
7576
columns: columns,
7677
bordered: true,
78+
showTableSetting: true,
7779
});
7880
7981
return {

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7887,10 +7887,10 @@ vue-i18n@^9.0.0-rc.1:
78877887
"@intlify/shared" "9.0.0-rc.1"
78887888
"@vue/devtools-api" "^6.0.0-beta.3"
78897889

7890-
vue-router@^4.0.2:
7891-
version "4.0.2"
7892-
resolved "https://registry.npmjs.org/vue-router/-/vue-router-4.0.2.tgz#5702bf8fa14535b80142fde226bf41a84917b1f4"
7893-
integrity sha512-LCsTSb5H25dZCxjsLasM9UED1BTg9vyTnp0Z9UhwC6QoqgLuHr/ySf7hjI/V0j2+xCKqJtecfmpghk6U8I2e4w==
7890+
vue-router@^4.0.3:
7891+
version "4.0.3"
7892+
resolved "https://registry.npmjs.org/vue-router/-/vue-router-4.0.3.tgz#8b26050c88b2dec7e27a88835f71046b365823ec"
7893+
integrity sha512-AD1OjtVPyQHTSpoRsEGfPpxRQwhAhxcacOYO3zJ3KNkYP/r09mileSp6kdMQKhZWP2cFsPR3E2M3PZguSN5/ww==
78947894

78957895
vue-types@^3.0.0, vue-types@^3.0.1:
78967896
version "3.0.1"

0 commit comments

Comments
 (0)