eoss-ui 0.6.53 → 0.6.55

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