Skip to content

Commit 44b6a0d

Browse files
cipchk执衡
authored andcommitted
feat(module:upload): add nz-upload component
1 parent ff34784 commit 44b6a0d

29 files changed

Lines changed: 2278 additions & 1 deletion

src/components/locale/locales/en-US.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,12 @@ export const enUS: NzLocale = {
6161
searchPlaceholder: 'Search here',
6262
itemUnit: 'item',
6363
itemsUnit: 'items',
64+
},
65+
66+
Upload: {
67+
uploading: 'Uploading...',
68+
removeFile: 'Remove',
69+
uploadError: 'Error',
70+
previewFile: 'Preview',
6471
}
6572
};

src/components/locale/locales/ru-RU.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,12 @@ export const ruRU: NzLocale = {
6161
searchPlaceholder: 'Поиск',
6262
itemUnit: 'элемент',
6363
itemsUnit: 'элементов',
64+
},
65+
66+
Upload: {
67+
uploading: 'Закачиваю...',
68+
removeFile: 'Удалить файл',
69+
uploadError: 'Ошибка при закачке',
70+
previewFile: 'Предпросмотр файла',
6471
}
6572
};

src/components/locale/locales/tr-TR.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,12 @@ export const trTR: NzLocale = {
6161
searchPlaceholder: 'Burada ara',
6262
itemUnit: 'öğe',
6363
itemsUnit: 'öğeler',
64+
},
65+
66+
Upload: {
67+
uploading: 'Yükleniyor...',
68+
removeFile: `Dosyayı kaldır`,
69+
uploadError: 'Yükleme Hatası',
70+
previewFile: `Dosyayı Önizle`,
6471
}
6572
};

src/components/locale/locales/zh-CN.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,12 @@ export const zhCN: NzLocale = {
6161
searchPlaceholder: '请输入',
6262
itemUnit: '项目',
6363
itemsUnit: '项目',
64+
},
65+
66+
Upload: {
67+
uploading: '文件上传中',
68+
removeFile: '删除文件',
69+
uploadError: '上传错误',
70+
previewFile: '预览文件',
6471
}
6572
};

src/components/locale/locales/zh-TW.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,12 @@ export const zhTW: NzLocale = {
6161
searchPlaceholder: '搜尋資料',
6262
itemUnit: '項目',
6363
itemsUnit: '項目',
64+
},
65+
66+
Upload: {
67+
uploading: '正在上傳...',
68+
removeFile: '刪除檔案',
69+
uploadError: '上傳失敗',
70+
previewFile: '檔案預覽',
6471
}
6572
};

src/components/locale/nz-locale.class.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,11 @@ export class NzLocale {
6161
itemUnit: string,
6262
itemsUnit: string,
6363
};
64+
65+
Upload: {
66+
uploading: string,
67+
removeFile: string,
68+
uploadError: string,
69+
previewFile: string,
70+
};
6471
}

src/components/ng-zorro-antd.module.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import { NzTimePickerModule } from './time-picker/nz-timepicker.module';
5252
import { NzTimelineModule } from './timeline/nz-timeline.module';
5353
import { NzToolTipModule } from './tooltip/nz-tooltip.module';
5454
import { NzTransferModule } from './transfer/nz-transfer.module';
55+
import { NzUploadModule } from './upload/nz-upload.module';
5556
import { LoggerModule } from './util/logger/index';
5657
import { NzUtilModule } from './util/nz-util.module';
5758

@@ -120,6 +121,7 @@ export { NzAffixModule } from './affix/nz-affix.module';
120121
export { NzAnchorModule } from './anchor/nz-anchor.module';
121122
export { NzAvatarModule } from './avatar/nz-avatar.module';
122123
export { NzTransferModule } from './transfer/nz-transfer.module';
124+
export { NzUploadModule } from './upload/nz-upload.module';
123125

124126
// Components
125127
export { NzRowComponent } from './grid/nz-row.component';
@@ -226,6 +228,8 @@ export { NzAnchorLinkComponent } from './anchor/nz-anchor-link.component';
226228
export { NzAnchorComponent } from './anchor/nz-anchor.component';
227229
export { NzAvatarComponent } from './avatar/nz-avatar.component';
228230
export { NzTransferComponent } from './transfer/nz-transfer.component';
231+
export { NzUploadComponent } from './upload/nz-upload.component';
232+
export * from './upload/interface';
229233

230234
// Services
231235
export { NzNotificationService } from './notification/nz-notification.service';
@@ -291,7 +295,8 @@ export { NZ_ROOT_CONFIG, NzRootConfig } from './root/nz-root-config';
291295
NzAffixModule,
292296
NzAnchorModule,
293297
NzAvatarModule,
294-
NzTransferModule
298+
NzTransferModule,
299+
NzUploadModule
295300
]
296301
})
297302
export class NgZorroAntdModule {

src/components/upload/interface.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// tslint:disable:prefer-method-signature
2+
import { Observable } from 'rxjs/Observable';
3+
import { Subscription } from 'rxjs/Subscription';
4+
5+
// tslint:disable:no-any
6+
/** 状态 */
7+
export type UploadFileStatus = 'error' | 'success' | 'done' | 'uploading' | 'removed';
8+
9+
/** 上传方式 */
10+
export type UploadType = 'select' | 'drag';
11+
12+
/** 上传列表的内建样式 */
13+
export type UploadListType = 'text' | 'picture' | 'picture-card';
14+
15+
/** 文件对象 */
16+
export interface UploadFile {
17+
uid: string;
18+
size: number;
19+
name: string;
20+
filename?: string;
21+
lastModified?: string;
22+
lastModifiedDate?: Date;
23+
url?: string;
24+
status?: UploadFileStatus;
25+
originFileObj?: File;
26+
percent?: number;
27+
thumbUrl?: string;
28+
response?: any;
29+
error?: any;
30+
linkProps?: any;
31+
type: string;
32+
[key: string]: any;
33+
}
34+
35+
export interface UploadChangeParam {
36+
file: UploadFile;
37+
fileList: UploadFile[];
38+
event?: { percent: number };
39+
}
40+
41+
export interface ShowUploadListInterface {
42+
showRemoveIcon?: boolean;
43+
showPreviewIcon?: boolean;
44+
}
45+
46+
export interface ZipButtonOptions {
47+
disabled?: boolean;
48+
accept?: string;
49+
action?: string;
50+
beforeUpload?: (file: UploadFile, fileList: UploadFile[]) => boolean | Observable<any>;
51+
customRequest?: (item: any) => Subscription;
52+
data?: {} | ((file: UploadFile) => {});
53+
headers?: {};
54+
name?: string;
55+
multiple?: boolean;
56+
withCredentials?: boolean;
57+
filters?: UploadFilter[];
58+
onStart?: (file: UploadFile) => void;
59+
onProgress?: (e: any, file: UploadFile) => void;
60+
onSuccess?: (ret: any, file: UploadFile, xhr: any) => void;
61+
onError?: (err: any, file: UploadFile) => void;
62+
}
63+
64+
export interface UploadFilter {
65+
name: string;
66+
fn: (fileList: UploadFile[]) => UploadFile[];
67+
}

0 commit comments

Comments
 (0)