cloud-web-corejs 1.0.280 → 1.1.0-dev.4
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/package.json +6 -2
- package/src/components/VabUpload/image-viewer.vue +442 -442
- package/src/components/VabUpload/index.vue +44 -2
- package/src/components/VabUpload/mixins.js +174 -34
- package/src/components/VabUpload/previewGroup.js +128 -0
- package/src/components/VabUpload/view.vue +247 -209
- package/src/components/baseTabs/mixins.js +181 -181
- package/src/components/bizTab/BizBillActions.vue +129 -0
- package/src/components/bizTab/BizTabListPage.vue +391 -0
- package/src/components/bizTab/README.md +378 -0
- package/src/components/bizTab/billTableUtil.js +48 -0
- package/src/components/bizTab/billValidators.js +136 -0
- package/src/components/bizTab/bizBillDetailMixin.js +705 -0
- package/src/components/bizTab/index.js +24 -0
- package/src/components/excelExport/exportFieldDialog.vue +23 -12
- package/src/components/excelExport/exportItemConfigUtil.js +30 -0
- package/src/components/excelExport/mixins.js +3 -3
- package/src/components/mobile/statusTag/mixins.js +1 -61
- package/src/components/mobile/wf/content.vue +1662 -1556
- package/src/components/mobile/wf/mixins/wfModifyDialogMixin.js +8 -6
- package/src/components/table/config.js +78 -78
- package/src/components/table/index.js +1276 -1276
- package/src/components/table/plugins/cell-area/index.js +1055 -0
- package/src/components/table/plugins/cell-area/index.scss +77 -0
- package/src/components/table/plugins/cell-area/util.js +224 -0
- package/src/components/table/tableForm.vue +330 -330
- package/src/components/table/tableFormMixin.js +318 -318
- package/src/components/table/vxeFilter/index.js +163 -163
- package/src/components/table/vxeFilter/mixin.js +316 -316
- package/src/components/wf/content.vue +1188 -1188
- package/src/components/wf/wf.js +40 -20
- package/src/components/wf/wfActionDropdown.vue +1 -1
- package/src/components/wf/wfActionItems.js +1 -1
- package/src/components/xform/docs/2026-08 xform H5 P0 /345/256/236/347/216/260/350/247/204/346/240/274.md" +528 -0
- package/src/components/xform/docs/2026-08 xform H5 P1 /345/256/236/347/216/260/350/247/204/346/240/274.md" +412 -0
- package/src/components/xform/docs/2026-08 xform H5 P2 /345/256/236/347/216/260/350/247/204/346/240/274.md" +287 -0
- package/src/components/xform/docs/2026-08 xform /347/247/273/345/212/250/347/253/257/345/270/203/345/261/200/345/257/271/351/275/220 bill_setting /346/226/271/346/241/210.md" +400 -0
- package/src/components/xform/form-designer/designer.js +15 -0
- package/src/components/xform/form-designer/form-widget/container-widget/data-table-widget.vue +269 -269
- package/src/components/xform/form-designer/form-widget/container-widget/detail-temp-widget.vue +132 -0
- package/src/components/xform/form-designer/form-widget/container-widget/detail-widget.vue +250 -250
- package/src/components/xform/form-designer/form-widget/dialog/fileReferenceDialog.vue +319 -320
- package/src/components/xform/form-designer/form-widget/dialog/formDialog.vue +365 -365
- package/src/components/xform/form-designer/form-widget/dialog/searchFormDialog.vue +554 -555
- package/src/components/xform/form-designer/form-widget/dialog/vabSearchDialog.vue +409 -409
- package/src/components/xform/form-designer/form-widget/field-widget/a-link-widget.vue +150 -132
- package/src/components/xform/form-designer/form-widget/field-widget/date-range-widget.vue +114 -114
- package/src/components/xform/form-designer/form-widget/field-widget/date-widget.vue +154 -154
- package/src/components/xform/form-designer/form-widget/field-widget/form-item-wrapper.vue +47 -1
- package/src/components/xform/form-designer/form-widget/field-widget/mixins/date-limit-mixin.js +178 -178
- package/src/components/xform/form-designer/form-widget/field-widget/mixins/time-limit-mixin.js +77 -77
- package/src/components/xform/form-designer/form-widget/field-widget/select-export-item-button-widget.vue +6 -0
- package/src/components/xform/form-designer/form-widget/field-widget/select-widget.vue +139 -139
- package/src/components/xform/form-designer/form-widget/field-widget/time-range-widget.vue +106 -106
- package/src/components/xform/form-designer/form-widget/field-widget/time-widget.vue +134 -134
- package/src/components/xform/form-designer/form-widget/field-widget/vabUpload-widget.vue +1 -0
- package/src/components/xform/form-designer/setting-panel/form-setting.vue +39 -39
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/data-table-editor.vue +10 -10
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/exportItemColumns-dialog.vue +438 -432
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/table-column-dialog.vue +2103 -2103
- package/src/components/xform/form-designer/setting-panel/property-editor/container-detail/detail-temp-edito.vue +90 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/container-grid/gutter-editor.vue +82 -82
- package/src/components/xform/form-designer/setting-panel/property-editor/container-list-h5/list-h5-editor.vue +19 -5
- package/src/components/xform/form-designer/setting-panel/property-editor/container-table/table-dynamicField-editor.vue +8 -8
- package/src/components/xform/form-designer/setting-panel/property-editor/dropdownFlag-editor.vue +137 -137
- package/src/components/xform/form-designer/setting-panel/property-editor/field-button/search-dialog-event-editor.vue +237 -237
- package/src/components/xform/form-designer/setting-panel/property-editor/field-date/date-defaultValue-editor.vue +43 -43
- package/src/components/xform/form-designer/setting-panel/property-editor/field-date-range/date-range-defaultValue-editor.vue +43 -43
- package/src/components/xform/form-designer/setting-panel/property-editor/field-import-button/import2-button-editor.vue +96 -96
- package/src/components/xform/form-designer/setting-panel/property-editor/field-table-export-button/select-export-item-button-editor.vue +51 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/field-time/time-defaultValue-editor.vue +42 -42
- package/src/components/xform/form-designer/setting-panel/property-editor/field-time-range/time-range-defaultValue-editor.vue +43 -43
- package/src/components/xform/form-designer/setting-panel/property-editor/formScriptEnabled-editor.vue +158 -158
- package/src/components/xform/form-designer/setting-panel/property-editor/h5Span-editor.vue +51 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/itemStyle-editor.vue +39 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/name-editor.vue +188 -188
- package/src/components/xform/form-designer/setting-panel/property-editor/styleTempClass-editor.vue +51 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/textFlag-editor.vue +347 -347
- package/src/components/xform/form-designer/setting-panel/propertyRegister.js +4 -0
- package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +59 -3
- package/src/components/xform/form-render/container-item/data-table-mixin.js +151 -93
- package/src/components/xform/form-render/container-item/detail-h5-item.vue +183 -32
- package/src/components/xform/form-render/container-item/detail-temp-item.vue +110 -0
- package/src/components/xform/form-render/container-item/h5-card-pane-item.vue +160 -140
- package/src/components/xform/form-render/container-item/list-h5-item.vue +1688 -1700
- package/src/components/xform/form-render/index.vue +153 -147
- package/src/components/xform/form-render/indexMixin.js +12 -0
- package/src/components/xform/lang/en-US.js +10 -0
- package/src/components/xform/lang/zh-CN.js +12 -0
- package/src/components/xform/mixins/defaultHandle.js +707 -707
- package/src/components/xform/styles/h5.scss +1992 -0
- package/src/components/xform/utils/textMaskUtil.js +182 -179
- package/src/components/xform/utils/treeTableUtil.js +1292 -1265
- package/src/components/xform/utils/util.js +56 -11
- package/src/index.js +9 -4
- package/src/layout/components/extractedCode/viewDialog.vue +7 -7
- package/src/router/index.js +21 -0
- package/src/router/modules/customer.js +71 -14
- package/src/store/modules/permission.js +17 -18
- package/src/utils/pdfUtil.js +429 -429
- package/src/utils/resolveViewComponent.js +142 -16
- package/src/views/bd/project/branch/bd_branch/edit.vue +145 -0
- package/src/views/bd/project/branch/bd_branch/list.vue +72 -0
- package/src/views/bd/project/branch/bd_branch/menuKindDialog.vue +106 -0
- package/src/views/bd/project/branch/bd_branch/mixins/edit.js +189 -0
- package/src/views/bd/project/branch/bd_branch/mixins/list.js +124 -0
- package/src/views/bd/project/branch/bd_branch/mixins/menuKindDialog.js +85 -0
- package/src/views/bd/project/branch/form_script/list.vue +31 -0
- package/src/views/bd/project/branch/form_template/list.vue +30 -0
- package/src/views/bd/project/branch/menu_kind/list.vue +31 -0
- package/src/views/bd/project/common/form_script/list.vue +16 -0
- package/src/views/bd/project/common/form_template/list.vue +15 -0
- package/src/views/bd/project/common/menu_kind/list.vue +15 -0
- package/src/views/bd/project/core/branchContext.js +100 -0
- package/src/views/bd/project/core/branchPage.js +78 -0
- package/src/views/bd/project/core/branchPageWrap.vue +225 -0
- package/src/views/bd/project/core/branchScope.js +44 -0
- package/src/views/bd/project/core/branchSearchPage.js +285 -0
- package/src/views/bd/project/core/branchSelect.vue +85 -0
- package/src/views/bd/project/core/branchTreeBar.vue +81 -0
- package/src/views/bd/project/core/httpBranchPatch.js +58 -0
- package/src/views/bd/project/datatable/menu_kind/list.vue +15 -0
- package/src/views/bd/project/datatable/table_model/list.vue +15 -0
- package/src/views/bd/setting/bd_company_env/dialog.vue +174 -174
- package/src/views/bd/setting/table_model/edit.vue +1066 -1066
- package/src/views/bd/setting/table_model/mixins/edit.js +1455 -1455
- package/src/views/bd/setting/table_model/mixins/zdDialog.js +148 -148
- package/src/views/demo/bizTab/bill/billConfig.js +41 -0
- package/src/views/demo/bizTab/bill/detail.vue +436 -0
- package/src/views/demo/bizTab/bill/list.vue +288 -0
- package/src/views/demo/bizTab/bill/productDialog.vue +176 -0
- package/src/views/demo/bizTab/simple/billApi.js +123 -0
- package/src/views/demo/bizTab/simple/detail.vue +407 -0
- package/src/views/demo/bizTab/simple/list.vue +217 -0
- package/src/views/demo/bizTab/standalone/index.vue +121 -0
- package/src/views/demo/bizTab/wf/billConfig.js +44 -0
- package/src/views/demo/bizTab/wf/detail.vue +661 -0
- package/src/views/demo/bizTab/wf/list.vue +242 -0
- package/src/views/support/form-dialog-demo/demoPickerDialog.vue +72 -0
- package/src/views/support/form-dialog-demo/index.vue +537 -0
- package/src/views/user/file_view_ins/list.vue +3 -3
- package/src/views/user/home/index.vue +8 -6
- package/src/views/user/home/wjl/content.vue +1569 -0
- package/src/views/user/notify_message/dialog.vue +7 -5
- package/src/views/user/outLink/cc_form_view.vue +188 -0
- package/src/views/user/outLink/form_view.vue +2 -2
- package/src/views/user/outLink/index.vue +4 -4
- package/src/views/user/outLink/view.vue +3 -3
- package/src/views/user/role/edit.vue +632 -632
- package/src/views/user/role/list.vue +260 -260
- package/src/views/user/wf/iframe/index.vue +3 -3
- package/src/views/user/wf/iframe/index2.vue +3 -3
- package/src/views/user/wf/wf_manage/list.vue +1112 -1116
- package/src/views/user/wf/wf_manage/list2.vue +9 -13
- package/src/views/user/wf/wf_manage/wfContentDialog.vue +8 -5
- package/src/components/xform/form-designer/form-widget/field-widget/dropdown-menu-widget.vue +0 -106
- package/src/components/xform/form-designer/form-widget/field-widget/tableexportbuttonwidget.vue +0 -99
- package/src/components/xform/form-render/container-item/list-h5-item2.vue +0 -1340
- package/src/utils/wf.js +0 -766
|
@@ -1,442 +1,442 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<transition name="viewer-fade">
|
|
3
|
-
<div tabindex="-1" ref="el-image-viewer__wrapper" class="el-image-viewer__wrapper" :style="{ 'z-index': viewerZIndex }">
|
|
4
|
-
<div class="el-image-viewer__mask" @click.self="handleMaskClick"></div>
|
|
5
|
-
<!-- CLOSE -->
|
|
6
|
-
<span class="el-image-viewer__btn el-image-viewer__close" @click="hide"><i class="el-icon-close"></i></span>
|
|
7
|
-
<div class="big">
|
|
8
|
-
<!-- ARROW -->
|
|
9
|
-
<template v-if="!isSingle">
|
|
10
|
-
<span class="el-image-viewer__btn el-image-viewer__prev" :class="{ 'is-disabled': !infinite && isFirst }" @click="prev"><i class="el-icon-arrow-left" /></span>
|
|
11
|
-
<span class="el-image-viewer__btn el-image-viewer__next" :class="{ 'is-disabled': !infinite && isLast }" @click="next"><i class="el-icon-arrow-right" /></span>
|
|
12
|
-
</template>
|
|
13
|
-
<!-- ACTIONS -->
|
|
14
|
-
<div class="el-image-viewer__btn el-image-viewer__actions">
|
|
15
|
-
<div class="el-image-viewer__actions__inner">
|
|
16
|
-
<i class="el-icon-zoom-out" @click="handleActions('zoomOut')"></i>
|
|
17
|
-
<i class="el-icon-zoom-in" @click="handleActions('zoomIn')"></i>
|
|
18
|
-
<i class="el-image-viewer__actions__divider"></i>
|
|
19
|
-
<i :class="mode.icon" @click="toggleMode"></i>
|
|
20
|
-
<i class="el-image-viewer__actions__divider"></i>
|
|
21
|
-
<i class="el-icon-refresh-left" @click="handleActions('anticlocelise')"></i>
|
|
22
|
-
<i class="el-icon-refresh-right" @click="handleActions('clocelise')"></i>
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
<!-- CANVAS -->
|
|
26
|
-
<div class="el-image-viewer__canvas">
|
|
27
|
-
<img
|
|
28
|
-
v-for="(url, i) in urlArr"
|
|
29
|
-
v-if="i === index"
|
|
30
|
-
ref="img"
|
|
31
|
-
class="el-image-viewer__img"
|
|
32
|
-
:key="url"
|
|
33
|
-
:src="currentImg"
|
|
34
|
-
:style="imgStyle"
|
|
35
|
-
@load="handleImgLoad"
|
|
36
|
-
@error="handleImgError"
|
|
37
|
-
@mousedown="handleMouseDown"
|
|
38
|
-
/>
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
41
|
-
<div class="small">
|
|
42
|
-
<div class="swiper-container small-slide">
|
|
43
|
-
<div class="swiper-wrapper">
|
|
44
|
-
<div class="swiper-slide" v-for="(productImageDTO, pindex) in urlArr2" :key="productImageDTO + pindex" :class="{ on: swiperIndex == pindex }">
|
|
45
|
-
<img :src="productImageDTO" :data-bigsrc="pindex" />
|
|
46
|
-
</div>
|
|
47
|
-
</div>
|
|
48
|
-
<!-- 如果需要导航按钮 -->
|
|
49
|
-
<div class="swiper-button-prev"><i class="el-icon-arrow-left"></i></div>
|
|
50
|
-
<div class="swiper-button-next"><i class="el-icon-arrow-right"></i></div>
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
</transition>
|
|
55
|
-
</template>
|
|
56
|
-
|
|
57
|
-
<script>
|
|
58
|
-
import { on, off } from 'element-ui/src/utils/dom';
|
|
59
|
-
import { rafThrottle, isFirefox } from 'element-ui/src/utils/util';
|
|
60
|
-
import { PopupManager } from 'element-ui/src/utils/popup';
|
|
61
|
-
import Swiper from 'swiper';
|
|
62
|
-
import 'swiper/dist/css/swiper.min.css';
|
|
63
|
-
import 'swiper/dist/js/swiper.min';
|
|
64
|
-
const Mode = {
|
|
65
|
-
CONTAIN: {
|
|
66
|
-
name: 'contain',
|
|
67
|
-
icon: 'el-icon-full-screen'
|
|
68
|
-
},
|
|
69
|
-
ORIGINAL: {
|
|
70
|
-
name: 'original',
|
|
71
|
-
icon: 'el-icon-c-scale-to-original'
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const mousewheelEventName = isFirefox() ? 'DOMMouseScroll' : 'mousewheel';
|
|
76
|
-
|
|
77
|
-
export default {
|
|
78
|
-
name: 'elImageViewer',
|
|
79
|
-
|
|
80
|
-
props: {
|
|
81
|
-
urlList: {
|
|
82
|
-
type: Array,
|
|
83
|
-
default: () => []
|
|
84
|
-
},
|
|
85
|
-
zIndex: {
|
|
86
|
-
type: Number,
|
|
87
|
-
default: 9999
|
|
88
|
-
},
|
|
89
|
-
onSwitch: {
|
|
90
|
-
type: Function,
|
|
91
|
-
default: () => {}
|
|
92
|
-
},
|
|
93
|
-
onClose: {
|
|
94
|
-
type: Function,
|
|
95
|
-
default: () => {}
|
|
96
|
-
},
|
|
97
|
-
initialIndex: {
|
|
98
|
-
type: Number,
|
|
99
|
-
default: 0
|
|
100
|
-
},
|
|
101
|
-
appendToBody: {
|
|
102
|
-
type: Boolean,
|
|
103
|
-
default: true
|
|
104
|
-
},
|
|
105
|
-
maskClosable: {
|
|
106
|
-
type: Boolean,
|
|
107
|
-
default: true
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
data() {
|
|
112
|
-
return {
|
|
113
|
-
urlArr: [],
|
|
114
|
-
urlArr2: [],
|
|
115
|
-
index: this.initialIndex,
|
|
116
|
-
isShow: false,
|
|
117
|
-
infinite: true,
|
|
118
|
-
loading: false,
|
|
119
|
-
mode: Mode.CONTAIN,
|
|
120
|
-
transform: {
|
|
121
|
-
scale: 1,
|
|
122
|
-
deg: 0,
|
|
123
|
-
offsetX: 0,
|
|
124
|
-
offsetY: 0,
|
|
125
|
-
enableTransition: false
|
|
126
|
-
},
|
|
127
|
-
swiperIndex: 0,
|
|
128
|
-
swiper: null
|
|
129
|
-
};
|
|
130
|
-
},
|
|
131
|
-
computed: {
|
|
132
|
-
isSingle() {
|
|
133
|
-
return this.urlArr.length <= 1;
|
|
134
|
-
},
|
|
135
|
-
isFirst() {
|
|
136
|
-
return this.index === 0;
|
|
137
|
-
},
|
|
138
|
-
isLast() {
|
|
139
|
-
return this.index === this.urlArr.length - 1;
|
|
140
|
-
},
|
|
141
|
-
currentImg() {
|
|
142
|
-
return this.urlArr[this.index];
|
|
143
|
-
},
|
|
144
|
-
imgStyle() {
|
|
145
|
-
const { scale, deg, offsetX, offsetY, enableTransition } = this.transform;
|
|
146
|
-
const style = {
|
|
147
|
-
transform: `scale(${scale}) rotate(${deg}deg)`,
|
|
148
|
-
transition: enableTransition ? 'transform .3s' : '',
|
|
149
|
-
'margin-left': `${offsetX}px`,
|
|
150
|
-
'margin-top': `${offsetY}px`
|
|
151
|
-
};
|
|
152
|
-
if (this.mode === Mode.CONTAIN) {
|
|
153
|
-
style.maxWidth = style.maxHeight = '100%';
|
|
154
|
-
}
|
|
155
|
-
return style;
|
|
156
|
-
},
|
|
157
|
-
viewerZIndex() {
|
|
158
|
-
const nextZIndex = PopupManager.nextZIndex();
|
|
159
|
-
return this.zIndex > nextZIndex ? this.zIndex : nextZIndex;
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
watch: {
|
|
163
|
-
index: {
|
|
164
|
-
handler: function(val) {
|
|
165
|
-
this.reset();
|
|
166
|
-
this.onSwitch(val);
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
currentImg(val) {
|
|
170
|
-
this.$nextTick(_ => {
|
|
171
|
-
const $img = this.$refs.img[0];
|
|
172
|
-
if (!$img.complete) {
|
|
173
|
-
this.loading = true;
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
methods: {
|
|
179
|
-
getHandleImage(imageDto, flag) {
|
|
180
|
-
if (typeof imageDto == 'string') {
|
|
181
|
-
return imageDto;
|
|
182
|
-
} else {
|
|
183
|
-
if (flag == 1) {
|
|
184
|
-
return imageDto.domain + imageDto.url;
|
|
185
|
-
} else if (flag == 2) {
|
|
186
|
-
return imageDto.domain + (imageDto.medium || imageDto.url);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
hide() {
|
|
191
|
-
this.deviceSupportUninstall();
|
|
192
|
-
this.onClose();
|
|
193
|
-
},
|
|
194
|
-
deviceSupportInstall() {
|
|
195
|
-
this._keyDownHandler = e => {
|
|
196
|
-
e.stopPropagation();
|
|
197
|
-
const keyCode = e.keyCode;
|
|
198
|
-
switch (keyCode) {
|
|
199
|
-
// ESC
|
|
200
|
-
case 27:
|
|
201
|
-
this.hide();
|
|
202
|
-
break;
|
|
203
|
-
// SPACE
|
|
204
|
-
case 32:
|
|
205
|
-
this.toggleMode();
|
|
206
|
-
break;
|
|
207
|
-
// LEFT_ARROW
|
|
208
|
-
case 37:
|
|
209
|
-
this.prev();
|
|
210
|
-
break;
|
|
211
|
-
// UP_ARROW
|
|
212
|
-
case 38:
|
|
213
|
-
this.handleActions('zoomIn');
|
|
214
|
-
break;
|
|
215
|
-
// RIGHT_ARROW
|
|
216
|
-
case 39:
|
|
217
|
-
this.next();
|
|
218
|
-
break;
|
|
219
|
-
// DOWN_ARROW
|
|
220
|
-
case 40:
|
|
221
|
-
this.handleActions('zoomOut');
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
this._mouseWheelHandler = rafThrottle(e => {
|
|
226
|
-
const delta = e.wheelDelta ? e.wheelDelta : -e.detail;
|
|
227
|
-
if (delta > 0) {
|
|
228
|
-
this.handleActions('zoomIn', {
|
|
229
|
-
zoomRate: 0.015,
|
|
230
|
-
enableTransition: false
|
|
231
|
-
});
|
|
232
|
-
} else {
|
|
233
|
-
this.handleActions('zoomOut', {
|
|
234
|
-
zoomRate: 0.015,
|
|
235
|
-
enableTransition: false
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
on(document, 'keydown', this._keyDownHandler);
|
|
240
|
-
on(document, mousewheelEventName, this._mouseWheelHandler);
|
|
241
|
-
},
|
|
242
|
-
deviceSupportUninstall() {
|
|
243
|
-
off(document, 'keydown', this._keyDownHandler);
|
|
244
|
-
off(document, mousewheelEventName, this._mouseWheelHandler);
|
|
245
|
-
this._keyDownHandler = null;
|
|
246
|
-
this._mouseWheelHandler = null;
|
|
247
|
-
},
|
|
248
|
-
handleImgLoad(e) {
|
|
249
|
-
this.loading = false;
|
|
250
|
-
},
|
|
251
|
-
handleImgError(e) {
|
|
252
|
-
this.loading = false;
|
|
253
|
-
e.target.alt = '加载失败';
|
|
254
|
-
},
|
|
255
|
-
handleMouseDown(e) {
|
|
256
|
-
if (this.loading || e.button !== 0) return;
|
|
257
|
-
|
|
258
|
-
const { offsetX, offsetY } = this.transform;
|
|
259
|
-
const startX = e.pageX;
|
|
260
|
-
const startY = e.pageY;
|
|
261
|
-
this._dragHandler = rafThrottle(ev => {
|
|
262
|
-
this.transform.offsetX = offsetX + ev.pageX - startX;
|
|
263
|
-
this.transform.offsetY = offsetY + ev.pageY - startY;
|
|
264
|
-
});
|
|
265
|
-
on(document, 'mousemove', this._dragHandler);
|
|
266
|
-
on(document, 'mouseup', ev => {
|
|
267
|
-
off(document, 'mousemove', this._dragHandler);
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
e.preventDefault();
|
|
271
|
-
},
|
|
272
|
-
handleMaskClick() {
|
|
273
|
-
if (this.maskClosable) {
|
|
274
|
-
this.hide();
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
reset() {
|
|
278
|
-
this.transform = {
|
|
279
|
-
scale: 1,
|
|
280
|
-
deg: 0,
|
|
281
|
-
offsetX: 0,
|
|
282
|
-
offsetY: 0,
|
|
283
|
-
enableTransition: false
|
|
284
|
-
};
|
|
285
|
-
},
|
|
286
|
-
toggleMode() {
|
|
287
|
-
if (this.loading) return;
|
|
288
|
-
|
|
289
|
-
const modeNames = Object.keys(Mode);
|
|
290
|
-
const modeValues = Object.values(Mode);
|
|
291
|
-
const index = modeValues.indexOf(this.mode);
|
|
292
|
-
const nextIndex = (index + 1) % modeNames.length;
|
|
293
|
-
this.mode = Mode[modeNames[nextIndex]];
|
|
294
|
-
this.reset();
|
|
295
|
-
},
|
|
296
|
-
prev() {
|
|
297
|
-
if (this.isFirst && !this.infinite) return;
|
|
298
|
-
const len = this.urlArr.length;
|
|
299
|
-
this.index = (this.index - 1 + len) % len;
|
|
300
|
-
this.swiper.slideTo(this.index, 100);
|
|
301
|
-
this.swiperIndex = this.index;
|
|
302
|
-
},
|
|
303
|
-
next() {
|
|
304
|
-
if (this.isLast && !this.infinite) return;
|
|
305
|
-
const len = this.urlArr.length;
|
|
306
|
-
this.index = (this.index + 1) % len;
|
|
307
|
-
this.swiper.slideTo(this.index, 100);
|
|
308
|
-
this.swiperIndex = this.index;
|
|
309
|
-
},
|
|
310
|
-
handleActions(action, options = {}) {
|
|
311
|
-
if (this.loading) return;
|
|
312
|
-
const { zoomRate, rotateDeg, enableTransition } = {
|
|
313
|
-
zoomRate: 0.2,
|
|
314
|
-
rotateDeg: 90,
|
|
315
|
-
enableTransition: true,
|
|
316
|
-
...options
|
|
317
|
-
};
|
|
318
|
-
const { transform } = this;
|
|
319
|
-
let that = this;
|
|
320
|
-
switch (action) {
|
|
321
|
-
case 'zoomOut':
|
|
322
|
-
if (transform.scale > 0.2) {
|
|
323
|
-
transform.scale = parseFloat((transform.scale - zoomRate).toFixed(3));
|
|
324
|
-
}
|
|
325
|
-
break;
|
|
326
|
-
case 'zoomIn':
|
|
327
|
-
transform.scale = parseFloat((transform.scale + zoomRate).toFixed(3));
|
|
328
|
-
break;
|
|
329
|
-
case 'clocelise':
|
|
330
|
-
transform.deg += rotateDeg;
|
|
331
|
-
|
|
332
|
-
break;
|
|
333
|
-
case 'anticlocelise':
|
|
334
|
-
transform.deg -= rotateDeg;
|
|
335
|
-
break;
|
|
336
|
-
}
|
|
337
|
-
transform.enableTransition = enableTransition;
|
|
338
|
-
}
|
|
339
|
-
},
|
|
340
|
-
created() {
|
|
341
|
-
this.swiperIndex = this.index;
|
|
342
|
-
this.urlArr = this.urlList.map(imgDTO => {
|
|
343
|
-
return this.getHandleImage(imgDTO, 1);
|
|
344
|
-
});
|
|
345
|
-
this.urlArr2 = this.urlList.map(imgDTO => {
|
|
346
|
-
return this.getHandleImage(imgDTO, 2);
|
|
347
|
-
});
|
|
348
|
-
},
|
|
349
|
-
mounted() {
|
|
350
|
-
this.deviceSupportInstall();
|
|
351
|
-
if (this.appendToBody) {
|
|
352
|
-
document.body.appendChild(this.$el);
|
|
353
|
-
}
|
|
354
|
-
// add tabindex then wrapper can be focusable via Javascript
|
|
355
|
-
// focus wrapper so arrow key can't cause inner scroll behavior underneath
|
|
356
|
-
this.$refs['el-image-viewer__wrapper'].focus();
|
|
357
|
-
|
|
358
|
-
let that = this;
|
|
359
|
-
let ff = this.urlArr2;
|
|
360
|
-
setTimeout(function() {
|
|
361
|
-
that.swiper = new Swiper('.small-slide', {
|
|
362
|
-
slidesPerView: 'auto',
|
|
363
|
-
spaceBetween: 10,
|
|
364
|
-
// loop: true,
|
|
365
|
-
slideToClickedSlide: true,
|
|
366
|
-
navigation: {
|
|
367
|
-
nextEl: '.swiper-button-next',
|
|
368
|
-
prevEl: '.swiper-button-prev'
|
|
369
|
-
},
|
|
370
|
-
preventLinksProPagation: false,
|
|
371
|
-
on: {
|
|
372
|
-
click: function(event) {
|
|
373
|
-
let num = this.clickedIndex;
|
|
374
|
-
if (this.clickedIndex != undefined) {
|
|
375
|
-
that.index = Number(event.target.dataset.bigsrc);
|
|
376
|
-
that.swiperIndex = num;
|
|
377
|
-
} else {
|
|
378
|
-
console.log(event.target);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
}, 200);
|
|
384
|
-
},
|
|
385
|
-
destroyed() {
|
|
386
|
-
// if appendToBody is true, remove DOM node after destroy
|
|
387
|
-
if (this.appendToBody && this.$el && this.$el.parentNode) {
|
|
388
|
-
this.$el.parentNode.removeChild(this.$el);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
</script>
|
|
393
|
-
<style lang="scss" scoped>
|
|
394
|
-
.el-image-viewer__wrapper {
|
|
395
|
-
.big {
|
|
396
|
-
height: calc(100vh - 92px);
|
|
397
|
-
position: relative;
|
|
398
|
-
}
|
|
399
|
-
.small {
|
|
400
|
-
padding: 12px;
|
|
401
|
-
background: none !important;
|
|
402
|
-
.swiper-container {
|
|
403
|
-
padding: 0 28px;
|
|
404
|
-
.swiper-slide {
|
|
405
|
-
width: 72px;
|
|
406
|
-
height: 67.5px;
|
|
407
|
-
img {
|
|
408
|
-
height: 67px;
|
|
409
|
-
width: 100%;
|
|
410
|
-
cursor: pointer;
|
|
411
|
-
}
|
|
412
|
-
&.on img {
|
|
413
|
-
border: solid 2px #fec171;
|
|
414
|
-
height: 63px;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
.swiper-button-prev,
|
|
418
|
-
.swiper-button-next {
|
|
419
|
-
width: 22px;
|
|
420
|
-
height: 71.75px;
|
|
421
|
-
background: #ececec;
|
|
422
|
-
line-height: 71.75px;
|
|
423
|
-
text-align: center;
|
|
424
|
-
color: #666666;
|
|
425
|
-
font-size: 18px;
|
|
426
|
-
margin-top: 0;
|
|
427
|
-
top: 0;
|
|
428
|
-
opacity: 1;
|
|
429
|
-
&.swiper-button-disabled {
|
|
430
|
-
background: #ececec !important;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
.swiper-button-prev {
|
|
434
|
-
left: 0;
|
|
435
|
-
}
|
|
436
|
-
.swiper-button-next {
|
|
437
|
-
right: 0;
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<transition name="viewer-fade">
|
|
3
|
+
<div tabindex="-1" ref="el-image-viewer__wrapper" class="el-image-viewer__wrapper" :style="{ 'z-index': viewerZIndex }">
|
|
4
|
+
<div class="el-image-viewer__mask" @click.self="handleMaskClick"></div>
|
|
5
|
+
<!-- CLOSE -->
|
|
6
|
+
<span class="el-image-viewer__btn el-image-viewer__close" @click="hide"><i class="el-icon-close"></i></span>
|
|
7
|
+
<div class="big">
|
|
8
|
+
<!-- ARROW -->
|
|
9
|
+
<template v-if="!isSingle">
|
|
10
|
+
<span class="el-image-viewer__btn el-image-viewer__prev" :class="{ 'is-disabled': !infinite && isFirst }" @click="prev"><i class="el-icon-arrow-left" /></span>
|
|
11
|
+
<span class="el-image-viewer__btn el-image-viewer__next" :class="{ 'is-disabled': !infinite && isLast }" @click="next"><i class="el-icon-arrow-right" /></span>
|
|
12
|
+
</template>
|
|
13
|
+
<!-- ACTIONS -->
|
|
14
|
+
<div class="el-image-viewer__btn el-image-viewer__actions">
|
|
15
|
+
<div class="el-image-viewer__actions__inner">
|
|
16
|
+
<i class="el-icon-zoom-out" @click="handleActions('zoomOut')"></i>
|
|
17
|
+
<i class="el-icon-zoom-in" @click="handleActions('zoomIn')"></i>
|
|
18
|
+
<i class="el-image-viewer__actions__divider"></i>
|
|
19
|
+
<i :class="mode.icon" @click="toggleMode"></i>
|
|
20
|
+
<i class="el-image-viewer__actions__divider"></i>
|
|
21
|
+
<i class="el-icon-refresh-left" @click="handleActions('anticlocelise')"></i>
|
|
22
|
+
<i class="el-icon-refresh-right" @click="handleActions('clocelise')"></i>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
<!-- CANVAS -->
|
|
26
|
+
<div class="el-image-viewer__canvas">
|
|
27
|
+
<img
|
|
28
|
+
v-for="(url, i) in urlArr"
|
|
29
|
+
v-if="i === index"
|
|
30
|
+
ref="img"
|
|
31
|
+
class="el-image-viewer__img"
|
|
32
|
+
:key="url + '-' + i"
|
|
33
|
+
:src="currentImg"
|
|
34
|
+
:style="imgStyle"
|
|
35
|
+
@load="handleImgLoad"
|
|
36
|
+
@error="handleImgError"
|
|
37
|
+
@mousedown="handleMouseDown"
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
<div class="small">
|
|
42
|
+
<div class="swiper-container small-slide">
|
|
43
|
+
<div class="swiper-wrapper">
|
|
44
|
+
<div class="swiper-slide" v-for="(productImageDTO, pindex) in urlArr2" :key="productImageDTO + pindex" :class="{ on: swiperIndex == pindex }">
|
|
45
|
+
<img :src="productImageDTO" :data-bigsrc="pindex" />
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
<!-- 如果需要导航按钮 -->
|
|
49
|
+
<div class="swiper-button-prev"><i class="el-icon-arrow-left"></i></div>
|
|
50
|
+
<div class="swiper-button-next"><i class="el-icon-arrow-right"></i></div>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</transition>
|
|
55
|
+
</template>
|
|
56
|
+
|
|
57
|
+
<script>
|
|
58
|
+
import { on, off } from 'element-ui/src/utils/dom';
|
|
59
|
+
import { rafThrottle, isFirefox } from 'element-ui/src/utils/util';
|
|
60
|
+
import { PopupManager } from 'element-ui/src/utils/popup';
|
|
61
|
+
import Swiper from 'swiper';
|
|
62
|
+
import 'swiper/dist/css/swiper.min.css';
|
|
63
|
+
import 'swiper/dist/js/swiper.min';
|
|
64
|
+
const Mode = {
|
|
65
|
+
CONTAIN: {
|
|
66
|
+
name: 'contain',
|
|
67
|
+
icon: 'el-icon-full-screen'
|
|
68
|
+
},
|
|
69
|
+
ORIGINAL: {
|
|
70
|
+
name: 'original',
|
|
71
|
+
icon: 'el-icon-c-scale-to-original'
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const mousewheelEventName = isFirefox() ? 'DOMMouseScroll' : 'mousewheel';
|
|
76
|
+
|
|
77
|
+
export default {
|
|
78
|
+
name: 'elImageViewer',
|
|
79
|
+
|
|
80
|
+
props: {
|
|
81
|
+
urlList: {
|
|
82
|
+
type: Array,
|
|
83
|
+
default: () => []
|
|
84
|
+
},
|
|
85
|
+
zIndex: {
|
|
86
|
+
type: Number,
|
|
87
|
+
default: 9999
|
|
88
|
+
},
|
|
89
|
+
onSwitch: {
|
|
90
|
+
type: Function,
|
|
91
|
+
default: () => {}
|
|
92
|
+
},
|
|
93
|
+
onClose: {
|
|
94
|
+
type: Function,
|
|
95
|
+
default: () => {}
|
|
96
|
+
},
|
|
97
|
+
initialIndex: {
|
|
98
|
+
type: Number,
|
|
99
|
+
default: 0
|
|
100
|
+
},
|
|
101
|
+
appendToBody: {
|
|
102
|
+
type: Boolean,
|
|
103
|
+
default: true
|
|
104
|
+
},
|
|
105
|
+
maskClosable: {
|
|
106
|
+
type: Boolean,
|
|
107
|
+
default: true
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
data() {
|
|
112
|
+
return {
|
|
113
|
+
urlArr: [],
|
|
114
|
+
urlArr2: [],
|
|
115
|
+
index: this.initialIndex,
|
|
116
|
+
isShow: false,
|
|
117
|
+
infinite: true,
|
|
118
|
+
loading: false,
|
|
119
|
+
mode: Mode.CONTAIN,
|
|
120
|
+
transform: {
|
|
121
|
+
scale: 1,
|
|
122
|
+
deg: 0,
|
|
123
|
+
offsetX: 0,
|
|
124
|
+
offsetY: 0,
|
|
125
|
+
enableTransition: false
|
|
126
|
+
},
|
|
127
|
+
swiperIndex: 0,
|
|
128
|
+
swiper: null
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
computed: {
|
|
132
|
+
isSingle() {
|
|
133
|
+
return this.urlArr.length <= 1;
|
|
134
|
+
},
|
|
135
|
+
isFirst() {
|
|
136
|
+
return this.index === 0;
|
|
137
|
+
},
|
|
138
|
+
isLast() {
|
|
139
|
+
return this.index === this.urlArr.length - 1;
|
|
140
|
+
},
|
|
141
|
+
currentImg() {
|
|
142
|
+
return this.urlArr[this.index];
|
|
143
|
+
},
|
|
144
|
+
imgStyle() {
|
|
145
|
+
const { scale, deg, offsetX, offsetY, enableTransition } = this.transform;
|
|
146
|
+
const style = {
|
|
147
|
+
transform: `scale(${scale}) rotate(${deg}deg)`,
|
|
148
|
+
transition: enableTransition ? 'transform .3s' : '',
|
|
149
|
+
'margin-left': `${offsetX}px`,
|
|
150
|
+
'margin-top': `${offsetY}px`
|
|
151
|
+
};
|
|
152
|
+
if (this.mode === Mode.CONTAIN) {
|
|
153
|
+
style.maxWidth = style.maxHeight = '100%';
|
|
154
|
+
}
|
|
155
|
+
return style;
|
|
156
|
+
},
|
|
157
|
+
viewerZIndex() {
|
|
158
|
+
const nextZIndex = PopupManager.nextZIndex();
|
|
159
|
+
return this.zIndex > nextZIndex ? this.zIndex : nextZIndex;
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
watch: {
|
|
163
|
+
index: {
|
|
164
|
+
handler: function(val) {
|
|
165
|
+
this.reset();
|
|
166
|
+
this.onSwitch(val);
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
currentImg(val) {
|
|
170
|
+
this.$nextTick(_ => {
|
|
171
|
+
const $img = this.$refs.img[0];
|
|
172
|
+
if (!$img.complete) {
|
|
173
|
+
this.loading = true;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
methods: {
|
|
179
|
+
getHandleImage(imageDto, flag) {
|
|
180
|
+
if (typeof imageDto == 'string') {
|
|
181
|
+
return imageDto;
|
|
182
|
+
} else {
|
|
183
|
+
if (flag == 1) {
|
|
184
|
+
return imageDto.domain + imageDto.url;
|
|
185
|
+
} else if (flag == 2) {
|
|
186
|
+
return imageDto.domain + (imageDto.medium || imageDto.url);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
hide() {
|
|
191
|
+
this.deviceSupportUninstall();
|
|
192
|
+
this.onClose();
|
|
193
|
+
},
|
|
194
|
+
deviceSupportInstall() {
|
|
195
|
+
this._keyDownHandler = e => {
|
|
196
|
+
e.stopPropagation();
|
|
197
|
+
const keyCode = e.keyCode;
|
|
198
|
+
switch (keyCode) {
|
|
199
|
+
// ESC
|
|
200
|
+
case 27:
|
|
201
|
+
this.hide();
|
|
202
|
+
break;
|
|
203
|
+
// SPACE
|
|
204
|
+
case 32:
|
|
205
|
+
this.toggleMode();
|
|
206
|
+
break;
|
|
207
|
+
// LEFT_ARROW
|
|
208
|
+
case 37:
|
|
209
|
+
this.prev();
|
|
210
|
+
break;
|
|
211
|
+
// UP_ARROW
|
|
212
|
+
case 38:
|
|
213
|
+
this.handleActions('zoomIn');
|
|
214
|
+
break;
|
|
215
|
+
// RIGHT_ARROW
|
|
216
|
+
case 39:
|
|
217
|
+
this.next();
|
|
218
|
+
break;
|
|
219
|
+
// DOWN_ARROW
|
|
220
|
+
case 40:
|
|
221
|
+
this.handleActions('zoomOut');
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
this._mouseWheelHandler = rafThrottle(e => {
|
|
226
|
+
const delta = e.wheelDelta ? e.wheelDelta : -e.detail;
|
|
227
|
+
if (delta > 0) {
|
|
228
|
+
this.handleActions('zoomIn', {
|
|
229
|
+
zoomRate: 0.015,
|
|
230
|
+
enableTransition: false
|
|
231
|
+
});
|
|
232
|
+
} else {
|
|
233
|
+
this.handleActions('zoomOut', {
|
|
234
|
+
zoomRate: 0.015,
|
|
235
|
+
enableTransition: false
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
on(document, 'keydown', this._keyDownHandler);
|
|
240
|
+
on(document, mousewheelEventName, this._mouseWheelHandler);
|
|
241
|
+
},
|
|
242
|
+
deviceSupportUninstall() {
|
|
243
|
+
off(document, 'keydown', this._keyDownHandler);
|
|
244
|
+
off(document, mousewheelEventName, this._mouseWheelHandler);
|
|
245
|
+
this._keyDownHandler = null;
|
|
246
|
+
this._mouseWheelHandler = null;
|
|
247
|
+
},
|
|
248
|
+
handleImgLoad(e) {
|
|
249
|
+
this.loading = false;
|
|
250
|
+
},
|
|
251
|
+
handleImgError(e) {
|
|
252
|
+
this.loading = false;
|
|
253
|
+
e.target.alt = '加载失败';
|
|
254
|
+
},
|
|
255
|
+
handleMouseDown(e) {
|
|
256
|
+
if (this.loading || e.button !== 0) return;
|
|
257
|
+
|
|
258
|
+
const { offsetX, offsetY } = this.transform;
|
|
259
|
+
const startX = e.pageX;
|
|
260
|
+
const startY = e.pageY;
|
|
261
|
+
this._dragHandler = rafThrottle(ev => {
|
|
262
|
+
this.transform.offsetX = offsetX + ev.pageX - startX;
|
|
263
|
+
this.transform.offsetY = offsetY + ev.pageY - startY;
|
|
264
|
+
});
|
|
265
|
+
on(document, 'mousemove', this._dragHandler);
|
|
266
|
+
on(document, 'mouseup', ev => {
|
|
267
|
+
off(document, 'mousemove', this._dragHandler);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
e.preventDefault();
|
|
271
|
+
},
|
|
272
|
+
handleMaskClick() {
|
|
273
|
+
if (this.maskClosable) {
|
|
274
|
+
this.hide();
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
reset() {
|
|
278
|
+
this.transform = {
|
|
279
|
+
scale: 1,
|
|
280
|
+
deg: 0,
|
|
281
|
+
offsetX: 0,
|
|
282
|
+
offsetY: 0,
|
|
283
|
+
enableTransition: false
|
|
284
|
+
};
|
|
285
|
+
},
|
|
286
|
+
toggleMode() {
|
|
287
|
+
if (this.loading) return;
|
|
288
|
+
|
|
289
|
+
const modeNames = Object.keys(Mode);
|
|
290
|
+
const modeValues = Object.values(Mode);
|
|
291
|
+
const index = modeValues.indexOf(this.mode);
|
|
292
|
+
const nextIndex = (index + 1) % modeNames.length;
|
|
293
|
+
this.mode = Mode[modeNames[nextIndex]];
|
|
294
|
+
this.reset();
|
|
295
|
+
},
|
|
296
|
+
prev() {
|
|
297
|
+
if (this.isFirst && !this.infinite) return;
|
|
298
|
+
const len = this.urlArr.length;
|
|
299
|
+
this.index = (this.index - 1 + len) % len;
|
|
300
|
+
this.swiper.slideTo(this.index, 100);
|
|
301
|
+
this.swiperIndex = this.index;
|
|
302
|
+
},
|
|
303
|
+
next() {
|
|
304
|
+
if (this.isLast && !this.infinite) return;
|
|
305
|
+
const len = this.urlArr.length;
|
|
306
|
+
this.index = (this.index + 1) % len;
|
|
307
|
+
this.swiper.slideTo(this.index, 100);
|
|
308
|
+
this.swiperIndex = this.index;
|
|
309
|
+
},
|
|
310
|
+
handleActions(action, options = {}) {
|
|
311
|
+
if (this.loading) return;
|
|
312
|
+
const { zoomRate, rotateDeg, enableTransition } = {
|
|
313
|
+
zoomRate: 0.2,
|
|
314
|
+
rotateDeg: 90,
|
|
315
|
+
enableTransition: true,
|
|
316
|
+
...options
|
|
317
|
+
};
|
|
318
|
+
const { transform } = this;
|
|
319
|
+
let that = this;
|
|
320
|
+
switch (action) {
|
|
321
|
+
case 'zoomOut':
|
|
322
|
+
if (transform.scale > 0.2) {
|
|
323
|
+
transform.scale = parseFloat((transform.scale - zoomRate).toFixed(3));
|
|
324
|
+
}
|
|
325
|
+
break;
|
|
326
|
+
case 'zoomIn':
|
|
327
|
+
transform.scale = parseFloat((transform.scale + zoomRate).toFixed(3));
|
|
328
|
+
break;
|
|
329
|
+
case 'clocelise':
|
|
330
|
+
transform.deg += rotateDeg;
|
|
331
|
+
|
|
332
|
+
break;
|
|
333
|
+
case 'anticlocelise':
|
|
334
|
+
transform.deg -= rotateDeg;
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
transform.enableTransition = enableTransition;
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
created() {
|
|
341
|
+
this.swiperIndex = this.index;
|
|
342
|
+
this.urlArr = this.urlList.map(imgDTO => {
|
|
343
|
+
return this.getHandleImage(imgDTO, 1);
|
|
344
|
+
});
|
|
345
|
+
this.urlArr2 = this.urlList.map(imgDTO => {
|
|
346
|
+
return this.getHandleImage(imgDTO, 2);
|
|
347
|
+
});
|
|
348
|
+
},
|
|
349
|
+
mounted() {
|
|
350
|
+
this.deviceSupportInstall();
|
|
351
|
+
if (this.appendToBody) {
|
|
352
|
+
document.body.appendChild(this.$el);
|
|
353
|
+
}
|
|
354
|
+
// add tabindex then wrapper can be focusable via Javascript
|
|
355
|
+
// focus wrapper so arrow key can't cause inner scroll behavior underneath
|
|
356
|
+
this.$refs['el-image-viewer__wrapper'].focus();
|
|
357
|
+
|
|
358
|
+
let that = this;
|
|
359
|
+
let ff = this.urlArr2;
|
|
360
|
+
setTimeout(function() {
|
|
361
|
+
that.swiper = new Swiper('.small-slide', {
|
|
362
|
+
slidesPerView: 'auto',
|
|
363
|
+
spaceBetween: 10,
|
|
364
|
+
// loop: true,
|
|
365
|
+
slideToClickedSlide: true,
|
|
366
|
+
navigation: {
|
|
367
|
+
nextEl: '.swiper-button-next',
|
|
368
|
+
prevEl: '.swiper-button-prev'
|
|
369
|
+
},
|
|
370
|
+
preventLinksProPagation: false,
|
|
371
|
+
on: {
|
|
372
|
+
click: function(event) {
|
|
373
|
+
let num = this.clickedIndex;
|
|
374
|
+
if (this.clickedIndex != undefined) {
|
|
375
|
+
that.index = Number(event.target.dataset.bigsrc);
|
|
376
|
+
that.swiperIndex = num;
|
|
377
|
+
} else {
|
|
378
|
+
console.log(event.target);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}, 200);
|
|
384
|
+
},
|
|
385
|
+
destroyed() {
|
|
386
|
+
// if appendToBody is true, remove DOM node after destroy
|
|
387
|
+
if (this.appendToBody && this.$el && this.$el.parentNode) {
|
|
388
|
+
this.$el.parentNode.removeChild(this.$el);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
</script>
|
|
393
|
+
<style lang="scss" scoped>
|
|
394
|
+
.el-image-viewer__wrapper {
|
|
395
|
+
.big {
|
|
396
|
+
height: calc(100vh - 92px);
|
|
397
|
+
position: relative;
|
|
398
|
+
}
|
|
399
|
+
.small {
|
|
400
|
+
padding: 12px;
|
|
401
|
+
background: none !important;
|
|
402
|
+
.swiper-container {
|
|
403
|
+
padding: 0 28px;
|
|
404
|
+
.swiper-slide {
|
|
405
|
+
width: 72px;
|
|
406
|
+
height: 67.5px;
|
|
407
|
+
img {
|
|
408
|
+
height: 67px;
|
|
409
|
+
width: 100%;
|
|
410
|
+
cursor: pointer;
|
|
411
|
+
}
|
|
412
|
+
&.on img {
|
|
413
|
+
border: solid 2px #fec171;
|
|
414
|
+
height: 63px;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
.swiper-button-prev,
|
|
418
|
+
.swiper-button-next {
|
|
419
|
+
width: 22px;
|
|
420
|
+
height: 71.75px;
|
|
421
|
+
background: #ececec;
|
|
422
|
+
line-height: 71.75px;
|
|
423
|
+
text-align: center;
|
|
424
|
+
color: #666666;
|
|
425
|
+
font-size: 18px;
|
|
426
|
+
margin-top: 0;
|
|
427
|
+
top: 0;
|
|
428
|
+
opacity: 1;
|
|
429
|
+
&.swiper-button-disabled {
|
|
430
|
+
background: #ececec !important;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
.swiper-button-prev {
|
|
434
|
+
left: 0;
|
|
435
|
+
}
|
|
436
|
+
.swiper-button-next {
|
|
437
|
+
right: 0;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
</style>
|