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 | 7 | - `ant-design-vue`组件注册移动到`components/registerComponent` |
8 | 8 | - 移除 `setup` 文件夹 |
9 | 9 | - 升级到`vite2` |
10 | +- 图片预览改为`Image`组件实现,暂时移除函数式使用方式 | |
10 | 11 | |
11 | 12 | ### ✨ Features |
12 | 13 | |
... | ... | @@ -16,7 +17,7 @@ |
16 | 17 | - 新增`PageWrapper`组件。并应用于示例页面 |
17 | 18 | - 新增标签页折叠功能 |
18 | 19 | - 兼容旧版浏览器 |
19 | -- tinymce 新增图片上传· | |
20 | +- tinymce 新增图片上传 | |
20 | 21 | |
21 | 22 | ### 🐛 Bug Fixes |
22 | 23 | ... | ... |
package.json
src/components/Table/src/BasicTable.vue
... | ... | @@ -143,10 +143,14 @@ |
143 | 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 | 155 | const { getScrollRef, redoHeight } = useTableScroll( |
152 | 156 | getProps, |
... | ... | @@ -238,6 +242,7 @@ |
238 | 242 | updateTableData, |
239 | 243 | setShowPagination, |
240 | 244 | getShowPagination, |
245 | + setCacheColumnsByField, | |
241 | 246 | getSize: () => { |
242 | 247 | return unref(getBindValues).size as SizeType; |
243 | 248 | }, | ... | ... |
src/components/Table/src/components/settings/ColumnSetting.vue
src/components/Table/src/hooks/useColumns.ts
... | ... | @@ -173,6 +173,17 @@ export function useColumns( |
173 | 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 | 188 | * set columns |
178 | 189 | * @param columnList key|column |
... | ... | @@ -237,7 +248,14 @@ export function useColumns( |
237 | 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 | 261 | function sortFixedColumn(columns: BasicColumn[]) { | ... | ... |
src/components/Table/src/hooks/useTableScroll.ts
... | ... | @@ -127,11 +127,10 @@ export function useTableScroll( |
127 | 127 | width += 60; |
128 | 128 | } |
129 | 129 | |
130 | - // TODO propsdth ?? 0; | |
130 | + // TODO props ?? 0; | |
131 | 131 | const NORMAL_WIDTH = 150; |
132 | 132 | |
133 | - const columns = unref(columnsRef); | |
134 | - | |
133 | + const columns = unref(columnsRef).filter((item) => !item.defaultHidden); | |
135 | 134 | columns.forEach((item) => { |
136 | 135 | width += Number.parseInt(item.width as string) || 0; |
137 | 136 | }); |
... | ... | @@ -150,7 +149,6 @@ export function useTableScroll( |
150 | 149 | const getScrollRef = computed(() => { |
151 | 150 | const tableHeight = unref(tableHeightRef); |
152 | 151 | const { canResize, scroll } = unref(propsRef); |
153 | - | |
154 | 152 | return { |
155 | 153 | x: unref(getScrollX), |
156 | 154 | y: canResize ? tableHeight : null, | ... | ... |
src/components/Table/src/types/table.ts
... | ... | @@ -104,6 +104,7 @@ export interface TableActionType { |
104 | 104 | updateTableData: (index: number, key: string, value: any) => Recordable; |
105 | 105 | setShowPagination: (show: boolean) => Promise<void>; |
106 | 106 | getShowPagination: () => boolean; |
107 | + setCacheColumnsByField?: (dataIndex: string | undefined, value: BasicColumn) => void; | |
107 | 108 | } |
108 | 109 | |
109 | 110 | export interface FetchSetting { | ... | ... |
src/utils/http/axios/index.ts
... | ... | @@ -108,10 +108,8 @@ const transform: AxiosTransform = { |
108 | 108 | const params = config.params || {}; |
109 | 109 | if (config.method?.toUpperCase() === RequestEnum.GET) { |
110 | 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 | 113 | } else { |
116 | 114 | // 兼容restful风格 |
117 | 115 | config.url = config.url + params + `${createNow(joinTime, true)}`; | ... | ... |
src/views/demo/table/CustomerCell.vue
... | ... | @@ -35,6 +35,7 @@ |
35 | 35 | dataIndex: 'category', |
36 | 36 | width: 80, |
37 | 37 | align: 'center', |
38 | + defaultHidden: true, | |
38 | 39 | slots: { customRender: 'category' }, |
39 | 40 | }, |
40 | 41 | { |
... | ... | @@ -74,6 +75,7 @@ |
74 | 75 | api: demoListApi, |
75 | 76 | columns: columns, |
76 | 77 | bordered: true, |
78 | + showTableSetting: true, | |
77 | 79 | }); |
78 | 80 | |
79 | 81 | return { | ... | ... |
yarn.lock
... | ... | @@ -7887,10 +7887,10 @@ vue-i18n@^9.0.0-rc.1: |
7887 | 7887 | "@intlify/shared" "9.0.0-rc.1" |
7888 | 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 | 7895 | vue-types@^3.0.0, vue-types@^3.0.1: |
7896 | 7896 | version "3.0.1" | ... | ... |