@idooel/components 0.0.1-beta.1 → 0.0.1-beta.2

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 (40) hide show
  1. package/dist/@idooel/components.esm.js +2295 -378
  2. package/dist/@idooel/components.umd.js +2306 -388
  3. package/package.json +3 -2
  4. package/packages/attachment/index.js +0 -0
  5. package/packages/attachment/src/index.vue +15 -0
  6. package/packages/batch-export/index.js +5 -0
  7. package/packages/batch-export/src/index.vue +15 -0
  8. package/packages/checkbox/index.js +5 -0
  9. package/packages/checkbox/src/index.vue +44 -0
  10. package/packages/composite-components/button-group/src/index.vue +0 -5
  11. package/packages/composite-components/search-area/src/index.vue +75 -40
  12. package/packages/form/index.js +5 -0
  13. package/packages/form/src/index.vue +119 -0
  14. package/packages/form-model/index.js +5 -0
  15. package/packages/form-model/src/index.vue +139 -0
  16. package/packages/icon/index.js +5 -0
  17. package/packages/icon/src/index.vue +32 -0
  18. package/packages/index.js +25 -2
  19. package/packages/input/src/index.vue +5 -1
  20. package/packages/input-number/index.js +5 -0
  21. package/packages/input-number/src/index.vue +24 -0
  22. package/packages/modal/index.js +5 -0
  23. package/packages/modal/src/index.vue +129 -0
  24. package/packages/radio/index.js +5 -0
  25. package/packages/radio/src/index.vue +48 -0
  26. package/packages/select-entity/index.js +5 -0
  27. package/packages/select-entity/src/index.vue +114 -0
  28. package/packages/table/src/action.vue +1 -1
  29. package/packages/text/index.js +5 -0
  30. package/packages/text/src/index.vue +15 -0
  31. package/packages/textarea/index.js +5 -0
  32. package/packages/textarea/src/index.vue +49 -0
  33. package/packages/theme/form.scss +24 -0
  34. package/packages/theme/index.scss +12 -0
  35. package/packages/theme/variables.scss +23 -1
  36. package/packages/tree-table-model/src/index.vue +35 -27
  37. package/packages/upload/index.js +5 -0
  38. package/packages/upload/src/index.vue +351 -0
  39. package/packages/utils/index.js +4 -0
  40. package/scripts/rollup.config.js +1 -1
@@ -0,0 +1,351 @@
1
+ <template>
2
+ <div class="ele-upload__wrapper">
3
+ <FileUpload
4
+ class="ele-upload__inner"
5
+ v-show="isShowUploadContainer"
6
+ v-model="files"
7
+ :ref="uploadRef"
8
+ :drop="drop"
9
+ :chunk-enabled="chunkEnabled"
10
+ :chunk="chunkConfig"
11
+ :accept="accept"
12
+ :size="fileSizeLimit"
13
+ :post-action="postAction"
14
+ :multiple="multiple"
15
+ :maximum="getMaximum"
16
+ @input-file="onWatchInputFiles"
17
+ @input="onWatchFiles"
18
+ style="width: 100%;">
19
+ <section class="ele-upload__area">
20
+ <div class="ele-upload__area--icon">
21
+ <ele-icon type="cloud-upload"></ele-icon>
22
+ </div>
23
+ <div class="ele-upload__area--text">
24
+ <div class="ele-upload__message">单击或拖动文件到该区域以上传</div>
25
+ <div class="ele-upload__ext">文件小于{{ size }}M</div>
26
+ </div>
27
+ </section>
28
+ </FileUpload>
29
+ <section class="ele-files__wrapper">
30
+ <div class="ele-file__item" v-for="(file, idx) in files" :key="idx">
31
+ <div class="ele-file__suffix--icon">
32
+ <ele-icon type="icon-doc"></ele-icon>
33
+ </div>
34
+ <div class="ele-file__name">
35
+ <div class="ele-file__inner" @click="handleClickDownload(file)">{{ file.name }}</div>
36
+ <div v-if="!file.success" class="ele-uplpad__progress">
37
+ <a-progress :strokeWidth="2" :percent="Number(file.progress)" size="small" />
38
+ </div>
39
+ </div>
40
+ <div class="ele-file__delete" v-if="file.success || file.error">
41
+ <span class="ele-file__size">{{ (file.size / byteConversion).toFixed(2) }}M</span>
42
+ <span class="ele-file__delete--icon" @click="handleClickDelete(file)">
43
+ <ele-icon type="delete"></ele-icon>
44
+ </span>
45
+ </div>
46
+ </div>
47
+ </section>
48
+ </div>
49
+ </template>
50
+
51
+ <script>
52
+ import FileUpload from 'vue-upload-component'
53
+ import { v4 as uuidv4 } from 'uuid'
54
+ import { route, net } from '@idooel/shared'
55
+ import EleIcon from '../../icon/src/index.vue'
56
+ export default {
57
+ name: 'ele-upload',
58
+ components: {
59
+ FileUpload,
60
+ EleIcon
61
+ },
62
+ model: {
63
+ prop: 'value',
64
+ event: 'change'
65
+ },
66
+ props: {
67
+ url: {
68
+ type: String,
69
+ default: '/zuul/api-file/workbench/file'
70
+ },
71
+ size: {
72
+ type: Number,
73
+ default: 100
74
+ },
75
+ accept: {
76
+ type: String
77
+ },
78
+ maximum: {
79
+ type: Number,
80
+ default: 10
81
+ },
82
+ multiple: {
83
+ type: Boolean,
84
+ default: false
85
+ },
86
+ drop: {
87
+ type: Boolean,
88
+ default: true
89
+ },
90
+ value: {
91
+ type: [String, Array]
92
+ },
93
+ querys: {
94
+ type: Object,
95
+ default: () => ({
96
+ _csrf: 'c81f993f-f044-45bb-b3af-2977d335042d',
97
+ _t: new Date().valueOf()
98
+ })
99
+ },
100
+ headers: {
101
+ type: Object,
102
+ default: () => ({})
103
+ },
104
+ byteConversion: {
105
+ type: Number,
106
+ default: 1024 * 1024
107
+ },
108
+ chunkEnabled: {
109
+ type: Boolean,
110
+ default: true
111
+ }
112
+ },
113
+ data() {
114
+ return {
115
+ files: [],
116
+ saveToServerAsyncPageTimer: null
117
+ }
118
+ },
119
+ computed: {
120
+ getPayloads () {
121
+ return {
122
+ override: false
123
+ }
124
+ },
125
+ chunkConfig () {
126
+ const ret = route.toQueryString(this.querys)
127
+ return {
128
+ action: `${window.prefixPath}/zuul/api-file/workbench/file/temp/chunk/vue`,
129
+ headers: {
130
+ 'X-XSRF-TOKEN': localStorage.getItem('token')
131
+ },
132
+ minSize: 3 * this.byteConversion,
133
+ maxActive: 3,
134
+ maxRetries: 5,
135
+ startBody: {
136
+ override: true,
137
+ path: '/cw'
138
+ },
139
+ uploadBody: {
140
+ override: true,
141
+ path: '/cw'
142
+ },
143
+ finishBody: {
144
+ override: true,
145
+ path: '/cw'
146
+ }
147
+ }
148
+ },
149
+ isFileUploadSuccessed () {
150
+ return this.files.every(file => file.success)
151
+ },
152
+ isShowUploadContainer () {
153
+ if (this.multiple) {
154
+ if (this.isFileUploadSuccessed && this.files.length >= this.maximum) {
155
+ return false
156
+ } else {
157
+ return true
158
+ }
159
+ } else {
160
+ if (this.isFileUploadSuccessed && this.files.length >= 1) {
161
+ return false
162
+ } else {
163
+ return true
164
+ }
165
+ }
166
+ },
167
+ getMaximum () {
168
+ return this.multiple ? this.maximum : 1
169
+ },
170
+ fileSizeLimit () {
171
+ return this.size * this.byteConversion
172
+ },
173
+ postAction () {
174
+ const ret = route.toQueryString(this.querys)
175
+ return `${window.prefixPath}${this.url}?${ret}`
176
+ },
177
+ uploadRef () {
178
+ return uuidv4()
179
+ },
180
+ fileSuffixIcon () {
181
+ return {
182
+ 'doc': { name: 'icon-doc' },
183
+ }
184
+ },
185
+ fileIds () {
186
+ const fileIds = this.files.map(file => {
187
+ return file.response.data.fileID
188
+ })
189
+ return this.multiple ? fileIds : fileIds[0]
190
+ }
191
+ },
192
+ methods: {
193
+ handleClickDownload (file) {
194
+ console.log('download file', file)
195
+ },
196
+ handleClickDelete (file) {
197
+ this.$refs[this.uploadRef].remove(file)
198
+ this.$emit('change', this.fileIds)
199
+ },
200
+ onWatchFiles (files) {
201
+ this.files = files
202
+ if (this.isFileUploadSuccessed) {
203
+ this.$emit('change', this.fileIds)
204
+ }
205
+ },
206
+ async saveToServerAsyncPage (payloads = {}) {
207
+ net.post('zuul/api-file/workbench/file/temp/saveToServerAsyncPage', payloads, {
208
+ headers: {
209
+ 'Content-Type': 'multipart/form-data'
210
+ }
211
+ }).then(resp =>{
212
+ const { data } = resp
213
+ if (data !== 'saveToServerAsyncPage') {
214
+ clearInterval(this.saveToServerAsyncPageTimer)
215
+ }
216
+ })
217
+ // const ret = await net.post({
218
+ // url: 'zuul/api-file/workbench/file/temp/saveToServerAsyncPage',
219
+ // method: 'POST',
220
+ // data: { ...payloads }
221
+ // }).then(resp => {
222
+ // const { data: { data, code, message } } = resp
223
+ // if (code !== '2000') {
224
+ // this.$Message.error(message)
225
+ // return
226
+ // }
227
+ // if (data !== 'saveToServerAsyncPage') {
228
+ // clearInterval(timer)
229
+ // const { fileID, size } = data
230
+ // this.$emit('on-success', { ...data, fileId: fileID })
231
+ // this.$Message.success('同步成功')
232
+ // return { fileId: fileID, size }
233
+ // }
234
+ // })
235
+ // return ret
236
+ },
237
+ onWatchInputFiles (newFile, oldFile) {
238
+ if (newFile && !oldFile) {
239
+ // add file
240
+ console.log('add', newFile)
241
+ }
242
+ if (newFile && oldFile) {
243
+ // update file
244
+ console.log('update', newFile)
245
+ const { success, active, chunk, response } = newFile
246
+ if (chunk && success && !active) {
247
+ console.log('chunk end')
248
+ const { data: { file, type } } = response
249
+ const payloads = {
250
+ filePath: file.match(/\/cw(.*)/)[0],
251
+ asyncID: uuidv4(),
252
+ isDeleteOrigin: false,
253
+ toImage: type === 'pdf' ? true : false,
254
+ unzip: type === 'zip' ? true : false,
255
+ _csrf: localStorage.getItem('token')
256
+ }
257
+ this.saveToServerAsyncPageTimer = setInterval(() => {
258
+ this.saveToServerAsyncPage(payloads)
259
+ }, 2000)
260
+ }
261
+ }
262
+ if (!newFile && oldFile) {
263
+ // delete file
264
+ console.log('delete')
265
+ }
266
+ if (Boolean(newFile) !== Boolean(oldFile) || oldFile.error !== newFile.error) {
267
+ if (!this.$refs[this.uploadRef].active) {
268
+ this.$refs[this.uploadRef].active = true
269
+ }
270
+ }
271
+ }
272
+ }
273
+ }
274
+ </script>
275
+
276
+ <style lang="scss" scoped>
277
+ ::v-deep .file-uploads {
278
+ label {
279
+ opacity: 1 !important;
280
+ cursor: pointer;
281
+ border: 1px dashed var(--idooel-form-title-border-color);
282
+ background: var(--idooel-form-upload-bg-color) !important;
283
+ &:hover {
284
+ border-color: var(--idooel-form-upload-border-hover-color);
285
+ }
286
+ border-radius: var(--idooel-form-border-radius);
287
+ }
288
+ }
289
+ .ele-upload__wrapper {
290
+ width: 100%;
291
+ .ele-upload__area {
292
+ padding: 16px;
293
+ width: 100%;
294
+ height: 80px;
295
+ display: flex;
296
+ flex-direction: row;
297
+ .ele-upload__area--icon {
298
+ .anticon-cloud-upload {
299
+ font-size: 48px;
300
+ color: var(--idooel-primary-color);
301
+ }
302
+ }
303
+ .ele-upload__area--text {
304
+ margin-left: 16px;
305
+ .ele-upload__message {
306
+ font-size: 16px;
307
+ color: var(--idoole-black-008);
308
+ text-align: left;
309
+ }
310
+ .ele-upload__ext {
311
+ text-align: left;
312
+ font-size: 14px;
313
+ color: var(--idoole-black-06);
314
+ }
315
+ }
316
+ }
317
+ .ele-files__wrapper {
318
+ .ele-file__item {
319
+ width: 100%;
320
+ margin-top: 8px;
321
+ padding: 8px 12px;
322
+ border-radius: var(--idooel-form-border-radius);
323
+ background: var(--idooel-form-upload-bg-color);
324
+ display: flex;
325
+ flex-direction: row;
326
+ align-items: center;
327
+ .ele-file__suffix--icon {}
328
+ .ele-file__name {
329
+ flex: 1;
330
+ text-align: left;
331
+ white-space: nowrap;
332
+ overflow: hidden;
333
+ font-size: 14px;
334
+ margin-left: 8px;
335
+ cursor: pointer;
336
+ .ele-file__inner {
337
+ overflow: hidden;
338
+ text-overflow: ellipsis;
339
+ }
340
+ }
341
+ .ele-file__delete {
342
+ margin-left: 8px;
343
+ .ele-file__delete--icon {
344
+ margin-left: 8px;
345
+ cursor: pointer;
346
+ }
347
+ }
348
+ }
349
+ }
350
+ }
351
+ </style>
@@ -0,0 +1,4 @@
1
+ export const BUILT_IN_EVENT_NAMES = {
2
+ SUBMIT: 'submit',
3
+ CANCEL: 'cancel'
4
+ }
@@ -12,7 +12,7 @@ import babel from 'rollup-plugin-babel'
12
12
  /** @type { import('rollup').RollupOptions } */
13
13
  export default {
14
14
  input: 'packages/index.js',
15
- external: ['vue', '@idooel/shared'],
15
+ external: ['vue', '@idooel/shared', 'vue-upload-component'],
16
16
  plugins: [
17
17
  nodeResolve(),
18
18
  babel({