zartui 2.0.79 → 2.0.80-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/action-sheet/index.js +15 -26
- package/es/area/index.js +5 -41
- package/es/avatar/index.js +3 -16
- package/es/back-top/index.js +4 -19
- package/es/badge/index.js +4 -12
- package/es/button/index.js +20 -40
- package/es/calendar/components/Header.js +3 -12
- package/es/calendar/components/Month.js +12 -65
- package/es/calendar/index.js +23 -94
- package/es/calendar/types.js +0 -6
- package/es/calendar/utils.js +5 -16
- package/es/cascader/index.js +4 -37
- package/es/cell/index.js +19 -37
- package/es/cell-group/index.js +5 -8
- package/es/checkbox/index.js +4 -11
- package/es/checkbox-group/index.js +4 -9
- package/es/col/index.js +6 -11
- package/es/collapse/index.js +2 -5
- package/es/collapse-item/index.js +19 -35
- package/es/count-down/index.js +2 -15
- package/es/count-down/utils.js +3 -10
- package/es/datetime-picker/DatePicker.js +12 -70
- package/es/datetime-picker/TimePicker.js +10 -23
- package/es/datetime-picker/index.js +2 -4
- package/es/datetime-picker/shared.js +5 -19
- package/es/datetime-picker/utils.js +0 -5
- package/es/dialog/Dialog.js +6 -21
- package/es/dialog/index.js +0 -16
- package/es/divider/index.js +5 -6
- package/es/dropdown-item/index.js +22 -35
- package/es/dropdown-menu/index.js +4 -9
- package/es/empty/index.js +3 -11
- package/es/field/index.js +20 -83
- package/es/fold-dialog/index.js +5 -20
- package/es/form/index.js +2 -18
- package/es/grid/index.js +2 -6
- package/es/grid-item/index.js +17 -30
- package/es/hierarchy-select/breadcrumb.js +2 -6
- package/es/hierarchy-select/index.js +3 -12
- package/es/hierarchy-select/markList.js +2 -25
- package/es/hierarchy-select/svg/SubIcon.js +0 -1
- package/es/icon/index.js +9 -13
- package/es/image/index.js +2 -17
- package/es/image-preview/ImagePreview.js +4 -8
- package/es/image-preview/ImagePreviewItem.js +14 -30
- package/es/image-preview/index.js +0 -12
- package/es/image-preview/shared.js +2 -4
- package/es/index-anchor/index.js +2 -6
- package/es/index-bar/IndexIndicate.js +0 -1
- package/es/index-bar/index.js +7 -28
- package/es/index.js +1 -4
- package/es/info/index.js +6 -8
- package/es/list/index.js +11 -27
- package/es/loading/index.js +7 -15
- package/es/locale/index.js +0 -2
- package/es/media-picker/index.js +33 -117
- package/es/media-picker/media-util.js +2 -5
- package/es/media-picker/type.js +0 -5
- package/es/media-player/index.js +7 -17
- package/es/mixins/bind-event.js +0 -3
- package/es/mixins/checkbox.js +5 -11
- package/es/mixins/click-outside.js +0 -2
- package/es/mixins/close-on-popstate.js +0 -1
- package/es/mixins/field.js +0 -2
- package/es/mixins/popup/index.js +12 -28
- package/es/mixins/popup/overlay.js +1 -11
- package/es/mixins/portal.js +2 -8
- package/es/mixins/relation.js +0 -8
- package/es/mixins/slots.js +1 -4
- package/es/mixins/touch.js +4 -9
- package/es/multiple-picker/MultiplePickerOptions.js +2 -18
- package/es/multiple-picker/index.js +5 -17
- package/es/nav-bar/index.js +4 -12
- package/es/notice-bar/index.js +10 -28
- package/es/number-keyboard/Key.js +2 -10
- package/es/number-keyboard/index.js +4 -19
- package/es/overlay/index.js +5 -8
- package/es/password-input/index.js +10 -16
- package/es/picker/PickerColumn.js +20 -54
- package/es/picker/index.js +13 -42
- package/es/popover/index.js +11 -20
- package/es/popup/index.js +5 -21
- package/es/pull-refresh/index.js +15 -32
- package/es/radio/index.js +2 -4
- package/es/radio-group/index.js +2 -4
- package/es/rate/index.js +12 -26
- package/es/row/index.js +3 -9
- package/es/search/index.js +8 -13
- package/es/signature/bezier.js +5 -12
- package/es/signature/force-landscape.js +0 -5
- package/es/signature/index.js +5 -24
- package/es/signature/point.js +1 -6
- package/es/signature/throttle.js +1 -10
- package/es/skeleton/index.js +5 -15
- package/es/slider/index.js +19 -55
- package/es/step/index.js +5 -12
- package/es/stepper/index.js +10 -37
- package/es/steps/index.js +2 -4
- package/es/sticky/index.js +8 -50
- package/es/swipe/index.js +19 -62
- package/es/swipe-cell/index.js +7 -23
- package/es/swipe-item/index.js +9 -19
- package/es/switch/index.js +8 -10
- package/es/switch/shared.js +1 -0
- package/es/switch-cell/index.js +7 -7
- package/es/tab/index.js +4 -15
- package/es/tabbar/index.js +4 -14
- package/es/tabbar-item/index.js +7 -15
- package/es/table/index.js +10 -35
- package/es/tabs/Content.js +5 -9
- package/es/tabs/Title.js +11 -19
- package/es/tabs/index.js +16 -51
- package/es/tabs/utils.js +0 -8
- package/es/tag/index.js +13 -17
- package/es/timeline/index.js +2 -25
- package/es/toast/Toast.js +11 -23
- package/es/toast/index.js +6 -33
- package/es/toast/lock-click.js +0 -2
- package/es/uploader/index.js +11 -62
- package/es/uploader/utils.js +0 -10
- package/es/utils/constant.js +2 -1
- package/es/utils/create/bem.js +1 -5
- package/es/utils/create/component.js +4 -7
- package/es/utils/create/i18n.js +0 -2
- package/es/utils/deep-assign.js +0 -4
- package/es/utils/deep-clone.js +0 -3
- package/es/utils/dom/event.js +2 -5
- package/es/utils/dom/node.js +0 -1
- package/es/utils/dom/raf.js +7 -6
- package/es/utils/dom/reset-scroll.js +2 -1
- package/es/utils/dom/scroll.js +8 -17
- package/es/utils/dom/style.js +3 -2
- package/es/utils/easings.js +2 -4
- package/es/utils/format/date-util.js +54 -122
- package/es/utils/format/number.js +2 -11
- package/es/utils/format/string.js +0 -3
- package/es/utils/format/unit.js +2 -12
- package/es/utils/functional.js +6 -9
- package/es/utils/getScroll.js +0 -5
- package/es/utils/index.js +3 -5
- package/es/utils/interceptor.js +2 -4
- package/es/utils/media/image-util.js +7 -19
- package/es/utils/raf.js +4 -12
- package/es/utils/router.js +7 -6
- package/es/utils/scrollTo.js +7 -12
- package/es/utils/validate/number.js +2 -2
- package/es/utils/vnodes.js +2 -8
- package/lib/action-sheet/index.js +11 -35
- package/lib/area/index.js +5 -45
- package/lib/avatar/index.js +3 -18
- package/lib/back-top/index.js +4 -25
- package/lib/badge/index.js +4 -15
- package/lib/button/index.js +19 -50
- package/lib/calendar/components/Header.js +3 -18
- package/lib/calendar/components/Month.js +12 -71
- package/lib/calendar/index.js +21 -106
- package/lib/calendar/types.js +0 -7
- package/lib/calendar/utils.js +5 -32
- package/lib/cascader/index.js +4 -46
- package/lib/cell/index.js +18 -48
- package/lib/cell-group/index.js +5 -15
- package/lib/checkbox/index.js +4 -14
- package/lib/checkbox-group/index.js +4 -13
- package/lib/col/index.js +6 -14
- package/lib/collapse/index.js +2 -8
- package/lib/collapse-item/index.js +18 -43
- package/lib/count-down/index.js +2 -19
- package/lib/count-down/utils.js +3 -15
- package/lib/datetime-picker/DatePicker.js +12 -81
- package/lib/datetime-picker/TimePicker.js +10 -30
- package/lib/datetime-picker/index.js +2 -10
- package/lib/datetime-picker/shared.js +5 -27
- package/lib/datetime-picker/utils.js +0 -9
- package/lib/dialog/Dialog.js +6 -28
- package/lib/dialog/index.js +0 -22
- package/lib/divider/index.js +5 -12
- package/lib/dropdown-item/index.js +21 -44
- package/lib/dropdown-menu/index.js +4 -15
- package/lib/empty/index.js +3 -23
- package/lib/field/index.js +20 -96
- package/lib/fold-dialog/index.js +5 -22
- package/lib/form/index.js +2 -21
- package/lib/grid/index.js +2 -10
- package/lib/grid-item/index.js +16 -37
- package/lib/hierarchy-select/breadcrumb.js +3 -10
- package/lib/hierarchy-select/index.js +4 -20
- package/lib/hierarchy-select/markList.js +3 -31
- package/lib/hierarchy-select/svg/SubIcon.js +0 -1
- package/lib/icon/index.js +8 -19
- package/lib/image/index.js +2 -22
- package/lib/image-preview/ImagePreview.js +0 -16
- package/lib/image-preview/ImagePreviewItem.js +13 -36
- package/lib/image-preview/index.js +0 -16
- package/lib/image-preview/shared.js +2 -5
- package/lib/index-anchor/index.js +2 -11
- package/lib/index-bar/IndexIndicate.js +0 -1
- package/lib/index-bar/index.js +7 -37
- package/lib/index.js +1 -157
- package/lib/info/index.js +6 -14
- package/lib/lazyload/index.js +0 -3
- package/lib/list/index.js +10 -33
- package/lib/loading/index.js +7 -21
- package/lib/locale/index.js +0 -7
- package/lib/media-picker/index.js +27 -153
- package/lib/media-picker/media-util.js +2 -15
- package/lib/media-picker/type.js +0 -5
- package/lib/media-player/index.js +6 -22
- package/lib/mixins/bind-event.js +1 -6
- package/lib/mixins/checkbox.js +6 -18
- package/lib/mixins/click-outside.js +1 -5
- package/lib/mixins/close-on-popstate.js +0 -4
- package/lib/mixins/field.js +0 -2
- package/lib/mixins/popup/index.js +11 -36
- package/lib/mixins/popup/overlay.js +1 -23
- package/lib/mixins/portal.js +2 -9
- package/lib/mixins/relation.js +0 -11
- package/lib/mixins/slots.js +1 -5
- package/lib/mixins/touch.js +4 -11
- package/lib/multiple-picker/MultiplePickerOptions.js +2 -23
- package/lib/multiple-picker/index.js +5 -26
- package/lib/nav-bar/index.js +4 -16
- package/lib/notice-bar/index.js +10 -40
- package/lib/number-keyboard/Key.js +2 -17
- package/lib/number-keyboard/index.js +4 -26
- package/lib/overlay/index.js +5 -16
- package/lib/password-input/index.js +10 -23
- package/lib/picker/PickerColumn.js +19 -63
- package/lib/picker/index.js +13 -53
- package/lib/popover/index.js +9 -27
- package/lib/popup/index.js +5 -27
- package/lib/pull-refresh/index.js +14 -38
- package/lib/radio/index.js +2 -7
- package/lib/radio-group/index.js +2 -8
- package/lib/rate/index.js +11 -31
- package/lib/row/index.js +3 -12
- package/lib/search/index.js +7 -21
- package/lib/signature/bezier.js +5 -15
- package/lib/signature/force-landscape.js +0 -11
- package/lib/signature/index.js +6 -31
- package/lib/signature/point.js +0 -8
- package/lib/signature/throttle.js +1 -11
- package/lib/skeleton/index.js +5 -21
- package/lib/slider/index.js +19 -63
- package/lib/step/index.js +5 -18
- package/lib/stepper/index.js +10 -46
- package/lib/steps/index.js +2 -7
- package/lib/sticky/index.js +8 -59
- package/lib/swipe/index.js +19 -70
- package/lib/swipe-cell/index.js +7 -29
- package/lib/swipe-item/index.js +9 -24
- package/lib/switch/index.js +7 -14
- package/lib/switch/shared.js +1 -1
- package/lib/switch-cell/index.js +6 -16
- package/lib/tab/index.js +4 -21
- package/lib/tabbar/index.js +4 -19
- package/lib/tabbar-item/index.js +5 -21
- package/lib/table/index.js +10 -38
- package/lib/tabs/Content.js +5 -15
- package/lib/tabs/Title.js +11 -23
- package/lib/tabs/index.js +15 -65
- package/lib/tabs/utils.js +0 -13
- package/lib/tag/index.js +12 -23
- package/lib/timeline/index.js +2 -32
- package/lib/toast/Toast.js +10 -30
- package/lib/toast/index.js +6 -38
- package/lib/toast/lock-click.js +0 -3
- package/lib/uploader/index.js +10 -72
- package/lib/uploader/utils.js +0 -17
- package/lib/utils/constant.js +2 -1
- package/lib/utils/create/bem.js +1 -6
- package/lib/utils/create/component.js +5 -14
- package/lib/utils/create/i18n.js +0 -8
- package/lib/utils/create/index.js +0 -4
- package/lib/utils/deep-assign.js +0 -6
- package/lib/utils/deep-clone.js +0 -5
- package/lib/utils/device.js +0 -2
- package/lib/utils/dom/event.js +2 -10
- package/lib/utils/dom/node.js +0 -2
- package/lib/utils/dom/raf.js +7 -11
- package/lib/utils/dom/reset-scroll.js +2 -4
- package/lib/utils/dom/scroll.js +8 -28
- package/lib/utils/dom/style.js +3 -3
- package/lib/utils/easings.js +2 -5
- package/lib/utils/format/date-util.js +54 -168
- package/lib/utils/format/number.js +2 -13
- package/lib/utils/format/string.js +0 -5
- package/lib/utils/format/unit.js +2 -16
- package/lib/utils/functional.js +6 -14
- package/lib/utils/getScroll.js +0 -7
- package/lib/utils/index.js +3 -19
- package/lib/utils/interceptor.js +2 -6
- package/lib/utils/media/image-util.js +7 -25
- package/lib/utils/raf.js +4 -13
- package/lib/utils/router.js +7 -9
- package/lib/utils/scrollTo.js +9 -21
- package/lib/utils/validate/date.js +0 -2
- package/lib/utils/validate/email.js +0 -1
- package/lib/utils/validate/mobile.js +0 -1
- package/lib/utils/validate/number.js +2 -4
- package/lib/utils/validate/system.js +0 -3
- package/lib/utils/vnodes.js +2 -9
- package/lib/zart.js +57 -18
- package/lib/zart.min.js +1 -1
- package/package.json +17 -18
package/es/media-picker/index.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
// Utils
|
|
2
|
-
import { createNamespace, isDef, isPromise
|
|
2
|
+
import { createNamespace, isDef, isPromise } from '../utils';
|
|
3
3
|
import Icon from "../icon";
|
|
4
4
|
import Loading from "../loading";
|
|
5
5
|
import ZtImage from "../image";
|
|
6
6
|
import ZtGridItem from "../grid-item";
|
|
7
7
|
import ZtMediaPlayer from "../media-player";
|
|
8
8
|
import ZtActionSheet from "../action-sheet";
|
|
9
|
-
import ZtGrid from "../grid";
|
|
10
|
-
|
|
11
|
-
import { MediaAddType, MediaType,
|
|
12
|
-
import { checkWatermarkConfigSupported, CompressOptions, file2DataURL, ImageProcessor, ResizeOptions, WatermarkOptions } from "@egova/media";
|
|
9
|
+
import ZtGrid from "../grid";
|
|
10
|
+
// Types
|
|
11
|
+
import { MediaAddType, MediaType, MediaUploadStatus } from "./type";
|
|
12
|
+
import { checkWatermarkConfigSupported, CompressOptions, file2DataURL, ImageProcessor, ResizeOptions, WatermarkOptions } from "@egova/media";
|
|
13
13
|
|
|
14
|
+
// import components
|
|
14
15
|
import Toast from '../toast';
|
|
15
|
-
import ImagePreview from "../image-preview";
|
|
16
|
+
import ImagePreview from "../image-preview";
|
|
16
17
|
|
|
18
|
+
// Images
|
|
17
19
|
import TakePhotoIcon from "./image/TakePhotoIcon";
|
|
18
20
|
import PickPhotoIcon from "./image/PickPhotoIcon";
|
|
19
21
|
import TakeVideoIcon from "./image/TakeVideoIcon";
|
|
@@ -30,14 +32,13 @@ import DefaultPdfIcon from "./image/DefaultPdfIcon";
|
|
|
30
32
|
import DefaultPptIcon from "./image/DefaultPptIcon";
|
|
31
33
|
import DefaultTextIcon from "./image/DefaultTextIcon";
|
|
32
34
|
import { FRAME_CONTAINER, CERTIFICATE_BACKGROUND, CERTIFICATE_BUTTON } from './image/Img64';
|
|
33
|
-
import { getFileUniqueCode, getUniqueFileName, isAudioType, isImageType, isVideoType, isPdfType, isDocType, isTextType, isPptType, isExcelType } from "./media-util";
|
|
35
|
+
import { getFileUniqueCode, getUniqueFileName, isAudioType, isImageType, isVideoType, isPdfType, isDocType, isTextType, isPptType, isExcelType } from "./media-util";
|
|
34
36
|
|
|
37
|
+
// 单个文件最大限制,单位为M(目前限制是100M)
|
|
35
38
|
var FILE_SIZE_LIMIT = 100;
|
|
36
|
-
|
|
37
39
|
var _createNamespace = createNamespace('media-picker'),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
createComponent = _createNamespace[0],
|
|
41
|
+
bem = _createNamespace[1];
|
|
41
42
|
export default createComponent({
|
|
42
43
|
props: {
|
|
43
44
|
disabled: Boolean,
|
|
@@ -70,7 +71,6 @@ export default createComponent({
|
|
|
70
71
|
type: Number,
|
|
71
72
|
default: FILE_SIZE_LIMIT * 1024
|
|
72
73
|
},
|
|
73
|
-
|
|
74
74
|
/**
|
|
75
75
|
* {
|
|
76
76
|
* maxImageSideLength,
|
|
@@ -184,7 +184,6 @@ export default createComponent({
|
|
|
184
184
|
},
|
|
185
185
|
actionOptions: function actionOptions() {
|
|
186
186
|
var _this = this;
|
|
187
|
-
|
|
188
187
|
if (this.videoOptionsVisible) {
|
|
189
188
|
return [{
|
|
190
189
|
name: '拍摄',
|
|
@@ -217,24 +216,20 @@ export default createComponent({
|
|
|
217
216
|
if (this.disabled) {
|
|
218
217
|
return;
|
|
219
218
|
}
|
|
220
|
-
|
|
221
219
|
if (!this.checkFileCountBeforeAdd(mediaType)) {
|
|
222
220
|
return;
|
|
223
221
|
}
|
|
224
|
-
|
|
225
222
|
if (this.mediaPickAction && this.mediaPickAction(mediaType, mediaAddType)) {
|
|
226
223
|
return;
|
|
227
224
|
}
|
|
228
|
-
|
|
229
225
|
var _this$$refs = this.$refs,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
226
|
+
cameraInput = _this$$refs.cameraInput,
|
|
227
|
+
imageInput = _this$$refs.imageInput,
|
|
228
|
+
camcorderInput = _this$$refs.camcorderInput,
|
|
229
|
+
videoFileInput = _this$$refs.videoFileInput,
|
|
230
|
+
audioRecorderInput = _this$$refs.audioRecorderInput,
|
|
231
|
+
audioFileInput = _this$$refs.audioFileInput,
|
|
232
|
+
fileInput = _this$$refs.fileInput;
|
|
238
233
|
if (mediaType === MediaType.PHOTO) {
|
|
239
234
|
if (mediaAddType === MediaAddType.TAKE) {
|
|
240
235
|
this.triggerHiddenInput(cameraInput);
|
|
@@ -270,7 +265,6 @@ export default createComponent({
|
|
|
270
265
|
ref.click();
|
|
271
266
|
}
|
|
272
267
|
},
|
|
273
|
-
|
|
274
268
|
/**
|
|
275
269
|
* 清空value,避免添加相同图片时 change 事件不触发:https://stackoverflow.com/a/54125788/1263423
|
|
276
270
|
* @param mediaType
|
|
@@ -278,14 +272,13 @@ export default createComponent({
|
|
|
278
272
|
*/
|
|
279
273
|
resetInput: function resetInput(mediaType, mediaAddType) {
|
|
280
274
|
var _this$$refs2 = this.$refs,
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
275
|
+
cameraInput = _this$$refs2.cameraInput,
|
|
276
|
+
imageInput = _this$$refs2.imageInput,
|
|
277
|
+
camcorderInput = _this$$refs2.camcorderInput,
|
|
278
|
+
videoFileInput = _this$$refs2.videoFileInput,
|
|
279
|
+
audioRecorderInput = _this$$refs2.audioRecorderInput,
|
|
280
|
+
audioFileInput = _this$$refs2.audioFileInput,
|
|
281
|
+
fileInput = _this$$refs2.fileInput;
|
|
289
282
|
if (mediaType === MediaType.PHOTO) {
|
|
290
283
|
if (mediaAddType === MediaAddType.TAKE) {
|
|
291
284
|
cameraInput.value = '';
|
|
@@ -310,34 +303,25 @@ export default createComponent({
|
|
|
310
303
|
},
|
|
311
304
|
handleInputFiles: function handleInputFiles(event) {
|
|
312
305
|
var _this2 = this;
|
|
313
|
-
|
|
314
306
|
var files = event.target.files;
|
|
315
|
-
|
|
316
307
|
if (!files || files.length === 0) {
|
|
317
308
|
return;
|
|
318
309
|
}
|
|
319
|
-
|
|
320
310
|
if (this.pickerMode === "certificate") {
|
|
321
311
|
files = [files[0]];
|
|
322
312
|
}
|
|
323
|
-
|
|
324
313
|
files = this.filterValidFiles(files);
|
|
325
|
-
|
|
326
314
|
if (files.length === 0) {
|
|
327
315
|
return;
|
|
328
316
|
}
|
|
329
|
-
|
|
330
317
|
if (!this.checkFileCountAfterAdd(files)) {
|
|
331
318
|
return;
|
|
332
319
|
}
|
|
333
|
-
|
|
334
320
|
if (this.beforeRead) {
|
|
335
321
|
var response = this.beforeRead(files);
|
|
336
|
-
|
|
337
322
|
if (!response) {
|
|
338
323
|
return;
|
|
339
324
|
}
|
|
340
|
-
|
|
341
325
|
if (isPromise(response)) {
|
|
342
326
|
response.then(function (data) {
|
|
343
327
|
if (data) {
|
|
@@ -349,12 +333,10 @@ export default createComponent({
|
|
|
349
333
|
return;
|
|
350
334
|
}
|
|
351
335
|
}
|
|
352
|
-
|
|
353
336
|
this.readFiles(files);
|
|
354
337
|
},
|
|
355
338
|
readFiles: function readFiles(files) {
|
|
356
339
|
var _this3 = this;
|
|
357
|
-
|
|
358
340
|
// 处理非图片
|
|
359
341
|
var notImages = files.filter(function (f) {
|
|
360
342
|
return !isImageType(f);
|
|
@@ -362,23 +344,19 @@ export default createComponent({
|
|
|
362
344
|
return _this3.transformNotImageFile(f);
|
|
363
345
|
});
|
|
364
346
|
var newMedias = [];
|
|
365
|
-
|
|
366
347
|
if (notImages.length > 0) {
|
|
367
348
|
newMedias = newMedias.concat(notImages);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
|
|
349
|
+
}
|
|
350
|
+
// 处理图片并合并
|
|
371
351
|
var imageFiles = files.filter(function (f) {
|
|
372
352
|
return isImageType(f);
|
|
373
353
|
});
|
|
374
354
|
var promise;
|
|
375
|
-
|
|
376
355
|
if (imageFiles.length === 0) {
|
|
377
356
|
promise = Promise.resolve();
|
|
378
357
|
} else {
|
|
379
358
|
promise = this.transformImageFiles(imageFiles);
|
|
380
359
|
}
|
|
381
|
-
|
|
382
360
|
promise.then(function (medias) {
|
|
383
361
|
if (medias && medias.length > 0) {
|
|
384
362
|
newMedias = newMedias.concat(medias);
|
|
@@ -389,13 +367,11 @@ export default createComponent({
|
|
|
389
367
|
} else {
|
|
390
368
|
_this3.$emit('input', [].concat(_this3.mediaList, newMedias));
|
|
391
369
|
}
|
|
392
|
-
|
|
393
370
|
if (_this3.afterRead) {
|
|
394
371
|
_this3.afterRead(newMedias);
|
|
395
372
|
}
|
|
396
373
|
});
|
|
397
374
|
},
|
|
398
|
-
|
|
399
375
|
/**
|
|
400
376
|
* 选择多媒体前进行数量检查
|
|
401
377
|
*/
|
|
@@ -404,31 +380,26 @@ export default createComponent({
|
|
|
404
380
|
Toast.fail("\u5DF2\u8FBE\u5230\u6587\u4EF6\u6700\u5927\u6570\u91CF\u9650\u5236");
|
|
405
381
|
return false;
|
|
406
382
|
}
|
|
407
|
-
|
|
408
383
|
if (mediaType === MediaType.PHOTO && this.mediaList.filter(function (media) {
|
|
409
384
|
return media.type === MediaType.PHOTO;
|
|
410
385
|
}).length > this.maxImageCount) {
|
|
411
386
|
Toast.fail("\u5DF2\u8FBE\u5230\u56FE\u7247\u6700\u5927\u6570\u91CF\u9650\u5236");
|
|
412
387
|
return false;
|
|
413
388
|
}
|
|
414
|
-
|
|
415
389
|
if (mediaType === MediaType.VIDEO && this.mediaList.filter(function (media) {
|
|
416
390
|
return media.type === MediaType.VIDEO;
|
|
417
391
|
}).length > this.maxVideoCount) {
|
|
418
392
|
Toast.fail("\u5DF2\u8FBE\u5230\u89C6\u9891\u6700\u5927\u6570\u91CF\u9650\u5236");
|
|
419
393
|
return false;
|
|
420
394
|
}
|
|
421
|
-
|
|
422
395
|
if (mediaType === MediaType.AUDIO && this.mediaList.filter(function (media) {
|
|
423
396
|
return media.type === MediaType.AUDIO;
|
|
424
397
|
}).length > this.maxAudioCount) {
|
|
425
398
|
Toast.fail("\u5DF2\u8FBE\u5230\u5F55\u97F3\u6700\u5927\u6570\u91CF\u9650\u5236");
|
|
426
399
|
return false;
|
|
427
400
|
}
|
|
428
|
-
|
|
429
401
|
return true;
|
|
430
402
|
},
|
|
431
|
-
|
|
432
403
|
/**
|
|
433
404
|
* 选择多媒体后进行数量检查
|
|
434
405
|
*/
|
|
@@ -437,7 +408,6 @@ export default createComponent({
|
|
|
437
408
|
Toast.fail("\u6700\u591A\u53EA\u80FD\u4E0A\u4F20" + this.maxMediaCount + "\u4E2A\u6587\u4EF6");
|
|
438
409
|
return false;
|
|
439
410
|
}
|
|
440
|
-
|
|
441
411
|
if (this.mediaList.filter(function (media) {
|
|
442
412
|
return media.type === MediaType.PHOTO;
|
|
443
413
|
}).length + files.filter(function (media) {
|
|
@@ -446,7 +416,6 @@ export default createComponent({
|
|
|
446
416
|
Toast.fail("\u6700\u591A\u53EA\u80FD\u4E0A\u4F20" + this.maxImageCount + "\u5F20\u56FE\u7247");
|
|
447
417
|
return false;
|
|
448
418
|
}
|
|
449
|
-
|
|
450
419
|
if (this.mediaList.filter(function (media) {
|
|
451
420
|
return media.type === MediaType.VIDEO;
|
|
452
421
|
}).length + files.filter(function (media) {
|
|
@@ -455,7 +424,6 @@ export default createComponent({
|
|
|
455
424
|
Toast.fail("\u6700\u591A\u53EA\u80FD\u4E0A\u4F20" + this.maxVideoCount + "\u4E2A\u89C6\u9891");
|
|
456
425
|
return false;
|
|
457
426
|
}
|
|
458
|
-
|
|
459
427
|
if (this.mediaList.filter(function (media) {
|
|
460
428
|
return media.type === MediaType.AUDIO;
|
|
461
429
|
}).length + files.filter(function (media) {
|
|
@@ -464,31 +432,24 @@ export default createComponent({
|
|
|
464
432
|
Toast.fail("\u6700\u591A\u53EA\u80FD\u4E0A\u4F20" + this.maxAudioCount + "\u4E2A\u5F55\u97F3");
|
|
465
433
|
return false;
|
|
466
434
|
}
|
|
467
|
-
|
|
468
435
|
return true;
|
|
469
436
|
},
|
|
470
437
|
filterValidFiles: function filterValidFiles(files) {
|
|
471
438
|
var validFiles = [];
|
|
472
|
-
|
|
473
439
|
for (var i = 0; i < files.length; i++) {
|
|
474
440
|
var file = files[i];
|
|
475
|
-
|
|
476
441
|
if (file.size > this.maxFileSize * 1024) {
|
|
477
442
|
Toast.fail("\u8BF7\u52FF\u6DFB\u52A0\u5927\u4E8E" + this.maxFileSize + "K\u7684\u6587\u4EF6");
|
|
478
443
|
return validFiles;
|
|
479
444
|
}
|
|
480
|
-
|
|
481
445
|
if (this.checkFileExist(file)) {
|
|
482
446
|
Toast.fail('请勿重复添加文件');
|
|
483
447
|
return validFiles;
|
|
484
448
|
}
|
|
485
|
-
|
|
486
449
|
validFiles.push(file);
|
|
487
450
|
}
|
|
488
|
-
|
|
489
451
|
return validFiles;
|
|
490
452
|
},
|
|
491
|
-
|
|
492
453
|
/**
|
|
493
454
|
* 转换图片文件,压缩、加水印,返回Media格式的图片
|
|
494
455
|
* @param files 图片文件
|
|
@@ -496,16 +457,13 @@ export default createComponent({
|
|
|
496
457
|
*/
|
|
497
458
|
transformImageFiles: function transformImageFiles(files) {
|
|
498
459
|
var _this4 = this;
|
|
499
|
-
|
|
500
460
|
var promisesTodo = [];
|
|
501
461
|
var resizeOptions = new ResizeOptions(this.maxImageSideLength);
|
|
502
462
|
var compressOptions = new CompressOptions(this.maxImageFileSize);
|
|
503
|
-
|
|
504
463
|
var _loop = function _loop(i) {
|
|
505
464
|
var file = files[i];
|
|
506
465
|
var watermarkEnabled = _this4.watermarkOptions && _this4.watermarkOptions.watermarkConfigString && checkWatermarkConfigSupported(_this4.watermarkOptions.watermarkConfigString);
|
|
507
466
|
var watermarkOpt = void 0;
|
|
508
|
-
|
|
509
467
|
if (watermarkEnabled) {
|
|
510
468
|
watermarkOpt = new WatermarkOptions({
|
|
511
469
|
enabled: true,
|
|
@@ -524,12 +482,10 @@ export default createComponent({
|
|
|
524
482
|
enabled: false
|
|
525
483
|
});
|
|
526
484
|
}
|
|
527
|
-
|
|
528
485
|
var promise = new ImageProcessor(file, resizeOptions, watermarkOpt, compressOptions).process().then(function (f) {
|
|
529
486
|
if (!f) {
|
|
530
487
|
return Promise.resolve();
|
|
531
488
|
}
|
|
532
|
-
|
|
533
489
|
return file2DataURL(f).then(function (base64) {
|
|
534
490
|
var uniqueFileName = getUniqueFileName(f, 'jpg');
|
|
535
491
|
return Promise.resolve({
|
|
@@ -553,17 +509,14 @@ export default createComponent({
|
|
|
553
509
|
originalName: file.name,
|
|
554
510
|
// 原始名称
|
|
555
511
|
originalSize: file.size // 原始大小
|
|
556
|
-
|
|
557
512
|
});
|
|
558
513
|
});
|
|
559
514
|
});
|
|
560
515
|
promisesTodo.push(promise);
|
|
561
516
|
};
|
|
562
|
-
|
|
563
517
|
for (var i = 0; i < files.length; i++) {
|
|
564
518
|
_loop(i);
|
|
565
519
|
}
|
|
566
|
-
|
|
567
520
|
Toast.loading({
|
|
568
521
|
message: '处理中...',
|
|
569
522
|
forbidClick: true,
|
|
@@ -577,7 +530,6 @@ export default createComponent({
|
|
|
577
530
|
Toast.clear();
|
|
578
531
|
});
|
|
579
532
|
},
|
|
580
|
-
|
|
581
533
|
/**
|
|
582
534
|
* 转换非图片文件
|
|
583
535
|
* @param {File} f 非图片文件
|
|
@@ -587,7 +539,6 @@ export default createComponent({
|
|
|
587
539
|
console.warn("type", f.type);
|
|
588
540
|
var suffix = '';
|
|
589
541
|
var type = MediaType.FILE;
|
|
590
|
-
|
|
591
542
|
if (isAudioType(f)) {
|
|
592
543
|
type = MediaType.AUDIO;
|
|
593
544
|
suffix = 'mp3';
|
|
@@ -607,7 +558,6 @@ export default createComponent({
|
|
|
607
558
|
} else {
|
|
608
559
|
type = MediaType.FILE;
|
|
609
560
|
}
|
|
610
|
-
|
|
611
561
|
var uniqueFileName = getUniqueFileName(f, suffix);
|
|
612
562
|
return {
|
|
613
563
|
type: type,
|
|
@@ -623,7 +573,6 @@ export default createComponent({
|
|
|
623
573
|
message: ''
|
|
624
574
|
};
|
|
625
575
|
},
|
|
626
|
-
|
|
627
576
|
/**
|
|
628
577
|
* 检查文件是否重复添加
|
|
629
578
|
*/
|
|
@@ -632,7 +581,6 @@ export default createComponent({
|
|
|
632
581
|
return media.uniqueCode === getFileUniqueCode(file);
|
|
633
582
|
});
|
|
634
583
|
},
|
|
635
|
-
|
|
636
584
|
/**
|
|
637
585
|
* 点击预览
|
|
638
586
|
*/
|
|
@@ -640,7 +588,6 @@ export default createComponent({
|
|
|
640
588
|
if (this.preview && this.preview(media, index)) {
|
|
641
589
|
return;
|
|
642
590
|
}
|
|
643
|
-
|
|
644
591
|
if (media.type === MediaType.PHOTO) {
|
|
645
592
|
var imageIndex = this.imageList.indexOf(media);
|
|
646
593
|
ImagePreview({
|
|
@@ -657,8 +604,8 @@ export default createComponent({
|
|
|
657
604
|
Toast('文件参数缺失');
|
|
658
605
|
} else {
|
|
659
606
|
this.mediaTypeToPlay = media.type;
|
|
660
|
-
this.mediaUrlToPlay = media.url || (URL || webkitURL).createObjectURL(media.file);
|
|
661
|
-
|
|
607
|
+
this.mediaUrlToPlay = media.url || (URL || webkitURL).createObjectURL(media.file);
|
|
608
|
+
// this.mediaUrlToPlay = 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4'
|
|
662
609
|
this.mediaPlayerVisible = true;
|
|
663
610
|
}
|
|
664
611
|
} else {
|
|
@@ -667,14 +614,11 @@ export default createComponent({
|
|
|
667
614
|
},
|
|
668
615
|
onDelete: function onDelete(media, index) {
|
|
669
616
|
var _this5 = this;
|
|
670
|
-
|
|
671
617
|
if (this.beforeDelete) {
|
|
672
618
|
var response = this.beforeDelete(media);
|
|
673
|
-
|
|
674
619
|
if (!response) {
|
|
675
620
|
return;
|
|
676
621
|
}
|
|
677
|
-
|
|
678
622
|
if (isPromise(response)) {
|
|
679
623
|
response.then(function () {
|
|
680
624
|
_this5.deleteMedia(media, index);
|
|
@@ -682,7 +626,6 @@ export default createComponent({
|
|
|
682
626
|
return;
|
|
683
627
|
}
|
|
684
628
|
}
|
|
685
|
-
|
|
686
629
|
this.deleteMedia(media, index);
|
|
687
630
|
},
|
|
688
631
|
deleteMedia: function deleteMedia(media, index) {
|
|
@@ -693,7 +636,6 @@ export default createComponent({
|
|
|
693
636
|
},
|
|
694
637
|
hiddenInput: function hiddenInput() {
|
|
695
638
|
var _this6 = this;
|
|
696
|
-
|
|
697
639
|
var h = this.$createElement;
|
|
698
640
|
return [h("input", {
|
|
699
641
|
"attrs": {
|
|
@@ -795,9 +737,7 @@ export default createComponent({
|
|
|
795
737
|
},
|
|
796
738
|
renderIcon: function renderIcon(mediaType, mediaAddType) {
|
|
797
739
|
var _this7 = this;
|
|
798
|
-
|
|
799
740
|
var h = this.$createElement;
|
|
800
|
-
|
|
801
741
|
if (mediaType === MediaType.PHOTO) {
|
|
802
742
|
if (mediaAddType === MediaAddType.TAKE) {
|
|
803
743
|
return h(TakePhotoIcon, {
|
|
@@ -850,7 +790,6 @@ export default createComponent({
|
|
|
850
790
|
renderButton: function renderButton(mediaType, mediaAddType) {
|
|
851
791
|
var h = this.$createElement;
|
|
852
792
|
var label = '';
|
|
853
|
-
|
|
854
793
|
if (mediaType === MediaType.PHOTO) {
|
|
855
794
|
if (mediaAddType === MediaAddType.TAKE) {
|
|
856
795
|
label = '拍照';
|
|
@@ -864,7 +803,6 @@ export default createComponent({
|
|
|
864
803
|
} else if (mediaType === MediaType.FILE) {
|
|
865
804
|
label = '文档';
|
|
866
805
|
}
|
|
867
|
-
|
|
868
806
|
return h("div", {
|
|
869
807
|
"class": bem('box')
|
|
870
808
|
}, [this.renderIcon(mediaType, mediaAddType), h("div", {
|
|
@@ -873,9 +811,7 @@ export default createComponent({
|
|
|
873
811
|
},
|
|
874
812
|
renderCertificates: function renderCertificates() {
|
|
875
813
|
var _this8 = this;
|
|
876
|
-
|
|
877
814
|
var h = this.$createElement;
|
|
878
|
-
|
|
879
815
|
if (this.mediaList && this.mediaList.length) {
|
|
880
816
|
var media = this.mediaList[0];
|
|
881
817
|
var showDelete = media.deletable && media.status !== MediaUploadStatus.UPLOADING;
|
|
@@ -884,9 +820,7 @@ export default createComponent({
|
|
|
884
820
|
"on": {
|
|
885
821
|
"click": function click(event) {
|
|
886
822
|
event.stopPropagation();
|
|
887
|
-
|
|
888
823
|
_this8.onDelete(media, 0);
|
|
889
|
-
|
|
890
824
|
_this8.mediaPick(MediaType.PHOTO, MediaAddType.PICK);
|
|
891
825
|
}
|
|
892
826
|
}
|
|
@@ -903,8 +837,8 @@ export default createComponent({
|
|
|
903
837
|
},
|
|
904
838
|
"on": {
|
|
905
839
|
"click": function click(event) {
|
|
906
|
-
event.stopPropagation();
|
|
907
|
-
|
|
840
|
+
event.stopPropagation();
|
|
841
|
+
// 证件照模式只有一张图片
|
|
908
842
|
_this8.previewMedia(media, 0);
|
|
909
843
|
}
|
|
910
844
|
}
|
|
@@ -932,50 +866,39 @@ export default createComponent({
|
|
|
932
866
|
},
|
|
933
867
|
renderButtons: function renderButtons() {
|
|
934
868
|
var buttons = [];
|
|
935
|
-
|
|
936
869
|
if (this.allowTakePhoto) {
|
|
937
870
|
buttons.push(this.renderButton(MediaType.PHOTO, MediaAddType.TAKE));
|
|
938
871
|
}
|
|
939
|
-
|
|
940
872
|
if (this.allowPickPhoto) {
|
|
941
873
|
buttons.push(this.renderButton(MediaType.PHOTO, MediaAddType.PICK));
|
|
942
874
|
}
|
|
943
|
-
|
|
944
875
|
if (this.allowTakeVideo || this.allowPickVideo) {
|
|
945
876
|
var addType = MediaAddType.TAKE_AND_PICK;
|
|
946
|
-
|
|
947
877
|
if (!this.allowTakeVideo) {
|
|
948
878
|
addType = MediaAddType.PICK;
|
|
949
879
|
} else if (!this.allowPickVideo) {
|
|
950
880
|
addType = MediaAddType.TAKE;
|
|
951
881
|
}
|
|
952
|
-
|
|
953
882
|
buttons.push(this.renderButton(MediaType.VIDEO, addType));
|
|
954
883
|
}
|
|
955
|
-
|
|
956
884
|
if (this.allowTakeAudio || this.allowPickAudio) {
|
|
957
885
|
var _addType = MediaAddType.TAKE_AND_PICK;
|
|
958
|
-
|
|
959
886
|
if (!this.allowTakeAudio) {
|
|
960
887
|
_addType = MediaAddType.PICK;
|
|
961
888
|
} else if (!this.allowPickAudio) {
|
|
962
889
|
_addType = MediaAddType.TAKE;
|
|
963
890
|
}
|
|
964
|
-
|
|
965
891
|
buttons.push(this.renderButton(MediaType.AUDIO, _addType));
|
|
966
892
|
}
|
|
967
|
-
|
|
968
893
|
if (this.allowPickFile) {
|
|
969
894
|
buttons.push(this.renderButton(MediaType.FILE, MediaAddType.PICK));
|
|
970
895
|
}
|
|
971
|
-
|
|
972
896
|
return buttons;
|
|
973
897
|
},
|
|
974
898
|
genThumbnailMask: function genThumbnailMask(media) {
|
|
975
899
|
var h = this.$createElement;
|
|
976
900
|
var status = media.status,
|
|
977
|
-
|
|
978
|
-
|
|
901
|
+
message = media.message;
|
|
979
902
|
if (status === MediaUploadStatus.UPLOADING || status === MediaUploadStatus.FAILED) {
|
|
980
903
|
var MaskIcon = status === MediaUploadStatus.FAILED ? h(Icon, {
|
|
981
904
|
"attrs": {
|
|
@@ -995,7 +918,6 @@ export default createComponent({
|
|
|
995
918
|
},
|
|
996
919
|
renderMediaBox: function renderMediaBox(media) {
|
|
997
920
|
var h = this.$createElement;
|
|
998
|
-
|
|
999
921
|
if (!this.showFileName) {
|
|
1000
922
|
return this.renderMediaThumbnail(media);
|
|
1001
923
|
} else {
|
|
@@ -1006,13 +928,11 @@ export default createComponent({
|
|
|
1006
928
|
}, [media.name || media.fileName])]);
|
|
1007
929
|
}
|
|
1008
930
|
},
|
|
1009
|
-
|
|
1010
931
|
/**
|
|
1011
932
|
* 多媒体对应展示的缩略图
|
|
1012
933
|
*/
|
|
1013
934
|
renderMediaThumbnail: function renderMediaThumbnail(media) {
|
|
1014
935
|
var h = this.$createElement;
|
|
1015
|
-
|
|
1016
936
|
if (media.showSrc) {
|
|
1017
937
|
return h(ZtImage, {
|
|
1018
938
|
"attrs": {
|
|
@@ -1057,7 +977,6 @@ export default createComponent({
|
|
|
1057
977
|
},
|
|
1058
978
|
renderMediaList: function renderMediaList() {
|
|
1059
979
|
var _this9 = this;
|
|
1060
|
-
|
|
1061
980
|
var h = this.$createElement;
|
|
1062
981
|
return this.mediaList.map(function (media, index) {
|
|
1063
982
|
var showDelete = media.deletable && media.status !== MediaUploadStatus.UPLOADING;
|
|
@@ -1066,7 +985,6 @@ export default createComponent({
|
|
|
1066
985
|
"on": {
|
|
1067
986
|
"click": function click(event) {
|
|
1068
987
|
event.stopPropagation();
|
|
1069
|
-
|
|
1070
988
|
_this9.onDelete(media, index);
|
|
1071
989
|
}
|
|
1072
990
|
}
|
|
@@ -1076,7 +994,6 @@ export default createComponent({
|
|
|
1076
994
|
"on": {
|
|
1077
995
|
"click": function click(event) {
|
|
1078
996
|
event.stopPropagation();
|
|
1079
|
-
|
|
1080
997
|
_this9.previewMedia(media, index);
|
|
1081
998
|
}
|
|
1082
999
|
}
|
|
@@ -1090,7 +1007,6 @@ export default createComponent({
|
|
|
1090
1007
|
},
|
|
1091
1008
|
render: function render() {
|
|
1092
1009
|
var _this10 = this;
|
|
1093
|
-
|
|
1094
1010
|
var h = arguments[0];
|
|
1095
1011
|
var title = this.showTitle && h("div", {
|
|
1096
1012
|
"class": bem('title')
|
|
@@ -22,30 +22,27 @@ export function isPptType(file) {
|
|
|
22
22
|
export function isExcelType(file) {
|
|
23
23
|
return file.type.indexOf('.sheet') >= 0;
|
|
24
24
|
}
|
|
25
|
+
|
|
25
26
|
/**
|
|
26
27
|
* 文件唯一标识
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
29
|
export function getFileUniqueCode(file) {
|
|
30
30
|
return file.name + "_" + file.type + "_" + file.size + "_" + file.lastModified;
|
|
31
31
|
}
|
|
32
|
+
|
|
32
33
|
/**
|
|
33
34
|
* 生成不重复的文件名
|
|
34
35
|
* @param {File} file 原始文件
|
|
35
36
|
* @param {string} suffix 指定文件名后缀
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
38
|
export function getUniqueFileName(file, suffix) {
|
|
39
39
|
if (suffix === void 0) {
|
|
40
40
|
suffix = '';
|
|
41
41
|
}
|
|
42
|
-
|
|
43
42
|
var dotIndex = file.name.lastIndexOf('.');
|
|
44
|
-
|
|
45
43
|
if (dotIndex > 0) {
|
|
46
44
|
suffix = file.name.substring(dotIndex + 1);
|
|
47
45
|
}
|
|
48
|
-
|
|
49
46
|
var now = new Date();
|
|
50
47
|
var name = "" + now.getFullYear() + now.getMonth() + now.getDay() + now.getHours() + now.getMinutes() + now.getSeconds() + now.getMilliseconds() + "_" + Math.ceil(Math.random() * 10000);
|
|
51
48
|
return suffix ? name + '.' + suffix : name;
|
package/es/media-picker/type.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
export var MediaUploadStatus;
|
|
2
|
-
|
|
3
2
|
(function (MediaUploadStatus) {
|
|
4
3
|
MediaUploadStatus["UPLOADING"] = "uploading";
|
|
5
4
|
MediaUploadStatus["DONE"] = "done";
|
|
6
5
|
MediaUploadStatus["FAILED"] = "failed";
|
|
7
6
|
})(MediaUploadStatus || (MediaUploadStatus = {}));
|
|
8
|
-
|
|
9
7
|
export var MediaType;
|
|
10
|
-
|
|
11
8
|
(function (MediaType) {
|
|
12
9
|
MediaType["PHOTO"] = "photo";
|
|
13
10
|
MediaType["AUDIO"] = "audio";
|
|
@@ -19,9 +16,7 @@ export var MediaType;
|
|
|
19
16
|
MediaType["PPT"] = "ppt";
|
|
20
17
|
MediaType["EXCEL"] = "excel";
|
|
21
18
|
})(MediaType || (MediaType = {}));
|
|
22
|
-
|
|
23
19
|
export var MediaAddType;
|
|
24
|
-
|
|
25
20
|
(function (MediaAddType) {
|
|
26
21
|
MediaAddType["TAKE"] = "take";
|
|
27
22
|
MediaAddType["PICK"] = "pick";
|