Commit 3b3f6c903a5070ec225c9ec9ab20f16d1bdc3caa
Committed by
GitHub
1 parent
b3c4002b
fix: some mistakes close #1349, close #1250 close#1245 (#1373)
* fix(Loading): add theme prop, The repair background prop does not take effect * fix(AppLogo): fix title line height * fix(Table,Upload): fix #1349 #1250 #1245
Showing
3 changed files
with
18 additions
and
34 deletions
src/components/Table/src/components/settings/ColumnSetting.vue
... | ... | @@ -43,7 +43,7 @@ |
43 | 43 | <CheckboxGroup v-model:value="checkedList" @change="onChange" ref="columnListRef"> |
44 | 44 | <template v-for="item in plainOptions" :key="item.value"> |
45 | 45 | <div :class="`${prefixCls}__check-item`" v-if="!('ifShow' in item && !item.ifShow)"> |
46 | - <DragOutlined class="table-coulmn-drag-icon" /> | |
46 | + <DragOutlined class="table-column-drag-icon" /> | |
47 | 47 | <Checkbox :value="item.value"> |
48 | 48 | {{ item.label }} |
49 | 49 | </Checkbox> |
... | ... | @@ -120,7 +120,7 @@ |
120 | 120 | import { useSortable } from '/@/hooks/web/useSortable'; |
121 | 121 | import { isFunction, isNullAndUnDef } from '/@/utils/is'; |
122 | 122 | import { getPopupContainer as getParentContainer } from '/@/utils'; |
123 | - import { omit } from 'lodash-es'; | |
123 | + import { cloneDeep, omit } from 'lodash-es'; | |
124 | 124 | |
125 | 125 | interface State { |
126 | 126 | checkAll: boolean; |
... | ... | @@ -250,16 +250,15 @@ |
250 | 250 | |
251 | 251 | const indeterminate = computed(() => { |
252 | 252 | const len = plainOptions.value.length; |
253 | - let checkdedLen = state.checkedList.length; | |
254 | - unref(checkIndex) && checkdedLen--; | |
255 | - return checkdedLen > 0 && checkdedLen < len; | |
253 | + let checkedLen = state.checkedList.length; | |
254 | + unref(checkIndex) && checkedLen--; | |
255 | + return checkedLen > 0 && checkedLen < len; | |
256 | 256 | }); |
257 | 257 | |
258 | 258 | // Trigger when check/uncheck a column |
259 | 259 | function onChange(checkedList: string[]) { |
260 | - const len = plainOptions.value.length; | |
260 | + const len = plainSortOptions.value.length; | |
261 | 261 | state.checkAll = checkedList.length === len; |
262 | - | |
263 | 262 | const sortList = unref(plainSortOptions).map((item) => item.value); |
264 | 263 | checkedList.sort((prev, next) => { |
265 | 264 | return sortList.indexOf(prev) - sortList.indexOf(next); |
... | ... | @@ -286,14 +285,14 @@ |
286 | 285 | if (!el) return; |
287 | 286 | // Drag and drop sort |
288 | 287 | const { initSortable } = useSortable(el, { |
289 | - handle: '.table-coulmn-drag-icon ', | |
288 | + handle: '.table-column-drag-icon', | |
290 | 289 | onEnd: (evt) => { |
291 | 290 | const { oldIndex, newIndex } = evt; |
292 | 291 | if (isNullAndUnDef(oldIndex) || isNullAndUnDef(newIndex) || oldIndex === newIndex) { |
293 | 292 | return; |
294 | 293 | } |
295 | 294 | // Sort column |
296 | - const columns = getColumns(); | |
295 | + const columns = cloneDeep(plainSortOptions.value); | |
297 | 296 | |
298 | 297 | if (oldIndex > newIndex) { |
299 | 298 | columns.splice(newIndex, 0, columns[oldIndex]); |
... | ... | @@ -304,7 +303,6 @@ |
304 | 303 | } |
305 | 304 | |
306 | 305 | plainSortOptions.value = columns; |
307 | - plainOptions.value = columns; | |
308 | 306 | setColumns(columns); |
309 | 307 | }, |
310 | 308 | }); |
... | ... | @@ -347,7 +345,7 @@ |
347 | 345 | |
348 | 346 | function setColumns(columns: BasicColumn[] | string[]) { |
349 | 347 | table.setColumns(columns); |
350 | - const data: ColumnChangeParam[] = unref(plainOptions).map((col) => { | |
348 | + const data: ColumnChangeParam[] = unref(plainSortOptions).map((col) => { | |
351 | 349 | const visible = |
352 | 350 | columns.findIndex( |
353 | 351 | (c: BasicColumn | string) => |
... | ... | @@ -390,7 +388,7 @@ |
390 | 388 | <style lang="less"> |
391 | 389 | @prefix-cls: ~'@{namespace}-basic-column-setting'; |
392 | 390 | |
393 | - .table-coulmn-drag-icon { | |
391 | + .table-column-drag-icon { | |
394 | 392 | margin: 0 5px; |
395 | 393 | cursor: move; |
396 | 394 | } | ... | ... |
src/components/Table/src/hooks/useColumns.ts
... | ... | @@ -216,25 +216,17 @@ export function useColumns( |
216 | 216 | const columnKeys = columns as string[]; |
217 | 217 | const newColumns: BasicColumn[] = []; |
218 | 218 | cacheColumns.forEach((item) => { |
219 | - if (columnKeys.includes(item.dataIndex! || (item.key as string))) { | |
220 | - newColumns.push({ | |
221 | - ...item, | |
222 | - defaultHidden: false, | |
223 | - }); | |
224 | - } else { | |
225 | - newColumns.push({ | |
226 | - ...item, | |
227 | - defaultHidden: true, | |
228 | - }); | |
229 | - } | |
219 | + newColumns.push({ | |
220 | + ...item, | |
221 | + defaultHidden: !columnKeys.includes(item.dataIndex! || (item.key as string)), | |
222 | + }); | |
230 | 223 | }); |
231 | - | |
232 | 224 | // Sort according to another array |
233 | 225 | if (!isEqual(cacheKeys, columns)) { |
234 | 226 | newColumns.sort((prev, next) => { |
235 | 227 | return ( |
236 | - cacheKeys.indexOf(prev.dataIndex as string) - | |
237 | - cacheKeys.indexOf(next.dataIndex as string) | |
228 | + columnKeys.indexOf(prev.dataIndex as string) - | |
229 | + columnKeys.indexOf(next.dataIndex as string) | |
238 | 230 | ); |
239 | 231 | }); |
240 | 232 | } | ... | ... |
src/components/Upload/src/UploadModal.vue
... | ... | @@ -54,7 +54,7 @@ |
54 | 54 | import { basicProps } from './props'; |
55 | 55 | import { createTableColumns, createActionColumn } from './data'; |
56 | 56 | // utils |
57 | - import { checkFileType, checkImgType, getBase64WithFile } from './helper'; | |
57 | + import { checkImgType, getBase64WithFile } from './helper'; | |
58 | 58 | import { buildUUID } from '/@/utils/uuid'; |
59 | 59 | import { isFunction } from '/@/utils/is'; |
60 | 60 | import { warn } from '/@/utils/log'; |
... | ... | @@ -84,7 +84,7 @@ |
84 | 84 | const { t } = useI18n(); |
85 | 85 | const [register, { closeModal }] = useModalInner(); |
86 | 86 | |
87 | - const { getAccept, getStringAccept, getHelpText } = useUploadType({ | |
87 | + const { getStringAccept, getHelpText } = useUploadType({ | |
88 | 88 | acceptRef: accept, |
89 | 89 | helpTextRef: helpText, |
90 | 90 | maxNumberRef: maxNumber, |
... | ... | @@ -124,18 +124,12 @@ |
124 | 124 | function beforeUpload(file: File) { |
125 | 125 | const { size, name } = file; |
126 | 126 | const { maxSize } = props; |
127 | - const accept = unref(getAccept); | |
128 | 127 | // 设置最大值,则判断 |
129 | 128 | if (maxSize && file.size / 1024 / 1024 >= maxSize) { |
130 | 129 | createMessage.error(t('component.upload.maxSizeMultiple', [maxSize])); |
131 | 130 | return false; |
132 | 131 | } |
133 | 132 | |
134 | - // 设置类型,则判断 | |
135 | - if (accept.length > 0 && !checkFileType(file, accept)) { | |
136 | - createMessage.error!(t('component.upload.acceptUpload', [accept.join(',')])); | |
137 | - return false; | |
138 | - } | |
139 | 133 | const commonItem = { |
140 | 134 | uuid: buildUUID(), |
141 | 135 | file, | ... | ... |