eoss-ui 0.6.88 → 0.6.89

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