tianheng-ui 0.0.39 → 0.0.40

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 (35) hide show
  1. package/lib/iconfont.eot +0 -0
  2. package/lib/iconfont.svg +155 -0
  3. package/lib/iconfont.ttf +0 -0
  4. package/lib/iconfont.woff +0 -0
  5. package/lib/index.js +5 -2
  6. package/lib/tianheng-ui.js +34 -1
  7. package/lib/tianheng-ui.js.map +1 -1
  8. package/package.json +8 -2
  9. package/packages/formMaking/Container.vue +592 -0
  10. package/packages/formMaking/CusDialog.vue +134 -0
  11. package/packages/formMaking/FormConfig.vue +31 -0
  12. package/packages/formMaking/GenerateForm.vue +184 -0
  13. package/packages/formMaking/GenerateFormItem.vue +266 -0
  14. package/packages/formMaking/Upload/index.vue +451 -0
  15. package/packages/formMaking/WidgetConfig.vue +498 -0
  16. package/packages/formMaking/WidgetForm.vue +217 -0
  17. package/packages/formMaking/WidgetFormItem.vue +284 -0
  18. package/packages/formMaking/componentsConfig.js +313 -0
  19. package/packages/formMaking/generateCode.js +155 -0
  20. package/packages/formMaking/iconfont/demo.css +539 -0
  21. package/packages/formMaking/iconfont/demo_index.html +1159 -0
  22. package/packages/formMaking/iconfont/iconfont.css +189 -0
  23. package/packages/formMaking/iconfont/iconfont.eot +0 -0
  24. package/packages/formMaking/iconfont/iconfont.js +1 -0
  25. package/packages/formMaking/iconfont/iconfont.svg +155 -0
  26. package/packages/formMaking/iconfont/iconfont.ttf +0 -0
  27. package/packages/formMaking/iconfont/iconfont.woff +0 -0
  28. package/packages/formMaking/iconfont/iconfont.woff2 +0 -0
  29. package/packages/formMaking/index.js +79 -0
  30. package/packages/formMaking/lang/en-US.js +187 -0
  31. package/packages/formMaking/lang/zh-CN.js +187 -0
  32. package/packages/formMaking/styles/cover.scss +41 -0
  33. package/packages/formMaking/styles/index.scss +746 -0
  34. package/packages/formMaking/util/index.js +33 -0
  35. package/packages/formMaking/util/request.js +28 -0
@@ -0,0 +1,451 @@
1
+ <template>
2
+ <div class="fm-uplaod-container"
3
+ :id="uploadId"
4
+ >
5
+ <draggable class="drag-img-list"
6
+ v-model="fileList"
7
+ v-bind="{group: uploadId, ghostClass: 'ghost', animation: 200}"
8
+ :no-transition-on-drag="true"
9
+ >
10
+ <div
11
+ :id="item.key"
12
+ :style="{width: width+'px', height: height+'px'}"
13
+ :class="{uploading: item.status=='uploading', 'is-success': item.status=='success', 'is-diabled': disabled}"
14
+ class="upload-file" v-for="(item) in fileList" :key="item.key">
15
+ <img :src="item.url" />
16
+
17
+ <el-progress v-if="item.status=='uploading'" :width="miniWidth*0.9" class="upload-progress" type="circle" :percentage="item.percent"></el-progress>
18
+
19
+ <label class="item-status" v-if="item.status=='success'">
20
+ <i class="el-icon-upload-success el-icon-check"></i>
21
+ </label>
22
+
23
+ <div class="uplaod-action" :style="{height: miniWidth / 4 + 'px'}" v-if="!disabled">
24
+ <i class="iconfont icon-tupianyulan" :title="$t('fm.upload.preview')" @click="handlePreviewFile(item.key)" :style="{'font-size': miniWidth/8+'px'}"></i>
25
+ <i v-if="isEdit" class="iconfont icon-sync1" :title="$t('fm.upload.edit')" @click="handleEdit(item.key)" :style="{'font-size': miniWidth/8+'px'}"></i>
26
+ <i v-if="isDelete && fileList.length > min" class="iconfont icon-delete" :title="$t('fm.upload.delete')" @click="handleRemove(item.key)" :style="{'font-size': miniWidth/8+'px'}"></i>
27
+ </div>
28
+ </div>
29
+ </draggable>
30
+
31
+ <div class="el-upload el-upload--picture-card"
32
+ :class="{'is-disabled': disabled}"
33
+ v-show="(!isQiniu || (isQiniu && token)) && fileList.length < length"
34
+ :style="{width: width+'px', height: height+'px'}"
35
+ @click.self="handleAdd"
36
+ >
37
+ <i class="el-icon-plus" @click.self="handleAdd" :style="{fontSize:miniWidth/4+'px',marginTop: (-miniWidth/8)+'px', marginLeft: (-miniWidth/8)+'px'}"></i>
38
+ <input accept="image/*" v-if="multiple" multiple ref="uploadInput" @change="handleChange" type="file" :style="{width: 0, height: 0}" name="file" class="el-upload__input upload-input">
39
+ <input accept="image/*" v-else ref="uploadInput" @change="handleChange" type="file" :style="{width:0, height: 0}" name="file" class="el-upload__input upload-input">
40
+ </div>
41
+ </div>
42
+ </template>
43
+
44
+ <script>
45
+ import Viewer from 'viewerjs'
46
+ import Draggable from 'vuedraggable'
47
+ // import * as qiniu from 'qiniu-js'
48
+ require('viewerjs/dist/viewer.css')
49
+ export default {
50
+ components: {
51
+ Draggable
52
+ },
53
+ props: {
54
+ value: {
55
+ type: Array,
56
+ default: () => []
57
+ },
58
+ width: {
59
+ type: Number,
60
+ default: 100
61
+ },
62
+ height: {
63
+ type: Number,
64
+ default: 100
65
+ },
66
+ token: {
67
+ type: String,
68
+ default: ''
69
+ },
70
+ domain: {
71
+ type: String,
72
+ default: ''
73
+ },
74
+ multiple: {
75
+ type: Boolean,
76
+ default: false
77
+ },
78
+ length: {
79
+ type: Number,
80
+ default: 9
81
+ },
82
+ isQiniu: {
83
+ type: Boolean,
84
+ default: false
85
+ },
86
+ isDelete: {
87
+ type: Boolean,
88
+ default: false
89
+ },
90
+ min: {
91
+ type: Number,
92
+ default: 0
93
+ },
94
+ meitu: {
95
+ type: Boolean,
96
+ default: false
97
+ },
98
+ isEdit: {
99
+ type: Boolean,
100
+ default: false
101
+ },
102
+ action: {
103
+ type: String,
104
+ default: ''
105
+ },
106
+ disabled: {
107
+ type: Boolean,
108
+ default: false
109
+ }
110
+ },
111
+ data () {
112
+ return {
113
+ fileList: this.value.map(item => {
114
+ return {
115
+ key: item.key ? item.key : (new Date().getTime()) + '_' + Math.ceil(Math.random() * 99999),
116
+ url: item.url,
117
+ percent: item.percent ? item.percent : 100,
118
+ status: item.status ? item.status : 'success'
119
+ }
120
+ }),
121
+ viewer: null,
122
+ uploadId: 'upload_' + new Date().getTime(),
123
+ editIndex: -1,
124
+ meituIndex: -1,
125
+ }
126
+ },
127
+ computed: {
128
+ miniWidth () {
129
+ if (this.width > this.height) {
130
+ return this.height
131
+ } else {
132
+ return this.width
133
+ }
134
+ }
135
+ },
136
+ mounted () {
137
+ this.$emit('input', this.fileList)
138
+ },
139
+ methods: {
140
+ handleChange () {
141
+ console.log(this.$refs.uploadInput.files)
142
+ const files = this.$refs.uploadInput.files
143
+
144
+ for (let i = 0; i < files.length; i++) {
145
+ const file = files[i]
146
+ const reader = new FileReader()
147
+ const key = (new Date().getTime()) + '_' + Math.ceil(Math.random() * 99999)
148
+ reader.readAsDataURL(file)
149
+ reader.onload = () => {
150
+ if (this.editIndex >= 0) {
151
+
152
+ this.$set(this.fileList, this.editIndex, {
153
+ key,
154
+ url: reader.result,
155
+ percent: 0,
156
+ status: 'uploading'
157
+ })
158
+
159
+ this.editIndex = -1
160
+ } else {
161
+ this.fileList.push({
162
+ key,
163
+ url: reader.result,
164
+ percent: 0,
165
+ status: 'uploading'
166
+ })
167
+ }
168
+
169
+ this.$nextTick(() => {
170
+ if (this.isQiniu) {
171
+ this.uplaodAction2(reader.result, file, key)
172
+ } else {
173
+ this.uplaodAction(reader.result, file, key)
174
+ }
175
+ })
176
+ }
177
+ }
178
+ this.$refs.uploadInput.value = []
179
+ },
180
+ uplaodAction (res, file, key) {
181
+ let changeIndex = this.fileList.findIndex(item => item.key === key)
182
+ console.log(this.fileList.findIndex(item => item.key === key))
183
+ const xhr = new XMLHttpRequest()
184
+
185
+ const url = this.action
186
+ xhr.open('POST', url, true)
187
+ // xhr.setRequestHeader('Content-Type', 'multipart/form-data')
188
+
189
+ let formData = new FormData()
190
+ formData.append('file', file)
191
+
192
+ xhr.onreadystatechange = () => {
193
+ console.log(xhr)
194
+ if (xhr.readyState === 4) {
195
+
196
+ let resData = JSON.parse(xhr.response)
197
+ if (resData && resData.url) {
198
+ this.$set(this.fileList, this.fileList.findIndex(item => item.key === key), {
199
+ ...this.fileList[this.fileList.findIndex(item => item.key === key)],
200
+ url: resData.url,
201
+ percent: 100
202
+ })
203
+ setTimeout(() => {
204
+ this.$set(this.fileList, this.fileList.findIndex(item => item.key === key), {
205
+ ...this.fileList[this.fileList.findIndex(item => item.key === key)],
206
+ status: 'success'
207
+ })
208
+ this.$emit('input', this.fileList)
209
+ }, 200)
210
+ } else {
211
+ this.$set(this.fileList, this.fileList.findIndex(item => item.key === key), {
212
+ ...this.fileList[this.fileList.findIndex(item => item.key === key)],
213
+ status: 'error'
214
+ })
215
+ this.fileList.splice(this.fileList.findIndex(item => item.key === key), 1)
216
+ }
217
+ }
218
+ }
219
+ xhr.upload.onprogress = (res) => {
220
+ console.log('progress', res)
221
+ if (res.total && res.loaded) {
222
+ this.$set(this.fileList[this.fileList.findIndex(item => item.key === key)], 'percent', res.loaded/res.total*100)
223
+ }
224
+ }
225
+
226
+ xhr.send(formData)
227
+ },
228
+ uplaodAction2 (res, file, key) {
229
+ const _this = this
230
+ const observable = qiniu.upload(file, key, this.token, {
231
+ fname: key,
232
+ mimeType: []
233
+ }, {
234
+ useCdnDomain: true,
235
+ })
236
+ observable.subscribe({
237
+ next (res) {
238
+ _this.$set(_this.fileList[_this.fileList.findIndex(item => item.key === key)], 'percent', parseInt(res.total.percent))
239
+
240
+ },
241
+ error (err) {
242
+ _this.$set(_this.fileList, _this.fileList.findIndex(item => item.key === key), {
243
+ ..._this.fileList[_this.fileList.findIndex(item => item.key === key)],
244
+ status: 'error'
245
+ })
246
+ _this.fileList.splice(_this.fileList.findIndex(item => item.key === key), 1)
247
+ },
248
+ complete (res) {
249
+ _this.$set(_this.fileList, _this.fileList.findIndex(item => item.key === key), {
250
+ ..._this.fileList[_this.fileList.findIndex(item => item.key === key)],
251
+ url: _this.domain + res.key,
252
+ percent: 100
253
+ })
254
+ setTimeout(() => {
255
+ _this.$set(_this.fileList, _this.fileList.findIndex(item => item.key === key), {
256
+ ..._this.fileList[_this.fileList.findIndex(item => item.key === key)],
257
+ status: 'success'
258
+ })
259
+ _this.$emit('input', _this.fileList)
260
+ }, 200)
261
+ }
262
+ })
263
+ },
264
+ handleRemove (key) {
265
+ this.fileList.splice(this.fileList.findIndex(item => item.key === key), 1)
266
+ },
267
+ handleEdit (key) {
268
+
269
+ this.editIndex = this.fileList.findIndex(item => item.key === key)
270
+
271
+ this.$refs.uploadInput.click()
272
+ },
273
+ handleMeitu (key) {
274
+
275
+ this.$emit('on-meitu', this.fileList.findIndex(item => item.key === key))
276
+ },
277
+ handleAdd () {
278
+ if (!this.disabled) {
279
+ this.editIndex = -1
280
+ this.$refs.uploadInput.click()
281
+ }
282
+ },
283
+ handlePreviewFile (key) {
284
+ this.viewer && this.viewer.destroy()
285
+ this.uploadId = 'upload_' + new Date().getTime()
286
+
287
+ console.log(this.viewer)
288
+ this.$nextTick(() => {
289
+ this.viewer = new Viewer(document.getElementById(this.uploadId))
290
+ this.viewer.view(this.fileList.findIndex(item => item.key === key))
291
+ })
292
+ }
293
+ },
294
+ watch: {
295
+ 'fileList': {
296
+ deep: true,
297
+ handler (val) {
298
+ // this.$emit('input', this.fileList)
299
+ }
300
+ }
301
+ }
302
+ }
303
+ </script>
304
+
305
+ <style lang="scss">
306
+ .fm-uplaod-container{
307
+ .is-disabled{
308
+ position: relative;
309
+
310
+ &::after{
311
+ position: absolute;
312
+ top: 0;
313
+ bottom: 0;
314
+ left: 0;
315
+ right: 0;
316
+ // background: rgba(0,0,0,.1);
317
+ content: '';
318
+ display: block;
319
+ cursor:not-allowed;
320
+ }
321
+ }
322
+
323
+ .upload-file{
324
+ margin: 0 10px 10px 0;
325
+ display: inline-flex;
326
+ justify-content: center;
327
+ align-items: center;
328
+ // background: #fff;
329
+ overflow: hidden;
330
+ background-color: #fff;
331
+ border: 1px solid #c0ccda;
332
+ border-radius: 6px;
333
+ box-sizing: border-box;
334
+ position: relative;
335
+ vertical-align: top;
336
+ &:hover{
337
+ .uplaod-action{
338
+ display: flex;
339
+ }
340
+ }
341
+ .uplaod-action{
342
+ position: absolute;
343
+ // top: 0;
344
+ // height: 30px;
345
+ bottom: 0;
346
+ left: 0;
347
+ right: 0;
348
+ background: rgba(0,0,0,0.6);
349
+ display: none;
350
+ justify-content: center;
351
+ align-items: center;
352
+ i{
353
+ color: #fff;
354
+ cursor: pointer;
355
+ margin: 0 5px;
356
+ }
357
+ }
358
+ &.is-success{
359
+ .item-status{
360
+ position: absolute;
361
+ right: -15px;
362
+ top: -6px;
363
+ width: 40px;
364
+ height: 24px;
365
+ background: #13ce66;
366
+ text-align: center;
367
+ transform: rotate(45deg);
368
+ box-shadow: 0 0 1pc 1px rgba(0,0,0,.2);
369
+ &>i{
370
+ font-size: 12px;
371
+ margin-top: 11px;
372
+ color: #fff;
373
+ transform: rotate(-45deg);
374
+ }
375
+ }
376
+ }
377
+ &.uploading{
378
+ &:before{
379
+ display: block;
380
+ content: '';
381
+ position: absolute;
382
+ top: 0;
383
+ left: 0;
384
+ right: 0;
385
+ bottom: 0;
386
+ background: rgba(0,0,0,0.3);
387
+ }
388
+ }
389
+ .upload-progress{
390
+ position: absolute;
391
+ .el-progress__text{
392
+ color: #fff;
393
+ font-size: 16px !important;
394
+ }
395
+ }
396
+ img{
397
+ max-width: 100%;
398
+ max-height: 100%;
399
+ vertical-align: middle;
400
+ }
401
+ }
402
+ .el-upload--picture-card{
403
+ position: relative;
404
+ overflow: hidden;
405
+ .el-icon-plus{
406
+ position: absolute;
407
+ top: 50%;
408
+ left: 50%;
409
+ }
410
+ }
411
+ .upload-input{
412
+ position: absolute;
413
+ top: 0;
414
+ left: 0;
415
+ right: 0;
416
+ bottom: 0;
417
+ display: block;
418
+ opacity: 0;
419
+ cursor: pointer;
420
+ }
421
+
422
+ .drag-img-list{
423
+ display: inline;
424
+
425
+ .ghost{
426
+ position: relative;
427
+ &::after {
428
+ width: 100%;
429
+ height: 100%;
430
+ display: block;
431
+ content: '';
432
+ background: #fbfdff;
433
+ position: absolute;
434
+ top: 0;
435
+ bottom: 0;
436
+ left: 0;
437
+ right: 0;
438
+ border: 1px dashed #3bb3c2;
439
+ }
440
+ }
441
+
442
+ &>div{
443
+ cursor: move;
444
+ }
445
+ }
446
+ }
447
+
448
+ .viewer-container{
449
+ z-index: 9999 !important;
450
+ }
451
+ </style>