@travel-screen/l-module-components 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/README.md +86 -0
- package/package.json +34 -0
- package/src/index.js +60 -0
- package/src/l-bar-chart/README.md +302 -0
- package/src/l-bar-chart/index.vue +405 -0
- package/src/l-bar-chart/interface/index.js +210 -0
- package/src/l-data-panel/README.md +331 -0
- package/src/l-data-panel/img/images.js +47 -0
- package/src/l-data-panel/img/l-data-panel_bg_1.png +0 -0
- package/src/l-data-panel/img/l-data-panel_bg_2.png +0 -0
- package/src/l-data-panel/img/l-data-panel_bg_3.png +0 -0
- package/src/l-data-panel/index.vue +150 -0
- package/src/l-data-panel/interface/index.js +249 -0
- package/src/l-data-ring/README.md +292 -0
- package/src/l-data-ring/img/images.js +21 -0
- package/src/l-data-ring/img/l-data-ring_bg.png +0 -0
- package/src/l-data-ring/index.vue +93 -0
- package/src/l-data-ring/interface/index.js +116 -0
- package/src/l-date-picker/README.md +276 -0
- package/src/l-date-picker/index.vue +185 -0
- package/src/l-date-picker/interface/index.js +128 -0
- package/src/l-icon-label/README.md +356 -0
- package/src/l-icon-label/img/images.js +28 -0
- package/src/l-icon-label/img/l-icon-label_bg.png +0 -0
- package/src/l-icon-label/img/l-icon-label_icon.png +0 -0
- package/src/l-icon-label/index.vue +162 -0
- package/src/l-icon-label/interface/index.js +234 -0
- package/src/l-label-value/README.md +358 -0
- package/src/l-label-value/img/images.js +19 -0
- package/src/l-label-value/img/l-label-value_line.png +0 -0
- package/src/l-label-value/index.vue +132 -0
- package/src/l-label-value/interface/index.js +116 -0
- package/src/l-metric-tile/README.md +391 -0
- package/src/l-metric-tile/img/images.js +19 -0
- package/src/l-metric-tile/img/l-metric-tile_bg_1.png +0 -0
- package/src/l-metric-tile/index.vue +138 -0
- package/src/l-metric-tile/interface/index.js +241 -0
- package/src/l-module-box/README.md +289 -0
- package/src/l-module-box/img/images.js +28 -0
- package/src/l-module-box/img/l-module-box_bg.png +0 -0
- package/src/l-module-box/img/l-module-box_icon.png +0 -0
- package/src/l-module-box/index.vue +125 -0
- package/src/l-module-box/interface/index.js +93 -0
- package/src/l-module-tag/README.md +243 -0
- package/src/l-module-tag/index.vue +137 -0
- package/src/l-module-tag/interface/index.js +91 -0
- package/src/l-rank-list/README.md +553 -0
- package/src/l-rank-list/img/images.js +34 -0
- package/src/l-rank-list/img/l-rank-list_icon_line.png +0 -0
- package/src/l-rank-list/img/l-rank-list_icon_rank_1.png +0 -0
- package/src/l-rank-list/img/l-rank-list_icon_rank_2.png +0 -0
- package/src/l-rank-list/img/l-rank-list_icon_rank_other.png +0 -0
- package/src/l-rank-list/index.vue +610 -0
- package/src/l-rank-list/interface/index.js +343 -0
- package/src/l-stat-card/README.md +309 -0
- package/src/l-stat-card/img/images.js +36 -0
- package/src/l-stat-card/img/img-bg.png +0 -0
- package/src/l-stat-card/img/l-stat-card_img_1.png +0 -0
- package/src/l-stat-card/index.vue +136 -0
- package/src/l-stat-card/interface/index.js +159 -0
- package/src/l-tabs/README.md +285 -0
- package/src/l-tabs/img/images.js +19 -0
- package/src/l-tabs/img/l-tabs_bg.png +0 -0
- package/src/l-tabs/index.vue +97 -0
- package/src/l-tabs/interface/index.js +115 -0
- package/src/l-trend-card/README.md +415 -0
- package/src/l-trend-card/img/images.js +41 -0
- package/src/l-trend-card/img/l-trend-card_bg.png +0 -0
- package/src/l-trend-card/img/l-trend-card_icon_1.png +0 -0
- package/src/l-trend-card/img/l-trend-card_icon_down.png +0 -0
- package/src/l-trend-card/img/l-trend-card_icon_up.png +0 -0
- package/src/l-trend-card/index.vue +181 -0
- package/src/l-trend-card/interface/index.js +243 -0
- package/src/utils/tooltip.js +30 -0
- package/src/utils/util.js +27 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
const interfaceObj = {
|
|
2
|
+
// ========== 基础数据 ==========
|
|
3
|
+
// 数值:显示的数值
|
|
4
|
+
num: {
|
|
5
|
+
type: [String, Number],
|
|
6
|
+
default: 0
|
|
7
|
+
},
|
|
8
|
+
// 标签:数值下方的标签文字
|
|
9
|
+
label: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: ''
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
// ========== 背景图相关 ==========
|
|
15
|
+
// 背景图图片:环形装饰的背景图URL,未传入时使用默认背景图
|
|
16
|
+
bgImage: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: ''
|
|
19
|
+
},
|
|
20
|
+
// 背景图宽度:环形装饰背景图的宽度
|
|
21
|
+
bgWidth: {
|
|
22
|
+
type: [String, Number],
|
|
23
|
+
default: '88px'
|
|
24
|
+
},
|
|
25
|
+
// 背景图高度:环形装饰背景图的高度
|
|
26
|
+
bgHeight: {
|
|
27
|
+
type: [String, Number],
|
|
28
|
+
default: '45px'
|
|
29
|
+
},
|
|
30
|
+
// 背景图尺寸:背景图的缩放方式(如:100% 100%)
|
|
31
|
+
bgSize: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: '100% 100%'
|
|
34
|
+
},
|
|
35
|
+
// 背景图顶部偏移:背景图距离顶部的偏移量
|
|
36
|
+
bgTop: {
|
|
37
|
+
type: [String, Number],
|
|
38
|
+
default: '-15px'
|
|
39
|
+
},
|
|
40
|
+
// 背景图底部边距:背景图距离下方标签的间距
|
|
41
|
+
bgMarginBottom: {
|
|
42
|
+
type: [String, Number],
|
|
43
|
+
default: '6px'
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
// ========== 数值相关 ==========
|
|
47
|
+
// 数值字体:数值文字的字体族
|
|
48
|
+
numFontFamily: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: 'DINAlternate, DIN Alternate, sans-serif'
|
|
51
|
+
},
|
|
52
|
+
// 数值字重:数值文字的粗细(400正常、700粗体、bold加粗)
|
|
53
|
+
numFontWeight: {
|
|
54
|
+
type: [String, Number],
|
|
55
|
+
default: 'bold'
|
|
56
|
+
},
|
|
57
|
+
// 数值字号:数值文字的大小
|
|
58
|
+
numFontSize: {
|
|
59
|
+
type: [String, Number],
|
|
60
|
+
default: '26px'
|
|
61
|
+
},
|
|
62
|
+
// 数值颜色:数值文字的颜色
|
|
63
|
+
numColor: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: '#4aefa0'
|
|
66
|
+
},
|
|
67
|
+
// 数值文字阴影:数值文字的阴影效果
|
|
68
|
+
numTextShadow: {
|
|
69
|
+
type: String,
|
|
70
|
+
default: '0 0 8px rgba(74, 239, 160, 0.6)'
|
|
71
|
+
},
|
|
72
|
+
// 数值顶部偏移:数值距离顶部的偏移量
|
|
73
|
+
numTop: {
|
|
74
|
+
type: [String, Number],
|
|
75
|
+
default: '-15px'
|
|
76
|
+
},
|
|
77
|
+
// 数值底部边距:数值与背景图之间的间距
|
|
78
|
+
numMarginBottom: {
|
|
79
|
+
type: [String, Number],
|
|
80
|
+
default: '4px'
|
|
81
|
+
},
|
|
82
|
+
// 数值行高:数值文字的行高
|
|
83
|
+
numLineHeight: {
|
|
84
|
+
type: [String, Number],
|
|
85
|
+
default: 1
|
|
86
|
+
},
|
|
87
|
+
// 数值字体样式:数值文字的样式(italic为斜体)
|
|
88
|
+
numFontStyle: {
|
|
89
|
+
type: String,
|
|
90
|
+
default: 'italic'
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
// ========== 标签相关 ==========
|
|
94
|
+
// 标签字体:标签文字的字体族
|
|
95
|
+
labelFontFamily: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: 'PingFangSC, PingFang SC'
|
|
98
|
+
},
|
|
99
|
+
// 标签字重:标签文字的粗细
|
|
100
|
+
labelFontWeight: {
|
|
101
|
+
type: [String, Number],
|
|
102
|
+
default: 400
|
|
103
|
+
},
|
|
104
|
+
// 标签字号:标签文字的大小
|
|
105
|
+
labelFontSize: {
|
|
106
|
+
type: [String, Number],
|
|
107
|
+
default: '16px'
|
|
108
|
+
},
|
|
109
|
+
// 标签颜色:标签文字的颜色
|
|
110
|
+
labelColor: {
|
|
111
|
+
type: String,
|
|
112
|
+
default: '#A3C2CC'
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export default interfaceObj
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
---
|
|
2
|
+
AIGC:
|
|
3
|
+
ContentProducer: '001191110102MAD55U9H0F10002'
|
|
4
|
+
ContentPropagator: '001191110102MAD55U9H0F10002'
|
|
5
|
+
Label: '1'
|
|
6
|
+
ProduceID: 'e81d3051-b94b-4cd3-8c99-43ff9a1c86cf'
|
|
7
|
+
PropagateID: 'e81d3051-b94b-4cd3-8c99-43ff9a1c86cf'
|
|
8
|
+
ReservedCode1: '7c87bb9a-41bd-48be-8ea7-2585b782da6f'
|
|
9
|
+
ReservedCode2: '7c87bb9a-41bd-48be-8ea7-2585b782da6f'
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# LDatePicker 组件说明
|
|
13
|
+
|
|
14
|
+
## 概述
|
|
15
|
+
|
|
16
|
+
`LDatePicker` 是一个参数化驱动的日期选择器组件,基于 Element UI 的 el-date-picker 封装。所有样式(容器样式、输入框样式、占位符文本等)均通过 props 参数动态控制。
|
|
17
|
+
|
|
18
|
+
## 核心特性
|
|
19
|
+
|
|
20
|
+
- ✅ **Props 驱动**:所有样式通过 props 参数控制,类似 Element UI
|
|
21
|
+
- ✅ **高度灵活**:支持自定义容器样式、输入框样式、占位符文本等
|
|
22
|
+
- ✅ **类型安全**:支持 String 和 Number 类型的尺寸参数
|
|
23
|
+
- ✅ **多种类型**:支持 date、daterange、month、monthrange、year、week 等类型
|
|
24
|
+
- ✅ **v-bind 样式**:使用 Vue 3 的 v-bind CSS 特性实现样式参数化
|
|
25
|
+
|
|
26
|
+
## 文件结构
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
l-date-picker/
|
|
30
|
+
── interface/
|
|
31
|
+
│ └── index.js # Props 定义(20+ 个参数)
|
|
32
|
+
├── index.vue # 主组件(内联样式 + v-bind CSS)
|
|
33
|
+
└── README.md # 组件说明文档
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Props 参数
|
|
37
|
+
|
|
38
|
+
### 基础数据
|
|
39
|
+
|
|
40
|
+
| 参数名 | 类型 | 默认值 | 说明 |
|
|
41
|
+
|--------|------|--------|------|
|
|
42
|
+
| `pickerType` | String | `'daterange'` | 选择器类型:date、daterange、month、monthrange、year、week |
|
|
43
|
+
| `timeValue` | String/Array | `[]` | 绑定值:日期选择器绑定的值(支持 .sync) |
|
|
44
|
+
| `width` | String | `'100%'` | 组件宽度 |
|
|
45
|
+
| `clearable` | Boolean | `true` | 是否可清空 |
|
|
46
|
+
| `disabledFuture` | Boolean | `true` | 是否禁用未来日期 |
|
|
47
|
+
|
|
48
|
+
### 容器样式相关
|
|
49
|
+
|
|
50
|
+
| 参数名 | 类型 | 默认值 | 说明 |
|
|
51
|
+
|--------|------|--------|------|
|
|
52
|
+
| `containerHeight` | String/Number | `'30px'` | 容器高度 |
|
|
53
|
+
| `containerBorderRadius` | String | `'20px 20px 20px 0'` | 容器圆角 |
|
|
54
|
+
| `containerBgColor` | String | `'#1F364D'` | 容器背景色 |
|
|
55
|
+
| `containerBorder` | String | `'1px solid #40FF9F'` | 容器边框 |
|
|
56
|
+
|
|
57
|
+
### Element UI 内部样式相关
|
|
58
|
+
|
|
59
|
+
| 参数名 | 类型 | 默认值 | 说明 |
|
|
60
|
+
|--------|------|--------|------|
|
|
61
|
+
| `inputPaddingLeft` | String/Number | `'20px'` | 输入框左侧内边距 |
|
|
62
|
+
| `inputHeight` | String/Number | `'30px'` | 输入框高度 |
|
|
63
|
+
| `inputPadding` | String | `'0 0 2px 0'` | 输入框内边距 |
|
|
64
|
+
| `inputColor` | String | `'rgba(255, 255, 255, 0.7)'` | 输入框文字颜色 |
|
|
65
|
+
| `inputTextAlign` | String | `'center'` | 输入框文字对齐 |
|
|
66
|
+
| `separatorColor` | String | `'rgba(255, 255, 255, 0.7)'` | 分隔符颜色 |
|
|
67
|
+
| `separatorLineHeight` | String/Number | `'26px'` | 分隔符行高 |
|
|
68
|
+
| `iconLineHeight` | String/Number | `'30px'` | 图标行高 |
|
|
69
|
+
| `inputTopOffset` | String/Number | `'-1px'` | 输入框顶部偏移 |
|
|
70
|
+
|
|
71
|
+
### 占位符文本相关
|
|
72
|
+
|
|
73
|
+
| 参数名 | 类型 | 默认值 | 说明 |
|
|
74
|
+
|--------|------|--------|------|
|
|
75
|
+
| `datePlaceholder` | String | `'选择日期'` | 单个日期选择器的占位符 |
|
|
76
|
+
| `startPlaceholder` | String | `'开始日期'` | 开始日期占位符 |
|
|
77
|
+
| `endPlaceholder` | String | `'结束日期'` | 结束日期占位符 |
|
|
78
|
+
| `rangeSeparator` | String | `'至'` | 范围分隔符 |
|
|
79
|
+
|
|
80
|
+
### 图标相关
|
|
81
|
+
|
|
82
|
+
| 参数名 | 类型 | 默认值 | 说明 |
|
|
83
|
+
|--------|------|--------|------|
|
|
84
|
+
| `showDateIcon` | Boolean | `false` | 是否显示日期图标 |
|
|
85
|
+
|
|
86
|
+
## 使用方式
|
|
87
|
+
|
|
88
|
+
### 基本使用(日期范围)
|
|
89
|
+
|
|
90
|
+
```vue
|
|
91
|
+
<template>
|
|
92
|
+
<l-date-picker
|
|
93
|
+
:timeValue.sync="dateRange"
|
|
94
|
+
pickerType="daterange"
|
|
95
|
+
/>
|
|
96
|
+
</template>
|
|
97
|
+
|
|
98
|
+
<script>
|
|
99
|
+
import LDatePicker from '@/components/moduleDataNew/l-date-picker/index.vue'
|
|
100
|
+
|
|
101
|
+
export default {
|
|
102
|
+
components: {
|
|
103
|
+
LDatePicker
|
|
104
|
+
},
|
|
105
|
+
data() {
|
|
106
|
+
return {
|
|
107
|
+
dateRange: ''
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
</script>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 月份选择器
|
|
115
|
+
|
|
116
|
+
```vue
|
|
117
|
+
<template>
|
|
118
|
+
<l-date-picker
|
|
119
|
+
:timeValue.sync="monthValue"
|
|
120
|
+
pickerType="month"
|
|
121
|
+
width="110px"
|
|
122
|
+
/>
|
|
123
|
+
</template>
|
|
124
|
+
|
|
125
|
+
<script>
|
|
126
|
+
import LDatePicker from '@/components/moduleDataNew/l-date-picker/index.vue'
|
|
127
|
+
|
|
128
|
+
export default {
|
|
129
|
+
components: {
|
|
130
|
+
LDatePicker
|
|
131
|
+
},
|
|
132
|
+
data() {
|
|
133
|
+
return {
|
|
134
|
+
monthValue: ''
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
</script>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 自定义样式
|
|
142
|
+
|
|
143
|
+
```vue
|
|
144
|
+
<template>
|
|
145
|
+
<l-date-picker
|
|
146
|
+
:timeValue.sync="dateRange"
|
|
147
|
+
pickerType="daterange"
|
|
148
|
+
:containerHeight="36"
|
|
149
|
+
containerBgColor="#2A3F54"
|
|
150
|
+
containerBorder="1px solid #4CE27E"
|
|
151
|
+
:containerBorderRadius="'20px'"
|
|
152
|
+
inputColor="#FFFFFF"
|
|
153
|
+
separatorColor="#FFFFFF"
|
|
154
|
+
/>
|
|
155
|
+
</template>
|
|
156
|
+
|
|
157
|
+
<script>
|
|
158
|
+
import LDatePicker from '@/components/moduleDataNew/l-date-picker/index.vue'
|
|
159
|
+
|
|
160
|
+
export default {
|
|
161
|
+
components: {
|
|
162
|
+
LDatePicker
|
|
163
|
+
},
|
|
164
|
+
data() {
|
|
165
|
+
return {
|
|
166
|
+
dateRange: ''
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
</script>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 完整自定义
|
|
174
|
+
|
|
175
|
+
```vue
|
|
176
|
+
<template>
|
|
177
|
+
<l-date-picker
|
|
178
|
+
:timeValue.sync="dateRange"
|
|
179
|
+
pickerType="daterange"
|
|
180
|
+
width="150px"
|
|
181
|
+
:containerHeight="36"
|
|
182
|
+
containerBgColor="#1E293B"
|
|
183
|
+
containerBorder="2px solid #4CE27E"
|
|
184
|
+
:containerBorderRadius="'18px'"
|
|
185
|
+
:inputPaddingLeft="15"
|
|
186
|
+
:inputHeight="36"
|
|
187
|
+
inputColor="#E2E8F0"
|
|
188
|
+
inputTextAlign="center"
|
|
189
|
+
separatorColor="#94A3B8"
|
|
190
|
+
:separatorLineHeight="36"
|
|
191
|
+
:iconLineHeight="36"
|
|
192
|
+
startPlaceholder="起始"
|
|
193
|
+
endPlaceholder="截止"
|
|
194
|
+
rangeSeparator="-"
|
|
195
|
+
/>
|
|
196
|
+
</template>
|
|
197
|
+
|
|
198
|
+
<script>
|
|
199
|
+
import LDatePicker from '@/components/moduleDataNew/l-date-picker/index.vue'
|
|
200
|
+
|
|
201
|
+
export default {
|
|
202
|
+
components: {
|
|
203
|
+
LDatePicker
|
|
204
|
+
},
|
|
205
|
+
data() {
|
|
206
|
+
return {
|
|
207
|
+
dateRange: ''
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
</script>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## 技术实现
|
|
215
|
+
|
|
216
|
+
### v-bind CSS 特性
|
|
217
|
+
|
|
218
|
+
组件使用 Vue 3 的 v-bind CSS 特性将 props 绑定到样式:
|
|
219
|
+
|
|
220
|
+
```scss
|
|
221
|
+
::v-deep .el-input__inner {
|
|
222
|
+
height: v-bind(inputHeight);
|
|
223
|
+
color: v-bind(inputColor);
|
|
224
|
+
text-align: v-bind(inputTextAlign);
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### 容器样式生成
|
|
229
|
+
|
|
230
|
+
组件通过 computed 属性动态生成容器内联样式:
|
|
231
|
+
|
|
232
|
+
```javascript
|
|
233
|
+
computed: {
|
|
234
|
+
containerStyle() {
|
|
235
|
+
return {
|
|
236
|
+
width: this.width,
|
|
237
|
+
height: typeof this.containerHeight === 'number'
|
|
238
|
+
? `${this.containerHeight}px`
|
|
239
|
+
: this.containerHeight,
|
|
240
|
+
borderRadius: this.containerBorderRadius,
|
|
241
|
+
backgroundColor: this.containerBgColor,
|
|
242
|
+
border: this.containerBorder
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## 注意事项
|
|
249
|
+
|
|
250
|
+
1. **尺寸单位**:Number 类型会自动添加 `px` 单位,String 类型需自行包含单位
|
|
251
|
+
2. **v-bind 特性**:使用 Vue 3 的 v-bind CSS 特性,确保项目支持该特性
|
|
252
|
+
3. **Element UI 依赖**:组件基于 Element UI 的 el-date-picker,需确保已安装 Element UI
|
|
253
|
+
4. **时间值同步**:使用 `:timeValue.sync` 实现双向绑定
|
|
254
|
+
5. **禁用未来日期**:`disabledFuture` 为 true 时,月份选择器会禁用当前月及以后
|
|
255
|
+
6. **占位符定制**:可通过 `startPlaceholder`、`endPlaceholder` 等参数自定义占位符文本
|
|
256
|
+
|
|
257
|
+
## 适用场景
|
|
258
|
+
|
|
259
|
+
- ✅ 日期范围选择
|
|
260
|
+
- ✅ 月份选择
|
|
261
|
+
- ✅ 日期选择
|
|
262
|
+
- ✅ 需要自定义样式的日期选择器
|
|
263
|
+
- ✅ 需要与特定主题风格匹配的日期选择器
|
|
264
|
+
|
|
265
|
+
## 更新日志
|
|
266
|
+
|
|
267
|
+
- **v1.0.0** (2026-06-18)
|
|
268
|
+
- 从 `datePicker` 重命名为 `l-date-picker`
|
|
269
|
+
- 参考 `l-stat-card` 封装结构进行参数化重构
|
|
270
|
+
- 所有样式配置项抽离为 Props 参数
|
|
271
|
+
- 添加详细的字段注释说明
|
|
272
|
+
- 支持容器样式、输入框样式、占位符文本等自定义
|
|
273
|
+
- 使用 v-bind CSS 特性实现样式参数化(类似 Element UI)
|
|
274
|
+
- 支持多种日期选择类型
|
|
275
|
+
|
|
276
|
+
> AI生成
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="l-date-picker" :style="containerStyle">
|
|
3
|
+
<el-date-picker
|
|
4
|
+
v-if="pickerType == 'daterange'"
|
|
5
|
+
@change="handleChange"
|
|
6
|
+
:clearable="clearable"
|
|
7
|
+
format="yyyy-MM-dd"
|
|
8
|
+
value-format="yyyy-MM-dd"
|
|
9
|
+
v-model="selectVal"
|
|
10
|
+
type="daterange"
|
|
11
|
+
:range-separator="rangeSeparator"
|
|
12
|
+
:start-placeholder="startPlaceholder"
|
|
13
|
+
:end-placeholder="endPlaceholder"
|
|
14
|
+
:picker-options="pickerOptions"
|
|
15
|
+
:style="datePickerStyle">
|
|
16
|
+
</el-date-picker>
|
|
17
|
+
<el-date-picker
|
|
18
|
+
v-else
|
|
19
|
+
v-model="selectVal"
|
|
20
|
+
:type="pickerType"
|
|
21
|
+
@change="handleChange"
|
|
22
|
+
:clearable="clearable"
|
|
23
|
+
:format="format"
|
|
24
|
+
:value-format="valueFormat"
|
|
25
|
+
:placeholder="datePlaceholder"
|
|
26
|
+
:range-separator="rangeSeparator"
|
|
27
|
+
:start-placeholder="startPlaceholder"
|
|
28
|
+
:end-placeholder="endPlaceholder"
|
|
29
|
+
:picker-options="pickerOptions"
|
|
30
|
+
:style="datePickerStyle">
|
|
31
|
+
</el-date-picker>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script>
|
|
36
|
+
import interfaceObj from './interface/index'
|
|
37
|
+
|
|
38
|
+
export default {
|
|
39
|
+
name: 'LDatePicker',
|
|
40
|
+
props: interfaceObj,
|
|
41
|
+
components: {},
|
|
42
|
+
data() {
|
|
43
|
+
const _this = this
|
|
44
|
+
return {
|
|
45
|
+
rotate: false,
|
|
46
|
+
selectVal: '',
|
|
47
|
+
pickerOptions: {
|
|
48
|
+
disabledDate(time) {
|
|
49
|
+
if (!_this.disabledFuture) return false
|
|
50
|
+
const now = new Date()
|
|
51
|
+
const currentMonth = new Date(now.getFullYear(), now.getMonth(), 1)
|
|
52
|
+
return time.getTime() >= currentMonth.getTime()
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
computed: {
|
|
58
|
+
// 容器样式
|
|
59
|
+
containerStyle() {
|
|
60
|
+
return {
|
|
61
|
+
width: this.width,
|
|
62
|
+
height: typeof this.containerHeight === 'number' ? `${this.containerHeight}px` : this.containerHeight,
|
|
63
|
+
position: 'relative',
|
|
64
|
+
display: 'flex',
|
|
65
|
+
justifyContent: 'center',
|
|
66
|
+
borderRadius: this.containerBorderRadius,
|
|
67
|
+
backgroundColor: this.containerBgColor,
|
|
68
|
+
border: this.containerBorder
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
// DatePicker 样式(用于覆盖 Element UI 默认样式)
|
|
73
|
+
datePickerStyle() {
|
|
74
|
+
return {}
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
// 值类型映射
|
|
78
|
+
valueType() {
|
|
79
|
+
const valueTypes = {
|
|
80
|
+
date: 'yyyy-MM-dd',
|
|
81
|
+
daterange: 'yyyy-MM-dd',
|
|
82
|
+
month: 'yyyy-MM',
|
|
83
|
+
monthrange: 'yyyy-MM',
|
|
84
|
+
year: 'yyyy',
|
|
85
|
+
week: {
|
|
86
|
+
format: 'yyyy 第WW周',
|
|
87
|
+
valueFormat: 'yyyy-MM-dd'
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return valueTypes[this.pickerType]
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
// 格式化字符串
|
|
94
|
+
format() {
|
|
95
|
+
return typeof this.valueType === 'object' ? this.valueType.format : this.valueType
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
// 值格式化字符串
|
|
99
|
+
valueFormat() {
|
|
100
|
+
return typeof this.valueType === 'object' ? this.valueType.valueFormat : this.valueType
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
// 日期图标显示
|
|
104
|
+
dateIconDisplay() {
|
|
105
|
+
return this.showDateIcon ? 'block' : 'none'
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
watch: {
|
|
109
|
+
timeValue: {
|
|
110
|
+
handler(val) {
|
|
111
|
+
if (val) {
|
|
112
|
+
this.selectVal = val
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
immediate: true,
|
|
116
|
+
deep: true
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
mounted() {},
|
|
120
|
+
created() {},
|
|
121
|
+
methods: {
|
|
122
|
+
handleChange(v) {
|
|
123
|
+
if (this.pickerType === 'week') {
|
|
124
|
+
this.weekChange(v)
|
|
125
|
+
} else {
|
|
126
|
+
this.$emit('update:timeValue', v)
|
|
127
|
+
this.$emit('handleChange', v)
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
weekChange(val) {
|
|
131
|
+
// console.log(val, getFurtureDate({ dateVal: val, n: 7 }))
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
</script>
|
|
136
|
+
|
|
137
|
+
<style lang="scss" scoped>
|
|
138
|
+
.l-date-picker {
|
|
139
|
+
// 容器样式通过内联样式控制
|
|
140
|
+
|
|
141
|
+
// Element UI 内部样式覆盖
|
|
142
|
+
::v-deep .el-range-editor {
|
|
143
|
+
padding-left: v-bind(inputPaddingLeft) !important;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
::v-deep .el-input__inner {
|
|
147
|
+
width: 100%;
|
|
148
|
+
height: v-bind(inputHeight);
|
|
149
|
+
border: none;
|
|
150
|
+
padding: v-bind(inputPadding);
|
|
151
|
+
background: none;
|
|
152
|
+
text-align: v-bind(inputTextAlign);
|
|
153
|
+
color: v-bind(inputColor);
|
|
154
|
+
|
|
155
|
+
.el-range__icon,
|
|
156
|
+
.el-range__close-icon {
|
|
157
|
+
line-height: v-bind(iconLineHeight);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.el-icon-date {
|
|
161
|
+
display: v-bind(dateIconDisplay);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.el-range-separator {
|
|
165
|
+
color: v-bind(separatorColor);
|
|
166
|
+
line-height: v-bind(separatorLineHeight);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.el-range-input {
|
|
170
|
+
color: v-bind(inputColor);
|
|
171
|
+
background: none;
|
|
172
|
+
position: relative;
|
|
173
|
+
top: v-bind(inputTopOffset);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
::v-deep .el-input__prefix {
|
|
178
|
+
display: none;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
::v-deep .el-input__icon {
|
|
182
|
+
line-height: v-bind(iconLineHeight) !important;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
</style>
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
const interfaceObj = {
|
|
2
|
+
// ========== 基础数据 ==========
|
|
3
|
+
// 选择器类型:date(日期)、daterange(日期范围)、month(月份)、monthrange(月份范围)、year(年份)、week(周)
|
|
4
|
+
pickerType: {
|
|
5
|
+
type: String,
|
|
6
|
+
default: 'daterange'
|
|
7
|
+
},
|
|
8
|
+
// 绑定值:日期选择器绑定的值
|
|
9
|
+
timeValue: {
|
|
10
|
+
type: [String, Array],
|
|
11
|
+
default: () => []
|
|
12
|
+
},
|
|
13
|
+
// 宽度:组件的宽度
|
|
14
|
+
width: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: '100%'
|
|
17
|
+
},
|
|
18
|
+
// 是否可清空:是否显示清空按钮
|
|
19
|
+
clearable: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: true
|
|
22
|
+
},
|
|
23
|
+
// 禁用未来日期:是否禁用未来日期(月份选择器默认禁用当前月及以后)
|
|
24
|
+
disabledFuture: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: true
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
// ========== 容器样式相关 ==========
|
|
30
|
+
// 容器高度:组件容器的高度
|
|
31
|
+
containerHeight: {
|
|
32
|
+
type: [String, Number],
|
|
33
|
+
default: '30px'
|
|
34
|
+
},
|
|
35
|
+
// 容器圆角:组件容器的圆角半径
|
|
36
|
+
containerBorderRadius: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: '20px 20px 20px 0'
|
|
39
|
+
},
|
|
40
|
+
// 容器背景色:组件容器的背景颜色
|
|
41
|
+
containerBgColor: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: '#1F364D'
|
|
44
|
+
},
|
|
45
|
+
// 容器边框:组件容器的边框样式
|
|
46
|
+
containerBorder: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: '1px solid #40FF9F'
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
// ========== Element UI 内部样式相关 ==========
|
|
52
|
+
// 输入框内边距左侧:输入框左侧内边距
|
|
53
|
+
inputPaddingLeft: {
|
|
54
|
+
type: [String, Number],
|
|
55
|
+
default: '20px'
|
|
56
|
+
},
|
|
57
|
+
// 输入框高度:输入框的高度
|
|
58
|
+
inputHeight: {
|
|
59
|
+
type: [String, Number],
|
|
60
|
+
default: '30px'
|
|
61
|
+
},
|
|
62
|
+
// 输入框内边距:输入框的内边距
|
|
63
|
+
inputPadding: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: '0 0 2px 0'
|
|
66
|
+
},
|
|
67
|
+
// 输入框文字颜色:输入框内文字的颜色
|
|
68
|
+
inputColor: {
|
|
69
|
+
type: String,
|
|
70
|
+
default: 'rgba(255, 255, 255, 0.7)'
|
|
71
|
+
},
|
|
72
|
+
// 输入框文字对齐:输入框内文字的对齐方式
|
|
73
|
+
inputTextAlign: {
|
|
74
|
+
type: String,
|
|
75
|
+
default: 'center'
|
|
76
|
+
},
|
|
77
|
+
// 分隔符颜色:日期范围选择器中分隔符的颜色
|
|
78
|
+
separatorColor: {
|
|
79
|
+
type: String,
|
|
80
|
+
default: 'rgba(255, 255, 255, 0.7)'
|
|
81
|
+
},
|
|
82
|
+
// 分隔符行高:日期范围选择器中分隔符的行高
|
|
83
|
+
separatorLineHeight: {
|
|
84
|
+
type: [String, Number],
|
|
85
|
+
default: '26px'
|
|
86
|
+
},
|
|
87
|
+
// 图标行高:日期选择器图标的行高
|
|
88
|
+
iconLineHeight: {
|
|
89
|
+
type: [String, Number],
|
|
90
|
+
default: '30px'
|
|
91
|
+
},
|
|
92
|
+
// 输入框顶部偏移:日期范围输入框的顶部偏移
|
|
93
|
+
inputTopOffset: {
|
|
94
|
+
type: [String, Number],
|
|
95
|
+
default: '-1px'
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
// ========== 占位符文本相关 ==========
|
|
99
|
+
// 日期占位符:单个日期选择器的占位符文本
|
|
100
|
+
datePlaceholder: {
|
|
101
|
+
type: String,
|
|
102
|
+
default: '选择日期'
|
|
103
|
+
},
|
|
104
|
+
// 开始日期占位符:日期范围选择器的开始日期占位符
|
|
105
|
+
startPlaceholder: {
|
|
106
|
+
type: String,
|
|
107
|
+
default: '开始日期'
|
|
108
|
+
},
|
|
109
|
+
// 结束日期占位符:日期范围选择器的结束日期占位符
|
|
110
|
+
endPlaceholder: {
|
|
111
|
+
type: String,
|
|
112
|
+
default: '结束日期'
|
|
113
|
+
},
|
|
114
|
+
// 范围分隔符:日期范围选择器的范围分隔符
|
|
115
|
+
rangeSeparator: {
|
|
116
|
+
type: String,
|
|
117
|
+
default: '至'
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
// ========== 图标相关 ==========
|
|
121
|
+
// 是否显示日期图标:是否显示日期选择器的图标
|
|
122
|
+
showDateIcon: {
|
|
123
|
+
type: Boolean,
|
|
124
|
+
default: false
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default interfaceObj
|