eoss-ui 0.6.99 → 0.7.11

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