xt-element-ui 1.2.5 → 1.2.7
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 -0
- package/LICENSE +21 -0
- package/README.md +240 -104
- package/docs/README.md +67 -168
- package/docs/components/base/xt-card-item.md +1 -1
- package/docs/components/base/xt-step-price.md +280 -0
- package/docs/components/base/xt-time.md +165 -0
- package/docs/components/extend/ex-chart.md +252 -144
- package/docs/components/extend/ex-date-picker.md +0 -0
- package/docs/components/extend/ex-icon.md +1 -2
- package/docs/components/extend/ex-page.md +0 -75
- package/lib/index.common.js +1172 -586
- package/lib/index.css +1 -1
- package/lib/index.umd.js +1172 -586
- package/lib/index.umd.min.js +5 -5
- package/package.json +80 -41
- package/src/components/ex-chart/ExBar.vue +35 -29
- package/src/components/ex-chart/ExLine.vue +23 -14
- package/src/components/ex-chart/ExMulti.vue +30 -52
- package/src/components/ex-chart/ExPie.vue +23 -16
- package/src/components/ex-chart/theme/dark.js +5 -4
- package/src/components/ex-chart/theme/white.js +1 -0
- package/src/components/ex-chart/utils.js +148 -7
- package/src/components/ex-date-picker/index.js +2 -0
- package/src/components/{xt-date-picker → ex-date-picker}/index.vue +1 -1
- package/src/components/index.scss +6 -0
- package/src/components/xt-card-item/index.vue +3 -1
- package/src/components/xt-step-price/index.js +2 -0
- package/src/components/xt-step-price/index.vue +270 -0
- package/src/components/xt-step-price/style/index.scss +115 -0
- package/src/components/xt-step-price-item/index.js +2 -0
- package/src/components/xt-step-price-item/index.vue +174 -0
- package/src/components/xt-time/index.js +2 -0
- package/src/components/xt-time/index.vue +313 -0
- package/src/components/xt-time/style/index.scss +23 -0
- package/src/index.js +12 -3
- package/src/components/ex-chart/theme/blue.js +0 -91
- package/src/components/ex-chart/theme/orange.js +0 -92
- package/src/components/ex-chart/theme/starry.js +0 -106
- package/src/components/xt-date-picker/index.js +0 -2
- /package/src/components/{xt-date-picker → ex-date-picker}/SearchDate.vue +0 -0
- /package/src/components/{xt-date-picker → ex-date-picker}/quarter.vue +0 -0
|
@@ -0,0 +1,174 @@
|
|
|
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
|
+
<el-input
|
|
6
|
+
v-model.number="minInput"
|
|
7
|
+
:disabled="disabled || minLocked"
|
|
8
|
+
size="small"
|
|
9
|
+
class="xt-step-price-item__input"
|
|
10
|
+
@blur="onMinBlur"
|
|
11
|
+
/>
|
|
12
|
+
<span class="xt-step-price-item__comma">,</span>
|
|
13
|
+
<el-input
|
|
14
|
+
v-if="!isLast"
|
|
15
|
+
v-model.number="maxInput"
|
|
16
|
+
:disabled="disabled"
|
|
17
|
+
size="small"
|
|
18
|
+
class="xt-step-price-item__input"
|
|
19
|
+
@blur="onMaxBlur"
|
|
20
|
+
/>
|
|
21
|
+
<span v-else class="xt-step-price-item__infinity">+∞</span>
|
|
22
|
+
<span class="xt-step-price-item__bracket">{{ finalRightBracket }}</span>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<span class="xt-step-price-item__arrow">→</span>
|
|
26
|
+
|
|
27
|
+
<div class="xt-step-price-item__price">
|
|
28
|
+
<el-input
|
|
29
|
+
v-model.number="priceInput"
|
|
30
|
+
:disabled="disabled"
|
|
31
|
+
size="small"
|
|
32
|
+
placeholder="价格"
|
|
33
|
+
class="xt-step-price-item__input xt-step-price-item__input--price"
|
|
34
|
+
@blur="onPriceBlur"
|
|
35
|
+
/>
|
|
36
|
+
<span class="xt-step-price-item__unit">{{ unit }}</span>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<el-button
|
|
40
|
+
v-if="!disabled && removable && itemsLength > 1"
|
|
41
|
+
type="text"
|
|
42
|
+
icon="el-icon-delete"
|
|
43
|
+
class="xt-step-price-item__delete"
|
|
44
|
+
@click="onDelete"
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
<script>
|
|
50
|
+
export default {
|
|
51
|
+
name: 'XtStepPriceItem',
|
|
52
|
+
|
|
53
|
+
props: {
|
|
54
|
+
value: {
|
|
55
|
+
type: Object,
|
|
56
|
+
required: true,
|
|
57
|
+
default: () => ({ min: 0, max: null, price: 0 })
|
|
58
|
+
},
|
|
59
|
+
index: { type: Number, default: 0 },
|
|
60
|
+
isFirst: { type: Boolean, default: false },
|
|
61
|
+
isLast: { type: Boolean, default: false },
|
|
62
|
+
itemsLength: { type: Number, default: 1 },
|
|
63
|
+
removable: { type: Boolean, default: true },
|
|
64
|
+
disabled: { type: Boolean, default: false },
|
|
65
|
+
minLocked: { type: Boolean, default: false },
|
|
66
|
+
unit: { type: String, default: '元' },
|
|
67
|
+
precision: { type: Number, default: 2 },
|
|
68
|
+
// 左括号:默认 '[',传空则不显示
|
|
69
|
+
leftBracket: { type: String, default: '[' },
|
|
70
|
+
// 右括号:默认 null,走内置规则(只有1条为 ']',多条为 ')');传值则强制使用
|
|
71
|
+
rightBracket: { type: String, default: null },
|
|
72
|
+
// 字段名映射:{ min, max, price },允许传入的 value 使用自定义字段名
|
|
73
|
+
fieldKeys: {
|
|
74
|
+
type: Object,
|
|
75
|
+
default: () => ({ min: 'min', max: 'max', price: 'price' })
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
computed: {
|
|
80
|
+
keyMin() { return (this.fieldKeys && this.fieldKeys.min) || 'min' },
|
|
81
|
+
keyMax() { return (this.fieldKeys && this.fieldKeys.max) || 'max' },
|
|
82
|
+
keyPrice() { return (this.fieldKeys && this.fieldKeys.price) || 'price' },
|
|
83
|
+
finalRightBracket() {
|
|
84
|
+
if (this.rightBracket !== null && this.rightBracket !== undefined && this.rightBracket !== '') return this.rightBracket
|
|
85
|
+
return this.itemsLength === 1 ? ']' : ')'
|
|
86
|
+
},
|
|
87
|
+
finalLeftBracket() {
|
|
88
|
+
return (this.leftBracket === null || this.leftBracket === undefined) ? '[' : this.leftBracket
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
data() {
|
|
93
|
+
const v = this.value
|
|
94
|
+
const minVal = this.safeNumber(v && v[this.keyMin], 0)
|
|
95
|
+
const maxVal = this.isLast ? null : this.safeNumber(v && v[this.keyMax], minVal + 1)
|
|
96
|
+
const priceVal = this.safeNumber(v && v[this.keyPrice], 0)
|
|
97
|
+
return {
|
|
98
|
+
minInput: minVal,
|
|
99
|
+
maxInput: maxVal,
|
|
100
|
+
priceInput: priceVal
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
watch: {
|
|
105
|
+
value: {
|
|
106
|
+
deep: true,
|
|
107
|
+
handler(val) {
|
|
108
|
+
const minVal = this.safeNumber(val && val[this.keyMin], 0)
|
|
109
|
+
this.minInput = minVal
|
|
110
|
+
this.maxInput = this.isLast ? null : this.safeNumber(val && val[this.keyMax], minVal + 1)
|
|
111
|
+
this.priceInput = this.safeNumber(val && val[this.keyPrice], 0)
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
isLast(val) {
|
|
115
|
+
if (val) {
|
|
116
|
+
this.maxInput = null
|
|
117
|
+
} else {
|
|
118
|
+
const minVal = this.safeNumber(this.minInput, 0)
|
|
119
|
+
const v = this.value
|
|
120
|
+
this.maxInput = this.safeNumber(v && v[this.keyMax], minVal + 1)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
methods: {
|
|
126
|
+
// 统一兜底:非数字输入一律转为 fallback(默认 0)
|
|
127
|
+
safeNumber(v, fallback = 0) {
|
|
128
|
+
if (v === null || v === undefined || v === '' || v === Infinity || v === -Infinity) return fallback
|
|
129
|
+
const n = Number(v)
|
|
130
|
+
return isNaN(n) ? fallback : n
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
emitChange(partial) {
|
|
134
|
+
const next = {
|
|
135
|
+
[this.keyMin]: this.minInput,
|
|
136
|
+
[this.keyMax]: this.isLast ? null : this.maxInput,
|
|
137
|
+
[this.keyPrice]: this.priceInput,
|
|
138
|
+
...partial
|
|
139
|
+
}
|
|
140
|
+
this.$emit('input', next)
|
|
141
|
+
this.$emit('change', next, this.index)
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
onMinBlur() {
|
|
145
|
+
const v = this.safeNumber(this.minInput, 0)
|
|
146
|
+
this.minInput = v
|
|
147
|
+
this.$emit('min-change', v, this.index)
|
|
148
|
+
this.emitChange({ [this.keyMin]: v })
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
onMaxBlur() {
|
|
152
|
+
if (this.isLast) return
|
|
153
|
+
const minVal = this.safeNumber(this.minInput, 0)
|
|
154
|
+
let v = this.safeNumber(this.maxInput, minVal + 1)
|
|
155
|
+
if (v <= minVal) v = minVal + 1
|
|
156
|
+
this.maxInput = v
|
|
157
|
+
this.$emit('max-change', v, this.index)
|
|
158
|
+
this.emitChange({ [this.keyMax]: v })
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
onPriceBlur() {
|
|
162
|
+
let v = this.safeNumber(this.priceInput, 0)
|
|
163
|
+
if (v < 0) v = 0
|
|
164
|
+
v = Number(v.toFixed(this.precision))
|
|
165
|
+
this.priceInput = v
|
|
166
|
+
this.emitChange({ [this.keyPrice]: v })
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
onDelete() {
|
|
170
|
+
this.$emit('delete', this.index)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
</script>
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span
|
|
3
|
+
class="xt-time"
|
|
4
|
+
:class="[
|
|
5
|
+
typeColor ? 'xt-time--' + typeColor : '',
|
|
6
|
+
'xt-time--' + size,
|
|
7
|
+
{ 'xt-time--bold': bold }
|
|
8
|
+
]"
|
|
9
|
+
:style="customStyle"
|
|
10
|
+
@click="handleClick"
|
|
11
|
+
>
|
|
12
|
+
<slot name="prefix">{{ prefix }}</slot>
|
|
13
|
+
|
|
14
|
+
<slot>
|
|
15
|
+
<template v-if="mode === 'text'">
|
|
16
|
+
<template v-if="displayText !== undefined">{{ displayText }}</template>
|
|
17
|
+
<template v-else-if="!hideEmpty">{{ emptyText }}</template>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<template v-else-if="mode === 'now'">
|
|
21
|
+
{{ nowText }}
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<template v-else-if="mode === 'countdown'">
|
|
25
|
+
<template v-if="isCountdownFinished">
|
|
26
|
+
<slot name="finished">{{ finishedText }}</slot>
|
|
27
|
+
</template>
|
|
28
|
+
<template v-else>
|
|
29
|
+
{{ countdownText }}
|
|
30
|
+
</template>
|
|
31
|
+
</template>
|
|
32
|
+
</slot>
|
|
33
|
+
|
|
34
|
+
<slot name="suffix">{{ suffix }}</slot>
|
|
35
|
+
</span>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<script>
|
|
39
|
+
const DEFAULT_FORMAT = 'YYYY-MM-DD HH:mm:ss'
|
|
40
|
+
|
|
41
|
+
function pad(n) {
|
|
42
|
+
const s = String(n)
|
|
43
|
+
return s.length < 2 ? '0' + s : s
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 根据字符串/数字/Date 解析为 Date 对象
|
|
48
|
+
* 兼容:时间戳(ms/s)、Date、"2024-01-01"、"2024/01/01 12:00:00"、ISO 字符串
|
|
49
|
+
*/
|
|
50
|
+
function parseDate(value) {
|
|
51
|
+
if (value === null || value === undefined || value === '') return null
|
|
52
|
+
if (value instanceof Date) return isNaN(value.getTime()) ? null : value
|
|
53
|
+
|
|
54
|
+
// 数字时间戳
|
|
55
|
+
if (typeof value === 'number') {
|
|
56
|
+
// 10 位秒级时间戳补 000
|
|
57
|
+
const t = value < 1e12 ? value * 1000 : value
|
|
58
|
+
const d = new Date(t)
|
|
59
|
+
return isNaN(d.getTime()) ? null : d
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (typeof value === 'string') {
|
|
63
|
+
// 纯数字字符串
|
|
64
|
+
if (/^\d+$/.test(value)) {
|
|
65
|
+
const n = Number(value)
|
|
66
|
+
const t = n < 1e12 ? n * 1000 : n
|
|
67
|
+
const d = new Date(t)
|
|
68
|
+
return isNaN(d.getTime()) ? null : d
|
|
69
|
+
}
|
|
70
|
+
// 将 "-" 统一为 "/",避免 Safari 下 "YYYY-MM-DD" 解析失败
|
|
71
|
+
const normalized = value.replace(/-/g, '/')
|
|
72
|
+
const d = new Date(normalized)
|
|
73
|
+
return isNaN(d.getTime()) ? null : d
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return null
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 简易 formatDateTime 实现(不依赖外部库)
|
|
81
|
+
* 支持占位符:YYYY MM DD HH mm ss SSS
|
|
82
|
+
*/
|
|
83
|
+
function formatDateTime(date, fmt) {
|
|
84
|
+
if (!date) return ''
|
|
85
|
+
const f = fmt || DEFAULT_FORMAT
|
|
86
|
+
const map = {
|
|
87
|
+
YYYY: date.getFullYear(),
|
|
88
|
+
MM: pad(date.getMonth() + 1),
|
|
89
|
+
DD: pad(date.getDate()),
|
|
90
|
+
HH: pad(date.getHours()),
|
|
91
|
+
mm: pad(date.getMinutes()),
|
|
92
|
+
ss: pad(date.getSeconds()),
|
|
93
|
+
SSS: String(date.getMilliseconds()).padStart(3, '0')
|
|
94
|
+
}
|
|
95
|
+
return f.replace(/YYYY|MM|DD|HH|mm|ss|SSS/g, (k) => map[k])
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default {
|
|
99
|
+
name: 'XtTime',
|
|
100
|
+
|
|
101
|
+
props: {
|
|
102
|
+
// 显示模式:now(当前时间实时刷新)/ countdown(倒计时)/ text(格式化日期文本)
|
|
103
|
+
type: {
|
|
104
|
+
type: String,
|
|
105
|
+
default: 'now',
|
|
106
|
+
validator: (val) => ['now', 'countdown', 'text'].includes(val)
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
// ===== 通用 =====
|
|
110
|
+
size: {
|
|
111
|
+
type: String,
|
|
112
|
+
default: 'base',
|
|
113
|
+
validator: (val) =>
|
|
114
|
+
['extra-large', 'large', 'medium', 'base', 'small', 'extra-small'].includes(val)
|
|
115
|
+
},
|
|
116
|
+
typeColor: {
|
|
117
|
+
type: String,
|
|
118
|
+
default: '',
|
|
119
|
+
validator: (val) => ['', 'primary', 'success', 'warning', 'danger'].includes(val)
|
|
120
|
+
},
|
|
121
|
+
bold: {
|
|
122
|
+
type: Boolean,
|
|
123
|
+
default: false
|
|
124
|
+
},
|
|
125
|
+
format: {
|
|
126
|
+
type: String,
|
|
127
|
+
default: DEFAULT_FORMAT
|
|
128
|
+
},
|
|
129
|
+
prefix: {
|
|
130
|
+
type: String,
|
|
131
|
+
default: ''
|
|
132
|
+
},
|
|
133
|
+
suffix: {
|
|
134
|
+
type: String,
|
|
135
|
+
default: ''
|
|
136
|
+
},
|
|
137
|
+
emptyText: {
|
|
138
|
+
type: String,
|
|
139
|
+
default: '-'
|
|
140
|
+
},
|
|
141
|
+
hideEmpty: {
|
|
142
|
+
type: Boolean,
|
|
143
|
+
default: false
|
|
144
|
+
},
|
|
145
|
+
interval: {
|
|
146
|
+
type: Number,
|
|
147
|
+
default: 1000,
|
|
148
|
+
validator: (val) => val >= 100
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
// ===== text 模式 =====
|
|
152
|
+
// 兼容 v-model 用法,也可直接传 value / :value
|
|
153
|
+
value: {
|
|
154
|
+
type: [String, Number, Date],
|
|
155
|
+
default: ''
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
// ===== countdown 模式 =====
|
|
159
|
+
targetTime: {
|
|
160
|
+
type: [String, Number, Date],
|
|
161
|
+
default: ''
|
|
162
|
+
},
|
|
163
|
+
// 倒计时显示格式:
|
|
164
|
+
// DHMS -> 3天 12时 08分 30秒
|
|
165
|
+
// HMS -> 12时 08分 30秒(天数自动折算到小时)
|
|
166
|
+
// MS -> 08分 30秒(全部折算到分钟)
|
|
167
|
+
// SEC -> 3200秒
|
|
168
|
+
countdownFormat: {
|
|
169
|
+
type: String,
|
|
170
|
+
default: 'DHMS',
|
|
171
|
+
validator: (val) => ['DHMS', 'HMS', 'MS', 'SEC'].includes(val)
|
|
172
|
+
},
|
|
173
|
+
finishedText: {
|
|
174
|
+
type: String,
|
|
175
|
+
default: '已结束'
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
data() {
|
|
180
|
+
return {
|
|
181
|
+
tick: 0
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
computed: {
|
|
186
|
+
mode() {
|
|
187
|
+
return this.type
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
parsedValue() {
|
|
191
|
+
return parseDate(this.value)
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
parsedTarget() {
|
|
195
|
+
return parseDate(this.targetTime)
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
displayText() {
|
|
199
|
+
if (!this.parsedValue) return undefined
|
|
200
|
+
return formatDateTime(this.parsedValue, this.format)
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
nowText() {
|
|
204
|
+
// 通过 tick 触发刷新
|
|
205
|
+
// eslint-disable-next-line no-unused-vars
|
|
206
|
+
const _ = this.tick
|
|
207
|
+
return formatDateTime(new Date(), this.format)
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
// 剩余毫秒数(countdown 模式)
|
|
211
|
+
remainingMs() {
|
|
212
|
+
if (this.mode !== 'countdown') return 0
|
|
213
|
+
// eslint-disable-next-line no-unused-vars
|
|
214
|
+
const _ = this.tick
|
|
215
|
+
if (!this.parsedTarget) return 0
|
|
216
|
+
const diff = this.parsedTarget.getTime() - Date.now()
|
|
217
|
+
return diff > 0 ? diff : 0
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
isCountdownFinished() {
|
|
221
|
+
return this.mode === 'countdown' && this.parsedTarget && this.remainingMs <= 0
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
countdownText() {
|
|
225
|
+
if (!this.parsedTarget) return this.emptyText
|
|
226
|
+
const total = Math.floor(this.remainingMs / 1000)
|
|
227
|
+
if (total <= 0) return this.finishedText
|
|
228
|
+
|
|
229
|
+
switch (this.countdownFormat) {
|
|
230
|
+
case 'SEC':
|
|
231
|
+
return `${total}秒`
|
|
232
|
+
case 'MS': {
|
|
233
|
+
const m = Math.floor(total / 60)
|
|
234
|
+
const s = total % 60
|
|
235
|
+
return `${pad(m)}分${pad(s)}秒`
|
|
236
|
+
}
|
|
237
|
+
case 'HMS': {
|
|
238
|
+
const h = Math.floor(total / 3600)
|
|
239
|
+
const m = Math.floor((total % 3600) / 60)
|
|
240
|
+
const s = total % 60
|
|
241
|
+
return `${pad(h)}时${pad(m)}分${pad(s)}秒`
|
|
242
|
+
}
|
|
243
|
+
case 'DHMS':
|
|
244
|
+
default: {
|
|
245
|
+
const d = Math.floor(total / 86400)
|
|
246
|
+
const h = Math.floor((total % 86400) / 3600)
|
|
247
|
+
const m = Math.floor((total % 3600) / 60)
|
|
248
|
+
const s = total % 60
|
|
249
|
+
return `${d}天${pad(h)}时${pad(m)}分${pad(s)}秒`
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
customStyle() {
|
|
255
|
+
return {}
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
watch: {
|
|
260
|
+
type() {
|
|
261
|
+
this.restartTimer()
|
|
262
|
+
},
|
|
263
|
+
interval() {
|
|
264
|
+
this.restartTimer()
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
mounted() {
|
|
269
|
+
this.restartTimer()
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
beforeDestroy() {
|
|
273
|
+
this.clearTimer()
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
activated() {
|
|
277
|
+
this.restartTimer()
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
deactivated() {
|
|
281
|
+
this.clearTimer()
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
methods: {
|
|
285
|
+
restartTimer() {
|
|
286
|
+
this.clearTimer()
|
|
287
|
+
if (this.mode === 'now' || this.mode === 'countdown') {
|
|
288
|
+
// 立即刷新一次,避免首次渲染时 tick=0 导致的差异
|
|
289
|
+
this.tick++
|
|
290
|
+
this._timer = setInterval(() => {
|
|
291
|
+
this.tick++
|
|
292
|
+
// 倒计时结束触发 finish 事件
|
|
293
|
+
if (this.mode === 'countdown' && this.parsedTarget && this.remainingMs <= 0) {
|
|
294
|
+
this.clearTimer()
|
|
295
|
+
this.$emit('finish')
|
|
296
|
+
}
|
|
297
|
+
}, this.interval)
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
clearTimer() {
|
|
302
|
+
if (this._timer) {
|
|
303
|
+
clearInterval(this._timer)
|
|
304
|
+
this._timer = null
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
handleClick(e) {
|
|
309
|
+
this.$emit('click', e)
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
</script>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.xt-time {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
color: var(--xt-text-color, #303133);
|
|
4
|
+
font-variant-numeric: tabular-nums;
|
|
5
|
+
transition: color 0.2s ease;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/* 字号(同步 XtText 的 CSS 变量方案,若未定义则使用 fallback) */
|
|
9
|
+
.xt-time--extra-large { font-size: var(--xt-font-size-extra-large, 20px); }
|
|
10
|
+
.xt-time--large { font-size: var(--xt-font-size-large, 18px); }
|
|
11
|
+
.xt-time--medium { font-size: var(--xt-font-size-medium, 16px); }
|
|
12
|
+
.xt-time--base { font-size: var(--xt-font-size-base, 14px); }
|
|
13
|
+
.xt-time--small { font-size: var(--xt-font-size-small, 13px); }
|
|
14
|
+
.xt-time--extra-small { font-size: var(--xt-font-size-extra-small, 12px); }
|
|
15
|
+
|
|
16
|
+
/* 加粗 */
|
|
17
|
+
.xt-time--bold { font-weight: 700; }
|
|
18
|
+
|
|
19
|
+
/* 颜色语义:与 Element UI/XT 主题色一致 */
|
|
20
|
+
.xt-time--primary { color: var(--xt-color-primary, #409eff); }
|
|
21
|
+
.xt-time--success { color: var(--xt-color-success, #67c23a); }
|
|
22
|
+
.xt-time--warning { color: var(--xt-color-warning, #e6a23c); }
|
|
23
|
+
.xt-time--danger { color: var(--xt-color-danger, #f56c6c); }
|
package/src/index.js
CHANGED
|
@@ -23,9 +23,12 @@ import XtCard from './components/xt-card'
|
|
|
23
23
|
import XtCardItem from './components/xt-card-item'
|
|
24
24
|
import XtConfigProvider from './components/xt-config-provider'
|
|
25
25
|
import XtText from './components/xt-text'
|
|
26
|
+
import XtTime from './components/xt-time'
|
|
27
|
+
import XtStepPrice from './components/xt-step-price'
|
|
28
|
+
import XtStepPriceItem from './components/xt-step-price-item'
|
|
26
29
|
import XtGridBox from './components/xt-grid-box'
|
|
27
30
|
import XtGridItem from './components/xt-grid-item'
|
|
28
|
-
import
|
|
31
|
+
import ExDatePicker from './components/ex-date-picker'
|
|
29
32
|
import ExButton from './components/ex-button'
|
|
30
33
|
import ExChart from './components/ex-chart' // ExChart 组件(基于 ECharts 封装)
|
|
31
34
|
import ExCard from './components/ex-card'
|
|
@@ -44,9 +47,12 @@ const components = [
|
|
|
44
47
|
XtCardItem,
|
|
45
48
|
XtConfigProvider,
|
|
46
49
|
XtText,
|
|
50
|
+
XtTime,
|
|
51
|
+
XtStepPrice,
|
|
52
|
+
XtStepPriceItem,
|
|
47
53
|
XtGridBox,
|
|
48
54
|
XtGridItem,
|
|
49
|
-
|
|
55
|
+
ExDatePicker,
|
|
50
56
|
ExButton,
|
|
51
57
|
ExChart,
|
|
52
58
|
ExCard,
|
|
@@ -131,9 +137,12 @@ export default {
|
|
|
131
137
|
XtCardItem,
|
|
132
138
|
XtConfigProvider,
|
|
133
139
|
XtText,
|
|
140
|
+
XtTime,
|
|
141
|
+
XtStepPrice,
|
|
142
|
+
XtStepPriceItem,
|
|
134
143
|
XtGridBox,
|
|
135
144
|
XtGridItem,
|
|
136
|
-
|
|
145
|
+
ExDatePicker,
|
|
137
146
|
ExButton,
|
|
138
147
|
ExCard,
|
|
139
148
|
ExIcon,
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
color: ["#2CDEB3", "#A17EE6", "#E57E40", "#409EFF"],
|
|
3
|
-
backgroundColor: "#ffffff",
|
|
4
|
-
textStyle: {
|
|
5
|
-
fontFamily: "Microsoft YaHei, sans-serif"
|
|
6
|
-
},
|
|
7
|
-
title: {
|
|
8
|
-
textStyle: {
|
|
9
|
-
color: "#333"
|
|
10
|
-
},
|
|
11
|
-
subtextStyle: {
|
|
12
|
-
color: "#666666"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
line: {
|
|
16
|
-
itemStyle: {
|
|
17
|
-
},
|
|
18
|
-
lineStyle: {
|
|
19
|
-
width: 2
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
bar: {
|
|
23
|
-
itemStyle: {
|
|
24
|
-
borderRadius: 4
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
pie: {
|
|
28
|
-
roseType: "radius",
|
|
29
|
-
label: {
|
|
30
|
-
color: "#333"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
radar: {
|
|
34
|
-
indicator: {
|
|
35
|
-
color: "#666666"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
map: {
|
|
39
|
-
label: {
|
|
40
|
-
color: "#333"
|
|
41
|
-
},
|
|
42
|
-
itemStyle: {
|
|
43
|
-
borderColor: "#fff"
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
gauge: {
|
|
47
|
-
axisLine: {
|
|
48
|
-
lineStyle: {
|
|
49
|
-
color: [[1, "#5470c6"]]
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
toolbox: {
|
|
54
|
-
iconStyle: {
|
|
55
|
-
borderColor: "#666666"
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
axisLine: {
|
|
59
|
-
lineStyle: {
|
|
60
|
-
color: "#DCDFE6"
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
axisTick: {
|
|
64
|
-
lineStyle: {
|
|
65
|
-
color: "#DCDFE6"
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
splitLine: {
|
|
69
|
-
lineStyle: {
|
|
70
|
-
color: "#ebeef5"
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
splitArea: {
|
|
74
|
-
areaStyle: {
|
|
75
|
-
color: ["#f7f8fa", "#ffffff"]
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
legend: {
|
|
79
|
-
textStyle: {
|
|
80
|
-
color: "#666"
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
tooltip: {
|
|
84
|
-
backgroundColor: "rgba(255, 255, 255, 0.95)",
|
|
85
|
-
borderColor: "#DCDFE6",
|
|
86
|
-
borderWidth: 1,
|
|
87
|
-
textStyle: {
|
|
88
|
-
color: "#333"
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|