sadais-piui 1.2.7-beta70 → 1.2.7-beta71
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.
|
@@ -1,394 +1,464 @@
|
|
|
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', '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
|
-
|
|
121
|
-
type:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
default
|
|
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
|
-
|
|
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
|
-
return
|
|
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
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
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', '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
|
+
const date = this.$pi.date.parseDate(this.defaultValue)
|
|
231
|
+
return {
|
|
232
|
+
date,
|
|
233
|
+
scrolling: false // picker是否在滚动中,小程序在scrolling中点确定,选择的项目不正确
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
computed: {
|
|
237
|
+
getPopupSelect() {
|
|
238
|
+
return this.$pi.lang.mergeDeep(datePicker.popupSelect, this.popupSelect)
|
|
239
|
+
},
|
|
240
|
+
getConfirmBtn() {
|
|
241
|
+
const datePickerConfirmBtn = this.$pi.lang.mergeDeep(
|
|
242
|
+
datePicker.confirmBtn,
|
|
243
|
+
this.popupSelect.confirmBtn
|
|
244
|
+
)
|
|
245
|
+
const mergeConfirmBtn = this.$pi.lang.mergeDeep(datePickerConfirmBtn, this.confirmBtn)
|
|
246
|
+
if (!mergeConfirmBtn.disabled) {
|
|
247
|
+
mergeConfirmBtn.disabled = this.scrolling
|
|
248
|
+
}
|
|
249
|
+
return mergeConfirmBtn
|
|
250
|
+
},
|
|
251
|
+
getCancelBtn() {
|
|
252
|
+
const datePickerCancelBtn = this.$pi.lang.mergeDeep(
|
|
253
|
+
datePicker.cancelBtn,
|
|
254
|
+
this.popupSelect.cancelBtn
|
|
255
|
+
)
|
|
256
|
+
return this.$pi.lang.mergeDeep(datePickerCancelBtn, this.cancelBtn)
|
|
257
|
+
},
|
|
258
|
+
getPopup() {
|
|
259
|
+
const datePickerPopup = this.$pi.lang.mergeDeep(datePicker.popup, this.popupSelect.popup)
|
|
260
|
+
return this.$pi.lang.mergeDeep(datePickerPopup, this.popup)
|
|
261
|
+
},
|
|
262
|
+
options() {
|
|
263
|
+
const watchs = ['val', 'startYear', 'endYear', 'field', 'defaultValue']
|
|
264
|
+
const options = watchs
|
|
265
|
+
.filter(d => this[d])
|
|
266
|
+
.map(d => this[d].toString())
|
|
267
|
+
.join('-')
|
|
268
|
+
return options
|
|
269
|
+
},
|
|
270
|
+
getHeight() {
|
|
271
|
+
return this.$pi.common.addUnit(this.height)
|
|
272
|
+
},
|
|
273
|
+
getTitlePadding() {
|
|
274
|
+
return this.$pi.common.addUnit(this.titlePadding)
|
|
275
|
+
},
|
|
276
|
+
indicatorStyle() {
|
|
277
|
+
const itemHeight = uni.upx2px(this.itemHeight)
|
|
278
|
+
return `height: ${itemHeight}px;line-height: ${itemHeight}px;`
|
|
279
|
+
},
|
|
280
|
+
getUnits() {
|
|
281
|
+
return this.$pi.mergeDeep(datePicker.units, this.units, {
|
|
282
|
+
arrayMerge: (target, source, options) => {
|
|
283
|
+
return target.map((t, index) => source[index] || t)
|
|
284
|
+
}
|
|
285
|
+
})
|
|
286
|
+
},
|
|
287
|
+
getYearOptions() {
|
|
288
|
+
if (this.yearOptions && this.yearOptions.length > 0) {
|
|
289
|
+
return this.yearOptions
|
|
290
|
+
}
|
|
291
|
+
return this.$pi.common.generateArray(this.startYear, this.endYear)
|
|
292
|
+
},
|
|
293
|
+
getMonthOptions() {
|
|
294
|
+
if (this.monthOptions && this.monthOptions.length > 0) {
|
|
295
|
+
return this.monthOptions
|
|
296
|
+
}
|
|
297
|
+
return this.$pi.common.generateArray(1, 12)
|
|
298
|
+
},
|
|
299
|
+
getDayOptions() {
|
|
300
|
+
if (this.dayOptions && this.dayOptions.length > 0) {
|
|
301
|
+
return this.dayOptions
|
|
302
|
+
}
|
|
303
|
+
const monthDays = new Date(this.date.year, this.date.month, 0).getDate()
|
|
304
|
+
return this.$pi.common.generateArray(1, monthDays)
|
|
305
|
+
},
|
|
306
|
+
getHourOptions() {
|
|
307
|
+
if (this.hourOptions && this.hourOptions.length > 0) {
|
|
308
|
+
return this.hourOptions
|
|
309
|
+
}
|
|
310
|
+
return this.$pi.common.generateArray(0, 23)
|
|
311
|
+
},
|
|
312
|
+
getMinuteOptions() {
|
|
313
|
+
if (this.minuteOptions && this.minuteOptions.length > 0) {
|
|
314
|
+
return this.minuteOptions
|
|
315
|
+
}
|
|
316
|
+
return this.$pi.common.generateArray(0, 59)
|
|
317
|
+
},
|
|
318
|
+
columns() {
|
|
319
|
+
let columns = [
|
|
320
|
+
{
|
|
321
|
+
field: 'year',
|
|
322
|
+
unit: this.getUnits[0],
|
|
323
|
+
key: 'year',
|
|
324
|
+
setMethod: 'setYear',
|
|
325
|
+
items: this.getYearOptions
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
field: 'month',
|
|
329
|
+
unit: this.getUnits[1],
|
|
330
|
+
key: 'month',
|
|
331
|
+
setMethod: 'setMonth',
|
|
332
|
+
items: this.getMonthOptions
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
field: 'day',
|
|
336
|
+
unit: this.getUnits[2],
|
|
337
|
+
key: 'date',
|
|
338
|
+
setMethod: 'setDate',
|
|
339
|
+
items: this.getDayOptions
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
field: 'hour',
|
|
343
|
+
unit: this.getUnits[3],
|
|
344
|
+
key: 'hour',
|
|
345
|
+
setMethod: 'setHours',
|
|
346
|
+
type: 'time',
|
|
347
|
+
items: this.getHourOptions
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
field: 'minute',
|
|
351
|
+
unit: this.getUnits[4],
|
|
352
|
+
key: 'minute',
|
|
353
|
+
setMethod: 'setMinutes',
|
|
354
|
+
type: 'time',
|
|
355
|
+
items: this.getMinuteOptions
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
field: 'second',
|
|
359
|
+
unit: this.getUnits[5],
|
|
360
|
+
key: 'second',
|
|
361
|
+
setMethod: 'setSeconds',
|
|
362
|
+
type: 'time',
|
|
363
|
+
items: this.$pi.common.generateArray(0, 59)
|
|
364
|
+
}
|
|
365
|
+
]
|
|
366
|
+
|
|
367
|
+
columns = columns.filter((col, index) => {
|
|
368
|
+
return FIELDS.slice(index).includes(this.field)
|
|
369
|
+
})
|
|
370
|
+
|
|
371
|
+
if (this.dateType === 'time') {
|
|
372
|
+
columns = columns.filter(col => col.type === 'time')
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return columns
|
|
376
|
+
},
|
|
377
|
+
pickerValue() {
|
|
378
|
+
const pickerValue = []
|
|
379
|
+
this.columns.forEach(col => {
|
|
380
|
+
// 当前日期字段
|
|
381
|
+
const value = this.date[col.key]
|
|
382
|
+
if (value !== null) {
|
|
383
|
+
// 查找当前picker中索引对应的真实值
|
|
384
|
+
const intValue = parseInt(value, 10)
|
|
385
|
+
const val = col.items.findIndex(m => m === intValue)
|
|
386
|
+
pickerValue.push(val)
|
|
387
|
+
}
|
|
388
|
+
})
|
|
389
|
+
return pickerValue
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
watch: {
|
|
393
|
+
// ! 因为使用对象,在H5端watch的时候,就算没有发生改变,也会触发,这里直接监听toString后的值
|
|
394
|
+
options(val) {
|
|
395
|
+
this.init()
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
created() {
|
|
399
|
+
this.init()
|
|
400
|
+
},
|
|
401
|
+
methods: {
|
|
402
|
+
init() {
|
|
403
|
+
this.date = this.$pi.date.parseDate(this.defaultValue)
|
|
404
|
+
},
|
|
405
|
+
handlePickstart() {
|
|
406
|
+
this.scrolling = true
|
|
407
|
+
},
|
|
408
|
+
// 标识滑动结束
|
|
409
|
+
handlePickend() {
|
|
410
|
+
this.scrolling = false
|
|
411
|
+
},
|
|
412
|
+
handlePopupClose() {
|
|
413
|
+
this.val = false
|
|
414
|
+
// 关闭
|
|
415
|
+
this.$emit('close')
|
|
416
|
+
this.handleEmitChange()
|
|
417
|
+
},
|
|
418
|
+
handleDateChange(e) {
|
|
419
|
+
const values = e.detail.value // values 返回的数组固定是picker的数量,只返回有变化的索引值
|
|
420
|
+
const time = this.date.time // 取出当前date的实际时间
|
|
421
|
+
values.forEach((value, index) => {
|
|
422
|
+
if (value !== null) {
|
|
423
|
+
// value为picker列的索引值
|
|
424
|
+
const col = this.columns[index]
|
|
425
|
+
let val = col.items[value] // 取出对应picker值
|
|
426
|
+
if (col.field === 'month') val--
|
|
427
|
+
time[col.setMethod](val) // 调用原生date方法赋值
|
|
428
|
+
}
|
|
429
|
+
})
|
|
430
|
+
// 重新解析
|
|
431
|
+
this.date = this.$pi.date.parseDate(time)
|
|
432
|
+
},
|
|
433
|
+
/**
|
|
434
|
+
* @vuese
|
|
435
|
+
* 取消选择
|
|
436
|
+
*/
|
|
437
|
+
handleCancel() {
|
|
438
|
+
/**
|
|
439
|
+
* @vuese
|
|
440
|
+
* 点击取消按钮时触发
|
|
441
|
+
* @arg 当前选中的值 单选为对象,多选模式为数组
|
|
442
|
+
*/
|
|
443
|
+
this.$emit('cancel')
|
|
444
|
+
this.onCancelClose && this.handlePopupClose()
|
|
445
|
+
},
|
|
446
|
+
/**
|
|
447
|
+
* @vuese
|
|
448
|
+
* 确认选择
|
|
449
|
+
*/
|
|
450
|
+
handleConfirm() {
|
|
451
|
+
// 提交
|
|
452
|
+
const value = this.format ? this.date.format(this.format) : this.date
|
|
453
|
+
this.$emit('confirm', value)
|
|
454
|
+
this.onConfirmClose && this.handlePopupClose()
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
</script>
|
|
459
|
+
|
|
460
|
+
<style lang="scss" scoped>
|
|
461
|
+
.pi-date-picker {
|
|
462
|
+
height: 50vh;
|
|
463
|
+
}
|
|
464
|
+
</style>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
* @Author: zhangzhenfei
|
|
3
3
|
* @Date: 2022-05-18 11:08:49
|
|
4
|
-
* @LastEditTime:
|
|
5
|
-
* @LastEditors:
|
|
4
|
+
* @LastEditTime: 2023-08-03 16:19:44
|
|
5
|
+
* @LastEditors: liujun
|
|
6
6
|
* @Description: 日历输入
|
|
7
|
-
* @FilePath:
|
|
7
|
+
* @FilePath: \dt-opt-manage-consoled:\project-liujun\piui-awesome\src\piui\components\pi-date-picker-input\index.vue
|
|
8
8
|
-->
|
|
9
9
|
|
|
10
10
|
<template>
|
|
@@ -55,6 +55,11 @@
|
|
|
55
55
|
:end-year="getDatePicker.endYear"
|
|
56
56
|
:field="getDatePicker.field"
|
|
57
57
|
:date-type="getDatePicker.dateType"
|
|
58
|
+
:year-options="getDatePicker.yearOptions"
|
|
59
|
+
:month-options="getDatePicker.monthOptions"
|
|
60
|
+
:day-options="getDatePicker.dayOptions"
|
|
61
|
+
:hour-options="getDatePicker.hourOptions"
|
|
62
|
+
:minute-options="getDatePicker.minuteOptions"
|
|
58
63
|
:format="dateFormat"
|
|
59
64
|
:item-height="getDatePicker.itemHeight"
|
|
60
65
|
:item-style="getDatePicker.itemStyle"
|
package/config/datePicker.js
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
import popupSelect from './popupSelect'
|
|
2
|
-
|
|
3
|
-
const currentYear = new Date().getFullYear()
|
|
4
|
-
const startYear = currentYear - 30
|
|
5
|
-
const endYear = currentYear
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
customClass: '', // 自定义样式类,字符串形式('')
|
|
9
|
-
customStyle: {}, // 自定义样式,对象形式(默认值:{})
|
|
10
|
-
startYear, // 开始年份(默认当前年份 - 30)
|
|
11
|
-
endYear, // 结束年份(默认当前年份)
|
|
12
|
-
field: 'day', // 选择器的粒度 year、month、day、hour、minute、second
|
|
13
|
-
dateType: 'datetime', // 日期类型,date、datetime、time(默认值:datetime)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import popupSelect from './popupSelect'
|
|
2
|
+
|
|
3
|
+
const currentYear = new Date().getFullYear()
|
|
4
|
+
const startYear = currentYear - 30
|
|
5
|
+
const endYear = currentYear
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
customClass: '', // 自定义样式类,字符串形式('')
|
|
9
|
+
customStyle: {}, // 自定义样式,对象形式(默认值:{})
|
|
10
|
+
startYear, // 开始年份(默认当前年份 - 30)
|
|
11
|
+
endYear, // 结束年份(默认当前年份)
|
|
12
|
+
field: 'day', // 选择器的粒度 year、month、day、hour、minute、second
|
|
13
|
+
dateType: 'datetime', // 日期类型,date、datetime、time(默认值:datetime)
|
|
14
|
+
yearOptions: [], // 年份选项(默认值:[])
|
|
15
|
+
monthOptions: [], // 月份选项(默认值:[])
|
|
16
|
+
dayOptions: [], // 日期选项(默认值:[])
|
|
17
|
+
hourOptions: [], // 小时选项(默认值:[])
|
|
18
|
+
minuteOptions: [], // 分钟选项(默认值:[])
|
|
19
|
+
defaultValue: '', // 日期默认值
|
|
20
|
+
units: ['年', '月', '日', '时', '分', '秒'], // 单位数组,默认值:['年', '月', '日', '时', '分', '秒']
|
|
21
|
+
format: '', // 返回的日期格式,为空的时候,返回的是日期对象
|
|
22
|
+
itemHeight: 110, // 行高(默认:'110rpx')
|
|
23
|
+
itemStyle: {}, // 行样式(默认:{})
|
|
24
|
+
showItemBottomBorder: true, // 是否显示底部边线
|
|
25
|
+
popupSelect: popupSelect, // popupSelect配置
|
|
26
|
+
popup: popupSelect.popup, // 弹窗的配置,默认选项请参照popup
|
|
27
|
+
confirmBtn: popupSelect.confirmBtn, // 确认按钮配置
|
|
28
|
+
cancelBtn: popupSelect.cancelBtn // 取消按钮配置
|
|
29
|
+
}
|