Commit 54d14056462566521f2528480c13fb24279156ae
1 parent
de499a14
fix: fix table column settings not displayed by setting
Showing
3 changed files
with
17 additions
and
8 deletions
CHANGELOG.zh_CN.md
src/components/Table/src/components/TableSetting.vue
... | ... | @@ -77,7 +77,7 @@ |
77 | 77 | </div> |
78 | 78 | </template> |
79 | 79 | <script lang="ts"> |
80 | - import { defineComponent, ref, reactive, toRefs, PropType, computed } from 'vue'; | |
80 | + import { defineComponent, ref, reactive, toRefs, PropType, computed, watchEffect } from 'vue'; | |
81 | 81 | import { injectTable } from '../hooks/useProvinceTable'; |
82 | 82 | import { Tooltip, Divider, Dropdown, Menu, Popover, Checkbox } from 'ant-design-vue'; |
83 | 83 | import { |
... | ... | @@ -132,7 +132,7 @@ |
132 | 132 | const { toggleFullscreen, isFullscreenRef } = useFullscreen(table.wrapRef); |
133 | 133 | const selectedKeysRef = ref<SizeType[]>([table.getSize()]); |
134 | 134 | |
135 | - let plainOptions: Options[] = []; | |
135 | + const plainOptions = ref<Options[]>([]); | |
136 | 136 | const state = reactive<State>({ |
137 | 137 | indeterminate: false, |
138 | 138 | checkAll: true, |
... | ... | @@ -142,6 +142,12 @@ |
142 | 142 | |
143 | 143 | const { t } = useI18n('component.table'); |
144 | 144 | |
145 | + watchEffect(() => { | |
146 | + const columns = table.getColumns(); | |
147 | + if (columns.length) { | |
148 | + init(); | |
149 | + } | |
150 | + }); | |
145 | 151 | function init() { |
146 | 152 | let ret: Options[] = []; |
147 | 153 | table.getColumns({ ignoreIndex: true, ignoreAction: true }).forEach((item) => { |
... | ... | @@ -150,7 +156,8 @@ |
150 | 156 | value: (item.dataIndex || item.title) as string, |
151 | 157 | }); |
152 | 158 | }); |
153 | - plainOptions = ret; | |
159 | + | |
160 | + plainOptions.value = ret; | |
154 | 161 | const checkList = table |
155 | 162 | .getColumns() |
156 | 163 | .map((item) => item.dataIndex || item.title) as string[]; |
... | ... | @@ -171,7 +178,7 @@ |
171 | 178 | |
172 | 179 | function onCheckAllChange(e: ChangeEvent) { |
173 | 180 | state.indeterminate = false; |
174 | - const checkList = plainOptions.map((item) => item.value); | |
181 | + const checkList = plainOptions.value.map((item) => item.value); | |
175 | 182 | if (e.target.checked) { |
176 | 183 | state.checkedList = checkList; |
177 | 184 | table.setColumns(checkList); |
... | ... | @@ -182,8 +189,9 @@ |
182 | 189 | } |
183 | 190 | |
184 | 191 | function onChange(checkedList: string[]) { |
185 | - state.indeterminate = !!checkedList.length && checkedList.length < plainOptions.length; | |
186 | - state.checkAll = checkedList.length === plainOptions.length; | |
192 | + const len = plainOptions.value.length; | |
193 | + state.indeterminate = !!checkedList.length && checkedList.length < len; | |
194 | + state.checkAll = checkedList.length === len; | |
187 | 195 | table.setColumns(checkedList); |
188 | 196 | } |
189 | 197 | |
... | ... | @@ -207,7 +215,6 @@ |
207 | 215 | } |
208 | 216 | ); |
209 | 217 | |
210 | - init(); | |
211 | 218 | return { |
212 | 219 | redo: () => table.reload(), |
213 | 220 | handleTitleClick, | ... | ... |
vite.config.ts
... | ... | @@ -55,7 +55,7 @@ const viteConfig: UserConfig = { |
55 | 55 | * Available options are 'terser' or 'esbuild'. |
56 | 56 | * @default 'terser' |
57 | 57 | */ |
58 | - minify: isDevFn() ? 'esbuild' : 'terser', | |
58 | + minify: isDevFn() ? false : 'terser', | |
59 | 59 | /** |
60 | 60 | * Base public path when served in production. |
61 | 61 | * @default '/' | ... | ... |