eoss-ui 0.6.38 → 0.6.39

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.
Files changed (261) hide show
  1. package/lib/button-group.js +535 -374
  2. package/lib/button.js +535 -374
  3. package/lib/checkbox-group.js +536 -375
  4. package/lib/config/api.js +31 -19
  5. package/lib/data-table-form.js +547 -386
  6. package/lib/data-table.js +547 -382
  7. package/lib/date-picker.js +535 -374
  8. package/lib/dialog.js +535 -374
  9. package/lib/eoss-ui.common.js +11182 -4328
  10. package/lib/error-page.js +4 -4
  11. package/lib/flow-group.js +553 -377
  12. package/lib/flow-list.js +621 -460
  13. package/lib/flow.js +9822 -2988
  14. package/lib/form.js +540 -379
  15. package/lib/handle-user.js +536 -375
  16. package/lib/handler.js +536 -375
  17. package/lib/icon.js +536 -375
  18. package/lib/index.js +1 -1
  19. package/lib/input-number.js +535 -374
  20. package/lib/input.js +535 -374
  21. package/lib/layout.js +2 -2
  22. package/lib/login.js +550 -389
  23. package/lib/main.js +704 -543
  24. package/lib/nav.js +535 -374
  25. package/lib/notify.js +127 -109
  26. package/lib/page.js +535 -374
  27. package/lib/pagination.js +535 -374
  28. package/lib/player.js +535 -374
  29. package/lib/qr-code.js +548 -387
  30. package/lib/radio-group.js +536 -375
  31. package/lib/retrial-auth.js +538 -377
  32. package/lib/select-ganged.js +536 -375
  33. package/lib/select.js +536 -375
  34. package/lib/selector-panel.js +558 -396
  35. package/lib/selector.js +539 -378
  36. package/lib/sizer.js +541 -380
  37. package/lib/steps.js +535 -374
  38. package/lib/switch.js +535 -374
  39. package/lib/table-form.js +535 -374
  40. package/lib/tabs.js +539 -378
  41. package/lib/theme-chalk/flow.css +1 -1
  42. package/lib/theme-chalk/index.css +1 -1
  43. package/lib/tips.js +536 -375
  44. package/lib/tree-group.js +535 -374
  45. package/lib/tree.js +536 -375
  46. package/lib/upload.js +545 -384
  47. package/lib/utils/util.js +411 -268
  48. package/lib/wujie.js +535 -374
  49. package/lib/wxlogin.js +535 -374
  50. package/package.json +159 -158
  51. package/packages/button/index.js +5 -5
  52. package/packages/button/src/main.vue +418 -418
  53. package/packages/button-group/index.js +5 -5
  54. package/packages/button-group/src/main.vue +298 -298
  55. package/packages/calendar/index.js +5 -5
  56. package/packages/card/index.js +5 -5
  57. package/packages/card/src/main.vue +156 -156
  58. package/packages/cascader/index.js +5 -5
  59. package/packages/cascader/src/main.vue +168 -168
  60. package/packages/checkbox-group/index.js +5 -5
  61. package/packages/checkbox-group/src/main.vue +333 -333
  62. package/packages/clients/index.js +5 -5
  63. package/packages/clients/src/main.vue +144 -144
  64. package/packages/data-table/index.js +5 -5
  65. package/packages/data-table/src/children.vue +39 -39
  66. package/packages/data-table/src/column.vue +983 -983
  67. package/packages/data-table/src/main.vue +1820 -1816
  68. package/packages/data-table/src/sizer.vue +195 -195
  69. package/packages/data-table-form/index.js +5 -5
  70. package/packages/data-table-form/src/checkbox.vue +101 -101
  71. package/packages/data-table-form/src/colgroup.vue +17 -17
  72. package/packages/data-table-form/src/main.vue +181 -181
  73. package/packages/data-table-form/src/radio.vue +65 -65
  74. package/packages/data-table-form/src/table.vue +233 -233
  75. package/packages/data-table-form/src/tbody.vue +336 -336
  76. package/packages/data-table-form/src/thead.vue +68 -68
  77. package/packages/date-picker/index.js +5 -5
  78. package/packages/date-picker/src/main.vue +236 -236
  79. package/packages/dialog/index.js +5 -5
  80. package/packages/enterprise/index.js +5 -5
  81. package/packages/enterprise/src/main.vue +66 -66
  82. package/packages/error-page/index.js +5 -5
  83. package/packages/error-page/src/main.vue +44 -44
  84. package/packages/flow/index.js +5 -5
  85. package/packages/flow/src/component/CommonOpinions.vue +345 -341
  86. package/packages/flow/src/component/CustomPreset.vue +322 -322
  87. package/packages/flow/src/component/FileList.vue +99 -99
  88. package/packages/flow/src/component/Preset.vue +255 -255
  89. package/packages/flow/src/component/SendMsg.vue +229 -229
  90. package/packages/flow/src/component/TimeLimit.vue +190 -190
  91. package/packages/flow/src/component/taskUnionExamine.vue +603 -547
  92. package/packages/flow/src/form.vue +121 -121
  93. package/packages/flow/src/freeStartFlow.vue +2843 -0
  94. package/packages/flow/src/main.vue +2864 -2731
  95. package/packages/flow/src/processForm.vue +1007 -954
  96. package/packages/flow/src/processReject.vue +293 -293
  97. package/packages/flow/src/reset.vue +901 -0
  98. package/packages/flow/src/selectUser.vue +5 -0
  99. package/packages/flow/src/startTaskRead.vue +596 -596
  100. package/packages/flow/src/table.vue +58 -58
  101. package/packages/flow-group/index.js +5 -5
  102. package/packages/flow-group/src/main.vue +688 -684
  103. package/packages/flow-list/index.js +5 -5
  104. package/packages/flow-list/src/main.vue +1172 -1172
  105. package/packages/form/index.js +5 -5
  106. package/packages/form/src/main.vue +3584 -3584
  107. package/packages/form/src/table.vue +1420 -1420
  108. package/packages/handle-user/index.js +5 -5
  109. package/packages/handle-user/src/main.vue +138 -138
  110. package/packages/handler/index.js +5 -5
  111. package/packages/handler/src/main.vue +388 -388
  112. package/packages/icon/index.js +5 -5
  113. package/packages/icon/src/main.vue +101 -101
  114. package/packages/icons/index.js +5 -5
  115. package/packages/icons/src/main.vue +81 -81
  116. package/packages/input/index.js +5 -5
  117. package/packages/input/src/main.vue +356 -356
  118. package/packages/input-number/index.js +5 -5
  119. package/packages/input-number/src/main.vue +106 -106
  120. package/packages/label/index.js +5 -5
  121. package/packages/label/src/main.vue +457 -457
  122. package/packages/layout/index.js +5 -5
  123. package/packages/layout/src/item.vue +152 -152
  124. package/packages/layout/src/main.vue +31 -31
  125. package/packages/login/index.js +5 -5
  126. package/packages/login/src/main.vue +1892 -1894
  127. package/packages/login/src/resetPassword.vue +562 -562
  128. package/packages/main/index.js +5 -5
  129. package/packages/main/src/default/message.vue +249 -249
  130. package/packages/main/src/default/notice.vue +157 -157
  131. package/packages/main/src/default/userinfo.vue +505 -505
  132. package/packages/main/src/public/online.vue +89 -89
  133. package/packages/main/src/public/search.vue +454 -454
  134. package/packages/main/src/public/settings.vue +221 -221
  135. package/packages/main/src/simplicity/apps.vue +388 -388
  136. package/packages/main/src/simplicity/avatar.vue +82 -82
  137. package/packages/main/src/simplicity/handler.vue +221 -221
  138. package/packages/main/src/simplicity/index.vue +1993 -1993
  139. package/packages/main/src/simplicity/lists.vue +84 -84
  140. package/packages/main/src/simplicity/menu-list.vue +128 -128
  141. package/packages/main/src/simplicity/message.vue +259 -259
  142. package/packages/main/src/simplicity/notice.vue +190 -190
  143. package/packages/main/src/simplicity/router-page.vue +45 -45
  144. package/packages/main/src/simplicity/sub-menu.vue +241 -241
  145. package/packages/main/src/simplicity/user.vue +257 -257
  146. package/packages/main/src/simplicity/userinfo.vue +312 -312
  147. package/packages/menu/index.js +5 -5
  148. package/packages/menu/src/main.vue +536 -536
  149. package/packages/nav/index.js +5 -5
  150. package/packages/nav/src/main.vue +402 -402
  151. package/packages/notify/index.js +5 -5
  152. package/packages/notify/src/main.vue +538 -538
  153. package/packages/page/index.js +5 -5
  154. package/packages/page/src/main.vue +167 -167
  155. package/packages/pagination/index.js +5 -5
  156. package/packages/pagination/src/main.vue +96 -96
  157. package/packages/player/index.js +5 -5
  158. package/packages/player/src/main.vue +194 -194
  159. package/packages/qr-code/index.js +5 -5
  160. package/packages/qr-code/src/main.vue +170 -170
  161. package/packages/radio-group/index.js +6 -6
  162. package/packages/radio-group/src/main.vue +319 -319
  163. package/packages/retrial-auth/index.js +5 -5
  164. package/packages/retrial-auth/src/main.vue +280 -280
  165. package/packages/select/index.js +5 -5
  166. package/packages/select/src/main.vue +775 -775
  167. package/packages/select-ganged/index.js +5 -5
  168. package/packages/select-ganged/src/main.vue +724 -724
  169. package/packages/selector/index.js +5 -5
  170. package/packages/selector/src/main.vue +677 -677
  171. package/packages/selector-panel/index.js +5 -5
  172. package/packages/selector-panel/src/main.vue +1028 -1027
  173. package/packages/selector-panel/src/selection.vue +177 -177
  174. package/packages/selector-panel/src/tree.vue +129 -129
  175. package/packages/sizer/index.js +5 -5
  176. package/packages/sizer/src/main.vue +254 -254
  177. package/packages/steps/index.js +5 -5
  178. package/packages/steps/src/main.vue +181 -181
  179. package/packages/switch/index.js +5 -5
  180. package/packages/switch/src/main.vue +154 -154
  181. package/packages/table-form/index.js +5 -5
  182. package/packages/tabs/index.js +5 -5
  183. package/packages/tabs/src/main.vue +788 -788
  184. package/packages/tabs-panel/index.js +5 -5
  185. package/packages/tabs-panel/src/main.vue +29 -29
  186. package/packages/theme-chalk/lib/flow.css +1 -1
  187. package/packages/theme-chalk/lib/index.css +1 -1
  188. package/packages/theme-chalk/src/base.scss +260 -260
  189. package/packages/theme-chalk/src/button-group.scss +175 -175
  190. package/packages/theme-chalk/src/button.scss +24 -24
  191. package/packages/theme-chalk/src/calendar.scss +113 -113
  192. package/packages/theme-chalk/src/card.scss +99 -99
  193. package/packages/theme-chalk/src/checkbox-group.scss +8 -8
  194. package/packages/theme-chalk/src/clients.scss +87 -87
  195. package/packages/theme-chalk/src/data-table-form.scss +67 -67
  196. package/packages/theme-chalk/src/data-table.scss +293 -293
  197. package/packages/theme-chalk/src/date-picker.scss +7 -7
  198. package/packages/theme-chalk/src/dialog.scss +77 -77
  199. package/packages/theme-chalk/src/enterprise.scss +5 -5
  200. package/packages/theme-chalk/src/error-page.scss +18 -18
  201. package/packages/theme-chalk/src/flow-group.scss +110 -110
  202. package/packages/theme-chalk/src/flow-list.scss +36 -36
  203. package/packages/theme-chalk/src/flow.scss +310 -308
  204. package/packages/theme-chalk/src/form.scss +496 -496
  205. package/packages/theme-chalk/src/handle-user.scss +40 -40
  206. package/packages/theme-chalk/src/handler.scss +143 -143
  207. package/packages/theme-chalk/src/icon.scss +1760 -1760
  208. package/packages/theme-chalk/src/icons.scss +99 -99
  209. package/packages/theme-chalk/src/input.scss +9 -9
  210. package/packages/theme-chalk/src/label.scss +24 -24
  211. package/packages/theme-chalk/src/layout.scss +46 -46
  212. package/packages/theme-chalk/src/login.scss +939 -939
  213. package/packages/theme-chalk/src/main.scss +632 -632
  214. package/packages/theme-chalk/src/menu.scss +222 -222
  215. package/packages/theme-chalk/src/mixins/color.scss +117 -117
  216. package/packages/theme-chalk/src/nav.scss +125 -125
  217. package/packages/theme-chalk/src/page.scss +3 -3
  218. package/packages/theme-chalk/src/pagination.scss +29 -29
  219. package/packages/theme-chalk/src/player.scss +9 -9
  220. package/packages/theme-chalk/src/qr-code.scss +17 -17
  221. package/packages/theme-chalk/src/radio-group.scss +9 -9
  222. package/packages/theme-chalk/src/retrial-auth.scss +38 -38
  223. package/packages/theme-chalk/src/select-ganged.scss +8 -8
  224. package/packages/theme-chalk/src/select.scss +8 -8
  225. package/packages/theme-chalk/src/selector-panel.scss +204 -204
  226. package/packages/theme-chalk/src/selector.scss +91 -91
  227. package/packages/theme-chalk/src/simplicity.scss +1262 -1262
  228. package/packages/theme-chalk/src/sizer.scss +36 -36
  229. package/packages/theme-chalk/src/steps.scss +88 -88
  230. package/packages/theme-chalk/src/switch.scss +3 -3
  231. package/packages/theme-chalk/src/table-form.scss +1 -1
  232. package/packages/theme-chalk/src/tabs.scss +87 -87
  233. package/packages/theme-chalk/src/tips.scss +7 -7
  234. package/packages/theme-chalk/src/toolbar.scss +179 -179
  235. package/packages/theme-chalk/src/tree-group.scss +72 -72
  236. package/packages/theme-chalk/src/tree.scss +165 -165
  237. package/packages/theme-chalk/src/upload.scss +167 -167
  238. package/packages/theme-chalk/src/wxlogin.scss +3 -3
  239. package/packages/tips/index.js +5 -5
  240. package/packages/tips/src/main.vue +141 -141
  241. package/packages/toolbar/index.js +5 -5
  242. package/packages/toolbar/src/main.vue +430 -430
  243. package/packages/tree/index.js +5 -5
  244. package/packages/tree-group/index.js +5 -5
  245. package/packages/upload/index.js +5 -5
  246. package/packages/upload/src/main.vue +1334 -1334
  247. package/packages/upload/src/picture.js +15 -15
  248. package/packages/wujie/index.js +5 -5
  249. package/packages/wujie/src/main.vue +145 -145
  250. package/packages/wxlogin/index.js +5 -5
  251. package/packages/wxlogin/src/main.vue +128 -128
  252. package/src/config/api.js +248 -236
  253. package/src/config/image.js +2 -2
  254. package/src/index.js +1 -1
  255. package/src/utils/bus.js +3 -3
  256. package/src/utils/date-util.js +312 -312
  257. package/src/utils/http.js +50 -50
  258. package/src/utils/rules.js +18 -18
  259. package/src/utils/store.js +21 -21
  260. package/src/utils/util.js +398 -258
  261. package/src/utils/webSocket.js +107 -107
@@ -1,1334 +1,1334 @@
1
- <template>
2
- <el-upload
3
- v-if="isRender && uploadUrl"
4
- ref="upload"
5
- v-bind="$attrs"
6
- class="es-upload"
7
- :list-type="listType"
8
- :wait="1000"
9
- :height="boxHeight"
10
- :multiple="portrait ? false : multiple"
11
- :action="uploadUrl"
12
- :show-file-list="showList"
13
- :file-list="lists"
14
- :result-file="resultFile"
15
- :disabled="isDisabled || isReadonly"
16
- :readonly="isReadonly"
17
- :class="[
18
- {
19
- 'es-avatar-uploader': portrait && !$slots.default,
20
- 'es-upload-readonly': isReadonly && !downloads
21
- },
22
- 'es-upload-' + listType
23
- ]"
24
- :previewAdjunct="host + previewAdjunct"
25
- :headers="headers"
26
- :data="datas"
27
- :show-info="showList ? showInfo : []"
28
- :auto-upload="autoUpload"
29
- :response="true"
30
- :operate="operate"
31
- :accept="accepts"
32
- :drag-sort="isSort"
33
- :preview="preview"
34
- :exclude="excludes"
35
- :download="isDownload"
36
- :deleted="isRemove"
37
- :icons="_icons"
38
- :picture="_picture"
39
- :before-upload="handleBeforeUpload"
40
- :before-remove="handleBeforeRemove"
41
- :on-preview="handlePreview"
42
- :on-downloads="handleDownloads"
43
- :on-download="handleDownload"
44
- :on-sort="handleSort"
45
- :on-success="handleSuccess"
46
- :on-change="handleChange"
47
- :on-remove="handleRemove"
48
- :on-error="handleError"
49
- >
50
- <template v-if="prepend">
51
- <template v-if="Array.isArray(prepend)">
52
- <el-button
53
- v-for="(item, index) in prepend"
54
- v-bind="{ ...item, size: btnSize }"
55
- :key="index"
56
- @click.stop="handleClick(item)"
57
- >
58
- {{ item.label || item.text }}
59
- </el-button>
60
- </template>
61
- <el-button
62
- v-else
63
- v-bind="{ ...prepend, size: btnSize }"
64
- @click.stop="handleClick(prepend)"
65
- >
66
- {{ prepend.label || prepend.text }}
67
- </el-button>
68
- </template>
69
- <slot>
70
- <expand-dom v-if="render" :render="render"></expand-dom>
71
- <template v-else>
72
- <template v-if="portrait">
73
- <img
74
- v-if="profile"
75
- :src="profile"
76
- class="avatar"
77
- :style="{ width: width, height: height }"
78
- />
79
- <i
80
- v-else
81
- class="avatar-uploader-icon"
82
- :class="{ 'el-icon-plus': !isReadonly, 'is-disabled': isDisabled }"
83
- :style="{ width: width, height: height, lineHeight: height }"
84
- ></i>
85
- </template>
86
- <template v-else>
87
- <template v-if="!isReadonly">
88
- <i
89
- class="el-icon-plus es-uploader-icon"
90
- :class="{ 'is-disabled': isDisabled }"
91
- v-if="selectType === 'icon-plus'"
92
- ></i>
93
- <el-button
94
- v-else
95
- class="es-upload-button"
96
- :class="icon"
97
- :type="selectType"
98
- :size="btnSize"
99
- :disabled="isDisabled"
100
- >{{
101
- text ? text : autoUpload ? '点击上传' : '选择文件'
102
- }}</el-button
103
- >
104
- <el-button
105
- class="es-upload-button"
106
- v-if="!autoUpload"
107
- :type="uploadType"
108
- :size="btnSize"
109
- :disabled="isDisabled"
110
- @click.stop="handleUpload"
111
- >
112
- 上传文件
113
- </el-button>
114
- </template>
115
- <el-button
116
- v-if="showFileList && isDownloads"
117
- slot="handle"
118
- class="es-upload-button es-upload-downloads"
119
- :size="btnSize"
120
- @click.stop="handleDownloads"
121
- >
122
- 批量下载
123
- </el-button>
124
- </template>
125
- </template>
126
- </slot>
127
- <template v-if="append">
128
- <template v-if="Array.isArray(append)">
129
- <el-button
130
- v-for="(item, index) in append"
131
- v-bind="{ ...item, size: btnSize }"
132
- :key="index"
133
- @click.stop="handleClick(item)"
134
- >
135
- {{ item.label || item.text }}
136
- </el-button>
137
- </template>
138
- <el-button
139
- v-else
140
- v-bind="{ ...append, size: btnSize }"
141
- @click.stop="handleClick(append)"
142
- >
143
- {{ append.label || append.text }}
144
- </el-button>
145
- </template>
146
- <template slot="tip">
147
- <slot name="tip">
148
- <div v-if="tips" class="el-upload__tip">{{ tips }}</div>
149
- </slot>
150
- </template>
151
- <el-image-viewer
152
- slot="dialog"
153
- v-if="previewScale && showImg"
154
- :z-index="9999"
155
- :initial-index="0"
156
- :url-list="[imgUrl]"
157
- :on-close="closeViewer"
158
- ></el-image-viewer>
159
- <es-dialog v-else :title="title" :visible.sync="showImg" slot="dialog">
160
- <div
161
- v-loading="imgChange"
162
- element-loading-background="rgba(0, 0, 0, 0.8)"
163
- class="es-upload-dialog"
164
- >
165
- <img v-show="!imgChange" ref="showImg" :src="imgUrl" :style="styles" />
166
- </div>
167
- </es-dialog>
168
- <es-dialog :title="title" :visible.sync="showVideo" slot="dialog">
169
- <es-player
170
- autoplay
171
- type="video/mp4"
172
- :is-pause="!showVideo"
173
- :source="source"
174
- ></es-player>
175
- </es-dialog>
176
- </el-upload>
177
- </template>
178
- <script>
179
- import {
180
- getAdjunctProperties,
181
- uploads,
182
- uploadOnlyOne,
183
- getAdjunctFileInfos,
184
- uploadDownloads,
185
- previewAdjunctOffice,
186
- previewAdjunct,
187
- previewAdjunct2,
188
- uploadSort,
189
- delAdjunct,
190
- downloadByAdjunctId
191
- } from 'eoss-ui/src/config/api.js';
192
- import { debounce } from 'throttle-debounce';
193
- import util from 'eoss-ui/src/utils/util.js';
194
- import picture from './picture.js';
195
- import store from 'eoss-ui/src/utils/store';
196
- import { Base64 } from 'js-base64';
197
- export default {
198
- name: 'EsUpload',
199
- components: {
200
- expandDom: {
201
- functional: true,
202
- props: {
203
- render: [Function, String]
204
- },
205
- render: (h, ctx) => {
206
- if (typeof ctx.props.render == 'string') {
207
- try {
208
- return util.toFunction(ctx.props.render)(h, params);
209
- } catch (error) {
210
- throw error;
211
- }
212
- }
213
- return ctx.props.render(h);
214
- }
215
- }
216
- },
217
- inheritAttrs: false,
218
- inject: {
219
- elForm: {
220
- default: ''
221
- },
222
- elFormItem: {
223
- default: ''
224
- }
225
- },
226
- props: {
227
- prepend: [Array, Object],
228
- append: [Array, Object],
229
- render: Function,
230
- template: String,
231
- value: [String, Array, Object],
232
- name: String,
233
- method: {
234
- type: String,
235
- default: 'get'
236
- },
237
- text: String,
238
- icon: String,
239
- headers: {
240
- type: Object,
241
- default() {
242
- return util.getStorage();
243
- }
244
- },
245
- listType: {
246
- type: String,
247
- default: 'text' // text,picture,picture-card
248
- },
249
- operate: {
250
- type: Boolean,
251
- default: true
252
- },
253
- accept: String,
254
- // 附件code
255
- code: String,
256
- // 业务id
257
- ownId: String,
258
- //附件文档id
259
- documentId: String,
260
- requiredOwnId: {
261
- type: Boolean,
262
- default: true
263
- },
264
- //
265
- downloads: {
266
- type: Boolean,
267
- default: false
268
- },
269
- // 附件扩展编码
270
- extendCode: String,
271
- // 是否添加文件md5值
272
- fileMd5: {
273
- type: Boolean,
274
- default: false
275
- },
276
- // 额外的参数
277
- data: {
278
- type: Object,
279
- default() {
280
- return {};
281
- }
282
- },
283
- param: {
284
- type: Object,
285
- default() {
286
- return {};
287
- }
288
- },
289
- // 单文件大小
290
- size: Number,
291
- totalSize: Number,
292
- // 是否头像模式上传
293
- portrait: {
294
- type: Boolean,
295
- default: false
296
- },
297
- photo: [String, Boolean],
298
- //头像按钮框宽度
299
- width: String,
300
- //头像按钮框高度度
301
- height: String,
302
- // 自定义的文字提示
303
- tips: {
304
- type: String,
305
- default: ''
306
- },
307
- dragSort: {
308
- type: Boolean,
309
- default: false
310
- },
311
- // 上传成功后绑定到file的内容
312
- showInfo: {
313
- type: Array,
314
- default() {
315
- return ['uploadTime', 'fileSize', 'userName'];
316
- }
317
- },
318
- // 上传地址
319
- action: String,
320
- // 自动上传
321
- autoUpload: {
322
- type: Boolean,
323
- default: true
324
- },
325
- // 是否支持多选文件
326
- multiple: {
327
- type: Boolean,
328
- default: true
329
- },
330
- // 显示文件列表
331
- showFileList: {
332
- type: Boolean,
333
- default: true
334
- },
335
- // 上传的文件列表
336
- fileList: [Array, String],
337
- requestFiles: {
338
- type: Boolean,
339
- default: true
340
- },
341
- filesParam: {
342
- type: Object,
343
- default() {
344
- return {};
345
- }
346
- },
347
- state: {
348
- type: Number,
349
- default: 1
350
- },
351
- selectType: {
352
- type: String,
353
- default: 'primary'
354
- },
355
- uploadType: {
356
- type: String,
357
- default: 'success'
358
- },
359
- host: {
360
- type: String,
361
- default() {
362
- return util.getStorage('host') ? util.getStorage('host') : '';
363
- }
364
- },
365
- message: Object,
366
- btnSize: {
367
- type: String,
368
- default: 'medium'
369
- },
370
- // 只读
371
- readonly: {
372
- type: Boolean,
373
- default: false
374
- },
375
- disabled: Boolean,
376
- preview: { type: [Boolean, String], default: true },
377
- exclude: String,
378
- download: { type: [Boolean, String], default: true },
379
- deleted: { type: [Boolean, String], default: true },
380
- remove: { type: [Boolean, String], default: true },
381
- beforeUpload: Function,
382
- onPreview: Function,
383
- // 文件列表排序
384
- onSort: Function,
385
- beforeRemove: Function,
386
- onDownloads: Function,
387
- onDownload: Function,
388
- onSort: Function,
389
- onSuccess: Function,
390
- onChange: Function,
391
- onRemove: Function,
392
- onError: Function,
393
- dangerouslyUseHTMLString: Boolean,
394
- fileCount: Number,
395
- listHeight: String,
396
- display: Boolean,
397
- resultFile: {
398
- type: Boolean,
399
- default: true
400
- },
401
- properties: {
402
- type: String,
403
- default() {
404
- return getAdjunctProperties;
405
- }
406
- },
407
- icons: {
408
- type: Object,
409
- default() {
410
- return {};
411
- }
412
- },
413
- picture: {
414
- type: Object,
415
- default() {
416
- return {};
417
- }
418
- },
419
- previewScale: {
420
- type: Boolean,
421
- default: true
422
- },
423
- useCaseCode: String
424
- },
425
- data() {
426
- return {
427
- uploadUrl: this.action,
428
- lists: [],
429
- image: '',
430
- fileAccept: '',
431
- fileSize: 0,
432
- fileTotalSize: 0,
433
- filesTotalSize: 0,
434
- showImg: false,
435
- imgChange: false,
436
- title: '',
437
- imgUrl: '',
438
- styles: {},
439
- showVideo: false,
440
- videoChange: false,
441
- source: '',
442
- excludeNames: '',
443
- boxHeight: this.listHeight,
444
- previewAdjunct: previewAdjunct,
445
- kkfileview: null,
446
- dochubConfig: {}
447
- };
448
- },
449
- computed: {
450
- isRender() {
451
- let useCaseCodes = util.getStorage('useCaseCodes');
452
- if (useCaseCodes && this.useCaseCode) {
453
- return useCaseCodes.indexOf(this.useCaseCode) > -1;
454
- }
455
- return true;
456
- },
457
- _icons() {
458
- return {
459
- ppt: 'es-icon-ppt',
460
- png: 'es-icon-picture',
461
- gif: 'es-icon-picture',
462
- jpg: 'es-icon-picture',
463
- xls: 'es-icon-excel',
464
- xlsx: 'es-icon-excel',
465
- docx: 'es-icon-word',
466
- doc: 'es-icon-word',
467
- rar: 'es-icon-zip',
468
- zip: 'es-icon-zip',
469
- txt: 'es-icon-txt',
470
- ipa: 'es-icon-ios',
471
- apk: 'es-icon-android',
472
- mp4: 'es-icon-video',
473
- avi: 'es-icon-video',
474
- mp3: 'es-icon-audioo',
475
- wma: 'es-icon-audioo',
476
- pdf: 'es-icon-pdf',
477
- ...this.icons
478
- };
479
- },
480
- _picture() {
481
- return {
482
- ...picture,
483
- ...this.picture
484
- };
485
- },
486
- show() {
487
- if ((this.photo && typeof this.photo === 'string') || this.value) {
488
- return false;
489
- }
490
- return this.showFileList;
491
- },
492
- excludes() {
493
- return this.exclude ? this.exclude : this.excludeNames;
494
- },
495
- accepts() {
496
- return this.accept
497
- ? this.accept
498
- : this.fileAccept
499
- ? this.fileAccept
500
- : this.portrait
501
- ? 'image/*'
502
- : undefined;
503
- },
504
- _size() {
505
- return this.size ? this.size : this.fileSize ? this.fileSize : 0;
506
- },
507
- _totalSize() {
508
- return this.totalSize
509
- ? this.totalSize
510
- : this.fileTotalSize
511
- ? this.fileTotalSize
512
- : 0;
513
- },
514
- getAdjunctFileInfos() {
515
- return typeof this.fileList === 'string'
516
- ? this.fileList
517
- : getAdjunctFileInfos;
518
- },
519
- showList() {
520
- return this.portrait ? false : this.showFileList;
521
- },
522
- isDownloads() {
523
- return this.downloads;
524
- },
525
- isDownload() {
526
- if (this.download) {
527
- return true;
528
- }
529
- return false;
530
- },
531
- isDisabled() {
532
- return this.disabled || (this.elForm || {}).disabled;
533
- },
534
- isReadonly() {
535
- return this.readonly || (this.elForm || {}).readonly;
536
- },
537
- isRemove() {
538
- if (this.remove == false || this.deleted == false) {
539
- return false;
540
- }
541
- return true;
542
- },
543
- isSort() {
544
- // return this.dragSort && !this.isDisabled && this.isReadonly;
545
- return this.dragSort && !this.isDisabled;
546
- },
547
- datas() {
548
- if (this.data) {
549
- return util.extend({}, this.data, this.params);
550
- }
551
- return this.params;
552
- },
553
- params() {
554
- let params = { userId: util.getStorage('userId'), ...this.param };
555
- if (this.code !== undefined) {
556
- params.code = this.code;
557
- params.bucketCode = this.code;
558
- }
559
- if (this.ownId !== undefined) {
560
- params.ownId = this.ownId;
561
- params.businessId = this.ownId;
562
- }
563
- return params;
564
- },
565
- showMessage() {
566
- if (this.message !== undefined) {
567
- return util.extend({}, { success: true, error: true }, this.message);
568
- }
569
- return { success: true, error: true };
570
- },
571
- profile() {
572
- const previewAdjunct =
573
- this.dochubConfig.downloadDocumentUrl || this.previewAdjunct;
574
- if (this.image) {
575
- if (typeof this.image === 'string') {
576
- return this.image;
577
- }
578
- return `${this.host}${previewAdjunct}?documentId=${
579
- this.image.adjunctId
580
- }&adjunctId=${this.image.adjunctId}&_tt=${new Date().getTime()}`;
581
- }
582
- if (this.value) {
583
- if (typeof this.value === 'string') {
584
- if (this.value.indexOf('data:image/') === 0) {
585
- return this.value;
586
- } else if (this.value.indexOf(previewAdjunct) > -1) {
587
- let val =
588
- this.host +
589
- util.jointUrl({
590
- url: this.value,
591
- reg: '/main2'
592
- });
593
- return val;
594
- } else if (this.value.indexOf('/') === -1) {
595
- return `${this.host}${previewAdjunct}?documentId=${
596
- this.value
597
- }&adjunctId=${this.value}&_tt=${new Date().getTime()}`;
598
- }
599
- return this.value;
600
- } else if (Array.isArray(this.value)) {
601
- let adjunctId = this.value[0].response
602
- ? this.value[0].response.adjunctId
603
- : this.value[0].adjunctId;
604
- return `${
605
- this.host
606
- }${previewAdjunct}?documentId=${adjunctId}&adjunctId=${adjunctId}&_tt=${new Date().getTime()}`;
607
- } else {
608
- let adjunctId = this.value.response
609
- ? this.value.response.adjunctId
610
- : this.value.adjunctId;
611
- return `${
612
- this.host
613
- }${previewAdjunct}?documentId=${adjunctId}&adjunctId=${adjunctId}&_tt=${new Date().getTime()}`;
614
- }
615
- }
616
- if (this.photo && typeof this.photo === 'string') {
617
- if (this.photo.indexOf('data:image/') === 0) {
618
- return this.photo;
619
- } else if (this.photo.indexOf(previewAdjunct) > -1) {
620
- let val =
621
- this.host +
622
- util.jointUrl({
623
- url: this.value,
624
- reg: '/main2'
625
- });
626
- return val;
627
- } else if (this.photo.indexOf('/') === -1) {
628
- return `${this.host}${previewAdjunct}?documentId=${
629
- this.photo
630
- }&adjunctId=${this.photo}&_tt=${new Date().getTime()}`;
631
- }
632
- }
633
- return this.photo;
634
- }
635
- },
636
- watch: {
637
- fileList: {
638
- immediate: true,
639
- deep: true,
640
- handler(val) {
641
- if (Array.isArray(val) && val.length > 0) {
642
- this.lists = val;
643
- let filesTotalSize = 0;
644
- val.forEach((item) => {
645
- if (
646
- Object.prototype.hasOwnProperty.call(item, 'fileSize') &&
647
- item.fileSize
648
- ) {
649
- filesTotalSize += parseFloat(item.fileSize, 10);
650
- } else {
651
- filesTotalSize += item.size
652
- ? Math.round((item.size / 1024) * 10) / 10
653
- : 0;
654
- }
655
- });
656
- this.filesTotalSize = filesTotalSize;
657
- this.$emit('input', val);
658
- }
659
- }
660
- },
661
- value: {
662
- immediate: true,
663
- deep: true,
664
- handler(val) {
665
- if (val && typeof val === 'object' && this.showFileList) {
666
- if (Array.isArray(val)) {
667
- this.lists = val;
668
- } else {
669
- this.lists = [val];
670
- }
671
- }
672
- }
673
- },
674
- params: {
675
- deep: true,
676
- handler(val) {
677
- this.getFiles(val);
678
- }
679
- },
680
- lists: {
681
- deep: true,
682
- handler(val) {
683
- this.$emit('update:fileCount', val.length);
684
- }
685
- },
686
- display(val) {
687
- val && this.getHeight();
688
- }
689
- },
690
- beforeCreate() {
691
- this.getFiles = debounce(500, (params) => {
692
- this.getFileLists(params);
693
- });
694
- this.getAdjunctPropertie = debounce(500, () => {
695
- this.getAdjunctProperties();
696
- });
697
- },
698
- created() {
699
- const dochubConfig = sessionStorage.getItem('dochubConfig');
700
- if (dochubConfig) {
701
- this.dochubConfig = JSON.parse(dochubConfig);
702
- }
703
- this.getAdjunctPropertie();
704
- },
705
- mounted() {
706
- this.$nextTick(() => {
707
- this.getHeight();
708
- });
709
- },
710
- methods: {
711
- getHeight() {
712
- if (this.height === 'auto') {
713
- let pt =
714
- parseInt(util.getStyle(this.$el.parentNode, 'padding-top'), 10) || 0;
715
- let pb =
716
- parseInt(util.getStyle(this.$el.parentNode, 'padding-bottom'), 10) ||
717
- 0;
718
- let btn = this.$refs.upload
719
- ? this.$refs.upload.$children[0].$el.offsetHeight || 0
720
- : 0;
721
- this.boxHeight =
722
- this.$el.parentNode.offsetHeight - pt - pb - btn + 'px';
723
- }
724
- },
725
- //根据code获取附件参数配置
726
- getAdjunctProperties() {
727
- if (this.code !== undefined) {
728
- let config = store.get(this.code);
729
- if (config) {
730
- this.fileAccept = config.accept;
731
- this.fileSize = config.size;
732
- this.fileTotalSize = config.totalSize;
733
- if (config.dochubConfig) {
734
- this.dochubConfig = config.dochubConfig;
735
- }
736
-
737
- let url =
738
- this.portrait || this.documentId
739
- ? this.dochubConfig.reuploadDocumentUrl || uploadOnlyOne
740
- : this.dochubConfig.uploadDocumentUrl || uploads;
741
- this.uploadUrl = url.indexOf(this.host) > -1 ? url : this.host + url;
742
- this.requestFiles && this.getFiles(this.params);
743
- } else {
744
- util
745
- .ajax({
746
- method: this.method,
747
- url: this.properties,
748
- data: { code: this.code, ...this.param },
749
- params: { code: this.code, ...this.param }
750
- })
751
- .then((res) => {
752
- if (res.rCode === 0) {
753
- if (res.results) {
754
- this.excludeNames = res.results.excludeName;
755
- if (res.results.fileTypeExtName) {
756
- let fileTypeExtName =
757
- res.results.fileTypeExtName.split(';');
758
- this.fileAccept = fileTypeExtName
759
- .filter((item) => {
760
- return item;
761
- })
762
- .join(',');
763
- }
764
- if (res.results.dochubConfig) {
765
- this.dochubConfig = res.results.dochubConfig;
766
- sessionStorage.setItem(
767
- 'dochubConfig',
768
- JSON.stringify(res.results.dochubConfig)
769
- );
770
- }
771
- let url = this.portrait
772
- ? this.dochubConfig.reuploadDocumentUrl || uploadOnlyOne
773
- : this.dochubConfig.uploadDocumentUrl || uploads;
774
- this.uploadUrl =
775
- url.indexOf(this.host) > -1 ? url : this.host + url;
776
- if (res.results.kkViewRootPath) {
777
- this.kkfileview = res.results.kkViewRootPath;
778
- }
779
- this.fileSize = res.results.limitFileSize
780
- ? res.results.limitFileSize
781
- : 0;
782
- this.fileTotalSize = res.results.limitTotalSize;
783
- store.set(this.code, {
784
- accept: this.fileAccept,
785
- size: this.fileSize,
786
- totalSize: this.fileTotalSize,
787
- dochubConfig: this.dochubConfig
788
- });
789
- }
790
- this.requestFiles && this.getFiles(this.params);
791
- }
792
- })
793
- .catch((err) => {
794
- if (err.message && err.message !== 'canceled') {
795
- this.$message.error(err.message);
796
- }
797
- });
798
- }
799
- }
800
- },
801
- getFileLists(params) {
802
- if (
803
- !this.show ||
804
- (this.fileList &&
805
- Array.isArray(this.fileList) &&
806
- this.fileList.length) ||
807
- (this.requiredOwnId &&
808
- !Object.prototype.hasOwnProperty.call(params, 'ownId'))
809
- ) {
810
- return false;
811
- }
812
- let url =
813
- typeof this.fileList === 'string'
814
- ? this.fileList
815
- : this.dochubConfig.getDocumentList
816
- ? this.dochubConfig.getDocumentList
817
- : getAdjunctFileInfos;
818
- util
819
- .ajax({
820
- method: this.method,
821
- url: url,
822
- data: params,
823
- params: params,
824
- format: false
825
- })
826
- .then((res) => {
827
- if (res.rCode === 0) {
828
- if (this.portrait === true) {
829
- this.image = JSON.parse(JSON.stringify(res.results))[0];
830
- } else {
831
- this.lists = JSON.parse(JSON.stringify(res.results));
832
- let filesTotalSize = 0;
833
- this.lists.forEach((item) => {
834
- if (
835
- Object.prototype.hasOwnProperty.call(item, 'fileSize') &&
836
- item.fileSize
837
- ) {
838
- filesTotalSize += parseFloat(item.fileSize, 10);
839
- } else {
840
- filesTotalSize += item.size
841
- ? Math.round((item.size / 1024) * 10) / 10
842
- : 0;
843
- }
844
- });
845
- this.filesTotalSize = filesTotalSize;
846
- if (this.lists.length) {
847
- this.$emit('input', this.lists);
848
- }
849
- }
850
- } else {
851
- let msg = res.msg || '系统错误,请联系管理员!';
852
- this.$message.error(msg);
853
- }
854
- })
855
- .catch((err) => {
856
- if (err.message && err.message !== 'canceled') {
857
- this.$message.error(err.message);
858
- }
859
- });
860
- },
861
- handleUpload() {
862
- this.$refs.upload.submit();
863
- },
864
- openKkfileview(file) {
865
- let host = util.win.location.origin;
866
- if (this.host) {
867
- if (util.startWith(this.host, 'http')) {
868
- host = this.host;
869
- } else {
870
- host += this.host;
871
- }
872
- }
873
- let url = encodeURIComponent(
874
- Base64.encode(
875
- host +
876
- (typeof this.download === 'string'
877
- ? this.download
878
- : downloadByAdjunctId) +
879
- `?adjunctId=${
880
- file.adjunctId || file.response.adjunctId
881
- }&fullfilename=${file.originalName}`
882
- )
883
- );
884
- util.win.open(`${this.kkfileview}?url=${url}`);
885
- },
886
- handlePreview(res) {
887
- if (this.preview) {
888
- if (this.onPreview) {
889
- this.onPreview(res);
890
- } else {
891
- let file = res.response ? res.response : res;
892
- let url =
893
- typeof this.preview === 'string'
894
- ? this.preview
895
- : typeof this.preview === 'function'
896
- ? this.preview(file)
897
- : null;
898
- if (res.status === 'success') {
899
- let suffix = file.suffix;
900
- suffix = suffix.toLowerCase();
901
- if (this.dochubConfig.previewDocumentUrl) {
902
- if (
903
- suffix.includes('jpge') ||
904
- suffix.includes('jpg') ||
905
- suffix.includes('gif') ||
906
- suffix.includes('png')
907
- ) {
908
- this.imgUrl =
909
- res.url && util.startWith(url, ['http', '/', true])
910
- ? res.url
911
- : this.host +
912
- (url
913
- ? url
914
- : `${this.dochubConfig.downloadDocumentUrl}?documentId=${file.adjunctId}`);
915
- this.title = file.originalName;
916
- this.showImg = true;
917
- this.$nextTick(() => {
918
- this.loadImage();
919
- });
920
- } else if (suffix.includes('mp4')) {
921
- this.source = {
922
- src:
923
- this.host +
924
- (url
925
- ? url
926
- : `${this.dochubConfig.downloadDocumentUrl}?documentId=${file.adjunctId}`)
927
- };
928
- this.title = file.originalName;
929
- this.showVideo = true;
930
- } else {
931
- util.win.open(
932
- this.host +
933
- (url
934
- ? url
935
- : `${this.dochubConfig.previewDocumentUrl}?documentId=${file.adjunctId}&action=附件预览`)
936
- );
937
- }
938
- } else {
939
- if (
940
- suffix.includes('doc') ||
941
- suffix.includes('docx') ||
942
- suffix.includes('xls') ||
943
- suffix.includes('xlsx') ||
944
- suffix.includes('ppt')
945
- ) {
946
- if (this.kkfileview) {
947
- this.openKkfileview(file);
948
- } else {
949
- util.win.open(
950
- this.host +
951
- (url ? url : previewAdjunctOffice) +
952
- '?cmd=view&bucketName=' +
953
- file.absolutePath +
954
- '&fileId=' +
955
- file.adjunctId +
956
- '&fileName=' +
957
- file.newName
958
- );
959
- }
960
- } else if (suffix.includes('pdf')) {
961
- if (this.kkfileview) {
962
- this.openKkfileview(file);
963
- } else {
964
- util.win.open(
965
- this.host +
966
- (url ? url : previewAdjunct2) +
967
- '/' +
968
- file.originalName +
969
- '?adjunctId=' +
970
- file.adjunctId
971
- );
972
- }
973
- } else if (
974
- suffix.includes('jpge') ||
975
- suffix.includes('jpg') ||
976
- suffix.includes('gif') ||
977
- suffix.includes('png')
978
- ) {
979
- this.imgUrl =
980
- res.url && util.startWith(url, ['http', '/', true])
981
- ? res.url
982
- : this.host +
983
- (url ? url : this.previewAdjunct) +
984
- '?adjunctId=' +
985
- file.adjunctId;
986
- this.title = file.originalName;
987
- this.showImg = true;
988
- this.$nextTick(() => {
989
- this.loadImage();
990
- });
991
- } else if (suffix.includes('mp4')) {
992
- this.source = {
993
- src:
994
- this.host +
995
- (url ? url : this.previewAdjunct) +
996
- '?adjunctId=' +
997
- file.adjunctId
998
- };
999
- this.title = file.originalName;
1000
- this.showVideo = true;
1001
- } else {
1002
- if (this.kkfileview) {
1003
- this.openKkfileview(file);
1004
- } else {
1005
- util.win.open(
1006
- this.host +
1007
- (url ? url : this.previewAdjunct) +
1008
- '?adjunctId=' +
1009
- file.adjunctId
1010
- );
1011
- }
1012
- }
1013
- }
1014
- } else {
1015
- util.win.open(URL.createObjectURL(file.raw));
1016
- }
1017
- }
1018
- }
1019
- },
1020
- closeViewer() {
1021
- this.showImg = false;
1022
- },
1023
- loadImage() {
1024
- this.$refs.showImg &&
1025
- (this.$refs.showImg.onload = () => {
1026
- this.imgChange = false;
1027
- let w = this.$refs.showImg.naturalWidth;
1028
- let h = this.$refs.showImg.naturalHeight;
1029
- let pw = this.$refs.showImg.parentNode.offsetWidth;
1030
- let ph = this.$refs.showImg.parentNode.offsetHeight;
1031
- if (w / h > pw / ph) {
1032
- this.styles = { 'max-width': '100%' };
1033
- } else {
1034
- this.styles = { 'max-height': '100%' };
1035
- }
1036
- if (w < pw) {
1037
- this.styles.width = w + 'px';
1038
- }
1039
- if (h < ph) {
1040
- this.styles.height = h + 'px';
1041
- }
1042
- });
1043
- },
1044
- isLt(file) {
1045
- let flag = false;
1046
- let flieArr = file.name.split('.');
1047
- let suffix = '.' + flieArr[flieArr.length - 1].toLowerCase();
1048
- if (this.accepts) {
1049
- let accepts = this.accepts.toLowerCase().split(',');
1050
- flag = accepts.includes(suffix);
1051
- if (!flag) {
1052
- this.$message.error(`文件类型错误,请上传${this.accepts}类型文件!`);
1053
- return flag;
1054
- }
1055
- }
1056
- let size = this._size;
1057
- let text = '单个附件';
1058
- let se = Math.round((file.size / 1024) * 10) / 10;
1059
- if (this._size === 0 && this._totalSize === 0) {
1060
- flag = true;
1061
- } else if (this._size > 0 && this._totalSize === 0) {
1062
- flag = se < this._size;
1063
- size = this._size;
1064
- text = '单个附件';
1065
- } else if (this._size === 0 && this._totalSize > 0) {
1066
- flag = this.filesTotalSize + se < this._totalSize;
1067
- size = this._totalSize;
1068
- text = '附件总';
1069
- } else {
1070
- flag = se < this._size && this.filesTotalSize + se < this._totalSize;
1071
- if (se < this._size) {
1072
- size = this._size;
1073
- text = '单个附件';
1074
- } else {
1075
- size = this._totalSize;
1076
- text = '附件总';
1077
- }
1078
- }
1079
- if (!flag) {
1080
- this.$message.error(`上传${text}大小不能超过${size}KB!`);
1081
- return flag;
1082
- }
1083
- return flag;
1084
- },
1085
- handleBeforeUpload(file) {
1086
- const flag = this.isLt(file);
1087
- if (this.portrait) {
1088
- if (flag && this.beforeUpload) {
1089
- return this.beforeUpload(file);
1090
- }
1091
- return flag;
1092
- }
1093
- if (this.beforeUpload) {
1094
- if (flag) {
1095
- return this.beforeUpload(file);
1096
- }
1097
- return flag;
1098
- }
1099
- return flag;
1100
- },
1101
- handleBeforeRemove(file, fileList) {
1102
- if (file && file.status === 'success') {
1103
- return this.$confirm('确定删除文件吗?', '提示', {
1104
- confirmButtonText: '确定',
1105
- cancelButtonText: '取消',
1106
- type: 'warning'
1107
- })
1108
- .then(() => {
1109
- if (this.beforeRemove) {
1110
- return this.beforeRemove(file, fileList);
1111
- } else if (file.status === 'success') {
1112
- let userName =
1113
- file.userName ||
1114
- (file.response && file.response.userName) ||
1115
- util.getStorage('userName');
1116
- // eslint-disable-next-line no-undef
1117
- return new Promise((resolve, reject) => {
1118
- let url =
1119
- typeof this.deleted === 'string'
1120
- ? this.deleted
1121
- : this.remove === 'string'
1122
- ? this.remove
1123
- : this.dochubConfig.deleteDocumentUrl || delAdjunct;
1124
- util
1125
- .ajax({
1126
- method: this.method,
1127
- url: url,
1128
- data: {
1129
- userName: userName,
1130
- documentId: file.adjunctId || file.response.adjunctId,
1131
- id: file.adjunctId || file.response.adjunctId
1132
- },
1133
- params: {
1134
- userName: userName,
1135
- documentId: file.adjunctId || file.response.adjunctId,
1136
- id: file.adjunctId || file.response.adjunctId
1137
- }
1138
- })
1139
- .then((res) => {
1140
- if (res.rCode === 0) {
1141
- let se =
1142
- this.filesTotalSize -
1143
- Math.round((file.size / 1024) * 10) / 10;
1144
- this.filesTotalSize = se;
1145
- this.$message.success(res.msg);
1146
- resolve();
1147
- } else {
1148
- let msg = res.msg || '系统错误,请联系管理员!';
1149
- this.$message.error(msg);
1150
- reject();
1151
- }
1152
- })
1153
- .catch((err) => {
1154
- if (err.message && err.message !== 'canceled') {
1155
- this.$message.error(err.message);
1156
- }
1157
- });
1158
- });
1159
- }
1160
- return true;
1161
- })
1162
- .catch(() => {
1163
- return flag;
1164
- });
1165
- }
1166
- },
1167
- handleDownloads() {
1168
- let url =
1169
- typeof this.downloads === 'string'
1170
- ? this.downloads
1171
- : this.dochubConfig.compressDownloadDocumentUrl || uploadDownloads;
1172
- util.win.open(
1173
- this.host +
1174
- url +
1175
- '?ownId=' +
1176
- this.ownId +
1177
- '&code=' +
1178
- this.code +
1179
- (this.extendCode ? '&extendCode=' + this.extendCode : '')
1180
- );
1181
- },
1182
- handleDownload(file) {
1183
- if (file.status === 'success') {
1184
- let url =
1185
- typeof this.download === 'string'
1186
- ? this.download
1187
- : this.dochubConfig.downloadDocumentUrl || downloadByAdjunctId;
1188
- util.win.open(
1189
- this.host +
1190
- url +
1191
- '?adjunctId=' +
1192
- (file.adjunctId || file.response.adjunctId) +
1193
- '&documentId=' +
1194
- (file.adjunctId || file.response.adjunctId)
1195
- );
1196
- } else {
1197
- this.aLinkDownload(file);
1198
- }
1199
- },
1200
- handleClick(res) {
1201
- if (res.event && typeof res.event === 'function') {
1202
- res.event(res);
1203
- } else {
1204
- this.$emit('click', res);
1205
- }
1206
- },
1207
- aLinkDownload(file) {
1208
- var a = document.createElement('a');
1209
- let event = new MouseEvent('click');
1210
- a.href = URL.createObjectURL(file.raw);
1211
- a.download = file.name;
1212
- a.dispatchEvent(event);
1213
- },
1214
- handleSort(files) {
1215
- if (this.isSort) {
1216
- if (this.onSort) {
1217
- this.onSort(files);
1218
- } else {
1219
- let ids = files.map((item) => {
1220
- if (item.status === 'success') {
1221
- return item.adjunctId || item.response.adjunctId;
1222
- }
1223
- });
1224
- ids = ids.join(',');
1225
- util
1226
- .ajax({
1227
- method: this.method,
1228
- url: this.dochubConfig.sortDocumentsUrl || uploadSort,
1229
- data: {
1230
- ids: ids,
1231
- documentIds: ids,
1232
- ownId: this.ownId,
1233
- code: this.code,
1234
- bucketCode: this.code,
1235
- businessId: this.ownId
1236
- },
1237
- params: {
1238
- ids: ids,
1239
- documentIds: ids,
1240
- ownId: this.ownId,
1241
- code: this.code,
1242
- bucketCode: this.code,
1243
- businessId: this.ownId
1244
- }
1245
- })
1246
- .then((res) => {
1247
- if (res.rCode === 0) {
1248
- this.$message.success(res.msg);
1249
- } else {
1250
- let msg = res.msg || '系统错误,请联系管理员!';
1251
- this.$message.error(msg);
1252
- }
1253
- })
1254
- .catch((err) => {
1255
- if (err.message && err.message !== 'canceled') {
1256
- this.$message.error(err.message);
1257
- }
1258
- });
1259
- }
1260
- }
1261
- },
1262
- handleSuccess(response, file, fileList) {
1263
- if (this.portrait) {
1264
- this.image = URL.createObjectURL(file.raw);
1265
- }
1266
- if (this.showMessage.success) {
1267
- if (response.rCode) {
1268
- if (this.dangerouslyUseHTMLString) {
1269
- this.$alert(
1270
- response.msg ? response.msg : '上传失败:请联系管理员',
1271
- '提示',
1272
- {
1273
- dangerouslyUseHTMLString: true,
1274
- setHeight: response.msg
1275
- }
1276
- ).catch();
1277
- } else {
1278
- this.$message({
1279
- type: 'error',
1280
- message: response.msg || '成功!'
1281
- });
1282
- }
1283
- } else {
1284
- this.$message.success(response.msg);
1285
- }
1286
- }
1287
- let se =
1288
- this.filesTotalSize +
1289
- (this.resultFile ? Math.round((file.size / 1024) * 10) / 10 : 0);
1290
- this.filesTotalSize = se;
1291
- this.onSuccess &&
1292
- this.onSuccess(response, file, fileList, this.dochubConfig);
1293
- this.$emit('success', response, file, fileList, this.dochubConfig);
1294
- if (this.resultFile) {
1295
- if (this.portrait) {
1296
- this.$emit('input', file);
1297
- } else {
1298
- this.$emit('input', fileList);
1299
- }
1300
- if (this.elForm) {
1301
- this.elForm.clearValidate(this.name);
1302
- }
1303
- }
1304
- },
1305
- handleChange(file, fileList) {
1306
- this.$emit('change', fileList);
1307
- this.onChange && this.onChange(file, fileList);
1308
- },
1309
- handleRemove(file, fileList) {
1310
- this.$emit('input', fileList.length ? fileList : '');
1311
- this.$emit('remove', file, fileList);
1312
- this.$emit('change', fileList);
1313
- this.onRemove && this.onRemove(file, fileList);
1314
- },
1315
- handleError(err, file, fileList) {
1316
- if (this.showMessage.error) {
1317
- if (this.dangerouslyUseHTMLString) {
1318
- this.$alert(err.msg ? err.msg : '上传失败:请联系管理员', '提示', {
1319
- dangerouslyUseHTMLString: true,
1320
- setHeight: err.msg
1321
- }).catch();
1322
- } else {
1323
- this.$message({
1324
- type: 'error',
1325
- message: '上传失败:' + (err.msg ? err.msg : '请联系管理员')
1326
- });
1327
- }
1328
- }
1329
- this.$emit('error', err, file, fileList);
1330
- this.onError && this.onError(err, file, fileList);
1331
- }
1332
- }
1333
- };
1334
- </script>
1
+ <template>
2
+ <el-upload
3
+ v-if="isRender && uploadUrl"
4
+ ref="upload"
5
+ v-bind="$attrs"
6
+ class="es-upload"
7
+ :list-type="listType"
8
+ :wait="1000"
9
+ :height="boxHeight"
10
+ :multiple="portrait ? false : multiple"
11
+ :action="uploadUrl"
12
+ :show-file-list="showList"
13
+ :file-list="lists"
14
+ :result-file="resultFile"
15
+ :disabled="isDisabled || isReadonly"
16
+ :readonly="isReadonly"
17
+ :class="[
18
+ {
19
+ 'es-avatar-uploader': portrait && !$slots.default,
20
+ 'es-upload-readonly': isReadonly && !downloads
21
+ },
22
+ 'es-upload-' + listType
23
+ ]"
24
+ :previewAdjunct="host + previewAdjunct"
25
+ :headers="headers"
26
+ :data="datas"
27
+ :show-info="showList ? showInfo : []"
28
+ :auto-upload="autoUpload"
29
+ :response="true"
30
+ :operate="operate"
31
+ :accept="accepts"
32
+ :drag-sort="isSort"
33
+ :preview="preview"
34
+ :exclude="excludes"
35
+ :download="isDownload"
36
+ :deleted="isRemove"
37
+ :icons="_icons"
38
+ :picture="_picture"
39
+ :before-upload="handleBeforeUpload"
40
+ :before-remove="handleBeforeRemove"
41
+ :on-preview="handlePreview"
42
+ :on-downloads="handleDownloads"
43
+ :on-download="handleDownload"
44
+ :on-sort="handleSort"
45
+ :on-success="handleSuccess"
46
+ :on-change="handleChange"
47
+ :on-remove="handleRemove"
48
+ :on-error="handleError"
49
+ >
50
+ <template v-if="prepend">
51
+ <template v-if="Array.isArray(prepend)">
52
+ <el-button
53
+ v-for="(item, index) in prepend"
54
+ v-bind="{ ...item, size: btnSize }"
55
+ :key="index"
56
+ @click.stop="handleClick(item)"
57
+ >
58
+ {{ item.label || item.text }}
59
+ </el-button>
60
+ </template>
61
+ <el-button
62
+ v-else
63
+ v-bind="{ ...prepend, size: btnSize }"
64
+ @click.stop="handleClick(prepend)"
65
+ >
66
+ {{ prepend.label || prepend.text }}
67
+ </el-button>
68
+ </template>
69
+ <slot>
70
+ <expand-dom v-if="render" :render="render"></expand-dom>
71
+ <template v-else>
72
+ <template v-if="portrait">
73
+ <img
74
+ v-if="profile"
75
+ :src="profile"
76
+ class="avatar"
77
+ :style="{ width: width, height: height }"
78
+ />
79
+ <i
80
+ v-else
81
+ class="avatar-uploader-icon"
82
+ :class="{ 'el-icon-plus': !isReadonly, 'is-disabled': isDisabled }"
83
+ :style="{ width: width, height: height, lineHeight: height }"
84
+ ></i>
85
+ </template>
86
+ <template v-else>
87
+ <template v-if="!isReadonly">
88
+ <i
89
+ class="el-icon-plus es-uploader-icon"
90
+ :class="{ 'is-disabled': isDisabled }"
91
+ v-if="selectType === 'icon-plus'"
92
+ ></i>
93
+ <el-button
94
+ v-else
95
+ class="es-upload-button"
96
+ :class="icon"
97
+ :type="selectType"
98
+ :size="btnSize"
99
+ :disabled="isDisabled"
100
+ >{{
101
+ text ? text : autoUpload ? '点击上传' : '选择文件'
102
+ }}</el-button
103
+ >
104
+ <el-button
105
+ class="es-upload-button"
106
+ v-if="!autoUpload"
107
+ :type="uploadType"
108
+ :size="btnSize"
109
+ :disabled="isDisabled"
110
+ @click.stop="handleUpload"
111
+ >
112
+ 上传文件
113
+ </el-button>
114
+ </template>
115
+ <el-button
116
+ v-if="showFileList && isDownloads"
117
+ slot="handle"
118
+ class="es-upload-button es-upload-downloads"
119
+ :size="btnSize"
120
+ @click.stop="handleDownloads"
121
+ >
122
+ 批量下载
123
+ </el-button>
124
+ </template>
125
+ </template>
126
+ </slot>
127
+ <template v-if="append">
128
+ <template v-if="Array.isArray(append)">
129
+ <el-button
130
+ v-for="(item, index) in append"
131
+ v-bind="{ ...item, size: btnSize }"
132
+ :key="index"
133
+ @click.stop="handleClick(item)"
134
+ >
135
+ {{ item.label || item.text }}
136
+ </el-button>
137
+ </template>
138
+ <el-button
139
+ v-else
140
+ v-bind="{ ...append, size: btnSize }"
141
+ @click.stop="handleClick(append)"
142
+ >
143
+ {{ append.label || append.text }}
144
+ </el-button>
145
+ </template>
146
+ <template slot="tip">
147
+ <slot name="tip">
148
+ <div v-if="tips" class="el-upload__tip">{{ tips }}</div>
149
+ </slot>
150
+ </template>
151
+ <el-image-viewer
152
+ slot="dialog"
153
+ v-if="previewScale && showImg"
154
+ :z-index="9999"
155
+ :initial-index="0"
156
+ :url-list="[imgUrl]"
157
+ :on-close="closeViewer"
158
+ ></el-image-viewer>
159
+ <es-dialog v-else :title="title" :visible.sync="showImg" slot="dialog">
160
+ <div
161
+ v-loading="imgChange"
162
+ element-loading-background="rgba(0, 0, 0, 0.8)"
163
+ class="es-upload-dialog"
164
+ >
165
+ <img v-show="!imgChange" ref="showImg" :src="imgUrl" :style="styles" />
166
+ </div>
167
+ </es-dialog>
168
+ <es-dialog :title="title" :visible.sync="showVideo" slot="dialog">
169
+ <es-player
170
+ autoplay
171
+ type="video/mp4"
172
+ :is-pause="!showVideo"
173
+ :source="source"
174
+ ></es-player>
175
+ </es-dialog>
176
+ </el-upload>
177
+ </template>
178
+ <script>
179
+ import {
180
+ getAdjunctProperties,
181
+ uploads,
182
+ uploadOnlyOne,
183
+ getAdjunctFileInfos,
184
+ uploadDownloads,
185
+ previewAdjunctOffice,
186
+ previewAdjunct,
187
+ previewAdjunct2,
188
+ uploadSort,
189
+ delAdjunct,
190
+ downloadByAdjunctId
191
+ } from 'eoss-ui/src/config/api.js';
192
+ import { debounce } from 'throttle-debounce';
193
+ import util from 'eoss-ui/src/utils/util.js';
194
+ import picture from './picture.js';
195
+ import store from 'eoss-ui/src/utils/store';
196
+ import { Base64 } from 'js-base64';
197
+ export default {
198
+ name: 'EsUpload',
199
+ components: {
200
+ expandDom: {
201
+ functional: true,
202
+ props: {
203
+ render: [Function, String]
204
+ },
205
+ render: (h, ctx) => {
206
+ if (typeof ctx.props.render == 'string') {
207
+ try {
208
+ return util.toFunction(ctx.props.render)(h, params);
209
+ } catch (error) {
210
+ throw error;
211
+ }
212
+ }
213
+ return ctx.props.render(h);
214
+ }
215
+ }
216
+ },
217
+ inheritAttrs: false,
218
+ inject: {
219
+ elForm: {
220
+ default: ''
221
+ },
222
+ elFormItem: {
223
+ default: ''
224
+ }
225
+ },
226
+ props: {
227
+ prepend: [Array, Object],
228
+ append: [Array, Object],
229
+ render: Function,
230
+ template: String,
231
+ value: [String, Array, Object],
232
+ name: String,
233
+ method: {
234
+ type: String,
235
+ default: 'get'
236
+ },
237
+ text: String,
238
+ icon: String,
239
+ headers: {
240
+ type: Object,
241
+ default() {
242
+ return util.getStorage();
243
+ }
244
+ },
245
+ listType: {
246
+ type: String,
247
+ default: 'text' // text,picture,picture-card
248
+ },
249
+ operate: {
250
+ type: Boolean,
251
+ default: true
252
+ },
253
+ accept: String,
254
+ // 附件code
255
+ code: String,
256
+ // 业务id
257
+ ownId: String,
258
+ //附件文档id
259
+ documentId: String,
260
+ requiredOwnId: {
261
+ type: Boolean,
262
+ default: true
263
+ },
264
+ //
265
+ downloads: {
266
+ type: Boolean,
267
+ default: false
268
+ },
269
+ // 附件扩展编码
270
+ extendCode: String,
271
+ // 是否添加文件md5值
272
+ fileMd5: {
273
+ type: Boolean,
274
+ default: false
275
+ },
276
+ // 额外的参数
277
+ data: {
278
+ type: Object,
279
+ default() {
280
+ return {};
281
+ }
282
+ },
283
+ param: {
284
+ type: Object,
285
+ default() {
286
+ return {};
287
+ }
288
+ },
289
+ // 单文件大小
290
+ size: Number,
291
+ totalSize: Number,
292
+ // 是否头像模式上传
293
+ portrait: {
294
+ type: Boolean,
295
+ default: false
296
+ },
297
+ photo: [String, Boolean],
298
+ //头像按钮框宽度
299
+ width: String,
300
+ //头像按钮框高度度
301
+ height: String,
302
+ // 自定义的文字提示
303
+ tips: {
304
+ type: String,
305
+ default: ''
306
+ },
307
+ dragSort: {
308
+ type: Boolean,
309
+ default: false
310
+ },
311
+ // 上传成功后绑定到file的内容
312
+ showInfo: {
313
+ type: Array,
314
+ default() {
315
+ return ['uploadTime', 'fileSize', 'userName'];
316
+ }
317
+ },
318
+ // 上传地址
319
+ action: String,
320
+ // 自动上传
321
+ autoUpload: {
322
+ type: Boolean,
323
+ default: true
324
+ },
325
+ // 是否支持多选文件
326
+ multiple: {
327
+ type: Boolean,
328
+ default: true
329
+ },
330
+ // 显示文件列表
331
+ showFileList: {
332
+ type: Boolean,
333
+ default: true
334
+ },
335
+ // 上传的文件列表
336
+ fileList: [Array, String],
337
+ requestFiles: {
338
+ type: Boolean,
339
+ default: true
340
+ },
341
+ filesParam: {
342
+ type: Object,
343
+ default() {
344
+ return {};
345
+ }
346
+ },
347
+ state: {
348
+ type: Number,
349
+ default: 1
350
+ },
351
+ selectType: {
352
+ type: String,
353
+ default: 'primary'
354
+ },
355
+ uploadType: {
356
+ type: String,
357
+ default: 'success'
358
+ },
359
+ host: {
360
+ type: String,
361
+ default() {
362
+ return util.getStorage('host') ? util.getStorage('host') : '';
363
+ }
364
+ },
365
+ message: Object,
366
+ btnSize: {
367
+ type: String,
368
+ default: 'medium'
369
+ },
370
+ // 只读
371
+ readonly: {
372
+ type: Boolean,
373
+ default: false
374
+ },
375
+ disabled: Boolean,
376
+ preview: { type: [Boolean, String], default: true },
377
+ exclude: String,
378
+ download: { type: [Boolean, String], default: true },
379
+ deleted: { type: [Boolean, String], default: true },
380
+ remove: { type: [Boolean, String], default: true },
381
+ beforeUpload: Function,
382
+ onPreview: Function,
383
+ // 文件列表排序
384
+ onSort: Function,
385
+ beforeRemove: Function,
386
+ onDownloads: Function,
387
+ onDownload: Function,
388
+ onSort: Function,
389
+ onSuccess: Function,
390
+ onChange: Function,
391
+ onRemove: Function,
392
+ onError: Function,
393
+ dangerouslyUseHTMLString: Boolean,
394
+ fileCount: Number,
395
+ listHeight: String,
396
+ display: Boolean,
397
+ resultFile: {
398
+ type: Boolean,
399
+ default: true
400
+ },
401
+ properties: {
402
+ type: String,
403
+ default() {
404
+ return getAdjunctProperties;
405
+ }
406
+ },
407
+ icons: {
408
+ type: Object,
409
+ default() {
410
+ return {};
411
+ }
412
+ },
413
+ picture: {
414
+ type: Object,
415
+ default() {
416
+ return {};
417
+ }
418
+ },
419
+ previewScale: {
420
+ type: Boolean,
421
+ default: true
422
+ },
423
+ useCaseCode: String
424
+ },
425
+ data() {
426
+ return {
427
+ uploadUrl: this.action,
428
+ lists: [],
429
+ image: '',
430
+ fileAccept: '',
431
+ fileSize: 0,
432
+ fileTotalSize: 0,
433
+ filesTotalSize: 0,
434
+ showImg: false,
435
+ imgChange: false,
436
+ title: '',
437
+ imgUrl: '',
438
+ styles: {},
439
+ showVideo: false,
440
+ videoChange: false,
441
+ source: '',
442
+ excludeNames: '',
443
+ boxHeight: this.listHeight,
444
+ previewAdjunct: previewAdjunct,
445
+ kkfileview: null,
446
+ dochubConfig: {}
447
+ };
448
+ },
449
+ computed: {
450
+ isRender() {
451
+ let useCaseCodes = util.getStorage('useCaseCodes');
452
+ if (useCaseCodes && this.useCaseCode) {
453
+ return useCaseCodes.indexOf(this.useCaseCode) > -1;
454
+ }
455
+ return true;
456
+ },
457
+ _icons() {
458
+ return {
459
+ ppt: 'es-icon-ppt',
460
+ png: 'es-icon-picture',
461
+ gif: 'es-icon-picture',
462
+ jpg: 'es-icon-picture',
463
+ xls: 'es-icon-excel',
464
+ xlsx: 'es-icon-excel',
465
+ docx: 'es-icon-word',
466
+ doc: 'es-icon-word',
467
+ rar: 'es-icon-zip',
468
+ zip: 'es-icon-zip',
469
+ txt: 'es-icon-txt',
470
+ ipa: 'es-icon-ios',
471
+ apk: 'es-icon-android',
472
+ mp4: 'es-icon-video',
473
+ avi: 'es-icon-video',
474
+ mp3: 'es-icon-audioo',
475
+ wma: 'es-icon-audioo',
476
+ pdf: 'es-icon-pdf',
477
+ ...this.icons
478
+ };
479
+ },
480
+ _picture() {
481
+ return {
482
+ ...picture,
483
+ ...this.picture
484
+ };
485
+ },
486
+ show() {
487
+ if ((this.photo && typeof this.photo === 'string') || this.value) {
488
+ return false;
489
+ }
490
+ return this.showFileList;
491
+ },
492
+ excludes() {
493
+ return this.exclude ? this.exclude : this.excludeNames;
494
+ },
495
+ accepts() {
496
+ return this.accept
497
+ ? this.accept
498
+ : this.fileAccept
499
+ ? this.fileAccept
500
+ : this.portrait
501
+ ? 'image/*'
502
+ : undefined;
503
+ },
504
+ _size() {
505
+ return this.size ? this.size : this.fileSize ? this.fileSize : 0;
506
+ },
507
+ _totalSize() {
508
+ return this.totalSize
509
+ ? this.totalSize
510
+ : this.fileTotalSize
511
+ ? this.fileTotalSize
512
+ : 0;
513
+ },
514
+ getAdjunctFileInfos() {
515
+ return typeof this.fileList === 'string'
516
+ ? this.fileList
517
+ : getAdjunctFileInfos;
518
+ },
519
+ showList() {
520
+ return this.portrait ? false : this.showFileList;
521
+ },
522
+ isDownloads() {
523
+ return this.downloads;
524
+ },
525
+ isDownload() {
526
+ if (this.download) {
527
+ return true;
528
+ }
529
+ return false;
530
+ },
531
+ isDisabled() {
532
+ return this.disabled || (this.elForm || {}).disabled;
533
+ },
534
+ isReadonly() {
535
+ return this.readonly || (this.elForm || {}).readonly;
536
+ },
537
+ isRemove() {
538
+ if (this.remove == false || this.deleted == false) {
539
+ return false;
540
+ }
541
+ return true;
542
+ },
543
+ isSort() {
544
+ // return this.dragSort && !this.isDisabled && this.isReadonly;
545
+ return this.dragSort && !this.isDisabled;
546
+ },
547
+ datas() {
548
+ if (this.data) {
549
+ return util.extend({}, this.data, this.params);
550
+ }
551
+ return this.params;
552
+ },
553
+ params() {
554
+ let params = { userId: util.getStorage('userId'), ...this.param };
555
+ if (this.code !== undefined) {
556
+ params.code = this.code;
557
+ params.bucketCode = this.code;
558
+ }
559
+ if (this.ownId !== undefined) {
560
+ params.ownId = this.ownId;
561
+ params.businessId = this.ownId;
562
+ }
563
+ return params;
564
+ },
565
+ showMessage() {
566
+ if (this.message !== undefined) {
567
+ return util.extend({}, { success: true, error: true }, this.message);
568
+ }
569
+ return { success: true, error: true };
570
+ },
571
+ profile() {
572
+ const previewAdjunct =
573
+ this.dochubConfig.downloadDocumentUrl || this.previewAdjunct;
574
+ if (this.image) {
575
+ if (typeof this.image === 'string') {
576
+ return this.image;
577
+ }
578
+ return `${this.host}${previewAdjunct}?documentId=${
579
+ this.image.adjunctId
580
+ }&adjunctId=${this.image.adjunctId}&_tt=${new Date().getTime()}`;
581
+ }
582
+ if (this.value) {
583
+ if (typeof this.value === 'string') {
584
+ if (this.value.indexOf('data:image/') === 0) {
585
+ return this.value;
586
+ } else if (this.value.indexOf(previewAdjunct) > -1) {
587
+ let val =
588
+ this.host +
589
+ util.jointUrl({
590
+ url: this.value,
591
+ reg: '/main2'
592
+ });
593
+ return val;
594
+ } else if (this.value.indexOf('/') === -1) {
595
+ return `${this.host}${previewAdjunct}?documentId=${
596
+ this.value
597
+ }&adjunctId=${this.value}&_tt=${new Date().getTime()}`;
598
+ }
599
+ return this.value;
600
+ } else if (Array.isArray(this.value)) {
601
+ let adjunctId = this.value[0].response
602
+ ? this.value[0].response.adjunctId
603
+ : this.value[0].adjunctId;
604
+ return `${
605
+ this.host
606
+ }${previewAdjunct}?documentId=${adjunctId}&adjunctId=${adjunctId}&_tt=${new Date().getTime()}`;
607
+ } else {
608
+ let adjunctId = this.value.response
609
+ ? this.value.response.adjunctId
610
+ : this.value.adjunctId;
611
+ return `${
612
+ this.host
613
+ }${previewAdjunct}?documentId=${adjunctId}&adjunctId=${adjunctId}&_tt=${new Date().getTime()}`;
614
+ }
615
+ }
616
+ if (this.photo && typeof this.photo === 'string') {
617
+ if (this.photo.indexOf('data:image/') === 0) {
618
+ return this.photo;
619
+ } else if (this.photo.indexOf(previewAdjunct) > -1) {
620
+ let val =
621
+ this.host +
622
+ util.jointUrl({
623
+ url: this.value,
624
+ reg: '/main2'
625
+ });
626
+ return val;
627
+ } else if (this.photo.indexOf('/') === -1) {
628
+ return `${this.host}${previewAdjunct}?documentId=${
629
+ this.photo
630
+ }&adjunctId=${this.photo}&_tt=${new Date().getTime()}`;
631
+ }
632
+ }
633
+ return this.photo;
634
+ }
635
+ },
636
+ watch: {
637
+ fileList: {
638
+ immediate: true,
639
+ deep: true,
640
+ handler(val) {
641
+ if (Array.isArray(val) && val.length > 0) {
642
+ this.lists = val;
643
+ let filesTotalSize = 0;
644
+ val.forEach((item) => {
645
+ if (
646
+ Object.prototype.hasOwnProperty.call(item, 'fileSize') &&
647
+ item.fileSize
648
+ ) {
649
+ filesTotalSize += parseFloat(item.fileSize, 10);
650
+ } else {
651
+ filesTotalSize += item.size
652
+ ? Math.round((item.size / 1024) * 10) / 10
653
+ : 0;
654
+ }
655
+ });
656
+ this.filesTotalSize = filesTotalSize;
657
+ this.$emit('input', val);
658
+ }
659
+ }
660
+ },
661
+ value: {
662
+ immediate: true,
663
+ deep: true,
664
+ handler(val) {
665
+ if (val && typeof val === 'object' && this.showFileList) {
666
+ if (Array.isArray(val)) {
667
+ this.lists = val;
668
+ } else {
669
+ this.lists = [val];
670
+ }
671
+ }
672
+ }
673
+ },
674
+ params: {
675
+ deep: true,
676
+ handler(val) {
677
+ this.getFiles(val);
678
+ }
679
+ },
680
+ lists: {
681
+ deep: true,
682
+ handler(val) {
683
+ this.$emit('update:fileCount', val.length);
684
+ }
685
+ },
686
+ display(val) {
687
+ val && this.getHeight();
688
+ }
689
+ },
690
+ beforeCreate() {
691
+ this.getFiles = debounce(500, (params) => {
692
+ this.getFileLists(params);
693
+ });
694
+ this.getAdjunctPropertie = debounce(500, () => {
695
+ this.getAdjunctProperties();
696
+ });
697
+ },
698
+ created() {
699
+ const dochubConfig = sessionStorage.getItem('dochubConfig');
700
+ if (dochubConfig) {
701
+ this.dochubConfig = JSON.parse(dochubConfig);
702
+ }
703
+ this.getAdjunctPropertie();
704
+ },
705
+ mounted() {
706
+ this.$nextTick(() => {
707
+ this.getHeight();
708
+ });
709
+ },
710
+ methods: {
711
+ getHeight() {
712
+ if (this.height === 'auto') {
713
+ let pt =
714
+ parseInt(util.getStyle(this.$el.parentNode, 'padding-top'), 10) || 0;
715
+ let pb =
716
+ parseInt(util.getStyle(this.$el.parentNode, 'padding-bottom'), 10) ||
717
+ 0;
718
+ let btn = this.$refs.upload
719
+ ? this.$refs.upload.$children[0].$el.offsetHeight || 0
720
+ : 0;
721
+ this.boxHeight =
722
+ this.$el.parentNode.offsetHeight - pt - pb - btn + 'px';
723
+ }
724
+ },
725
+ //根据code获取附件参数配置
726
+ getAdjunctProperties() {
727
+ if (this.code !== undefined) {
728
+ let config = store.get(this.code);
729
+ if (config) {
730
+ this.fileAccept = config.accept;
731
+ this.fileSize = config.size;
732
+ this.fileTotalSize = config.totalSize;
733
+ if (config.dochubConfig) {
734
+ this.dochubConfig = config.dochubConfig;
735
+ }
736
+
737
+ let url =
738
+ this.portrait || this.documentId
739
+ ? this.dochubConfig.reuploadDocumentUrl || uploadOnlyOne
740
+ : this.dochubConfig.uploadDocumentUrl || uploads;
741
+ this.uploadUrl = url.indexOf(this.host) > -1 ? url : this.host + url;
742
+ this.requestFiles && this.getFiles(this.params);
743
+ } else {
744
+ util
745
+ .ajax({
746
+ method: this.method,
747
+ url: this.properties,
748
+ data: { code: this.code, ...this.param },
749
+ params: { code: this.code, ...this.param }
750
+ })
751
+ .then((res) => {
752
+ if (res.rCode === 0) {
753
+ if (res.results) {
754
+ this.excludeNames = res.results.excludeName;
755
+ if (res.results.fileTypeExtName) {
756
+ let fileTypeExtName =
757
+ res.results.fileTypeExtName.split(';');
758
+ this.fileAccept = fileTypeExtName
759
+ .filter((item) => {
760
+ return item;
761
+ })
762
+ .join(',');
763
+ }
764
+ if (res.results.dochubConfig) {
765
+ this.dochubConfig = res.results.dochubConfig;
766
+ sessionStorage.setItem(
767
+ 'dochubConfig',
768
+ JSON.stringify(res.results.dochubConfig)
769
+ );
770
+ }
771
+ let url = this.portrait
772
+ ? this.dochubConfig.reuploadDocumentUrl || uploadOnlyOne
773
+ : this.dochubConfig.uploadDocumentUrl || uploads;
774
+ this.uploadUrl =
775
+ url.indexOf(this.host) > -1 ? url : this.host + url;
776
+ if (res.results.kkViewRootPath) {
777
+ this.kkfileview = res.results.kkViewRootPath;
778
+ }
779
+ this.fileSize = res.results.limitFileSize
780
+ ? res.results.limitFileSize
781
+ : 0;
782
+ this.fileTotalSize = res.results.limitTotalSize;
783
+ store.set(this.code, {
784
+ accept: this.fileAccept,
785
+ size: this.fileSize,
786
+ totalSize: this.fileTotalSize,
787
+ dochubConfig: this.dochubConfig
788
+ });
789
+ }
790
+ this.requestFiles && this.getFiles(this.params);
791
+ }
792
+ })
793
+ .catch((err) => {
794
+ if (err.message && err.message !== 'canceled') {
795
+ this.$message.error(err.message);
796
+ }
797
+ });
798
+ }
799
+ }
800
+ },
801
+ getFileLists(params) {
802
+ if (
803
+ !this.show ||
804
+ (this.fileList &&
805
+ Array.isArray(this.fileList) &&
806
+ this.fileList.length) ||
807
+ (this.requiredOwnId &&
808
+ !Object.prototype.hasOwnProperty.call(params, 'ownId'))
809
+ ) {
810
+ return false;
811
+ }
812
+ let url =
813
+ typeof this.fileList === 'string'
814
+ ? this.fileList
815
+ : this.dochubConfig.getDocumentList
816
+ ? this.dochubConfig.getDocumentList
817
+ : getAdjunctFileInfos;
818
+ util
819
+ .ajax({
820
+ method: this.method,
821
+ url: url,
822
+ data: params,
823
+ params: params,
824
+ format: false
825
+ })
826
+ .then((res) => {
827
+ if (res.rCode === 0) {
828
+ if (this.portrait === true) {
829
+ this.image = JSON.parse(JSON.stringify(res.results))[0];
830
+ } else {
831
+ this.lists = JSON.parse(JSON.stringify(res.results));
832
+ let filesTotalSize = 0;
833
+ this.lists.forEach((item) => {
834
+ if (
835
+ Object.prototype.hasOwnProperty.call(item, 'fileSize') &&
836
+ item.fileSize
837
+ ) {
838
+ filesTotalSize += parseFloat(item.fileSize, 10);
839
+ } else {
840
+ filesTotalSize += item.size
841
+ ? Math.round((item.size / 1024) * 10) / 10
842
+ : 0;
843
+ }
844
+ });
845
+ this.filesTotalSize = filesTotalSize;
846
+ if (this.lists.length) {
847
+ this.$emit('input', this.lists);
848
+ }
849
+ }
850
+ } else {
851
+ let msg = res.msg || '系统错误,请联系管理员!';
852
+ this.$message.error(msg);
853
+ }
854
+ })
855
+ .catch((err) => {
856
+ if (err.message && err.message !== 'canceled') {
857
+ this.$message.error(err.message);
858
+ }
859
+ });
860
+ },
861
+ handleUpload() {
862
+ this.$refs.upload.submit();
863
+ },
864
+ openKkfileview(file) {
865
+ let host = util.win.location.origin;
866
+ if (this.host) {
867
+ if (util.startWith(this.host, 'http')) {
868
+ host = this.host;
869
+ } else {
870
+ host += this.host;
871
+ }
872
+ }
873
+ let url = encodeURIComponent(
874
+ Base64.encode(
875
+ host +
876
+ (typeof this.download === 'string'
877
+ ? this.download
878
+ : downloadByAdjunctId) +
879
+ `?adjunctId=${
880
+ file.adjunctId || file.response.adjunctId
881
+ }&fullfilename=${file.originalName}`
882
+ )
883
+ );
884
+ util.win.open(`${this.kkfileview}?url=${url}`);
885
+ },
886
+ handlePreview(res) {
887
+ if (this.preview) {
888
+ if (this.onPreview) {
889
+ this.onPreview(res);
890
+ } else {
891
+ let file = res.response ? res.response : res;
892
+ let url =
893
+ typeof this.preview === 'string'
894
+ ? this.preview
895
+ : typeof this.preview === 'function'
896
+ ? this.preview(file)
897
+ : null;
898
+ if (res.status === 'success') {
899
+ let suffix = file.suffix;
900
+ suffix = suffix.toLowerCase();
901
+ if (this.dochubConfig.previewDocumentUrl) {
902
+ if (
903
+ suffix.includes('jpge') ||
904
+ suffix.includes('jpg') ||
905
+ suffix.includes('gif') ||
906
+ suffix.includes('png')
907
+ ) {
908
+ this.imgUrl =
909
+ res.url && util.startWith(url, ['http', '/', true])
910
+ ? res.url
911
+ : this.host +
912
+ (url
913
+ ? url
914
+ : `${this.dochubConfig.downloadDocumentUrl}?documentId=${file.adjunctId}`);
915
+ this.title = file.originalName;
916
+ this.showImg = true;
917
+ this.$nextTick(() => {
918
+ this.loadImage();
919
+ });
920
+ } else if (suffix.includes('mp4')) {
921
+ this.source = {
922
+ src:
923
+ this.host +
924
+ (url
925
+ ? url
926
+ : `${this.dochubConfig.downloadDocumentUrl}?documentId=${file.adjunctId}`)
927
+ };
928
+ this.title = file.originalName;
929
+ this.showVideo = true;
930
+ } else {
931
+ util.win.open(
932
+ this.host +
933
+ (url
934
+ ? url
935
+ : `${this.dochubConfig.previewDocumentUrl}?documentId=${file.adjunctId}&action=附件预览`)
936
+ );
937
+ }
938
+ } else {
939
+ if (
940
+ suffix.includes('doc') ||
941
+ suffix.includes('docx') ||
942
+ suffix.includes('xls') ||
943
+ suffix.includes('xlsx') ||
944
+ suffix.includes('ppt')
945
+ ) {
946
+ if (this.kkfileview) {
947
+ this.openKkfileview(file);
948
+ } else {
949
+ util.win.open(
950
+ this.host +
951
+ (url ? url : previewAdjunctOffice) +
952
+ '?cmd=view&bucketName=' +
953
+ file.absolutePath +
954
+ '&fileId=' +
955
+ file.adjunctId +
956
+ '&fileName=' +
957
+ file.newName
958
+ );
959
+ }
960
+ } else if (suffix.includes('pdf')) {
961
+ if (this.kkfileview) {
962
+ this.openKkfileview(file);
963
+ } else {
964
+ util.win.open(
965
+ this.host +
966
+ (url ? url : previewAdjunct2) +
967
+ '/' +
968
+ file.originalName +
969
+ '?adjunctId=' +
970
+ file.adjunctId
971
+ );
972
+ }
973
+ } else if (
974
+ suffix.includes('jpge') ||
975
+ suffix.includes('jpg') ||
976
+ suffix.includes('gif') ||
977
+ suffix.includes('png')
978
+ ) {
979
+ this.imgUrl =
980
+ res.url && util.startWith(url, ['http', '/', true])
981
+ ? res.url
982
+ : this.host +
983
+ (url ? url : this.previewAdjunct) +
984
+ '?adjunctId=' +
985
+ file.adjunctId;
986
+ this.title = file.originalName;
987
+ this.showImg = true;
988
+ this.$nextTick(() => {
989
+ this.loadImage();
990
+ });
991
+ } else if (suffix.includes('mp4')) {
992
+ this.source = {
993
+ src:
994
+ this.host +
995
+ (url ? url : this.previewAdjunct) +
996
+ '?adjunctId=' +
997
+ file.adjunctId
998
+ };
999
+ this.title = file.originalName;
1000
+ this.showVideo = true;
1001
+ } else {
1002
+ if (this.kkfileview) {
1003
+ this.openKkfileview(file);
1004
+ } else {
1005
+ util.win.open(
1006
+ this.host +
1007
+ (url ? url : this.previewAdjunct) +
1008
+ '?adjunctId=' +
1009
+ file.adjunctId
1010
+ );
1011
+ }
1012
+ }
1013
+ }
1014
+ } else {
1015
+ util.win.open(URL.createObjectURL(file.raw));
1016
+ }
1017
+ }
1018
+ }
1019
+ },
1020
+ closeViewer() {
1021
+ this.showImg = false;
1022
+ },
1023
+ loadImage() {
1024
+ this.$refs.showImg &&
1025
+ (this.$refs.showImg.onload = () => {
1026
+ this.imgChange = false;
1027
+ let w = this.$refs.showImg.naturalWidth;
1028
+ let h = this.$refs.showImg.naturalHeight;
1029
+ let pw = this.$refs.showImg.parentNode.offsetWidth;
1030
+ let ph = this.$refs.showImg.parentNode.offsetHeight;
1031
+ if (w / h > pw / ph) {
1032
+ this.styles = { 'max-width': '100%' };
1033
+ } else {
1034
+ this.styles = { 'max-height': '100%' };
1035
+ }
1036
+ if (w < pw) {
1037
+ this.styles.width = w + 'px';
1038
+ }
1039
+ if (h < ph) {
1040
+ this.styles.height = h + 'px';
1041
+ }
1042
+ });
1043
+ },
1044
+ isLt(file) {
1045
+ let flag = false;
1046
+ let flieArr = file.name.split('.');
1047
+ let suffix = '.' + flieArr[flieArr.length - 1].toLowerCase();
1048
+ if (this.accepts) {
1049
+ let accepts = this.accepts.toLowerCase().split(',');
1050
+ flag = accepts.includes(suffix);
1051
+ if (!flag) {
1052
+ this.$message.error(`文件类型错误,请上传${this.accepts}类型文件!`);
1053
+ return flag;
1054
+ }
1055
+ }
1056
+ let size = this._size;
1057
+ let text = '单个附件';
1058
+ let se = Math.round((file.size / 1024) * 10) / 10;
1059
+ if (this._size === 0 && this._totalSize === 0) {
1060
+ flag = true;
1061
+ } else if (this._size > 0 && this._totalSize === 0) {
1062
+ flag = se < this._size;
1063
+ size = this._size;
1064
+ text = '单个附件';
1065
+ } else if (this._size === 0 && this._totalSize > 0) {
1066
+ flag = this.filesTotalSize + se < this._totalSize;
1067
+ size = this._totalSize;
1068
+ text = '附件总';
1069
+ } else {
1070
+ flag = se < this._size && this.filesTotalSize + se < this._totalSize;
1071
+ if (se < this._size) {
1072
+ size = this._size;
1073
+ text = '单个附件';
1074
+ } else {
1075
+ size = this._totalSize;
1076
+ text = '附件总';
1077
+ }
1078
+ }
1079
+ if (!flag) {
1080
+ this.$message.error(`上传${text}大小不能超过${size}KB!`);
1081
+ return flag;
1082
+ }
1083
+ return flag;
1084
+ },
1085
+ handleBeforeUpload(file) {
1086
+ const flag = this.isLt(file);
1087
+ if (this.portrait) {
1088
+ if (flag && this.beforeUpload) {
1089
+ return this.beforeUpload(file);
1090
+ }
1091
+ return flag;
1092
+ }
1093
+ if (this.beforeUpload) {
1094
+ if (flag) {
1095
+ return this.beforeUpload(file);
1096
+ }
1097
+ return flag;
1098
+ }
1099
+ return flag;
1100
+ },
1101
+ handleBeforeRemove(file, fileList) {
1102
+ if (file && file.status === 'success') {
1103
+ return this.$confirm('确定删除文件吗?', '提示', {
1104
+ confirmButtonText: '确定',
1105
+ cancelButtonText: '取消',
1106
+ type: 'warning'
1107
+ })
1108
+ .then(() => {
1109
+ if (this.beforeRemove) {
1110
+ return this.beforeRemove(file, fileList);
1111
+ } else if (file.status === 'success') {
1112
+ let userName =
1113
+ file.userName ||
1114
+ (file.response && file.response.userName) ||
1115
+ util.getStorage('userName');
1116
+ // eslint-disable-next-line no-undef
1117
+ return new Promise((resolve, reject) => {
1118
+ let url =
1119
+ typeof this.deleted === 'string'
1120
+ ? this.deleted
1121
+ : this.remove === 'string'
1122
+ ? this.remove
1123
+ : this.dochubConfig.deleteDocumentUrl || delAdjunct;
1124
+ util
1125
+ .ajax({
1126
+ method: this.method,
1127
+ url: url,
1128
+ data: {
1129
+ userName: userName,
1130
+ documentId: file.adjunctId || file.response.adjunctId,
1131
+ id: file.adjunctId || file.response.adjunctId
1132
+ },
1133
+ params: {
1134
+ userName: userName,
1135
+ documentId: file.adjunctId || file.response.adjunctId,
1136
+ id: file.adjunctId || file.response.adjunctId
1137
+ }
1138
+ })
1139
+ .then((res) => {
1140
+ if (res.rCode === 0) {
1141
+ let se =
1142
+ this.filesTotalSize -
1143
+ Math.round((file.size / 1024) * 10) / 10;
1144
+ this.filesTotalSize = se;
1145
+ this.$message.success(res.msg);
1146
+ resolve();
1147
+ } else {
1148
+ let msg = res.msg || '系统错误,请联系管理员!';
1149
+ this.$message.error(msg);
1150
+ reject();
1151
+ }
1152
+ })
1153
+ .catch((err) => {
1154
+ if (err.message && err.message !== 'canceled') {
1155
+ this.$message.error(err.message);
1156
+ }
1157
+ });
1158
+ });
1159
+ }
1160
+ return true;
1161
+ })
1162
+ .catch(() => {
1163
+ return flag;
1164
+ });
1165
+ }
1166
+ },
1167
+ handleDownloads() {
1168
+ let url =
1169
+ typeof this.downloads === 'string'
1170
+ ? this.downloads
1171
+ : this.dochubConfig.compressDownloadDocumentUrl || uploadDownloads;
1172
+ util.win.open(
1173
+ this.host +
1174
+ url +
1175
+ '?ownId=' +
1176
+ this.ownId +
1177
+ '&code=' +
1178
+ this.code +
1179
+ (this.extendCode ? '&extendCode=' + this.extendCode : '')
1180
+ );
1181
+ },
1182
+ handleDownload(file) {
1183
+ if (file.status === 'success') {
1184
+ let url =
1185
+ typeof this.download === 'string'
1186
+ ? this.download
1187
+ : this.dochubConfig.downloadDocumentUrl || downloadByAdjunctId;
1188
+ util.win.open(
1189
+ this.host +
1190
+ url +
1191
+ '?adjunctId=' +
1192
+ (file.adjunctId || file.response.adjunctId) +
1193
+ '&documentId=' +
1194
+ (file.adjunctId || file.response.adjunctId)
1195
+ );
1196
+ } else {
1197
+ this.aLinkDownload(file);
1198
+ }
1199
+ },
1200
+ handleClick(res) {
1201
+ if (res.event && typeof res.event === 'function') {
1202
+ res.event(res);
1203
+ } else {
1204
+ this.$emit('click', res);
1205
+ }
1206
+ },
1207
+ aLinkDownload(file) {
1208
+ var a = document.createElement('a');
1209
+ let event = new MouseEvent('click');
1210
+ a.href = URL.createObjectURL(file.raw);
1211
+ a.download = file.name;
1212
+ a.dispatchEvent(event);
1213
+ },
1214
+ handleSort(files) {
1215
+ if (this.isSort) {
1216
+ if (this.onSort) {
1217
+ this.onSort(files);
1218
+ } else {
1219
+ let ids = files.map((item) => {
1220
+ if (item.status === 'success') {
1221
+ return item.adjunctId || item.response.adjunctId;
1222
+ }
1223
+ });
1224
+ ids = ids.join(',');
1225
+ util
1226
+ .ajax({
1227
+ method: this.method,
1228
+ url: this.dochubConfig.sortDocumentsUrl || uploadSort,
1229
+ data: {
1230
+ ids: ids,
1231
+ documentIds: ids,
1232
+ ownId: this.ownId,
1233
+ code: this.code,
1234
+ bucketCode: this.code,
1235
+ businessId: this.ownId
1236
+ },
1237
+ params: {
1238
+ ids: ids,
1239
+ documentIds: ids,
1240
+ ownId: this.ownId,
1241
+ code: this.code,
1242
+ bucketCode: this.code,
1243
+ businessId: this.ownId
1244
+ }
1245
+ })
1246
+ .then((res) => {
1247
+ if (res.rCode === 0) {
1248
+ this.$message.success(res.msg);
1249
+ } else {
1250
+ let msg = res.msg || '系统错误,请联系管理员!';
1251
+ this.$message.error(msg);
1252
+ }
1253
+ })
1254
+ .catch((err) => {
1255
+ if (err.message && err.message !== 'canceled') {
1256
+ this.$message.error(err.message);
1257
+ }
1258
+ });
1259
+ }
1260
+ }
1261
+ },
1262
+ handleSuccess(response, file, fileList) {
1263
+ if (this.portrait) {
1264
+ this.image = URL.createObjectURL(file.raw);
1265
+ }
1266
+ if (this.showMessage.success) {
1267
+ if (response.rCode) {
1268
+ if (this.dangerouslyUseHTMLString) {
1269
+ this.$alert(
1270
+ response.msg ? response.msg : '上传失败:请联系管理员',
1271
+ '提示',
1272
+ {
1273
+ dangerouslyUseHTMLString: true,
1274
+ setHeight: response.msg
1275
+ }
1276
+ ).catch();
1277
+ } else {
1278
+ this.$message({
1279
+ type: 'error',
1280
+ message: response.msg || '成功!'
1281
+ });
1282
+ }
1283
+ } else {
1284
+ this.$message.success(response.msg);
1285
+ }
1286
+ }
1287
+ let se =
1288
+ this.filesTotalSize +
1289
+ (this.resultFile ? Math.round((file.size / 1024) * 10) / 10 : 0);
1290
+ this.filesTotalSize = se;
1291
+ this.onSuccess &&
1292
+ this.onSuccess(response, file, fileList, this.dochubConfig);
1293
+ this.$emit('success', response, file, fileList, this.dochubConfig);
1294
+ if (this.resultFile) {
1295
+ if (this.portrait) {
1296
+ this.$emit('input', file);
1297
+ } else {
1298
+ this.$emit('input', fileList);
1299
+ }
1300
+ if (this.elForm) {
1301
+ this.elForm.clearValidate(this.name);
1302
+ }
1303
+ }
1304
+ },
1305
+ handleChange(file, fileList) {
1306
+ this.$emit('change', fileList);
1307
+ this.onChange && this.onChange(file, fileList);
1308
+ },
1309
+ handleRemove(file, fileList) {
1310
+ this.$emit('input', fileList.length ? fileList : '');
1311
+ this.$emit('remove', file, fileList);
1312
+ this.$emit('change', fileList);
1313
+ this.onRemove && this.onRemove(file, fileList);
1314
+ },
1315
+ handleError(err, file, fileList) {
1316
+ if (this.showMessage.error) {
1317
+ if (this.dangerouslyUseHTMLString) {
1318
+ this.$alert(err.msg ? err.msg : '上传失败:请联系管理员', '提示', {
1319
+ dangerouslyUseHTMLString: true,
1320
+ setHeight: err.msg
1321
+ }).catch();
1322
+ } else {
1323
+ this.$message({
1324
+ type: 'error',
1325
+ message: '上传失败:' + (err.msg ? err.msg : '请联系管理员')
1326
+ });
1327
+ }
1328
+ }
1329
+ this.$emit('error', err, file, fileList);
1330
+ this.onError && this.onError(err, file, fileList);
1331
+ }
1332
+ }
1333
+ };
1334
+ </script>