Commit 3b3f6c903a5070ec225c9ec9ab20f16d1bdc3caa

Authored by nsk
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
src/components/Table/src/components/settings/ColumnSetting.vue
@@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
43 <CheckboxGroup v-model:value="checkedList" @change="onChange" ref="columnListRef"> 43 <CheckboxGroup v-model:value="checkedList" @change="onChange" ref="columnListRef">
44 <template v-for="item in plainOptions" :key="item.value"> 44 <template v-for="item in plainOptions" :key="item.value">
45 <div :class="`${prefixCls}__check-item`" v-if="!('ifShow' in item && !item.ifShow)"> 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 <Checkbox :value="item.value"> 47 <Checkbox :value="item.value">
48 {{ item.label }} 48 {{ item.label }}
49 </Checkbox> 49 </Checkbox>
@@ -120,7 +120,7 @@ @@ -120,7 +120,7 @@
120 import { useSortable } from '/@/hooks/web/useSortable'; 120 import { useSortable } from '/@/hooks/web/useSortable';
121 import { isFunction, isNullAndUnDef } from '/@/utils/is'; 121 import { isFunction, isNullAndUnDef } from '/@/utils/is';
122 import { getPopupContainer as getParentContainer } from '/@/utils'; 122 import { getPopupContainer as getParentContainer } from '/@/utils';
123 - import { omit } from 'lodash-es'; 123 + import { cloneDeep, omit } from 'lodash-es';
124 124
125 interface State { 125 interface State {
126 checkAll: boolean; 126 checkAll: boolean;
@@ -250,16 +250,15 @@ @@ -250,16 +250,15 @@
250 250
251 const indeterminate = computed(() => { 251 const indeterminate = computed(() => {
252 const len = plainOptions.value.length; 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 // Trigger when check/uncheck a column 258 // Trigger when check/uncheck a column
259 function onChange(checkedList: string[]) { 259 function onChange(checkedList: string[]) {
260 - const len = plainOptions.value.length; 260 + const len = plainSortOptions.value.length;
261 state.checkAll = checkedList.length === len; 261 state.checkAll = checkedList.length === len;
262 -  
263 const sortList = unref(plainSortOptions).map((item) => item.value); 262 const sortList = unref(plainSortOptions).map((item) => item.value);
264 checkedList.sort((prev, next) => { 263 checkedList.sort((prev, next) => {
265 return sortList.indexOf(prev) - sortList.indexOf(next); 264 return sortList.indexOf(prev) - sortList.indexOf(next);
@@ -286,14 +285,14 @@ @@ -286,14 +285,14 @@
286 if (!el) return; 285 if (!el) return;
287 // Drag and drop sort 286 // Drag and drop sort
288 const { initSortable } = useSortable(el, { 287 const { initSortable } = useSortable(el, {
289 - handle: '.table-coulmn-drag-icon ', 288 + handle: '.table-column-drag-icon',
290 onEnd: (evt) => { 289 onEnd: (evt) => {
291 const { oldIndex, newIndex } = evt; 290 const { oldIndex, newIndex } = evt;
292 if (isNullAndUnDef(oldIndex) || isNullAndUnDef(newIndex) || oldIndex === newIndex) { 291 if (isNullAndUnDef(oldIndex) || isNullAndUnDef(newIndex) || oldIndex === newIndex) {
293 return; 292 return;
294 } 293 }
295 // Sort column 294 // Sort column
296 - const columns = getColumns(); 295 + const columns = cloneDeep(plainSortOptions.value);
297 296
298 if (oldIndex > newIndex) { 297 if (oldIndex > newIndex) {
299 columns.splice(newIndex, 0, columns[oldIndex]); 298 columns.splice(newIndex, 0, columns[oldIndex]);
@@ -304,7 +303,6 @@ @@ -304,7 +303,6 @@
304 } 303 }
305 304
306 plainSortOptions.value = columns; 305 plainSortOptions.value = columns;
307 - plainOptions.value = columns;  
308 setColumns(columns); 306 setColumns(columns);
309 }, 307 },
310 }); 308 });
@@ -347,7 +345,7 @@ @@ -347,7 +345,7 @@
347 345
348 function setColumns(columns: BasicColumn[] | string[]) { 346 function setColumns(columns: BasicColumn[] | string[]) {
349 table.setColumns(columns); 347 table.setColumns(columns);
350 - const data: ColumnChangeParam[] = unref(plainOptions).map((col) => { 348 + const data: ColumnChangeParam[] = unref(plainSortOptions).map((col) => {
351 const visible = 349 const visible =
352 columns.findIndex( 350 columns.findIndex(
353 (c: BasicColumn | string) => 351 (c: BasicColumn | string) =>
@@ -390,7 +388,7 @@ @@ -390,7 +388,7 @@
390 <style lang="less"> 388 <style lang="less">
391 @prefix-cls: ~'@{namespace}-basic-column-setting'; 389 @prefix-cls: ~'@{namespace}-basic-column-setting';
392 390
393 - .table-coulmn-drag-icon { 391 + .table-column-drag-icon {
394 margin: 0 5px; 392 margin: 0 5px;
395 cursor: move; 393 cursor: move;
396 } 394 }
src/components/Table/src/hooks/useColumns.ts
@@ -216,25 +216,17 @@ export function useColumns( @@ -216,25 +216,17 @@ export function useColumns(
216 const columnKeys = columns as string[]; 216 const columnKeys = columns as string[];
217 const newColumns: BasicColumn[] = []; 217 const newColumns: BasicColumn[] = [];
218 cacheColumns.forEach((item) => { 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 // Sort according to another array 224 // Sort according to another array
233 if (!isEqual(cacheKeys, columns)) { 225 if (!isEqual(cacheKeys, columns)) {
234 newColumns.sort((prev, next) => { 226 newColumns.sort((prev, next) => {
235 return ( 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,7 +54,7 @@
54 import { basicProps } from './props'; 54 import { basicProps } from './props';
55 import { createTableColumns, createActionColumn } from './data'; 55 import { createTableColumns, createActionColumn } from './data';
56 // utils 56 // utils
57 - import { checkFileType, checkImgType, getBase64WithFile } from './helper'; 57 + import { checkImgType, getBase64WithFile } from './helper';
58 import { buildUUID } from '/@/utils/uuid'; 58 import { buildUUID } from '/@/utils/uuid';
59 import { isFunction } from '/@/utils/is'; 59 import { isFunction } from '/@/utils/is';
60 import { warn } from '/@/utils/log'; 60 import { warn } from '/@/utils/log';
@@ -84,7 +84,7 @@ @@ -84,7 +84,7 @@
84 const { t } = useI18n(); 84 const { t } = useI18n();
85 const [register, { closeModal }] = useModalInner(); 85 const [register, { closeModal }] = useModalInner();
86 86
87 - const { getAccept, getStringAccept, getHelpText } = useUploadType({ 87 + const { getStringAccept, getHelpText } = useUploadType({
88 acceptRef: accept, 88 acceptRef: accept,
89 helpTextRef: helpText, 89 helpTextRef: helpText,
90 maxNumberRef: maxNumber, 90 maxNumberRef: maxNumber,
@@ -124,18 +124,12 @@ @@ -124,18 +124,12 @@
124 function beforeUpload(file: File) { 124 function beforeUpload(file: File) {
125 const { size, name } = file; 125 const { size, name } = file;
126 const { maxSize } = props; 126 const { maxSize } = props;
127 - const accept = unref(getAccept);  
128 // 设置最大值,则判断 127 // 设置最大值,则判断
129 if (maxSize && file.size / 1024 / 1024 >= maxSize) { 128 if (maxSize && file.size / 1024 / 1024 >= maxSize) {
130 createMessage.error(t('component.upload.maxSizeMultiple', [maxSize])); 129 createMessage.error(t('component.upload.maxSizeMultiple', [maxSize]));
131 return false; 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 const commonItem = { 133 const commonItem = {
140 uuid: buildUUID(), 134 uuid: buildUUID(),
141 file, 135 file,