@tagplus/components 0.2.108 → 1.0.0
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.
- package/dist/tp.common.js +1 -8714
- package/dist/tp.common.js.map +1 -1
- package/dist/tp.css +1 -1
- package/dist/tp.umd.js +1 -8724
- package/dist/tp.umd.js.map +1 -1
- package/dist/tp.umd.min.js +1 -1
- package/dist/tp.umd.min.js.map +1 -1
- package/package.json +22 -16
- package/src/components/Autosuggest/Autosuggest.vue +39 -39
- package/src/components/Inline/Inline.vue +9 -10
- package/src/components/Inline/index.js +1 -1
- package/src/components/InputNumber/InputNumber.vue +3 -3
- package/src/components/InputNumber/index.js +1 -1
- package/src/components/Loader/Loader.vue +6 -6
- package/src/components/Loader/index.js +1 -1
- package/src/components/Money/Money.vue +9 -9
- package/src/components/Money/index.js +1 -1
- package/src/components/Multisuggest/Multisuggest.vue +39 -40
- package/src/components/OptionsList/OptionsList.vue +1 -1
- package/src/components/OptionsList/index.js +1 -1
- package/src/components/OptionsListItem/OptionsListItem.vue +4 -4
- package/src/components/OptionsListItem/index.js +1 -1
- package/src/components/Percent/Percent.vue +9 -9
- package/src/components/Percent/index.js +1 -1
- package/src/components/Skeleton/Skeleton.vue +7 -7
- package/src/components/Skeleton/index.js +1 -1
- package/src/components/Step/Step.vue +222 -0
- package/src/components/Step/index.js +3 -0
- package/src/components/Steps/Steps.vue +19 -0
- package/src/components/Steps/index.js +3 -0
- package/src/components/Tip/Tip.vue +19 -15
- package/src/components/Tip/index.js +2 -2
- package/src/components/index.js +5 -1
- package/src/locale/index.js +13 -15
- package/src/locale/lang/en.js +3 -3
- package/src/locale/lang/pt-br.js +3 -3
- package/src/main.js +3 -6
- package/src/mixins/locale.js +2 -2
- package/src/utils/currency.js +15 -15
- package/src/utils/filters.js +9 -14
|
@@ -344,7 +344,7 @@ export default {
|
|
|
344
344
|
}
|
|
345
345
|
},
|
|
346
346
|
|
|
347
|
-
data() {
|
|
347
|
+
data () {
|
|
348
348
|
return {
|
|
349
349
|
selectedLabelsArray: [],
|
|
350
350
|
selectedLabels: ''
|
|
@@ -352,19 +352,18 @@ export default {
|
|
|
352
352
|
},
|
|
353
353
|
|
|
354
354
|
computed: {
|
|
355
|
-
_id() {
|
|
355
|
+
_id () {
|
|
356
356
|
return this.id || this.$options.name
|
|
357
357
|
},
|
|
358
358
|
|
|
359
359
|
/**
|
|
360
360
|
* Trata o caso que o autosuggest recebe um objeto com o valueKey e labelKey
|
|
361
361
|
*/
|
|
362
|
-
formatedValue() {
|
|
362
|
+
formatedValue () {
|
|
363
363
|
let newVal = ''
|
|
364
364
|
if (typeof this.value === 'boolean') {
|
|
365
365
|
newVal = ''
|
|
366
|
-
}
|
|
367
|
-
else if (Array.isArray(this.value)) {
|
|
366
|
+
} else if (Array.isArray(this.value)) {
|
|
368
367
|
this.value.forEach((item) => {
|
|
369
368
|
if (!item[this.valueKey]) {
|
|
370
369
|
if (process.env.DEBUG === 'true') {
|
|
@@ -372,31 +371,31 @@ export default {
|
|
|
372
371
|
}
|
|
373
372
|
}
|
|
374
373
|
})
|
|
375
|
-
|
|
374
|
+
|
|
376
375
|
newVal = this.value
|
|
377
376
|
}
|
|
378
377
|
|
|
379
378
|
return newVal
|
|
380
379
|
},
|
|
381
|
-
iconClass() {
|
|
380
|
+
iconClass () {
|
|
382
381
|
return this.visible ? 'arrow-up is-reverse' : 'arrow-up'
|
|
383
382
|
},
|
|
384
|
-
showNewOption() {
|
|
385
|
-
|
|
383
|
+
showNewOption () {
|
|
384
|
+
const hasExistingOption = this.options
|
|
386
385
|
.filter(option => !option.created)
|
|
387
386
|
.some(option => option.currentLabel === this.query)
|
|
388
387
|
return this.filterable && this.allowCreate && !hasExistingOption
|
|
389
388
|
},
|
|
390
389
|
// Monta a lista com ou sem "Cadastrar Novo Item"
|
|
391
|
-
suggestionsList() {
|
|
390
|
+
suggestionsList () {
|
|
392
391
|
if (this.loading) return []
|
|
393
|
-
//transformando em Array
|
|
394
|
-
|
|
392
|
+
// transformando em Array
|
|
393
|
+
const list =
|
|
395
394
|
typeof this.suggestions === 'object'
|
|
396
395
|
? Object.values(this.suggestions)
|
|
397
396
|
: this.suggestions
|
|
398
397
|
if (this.allowCreate) {
|
|
399
|
-
|
|
398
|
+
const createdSuggestion = { created: true }
|
|
400
399
|
createdSuggestion[this.valueKey] = this.query !== '' ? this.query : null
|
|
401
400
|
createdSuggestion[this.labelKey] = ''
|
|
402
401
|
list.push(createdSuggestion)
|
|
@@ -404,12 +403,13 @@ export default {
|
|
|
404
403
|
return list
|
|
405
404
|
},
|
|
406
405
|
|
|
407
|
-
emptyText() {
|
|
406
|
+
emptyText () {
|
|
408
407
|
if (this.loading) {
|
|
409
408
|
return this.loadingText || this.t('el.select.loading')
|
|
410
409
|
} else {
|
|
411
410
|
if (this.remote && this.query === '' && this.options.length === 0) {
|
|
412
|
-
return this.noDataText || this.$tpI18n.t('autosuggests.sem_dados')
|
|
411
|
+
return this.noDataText || this.$tpI18n.t('autosuggests.sem_dados')
|
|
412
|
+
}
|
|
413
413
|
if (this.filterable && this.query && this.options.length > 0 && this.filteredOptionsCount === 0) {
|
|
414
414
|
return this.noMatchText || this.t('el.select.noMatch')
|
|
415
415
|
}
|
|
@@ -423,19 +423,19 @@ export default {
|
|
|
423
423
|
|
|
424
424
|
watch: {
|
|
425
425
|
// eslint-disable-next-line no-unused-vars
|
|
426
|
-
value(newValue, oldValue) {
|
|
426
|
+
value (newValue, oldValue) {
|
|
427
427
|
// Se limpou com o X
|
|
428
428
|
if (!Array.isArray(newValue)) {
|
|
429
429
|
this.selectedLabelsArray = []
|
|
430
430
|
} else if (newValue.length > oldValue.length) {
|
|
431
|
-
|
|
431
|
+
const novoItem = newValue.filter(x => !oldValue.includes(x))
|
|
432
432
|
this.suggestionsList.forEach(item => {
|
|
433
433
|
if (item[this.valueKey] === novoItem[0]) {
|
|
434
434
|
this.selectedLabelsArray.push(item)
|
|
435
435
|
}
|
|
436
436
|
})
|
|
437
437
|
} else {
|
|
438
|
-
|
|
438
|
+
const itemApagado = oldValue.filter(x => !newValue.includes(x))
|
|
439
439
|
this.selectedLabelsArray.forEach((item, index) => {
|
|
440
440
|
if (item.id === itemApagado[0]) {
|
|
441
441
|
this.selectedLabelsArray.splice(index, 1)
|
|
@@ -451,7 +451,7 @@ export default {
|
|
|
451
451
|
}
|
|
452
452
|
},
|
|
453
453
|
|
|
454
|
-
created() {
|
|
454
|
+
created () {
|
|
455
455
|
this.debouncedQueryChange = debounce(this.debounce, e => {
|
|
456
456
|
if (e.isComposing) {
|
|
457
457
|
// Se está apagando
|
|
@@ -473,16 +473,16 @@ export default {
|
|
|
473
473
|
}
|
|
474
474
|
})
|
|
475
475
|
|
|
476
|
-
if(Array.isArray(this.value)){
|
|
477
|
-
this.value.forEach((item,key) => {
|
|
476
|
+
if (Array.isArray(this.value)) {
|
|
477
|
+
this.value.forEach((item, key) => {
|
|
478
478
|
if (item[this.valueKey]) {
|
|
479
479
|
this.value[key] = item[this.valueKey]
|
|
480
|
-
if(item[this.labelKey]) {
|
|
480
|
+
if (item[this.labelKey]) {
|
|
481
481
|
this.selectedLabelsArray.push(item)
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
484
|
})
|
|
485
|
-
}else if(process.env.DEBUG === 'true'){
|
|
485
|
+
} else if (process.env.DEBUG === 'true') {
|
|
486
486
|
console.log(`'${this.$options.name}' recebeu valor em formato inválido.`)
|
|
487
487
|
console.log(this.value)
|
|
488
488
|
}
|
|
@@ -508,7 +508,7 @@ export default {
|
|
|
508
508
|
},
|
|
509
509
|
|
|
510
510
|
methods: {
|
|
511
|
-
emitChange(val) {
|
|
511
|
+
emitChange (val) {
|
|
512
512
|
if (!valueEquals(this.formatedValue, val)) {
|
|
513
513
|
this.$nextTick(() => {
|
|
514
514
|
this.$emit('change', val, this.createdSelected)
|
|
@@ -517,7 +517,7 @@ export default {
|
|
|
517
517
|
},
|
|
518
518
|
|
|
519
519
|
// eslint-disable-next-line no-unused-vars
|
|
520
|
-
clearTags(event) {
|
|
520
|
+
clearTags (event) {
|
|
521
521
|
// Faz uma requisição limpa
|
|
522
522
|
this.query = ''
|
|
523
523
|
this.doRequest = true
|
|
@@ -534,7 +534,7 @@ export default {
|
|
|
534
534
|
/**
|
|
535
535
|
* Sobrescreve o getOption do select para mostrar o labelValue em vez do idValue
|
|
536
536
|
*/
|
|
537
|
-
getOption(val) {
|
|
537
|
+
getOption (val) {
|
|
538
538
|
let value = ''
|
|
539
539
|
let initialLabel = false
|
|
540
540
|
|
|
@@ -542,9 +542,8 @@ export default {
|
|
|
542
542
|
value = ''
|
|
543
543
|
} else if (Array.isArray(val)) {
|
|
544
544
|
value = val
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
// Se val for Object converte para outro tipo
|
|
545
|
+
} else if (val && typeof val === 'object') {
|
|
546
|
+
// Se val for Object converte para outro tipo
|
|
548
547
|
if (!val[this.valueKey]) {
|
|
549
548
|
console.error(`Multisuggest '${this.$options.name}' option doesn't have a valueKey '${this.valueKey}' key`)
|
|
550
549
|
} else {
|
|
@@ -581,16 +580,16 @@ export default {
|
|
|
581
580
|
}
|
|
582
581
|
if (option) return option
|
|
583
582
|
const label = !isObject && !isNull && !isUndefined ? value : ''
|
|
584
|
-
|
|
585
|
-
value
|
|
586
|
-
currentLabel: initialLabel
|
|
583
|
+
const newOption = {
|
|
584
|
+
value,
|
|
585
|
+
currentLabel: initialLabel || label
|
|
587
586
|
}
|
|
588
587
|
if (this.multiple) {
|
|
589
588
|
newOption.hitState = false
|
|
590
589
|
}
|
|
591
590
|
return newOption
|
|
592
591
|
},
|
|
593
|
-
checkDefaultFirstOption() {
|
|
592
|
+
checkDefaultFirstOption () {
|
|
594
593
|
this.$nextTick(() => {
|
|
595
594
|
this.hoverIndex = -1
|
|
596
595
|
|
|
@@ -615,7 +614,7 @@ export default {
|
|
|
615
614
|
/**
|
|
616
615
|
* Sobrescreve a função de abrir menu do select para fazer a busca quando loadOnCreate = false
|
|
617
616
|
*/
|
|
618
|
-
toggleMenu() {
|
|
617
|
+
toggleMenu () {
|
|
619
618
|
if (!this.selectDisabled) {
|
|
620
619
|
// Se mantem visivel quando clica nele aberto
|
|
621
620
|
if (this.menuVisibleOnFocus) {
|
|
@@ -631,7 +630,7 @@ export default {
|
|
|
631
630
|
}
|
|
632
631
|
},
|
|
633
632
|
|
|
634
|
-
handleClose() {
|
|
633
|
+
handleClose () {
|
|
635
634
|
this.visible && this.$emit('closeSelect')
|
|
636
635
|
this.visible = false
|
|
637
636
|
// Limpa busca quando fecha
|
|
@@ -641,8 +640,8 @@ export default {
|
|
|
641
640
|
/**
|
|
642
641
|
* Sobrescreve função do select
|
|
643
642
|
*/
|
|
644
|
-
handleQueryChange(val, forceBusca = false) {
|
|
645
|
-
|
|
643
|
+
handleQueryChange (val, forceBusca = false) {
|
|
644
|
+
const _this6 = this
|
|
646
645
|
// Correção aqui para forçar primeira request com createOnLoad = false
|
|
647
646
|
// Não considera isOnComposition mais
|
|
648
647
|
if (!this.doRequest && this.previousQuery === val) return
|
|
@@ -657,13 +656,13 @@ export default {
|
|
|
657
656
|
}
|
|
658
657
|
}
|
|
659
658
|
this.previousQuery = val
|
|
660
|
-
this.$nextTick(function() {
|
|
659
|
+
this.$nextTick(function () {
|
|
661
660
|
if (_this6.visible) _this6.broadcast('ElSelectDropdown', 'updatePopper')
|
|
662
661
|
})
|
|
663
662
|
this.hoverIndex = -1
|
|
664
663
|
if (this.multiple && this.filterable) {
|
|
665
|
-
this.$nextTick(function() {
|
|
666
|
-
|
|
664
|
+
this.$nextTick(function () {
|
|
665
|
+
const length = _this6.$refs.input.value.length * 15 + 20
|
|
667
666
|
_this6.inputLength = _this6.collapseTags
|
|
668
667
|
? Math.min(50, length)
|
|
669
668
|
: length
|
|
@@ -57,7 +57,7 @@ export default {
|
|
|
57
57
|
},
|
|
58
58
|
checked: {
|
|
59
59
|
type: Boolean,
|
|
60
|
-
default: false
|
|
60
|
+
default: false
|
|
61
61
|
},
|
|
62
62
|
type: {
|
|
63
63
|
type: String,
|
|
@@ -66,14 +66,14 @@ export default {
|
|
|
66
66
|
active: {
|
|
67
67
|
type: String,
|
|
68
68
|
default: ''
|
|
69
|
-
}
|
|
69
|
+
}
|
|
70
70
|
},
|
|
71
71
|
methods: {
|
|
72
72
|
updateOption () {
|
|
73
73
|
this.$emit('updateValor', this.optValue)
|
|
74
74
|
this.$emit('input', this.optValue)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
77
|
}
|
|
78
78
|
</script>
|
|
79
79
|
|
|
@@ -39,34 +39,34 @@ export default {
|
|
|
39
39
|
required: false,
|
|
40
40
|
default: null
|
|
41
41
|
},
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
// remove o simbolo em prepend
|
|
44
44
|
removePrepend: {
|
|
45
|
-
type:Boolean,
|
|
45
|
+
type: Boolean,
|
|
46
46
|
default: false
|
|
47
|
-
},
|
|
47
|
+
},
|
|
48
48
|
|
|
49
49
|
// coloca o simbolo no append
|
|
50
50
|
showAppend: {
|
|
51
|
-
type:Boolean,
|
|
51
|
+
type: Boolean,
|
|
52
52
|
default: false
|
|
53
|
-
},
|
|
53
|
+
},
|
|
54
54
|
|
|
55
|
-
//valor do campo. Pode ser usado como v-model também
|
|
55
|
+
// valor do campo. Pode ser usado como v-model também
|
|
56
56
|
value: {
|
|
57
57
|
type: [Number, String],
|
|
58
58
|
default: 0
|
|
59
59
|
},
|
|
60
60
|
|
|
61
|
-
//tamanho máximo do campo. limitado por padrão a 21 caracteres por limitações do JS
|
|
61
|
+
// tamanho máximo do campo. limitado por padrão a 21 caracteres por limitações do JS
|
|
62
62
|
maxlength: {
|
|
63
63
|
type: Number,
|
|
64
64
|
default: 21
|
|
65
|
-
}
|
|
65
|
+
}
|
|
66
66
|
},
|
|
67
67
|
|
|
68
68
|
computed: {
|
|
69
|
-
_id(){
|
|
69
|
+
_id () {
|
|
70
70
|
return this.id || this.$options.name
|
|
71
71
|
}
|
|
72
72
|
},
|
|
@@ -40,7 +40,7 @@ export default {
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Largura em "%"". Quando círculo, em "px"
|
|
43
|
-
*
|
|
43
|
+
*
|
|
44
44
|
*/
|
|
45
45
|
width: {
|
|
46
46
|
type: Number,
|
|
@@ -68,15 +68,15 @@ export default {
|
|
|
68
68
|
},
|
|
69
69
|
|
|
70
70
|
computed: {
|
|
71
|
-
cWidth() {
|
|
72
|
-
if(this.circle && this.width){
|
|
71
|
+
cWidth () {
|
|
72
|
+
if (this.circle && this.width) {
|
|
73
73
|
return `${this.width}px`
|
|
74
74
|
}
|
|
75
75
|
return `${this.width}%`
|
|
76
76
|
},
|
|
77
77
|
|
|
78
|
-
cHeight() {
|
|
79
|
-
if(this.circle && this.width){
|
|
78
|
+
cHeight () {
|
|
79
|
+
if (this.circle && this.width) {
|
|
80
80
|
return `${this.width}px`
|
|
81
81
|
}
|
|
82
82
|
return `${this.height}em`
|
|
@@ -98,7 +98,7 @@ export default {
|
|
|
98
98
|
.tp-skeleton {
|
|
99
99
|
display: block;
|
|
100
100
|
height: 100%;
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
--baseColor: #ebeef2;
|
|
103
103
|
|
|
104
104
|
span {
|
|
@@ -132,4 +132,4 @@ export default {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
</style>
|
|
135
|
+
</style>
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="el-step"
|
|
4
|
+
:style="style"
|
|
5
|
+
:class="[
|
|
6
|
+
!isSimple && `is-${$parent.direction}`,
|
|
7
|
+
isSimple && 'is-simple',
|
|
8
|
+
isLast && !space && !isCenter && 'is-flex',
|
|
9
|
+
isCenter && !isVertical && !isSimple && 'is-center']"
|
|
10
|
+
>
|
|
11
|
+
<!-- icon & line -->
|
|
12
|
+
<div
|
|
13
|
+
class="el-step__head"
|
|
14
|
+
:class="`is-${currentStatus === 'active' ? 'finish' : currentStatus}`"
|
|
15
|
+
>
|
|
16
|
+
<div
|
|
17
|
+
class="el-step__line"
|
|
18
|
+
:style="isLast ? '' : { marginRight: $parent.stepOffset + 'px' }"
|
|
19
|
+
>
|
|
20
|
+
<i class="el-step__line-inner" :style="lineStyle" />
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<div class="el-step__icon" :class="`is-${icon ? 'icon' : 'text'}`">
|
|
24
|
+
<slot
|
|
25
|
+
v-if="currentStatus !== 'success' && currentStatus !== 'error'"
|
|
26
|
+
name="icon"
|
|
27
|
+
>
|
|
28
|
+
<i v-if="icon" class="el-step__icon-inner" :class="[icon]" />
|
|
29
|
+
<div v-if="!icon && !isSimple" class="el-step__icon-inner">
|
|
30
|
+
{{ index + 1 }}
|
|
31
|
+
</div>
|
|
32
|
+
</slot>
|
|
33
|
+
<i
|
|
34
|
+
v-else
|
|
35
|
+
:class="['el-icon-' + (currentStatus === 'success' ? 'check' : 'close')]"
|
|
36
|
+
class="el-step__icon-inner is-status"
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
<!-- title & description -->
|
|
41
|
+
<div class="el-step__main">
|
|
42
|
+
<div
|
|
43
|
+
ref="title"
|
|
44
|
+
class="el-step__title"
|
|
45
|
+
:class="['is-' + currentStatus]"
|
|
46
|
+
>
|
|
47
|
+
<slot name="title">
|
|
48
|
+
{{ title }}
|
|
49
|
+
</slot>
|
|
50
|
+
</div>
|
|
51
|
+
<div v-if="isSimple" class="el-step__arrow" />
|
|
52
|
+
<div
|
|
53
|
+
v-else
|
|
54
|
+
class="el-step__description"
|
|
55
|
+
:class="['is-' + currentStatus]"
|
|
56
|
+
>
|
|
57
|
+
<slot name="description">
|
|
58
|
+
{{ description }}
|
|
59
|
+
</slot>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</template>
|
|
64
|
+
<script>
|
|
65
|
+
export default {
|
|
66
|
+
name: 'TpStep',
|
|
67
|
+
|
|
68
|
+
props: {
|
|
69
|
+
title: {
|
|
70
|
+
type: String,
|
|
71
|
+
default: ''
|
|
72
|
+
},
|
|
73
|
+
icon: {
|
|
74
|
+
type: String,
|
|
75
|
+
default: ''
|
|
76
|
+
},
|
|
77
|
+
description: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: ''
|
|
80
|
+
},
|
|
81
|
+
status: {
|
|
82
|
+
type: String,
|
|
83
|
+
default: ''
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
data () {
|
|
88
|
+
return {
|
|
89
|
+
index: -1,
|
|
90
|
+
lineStyle: {},
|
|
91
|
+
internalStatus: ''
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
computed: {
|
|
96
|
+
currentStatus () {
|
|
97
|
+
return this.internalStatus
|
|
98
|
+
},
|
|
99
|
+
prevStatus () {
|
|
100
|
+
const prevStep = this.$parent.steps[this.index - 1]
|
|
101
|
+
return prevStep ? prevStep.currentStatus : 'wait'
|
|
102
|
+
},
|
|
103
|
+
isCenter () {
|
|
104
|
+
return this.$parent.alignCenter
|
|
105
|
+
},
|
|
106
|
+
isVertical () {
|
|
107
|
+
return this.$parent.direction === 'vertical'
|
|
108
|
+
},
|
|
109
|
+
isSimple () {
|
|
110
|
+
return this.$parent.simple
|
|
111
|
+
},
|
|
112
|
+
isLast () {
|
|
113
|
+
const parent = this.$parent
|
|
114
|
+
return parent.steps[parent.steps.length - 1] === this
|
|
115
|
+
},
|
|
116
|
+
stepsCount () {
|
|
117
|
+
return this.$parent.steps.length
|
|
118
|
+
},
|
|
119
|
+
space () {
|
|
120
|
+
const { isSimple, $parent: { space } } = this
|
|
121
|
+
return isSimple ? '' : space
|
|
122
|
+
},
|
|
123
|
+
style: function () {
|
|
124
|
+
const style = {}
|
|
125
|
+
const parent = this.$parent
|
|
126
|
+
const len = parent.steps.length
|
|
127
|
+
|
|
128
|
+
const space = (typeof this.space === 'number'
|
|
129
|
+
? this.space + 'px'
|
|
130
|
+
: this.space
|
|
131
|
+
? this.space
|
|
132
|
+
: 100 / (len - (this.isCenter ? 0 : 1)) + '%')
|
|
133
|
+
style.flexBasis = space
|
|
134
|
+
if (this.isVertical) return style
|
|
135
|
+
if (this.isLast) {
|
|
136
|
+
style.maxWidth = 100 / this.stepsCount + '%'
|
|
137
|
+
} else {
|
|
138
|
+
style.marginRight = -this.$parent.stepOffset + 'px'
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return style
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
watch: {
|
|
146
|
+
status (newVal) {
|
|
147
|
+
if (newVal === 'process' || newVal === 'error') {
|
|
148
|
+
this.updateStatus(this.$parent.active)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
beforeCreate () {
|
|
155
|
+
this.$parent.steps.push(this)
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
beforeDestroy () {
|
|
159
|
+
const steps = this.$parent.steps
|
|
160
|
+
const index = steps.indexOf(this)
|
|
161
|
+
if (index >= 0) {
|
|
162
|
+
steps.splice(index, 1)
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
mounted () {
|
|
167
|
+
const unwatch = this.$watch('index', () => {
|
|
168
|
+
this.$watch('$parent.active', this.updateStatus, { immediate: true })
|
|
169
|
+
this.$watch('$parent.processStatus', () => {
|
|
170
|
+
const activeIndex = this.$parent.active
|
|
171
|
+
this.updateStatus(activeIndex)
|
|
172
|
+
}, { immediate: true })
|
|
173
|
+
unwatch()
|
|
174
|
+
})
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
methods: {
|
|
178
|
+
updateStatus (val) {
|
|
179
|
+
const prevChild = this.$parent.$children[this.index - 1]
|
|
180
|
+
|
|
181
|
+
if (this.status === 'error') {
|
|
182
|
+
this.internalStatus = 'error'
|
|
183
|
+
} else if (val > this.index) {
|
|
184
|
+
this.internalStatus = this.$parent.finishStatus
|
|
185
|
+
} else if (val === this.index && this.prevStatus !== 'error') {
|
|
186
|
+
this.internalStatus = this.$parent.processStatus
|
|
187
|
+
} else if (this.$parent.newItem && this.prevStatus !== 'error') {
|
|
188
|
+
this.internalStatus = 'wait'
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (prevChild) prevChild.calcProgress(this.internalStatus)
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
calcProgress (status) {
|
|
195
|
+
let step = 100
|
|
196
|
+
const style = {}
|
|
197
|
+
|
|
198
|
+
style.transitionDelay = 150 * this.index + 'ms'
|
|
199
|
+
// if (status === this.$parent.processStatus) {
|
|
200
|
+
// step = this.currentStatus !== 'error' ? 0 : 0
|
|
201
|
+
// } else
|
|
202
|
+
if (status === 'wait') {
|
|
203
|
+
step = 0
|
|
204
|
+
style.transitionDelay = (-50 * this.index) + 'ms'
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
style.borderWidth = step && !this.isSimple ? '1px' : 0
|
|
208
|
+
this.$parent.direction === 'vertical'
|
|
209
|
+
? style.height = step + '%'
|
|
210
|
+
: style.width = step + '%'
|
|
211
|
+
|
|
212
|
+
this.lineStyle = style
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
</script>
|
|
217
|
+
<style lang="scss" scoped>
|
|
218
|
+
.el-step__head.is-process {
|
|
219
|
+
color: #2d6eda;
|
|
220
|
+
border-color: #2d6eda;
|
|
221
|
+
}
|
|
222
|
+
</style>
|