@fox-js/phone-skills 4.0.1-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 +30 -0
- package/foxui/SKILL.md +442 -0
- package/foxui/references/fox-action-sheet/doc.md +74 -0
- package/foxui/references/fox-actionsheet-item/doc.md +499 -0
- package/foxui/references/fox-animate/doc.md +66 -0
- package/foxui/references/fox-audio/doc.md +76 -0
- package/foxui/references/fox-avatar/doc.md +70 -0
- package/foxui/references/fox-back-top/doc.md +69 -0
- package/foxui/references/fox-badge/doc.md +72 -0
- package/foxui/references/fox-barrage/doc.md +116 -0
- package/foxui/references/fox-button/doc.md +203 -0
- package/foxui/references/fox-calendar/doc.md +346 -0
- package/foxui/references/fox-calendar-item/doc.md +331 -0
- package/foxui/references/fox-cascader/doc.md +78 -0
- package/foxui/references/fox-cascader-item/doc.md +710 -0
- package/foxui/references/fox-cell/doc.md +74 -0
- package/foxui/references/fox-checkbox-item/doc.md +387 -0
- package/foxui/references/fox-circle-progress/doc.md +65 -0
- package/foxui/references/fox-collapse/doc.md +71 -0
- package/foxui/references/fox-count-down/doc.md +78 -0
- package/foxui/references/fox-count-up/doc.md +178 -0
- package/foxui/references/fox-date-item/doc.md +437 -0
- package/foxui/references/fox-date-picker/doc.md +438 -0
- package/foxui/references/fox-dialog/doc.md +242 -0
- package/foxui/references/fox-divider/doc.md +149 -0
- package/foxui/references/fox-domain-provider/doc.md +93 -0
- package/foxui/references/fox-drag/doc.md +64 -0
- package/foxui/references/fox-dropdown/doc.md +138 -0
- package/foxui/references/fox-elevator/doc.md +66 -0
- package/foxui/references/fox-ellipsis/doc.md +69 -0
- package/foxui/references/fox-empty/doc.md +67 -0
- package/foxui/references/fox-fixed-nav/doc.md +72 -0
- package/foxui/references/fox-floating-button/doc.md +142 -0
- package/foxui/references/fox-grid/doc.md +69 -0
- package/foxui/references/fox-group/doc.md +295 -0
- package/foxui/references/fox-icon/doc.md +65 -0
- package/foxui/references/fox-image/doc.md +75 -0
- package/foxui/references/fox-image-preview/doc.md +79 -0
- package/foxui/references/fox-indicator/doc.md +70 -0
- package/foxui/references/fox-infinite-loading/doc.md +74 -0
- package/foxui/references/fox-input-item/doc.md +210 -0
- package/foxui/references/fox-input-number/doc.md +199 -0
- package/foxui/references/fox-input-number-item/doc.md +213 -0
- package/foxui/references/fox-item/doc.md +207 -0
- package/foxui/references/fox-layout/doc.md +273 -0
- package/foxui/references/fox-link-item/doc.md +158 -0
- package/foxui/references/fox-list/doc.md +71 -0
- package/foxui/references/fox-mapping/doc.md +251 -0
- package/foxui/references/fox-menu/doc.md +425 -0
- package/foxui/references/fox-message-box/doc.md +200 -0
- package/foxui/references/fox-money-item/doc.md +174 -0
- package/foxui/references/fox-more-button/doc.md +208 -0
- package/foxui/references/fox-navbar/doc.md +75 -0
- package/foxui/references/fox-notice-bar/doc.md +71 -0
- package/foxui/references/fox-notify/doc.md +72 -0
- package/foxui/references/fox-number-keyboard/doc.md +77 -0
- package/foxui/references/fox-over-lay/doc.md +70 -0
- package/foxui/references/fox-page/doc.md +76 -0
- package/foxui/references/fox-pagination/doc.md +73 -0
- package/foxui/references/fox-picker/doc.md +668 -0
- package/foxui/references/fox-picker-item/doc.md +389 -0
- package/foxui/references/fox-popover/doc.md +70 -0
- package/foxui/references/fox-popover-dialog/doc.md +113 -0
- package/foxui/references/fox-popup/doc.md +88 -0
- package/foxui/references/fox-price/doc.md +67 -0
- package/foxui/references/fox-progress/doc.md +74 -0
- package/foxui/references/fox-pull-refresh/doc.md +77 -0
- package/foxui/references/fox-radio-item/doc.md +384 -0
- package/foxui/references/fox-range/doc.md +65 -0
- package/foxui/references/fox-rate/doc.md +141 -0
- package/foxui/references/fox-rate-item/doc.md +137 -0
- package/foxui/references/fox-rolling-provider/doc.md +87 -0
- package/foxui/references/fox-search-bar/doc.md +91 -0
- package/foxui/references/fox-short-password/doc.md +78 -0
- package/foxui/references/fox-side-nav-bar/doc.md +68 -0
- package/foxui/references/fox-signature/doc.md +202 -0
- package/foxui/references/fox-skeleton/doc.md +73 -0
- package/foxui/references/fox-steps/doc.md +162 -0
- package/foxui/references/fox-steps-bar/doc.md +610 -0
- package/foxui/references/fox-sticky/doc.md +68 -0
- package/foxui/references/fox-swipe/doc.md +176 -0
- package/foxui/references/fox-swiper/doc.md +254 -0
- package/foxui/references/fox-switch/doc.md +162 -0
- package/foxui/references/fox-switch-item/doc.md +190 -0
- package/foxui/references/fox-tabbar/doc.md +63 -0
- package/foxui/references/fox-table/doc.md +640 -0
- package/foxui/references/fox-tabs/doc.md +67 -0
- package/foxui/references/fox-tabs-bar/doc.md +533 -0
- package/foxui/references/fox-tag/doc.md +213 -0
- package/foxui/references/fox-text/doc.md +84 -0
- package/foxui/references/fox-textarea-item/doc.md +106 -0
- package/foxui/references/fox-toast/doc.md +149 -0
- package/foxui/references/fox-tour/doc.md +89 -0
- package/foxui/references/fox-trend-arrow/doc.md +72 -0
- package/foxui/references/fox-uploader/doc.md +96 -0
- package/foxui/references/fox-video/doc.md +245 -0
- package/foxui/references/fox-water-mark/doc.md +81 -0
- package/package.json +21 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: 江成
|
|
3
|
+
* @Date: 2026-04-27 00:37:28
|
|
4
|
+
* @LastEditors: 江成
|
|
5
|
+
* @LastEditTime: 2026-05-12 22:33:21
|
|
6
|
+
-->
|
|
7
|
+
---
|
|
8
|
+
title: Calendar 组件使用规范
|
|
9
|
+
impact: HIGH
|
|
10
|
+
type: capability
|
|
11
|
+
description: 日历组件
|
|
12
|
+
tags: [foxui, fox-calendar, FoxCalendar]
|
|
13
|
+
version: "4.0.0"
|
|
14
|
+
author: jiangcheng
|
|
15
|
+
related: ["fox-js","fox-cell"]
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Calendar 组件使用规范
|
|
19
|
+
|
|
20
|
+
## 1. 核心职责 (Core Responsibility)
|
|
21
|
+
Calendar 是 foxui 中用于 **日历组件** 的标准组件。
|
|
22
|
+
- **基于**: NutUI `nut-calendar` 进行了二次封装 (若为纯自研组件则填 "自定义开发")
|
|
23
|
+
- **核心增强**: 基于 NutUI 组件二次封装、支持 v-model 双向绑定、适配 H5 与小程序多端、支持插槽扩展自定义内容、支持主题定制
|
|
24
|
+
- **适用场景**: 日历组件
|
|
25
|
+
|
|
26
|
+
> 💡 **关键原则**: 在所有 日历组件 中,**必须**优先使用此组件,禁止直接使用原生 NutUI 组件。
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 2. 关键 API 说明 (Key API)
|
|
31
|
+
|
|
32
|
+
### 2.1 Props 属性
|
|
33
|
+
|
|
34
|
+
| 属性名 | 类型 | 必填 | 默认值 | 说明 |
|
|
35
|
+
| :--- | :--- | :---: | :---: | :--- |
|
|
36
|
+
| `v-model` | 绑定值,日期选择 String 格式,区间选择 Array 格式 | String 、 Array | null |
|
|
37
|
+
| `v-model:visible` | 是否可见 | Boolean | false |
|
|
38
|
+
| `type` | 类型,日期选择'one',区间选择'range' | String | 'one' |
|
|
39
|
+
| `poppable` | 是否弹窗状态展示 | Boolean | true |
|
|
40
|
+
| `is-auto-back-fill` | 自动回填 | Boolean | false |
|
|
41
|
+
| `title` | 显示标题 | String | ‘日期选择’ |
|
|
42
|
+
| `default-value` | 默认值,日期选择 String 格式,区间选择 Array 格式 | String 、 Array | null |
|
|
43
|
+
| `start-date` | 开始日期, 如果不限制开始日期传 null | String | 今天 |
|
|
44
|
+
| `end-date` | 结束日期,如果不限制结束日期传 null | String | 距离今天 365 天 |
|
|
45
|
+
| `show-today` | 是否展示今天标记 | Boolean | true |
|
|
46
|
+
| `start-text` | 范围选择,开始信息文案 | String | ’开始‘ |
|
|
47
|
+
| `end-text` | 范围选择,结束信息文案 | String | ‘结束’ |
|
|
48
|
+
| `confirm-text` | 底部确认按钮文案 | String | ’确认‘ |
|
|
49
|
+
| `show-title` | 是否在展示日历标题 | Boolean | true |
|
|
50
|
+
| `show-sub-title` | 是否展示日期标题 | Boolean | true |
|
|
51
|
+
|
|
52
|
+
### 2.2 Events 事件
|
|
53
|
+
|
|
54
|
+
| 事件名 | 类型 | 说明 |
|
|
55
|
+
| :--- | :--- | :--- |
|
|
56
|
+
| `choose` | 选择之后或是点击确认按钮触发 | 日期数组(包含年月日和星期) |
|
|
57
|
+
| `close` | 关闭时触发 | - |
|
|
58
|
+
| `select` | 点击/选择后触发 | Day:object |
|
|
59
|
+
|
|
60
|
+
### 2.3 Methods 方法
|
|
61
|
+
|
|
62
|
+
| 方法名 | 参数 | 说明 |
|
|
63
|
+
| :--- | :--- | :--- |
|
|
64
|
+
| `scrollToDate` | 滚动到指定日期所在月,如:'2021-12-30' | string |
|
|
65
|
+
| `initPosition` | 初始化滚动位置 | 无 |
|
|
66
|
+
|
|
67
|
+
### 2.4 Slots 插槽
|
|
68
|
+
|
|
69
|
+
| 插槽名 | 说明 |
|
|
70
|
+
| :--- | :--- |
|
|
71
|
+
| `btn` | 自定义日历标题下部,可用以添加自定义操作 |
|
|
72
|
+
| `day` | 日期信息 |
|
|
73
|
+
| `topInfo` | 日期顶部信息 |
|
|
74
|
+
| `bottomInfo` | 日期底部信息 |
|
|
75
|
+
|
|
76
|
+
## 3. 例子 (Examples)
|
|
77
|
+
|
|
78
|
+
## 代码演示
|
|
79
|
+
|
|
80
|
+
### 基础用法
|
|
81
|
+
|
|
82
|
+
```html
|
|
83
|
+
<fox-cell
|
|
84
|
+
:showIcon="true"
|
|
85
|
+
title="选择单个日期"
|
|
86
|
+
:desc="date ? `${date} ${dateWeek}` : '请选择'"
|
|
87
|
+
@click="openSwitch('isVisible')"
|
|
88
|
+
>
|
|
89
|
+
</fox-cell>
|
|
90
|
+
<fox-calendar
|
|
91
|
+
v-model:visible="isVisible"
|
|
92
|
+
:default-value="date"
|
|
93
|
+
@close="closeSwitch('isVisible')"
|
|
94
|
+
@choose="setChooseValue"
|
|
95
|
+
:start-date="`2019-10-11`"
|
|
96
|
+
:end-date="`2022-11-11`"
|
|
97
|
+
>
|
|
98
|
+
</fox-calendar>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```javascript
|
|
102
|
+
setup() {
|
|
103
|
+
const state = reactive({
|
|
104
|
+
isVisible: false,
|
|
105
|
+
date: '',
|
|
106
|
+
dateWeek: ''
|
|
107
|
+
})
|
|
108
|
+
const openSwitch = param => {
|
|
109
|
+
state[`${param}`] = true;
|
|
110
|
+
}
|
|
111
|
+
const closeSwitch = param => {
|
|
112
|
+
state[`${param}`] = false;
|
|
113
|
+
}
|
|
114
|
+
const setChooseValue = (param: any) => {
|
|
115
|
+
state.date = param[3]
|
|
116
|
+
state.dateWeek = param[4]
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
...toRefs(state),
|
|
121
|
+
openSwitch,
|
|
122
|
+
closeSwitch,
|
|
123
|
+
setChooseValue
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 区间选择
|
|
129
|
+
|
|
130
|
+
```html
|
|
131
|
+
<fox-cell
|
|
132
|
+
:show-icon="true"
|
|
133
|
+
title="选择日期区间"
|
|
134
|
+
:desc="date1 ? `${date1[0]}至${date1[1]}` : '请选择'"
|
|
135
|
+
@click="openSwitch('isVisible1')"
|
|
136
|
+
>
|
|
137
|
+
</fox-cell>
|
|
138
|
+
<fox-calendar
|
|
139
|
+
v-model:visible="isVisible1"
|
|
140
|
+
:default-value="date1"
|
|
141
|
+
type="range"
|
|
142
|
+
:start-date="`2019-12-22`"
|
|
143
|
+
:end-date="`2021-01-08`"
|
|
144
|
+
@close="closeSwitch('isVisible1')"
|
|
145
|
+
@choose="setChooseValue1"
|
|
146
|
+
@select="select"
|
|
147
|
+
>
|
|
148
|
+
</fox-calendar>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
```javascript
|
|
152
|
+
setup() {
|
|
153
|
+
const state: TestCalendarState = reactive({
|
|
154
|
+
date1: ['2019-12-23', '2019-12-26'],
|
|
155
|
+
isVisible1: true
|
|
156
|
+
})
|
|
157
|
+
const openSwitch = param => {
|
|
158
|
+
state[`${param}`] = true;
|
|
159
|
+
}
|
|
160
|
+
const closeSwitch = param => {
|
|
161
|
+
state[`${param}`] = false;
|
|
162
|
+
}
|
|
163
|
+
const setChooseValue1 = (param: any) => {
|
|
164
|
+
state.date1 = [...[param[0][3], param[1][3]]]
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
...toRefs(state),
|
|
169
|
+
openSwitch,
|
|
170
|
+
closeSwitch,
|
|
171
|
+
setChooseValue1
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 快捷选择
|
|
177
|
+
|
|
178
|
+
```html
|
|
179
|
+
<fox-cell
|
|
180
|
+
:showIcon="true"
|
|
181
|
+
title="选择日期"
|
|
182
|
+
:desc="date3 ? date3 : '请选择'"
|
|
183
|
+
@click="openSwitch('isVisible3')"
|
|
184
|
+
>
|
|
185
|
+
</fox-cell>
|
|
186
|
+
<fox-calendar
|
|
187
|
+
v-model:visible="isVisible"
|
|
188
|
+
default-value="date3"
|
|
189
|
+
@close="closeSwitch('isVisible3')"
|
|
190
|
+
@choose="setChooseValue3"
|
|
191
|
+
:start-date="null"
|
|
192
|
+
:end-date="null"
|
|
193
|
+
:is-auto-back-fill="true"
|
|
194
|
+
>
|
|
195
|
+
</fox-calendar>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
```javascript
|
|
199
|
+
setup() {
|
|
200
|
+
const state = reactive({
|
|
201
|
+
date3: '',
|
|
202
|
+
isVisible3: false
|
|
203
|
+
})
|
|
204
|
+
const openSwitch = param => {
|
|
205
|
+
state[`${param}`] = true;
|
|
206
|
+
}
|
|
207
|
+
const closeSwitch = param => {
|
|
208
|
+
state[`${param}`] = false;
|
|
209
|
+
}
|
|
210
|
+
const setChooseValue3= (param: any) => {
|
|
211
|
+
state.date3 = param[3]
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
...toRefs(state),
|
|
215
|
+
openSwitch,
|
|
216
|
+
closeSwitch,
|
|
217
|
+
setChooseValue3
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### 自定义日历
|
|
223
|
+
|
|
224
|
+
```html
|
|
225
|
+
<div>
|
|
226
|
+
<fox-cell
|
|
227
|
+
:show-icon="true"
|
|
228
|
+
title="自定义按钮"
|
|
229
|
+
:desc="date5 && date5[0] ? `${date5[0]}至${date5[1]}` : '请选择'"
|
|
230
|
+
@click="openSwitch('isVisible5')"
|
|
231
|
+
>
|
|
232
|
+
</fox-cell>
|
|
233
|
+
<fox-calendar
|
|
234
|
+
v-model:visible="isVisible5"
|
|
235
|
+
:default-value="date5"
|
|
236
|
+
type="range"
|
|
237
|
+
:start-date="`2021-12-22`"
|
|
238
|
+
:end-date="`2022-12-31`"
|
|
239
|
+
@close="closeSwitch('isVisible5')"
|
|
240
|
+
@choose="setChooseValue5"
|
|
241
|
+
>
|
|
242
|
+
<template v-slot:btn>
|
|
243
|
+
<div class="wrapper">
|
|
244
|
+
<div class="d_div"><span class="d_btn" @click="clickBtn">最近七天</span></div>
|
|
245
|
+
<div class="d_div"><span class="d_btn" @click="clickBtn1">当月</span></div>
|
|
246
|
+
</div>
|
|
247
|
+
</template>
|
|
248
|
+
<template v-slot:day="date">
|
|
249
|
+
<span>{{ date.date.day }}</span>
|
|
250
|
+
</template>
|
|
251
|
+
</fox-calendar>
|
|
252
|
+
</div>
|
|
253
|
+
<div>
|
|
254
|
+
<fox-cell
|
|
255
|
+
:show-icon="true"
|
|
256
|
+
title="自定义时间文案"
|
|
257
|
+
:desc="date6 && date6[0] ? `${date6[0]}至${date6[1]}` : '请选择'"
|
|
258
|
+
@click="openSwitch('isVisible6')"
|
|
259
|
+
>
|
|
260
|
+
</fox-cell>
|
|
261
|
+
<fox-calendar
|
|
262
|
+
v-model:visible="isVisible6"
|
|
263
|
+
:default-value="date6"
|
|
264
|
+
type="range"
|
|
265
|
+
@close="closeSwitch('isVisible6')"
|
|
266
|
+
@choose="setChooseValue6"
|
|
267
|
+
:start-date="`2022-01-01`"
|
|
268
|
+
:end-date="`2022-12-31`"
|
|
269
|
+
confirm-text="submit"
|
|
270
|
+
start-text="入店"
|
|
271
|
+
end-text="离店"
|
|
272
|
+
title="日期选择"
|
|
273
|
+
>
|
|
274
|
+
<template v-slot:day="date">
|
|
275
|
+
<span>{{ date.date.day <= 9 ? '0' + date.date.day : date.date.day }}</span>
|
|
276
|
+
</template>
|
|
277
|
+
<template v-slot:bottomInfo="date">
|
|
278
|
+
<span class="info">{{
|
|
279
|
+
date.date ? (date.date.day <= 10 ? '上旬' : date.date.day <= 20 ? '中旬' : '下旬') : ''
|
|
280
|
+
}}</span>
|
|
281
|
+
</template>
|
|
282
|
+
</fox-calendar>
|
|
283
|
+
</div>
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
```javascript
|
|
287
|
+
setup() {
|
|
288
|
+
const state: TestCalendarState = reactive({
|
|
289
|
+
isVisible5: boolean
|
|
290
|
+
isVisible6: boolean
|
|
291
|
+
date5: string[]
|
|
292
|
+
date6: string[]
|
|
293
|
+
})
|
|
294
|
+
const openSwitch = param => {
|
|
295
|
+
state[`${param}`] = true;
|
|
296
|
+
}
|
|
297
|
+
const closeSwitch = param => {
|
|
298
|
+
state[`${param}`] = false;
|
|
299
|
+
}
|
|
300
|
+
const setChooseValue5 = (param: any) => {
|
|
301
|
+
state.date5 = [...[param[0][3], param[1][3]]]
|
|
302
|
+
}
|
|
303
|
+
const setChooseValue6 = (param: any) => {
|
|
304
|
+
state.date6 = [...[param[0][3], param[1][3]]]
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return {
|
|
309
|
+
...toRefs(state),
|
|
310
|
+
openSwitch,
|
|
311
|
+
closeSwitch,
|
|
312
|
+
setChooseValue5,
|
|
313
|
+
setChooseValue6
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
### 平铺展示
|
|
320
|
+
|
|
321
|
+
```html
|
|
322
|
+
<div class="test-calendar-wrapper">
|
|
323
|
+
<fox-calendar :poppable="false" :default-value="date2" :is-auto-back-fill="true" @choose="setChooseValue2">
|
|
324
|
+
</fox-calendar>
|
|
325
|
+
</div>
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
```javascript
|
|
329
|
+
setup() {
|
|
330
|
+
const state: TestCalendarState = reactive({
|
|
331
|
+
date2: ''
|
|
332
|
+
})
|
|
333
|
+
const setChooseValue2 = (param: any) => {
|
|
334
|
+
state.date2 = param[3]
|
|
335
|
+
}
|
|
336
|
+
return {
|
|
337
|
+
...toRefs(state),
|
|
338
|
+
setChooseValue2
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## 4. 相关组件 (Related Components)
|
|
344
|
+
- **fox-js**: 与 Calendar 配合使用的相关组件
|
|
345
|
+
- **fox-cell**: 与 Calendar 配合使用的相关组件
|
|
346
|
+
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: 江成
|
|
3
|
+
* @Date: 2026-04-27 00:37:28
|
|
4
|
+
* @LastEditors: 江成
|
|
5
|
+
* @LastEditTime: 2026-05-12 22:33:21
|
|
6
|
+
-->
|
|
7
|
+
---
|
|
8
|
+
title: CalendarItem 组件使用规范
|
|
9
|
+
impact: HIGH
|
|
10
|
+
type: capability
|
|
11
|
+
description: 日历选择框
|
|
12
|
+
tags: [foxui, fox-calendar-item, FoxCalendarItem]
|
|
13
|
+
version: "4.0.0"
|
|
14
|
+
author: jiangcheng
|
|
15
|
+
related: ["fox-js"]
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# CalendarItem 组件使用规范
|
|
19
|
+
|
|
20
|
+
## 1. 核心职责 (Core Responsibility)
|
|
21
|
+
CalendarItem 是 foxui 中用于 **日历选择框** 的标准组件。
|
|
22
|
+
- **基于**: NutUI `nut-calendar-item` 进行了二次封装 (若为纯自研组件则填 "自定义开发")
|
|
23
|
+
- **核心增强**: 基于 NutUI 组件二次封装、内置必填校验标识、支持 v-model 双向绑定、支持标签位置自定义、支持占位符提示、支持禁用/只读状态、内置多级提示信息、适配 H5 与小程序多端、支持插槽扩展自定义内容、支持主题定制
|
|
24
|
+
- **适用场景**: 日历选择框
|
|
25
|
+
|
|
26
|
+
> 💡 **关键原则**: 在所有 日历选择框 中,**必须**优先使用此组件,禁止直接使用原生 NutUI 组件。
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 2. 关键 API 说明 (Key API)
|
|
31
|
+
|
|
32
|
+
### 2.1 Props 属性
|
|
33
|
+
|
|
34
|
+
| 属性名 | 类型 | 必填 | 默认值 | 说明 |
|
|
35
|
+
| :--- | :--- | :---: | :---: | :--- |
|
|
36
|
+
| `v-model` | 绑定值 | string,string(范围),Date,Date(范围) | - |
|
|
37
|
+
| `value-format` | 可选,绑定值的格式。不指定则绑定值为 Date 对象 | String | - |
|
|
38
|
+
| `format` | 格式化显示的文本值 | String | - |
|
|
39
|
+
| `placeholder` | 为空时占位符 | String | - |
|
|
40
|
+
| `clearable` | 展示清除icon | Boolean | true |
|
|
41
|
+
| `text-align` | 文本位置,可选值left,center,right | String | left |
|
|
42
|
+
| `label` | 标签 | String | - |
|
|
43
|
+
| `label-width` | 标签宽度 | String | - |
|
|
44
|
+
| `label-position` | 标签位置可选值left,right,top | String | - |
|
|
45
|
+
| `is-required` | 左侧号是否展示 | Boolean | false |
|
|
46
|
+
| `disabled` | 是否禁用 | Boolean | false |
|
|
47
|
+
| `readonly` | 是否只读 | Boolean | false |
|
|
48
|
+
| `error-tip` | 错误提示 | String | - |
|
|
49
|
+
| `error-icon` | 错误提示图标 | String | - |
|
|
50
|
+
| `warn-tip` | 警告提示 | String | - |
|
|
51
|
+
| `wran-icon` | 警告提示图标 | String | - |
|
|
52
|
+
| `info-tip` | 提示 | String | - |
|
|
53
|
+
| `info-icon` | 提示图标 | String | - |
|
|
54
|
+
| `v-model:visible` | 是否可见 | Boolean | false |
|
|
55
|
+
| `type` | 类型,日期选择'one',区间选择'range' | String | 'one' |
|
|
56
|
+
| `poppable` | 是否弹窗状态展示 | Boolean | true |
|
|
57
|
+
| `is-auto-back-fill` | 自动回填 | Boolean | false |
|
|
58
|
+
| `title` | 显示标题 | String | ‘日期选择’ |
|
|
59
|
+
| `default-value` | 默认值,日期选择 String 格式,区间选择 Array 格式 | String 、 Array | null |
|
|
60
|
+
| `start-date` | 开始日期, 如果不限制开始日期传 null | String | 今天 |
|
|
61
|
+
| `end-date` | 结束日期,如果不限制结束日期传 null | String | 距离今天 365 天 |
|
|
62
|
+
| `show-today` | 是否展示今天标记 | Boolean | true |
|
|
63
|
+
| `start-text` | 范围选择,开始信息文案 | String | ’开始‘ |
|
|
64
|
+
| `end-text` | 范围选择,结束信息文案 | String | ‘结束’ |
|
|
65
|
+
| `confirm-text` | 底部确认按钮文案 | String | ’确认‘ |
|
|
66
|
+
| `show-title` | 是否在展示日历标题 | Boolean | true |
|
|
67
|
+
| `show-sub-title` | 是否展示日期标题 | Boolean | true |
|
|
68
|
+
|
|
69
|
+
### 2.2 Events 事件
|
|
70
|
+
|
|
71
|
+
| 事件名 | 类型 | 说明 |
|
|
72
|
+
| :--- | :--- | :--- |
|
|
73
|
+
无
|
|
74
|
+
|
|
75
|
+
### 2.3 Methods 方法
|
|
76
|
+
|
|
77
|
+
| 方法名 | 参数 | 说明 |
|
|
78
|
+
| :--- | :--- | :--- |
|
|
79
|
+
无
|
|
80
|
+
|
|
81
|
+
### 2.4 Slots 插槽
|
|
82
|
+
|
|
83
|
+
| 插槽名 | 说明 |
|
|
84
|
+
| :--- | :--- |
|
|
85
|
+
| `default` | label内容 |
|
|
86
|
+
| `prepend` | 左侧自定义内容 |
|
|
87
|
+
| `append` | 右侧自定义内容 |
|
|
88
|
+
| `btn` | 自定义日历标题下部,可用以添加自定义操作 |
|
|
89
|
+
| `day` | 日期信息 |
|
|
90
|
+
| `topInfo` | 日期顶部信息 |
|
|
91
|
+
| `bottomInfo` | 日期底部信息 |
|
|
92
|
+
|
|
93
|
+
## 3. 例子 (Examples)
|
|
94
|
+
|
|
95
|
+
## 代码演示
|
|
96
|
+
### 单选
|
|
97
|
+
```html
|
|
98
|
+
<fox-calendar-item v-model="date" :show-week="true" start-date="2021-10-01" end-date="2021-10-31" @focus="onFocus" @blur="onBlur">单选日历</fox-calendar-item>
|
|
99
|
+
```
|
|
100
|
+
```javascript
|
|
101
|
+
export default createDemo({
|
|
102
|
+
props: {},
|
|
103
|
+
setup() {
|
|
104
|
+
// 数据
|
|
105
|
+
const data = reactive({
|
|
106
|
+
date: '2021-10-05',
|
|
107
|
+
})
|
|
108
|
+
// 方法
|
|
109
|
+
const method = {
|
|
110
|
+
onFocus() {
|
|
111
|
+
console.info('on focus')
|
|
112
|
+
},
|
|
113
|
+
onBlur() {
|
|
114
|
+
console.info('on blur')
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
...toRefs(data),
|
|
119
|
+
...method
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
```
|
|
124
|
+
### 单选(value格式化)
|
|
125
|
+
```html
|
|
126
|
+
<fox-calendar-item v-model="date2" value-format="YYYY/MM/DD" :show-week="true" @focus="onFocus" @blur="onBlur">value格式化
|
|
127
|
+
</fox-calendar-item>
|
|
128
|
+
```
|
|
129
|
+
```javascript
|
|
130
|
+
export default createDemo({
|
|
131
|
+
props: {},
|
|
132
|
+
setup() {
|
|
133
|
+
// 数据
|
|
134
|
+
const data = reactive({
|
|
135
|
+
date2: '',
|
|
136
|
+
})
|
|
137
|
+
// 方法
|
|
138
|
+
const method = {
|
|
139
|
+
onFocus() {
|
|
140
|
+
console.info('on focus')
|
|
141
|
+
},
|
|
142
|
+
onBlur() {
|
|
143
|
+
console.info('on blur')
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
...toRefs(data),
|
|
148
|
+
...method
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
```
|
|
153
|
+
### 单选(text格式化)
|
|
154
|
+
```html
|
|
155
|
+
<fox-calendar-item v-model="date3" format="YYYY年MM月DD日" :show-week="false" @focus="onFocus" @blur="onBlur">text格式化</fox-calendar-item>
|
|
156
|
+
```
|
|
157
|
+
```javascript
|
|
158
|
+
export default createDemo({
|
|
159
|
+
props: {},
|
|
160
|
+
setup() {
|
|
161
|
+
// 数据
|
|
162
|
+
const data = reactive({
|
|
163
|
+
date3: new Date(),
|
|
164
|
+
})
|
|
165
|
+
// 方法
|
|
166
|
+
const method = {
|
|
167
|
+
onFocus() {
|
|
168
|
+
console.info('on focus')
|
|
169
|
+
},
|
|
170
|
+
onBlur() {
|
|
171
|
+
console.info('on blur')
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
...toRefs(data),
|
|
176
|
+
...method
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
```
|
|
181
|
+
### 区间选择
|
|
182
|
+
```html
|
|
183
|
+
<fox-calendar-item type="range" v-model="date4" value-format="YYYY年MM月DD日">范围选择</fox-calendar-item>
|
|
184
|
+
```
|
|
185
|
+
```javascript
|
|
186
|
+
export default createDemo({
|
|
187
|
+
props: {},
|
|
188
|
+
setup() {
|
|
189
|
+
// 数据
|
|
190
|
+
const data = reactive({
|
|
191
|
+
date4: ['2021-10-01', '2021-10-31'],
|
|
192
|
+
})
|
|
193
|
+
// 方法
|
|
194
|
+
const method = {
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
watch(
|
|
198
|
+
() => data.date4,
|
|
199
|
+
val => {
|
|
200
|
+
console.info(`date4 change`, val)
|
|
201
|
+
}
|
|
202
|
+
)
|
|
203
|
+
return {
|
|
204
|
+
...toRefs(data),
|
|
205
|
+
...method
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
```
|
|
210
|
+
### 自动回填
|
|
211
|
+
```html
|
|
212
|
+
<fox-calendar-item type="range" v-model="date5" format="YYYY/MM/DD" :is-auto-back-fill="true">自动回填</fox-calendar-item>
|
|
213
|
+
```
|
|
214
|
+
```javascript
|
|
215
|
+
export default createDemo({
|
|
216
|
+
props: {},
|
|
217
|
+
setup() {
|
|
218
|
+
// 数据
|
|
219
|
+
const data = reactive({
|
|
220
|
+
date5: ''
|
|
221
|
+
})
|
|
222
|
+
// 方法
|
|
223
|
+
const method = {
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
...toRefs(data),
|
|
228
|
+
...method
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
})
|
|
232
|
+
```
|
|
233
|
+
### 自定义-自定义按钮
|
|
234
|
+
```html
|
|
235
|
+
<fox-calendar-item
|
|
236
|
+
type="range"
|
|
237
|
+
v-model="date6"
|
|
238
|
+
:start-date="`2021-12-22`"
|
|
239
|
+
:end-date="`2022-12-31`"
|
|
240
|
+
value-format="YYYY年MM月DD日"
|
|
241
|
+
>
|
|
242
|
+
<template v-slot:default>自定义按钮</template>
|
|
243
|
+
<template v-slot:btn>
|
|
244
|
+
<div class="wrapper">
|
|
245
|
+
<div class="my-calender-div"><span class="my-calender-btn" @click="selectLast7Days">最近七天</span></div>
|
|
246
|
+
<div class="my-calender-div"><span class="my-calender-btn" @click="selectCurMonth">当月</span></div>
|
|
247
|
+
</div>
|
|
248
|
+
</template>
|
|
249
|
+
<template v-slot:day="date">
|
|
250
|
+
<span>{{ date.date.day }}</span>
|
|
251
|
+
</template>
|
|
252
|
+
</fox-calendar-item>
|
|
253
|
+
```
|
|
254
|
+
```javascript
|
|
255
|
+
export default createDemo({
|
|
256
|
+
props: {},
|
|
257
|
+
setup() {
|
|
258
|
+
// 数据
|
|
259
|
+
const data = reactive({
|
|
260
|
+
date6: ''
|
|
261
|
+
})
|
|
262
|
+
// 方法
|
|
263
|
+
const method = {
|
|
264
|
+
selectLast7Days: () => {
|
|
265
|
+
let date = [Utils.date2Str(new Date()), Utils.getDay(6)]
|
|
266
|
+
data.date6 = date
|
|
267
|
+
},
|
|
268
|
+
selectCurMonth: () => {
|
|
269
|
+
let date = new Date()
|
|
270
|
+
let year = date.getFullYear()
|
|
271
|
+
let month: any = date.getMonth() + 1
|
|
272
|
+
month = month < 10 ? '0' + month : month + ''
|
|
273
|
+
let yearMonth = `${year}-${month}`
|
|
274
|
+
let currMonthDays = Utils.getMonthDays(year + '', month + '')
|
|
275
|
+
data.date6 = [`${yearMonth}-01`, `${yearMonth}-${currMonthDays}`]
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
...toRefs(data),
|
|
281
|
+
...method
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
})
|
|
285
|
+
```
|
|
286
|
+
### 自定义-自定义文案
|
|
287
|
+
```html
|
|
288
|
+
<fox-calendar-item
|
|
289
|
+
v-model="date7"
|
|
290
|
+
type="range"
|
|
291
|
+
:start-date="`2022-01-01`"
|
|
292
|
+
:end-date="`2022-12-31`"
|
|
293
|
+
confirm-text="submit"
|
|
294
|
+
start-text="入店"
|
|
295
|
+
end-text="离店"
|
|
296
|
+
title="日期选择"
|
|
297
|
+
>
|
|
298
|
+
<template v-slot:default>自定义文案</template>
|
|
299
|
+
<template v-slot:day="date">
|
|
300
|
+
<span>{{ date.date.day <= 9 ? '0' + date.date.day : date.date.day }}</span>
|
|
301
|
+
</template>
|
|
302
|
+
<template v-slot:bottomInfo="date">
|
|
303
|
+
<span class="info">{{
|
|
304
|
+
date.date ? (date.date.day <= 10 ? '上旬' : date.date.day <= 20 ? '中旬' : '下旬') : ''
|
|
305
|
+
}}</span>
|
|
306
|
+
</template>
|
|
307
|
+
</fox-calendar-item>
|
|
308
|
+
```
|
|
309
|
+
```javascript
|
|
310
|
+
export default createDemo({
|
|
311
|
+
props: {},
|
|
312
|
+
setup() {
|
|
313
|
+
// 数据
|
|
314
|
+
const data = reactive({
|
|
315
|
+
date7: ''
|
|
316
|
+
})
|
|
317
|
+
// 方法
|
|
318
|
+
const method = {
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return {
|
|
322
|
+
...toRefs(data),
|
|
323
|
+
...method
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
})
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## 4. 相关组件 (Related Components)
|
|
330
|
+
- **fox-js**: 与 CalendarItem 配合使用的相关组件
|
|
331
|
+
|