sadais-piui 1.2.7-beta15 → 1.2.7-beta151
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/.prettierrc +8 -0
- package/components/pi-action-sheet/index.vue +260 -247
- package/components/pi-badge/index.vue +11 -1
- package/components/pi-bottom-bar/index.vue +1 -1
- package/components/pi-calendar/index.vue +207 -182
- package/components/pi-calendar-input/index.vue +61 -30
- package/components/pi-calendar-panel/components/calendar-days/index.vue +91 -52
- package/components/pi-calendar-panel/index.vue +28 -12
- package/components/pi-canvas/index.vue +8 -1
- package/components/pi-cascader/index.vue +601 -0
- package/components/pi-checkbox/index.vue +8 -4
- package/components/pi-checkbox-group/index.vue +12 -11
- package/components/pi-circle-progress/index.vue +53 -16
- package/components/pi-code-input/index.vue +11 -3
- package/components/pi-collapse/index.vue +16 -6
- package/components/pi-collapse-item/index.vue +35 -22
- package/components/pi-date-picker/index.vue +512 -391
- package/components/pi-date-picker-input/index.vue +61 -30
- package/components/pi-dropdown/components/dropdown-tab.vue +33 -23
- package/components/pi-dropdown/index.vue +34 -19
- package/components/pi-dropdown-item/index.vue +70 -58
- package/components/pi-form-item/index.vue +98 -20
- package/components/pi-grid/index.vue +1 -1
- package/components/pi-grid-item/index.vue +4 -4
- package/components/pi-img/index.vue +275 -267
- package/components/pi-img-cropper/index.vue +6 -3
- package/components/pi-input/index.vue +97 -36
- package/components/pi-list-item/index.vue +1 -1
- package/components/pi-marquee/index.vue +322 -310
- package/components/pi-marquee-pure-css/index.vue +267 -0
- package/components/pi-mask/index.vue +3 -1
- package/components/pi-modal/index.vue +311 -303
- package/components/pi-pagination/index.vue +13 -0
- package/components/pi-picker/index.vue +332 -317
- package/components/pi-popup/index.vue +4 -1
- package/components/pi-popup-select/index.vue +13 -4
- package/components/pi-radio/index.vue +12 -11
- package/components/pi-radio-group/index.vue +25 -5
- package/components/pi-regions-select/index.vue +6 -1
- package/components/pi-regions-select-input/index.vue +69 -31
- package/components/pi-search/index.vue +37 -2
- package/components/pi-section/index.vue +1 -1
- package/components/pi-select/index.vue +237 -22
- package/components/pi-select-input/index.vue +106 -41
- package/components/pi-stepper/index.vue +135 -121
- package/components/pi-steps/index.vue +115 -36
- package/components/pi-swiper/index.vue +22 -7
- package/components/pi-switch/index.vue +5 -1
- package/components/pi-table/index.vue +351 -0
- package/components/pi-tabs/index.vue +46 -10
- package/components/pi-upload-img/index.vue +895 -44
- package/components/pi-webview/index.vue +95 -82
- package/config/actionSheet.js +0 -1
- package/config/calendarInput.js +2 -1
- package/config/calendarPanel.js +2 -1
- package/config/cascader.js +22 -0
- package/config/circleProgress.js +12 -4
- package/config/codeInput.js +2 -1
- package/config/datePicker.js +29 -24
- package/config/datePickerInput.js +2 -1
- package/config/dropdown.js +3 -1
- package/config/input.js +5 -3
- package/config/marqueePureCss.js +18 -0
- package/config/regionsSelectInput.js +2 -1
- package/config/select.js +13 -1
- package/config/selectInput.js +2 -1
- package/config/steps.js +1 -1
- package/config/table.js +9 -0
- package/config/uploadImg.js +33 -11
- package/mixin/emitter.js +8 -1
- package/mixin/value-sync.js +5 -0
- package/package.json +5 -2
- package/scss/common.scss +11 -14
- package/scss/icon/icon.scss +2 -1
- package/scss/mixin.scss +5 -5
|
@@ -1,391 +1,512 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<pi-popup-select
|
|
3
|
-
:value="val"
|
|
4
|
-
:custom-style="getPopupSelect.customStyle"
|
|
5
|
-
:custom-class="getPopupSelect.customClass"
|
|
6
|
-
:height="getPopupSelect.height"
|
|
7
|
-
:show-title="getPopupSelect.showTitle"
|
|
8
|
-
:title="getPopupSelect.title"
|
|
9
|
-
:title-padding="getPopupSelect.titlePadding"
|
|
10
|
-
:toolbar-position="getPopupSelect.toolbarPosition"
|
|
11
|
-
:on-confirm-close="getPopupSelect.onConfirmClose"
|
|
12
|
-
:on-cancel-close="getPopupSelect.onCancelClose"
|
|
13
|
-
:confirm-btn="getConfirmBtn"
|
|
14
|
-
:cancel-btn="getCancelBtn"
|
|
15
|
-
:popup="getPopup"
|
|
16
|
-
@close="handlePopupClose"
|
|
17
|
-
@cancel="handleCancel"
|
|
18
|
-
@confirm="handleConfirm"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
</
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
},
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
type:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
)
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
datePicker.
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
this.
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
this.
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<pi-popup-select
|
|
3
|
+
:value="val"
|
|
4
|
+
:custom-style="getPopupSelect.customStyle"
|
|
5
|
+
:custom-class="getPopupSelect.customClass"
|
|
6
|
+
:height="getPopupSelect.height"
|
|
7
|
+
:show-title="getPopupSelect.showTitle"
|
|
8
|
+
:title="getPopupSelect.title"
|
|
9
|
+
:title-padding="getPopupSelect.titlePadding"
|
|
10
|
+
:toolbar-position="getPopupSelect.toolbarPosition"
|
|
11
|
+
:on-confirm-close="getPopupSelect.onConfirmClose"
|
|
12
|
+
:on-cancel-close="getPopupSelect.onCancelClose"
|
|
13
|
+
:confirm-btn="getConfirmBtn"
|
|
14
|
+
:cancel-btn="getCancelBtn"
|
|
15
|
+
:popup="getPopup"
|
|
16
|
+
@close="handlePopupClose"
|
|
17
|
+
@cancel="handleCancel"
|
|
18
|
+
@confirm="handleConfirm"
|
|
19
|
+
@closed="$emit('closed', $event)"
|
|
20
|
+
@show="$emit('show', $event)"
|
|
21
|
+
@showed="$emit('showed', $event)"
|
|
22
|
+
>
|
|
23
|
+
<slot name="header" />
|
|
24
|
+
<picker-view
|
|
25
|
+
v-if="val"
|
|
26
|
+
class="pi-text-center pi-h-100P"
|
|
27
|
+
:style="[customStyle]"
|
|
28
|
+
:class="[customClass]"
|
|
29
|
+
:indicator-style="indicatorStyle"
|
|
30
|
+
:value="pickerValue"
|
|
31
|
+
@pickstart="handlePickstart"
|
|
32
|
+
@pickend="handlePickend"
|
|
33
|
+
@change="handleDateChange"
|
|
34
|
+
>
|
|
35
|
+
<picker-view-column v-for="col in columns" :key="col.field">
|
|
36
|
+
<view v-for="item in col.items" :key="item" :style="indicatorStyle">
|
|
37
|
+
{{ item }}{{ col.unit }}
|
|
38
|
+
</view>
|
|
39
|
+
</picker-view-column>
|
|
40
|
+
</picker-view>
|
|
41
|
+
<slot name="footer" />
|
|
42
|
+
</pi-popup-select>
|
|
43
|
+
</template>
|
|
44
|
+
|
|
45
|
+
<script>
|
|
46
|
+
import ValueSync from '../../mixin/value-sync'
|
|
47
|
+
import { getConfig } from '../../config'
|
|
48
|
+
|
|
49
|
+
const TAG = 'PiDatePicker'
|
|
50
|
+
const { datePicker } = getConfig()
|
|
51
|
+
const FIELDS = ['year', 'month', 'day', 'halfday', 'hour', 'minute', 'second']
|
|
52
|
+
|
|
53
|
+
export default {
|
|
54
|
+
name: 'PiDatePicker',
|
|
55
|
+
// 混入v-model
|
|
56
|
+
mixins: [ValueSync],
|
|
57
|
+
props: {
|
|
58
|
+
// 是否显示弹窗
|
|
59
|
+
value: {
|
|
60
|
+
required: false
|
|
61
|
+
},
|
|
62
|
+
// 自定义样式
|
|
63
|
+
customStyle: {
|
|
64
|
+
type: Object,
|
|
65
|
+
default() {
|
|
66
|
+
// {}
|
|
67
|
+
return datePicker.customStyle
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
// 自定义样式类
|
|
71
|
+
customClass: {
|
|
72
|
+
type: String,
|
|
73
|
+
default() {
|
|
74
|
+
// ''
|
|
75
|
+
return datePicker.customClass
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
// 开始年份
|
|
79
|
+
startYear: {
|
|
80
|
+
type: [String, Number],
|
|
81
|
+
default() {
|
|
82
|
+
// 当前年份 - 30
|
|
83
|
+
return datePicker.startYear
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
// 结束年份
|
|
87
|
+
endYear: {
|
|
88
|
+
type: [String, Number],
|
|
89
|
+
default() {
|
|
90
|
+
// 当前年份
|
|
91
|
+
return datePicker.endYear
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
// 选择器的粒度
|
|
95
|
+
field: {
|
|
96
|
+
// `'year'` `'month'` `'day'` `'hour'` `'minute'` `'second'`
|
|
97
|
+
type: String,
|
|
98
|
+
validator: function(value) {
|
|
99
|
+
// 这个值必须匹配下列字符串中的一个
|
|
100
|
+
return FIELDS.includes(value)
|
|
101
|
+
},
|
|
102
|
+
// 'day'
|
|
103
|
+
default() {
|
|
104
|
+
return datePicker.field
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
// 日期类型,date、datetime、time
|
|
108
|
+
dateType: {
|
|
109
|
+
// `'date'` `'datetime'` `'time'`
|
|
110
|
+
type: String,
|
|
111
|
+
validator: function(value) {
|
|
112
|
+
return ['date', 'datetime', 'time'].includes(value)
|
|
113
|
+
},
|
|
114
|
+
// 'datetime'
|
|
115
|
+
default() {
|
|
116
|
+
return datePicker.dateType
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
// 年份选项
|
|
120
|
+
yearOptions: {
|
|
121
|
+
type: Array,
|
|
122
|
+
default() {
|
|
123
|
+
// []
|
|
124
|
+
return datePicker.yearOptions
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
// 月份选项
|
|
128
|
+
monthOptions: {
|
|
129
|
+
type: Array,
|
|
130
|
+
default() {
|
|
131
|
+
// []
|
|
132
|
+
return datePicker.monthOptions
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
// 日期选项
|
|
136
|
+
dayOptions: {
|
|
137
|
+
type: Array,
|
|
138
|
+
default() {
|
|
139
|
+
// []
|
|
140
|
+
return datePicker.dayOptions
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
// 小时选项
|
|
144
|
+
hourOptions: {
|
|
145
|
+
type: Array,
|
|
146
|
+
default() {
|
|
147
|
+
// []
|
|
148
|
+
return datePicker.hourOptions
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
// 分钟选项
|
|
152
|
+
minuteOptions: {
|
|
153
|
+
type: Array,
|
|
154
|
+
default() {
|
|
155
|
+
// []
|
|
156
|
+
return datePicker.minuteOptions
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
// 日期默认值
|
|
160
|
+
defaultValue: {
|
|
161
|
+
type: [Number, String, Date],
|
|
162
|
+
// ''
|
|
163
|
+
default: datePicker.defaultValue
|
|
164
|
+
},
|
|
165
|
+
// 单位数组,默认值:['年', '月', '日', '时', '分', '秒']
|
|
166
|
+
units: {
|
|
167
|
+
type: Array,
|
|
168
|
+
default() {
|
|
169
|
+
return datePicker.units
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
// 返回的日期格式
|
|
173
|
+
format: {
|
|
174
|
+
type: String,
|
|
175
|
+
// 'YYYY-MM-DD'
|
|
176
|
+
default: datePicker.format
|
|
177
|
+
},
|
|
178
|
+
// 行高
|
|
179
|
+
itemHeight: {
|
|
180
|
+
type: [String, Number],
|
|
181
|
+
// 110
|
|
182
|
+
default: datePicker.itemHeight
|
|
183
|
+
},
|
|
184
|
+
// 行样式
|
|
185
|
+
itemStyle: {
|
|
186
|
+
type: Object,
|
|
187
|
+
default() {
|
|
188
|
+
// {}
|
|
189
|
+
return datePicker.itemStyle
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
// 是否显示item下边框
|
|
193
|
+
showItemBottomBorder: {
|
|
194
|
+
type: Boolean,
|
|
195
|
+
// true
|
|
196
|
+
default: datePicker.showItemBottomBorder
|
|
197
|
+
},
|
|
198
|
+
// 弹窗选择参数设置
|
|
199
|
+
popupSelect: {
|
|
200
|
+
type: Object,
|
|
201
|
+
default() {
|
|
202
|
+
// 参照popup
|
|
203
|
+
return datePicker.popupSelect
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
// 确认按钮配置
|
|
207
|
+
confirmBtn: {
|
|
208
|
+
type: Object,
|
|
209
|
+
default() {
|
|
210
|
+
return datePicker.confirmBtn
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
// 取消按钮配置
|
|
214
|
+
cancelBtn: {
|
|
215
|
+
type: Object,
|
|
216
|
+
default() {
|
|
217
|
+
return datePicker.cancelBtn
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
// 弹窗参数设置
|
|
221
|
+
popup: {
|
|
222
|
+
type: Object,
|
|
223
|
+
default() {
|
|
224
|
+
// 参照popup
|
|
225
|
+
return datePicker.popup
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
data() {
|
|
230
|
+
let date = this.$pi.date.parseDate(this.defaultValue)
|
|
231
|
+
if (this.field === 'halfday') {
|
|
232
|
+
const time = date.time
|
|
233
|
+
if (date.hour < 12) {
|
|
234
|
+
time.setHours(0)
|
|
235
|
+
} else {
|
|
236
|
+
time.setHours(12)
|
|
237
|
+
}
|
|
238
|
+
date = this.$pi.date.parseDate(time)
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
date,
|
|
242
|
+
scrolling: false // picker是否在滚动中,小程序在scrolling中点确定,选择的项目不正确
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
computed: {
|
|
246
|
+
getPopupSelect() {
|
|
247
|
+
return this.$pi.lang.mergeDeep(datePicker.popupSelect, this.popupSelect)
|
|
248
|
+
},
|
|
249
|
+
getConfirmBtn() {
|
|
250
|
+
const datePickerConfirmBtn = this.$pi.lang.mergeDeep(
|
|
251
|
+
datePicker.confirmBtn,
|
|
252
|
+
this.popupSelect.confirmBtn
|
|
253
|
+
)
|
|
254
|
+
const mergeConfirmBtn = this.$pi.lang.mergeDeep(
|
|
255
|
+
datePickerConfirmBtn,
|
|
256
|
+
this.confirmBtn
|
|
257
|
+
)
|
|
258
|
+
if (!mergeConfirmBtn.disabled) {
|
|
259
|
+
mergeConfirmBtn.disabled = this.scrolling
|
|
260
|
+
}
|
|
261
|
+
return mergeConfirmBtn
|
|
262
|
+
},
|
|
263
|
+
getCancelBtn() {
|
|
264
|
+
const datePickerCancelBtn = this.$pi.lang.mergeDeep(
|
|
265
|
+
datePicker.cancelBtn,
|
|
266
|
+
this.popupSelect.cancelBtn
|
|
267
|
+
)
|
|
268
|
+
return this.$pi.lang.mergeDeep(datePickerCancelBtn, this.cancelBtn)
|
|
269
|
+
},
|
|
270
|
+
getPopup() {
|
|
271
|
+
const datePickerPopup = this.$pi.lang.mergeDeep(
|
|
272
|
+
datePicker.popup,
|
|
273
|
+
this.popupSelect.popup
|
|
274
|
+
)
|
|
275
|
+
return this.$pi.lang.mergeDeep(datePickerPopup, this.popup)
|
|
276
|
+
},
|
|
277
|
+
options() {
|
|
278
|
+
const watchs = ['val', 'startYear', 'endYear', 'field', 'defaultValue']
|
|
279
|
+
const options = watchs
|
|
280
|
+
.filter(d => this[d])
|
|
281
|
+
.map(d => this[d].toString())
|
|
282
|
+
.join('-')
|
|
283
|
+
return options
|
|
284
|
+
},
|
|
285
|
+
getHeight() {
|
|
286
|
+
return this.$pi.common.addUnit(this.height)
|
|
287
|
+
},
|
|
288
|
+
getTitlePadding() {
|
|
289
|
+
return this.$pi.common.addUnit(this.titlePadding)
|
|
290
|
+
},
|
|
291
|
+
indicatorStyle() {
|
|
292
|
+
const itemHeight = uni.upx2px(this.itemHeight)
|
|
293
|
+
return `height: ${itemHeight}px;line-height: ${itemHeight}px;`
|
|
294
|
+
},
|
|
295
|
+
getUnits() {
|
|
296
|
+
return this.$pi.mergeDeep(datePicker.units, this.units, {
|
|
297
|
+
arrayMerge: (target, source, options) => {
|
|
298
|
+
return target.map((t, index) => source[index] || t)
|
|
299
|
+
}
|
|
300
|
+
})
|
|
301
|
+
},
|
|
302
|
+
getYearOptions() {
|
|
303
|
+
if (this.yearOptions && this.yearOptions.length > 0) {
|
|
304
|
+
return this.yearOptions
|
|
305
|
+
}
|
|
306
|
+
return this.$pi.common.generateArray(this.startYear, this.endYear)
|
|
307
|
+
},
|
|
308
|
+
getMonthOptions() {
|
|
309
|
+
if (this.monthOptions && this.monthOptions.length > 0) {
|
|
310
|
+
return this.monthOptions
|
|
311
|
+
}
|
|
312
|
+
return this.$pi.common.generateArray(1, 12)
|
|
313
|
+
},
|
|
314
|
+
getDayOptions() {
|
|
315
|
+
if (this.dayOptions && this.dayOptions.length > 0) {
|
|
316
|
+
return this.dayOptions
|
|
317
|
+
}
|
|
318
|
+
const monthDays = new Date(this.date.year, this.date.month, 0).getDate()
|
|
319
|
+
return this.$pi.common.generateArray(1, monthDays)
|
|
320
|
+
},
|
|
321
|
+
getHourOptions() {
|
|
322
|
+
if (this.hourOptions && this.hourOptions.length > 0) {
|
|
323
|
+
return this.hourOptions
|
|
324
|
+
}
|
|
325
|
+
return this.$pi.common.generateArray(0, 23)
|
|
326
|
+
},
|
|
327
|
+
getMinuteOptions() {
|
|
328
|
+
if (this.minuteOptions && this.minuteOptions.length > 0) {
|
|
329
|
+
return this.minuteOptions
|
|
330
|
+
}
|
|
331
|
+
return this.$pi.common.generateArray(0, 59)
|
|
332
|
+
},
|
|
333
|
+
columns() {
|
|
334
|
+
let columns = [
|
|
335
|
+
{
|
|
336
|
+
field: 'year',
|
|
337
|
+
unit: this.getUnits[0],
|
|
338
|
+
key: 'year',
|
|
339
|
+
setMethod: 'setYear',
|
|
340
|
+
items: this.getYearOptions
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
field: 'month',
|
|
344
|
+
unit: this.getUnits[1],
|
|
345
|
+
key: 'month',
|
|
346
|
+
setMethod: 'setMonth',
|
|
347
|
+
items: this.getMonthOptions
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
field: 'day',
|
|
351
|
+
unit: this.getUnits[2],
|
|
352
|
+
key: 'date',
|
|
353
|
+
setMethod: 'setDate',
|
|
354
|
+
items: this.getDayOptions
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
field: 'halfday',
|
|
358
|
+
unit: '',
|
|
359
|
+
key: 'hour',
|
|
360
|
+
setMethod: 'setHours',
|
|
361
|
+
items: ['上午', '下午']
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
field: 'hour',
|
|
365
|
+
unit: this.getUnits[3],
|
|
366
|
+
key: 'hour',
|
|
367
|
+
setMethod: 'setHours',
|
|
368
|
+
type: 'time',
|
|
369
|
+
items: this.getHourOptions
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
field: 'minute',
|
|
373
|
+
unit: this.getUnits[4],
|
|
374
|
+
key: 'minute',
|
|
375
|
+
setMethod: 'setMinutes',
|
|
376
|
+
type: 'time',
|
|
377
|
+
items: this.getMinuteOptions
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
field: 'second',
|
|
381
|
+
unit: this.getUnits[5],
|
|
382
|
+
key: 'second',
|
|
383
|
+
setMethod: 'setSeconds',
|
|
384
|
+
type: 'time',
|
|
385
|
+
items: this.$pi.common.generateArray(0, 59)
|
|
386
|
+
}
|
|
387
|
+
]
|
|
388
|
+
|
|
389
|
+
columns = columns.filter((col, index) => {
|
|
390
|
+
return FIELDS.slice(index).includes(this.field)
|
|
391
|
+
})
|
|
392
|
+
if (this.field !== 'halfday') {
|
|
393
|
+
columns = columns.filter(col => col.field !== 'halfday')
|
|
394
|
+
}
|
|
395
|
+
if (this.dateType === 'time') {
|
|
396
|
+
columns = columns.filter(col => col.type === 'time')
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return columns
|
|
400
|
+
},
|
|
401
|
+
pickerValue() {
|
|
402
|
+
const pickerValue = []
|
|
403
|
+
this.columns.forEach(col => {
|
|
404
|
+
// 当前日期字段
|
|
405
|
+
const value = this.date[col.key]
|
|
406
|
+
if (value !== null) {
|
|
407
|
+
// 查找当前picker中索引对应的真实值
|
|
408
|
+
if (col.field === 'halfday') {
|
|
409
|
+
const val = value < 12 ? 0 : 1
|
|
410
|
+
pickerValue.push(val)
|
|
411
|
+
} else {
|
|
412
|
+
const intValue = parseInt(value, 10)
|
|
413
|
+
const val = col.items.findIndex(m => m === intValue)
|
|
414
|
+
pickerValue.push(val)
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
})
|
|
418
|
+
return pickerValue
|
|
419
|
+
}
|
|
420
|
+
},
|
|
421
|
+
watch: {
|
|
422
|
+
// ! 因为使用对象,在H5端watch的时候,就算没有发生改变,也会触发,这里直接监听toString后的值
|
|
423
|
+
options(val) {
|
|
424
|
+
this.init()
|
|
425
|
+
}
|
|
426
|
+
},
|
|
427
|
+
created() {
|
|
428
|
+
this.init()
|
|
429
|
+
},
|
|
430
|
+
methods: {
|
|
431
|
+
init() {
|
|
432
|
+
this.date = this.$pi.date.parseDate(this.defaultValue)
|
|
433
|
+
if (this.field === 'halfday') {
|
|
434
|
+
const time = this.date.time
|
|
435
|
+
if (this.date.hour < 12) {
|
|
436
|
+
time.setHours(0)
|
|
437
|
+
} else {
|
|
438
|
+
time.setHours(12)
|
|
439
|
+
}
|
|
440
|
+
this.date = this.$pi.date.parseDate(time)
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
handlePickstart() {
|
|
444
|
+
this.scrolling = true
|
|
445
|
+
},
|
|
446
|
+
// 标识滑动结束
|
|
447
|
+
handlePickend() {
|
|
448
|
+
this.scrolling = false
|
|
449
|
+
},
|
|
450
|
+
handlePopupClose() {
|
|
451
|
+
this.val = false
|
|
452
|
+
// 关闭
|
|
453
|
+
this.$emit('close')
|
|
454
|
+
this.handleEmitChange()
|
|
455
|
+
},
|
|
456
|
+
handleDateChange(e) {
|
|
457
|
+
const values = e.detail.value // values 返回的数组固定是picker的数量,只返回有变化的索引值
|
|
458
|
+
const time = this.date.time // 取出当前date的实际时间
|
|
459
|
+
values.forEach((value, index) => {
|
|
460
|
+
if (value !== null) {
|
|
461
|
+
// value为picker列的索引值
|
|
462
|
+
const col = this.columns[index]
|
|
463
|
+
let val = col.items[value] // 取出对应picker值
|
|
464
|
+
if (col.field === 'month') val--
|
|
465
|
+
if (col.field === 'halfday') val = value === 0 ? 0 : 12
|
|
466
|
+
time[col.setMethod](val) // 调用原生date方法赋值
|
|
467
|
+
}
|
|
468
|
+
})
|
|
469
|
+
// 重新解析
|
|
470
|
+
this.date = this.$pi.date.parseDate(time)
|
|
471
|
+
|
|
472
|
+
this.$emit('scrollend', this.date)
|
|
473
|
+
},
|
|
474
|
+
/**
|
|
475
|
+
* @vuese
|
|
476
|
+
* 取消选择
|
|
477
|
+
*/
|
|
478
|
+
handleCancel() {
|
|
479
|
+
/**
|
|
480
|
+
* @vuese
|
|
481
|
+
* 点击取消按钮时触发
|
|
482
|
+
* @arg 当前选中的值 单选为对象,多选模式为数组
|
|
483
|
+
*/
|
|
484
|
+
this.$emit('cancel')
|
|
485
|
+
this.onCancelClose && this.handlePopupClose()
|
|
486
|
+
},
|
|
487
|
+
/**
|
|
488
|
+
* @vuese
|
|
489
|
+
* 确认选择
|
|
490
|
+
*/
|
|
491
|
+
handleConfirm() {
|
|
492
|
+
// 提交
|
|
493
|
+
if (this.field === 'halfday') {
|
|
494
|
+
const time = this.date.time
|
|
495
|
+
time.setMinutes(0)
|
|
496
|
+
time.setSeconds(0)
|
|
497
|
+
time.setMilliseconds(0)
|
|
498
|
+
this.date = this.$pi.date.parseDate(time)
|
|
499
|
+
}
|
|
500
|
+
const value = this.format ? this.date.format(this.format) : this.date
|
|
501
|
+
this.$emit('confirm', value)
|
|
502
|
+
this.onConfirmClose && this.handlePopupClose()
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
</script>
|
|
507
|
+
|
|
508
|
+
<style lang="scss" scoped>
|
|
509
|
+
.pi-date-picker {
|
|
510
|
+
height: 50vh;
|
|
511
|
+
}
|
|
512
|
+
</style>
|