tianheng-ui 0.0.55 → 0.0.57

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 (238) hide show
  1. package/lib/039af9192b9bb277966ceb4e4ce29c41.js +16 -0
  2. package/lib/{c755e7fc08446566ee8dd3a8aa8fe43f.js → 2d84c80112a372bc149cad3464e90fa3.js} +404 -502
  3. package/lib/5977b934a4c6b480790864ea01303173.js +10834 -0
  4. package/lib/7745f3e776488705a38e62f85adad54d.js +16 -0
  5. package/lib/de8dee841ffdaaede3a2254deef30376.js +15395 -0
  6. package/lib/e78eab250e7f8ccac3d918dfdb06ca10.js +8904 -0
  7. package/lib/index.js +4 -2
  8. package/lib/theme-chalk/fonts/PingFang.ttf +0 -0
  9. package/lib/theme-chalk/fonts/bpmn.eot +0 -0
  10. package/lib/theme-chalk/fonts/bpmn.svg +224 -0
  11. package/lib/theme-chalk/fonts/bpmn.ttf +0 -0
  12. package/lib/theme-chalk/fonts/bpmn.woff +0 -0
  13. package/lib/theme-chalk/fonts/bpmn.woff2 +0 -0
  14. package/lib/theme-chalk/fonts/fontawesome-webfont.eot +0 -0
  15. package/lib/theme-chalk/fonts/fontawesome-webfont.svg +2671 -0
  16. package/lib/theme-chalk/fonts/fontawesome-webfont.ttf +0 -0
  17. package/lib/theme-chalk/fonts/fontawesome-webfont.woff +0 -0
  18. package/lib/theme-chalk/fonts/fontawesome-webfont.woff2 +0 -0
  19. package/lib/{iconfont.eot → theme-chalk/fonts/iconfont.eot} +0 -0
  20. package/lib/{iconfont.svg → theme-chalk/fonts/iconfont.svg} +0 -0
  21. package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
  22. package/lib/theme-chalk/fonts/iconfont.woff +0 -0
  23. package/lib/theme-chalk/images/notData.png +0 -0
  24. package/lib/theme-chalk/index.scss +29 -0
  25. package/lib/theme-chalk/styles/button.scss +501 -0
  26. package/lib/theme-chalk/styles/card.scss +29 -0
  27. package/lib/theme-chalk/styles/cell.scss +54 -0
  28. package/lib/theme-chalk/styles/codeEditor.scss +9 -0
  29. package/lib/theme-chalk/styles/col.scss +151 -0
  30. package/lib/theme-chalk/styles/dialog.scss +59 -0
  31. package/lib/theme-chalk/styles/empty.scss +22 -0
  32. package/lib/theme-chalk/styles/feature.scss +42 -0
  33. package/lib/theme-chalk/styles/font.css +7 -0
  34. package/lib/theme-chalk/{icon.css → styles/icon.css} +3 -3
  35. package/lib/theme-chalk/styles/imagePreview.scss +113 -0
  36. package/lib/theme-chalk/styles/img.scss +35 -0
  37. package/lib/theme-chalk/styles/reset.scss +8 -0
  38. package/lib/theme-chalk/{root.css → styles/root.css} +2 -35
  39. package/lib/theme-chalk/styles/row.scss +23 -0
  40. package/lib/theme-chalk/styles/variable.scss +80 -0
  41. package/lib/tianheng-ui.js +71 -9
  42. package/package.json +24 -4
  43. package/packages/Button/index.js +8 -0
  44. package/packages/Button/index.vue +80 -0
  45. package/packages/Card/index.js +8 -0
  46. package/packages/Card/index.vue +37 -0
  47. package/packages/{cell → Cell}/index.js +0 -0
  48. package/packages/Cell/index.vue +68 -0
  49. package/packages/{codeEditor → CodeEditor}/index.js +0 -0
  50. package/packages/{codeEditor → CodeEditor}/index.vue +73 -108
  51. package/packages/Col/index.js +8 -0
  52. package/packages/Col/index.vue +41 -0
  53. package/packages/{dialog → Dialog}/index.js +0 -0
  54. package/packages/{dialog → Dialog}/index.vue +19 -10
  55. package/packages/Empty/images/notData.png +0 -0
  56. package/packages/{empty → Empty}/index.js +0 -0
  57. package/packages/Empty/index.vue +35 -0
  58. package/packages/FormMaking/Container.vue +1907 -0
  59. package/packages/{formMaking → FormMaking}/FormConfig.vue +22 -6
  60. package/packages/FormMaking/GenerateForm.vue +246 -0
  61. package/packages/{formMaking → FormMaking}/GenerateFormItem.vue +340 -172
  62. package/packages/FormMaking/GenerateFormItemH5.vue +828 -0
  63. package/packages/{formMaking → FormMaking}/Upload/index.vue +0 -0
  64. package/packages/FormMaking/WidgetConfig.vue +473 -0
  65. package/packages/{formMaking → FormMaking}/WidgetForm.vue +49 -31
  66. package/packages/FormMaking/WidgetFormItem.vue +157 -0
  67. package/packages/{formMaking/componentsConfig.js → FormMaking/custom/config.js} +379 -163
  68. package/packages/FormMaking/custom/configs/alliance.vue +0 -0
  69. package/packages/FormMaking/custom/configs/blank.vue +54 -0
  70. package/packages/FormMaking/custom/configs/button.vue +144 -0
  71. package/packages/FormMaking/custom/configs/cascader.vue +182 -0
  72. package/packages/FormMaking/custom/configs/cell.vue +81 -0
  73. package/packages/FormMaking/custom/configs/checkbox.vue +237 -0
  74. package/packages/FormMaking/custom/configs/color.vue +137 -0
  75. package/packages/FormMaking/custom/configs/date.vue +158 -0
  76. package/packages/FormMaking/custom/configs/divider.vue +61 -0
  77. package/packages/FormMaking/custom/configs/editor.vue +71 -0
  78. package/packages/FormMaking/custom/configs/filler.vue +52 -0
  79. package/packages/FormMaking/custom/configs/grid.vue +103 -0
  80. package/packages/FormMaking/custom/configs/image.vue +148 -0
  81. package/packages/FormMaking/custom/configs/input.vue +176 -0
  82. package/packages/FormMaking/custom/configs/number.vue +140 -0
  83. package/packages/FormMaking/custom/configs/radio.vue +215 -0
  84. package/packages/FormMaking/custom/configs/rate.vue +109 -0
  85. package/packages/FormMaking/custom/configs/select.vue +308 -0
  86. package/packages/FormMaking/custom/configs/slider.vue +142 -0
  87. package/packages/FormMaking/custom/configs/switch.vue +130 -0
  88. package/packages/FormMaking/custom/configs/table.vue +105 -0
  89. package/packages/FormMaking/custom/configs/table_h5.vue +102 -0
  90. package/packages/FormMaking/custom/configs/tabs.vue +175 -0
  91. package/packages/FormMaking/custom/configs/text.vue +71 -0
  92. package/packages/FormMaking/custom/configs/textarea.vue +167 -0
  93. package/packages/FormMaking/custom/configs/time.vue +153 -0
  94. package/packages/FormMaking/custom/configs/upload.vue +150 -0
  95. package/packages/FormMaking/custom/index.js +33 -0
  96. package/packages/FormMaking/custom/items/alliance.vue +132 -0
  97. package/packages/FormMaking/custom/items/blank.vue +16 -0
  98. package/packages/FormMaking/custom/items/button.vue +27 -0
  99. package/packages/FormMaking/custom/items/cascader.vue +29 -0
  100. package/packages/FormMaking/custom/items/cell.vue +18 -0
  101. package/packages/FormMaking/custom/items/checkbox.vue +46 -0
  102. package/packages/FormMaking/custom/items/color.vue +19 -0
  103. package/packages/FormMaking/custom/items/date.vue +29 -0
  104. package/packages/FormMaking/custom/items/divider.vue +14 -0
  105. package/packages/FormMaking/custom/items/editor.vue +22 -0
  106. package/packages/FormMaking/custom/items/filler.vue +17 -0
  107. package/packages/FormMaking/custom/items/grid.vue +129 -0
  108. package/packages/FormMaking/custom/items/image.vue +42 -0
  109. package/packages/FormMaking/custom/items/input.vue +36 -0
  110. package/packages/FormMaking/custom/items/login.vue +13 -0
  111. package/packages/FormMaking/custom/items/number.vue +24 -0
  112. package/packages/FormMaking/custom/items/radio.vue +44 -0
  113. package/packages/FormMaking/custom/items/rate.vue +20 -0
  114. package/packages/FormMaking/custom/items/select.vue +32 -0
  115. package/packages/FormMaking/custom/items/slider.vue +34 -0
  116. package/packages/FormMaking/custom/items/switch.vue +22 -0
  117. package/packages/FormMaking/custom/items/table.vue +106 -0
  118. package/packages/FormMaking/custom/items/table_h5.vue +126 -0
  119. package/packages/FormMaking/custom/items/tabs.vue +145 -0
  120. package/packages/FormMaking/custom/items/text.vue +18 -0
  121. package/packages/FormMaking/custom/items/textarea.vue +37 -0
  122. package/packages/FormMaking/custom/items/time.vue +32 -0
  123. package/packages/FormMaking/custom/items/upload.vue +83 -0
  124. package/packages/FormMaking/custom/mixins/index.js +61 -0
  125. package/packages/FormMaking/custom/register.js +18 -0
  126. package/packages/{formMaking → FormMaking}/iconfont/demo.css +0 -0
  127. package/packages/{formMaking → FormMaking}/iconfont/demo_index.html +0 -0
  128. package/packages/{formMaking → FormMaking}/iconfont/iconfont.css +0 -0
  129. package/packages/{formMaking → FormMaking}/iconfont/iconfont.eot +0 -0
  130. package/packages/{formMaking → FormMaking}/iconfont/iconfont.js +0 -0
  131. package/packages/{formMaking → FormMaking}/iconfont/iconfont.svg +0 -0
  132. package/{lib → packages/FormMaking/iconfont}/iconfont.ttf +0 -0
  133. package/{lib → packages/FormMaking/iconfont}/iconfont.woff +0 -0
  134. package/packages/{formMaking → FormMaking}/iconfont/iconfont.woff2 +0 -0
  135. package/packages/FormMaking/index.js +35 -0
  136. package/packages/{formMaking → FormMaking}/lang/en-US.js +1 -1
  137. package/packages/{formMaking → FormMaking}/lang/zh-CN.js +1 -1
  138. package/packages/{formMaking → FormMaking}/styles/cover.scss +1 -1
  139. package/packages/{formMaking → FormMaking}/styles/index.scss +445 -429
  140. package/packages/{formMaking → FormMaking/util}/generateCode.js +5 -5
  141. package/packages/{formMaking → FormMaking}/util/index.js +0 -0
  142. package/packages/{formMaking → FormMaking}/util/request.js +0 -0
  143. package/packages/{icons → Icons}/index.js +0 -0
  144. package/packages/{icons → Icons}/index.vue +26 -9
  145. package/packages/Image/index.js +8 -0
  146. package/packages/Image/index.vue +146 -0
  147. package/packages/ImagePreview/index.js +8 -0
  148. package/packages/ImagePreview/index.vue +386 -0
  149. package/packages/Row/index.js +8 -0
  150. package/packages/Row/index.vue +35 -0
  151. package/packages/{table → Table}/action.js +0 -0
  152. package/packages/{table → Table}/action.vue +1 -1
  153. package/packages/Table/column.vue +63 -0
  154. package/packages/{table → Table}/index.js +0 -0
  155. package/packages/{table → Table}/index.vue +25 -23
  156. package/packages/{table → Table}/search.js +0 -0
  157. package/packages/{table → Table}/search.vue +1 -1
  158. package/packages/{table → Table}/tools.js +0 -0
  159. package/packages/{table → Table}/tools.vue +0 -0
  160. package/packages/Workflow/Log.js +99 -0
  161. package/packages/Workflow/designer/ProcessDesigner.vue +628 -0
  162. package/packages/Workflow/designer/index.js +7 -0
  163. package/packages/Workflow/designer/plugins/content-pad/contentPadProvider.js +390 -0
  164. package/packages/Workflow/designer/plugins/content-pad/index.js +6 -0
  165. package/packages/Workflow/designer/plugins/defaultEmpty.js +24 -0
  166. package/packages/Workflow/designer/plugins/descriptor/activitiDescriptor.json +1071 -0
  167. package/packages/Workflow/designer/plugins/descriptor/camundaDescriptor.json +1087 -0
  168. package/packages/Workflow/designer/plugins/descriptor/flowableDescriptor.json +1215 -0
  169. package/packages/Workflow/designer/plugins/extension-moddle/activiti/activitiExtension.js +74 -0
  170. package/packages/Workflow/designer/plugins/extension-moddle/activiti/index.js +9 -0
  171. package/packages/Workflow/designer/plugins/extension-moddle/camunda/extension.js +148 -0
  172. package/packages/Workflow/designer/plugins/extension-moddle/camunda/index.js +6 -0
  173. package/packages/Workflow/designer/plugins/extension-moddle/flowable/flowableExtension.js +74 -0
  174. package/packages/Workflow/designer/plugins/extension-moddle/flowable/index.js +9 -0
  175. package/packages/Workflow/designer/plugins/palette/CustomPalette.js +156 -0
  176. package/packages/Workflow/designer/plugins/palette/index.js +6 -0
  177. package/packages/Workflow/designer/plugins/palette/paletteProvider.js +160 -0
  178. package/packages/Workflow/designer/plugins/translate/customTranslate.js +41 -0
  179. package/packages/Workflow/designer/plugins/translate/zh.js +238 -0
  180. package/packages/Workflow/highlight/index.js +5 -0
  181. package/packages/Workflow/index.js +26 -0
  182. package/packages/Workflow/index.vue +394 -0
  183. package/packages/Workflow/modules/auto-place/CustomAutoPlace.js +81 -0
  184. package/packages/Workflow/modules/auto-place/index.js +6 -0
  185. package/packages/Workflow/modules/custom-renderer/CustomRenderer.js +17 -0
  186. package/packages/Workflow/modules/custom-renderer/index.js +6 -0
  187. package/packages/Workflow/modules/rules/CustomRules.js +16 -0
  188. package/packages/Workflow/modules/rules/index.js +6 -0
  189. package/packages/Workflow/palette/ProcessPalette.vue +106 -0
  190. package/packages/Workflow/palette/index.js +7 -0
  191. package/packages/Workflow/penal/PropertiesPanel.vue +247 -0
  192. package/packages/Workflow/penal/base/ElementBaseInfo.vue +80 -0
  193. package/packages/Workflow/penal/flow-condition/FlowCondition.vue +142 -0
  194. package/packages/Workflow/penal/form/ElementForm.vue +367 -0
  195. package/packages/Workflow/penal/index.js +7 -0
  196. package/packages/Workflow/penal/listeners/ElementListeners.vue +299 -0
  197. package/packages/Workflow/penal/listeners/UserTaskListeners.vue +322 -0
  198. package/packages/Workflow/penal/listeners/template.js +178 -0
  199. package/packages/Workflow/penal/listeners/utilSelf.js +62 -0
  200. package/packages/Workflow/penal/multi-instance/ElementMultiInstance.vue +200 -0
  201. package/packages/Workflow/penal/other/ElementOtherConfig.vue +59 -0
  202. package/packages/Workflow/penal/properties/ElementProperties.vue +135 -0
  203. package/packages/Workflow/penal/signal-message/SignalAndMessage.vue +104 -0
  204. package/packages/Workflow/penal/task/ElementTask.vue +73 -0
  205. package/packages/Workflow/penal/task/task-components/ReceiveTask.vue +97 -0
  206. package/packages/Workflow/penal/task/task-components/ScriptTask.vue +85 -0
  207. package/packages/Workflow/penal/task/task-components/UserTask.vue +535 -0
  208. package/packages/Workflow/theme/element-variables.scss +70 -0
  209. package/packages/Workflow/theme/index.scss +2 -0
  210. package/packages/Workflow/theme/process-designer.scss +157 -0
  211. package/packages/Workflow/theme/process-panel.scss +107 -0
  212. package/packages/Workflow/translations.js +25 -0
  213. package/packages/Workflow/utils.js +71 -0
  214. package/packages/upload/ajax.js +85 -0
  215. package/packages/upload/index.js +8 -0
  216. package/packages/upload/index.vue +325 -0
  217. package/packages/upload/locale.js +9 -0
  218. package/packages/upload/upload-dragger.vue +70 -0
  219. package/packages/upload/upload-list.vue +101 -0
  220. package/packages/upload/upload.vue +211 -0
  221. package/lib/03250ed25fc1b305e9980cf7cf0dfb09.js +0 -1
  222. package/lib/theme-chalk/cell.css +0 -53
  223. package/lib/theme-chalk/dialog.css +0 -41
  224. package/lib/theme-chalk/empty.css +0 -27
  225. package/lib/theme-chalk/index.css +0 -6
  226. package/lib/theme-chalk/reset.css +0 -4
  227. package/lib/tianheng-ui.js.map +0 -1
  228. package/packages/cell/index.vue +0 -116
  229. package/packages/empty/index.vue +0 -33
  230. package/packages/formMaking/Container.vue +0 -591
  231. package/packages/formMaking/CusDialog.vue +0 -134
  232. package/packages/formMaking/GenerateForm.vue +0 -174
  233. package/packages/formMaking/WidgetConfig.vue +0 -1539
  234. package/packages/formMaking/WidgetFormItem.vue +0 -817
  235. package/packages/formMaking/iconfont/iconfont.ttf +0 -0
  236. package/packages/formMaking/iconfont/iconfont.woff +0 -0
  237. package/packages/formMaking/index.js +0 -77
  238. package/packages/table/column.vue +0 -111
@@ -0,0 +1,325 @@
1
+ <script>
2
+ import UploadList from './upload-list';
3
+ import Upload from './upload';
4
+ import ElProgress from 'element-ui/packages/progress';
5
+
6
+ function noop() {}
7
+
8
+ export default {
9
+ name: 'ElUpload',
10
+ components: {
11
+ ElProgress,
12
+ UploadList,
13
+ Upload
14
+ },
15
+
16
+ provide() {
17
+ return {
18
+ uploader: this
19
+ };
20
+ },
21
+
22
+ inject: {
23
+ elForm: {
24
+ default: ''
25
+ }
26
+ },
27
+
28
+ props: {
29
+ action: {
30
+ type: String,
31
+ required: true
32
+ },
33
+ headers: {
34
+ type: Object,
35
+ default() {
36
+ return {};
37
+ }
38
+ },
39
+ data: Object,
40
+ multiple: Boolean,
41
+ name: {
42
+ type: String,
43
+ default: 'file'
44
+ },
45
+ drag: Boolean,
46
+ dragger: Boolean,
47
+ withCredentials: Boolean,
48
+ showFileList: {
49
+ type: Boolean,
50
+ default: true
51
+ },
52
+ accept: String,
53
+ type: {
54
+ type: String,
55
+ default: 'select'
56
+ },
57
+ beforeUpload: Function,
58
+ beforeRemove: Function,
59
+ onRemove: {
60
+ type: Function,
61
+ default: noop
62
+ },
63
+ onChange: {
64
+ type: Function,
65
+ default: noop
66
+ },
67
+ onPreview: {
68
+ type: Function
69
+ },
70
+ onSuccess: {
71
+ type: Function,
72
+ default: noop
73
+ },
74
+ onProgress: {
75
+ type: Function,
76
+ default: noop
77
+ },
78
+ onError: {
79
+ type: Function,
80
+ default: noop
81
+ },
82
+ fileList: {
83
+ type: Array,
84
+ default() {
85
+ return [];
86
+ }
87
+ },
88
+ autoUpload: {
89
+ type: Boolean,
90
+ default: true
91
+ },
92
+ listType: {
93
+ type: String,
94
+ default: 'text' // text,picture,picture-card
95
+ },
96
+ httpRequest: Function,
97
+ disabled: Boolean,
98
+ limit: Number,
99
+ onExceed: {
100
+ type: Function,
101
+ default: noop
102
+ }
103
+ },
104
+
105
+ data() {
106
+ return {
107
+ uploadFiles: [],
108
+ dragOver: false,
109
+ draging: false,
110
+ tempIndex: 1
111
+ };
112
+ },
113
+
114
+ computed: {
115
+ uploadDisabled() {
116
+ return this.disabled || (this.elForm || {}).disabled;
117
+ }
118
+ },
119
+
120
+ watch: {
121
+ listType(type) {
122
+ if (type === 'picture-card' || type === 'picture') {
123
+ this.uploadFiles = this.uploadFiles.map(file => {
124
+ if (!file.url && file.raw) {
125
+ try {
126
+ file.url = URL.createObjectURL(file.raw);
127
+ } catch (err) {
128
+ console.error('[Element Error][Upload]', err);
129
+ }
130
+ }
131
+ return file;
132
+ });
133
+ }
134
+ },
135
+ fileList: {
136
+ immediate: true,
137
+ handler(fileList) {
138
+ this.uploadFiles = fileList.map(item => {
139
+ item.uid = item.uid || (Date.now() + this.tempIndex++);
140
+ item.status = item.status || 'success';
141
+ return item;
142
+ });
143
+ }
144
+ }
145
+ },
146
+
147
+ methods: {
148
+ handleStart(rawFile) {
149
+ rawFile.uid = Date.now() + this.tempIndex++;
150
+ let file = {
151
+ status: 'ready',
152
+ name: rawFile.name,
153
+ size: rawFile.size,
154
+ percentage: 0,
155
+ uid: rawFile.uid,
156
+ raw: rawFile
157
+ };
158
+
159
+ if (this.listType === 'picture-card' || this.listType === 'picture') {
160
+ try {
161
+ file.url = URL.createObjectURL(rawFile);
162
+ } catch (err) {
163
+ console.error('[Element Error][Upload]', err);
164
+ return;
165
+ }
166
+ }
167
+
168
+ this.uploadFiles.push(file);
169
+ this.onChange(file, this.uploadFiles);
170
+ },
171
+ handleProgress(ev, rawFile) {
172
+ const file = this.getFile(rawFile);
173
+ this.onProgress(ev, file, this.uploadFiles);
174
+ file.status = 'uploading';
175
+ file.percentage = ev.percent || 0;
176
+ },
177
+ handleSuccess(res, rawFile) {
178
+ const file = this.getFile(rawFile);
179
+
180
+ if (file) {
181
+ file.status = 'success';
182
+ file.response = res;
183
+
184
+ this.onSuccess(res, file, this.uploadFiles);
185
+ this.onChange(file, this.uploadFiles);
186
+ }
187
+ },
188
+ handleError(err, rawFile) {
189
+ const file = this.getFile(rawFile);
190
+ const fileList = this.uploadFiles;
191
+
192
+ file.status = 'fail';
193
+
194
+ fileList.splice(fileList.indexOf(file), 1);
195
+
196
+ this.onError(err, file, this.uploadFiles);
197
+ this.onChange(file, this.uploadFiles);
198
+ },
199
+ handleRemove(file, raw) {
200
+ if (raw) {
201
+ file = this.getFile(raw);
202
+ }
203
+ let doRemove = () => {
204
+ this.abort(file);
205
+ let fileList = this.uploadFiles;
206
+ fileList.splice(fileList.indexOf(file), 1);
207
+ this.onRemove(file, fileList);
208
+ };
209
+
210
+ if (!this.beforeRemove) {
211
+ doRemove();
212
+ } else if (typeof this.beforeRemove === 'function') {
213
+ const before = this.beforeRemove(file, this.uploadFiles);
214
+ if (before && before.then) {
215
+ before.then(() => {
216
+ doRemove();
217
+ }, noop);
218
+ } else if (before !== false) {
219
+ doRemove();
220
+ }
221
+ }
222
+ },
223
+ getFile(rawFile) {
224
+ let fileList = this.uploadFiles;
225
+ let target;
226
+ fileList.every(item => {
227
+ target = rawFile.uid === item.uid ? item : null;
228
+ return !target;
229
+ });
230
+ return target;
231
+ },
232
+ abort(file) {
233
+ this.$refs['upload-inner'].abort(file);
234
+ },
235
+ clearFiles() {
236
+ this.uploadFiles = [];
237
+ },
238
+ submit() {
239
+ this.uploadFiles
240
+ .filter(file => file.status === 'ready')
241
+ .forEach(file => {
242
+ this.$refs['upload-inner'].upload(file.raw);
243
+ });
244
+ },
245
+ },
246
+
247
+ beforeDestroy() {
248
+ this.uploadFiles.forEach(file => {
249
+ if (file.url && file.url.indexOf('blob:') === 0) {
250
+ URL.revokeObjectURL(file.url);
251
+ }
252
+ });
253
+ },
254
+
255
+ render(h) {
256
+ let uploadList;
257
+
258
+ if (this.showFileList) {
259
+ uploadList = (
260
+ <UploadList
261
+ disabled={this.uploadDisabled}
262
+ listType={this.listType}
263
+ files={this.uploadFiles}
264
+ on-remove={this.handleRemove}
265
+ handlePreview={this.onPreview}>
266
+ {
267
+ (props) => {
268
+ if (this.$scopedSlots.file) {
269
+ return this.$scopedSlots.file({
270
+ file: props.file
271
+ });
272
+ }
273
+ }
274
+ }
275
+ </UploadList>
276
+ );
277
+ }
278
+
279
+ const uploadData = {
280
+ props: {
281
+ type: this.type,
282
+ drag: this.drag,
283
+ action: this.action,
284
+ multiple: this.multiple,
285
+ 'before-upload': this.beforeUpload,
286
+ 'with-credentials': this.withCredentials,
287
+ headers: this.headers,
288
+ name: this.name,
289
+ data: this.data,
290
+ accept: this.accept,
291
+ fileList: this.uploadFiles,
292
+ autoUpload: this.autoUpload,
293
+ listType: this.listType,
294
+ disabled: this.uploadDisabled,
295
+ limit: this.limit,
296
+ 'on-exceed': this.onExceed,
297
+ 'on-start': this.handleStart,
298
+ 'on-progress': this.handleProgress,
299
+ 'on-success': this.handleSuccess,
300
+ 'on-error': this.handleError,
301
+ 'on-preview': this.onPreview,
302
+ 'on-remove': this.handleRemove,
303
+ 'http-request': this.httpRequest
304
+ },
305
+ ref: 'upload-inner'
306
+ };
307
+
308
+ const trigger = this.$slots.trigger || this.$slots.default;
309
+ const uploadComponent = <upload {...uploadData}>{trigger}</upload>;
310
+
311
+ return (
312
+ <div>
313
+ { this.listType === 'picture-card' ? uploadList : ''}
314
+ {
315
+ this.$slots.trigger
316
+ ? [uploadComponent, this.$slots.default]
317
+ : uploadComponent
318
+ }
319
+ {this.$slots.tip}
320
+ { this.listType !== 'picture-card' ? uploadList : ''}
321
+ </div>
322
+ );
323
+ }
324
+ };
325
+ </script>
@@ -0,0 +1,9 @@
1
+ import { t } from 'element-ui/src/locale';
2
+
3
+ export default {
4
+ methods: {
5
+ t(...args) {
6
+ return t.apply(this, args);
7
+ }
8
+ }
9
+ };
@@ -0,0 +1,70 @@
1
+ <template>
2
+ <div
3
+ class="el-upload-dragger"
4
+ :class="{
5
+ 'is-dragover': dragover
6
+ }"
7
+ @drop.prevent="onDrop"
8
+ @dragover.prevent="onDragover"
9
+ @dragleave.prevent="dragover = false"
10
+ >
11
+ <slot></slot>
12
+ </div>
13
+ </template>
14
+ <script>
15
+ export default {
16
+ name: 'ElUploadDrag',
17
+ props: {
18
+ disabled: Boolean
19
+ },
20
+ inject: {
21
+ uploader: {
22
+ default: ''
23
+ }
24
+ },
25
+ data() {
26
+ return {
27
+ dragover: false
28
+ };
29
+ },
30
+ methods: {
31
+ onDragover() {
32
+ if (!this.disabled) {
33
+ this.dragover = true;
34
+ }
35
+ },
36
+ onDrop(e) {
37
+ if (this.disabled || !this.uploader) return;
38
+ const accept = this.uploader.accept;
39
+ this.dragover = false;
40
+ if (!accept) {
41
+ this.$emit('file', e.dataTransfer.files);
42
+ return;
43
+ }
44
+ this.$emit('file', [].slice.call(e.dataTransfer.files).filter(file => {
45
+ const { type, name } = file;
46
+ const extension = name.indexOf('.') > -1
47
+ ? `.${ name.split('.').pop() }`
48
+ : '';
49
+ const baseType = type.replace(/\/.*$/, '');
50
+ return accept.split(',')
51
+ .map(type => type.trim())
52
+ .filter(type => type)
53
+ .some(acceptedType => {
54
+ if (/\..+$/.test(acceptedType)) {
55
+ return extension === acceptedType;
56
+ }
57
+ if (/\/\*$/.test(acceptedType)) {
58
+ return baseType === acceptedType.replace(/\/\*$/, '');
59
+ }
60
+ if (/^[^\/]+\/[^\/]+$/.test(acceptedType)) {
61
+ return type === acceptedType;
62
+ }
63
+ return false;
64
+ });
65
+ }));
66
+ }
67
+ }
68
+ };
69
+ </script>
70
+
@@ -0,0 +1,101 @@
1
+ <template>
2
+ <transition-group
3
+ tag="ul"
4
+ :class="[
5
+ 'el-upload-list',
6
+ 'el-upload-list--' + listType,
7
+ { 'is-disabled': disabled }
8
+ ]"
9
+ name="el-list"
10
+ >
11
+ <li
12
+ v-for="file in files"
13
+ :class="['el-upload-list__item', 'is-' + file.status, focusing ? 'focusing' : '']"
14
+ :key="file.uid"
15
+ tabindex="0"
16
+ @keydown.delete="!disabled && $emit('remove', file)"
17
+ @focus="focusing = true"
18
+ @blur="focusing = false"
19
+ @click="focusing = false"
20
+ >
21
+ <slot :file="file">
22
+ <img
23
+ class="el-upload-list__item-thumbnail"
24
+ v-if="file.status !== 'uploading' && ['picture-card', 'picture'].indexOf(listType) > -1"
25
+ :src="file.url" alt=""
26
+ >
27
+ <a class="el-upload-list__item-name" @click="handleClick(file)">
28
+ <i class="el-icon-document"></i>{{file.name}}
29
+ </a>
30
+ <label class="el-upload-list__item-status-label">
31
+ <i :class="{
32
+ 'el-icon-upload-success': true,
33
+ 'el-icon-circle-check': listType === 'text',
34
+ 'el-icon-check': ['picture-card', 'picture'].indexOf(listType) > -1
35
+ }"></i>
36
+ </label>
37
+ <i class="el-icon-close" v-if="!disabled" @click="$emit('remove', file)"></i>
38
+ <i class="el-icon-close-tip" v-if="!disabled">{{ t('el.upload.deleteTip') }}</i> <!--因为close按钮只在li:focus的时候 display, li blur后就不存在了,所以键盘导航时永远无法 focus到 close按钮上-->
39
+ <el-progress
40
+ v-if="file.status === 'uploading'"
41
+ :type="listType === 'picture-card' ? 'circle' : 'line'"
42
+ :stroke-width="listType === 'picture-card' ? 6 : 2"
43
+ :percentage="parsePercentage(file.percentage)">
44
+ </el-progress>
45
+ <span class="el-upload-list__item-actions" v-if="listType === 'picture-card'">
46
+ <span
47
+ class="el-upload-list__item-preview"
48
+ v-if="handlePreview && listType === 'picture-card'"
49
+ @click="handlePreview(file)"
50
+ >
51
+ <i class="el-icon-zoom-in"></i>
52
+ </span>
53
+ <span
54
+ v-if="!disabled"
55
+ class="el-upload-list__item-delete"
56
+ @click="$emit('remove', file)"
57
+ >
58
+ <i class="el-icon-delete"></i>
59
+ </span>
60
+ </span>
61
+ </slot>
62
+ </li>
63
+ </transition-group>
64
+ </template>
65
+ <script>
66
+ import Locale from 'element-ui/src/mixins/locale';
67
+ import ElProgress from 'element-ui/packages/progress';
68
+ export default {
69
+ name: 'ElUploadList',
70
+ mixins: [Locale],
71
+ data() {
72
+ return {
73
+ focusing: false
74
+ };
75
+ },
76
+ components: { ElProgress },
77
+
78
+ props: {
79
+ files: {
80
+ type: Array,
81
+ default() {
82
+ return [];
83
+ }
84
+ },
85
+ disabled: {
86
+ type: Boolean,
87
+ default: false
88
+ },
89
+ handlePreview: Function,
90
+ listType: String
91
+ },
92
+ methods: {
93
+ parsePercentage(val) {
94
+ return parseInt(val, 10);
95
+ },
96
+ handleClick(file) {
97
+ this.handlePreview && this.handlePreview(file);
98
+ }
99
+ }
100
+ };
101
+ </script>
@@ -0,0 +1,211 @@
1
+ <script>
2
+ import ajax from './ajax';
3
+ import UploadDragger from './upload-dragger.vue';
4
+
5
+ export default {
6
+ inject: ['uploader'],
7
+ components: {
8
+ UploadDragger
9
+ },
10
+ props: {
11
+ type: String,
12
+ action: {
13
+ type: String,
14
+ required: true
15
+ },
16
+ name: {
17
+ type: String,
18
+ default: 'file'
19
+ },
20
+ data: Object,
21
+ headers: Object,
22
+ withCredentials: Boolean,
23
+ multiple: Boolean,
24
+ accept: String,
25
+ onStart: Function,
26
+ onProgress: Function,
27
+ onSuccess: Function,
28
+ onError: Function,
29
+ beforeUpload: Function,
30
+ drag: Boolean,
31
+ onPreview: {
32
+ type: Function,
33
+ default: function() {}
34
+ },
35
+ onRemove: {
36
+ type: Function,
37
+ default: function() {}
38
+ },
39
+ fileList: Array,
40
+ autoUpload: Boolean,
41
+ listType: String,
42
+ httpRequest: {
43
+ type: Function,
44
+ default: ajax
45
+ },
46
+ disabled: Boolean,
47
+ limit: Number,
48
+ onExceed: Function
49
+ },
50
+
51
+ data() {
52
+ return {
53
+ mouseover: false,
54
+ reqs: {}
55
+ };
56
+ },
57
+
58
+ methods: {
59
+ isImage(str) {
60
+ return str.indexOf('image') !== -1;
61
+ },
62
+ handleChange(ev) {
63
+ const files = ev.target.files;
64
+
65
+ if (!files) return;
66
+ this.uploadFiles(files);
67
+ },
68
+ uploadFiles(files) {
69
+ if (this.limit && this.fileList.length + files.length > this.limit) {
70
+ this.onExceed && this.onExceed(files, this.fileList);
71
+ return;
72
+ }
73
+
74
+ let postFiles = Array.prototype.slice.call(files);
75
+ if (!this.multiple) { postFiles = postFiles.slice(0, 1); }
76
+
77
+ if (postFiles.length === 0) { return; }
78
+
79
+ postFiles.forEach(rawFile => {
80
+ this.onStart(rawFile);
81
+ if (this.autoUpload) this.upload(rawFile);
82
+ });
83
+ },
84
+ upload(rawFile) {
85
+ this.$refs.input.value = null;
86
+
87
+ if (!this.beforeUpload) {
88
+ return this.post(rawFile);
89
+ }
90
+
91
+ const before = this.beforeUpload(rawFile);
92
+ if (before && before.then) {
93
+ before.then(processedFile => {
94
+ const fileType = Object.prototype.toString.call(processedFile);
95
+
96
+ if (fileType === '[object File]' || fileType === '[object Blob]') {
97
+ if (fileType === '[object Blob]') {
98
+ processedFile = new File([processedFile], rawFile.name, {
99
+ type: rawFile.type
100
+ });
101
+ }
102
+ for (const p in rawFile) {
103
+ if (rawFile.hasOwnProperty(p)) {
104
+ processedFile[p] = rawFile[p];
105
+ }
106
+ }
107
+ this.post(processedFile);
108
+ } else {
109
+ this.post(rawFile);
110
+ }
111
+ }, () => {
112
+ this.onRemove(null, rawFile);
113
+ });
114
+ } else if (before !== false) {
115
+ this.post(rawFile);
116
+ } else {
117
+ this.onRemove(null, rawFile);
118
+ }
119
+ },
120
+ abort(file) {
121
+ const { reqs } = this;
122
+ if (file) {
123
+ let uid = file;
124
+ if (file.uid) uid = file.uid;
125
+ if (reqs[uid]) {
126
+ reqs[uid].abort();
127
+ }
128
+ } else {
129
+ Object.keys(reqs).forEach((uid) => {
130
+ if (reqs[uid]) reqs[uid].abort();
131
+ delete reqs[uid];
132
+ });
133
+ }
134
+ },
135
+ post(rawFile) {
136
+ const { uid } = rawFile;
137
+ const options = {
138
+ headers: this.headers,
139
+ withCredentials: this.withCredentials,
140
+ file: rawFile,
141
+ data: this.data,
142
+ filename: this.name,
143
+ action: this.action,
144
+ onProgress: e => {
145
+ this.onProgress(e, rawFile);
146
+ },
147
+ onSuccess: res => {
148
+ this.onSuccess(res, rawFile);
149
+ delete this.reqs[uid];
150
+ },
151
+ onError: err => {
152
+ this.onError(err, rawFile);
153
+ delete this.reqs[uid];
154
+ }
155
+ };
156
+ const req = this.httpRequest(options);
157
+ this.reqs[uid] = req;
158
+ if (req && req.then) {
159
+ req.then(options.onSuccess, options.onError);
160
+ }
161
+ },
162
+ handleClick() {
163
+ if (!this.disabled) {
164
+ this.$refs.input.value = null;
165
+ this.$refs.input.click();
166
+ }
167
+ },
168
+ handleKeydown(e) {
169
+ if (e.target !== e.currentTarget) return;
170
+ if (e.keyCode === 13 || e.keyCode === 32) {
171
+ this.handleClick();
172
+ }
173
+ }
174
+ },
175
+
176
+ render(h) {
177
+ let {
178
+ handleClick,
179
+ drag,
180
+ name,
181
+ handleChange,
182
+ multiple,
183
+ accept,
184
+ listType,
185
+ uploadFiles,
186
+ disabled,
187
+ handleKeydown
188
+ } = this;
189
+ const data = {
190
+ class: {
191
+ 'el-upload': true
192
+ },
193
+ on: {
194
+ click: handleClick,
195
+ keydown: handleKeydown
196
+ }
197
+ };
198
+ data.class[`el-upload--${listType}`] = true;
199
+ return (
200
+ <div {...data} tabindex="0" >
201
+ {
202
+ drag
203
+ ? <upload-dragger disabled={disabled} on-file={uploadFiles}>{this.$slots.default}</upload-dragger>
204
+ : this.$slots.default
205
+ }
206
+ <input class="el-upload__input" type="file" ref="input" name={name} on-change={handleChange} multiple={multiple} accept={accept}></input>
207
+ </div>
208
+ );
209
+ }
210
+ };
211
+ </script>