eoss-ui 0.6.67 → 0.6.69

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 +3 -2
  2. package/lib/button.js +3 -2
  3. package/lib/calogin.js +700 -256
  4. package/lib/checkbox-group.js +3 -2
  5. package/lib/data-table-form.js +3 -2
  6. package/lib/data-table.js +3 -2
  7. package/lib/date-picker.js +3 -2
  8. package/lib/dialog.js +3 -2
  9. package/lib/eoss-ui.common.js +1386 -920
  10. package/lib/flow-group.js +3 -2
  11. package/lib/flow-list.js +161 -177
  12. package/lib/flow.js +301 -291
  13. package/lib/form.js +3 -2
  14. package/lib/handle-user.js +3 -2
  15. package/lib/handler.js +3 -2
  16. package/lib/icon.js +3 -2
  17. package/lib/index.js +1 -1
  18. package/lib/input-number.js +3 -2
  19. package/lib/input.js +3 -2
  20. package/lib/login.js +70 -39
  21. package/lib/main.js +135 -134
  22. package/lib/nav.js +3 -2
  23. package/lib/page.js +3 -2
  24. package/lib/pagination.js +3 -2
  25. package/lib/player.js +3 -2
  26. package/lib/qr-code.js +16 -15
  27. package/lib/radio-group.js +3 -2
  28. package/lib/retrial-auth.js +3 -2
  29. package/lib/select-ganged.js +3 -2
  30. package/lib/select.js +3 -2
  31. package/lib/selector-panel.js +3 -2
  32. package/lib/selector.js +3 -2
  33. package/lib/sizer.js +3 -2
  34. package/lib/steps.js +3 -2
  35. package/lib/switch.js +3 -2
  36. package/lib/table-form.js +3 -2
  37. package/lib/tabs.js +3 -2
  38. package/lib/theme-chalk/index.css +1 -1
  39. package/lib/theme-chalk/login.css +1 -1
  40. package/lib/tips.js +3 -2
  41. package/lib/tree-group.js +3 -2
  42. package/lib/tree.js +3 -2
  43. package/lib/upload.js +3 -2
  44. package/lib/utils/util.js +3 -2
  45. package/lib/wujie.js +3 -2
  46. package/lib/wxlogin.js +3 -2
  47. package/package.json +160 -160
  48. package/packages/.DS_Store +0 -0
  49. package/packages/autocomplete/.DS_Store +0 -0
  50. package/packages/button/index.js +5 -5
  51. package/packages/button/src/main.vue +418 -418
  52. package/packages/button-group/index.js +5 -5
  53. package/packages/button-group/src/main.vue +298 -298
  54. package/packages/calendar/index.js +5 -5
  55. package/packages/calogin/.DS_Store +0 -0
  56. package/packages/calogin/index.js +5 -5
  57. package/packages/calogin/src/main.vue +410 -131
  58. package/packages/calogin/src/plugin.js +915 -748
  59. package/packages/card/index.js +5 -5
  60. package/packages/card/src/main.vue +156 -156
  61. package/packages/cascader/index.js +5 -5
  62. package/packages/cascader/src/main.vue +168 -168
  63. package/packages/checkbox-group/index.js +5 -5
  64. package/packages/checkbox-group/src/main.vue +333 -333
  65. package/packages/clients/index.js +5 -5
  66. package/packages/clients/src/main.vue +151 -151
  67. package/packages/data-table/index.js +5 -5
  68. package/packages/data-table/src/children.vue +39 -39
  69. package/packages/data-table/src/column.vue +989 -989
  70. package/packages/data-table/src/main.vue +1822 -1822
  71. package/packages/data-table/src/sizer.vue +195 -195
  72. package/packages/data-table-form/index.js +5 -5
  73. package/packages/data-table-form/src/checkbox.vue +101 -101
  74. package/packages/data-table-form/src/colgroup.vue +17 -17
  75. package/packages/data-table-form/src/main.vue +181 -181
  76. package/packages/data-table-form/src/radio.vue +65 -65
  77. package/packages/data-table-form/src/table.vue +233 -233
  78. package/packages/data-table-form/src/tbody.vue +336 -336
  79. package/packages/data-table-form/src/thead.vue +68 -68
  80. package/packages/date-picker/.DS_Store +0 -0
  81. package/packages/date-picker/index.js +5 -5
  82. package/packages/date-picker/src/.DS_Store +0 -0
  83. package/packages/date-picker/src/main.vue +236 -236
  84. package/packages/dialog/index.js +5 -5
  85. package/packages/enable-drag/index.js +5 -5
  86. package/packages/enterprise/index.js +5 -5
  87. package/packages/enterprise/src/main.vue +66 -66
  88. package/packages/error-page/index.js +5 -5
  89. package/packages/error-page/src/main.vue +44 -44
  90. package/packages/flow/.DS_Store +0 -0
  91. package/packages/flow/index.js +5 -5
  92. package/packages/flow/src/component/Circulate.vue +351 -351
  93. package/packages/flow/src/component/CommonOpinions.vue +346 -346
  94. package/packages/flow/src/component/CustomPreset.vue +322 -322
  95. package/packages/flow/src/component/FileList.vue +99 -99
  96. package/packages/flow/src/component/Preset.vue +255 -255
  97. package/packages/flow/src/component/SendMsg.vue +241 -241
  98. package/packages/flow/src/component/TimeLimit.vue +190 -190
  99. package/packages/flow/src/component/taskUnionExamine.vue +619 -619
  100. package/packages/flow/src/form.vue +121 -121
  101. package/packages/flow/src/freeStartFlow.vue +2843 -2843
  102. package/packages/flow/src/main.vue +3369 -3367
  103. package/packages/flow/src/processForm.vue +1091 -1091
  104. package/packages/flow/src/processReject.vue +294 -294
  105. package/packages/flow/src/reset.vue +905 -905
  106. package/packages/flow/src/selectUser.vue +6 -0
  107. package/packages/flow/src/startTaskRead.vue +659 -659
  108. package/packages/flow/src/supervise.vue +149 -149
  109. package/packages/flow/src/table.vue +58 -58
  110. package/packages/flow-group/index.js +5 -5
  111. package/packages/flow-group/src/main.vue +688 -688
  112. package/packages/flow-list/.DS_Store +0 -0
  113. package/packages/flow-list/index.js +5 -5
  114. package/packages/flow-list/src/main.vue +1738 -1757
  115. package/packages/form/index.js +5 -5
  116. package/packages/form/src/main.vue +3581 -3581
  117. package/packages/form/src/table.vue +1426 -1426
  118. package/packages/handle-user/index.js +5 -5
  119. package/packages/handle-user/src/main.vue +138 -138
  120. package/packages/handler/index.js +5 -5
  121. package/packages/handler/src/main.vue +493 -493
  122. package/packages/icon/index.js +5 -5
  123. package/packages/icon/src/main.vue +101 -101
  124. package/packages/icons/index.js +5 -5
  125. package/packages/icons/src/main.vue +81 -81
  126. package/packages/input/index.js +5 -5
  127. package/packages/input/src/main.vue +356 -356
  128. package/packages/input-number/index.js +5 -5
  129. package/packages/input-number/src/main.vue +106 -106
  130. package/packages/label/index.js +5 -5
  131. package/packages/label/src/main.vue +457 -457
  132. package/packages/layout/index.js +5 -5
  133. package/packages/layout/src/item.vue +152 -152
  134. package/packages/layout/src/main.vue +31 -31
  135. package/packages/login/.DS_Store +0 -0
  136. package/packages/login/index.js +5 -5
  137. package/packages/login/src/main.vue +2015 -1988
  138. package/packages/login/src/resetPassword.vue +562 -562
  139. package/packages/main/.DS_Store +0 -0
  140. package/packages/main/index.js +5 -5
  141. package/packages/main/src/.DS_Store +0 -0
  142. package/packages/main/src/default/message.vue +249 -249
  143. package/packages/main/src/default/notice.vue +157 -157
  144. package/packages/main/src/default/userinfo.vue +503 -503
  145. package/packages/main/src/public/online.vue +89 -89
  146. package/packages/main/src/public/search.vue +462 -462
  147. package/packages/main/src/public/settings.vue +221 -221
  148. package/packages/main/src/simplicity/apps.vue +388 -388
  149. package/packages/main/src/simplicity/avatar.vue +83 -83
  150. package/packages/main/src/simplicity/handler.vue +259 -259
  151. package/packages/main/src/simplicity/index.vue +2089 -2089
  152. package/packages/main/src/simplicity/lists.vue +84 -84
  153. package/packages/main/src/simplicity/menu-list.vue +135 -135
  154. package/packages/main/src/simplicity/message.vue +259 -259
  155. package/packages/main/src/simplicity/notice.vue +190 -190
  156. package/packages/main/src/simplicity/router-page.vue +45 -45
  157. package/packages/main/src/simplicity/sub-menu.vue +264 -264
  158. package/packages/main/src/simplicity/user.vue +257 -257
  159. package/packages/main/src/simplicity/userinfo.vue +312 -312
  160. package/packages/menu/.DS_Store +0 -0
  161. package/packages/menu/index.js +5 -5
  162. package/packages/menu/src/main.vue +584 -584
  163. package/packages/nav/index.js +5 -5
  164. package/packages/nav/src/main.vue +351 -351
  165. package/packages/notify/index.js +5 -5
  166. package/packages/notify/src/main.vue +538 -538
  167. package/packages/page/index.js +5 -5
  168. package/packages/page/src/main.vue +167 -167
  169. package/packages/pagination/index.js +5 -5
  170. package/packages/pagination/src/main.vue +96 -96
  171. package/packages/player/index.js +5 -5
  172. package/packages/player/src/main.vue +194 -194
  173. package/packages/qr-code/index.js +5 -5
  174. package/packages/qr-code/src/main.vue +170 -170
  175. package/packages/radio-group/index.js +6 -6
  176. package/packages/radio-group/src/main.vue +319 -319
  177. package/packages/retrial-auth/index.js +5 -5
  178. package/packages/retrial-auth/src/main.vue +280 -280
  179. package/packages/scrollbar/.DS_Store +0 -0
  180. package/packages/select/.DS_Store +0 -0
  181. package/packages/select/index.js +5 -5
  182. package/packages/select/src/main.vue +778 -778
  183. package/packages/select-ganged/index.js +5 -5
  184. package/packages/select-ganged/src/main.vue +724 -724
  185. package/packages/selector/index.js +5 -5
  186. package/packages/selector/src/main.vue +687 -687
  187. package/packages/selector-panel/index.js +5 -5
  188. package/packages/selector-panel/src/main.vue +1027 -1027
  189. package/packages/selector-panel/src/selection.vue +177 -177
  190. package/packages/selector-panel/src/tree.vue +129 -129
  191. package/packages/sizer/index.js +5 -5
  192. package/packages/sizer/src/main.vue +254 -254
  193. package/packages/steps/index.js +5 -5
  194. package/packages/steps/src/main.vue +181 -181
  195. package/packages/switch/index.js +5 -5
  196. package/packages/switch/src/main.vue +154 -154
  197. package/packages/table-form/index.js +5 -5
  198. package/packages/tabs/index.js +5 -5
  199. package/packages/tabs/src/main.vue +788 -788
  200. package/packages/tabs-panel/index.js +5 -5
  201. package/packages/tabs-panel/src/main.vue +29 -29
  202. package/packages/theme-chalk/lib/index.css +1 -1
  203. package/packages/theme-chalk/lib/login.css +1 -1
  204. package/packages/theme-chalk/src/.DS_Store +0 -0
  205. package/packages/theme-chalk/src/base.scss +261 -261
  206. package/packages/theme-chalk/src/button-group.scss +176 -176
  207. package/packages/theme-chalk/src/button.scss +24 -24
  208. package/packages/theme-chalk/src/calendar.scss +113 -113
  209. package/packages/theme-chalk/src/card.scss +99 -99
  210. package/packages/theme-chalk/src/checkbox-group.scss +8 -8
  211. package/packages/theme-chalk/src/clients.scss +87 -87
  212. package/packages/theme-chalk/src/data-table-form.scss +67 -67
  213. package/packages/theme-chalk/src/data-table.scss +293 -293
  214. package/packages/theme-chalk/src/date-picker.scss +7 -7
  215. package/packages/theme-chalk/src/dialog.scss +77 -77
  216. package/packages/theme-chalk/src/enable-drag.scss +181 -181
  217. package/packages/theme-chalk/src/enterprise.scss +5 -5
  218. package/packages/theme-chalk/src/error-page.scss +18 -18
  219. package/packages/theme-chalk/src/flow-group.scss +110 -110
  220. package/packages/theme-chalk/src/flow-list.scss +39 -39
  221. package/packages/theme-chalk/src/flow.scss +343 -343
  222. package/packages/theme-chalk/src/form.scss +496 -496
  223. package/packages/theme-chalk/src/handle-user.scss +40 -40
  224. package/packages/theme-chalk/src/handler.scss +143 -143
  225. package/packages/theme-chalk/src/icon.scss +1792 -1792
  226. package/packages/theme-chalk/src/icons.scss +99 -99
  227. package/packages/theme-chalk/src/input.scss +9 -9
  228. package/packages/theme-chalk/src/label.scss +24 -24
  229. package/packages/theme-chalk/src/layout.scss +46 -46
  230. package/packages/theme-chalk/src/login.scss +981 -981
  231. package/packages/theme-chalk/src/main.scss +663 -663
  232. package/packages/theme-chalk/src/menu.scss +222 -222
  233. package/packages/theme-chalk/src/mixins/color.scss +117 -117
  234. package/packages/theme-chalk/src/nav.scss +111 -111
  235. package/packages/theme-chalk/src/page.scss +3 -3
  236. package/packages/theme-chalk/src/pagination.scss +29 -29
  237. package/packages/theme-chalk/src/player.scss +9 -9
  238. package/packages/theme-chalk/src/qr-code.scss +17 -17
  239. package/packages/theme-chalk/src/radio-group.scss +9 -9
  240. package/packages/theme-chalk/src/retrial-auth.scss +38 -38
  241. package/packages/theme-chalk/src/select-ganged.scss +8 -8
  242. package/packages/theme-chalk/src/select.scss +8 -8
  243. package/packages/theme-chalk/src/selector-panel.scss +204 -204
  244. package/packages/theme-chalk/src/selector.scss +91 -91
  245. package/packages/theme-chalk/src/simplicity.scss +1355 -1355
  246. package/packages/theme-chalk/src/sizer.scss +36 -36
  247. package/packages/theme-chalk/src/steps.scss +88 -88
  248. package/packages/theme-chalk/src/switch.scss +3 -3
  249. package/packages/theme-chalk/src/table-form.scss +1 -1
  250. package/packages/theme-chalk/src/tabs.scss +87 -87
  251. package/packages/theme-chalk/src/tips.scss +7 -7
  252. package/packages/theme-chalk/src/toolbar.scss +179 -179
  253. package/packages/theme-chalk/src/tree-group.scss +72 -72
  254. package/packages/theme-chalk/src/tree.scss +165 -165
  255. package/packages/theme-chalk/src/upload.scss +168 -168
  256. package/packages/theme-chalk/src/wxlogin.scss +3 -3
  257. package/packages/tips/index.js +5 -5
  258. package/packages/tips/src/main.vue +141 -141
  259. package/packages/toolbar/index.js +5 -5
  260. package/packages/toolbar/src/main.vue +430 -430
  261. package/packages/tree/index.js +5 -5
  262. package/packages/tree-group/index.js +5 -5
  263. package/packages/upload/.DS_Store +0 -0
  264. package/packages/upload/index.js +5 -5
  265. package/packages/upload/src/main.vue +1347 -1347
  266. package/packages/upload/src/picture.js +15 -15
  267. package/packages/wujie/index.js +5 -5
  268. package/packages/wujie/src/main.vue +145 -145
  269. package/packages/wxlogin/index.js +5 -5
  270. package/packages/wxlogin/src/main.vue +128 -128
  271. package/src/.DS_Store +0 -0
  272. package/src/config/api.js +291 -291
  273. package/src/config/image.js +2 -2
  274. package/src/index.js +163 -163
  275. package/src/utils/.DS_Store +0 -0
  276. package/src/utils/bus.js +3 -3
  277. package/src/utils/date-util.js +312 -312
  278. package/src/utils/http.js +50 -50
  279. package/src/utils/rules.js +18 -18
  280. package/src/utils/store.js +21 -21
  281. package/src/utils/util.js +3 -2
  282. package/src/utils/webSocket.js +107 -107
@@ -1,1347 +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 { 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>
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>