xt-element-ui 1.3.2 → 1.3.4
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/CHANGELOG.md +72 -72
- package/LICENSE +21 -21
- package/README.md +240 -240
- package/docs/README.md +100 -100
- package/docs/components/base/xt-button.md +114 -114
- package/docs/components/base/xt-card-item.md +104 -104
- package/docs/components/base/xt-card.md +108 -108
- package/docs/components/base/xt-config-provider.md +199 -199
- package/docs/components/base/xt-flex-box.md +115 -115
- package/docs/components/base/xt-grid-box.md +302 -302
- package/docs/components/base/xt-input.md +150 -150
- package/docs/components/base/xt-map-provider.md +23 -0
- package/docs/components/base/xt-map.md +331 -331
- package/docs/components/base/xt-step-price.md +165 -165
- package/docs/components/base/xt-text.md +212 -212
- package/docs/components/base/xt-time.md +165 -165
- package/docs/components/extend/ex-bar.md +67 -67
- package/docs/components/extend/ex-button.md +62 -62
- package/docs/components/extend/ex-card.md +86 -86
- package/docs/components/extend/ex-chart.md +463 -463
- package/docs/components/extend/ex-icon.md +189 -189
- package/docs/components/extend/ex-line.md +70 -70
- package/docs/components/extend/ex-multi.md +155 -155
- package/docs/components/extend/ex-pie.md +69 -69
- package/docs/components/extend/ex-select-tree.md +210 -210
- package/docs/components/extend/ex-table.md +590 -590
- package/docs/components/extend/ex-upload.md +134 -134
- package/docs/components/utils/size.md +147 -147
- package/docs/components/utils/theme.md +182 -182
- package/lib/index.common.js +4131 -4162
- package/lib/index.css +1 -1
- package/lib/index.umd.js +4099 -4129
- package/lib/index.umd.min.js +3 -3
- package/package.json +80 -81
- package/src/components/ex-button/index.js +7 -7
- package/src/components/ex-button/index.vue +66 -66
- package/src/components/ex-button/style/index.scss +67 -67
- package/src/components/ex-card/index.js +7 -7
- package/src/components/ex-card/index.vue +68 -68
- package/src/components/ex-card/style/index.scss +73 -73
- package/src/components/ex-chart/index.js +7 -7
- package/src/components/ex-chart/index.vue +136 -136
- package/src/components/ex-date-picker/index.js +7 -7
- package/src/components/ex-icon/index.js +7 -7
- package/src/components/ex-icon/index.vue +168 -168
- package/src/components/ex-icon/style/index.scss +7 -7
- package/src/components/ex-page/index.js +7 -7
- package/src/components/ex-select-tree/index.js +7 -7
- package/src/components/ex-table/ExTableCell.vue +22 -22
- package/src/components/ex-table/index.js +7 -7
- package/src/components/ex-table/virtualScrollData.js +35 -35
- package/src/components/ex-upload/index.js +7 -7
- package/src/components/index.scss +39 -39
- package/src/components/xt-button/index.js +7 -7
- package/src/components/xt-button/index.vue +97 -97
- package/src/components/xt-card/index.js +7 -7
- package/src/components/xt-card/style/index.scss +48 -48
- package/src/components/xt-card-item/index.js +7 -7
- package/src/components/xt-card-item/style/index copy.scss +71 -71
- package/src/components/xt-card-item/style/index.scss +82 -82
- package/src/components/xt-config-provider/index.js +7 -7
- package/src/components/xt-config-provider/index.vue +362 -362
- package/src/components/xt-config-provider/style/index.scss +11 -11
- package/src/components/xt-flex-box/index.js +7 -7
- package/src/components/xt-flex-box/style/index.scss +81 -81
- package/src/components/xt-grid-box/index.js +7 -7
- package/src/components/xt-grid-box/style/index.scss +92 -92
- package/src/components/xt-grid-item/index.js +7 -7
- package/src/components/xt-grid-item/index.vue +106 -106
- package/src/components/xt-input/index.js +7 -7
- package/src/components/xt-input/index.vue +66 -66
- package/src/components/xt-input/style/index.scss +84 -84
- package/src/components/xt-map/adapters/amap.js +235 -235
- package/src/components/xt-map/adapters/baidu.js +254 -254
- package/src/components/xt-map/adapters/base.js +267 -267
- package/src/components/xt-map/adapters/index.js +29 -29
- package/src/components/xt-map/adapters/tianditu.js +242 -242
- package/src/components/xt-map/config/xt-map-config.js +197 -197
- package/src/components/xt-map/index.js +8 -30
- package/src/components/xt-map/index.vue +351 -351
- package/src/components/xt-map/loaders/script-loader.js +114 -114
- package/src/components/xt-map/provider.vue +200 -200
- package/src/components/xt-map/style/index.scss +77 -77
- package/src/components/xt-map-provider/index.js +8 -0
- package/src/components/xt-step-price/index.js +10 -10
- package/src/components/xt-step-price/index.vue +272 -272
- package/src/components/xt-step-price/style/index.scss +123 -123
- package/src/components/xt-step-price-item/index.js +7 -7
- package/src/components/xt-step-price-item/index.vue +187 -187
- package/src/components/xt-text/index.js +7 -7
- package/src/components/xt-text/index.vue +1 -1
- package/src/components/xt-text/style/index.scss +92 -92
- package/src/components/xt-time/index.js +7 -7
- package/src/components/xt-time/index.vue +313 -313
- package/src/components/xt-time/style/index.scss +23 -23
- package/src/config/element-registry.js +135 -135
- package/src/index.js +162 -178
- package/src/styles/css-variables.scss +257 -257
- package/src/styles/theme/background.scss +5 -5
- package/src/styles/theme/border-radius.scss +3 -3
- package/src/styles/theme/borders.scss +3 -3
- package/src/styles/theme/colors.scss +101 -101
- package/src/styles/theme/component-variables.scss +69 -69
- package/src/styles/theme/dark-variables.scss +28 -28
- package/src/styles/theme/font.scss +12 -12
- package/src/styles/theme/index.scss +11 -11
- package/src/styles/theme/shadows.scss +2 -2
- package/src/styles/theme/spacing.scss +4 -4
- package/src/styles/theme/transitions.scss +2 -2
- package/src/styles/theme/typography.scss +4 -4
- package/src/styles/variables-export.scss +85 -85
- package/src/utils/index.js +191 -202
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
@import '../../../styles/variables.scss';
|
|
2
|
-
|
|
3
|
-
.xt-step-price {
|
|
4
|
-
padding: 12px 16px;
|
|
5
|
-
background-color: var(--xt-fill-color-blank, #ffffff);
|
|
6
|
-
border: 1px solid var(--xt-border-color-lighter, #ebeef5);
|
|
7
|
-
border-radius: var(--xt-border-radius-base, 4px);
|
|
8
|
-
|
|
9
|
-
&__header {
|
|
10
|
-
display: flex;
|
|
11
|
-
align-items: center;
|
|
12
|
-
justify-content: space-between;
|
|
13
|
-
margin-bottom: 12px;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
&__list {
|
|
17
|
-
display: flex;
|
|
18
|
-
flex-direction: column;
|
|
19
|
-
gap: 8px;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
&__empty {
|
|
23
|
-
padding: 24px;
|
|
24
|
-
text-align: center;
|
|
25
|
-
color: var(--xt-text-color-secondary, #909399);
|
|
26
|
-
font-size: var(--xt-font-size-small, 13px);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&__tip {
|
|
30
|
-
margin-top: 12px;
|
|
31
|
-
color: var(--xt-text-color-secondary, #909399);
|
|
32
|
-
font-size: var(--xt-font-size-extra-small, 12px);
|
|
33
|
-
line-height: 1.6;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
&.is-disabled {
|
|
37
|
-
background-color: var(--xt-fill-color-light, #f5f7fa);
|
|
38
|
-
opacity: 0.85;
|
|
39
|
-
pointer-events: none;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.xt-step-price-item {
|
|
44
|
-
display: flex;
|
|
45
|
-
align-items: center;
|
|
46
|
-
padding: 8px 12px;
|
|
47
|
-
gap: 8px;
|
|
48
|
-
background-color: var(--xt-fill-color-light, #f5f7fa);
|
|
49
|
-
border-radius: var(--xt-border-radius-base, 4px);
|
|
50
|
-
transition: background-color var(--xt-transition-duration-fast, 0.2s) ease;
|
|
51
|
-
|
|
52
|
-
&:hover {
|
|
53
|
-
background-color: var(--xt-fill-color, #f0f2f5);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
&__range {
|
|
57
|
-
display: inline-flex;
|
|
58
|
-
align-items: center;
|
|
59
|
-
flex: 0 0 auto;
|
|
60
|
-
color: var(--xt-text-color-regular, #606266);
|
|
61
|
-
font-size: var(--xt-font-size-small, 13px);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
&__name {
|
|
65
|
-
color: var(--xt-text-color-primary, #303133);
|
|
66
|
-
font-weight: 600;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
&__bracket {
|
|
70
|
-
margin: 0 4px;
|
|
71
|
-
color: var(--xt-text-color-secondary, #909399);
|
|
72
|
-
font-weight: 600;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
&__comma {
|
|
76
|
-
margin: 0 6px;
|
|
77
|
-
color: var(--xt-text-color-secondary, #909399);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
&__infinity {
|
|
81
|
-
display: inline-block;
|
|
82
|
-
min-width: 80px;
|
|
83
|
-
text-align: center;
|
|
84
|
-
color: var(--xt-text-color-placeholder, #c0c4cc);
|
|
85
|
-
font-size: var(--xt-font-size-small, 13px);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
&__arrow {
|
|
89
|
-
margin: 0 12px;
|
|
90
|
-
color: var(--xt-color-primary, #1890ff);
|
|
91
|
-
font-weight: 600;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
&__price {
|
|
95
|
-
display: inline-flex;
|
|
96
|
-
align-items: center;
|
|
97
|
-
flex: 1;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
&__unit {
|
|
101
|
-
margin-left: 8px;
|
|
102
|
-
color: var(--xt-text-color-regular, #606266);
|
|
103
|
-
font-size: var(--xt-font-size-small, 13px);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
&__input {
|
|
107
|
-
width: 80px;
|
|
108
|
-
text-align: center;
|
|
109
|
-
|
|
110
|
-
&--price {
|
|
111
|
-
width: 140px;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
&__delete {
|
|
116
|
-
margin-left: 12px;
|
|
117
|
-
color: var(--xt-color-danger, #f56c6c) !important;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
&__delete:hover {
|
|
121
|
-
color: var(--xt-color-danger-light-5, #f57786) !important;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
1
|
+
@import '../../../styles/variables.scss';
|
|
2
|
+
|
|
3
|
+
.xt-step-price {
|
|
4
|
+
padding: 12px 16px;
|
|
5
|
+
background-color: var(--xt-fill-color-blank, #ffffff);
|
|
6
|
+
border: 1px solid var(--xt-border-color-lighter, #ebeef5);
|
|
7
|
+
border-radius: var(--xt-border-radius-base, 4px);
|
|
8
|
+
|
|
9
|
+
&__header {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: space-between;
|
|
13
|
+
margin-bottom: 12px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&__list {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
gap: 8px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&__empty {
|
|
23
|
+
padding: 24px;
|
|
24
|
+
text-align: center;
|
|
25
|
+
color: var(--xt-text-color-secondary, #909399);
|
|
26
|
+
font-size: var(--xt-font-size-small, 13px);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&__tip {
|
|
30
|
+
margin-top: 12px;
|
|
31
|
+
color: var(--xt-text-color-secondary, #909399);
|
|
32
|
+
font-size: var(--xt-font-size-extra-small, 12px);
|
|
33
|
+
line-height: 1.6;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&.is-disabled {
|
|
37
|
+
background-color: var(--xt-fill-color-light, #f5f7fa);
|
|
38
|
+
opacity: 0.85;
|
|
39
|
+
pointer-events: none;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.xt-step-price-item {
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
padding: 8px 12px;
|
|
47
|
+
gap: 8px;
|
|
48
|
+
background-color: var(--xt-fill-color-light, #f5f7fa);
|
|
49
|
+
border-radius: var(--xt-border-radius-base, 4px);
|
|
50
|
+
transition: background-color var(--xt-transition-duration-fast, 0.2s) ease;
|
|
51
|
+
|
|
52
|
+
&:hover {
|
|
53
|
+
background-color: var(--xt-fill-color, #f0f2f5);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&__range {
|
|
57
|
+
display: inline-flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
flex: 0 0 auto;
|
|
60
|
+
color: var(--xt-text-color-regular, #606266);
|
|
61
|
+
font-size: var(--xt-font-size-small, 13px);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&__name {
|
|
65
|
+
color: var(--xt-text-color-primary, #303133);
|
|
66
|
+
font-weight: 600;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&__bracket {
|
|
70
|
+
margin: 0 4px;
|
|
71
|
+
color: var(--xt-text-color-secondary, #909399);
|
|
72
|
+
font-weight: 600;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&__comma {
|
|
76
|
+
margin: 0 6px;
|
|
77
|
+
color: var(--xt-text-color-secondary, #909399);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&__infinity {
|
|
81
|
+
display: inline-block;
|
|
82
|
+
min-width: 80px;
|
|
83
|
+
text-align: center;
|
|
84
|
+
color: var(--xt-text-color-placeholder, #c0c4cc);
|
|
85
|
+
font-size: var(--xt-font-size-small, 13px);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&__arrow {
|
|
89
|
+
margin: 0 12px;
|
|
90
|
+
color: var(--xt-color-primary, #1890ff);
|
|
91
|
+
font-weight: 600;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&__price {
|
|
95
|
+
display: inline-flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
flex: 1;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&__unit {
|
|
101
|
+
margin-left: 8px;
|
|
102
|
+
color: var(--xt-text-color-regular, #606266);
|
|
103
|
+
font-size: var(--xt-font-size-small, 13px);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&__input {
|
|
107
|
+
width: 80px;
|
|
108
|
+
text-align: center;
|
|
109
|
+
|
|
110
|
+
&--price {
|
|
111
|
+
width: 140px;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&__delete {
|
|
116
|
+
margin-left: 12px;
|
|
117
|
+
color: var(--xt-color-danger, #f56c6c) !important;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&__delete:hover {
|
|
121
|
+
color: var(--xt-color-danger-light-5, #f57786) !important;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import XtStepPriceItem from './index.vue'
|
|
2
|
-
|
|
3
|
-
XtStepPriceItem.install = function (Vue) {
|
|
4
|
-
Vue.component(XtStepPriceItem.name, XtStepPriceItem)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default XtStepPriceItem
|
|
1
|
+
import XtStepPriceItem from './index.vue'
|
|
2
|
+
|
|
3
|
+
XtStepPriceItem.install = function (Vue) {
|
|
4
|
+
Vue.component(XtStepPriceItem.name, XtStepPriceItem)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default XtStepPriceItem
|
|
8
8
|
export { XtStepPriceItem }
|
|
@@ -1,187 +1,187 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="xt-step-price-item">
|
|
3
|
-
<div class="xt-step-price-item__range">
|
|
4
|
-
<span class="xt-step-price-item__bracket">{{ finalLeftBracket }}</span>
|
|
5
|
-
<span v-if="itemsLength > 1" class="xt-step-price-item__name">第{{ index + 1 }}档</span>
|
|
6
|
-
<span class="xt-step-price-item__bracket">{{ finalRightBracket }}</span>
|
|
7
|
-
<xt-input
|
|
8
|
-
v-model.number="minInput"
|
|
9
|
-
:disabled="disabled || minLocked"
|
|
10
|
-
size="small"
|
|
11
|
-
placeholder="下限"
|
|
12
|
-
class="xt-step-price-item__input"
|
|
13
|
-
@blur="onMinBlur"
|
|
14
|
-
/>
|
|
15
|
-
<span class="xt-step-price-item__comma">-</span>
|
|
16
|
-
<xt-input
|
|
17
|
-
v-if="!isLast"
|
|
18
|
-
v-model.number="maxInput"
|
|
19
|
-
:disabled="disabled"
|
|
20
|
-
size="small"
|
|
21
|
-
placeholder="上限"
|
|
22
|
-
class="xt-step-price-item__input"
|
|
23
|
-
@blur="onMaxBlur"
|
|
24
|
-
/>
|
|
25
|
-
<span v-else class="xt-step-price-item__infinity">+∞</span>
|
|
26
|
-
</div>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<div class="xt-step-price-item__price">
|
|
30
|
-
<xt-input
|
|
31
|
-
v-model.number="priceInput"
|
|
32
|
-
:disabled="disabled"
|
|
33
|
-
size="small"
|
|
34
|
-
placeholder="价格"
|
|
35
|
-
class="xt-step-price-item__input xt-step-price-item__input--price"
|
|
36
|
-
@blur="onPriceBlur"
|
|
37
|
-
/>
|
|
38
|
-
<span class="xt-step-price-item__unit">{{ unit }}</span>
|
|
39
|
-
</div>
|
|
40
|
-
|
|
41
|
-
<xt-button
|
|
42
|
-
v-if="!disabled && removable && itemsLength > 1"
|
|
43
|
-
text
|
|
44
|
-
icon="el-icon-delete"
|
|
45
|
-
class="xt-step-price-item__delete"
|
|
46
|
-
@click="onDelete"
|
|
47
|
-
/>
|
|
48
|
-
</div>
|
|
49
|
-
</template>
|
|
50
|
-
|
|
51
|
-
<script>
|
|
52
|
-
export default {
|
|
53
|
-
name: 'XtStepPriceItem',
|
|
54
|
-
|
|
55
|
-
props: {
|
|
56
|
-
value: {
|
|
57
|
-
type: Object,
|
|
58
|
-
required: true,
|
|
59
|
-
default: () => ({ min: 0, max: null, price: 0 })
|
|
60
|
-
},
|
|
61
|
-
index: { type: Number, default: 0 },
|
|
62
|
-
isFirst: { type: Boolean, default: false },
|
|
63
|
-
isLast: { type: Boolean, default: false },
|
|
64
|
-
itemsLength: { type: Number, default: 1 },
|
|
65
|
-
removable: { type: Boolean, default: true },
|
|
66
|
-
disabled: { type: Boolean, default: false },
|
|
67
|
-
minLocked: { type: Boolean, default: false },
|
|
68
|
-
unit: { type: String, default: '元' },
|
|
69
|
-
precision: { type: Number, default: 2 },
|
|
70
|
-
// 阶梯增量:控制新增/校正时的区间跨度,默认 1
|
|
71
|
-
step: { type: Number, default: 1 },
|
|
72
|
-
// 左括号:默认 '[',传空则不显示
|
|
73
|
-
leftBracket: { type: String, default: '[' },
|
|
74
|
-
// 右括号:默认 null,走内置规则(只有1条为 ']',多条为 ')');传值则强制使用
|
|
75
|
-
rightBracket: { type: String, default: null },
|
|
76
|
-
// 字段名映射:{ min, max, price },允许传入的 value 使用自定义字段名
|
|
77
|
-
fieldKeys: {
|
|
78
|
-
type: Object,
|
|
79
|
-
default: () => ({ min: 'min', max: 'max', price: 'price' })
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
computed: {
|
|
84
|
-
keyMin() { return (this.fieldKeys && this.fieldKeys.min) || 'min' },
|
|
85
|
-
keyMax() { return (this.fieldKeys && this.fieldKeys.max) || 'max' },
|
|
86
|
-
keyPrice() { return (this.fieldKeys && this.fieldKeys.price) || 'price' },
|
|
87
|
-
finalRightBracket() {
|
|
88
|
-
if (this.rightBracket !== null && this.rightBracket !== undefined && this.rightBracket !== '') return this.rightBracket
|
|
89
|
-
return this.isLast ? ']' : ')'
|
|
90
|
-
},
|
|
91
|
-
finalLeftBracket() {
|
|
92
|
-
return (this.leftBracket === null || this.leftBracket === undefined) ? '[' : this.leftBracket
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
data() {
|
|
97
|
-
const { minVal, maxVal, priceVal } = this.getPriceItem(this.value)
|
|
98
|
-
return {
|
|
99
|
-
minInput: minVal,
|
|
100
|
-
maxInput: maxVal,
|
|
101
|
-
priceInput: priceVal
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
watch: {
|
|
106
|
-
value: {
|
|
107
|
-
deep: true,
|
|
108
|
-
immediate: true,
|
|
109
|
-
handler(val) {
|
|
110
|
-
const { minVal, maxVal, priceVal } = this.getPriceItem(val)
|
|
111
|
-
this.minInput = minVal
|
|
112
|
-
this.maxInput = maxVal
|
|
113
|
-
this.priceInput = priceVal
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
isLast(val) {
|
|
117
|
-
if (val) {
|
|
118
|
-
this.maxInput = null
|
|
119
|
-
} else {
|
|
120
|
-
const minVal = this.safeNumber(this.minInput, 0)
|
|
121
|
-
const v = this.value
|
|
122
|
-
this.maxInput = this.safeNumber(v && v[this.keyMax], minVal + 1)
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
methods: {
|
|
128
|
-
getPriceItem(value) {
|
|
129
|
-
const v = value
|
|
130
|
-
const minVal = this.safeNumber(v && v[this.keyMin], 0)
|
|
131
|
-
const maxVal = this.isLast ? null : this.safeNumber(v && v[this.keyMax], minVal + 1)
|
|
132
|
-
const priceVal = this.safeNumber(v && v[this.keyPrice], 0)
|
|
133
|
-
return {
|
|
134
|
-
minVal,
|
|
135
|
-
maxVal,
|
|
136
|
-
priceVal
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
// 统一兜底:非数字输入一律转为 fallback(默认 0)
|
|
140
|
-
safeNumber(v, fallback = 0) {
|
|
141
|
-
if (v === null || v === undefined || v === '' || v === Infinity || v === -Infinity) return fallback
|
|
142
|
-
const n = Number(v)
|
|
143
|
-
return isNaN(n) ? fallback : n
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
emitChange(partial) {
|
|
147
|
-
const next = {
|
|
148
|
-
[this.keyMin]: this.minInput,
|
|
149
|
-
[this.keyMax]: this.isLast ? null : this.maxInput,
|
|
150
|
-
[this.keyPrice]: this.priceInput,
|
|
151
|
-
...partial
|
|
152
|
-
}
|
|
153
|
-
this.$emit('input', next)
|
|
154
|
-
this.$emit('change', next, this.index)
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
onMinBlur() {
|
|
158
|
-
const v = this.safeNumber(this.minInput, 0)
|
|
159
|
-
this.minInput = v
|
|
160
|
-
this.$emit('min-change', v, this.index)
|
|
161
|
-
this.emitChange({ [this.keyMin]: v })
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
onMaxBlur() {
|
|
165
|
-
if (this.isLast) return
|
|
166
|
-
const minVal = this.safeNumber(this.minInput, 0)
|
|
167
|
-
let v = this.safeNumber(this.maxInput, minVal + 1)
|
|
168
|
-
if (v <= minVal) v = minVal + 1
|
|
169
|
-
this.maxInput = v
|
|
170
|
-
this.$emit('max-change', v, this.index)
|
|
171
|
-
this.emitChange({ [this.keyMax]: v })
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
onPriceBlur() {
|
|
175
|
-
let v = this.safeNumber(this.priceInput, 0)
|
|
176
|
-
if (v < 0) v = 0
|
|
177
|
-
v = Number(v.toFixed(this.precision))
|
|
178
|
-
this.priceInput = v
|
|
179
|
-
this.emitChange({ [this.keyPrice]: v })
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
onDelete() {
|
|
183
|
-
this.$emit('delete', this.index)
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="xt-step-price-item">
|
|
3
|
+
<div class="xt-step-price-item__range">
|
|
4
|
+
<span class="xt-step-price-item__bracket">{{ finalLeftBracket }}</span>
|
|
5
|
+
<span v-if="itemsLength > 1" class="xt-step-price-item__name">第{{ index + 1 }}档</span>
|
|
6
|
+
<span class="xt-step-price-item__bracket">{{ finalRightBracket }}</span>
|
|
7
|
+
<xt-input
|
|
8
|
+
v-model.number="minInput"
|
|
9
|
+
:disabled="disabled || minLocked"
|
|
10
|
+
size="small"
|
|
11
|
+
placeholder="下限"
|
|
12
|
+
class="xt-step-price-item__input"
|
|
13
|
+
@blur="onMinBlur"
|
|
14
|
+
/>
|
|
15
|
+
<span class="xt-step-price-item__comma">-</span>
|
|
16
|
+
<xt-input
|
|
17
|
+
v-if="!isLast"
|
|
18
|
+
v-model.number="maxInput"
|
|
19
|
+
:disabled="disabled"
|
|
20
|
+
size="small"
|
|
21
|
+
placeholder="上限"
|
|
22
|
+
class="xt-step-price-item__input"
|
|
23
|
+
@blur="onMaxBlur"
|
|
24
|
+
/>
|
|
25
|
+
<span v-else class="xt-step-price-item__infinity">+∞</span>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
<div class="xt-step-price-item__price">
|
|
30
|
+
<xt-input
|
|
31
|
+
v-model.number="priceInput"
|
|
32
|
+
:disabled="disabled"
|
|
33
|
+
size="small"
|
|
34
|
+
placeholder="价格"
|
|
35
|
+
class="xt-step-price-item__input xt-step-price-item__input--price"
|
|
36
|
+
@blur="onPriceBlur"
|
|
37
|
+
/>
|
|
38
|
+
<span class="xt-step-price-item__unit">{{ unit }}</span>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<xt-button
|
|
42
|
+
v-if="!disabled && removable && itemsLength > 1"
|
|
43
|
+
text
|
|
44
|
+
icon="el-icon-delete"
|
|
45
|
+
class="xt-step-price-item__delete"
|
|
46
|
+
@click="onDelete"
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script>
|
|
52
|
+
export default {
|
|
53
|
+
name: 'XtStepPriceItem',
|
|
54
|
+
|
|
55
|
+
props: {
|
|
56
|
+
value: {
|
|
57
|
+
type: Object,
|
|
58
|
+
required: true,
|
|
59
|
+
default: () => ({ min: 0, max: null, price: 0 })
|
|
60
|
+
},
|
|
61
|
+
index: { type: Number, default: 0 },
|
|
62
|
+
isFirst: { type: Boolean, default: false },
|
|
63
|
+
isLast: { type: Boolean, default: false },
|
|
64
|
+
itemsLength: { type: Number, default: 1 },
|
|
65
|
+
removable: { type: Boolean, default: true },
|
|
66
|
+
disabled: { type: Boolean, default: false },
|
|
67
|
+
minLocked: { type: Boolean, default: false },
|
|
68
|
+
unit: { type: String, default: '元' },
|
|
69
|
+
precision: { type: Number, default: 2 },
|
|
70
|
+
// 阶梯增量:控制新增/校正时的区间跨度,默认 1
|
|
71
|
+
step: { type: Number, default: 1 },
|
|
72
|
+
// 左括号:默认 '[',传空则不显示
|
|
73
|
+
leftBracket: { type: String, default: '[' },
|
|
74
|
+
// 右括号:默认 null,走内置规则(只有1条为 ']',多条为 ')');传值则强制使用
|
|
75
|
+
rightBracket: { type: String, default: null },
|
|
76
|
+
// 字段名映射:{ min, max, price },允许传入的 value 使用自定义字段名
|
|
77
|
+
fieldKeys: {
|
|
78
|
+
type: Object,
|
|
79
|
+
default: () => ({ min: 'min', max: 'max', price: 'price' })
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
computed: {
|
|
84
|
+
keyMin() { return (this.fieldKeys && this.fieldKeys.min) || 'min' },
|
|
85
|
+
keyMax() { return (this.fieldKeys && this.fieldKeys.max) || 'max' },
|
|
86
|
+
keyPrice() { return (this.fieldKeys && this.fieldKeys.price) || 'price' },
|
|
87
|
+
finalRightBracket() {
|
|
88
|
+
if (this.rightBracket !== null && this.rightBracket !== undefined && this.rightBracket !== '') return this.rightBracket
|
|
89
|
+
return this.isLast ? ']' : ')'
|
|
90
|
+
},
|
|
91
|
+
finalLeftBracket() {
|
|
92
|
+
return (this.leftBracket === null || this.leftBracket === undefined) ? '[' : this.leftBracket
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
data() {
|
|
97
|
+
const { minVal, maxVal, priceVal } = this.getPriceItem(this.value)
|
|
98
|
+
return {
|
|
99
|
+
minInput: minVal,
|
|
100
|
+
maxInput: maxVal,
|
|
101
|
+
priceInput: priceVal
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
watch: {
|
|
106
|
+
value: {
|
|
107
|
+
deep: true,
|
|
108
|
+
immediate: true,
|
|
109
|
+
handler(val) {
|
|
110
|
+
const { minVal, maxVal, priceVal } = this.getPriceItem(val)
|
|
111
|
+
this.minInput = minVal
|
|
112
|
+
this.maxInput = maxVal
|
|
113
|
+
this.priceInput = priceVal
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
isLast(val) {
|
|
117
|
+
if (val) {
|
|
118
|
+
this.maxInput = null
|
|
119
|
+
} else {
|
|
120
|
+
const minVal = this.safeNumber(this.minInput, 0)
|
|
121
|
+
const v = this.value
|
|
122
|
+
this.maxInput = this.safeNumber(v && v[this.keyMax], minVal + 1)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
methods: {
|
|
128
|
+
getPriceItem(value) {
|
|
129
|
+
const v = value
|
|
130
|
+
const minVal = this.safeNumber(v && v[this.keyMin], 0)
|
|
131
|
+
const maxVal = this.isLast ? null : this.safeNumber(v && v[this.keyMax], minVal + 1)
|
|
132
|
+
const priceVal = this.safeNumber(v && v[this.keyPrice], 0)
|
|
133
|
+
return {
|
|
134
|
+
minVal,
|
|
135
|
+
maxVal,
|
|
136
|
+
priceVal
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
// 统一兜底:非数字输入一律转为 fallback(默认 0)
|
|
140
|
+
safeNumber(v, fallback = 0) {
|
|
141
|
+
if (v === null || v === undefined || v === '' || v === Infinity || v === -Infinity) return fallback
|
|
142
|
+
const n = Number(v)
|
|
143
|
+
return isNaN(n) ? fallback : n
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
emitChange(partial) {
|
|
147
|
+
const next = {
|
|
148
|
+
[this.keyMin]: this.minInput,
|
|
149
|
+
[this.keyMax]: this.isLast ? null : this.maxInput,
|
|
150
|
+
[this.keyPrice]: this.priceInput,
|
|
151
|
+
...partial
|
|
152
|
+
}
|
|
153
|
+
this.$emit('input', next)
|
|
154
|
+
this.$emit('change', next, this.index)
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
onMinBlur() {
|
|
158
|
+
const v = this.safeNumber(this.minInput, 0)
|
|
159
|
+
this.minInput = v
|
|
160
|
+
this.$emit('min-change', v, this.index)
|
|
161
|
+
this.emitChange({ [this.keyMin]: v })
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
onMaxBlur() {
|
|
165
|
+
if (this.isLast) return
|
|
166
|
+
const minVal = this.safeNumber(this.minInput, 0)
|
|
167
|
+
let v = this.safeNumber(this.maxInput, minVal + 1)
|
|
168
|
+
if (v <= minVal) v = minVal + 1
|
|
169
|
+
this.maxInput = v
|
|
170
|
+
this.$emit('max-change', v, this.index)
|
|
171
|
+
this.emitChange({ [this.keyMax]: v })
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
onPriceBlur() {
|
|
175
|
+
let v = this.safeNumber(this.priceInput, 0)
|
|
176
|
+
if (v < 0) v = 0
|
|
177
|
+
v = Number(v.toFixed(this.precision))
|
|
178
|
+
this.priceInput = v
|
|
179
|
+
this.emitChange({ [this.keyPrice]: v })
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
onDelete() {
|
|
183
|
+
this.$emit('delete', this.index)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
</script>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import XtText from './index.vue'
|
|
2
|
-
|
|
3
|
-
XtText.install = function (Vue) {
|
|
4
|
-
Vue.component(XtText.name, XtText)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default XtText
|
|
1
|
+
import XtText from './index.vue'
|
|
2
|
+
|
|
3
|
+
XtText.install = function (Vue) {
|
|
4
|
+
Vue.component(XtText.name, XtText)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default XtText
|
|
8
8
|
export { XtText }
|