提交 c9600208 作者: vben

fix(table): table setting error #174 #165

上级 3ad1a4f5
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
- `ant-design-vue`组件注册移动到`components/registerComponent` - `ant-design-vue`组件注册移动到`components/registerComponent`
- 移除 `setup` 文件夹 - 移除 `setup` 文件夹
- 升级到`vite2` - 升级到`vite2`
- 图片预览改为`Image`组件实现,暂时移除函数式使用方式
### ✨ Features ### ✨ Features
...@@ -16,7 +17,7 @@ ...@@ -16,7 +17,7 @@
- 新增`PageWrapper`组件。并应用于示例页面 - 新增`PageWrapper`组件。并应用于示例页面
- 新增标签页折叠功能 - 新增标签页折叠功能
- 兼容旧版浏览器 - 兼容旧版浏览器
- tinymce 新增图片上传· - tinymce 新增图片上传
### 🐛 Bug Fixes ### 🐛 Bug Fixes
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
"vditor": "^3.7.5", "vditor": "^3.7.5",
"vue": "^3.0.5", "vue": "^3.0.5",
"vue-i18n": "^9.0.0-rc.1", "vue-i18n": "^9.0.0-rc.1",
"vue-router": "^4.0.2", "vue-router": "^4.0.3",
"vue-types": "^3.0.1", "vue-types": "^3.0.1",
"vuex": "^4.0.0-rc.2", "vuex": "^4.0.0-rc.2",
"vuex-module-decorators": "^1.0.1", "vuex-module-decorators": "^1.0.1",
......
...@@ -143,10 +143,14 @@ ...@@ -143,10 +143,14 @@
emit emit
); );
const { getViewColumns, getColumns, setColumns, getColumnsRef, getCacheColumns } = useColumns( const {
getProps, getViewColumns,
getPaginationInfo getColumns,
); setCacheColumnsByField,
setColumns,
getColumnsRef,
getCacheColumns,
} = useColumns(getProps, getPaginationInfo);
const { getScrollRef, redoHeight } = useTableScroll( const { getScrollRef, redoHeight } = useTableScroll(
getProps, getProps,
...@@ -238,6 +242,7 @@ ...@@ -238,6 +242,7 @@
updateTableData, updateTableData,
setShowPagination, setShowPagination,
getShowPagination, getShowPagination,
setCacheColumnsByField,
getSize: () => { getSize: () => {
return unref(getBindValues).size as SizeType; return unref(getBindValues).size as SizeType;
}, },
......
...@@ -326,7 +326,7 @@ ...@@ -326,7 +326,7 @@
if (isFixed && !item.width) { if (isFixed && !item.width) {
item.width = 100; item.width = 100;
} }
table.setCacheColumnsByField?.(item.dataIndex, { fixed: isFixed });
table.setColumns(columns); table.setColumns(columns);
} }
......
...@@ -173,6 +173,17 @@ export function useColumns( ...@@ -173,6 +173,17 @@ export function useColumns(
// cacheColumns = columns?.filter((item) => !item.flag) ?? []; // cacheColumns = columns?.filter((item) => !item.flag) ?? [];
// }); // });
function setCacheColumnsByField(dataIndex: string | undefined, value: Partial<BasicColumn>) {
if (!dataIndex || !value) {
return;
}
cacheColumns.forEach((item) => {
if (item.dataIndex === dataIndex) {
Object.assign(item, value);
return;
}
});
}
/** /**
* set columns * set columns
* @param columnList key|column * @param columnList key|column
...@@ -237,7 +248,14 @@ export function useColumns( ...@@ -237,7 +248,14 @@ export function useColumns(
return cacheColumns; return cacheColumns;
} }
return { getColumnsRef, getCacheColumns, getColumns, setColumns, getViewColumns }; return {
getColumnsRef,
getCacheColumns,
getColumns,
setColumns,
getViewColumns,
setCacheColumnsByField,
};
} }
function sortFixedColumn(columns: BasicColumn[]) { function sortFixedColumn(columns: BasicColumn[]) {
......
...@@ -127,11 +127,10 @@ export function useTableScroll( ...@@ -127,11 +127,10 @@ export function useTableScroll(
width += 60; width += 60;
} }
// TODO propsdth ?? 0; // TODO props ?? 0;
const NORMAL_WIDTH = 150; const NORMAL_WIDTH = 150;
const columns = unref(columnsRef); const columns = unref(columnsRef).filter((item) => !item.defaultHidden);
columns.forEach((item) => { columns.forEach((item) => {
width += Number.parseInt(item.width as string) || 0; width += Number.parseInt(item.width as string) || 0;
}); });
...@@ -150,7 +149,6 @@ export function useTableScroll( ...@@ -150,7 +149,6 @@ export function useTableScroll(
const getScrollRef = computed(() => { const getScrollRef = computed(() => {
const tableHeight = unref(tableHeightRef); const tableHeight = unref(tableHeightRef);
const { canResize, scroll } = unref(propsRef); const { canResize, scroll } = unref(propsRef);
return { return {
x: unref(getScrollX), x: unref(getScrollX),
y: canResize ? tableHeight : null, y: canResize ? tableHeight : null,
......
...@@ -104,6 +104,7 @@ export interface TableActionType { ...@@ -104,6 +104,7 @@ export interface TableActionType {
updateTableData: (index: number, key: string, value: any) => Recordable; updateTableData: (index: number, key: string, value: any) => Recordable;
setShowPagination: (show: boolean) => Promise<void>; setShowPagination: (show: boolean) => Promise<void>;
getShowPagination: () => boolean; getShowPagination: () => boolean;
setCacheColumnsByField?: (dataIndex: string | undefined, value: BasicColumn) => void;
} }
export interface FetchSetting { export interface FetchSetting {
......
...@@ -108,10 +108,8 @@ const transform: AxiosTransform = { ...@@ -108,10 +108,8 @@ const transform: AxiosTransform = {
const params = config.params || {}; const params = config.params || {};
if (config.method?.toUpperCase() === RequestEnum.GET) { if (config.method?.toUpperCase() === RequestEnum.GET) {
if (!isString(params)) { if (!isString(params)) {
config.data = { // 给 get 请求加上时间戳参数,避免从缓存中拿数据。
// 给 get 请求加上时间戳参数,避免从缓存中拿数据。 config.params = Object.assign(params || {}, createNow(joinTime, false));
params: Object.assign(params || {}, createNow(joinTime, false)),
};
} else { } else {
// 兼容restful风格 // 兼容restful风格
config.url = config.url + params + `${createNow(joinTime, true)}`; config.url = config.url + params + `${createNow(joinTime, true)}`;
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
dataIndex: 'category', dataIndex: 'category',
width: 80, width: 80,
align: 'center', align: 'center',
defaultHidden: true,
slots: { customRender: 'category' }, slots: { customRender: 'category' },
}, },
{ {
...@@ -74,6 +75,7 @@ ...@@ -74,6 +75,7 @@
api: demoListApi, api: demoListApi,
columns: columns, columns: columns,
bordered: true, bordered: true,
showTableSetting: true,
}); });
return { return {
......
...@@ -7887,10 +7887,10 @@ vue-i18n@^9.0.0-rc.1: ...@@ -7887,10 +7887,10 @@ vue-i18n@^9.0.0-rc.1:
"@intlify/shared" "9.0.0-rc.1" "@intlify/shared" "9.0.0-rc.1"
"@vue/devtools-api" "^6.0.0-beta.3" "@vue/devtools-api" "^6.0.0-beta.3"
vue-router@^4.0.2: vue-router@^4.0.3:
version "4.0.2" version "4.0.3"
resolved "https://registry.npmjs.org/vue-router/-/vue-router-4.0.2.tgz#5702bf8fa14535b80142fde226bf41a84917b1f4" resolved "https://registry.npmjs.org/vue-router/-/vue-router-4.0.3.tgz#8b26050c88b2dec7e27a88835f71046b365823ec"
integrity sha512-LCsTSb5H25dZCxjsLasM9UED1BTg9vyTnp0Z9UhwC6QoqgLuHr/ySf7hjI/V0j2+xCKqJtecfmpghk6U8I2e4w== integrity sha512-AD1OjtVPyQHTSpoRsEGfPpxRQwhAhxcacOYO3zJ3KNkYP/r09mileSp6kdMQKhZWP2cFsPR3E2M3PZguSN5/ww==
vue-types@^3.0.0, vue-types@^3.0.1: vue-types@^3.0.0, vue-types@^3.0.1:
version "3.0.1" version "3.0.1"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论