Commit c9600208c52e3575fe8741e350833f7952bae3b7
1 parent
3ad1a4f5
fix(table): table setting error #174 #165
Showing
10 changed files
with
43 additions
and
20 deletions
CHANGELOG.zh_CN.md
@@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
7 | - `ant-design-vue`组件注册移动到`components/registerComponent` | 7 | - `ant-design-vue`组件注册移动到`components/registerComponent` |
8 | - 移除 `setup` 文件夹 | 8 | - 移除 `setup` 文件夹 |
9 | - 升级到`vite2` | 9 | - 升级到`vite2` |
10 | +- 图片预览改为`Image`组件实现,暂时移除函数式使用方式 | ||
10 | 11 | ||
11 | ### ✨ Features | 12 | ### ✨ Features |
12 | 13 | ||
@@ -16,7 +17,7 @@ | @@ -16,7 +17,7 @@ | ||
16 | - 新增`PageWrapper`组件。并应用于示例页面 | 17 | - 新增`PageWrapper`组件。并应用于示例页面 |
17 | - 新增标签页折叠功能 | 18 | - 新增标签页折叠功能 |
18 | - 兼容旧版浏览器 | 19 | - 兼容旧版浏览器 |
19 | -- tinymce 新增图片上传· | 20 | +- tinymce 新增图片上传 |
20 | 21 | ||
21 | ### 🐛 Bug Fixes | 22 | ### 🐛 Bug Fixes |
22 | 23 |
package.json
@@ -35,7 +35,7 @@ | @@ -35,7 +35,7 @@ | ||
35 | "vditor": "^3.7.5", | 35 | "vditor": "^3.7.5", |
36 | "vue": "^3.0.5", | 36 | "vue": "^3.0.5", |
37 | "vue-i18n": "^9.0.0-rc.1", | 37 | "vue-i18n": "^9.0.0-rc.1", |
38 | - "vue-router": "^4.0.2", | 38 | + "vue-router": "^4.0.3", |
39 | "vue-types": "^3.0.1", | 39 | "vue-types": "^3.0.1", |
40 | "vuex": "^4.0.0-rc.2", | 40 | "vuex": "^4.0.0-rc.2", |
41 | "vuex-module-decorators": "^1.0.1", | 41 | "vuex-module-decorators": "^1.0.1", |
src/components/Table/src/BasicTable.vue
@@ -143,10 +143,14 @@ | @@ -143,10 +143,14 @@ | ||
143 | emit | 143 | emit |
144 | ); | 144 | ); |
145 | 145 | ||
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); | ||
150 | 154 | ||
151 | const { getScrollRef, redoHeight } = useTableScroll( | 155 | const { getScrollRef, redoHeight } = useTableScroll( |
152 | getProps, | 156 | getProps, |
@@ -238,6 +242,7 @@ | @@ -238,6 +242,7 @@ | ||
238 | updateTableData, | 242 | updateTableData, |
239 | setShowPagination, | 243 | setShowPagination, |
240 | getShowPagination, | 244 | getShowPagination, |
245 | + setCacheColumnsByField, | ||
241 | getSize: () => { | 246 | getSize: () => { |
242 | return unref(getBindValues).size as SizeType; | 247 | return unref(getBindValues).size as SizeType; |
243 | }, | 248 | }, |
src/components/Table/src/components/settings/ColumnSetting.vue
@@ -326,7 +326,7 @@ | @@ -326,7 +326,7 @@ | ||
326 | if (isFixed && !item.width) { | 326 | if (isFixed && !item.width) { |
327 | item.width = 100; | 327 | item.width = 100; |
328 | } | 328 | } |
329 | - | 329 | + table.setCacheColumnsByField?.(item.dataIndex, { fixed: isFixed }); |
330 | table.setColumns(columns); | 330 | table.setColumns(columns); |
331 | } | 331 | } |
332 | 332 |
src/components/Table/src/hooks/useColumns.ts
@@ -173,6 +173,17 @@ export function useColumns( | @@ -173,6 +173,17 @@ export function useColumns( | ||
173 | // cacheColumns = columns?.filter((item) => !item.flag) ?? []; | 173 | // cacheColumns = columns?.filter((item) => !item.flag) ?? []; |
174 | // }); | 174 | // }); |
175 | 175 | ||
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 | + } | ||
176 | /** | 187 | /** |
177 | * set columns | 188 | * set columns |
178 | * @param columnList key|column | 189 | * @param columnList key|column |
@@ -237,7 +248,14 @@ export function useColumns( | @@ -237,7 +248,14 @@ export function useColumns( | ||
237 | return cacheColumns; | 248 | return cacheColumns; |
238 | } | 249 | } |
239 | 250 | ||
240 | - return { getColumnsRef, getCacheColumns, getColumns, setColumns, getViewColumns }; | 251 | + return { |
252 | + getColumnsRef, | ||
253 | + getCacheColumns, | ||
254 | + getColumns, | ||
255 | + setColumns, | ||
256 | + getViewColumns, | ||
257 | + setCacheColumnsByField, | ||
258 | + }; | ||
241 | } | 259 | } |
242 | 260 | ||
243 | function sortFixedColumn(columns: BasicColumn[]) { | 261 | function sortFixedColumn(columns: BasicColumn[]) { |
src/components/Table/src/hooks/useTableScroll.ts
@@ -127,11 +127,10 @@ export function useTableScroll( | @@ -127,11 +127,10 @@ export function useTableScroll( | ||
127 | width += 60; | 127 | width += 60; |
128 | } | 128 | } |
129 | 129 | ||
130 | - // TODO propsdth ?? 0; | 130 | + // TODO props ?? 0; |
131 | const NORMAL_WIDTH = 150; | 131 | const NORMAL_WIDTH = 150; |
132 | 132 | ||
133 | - const columns = unref(columnsRef); | ||
134 | - | 133 | + const columns = unref(columnsRef).filter((item) => !item.defaultHidden); |
135 | columns.forEach((item) => { | 134 | columns.forEach((item) => { |
136 | width += Number.parseInt(item.width as string) || 0; | 135 | width += Number.parseInt(item.width as string) || 0; |
137 | }); | 136 | }); |
@@ -150,7 +149,6 @@ export function useTableScroll( | @@ -150,7 +149,6 @@ export function useTableScroll( | ||
150 | const getScrollRef = computed(() => { | 149 | const getScrollRef = computed(() => { |
151 | const tableHeight = unref(tableHeightRef); | 150 | const tableHeight = unref(tableHeightRef); |
152 | const { canResize, scroll } = unref(propsRef); | 151 | const { canResize, scroll } = unref(propsRef); |
153 | - | ||
154 | return { | 152 | return { |
155 | x: unref(getScrollX), | 153 | x: unref(getScrollX), |
156 | y: canResize ? tableHeight : null, | 154 | y: canResize ? tableHeight : null, |
src/components/Table/src/types/table.ts
@@ -104,6 +104,7 @@ export interface TableActionType { | @@ -104,6 +104,7 @@ export interface TableActionType { | ||
104 | updateTableData: (index: number, key: string, value: any) => Recordable; | 104 | updateTableData: (index: number, key: string, value: any) => Recordable; |
105 | setShowPagination: (show: boolean) => Promise<void>; | 105 | setShowPagination: (show: boolean) => Promise<void>; |
106 | getShowPagination: () => boolean; | 106 | getShowPagination: () => boolean; |
107 | + setCacheColumnsByField?: (dataIndex: string | undefined, value: BasicColumn) => void; | ||
107 | } | 108 | } |
108 | 109 | ||
109 | export interface FetchSetting { | 110 | export interface FetchSetting { |
src/utils/http/axios/index.ts
@@ -108,10 +108,8 @@ const transform: AxiosTransform = { | @@ -108,10 +108,8 @@ const transform: AxiosTransform = { | ||
108 | const params = config.params || {}; | 108 | const params = config.params || {}; |
109 | if (config.method?.toUpperCase() === RequestEnum.GET) { | 109 | if (config.method?.toUpperCase() === RequestEnum.GET) { |
110 | if (!isString(params)) { | 110 | 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)); | ||
115 | } else { | 113 | } else { |
116 | // 兼容restful风格 | 114 | // 兼容restful风格 |
117 | config.url = config.url + params + `${createNow(joinTime, true)}`; | 115 | config.url = config.url + params + `${createNow(joinTime, true)}`; |
src/views/demo/table/CustomerCell.vue
@@ -35,6 +35,7 @@ | @@ -35,6 +35,7 @@ | ||
35 | dataIndex: 'category', | 35 | dataIndex: 'category', |
36 | width: 80, | 36 | width: 80, |
37 | align: 'center', | 37 | align: 'center', |
38 | + defaultHidden: true, | ||
38 | slots: { customRender: 'category' }, | 39 | slots: { customRender: 'category' }, |
39 | }, | 40 | }, |
40 | { | 41 | { |
@@ -74,6 +75,7 @@ | @@ -74,6 +75,7 @@ | ||
74 | api: demoListApi, | 75 | api: demoListApi, |
75 | columns: columns, | 76 | columns: columns, |
76 | bordered: true, | 77 | bordered: true, |
78 | + showTableSetting: true, | ||
77 | }); | 79 | }); |
78 | 80 | ||
79 | return { | 81 | return { |
yarn.lock
@@ -7887,10 +7887,10 @@ vue-i18n@^9.0.0-rc.1: | @@ -7887,10 +7887,10 @@ vue-i18n@^9.0.0-rc.1: | ||
7887 | "@intlify/shared" "9.0.0-rc.1" | 7887 | "@intlify/shared" "9.0.0-rc.1" |
7888 | "@vue/devtools-api" "^6.0.0-beta.3" | 7888 | "@vue/devtools-api" "^6.0.0-beta.3" |
7889 | 7889 | ||
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== | ||
7894 | 7894 | ||
7895 | vue-types@^3.0.0, vue-types@^3.0.1: | 7895 | vue-types@^3.0.0, vue-types@^3.0.1: |
7896 | version "3.0.1" | 7896 | version "3.0.1" |