sadais-piui 1.2.6-beta7 → 1.2.7-beta1
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/components/pi-bubble/index.vue +174 -0
- package/components/pi-calendar-input/index.vue +2 -3
- package/components/pi-calendar-panel/index.vue +5 -6
- package/components/pi-checkbox/index.vue +4 -2
- package/components/pi-date-picker/index.vue +83 -86
- package/components/pi-date-picker-input/index.vue +188 -0
- package/components/pi-input/index.vue +0 -2
- package/components/pi-radio/index.vue +3 -1
- package/components/pi-regions-select/index.vue +32 -6
- package/components/pi-regions-select-input/index.vue +192 -0
- package/components/pi-select/index.vue +79 -7
- package/components/pi-select-input/index.vue +208 -0
- package/components/pi-subsection/index.vue +37 -33
- package/config/bubble.js +6 -0
- package/config/datePicker.js +1 -0
- package/config/datePickerInput.js +17 -0
- package/config/regionsSelect.js +2 -1
- package/config/regionsSelectInput.js +28 -0
- package/config/select.js +1 -0
- package/config/selectInput.js +28 -0
- package/config/subsection.js +2 -2
- package/package.json +2 -3
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="pi-bubble pi-rela pi-flex pi-align-center pi-justify-center"
|
|
4
|
+
:style="[customStyle]"
|
|
5
|
+
:class="customClass"
|
|
6
|
+
@longpress.stop="handleLongpress"
|
|
7
|
+
>
|
|
8
|
+
<slot />
|
|
9
|
+
<view v-show="showBubble" class="pi-bubble-wrapper" :class="[bubbleClass]">
|
|
10
|
+
<view
|
|
11
|
+
ref="bubble"
|
|
12
|
+
class="pi-bubble-content pi-abso pi-bg-white pi-radius-4 pi-pd-20"
|
|
13
|
+
:style="[bubbleStyle]"
|
|
14
|
+
>
|
|
15
|
+
<slot name="bubble" />
|
|
16
|
+
<view class="pi-bubble-angle pi-abso" />
|
|
17
|
+
</view>
|
|
18
|
+
</view>
|
|
19
|
+
<pi-mask v-model="showMaks" background="transparent" @close="showBubble = false" />
|
|
20
|
+
</view>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script>
|
|
24
|
+
/**
|
|
25
|
+
* bubble 气泡弹窗
|
|
26
|
+
*/
|
|
27
|
+
import { getConfig } from '../../config'
|
|
28
|
+
const TAG = 'PiBubble'
|
|
29
|
+
const { bubble } = getConfig()
|
|
30
|
+
|
|
31
|
+
// 底部栏
|
|
32
|
+
export default {
|
|
33
|
+
name: 'PiBubble',
|
|
34
|
+
props: {
|
|
35
|
+
// 自定义样式,对象形式
|
|
36
|
+
customStyle: {
|
|
37
|
+
type: Object,
|
|
38
|
+
// {}
|
|
39
|
+
default() {
|
|
40
|
+
return bubble.customStyle
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
customClass: {
|
|
44
|
+
type: String,
|
|
45
|
+
// ''
|
|
46
|
+
default() {
|
|
47
|
+
return bubble.customClass
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
position: {
|
|
51
|
+
type: String,
|
|
52
|
+
default() {
|
|
53
|
+
return bubble.position
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
zIndex: {
|
|
57
|
+
type: Number,
|
|
58
|
+
default() {
|
|
59
|
+
return bubble.zIndex
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
data() {
|
|
64
|
+
return {
|
|
65
|
+
showBubble: false,
|
|
66
|
+
showMaks: false,
|
|
67
|
+
bubleWidth: 0,
|
|
68
|
+
sysInfo: {},
|
|
69
|
+
bublePosition: {
|
|
70
|
+
top: 0,
|
|
71
|
+
left: 0
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
computed: {
|
|
76
|
+
rpxRatio() {
|
|
77
|
+
return 750 / this.screenWidth
|
|
78
|
+
},
|
|
79
|
+
screenWidth() {
|
|
80
|
+
return this.sysInfo.screenWidth
|
|
81
|
+
},
|
|
82
|
+
bubblePosition() {
|
|
83
|
+
return this.position === 'bottom' ? 'top' : 'bottom'
|
|
84
|
+
},
|
|
85
|
+
bubbleStyle() {
|
|
86
|
+
return {
|
|
87
|
+
zIndex: this.zIndex,
|
|
88
|
+
...this.bublePosition
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
bubbleClass() {
|
|
92
|
+
return this.position === 'top' ? 'isTop' : ''
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
mounted() {
|
|
96
|
+
this.init()
|
|
97
|
+
},
|
|
98
|
+
methods: {
|
|
99
|
+
init() {
|
|
100
|
+
this.sysInfo = uni.getSystemInfoSync()
|
|
101
|
+
},
|
|
102
|
+
async handleLongpress(e) {
|
|
103
|
+
await this.calcBubblePosition()
|
|
104
|
+
this.showBubble = true
|
|
105
|
+
this.showMaks = true
|
|
106
|
+
},
|
|
107
|
+
getBubbleWidth() {
|
|
108
|
+
return new Promise(reslove => {
|
|
109
|
+
this.$set(this, 'bublePosition', { top: '-9999vh', left: 0 })
|
|
110
|
+
this.showBubble = true
|
|
111
|
+
setTimeout(() => {
|
|
112
|
+
reslove(this.$refs.bubble ? this.$refs.bubble.$el.getBoundingClientRect().width : 0)
|
|
113
|
+
this.showBubble = false
|
|
114
|
+
}, 500)
|
|
115
|
+
})
|
|
116
|
+
},
|
|
117
|
+
async calcBubblePosition() {
|
|
118
|
+
let bublePosition = this.$el.getBoundingClientRect()
|
|
119
|
+
this.bubleWidth = await this.getBubbleWidth()
|
|
120
|
+
const lengthGap = (this.bubleWidth - bublePosition.width) / 2
|
|
121
|
+
const compRight = this.screenWidth - bublePosition.x - bublePosition.width
|
|
122
|
+
const posRes = {}
|
|
123
|
+
if (lengthGap <= 0 || (lengthGap < bublePosition.x && lengthGap < compRight)) {
|
|
124
|
+
posRes.left = -Math.abs(lengthGap) + 'px'
|
|
125
|
+
} else {
|
|
126
|
+
posRes.right = 4 - Math.min(bublePosition.x, compRight) + 'px'
|
|
127
|
+
}
|
|
128
|
+
posRes[this.bubblePosition] = 'calc(100% + 18rpx)'
|
|
129
|
+
this.$set(this, 'bublePosition', posRes)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<style lang="scss" scoped>
|
|
136
|
+
.pi-bubble {
|
|
137
|
+
width: fit-content;
|
|
138
|
+
height: fit-content;
|
|
139
|
+
.pi-bubble-wrapper {
|
|
140
|
+
filter: drop-shadow(0 0 2rpx #000);
|
|
141
|
+
z-index: 9999;
|
|
142
|
+
position: absolute;
|
|
143
|
+
width: 100%;
|
|
144
|
+
height: 0;
|
|
145
|
+
top: 100%;
|
|
146
|
+
&.isTop {
|
|
147
|
+
top: 0;
|
|
148
|
+
.pi-bubble-content {
|
|
149
|
+
.pi-bubble-angle {
|
|
150
|
+
top: initial;
|
|
151
|
+
bottom: -10rpx;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
.pi-bubble-content {
|
|
156
|
+
max-width: 98vw;
|
|
157
|
+
line-height: 30rpx;
|
|
158
|
+
color: #fff;
|
|
159
|
+
z-index: 9999;
|
|
160
|
+
background-color: #000;
|
|
161
|
+
.pi-bubble-angle {
|
|
162
|
+
top: -10rpx;
|
|
163
|
+
left: 50%;
|
|
164
|
+
z-index: 9999;
|
|
165
|
+
width: 0rpx;
|
|
166
|
+
height: 0rpx;
|
|
167
|
+
border: 12rpx solid #000;
|
|
168
|
+
transform: translateX(-50%) rotate(45deg);
|
|
169
|
+
transform-origin: center;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
</style>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
* @Author: zhangzhenfei
|
|
3
3
|
* @Date: 2022-05-18 11:08:49
|
|
4
|
-
* @LastEditTime: 2022-05-
|
|
4
|
+
* @LastEditTime: 2022-05-21 15:00:48
|
|
5
5
|
* @LastEditors: zhangzhenfei
|
|
6
6
|
* @Description: 日历输入
|
|
7
7
|
* @FilePath: /hfmp-checkin-front/Users/feilin/workspace/piui/piui-awesome/src/piui/components/pi-calendar-input/index.vue
|
|
@@ -152,7 +152,6 @@ export default {
|
|
|
152
152
|
? this.parseValueFn.fn
|
|
153
153
|
: this.parseValueFn
|
|
154
154
|
if (this.$pi.lang.isFunction(parseValueFn)) {
|
|
155
|
-
// 删除之前的钩子, 如果定义了则使用钩子删除文件
|
|
156
155
|
const parseValue = parseValueFn(this.val)
|
|
157
156
|
return parseValue
|
|
158
157
|
}
|
|
@@ -173,7 +172,7 @@ export default {
|
|
|
173
172
|
.map(date => {
|
|
174
173
|
return this.$pi.date.formatDate(new Date(date), this.dateFormat)
|
|
175
174
|
})
|
|
176
|
-
.join(
|
|
175
|
+
.join(this.rangeSplit)
|
|
177
176
|
}
|
|
178
177
|
return ''
|
|
179
178
|
}
|
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
<view
|
|
59
59
|
class="pi-abso-center pi-fw-500 pi-light-gray"
|
|
60
60
|
style="
|
|
61
|
-
|
|
62
61
|
z-index: 1;
|
|
63
62
|
font-size: 300rpx;
|
|
64
63
|
pointer-events: none;
|
|
@@ -267,6 +266,11 @@ export default {
|
|
|
267
266
|
const inRange =
|
|
268
267
|
start && end && day.timestamp > start.timestamp && day.timestamp < end.timestamp
|
|
269
268
|
const activeStyle = {}
|
|
269
|
+
// 处理中间范围的样式
|
|
270
|
+
if (inRange) {
|
|
271
|
+
activeStyle.color = this.rangeColor
|
|
272
|
+
activeStyle.background = this.rangeBg
|
|
273
|
+
}
|
|
270
274
|
// 处理两端
|
|
271
275
|
if (isBegin || isEnd) {
|
|
272
276
|
activeStyle.color = this.activeColor
|
|
@@ -275,11 +279,6 @@ export default {
|
|
|
275
279
|
: `0 ${this.getActiveBorderRadius} ${this.getActiveBorderRadius} 0`
|
|
276
280
|
if (this.activeBg) activeStyle.background = this.activeBg
|
|
277
281
|
}
|
|
278
|
-
// 处理中间范围的样式
|
|
279
|
-
if (inRange) {
|
|
280
|
-
activeStyle.color = this.rangeColor
|
|
281
|
-
activeStyle.background = this.rangeBg
|
|
282
|
-
}
|
|
283
282
|
day.activeStyle = activeStyle
|
|
284
283
|
// type 为 range 开始和结束的提示
|
|
285
284
|
if (isBegin) day.tip = this.startText
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
v-if="getShape !== 'text'"
|
|
10
10
|
class="check-icon"
|
|
11
11
|
:style="[checkStyle]"
|
|
12
|
-
@tap="handleCheckboxToggle(false)"
|
|
12
|
+
@tap.stop="handleCheckboxToggle(false)"
|
|
13
13
|
>
|
|
14
14
|
<view v-if="getShape === 'dot'" class="dot" :style="[dotStyle]" />
|
|
15
15
|
<pi-icon v-else name="blod-check" :size="getIconSize" />
|
|
@@ -259,6 +259,8 @@ $unactive-color: #cccccc;
|
|
|
259
259
|
.pi-check-wrap {
|
|
260
260
|
display: inline-flex;
|
|
261
261
|
align-items: center;
|
|
262
|
+
cursor: pointer;
|
|
263
|
+
|
|
262
264
|
.check-icon {
|
|
263
265
|
position: relative;
|
|
264
266
|
display: inline-flex;
|
|
@@ -324,7 +326,7 @@ $unactive-color: #cccccc;
|
|
|
324
326
|
opacity: $pi-disabled-opacity;
|
|
325
327
|
}
|
|
326
328
|
&.active {
|
|
327
|
-
.
|
|
329
|
+
.check-label {
|
|
328
330
|
color: $pi-primary-color;
|
|
329
331
|
}
|
|
330
332
|
&.line,
|
|
@@ -29,32 +29,9 @@
|
|
|
29
29
|
@pickend="handlePickend"
|
|
30
30
|
@change="handleDateChange"
|
|
31
31
|
>
|
|
32
|
-
<picker-view-column>
|
|
33
|
-
<view v-for="
|
|
34
|
-
{{ item }}
|
|
35
|
-
</view>
|
|
36
|
-
</picker-view-column>
|
|
37
|
-
<picker-view-column v-if="showMonth">
|
|
38
|
-
<view v-for="(item, index) in months" :key="index" :style="indicatorStyle">
|
|
39
|
-
{{ item + 1 }}月
|
|
40
|
-
</view>
|
|
41
|
-
</picker-view-column>
|
|
42
|
-
<picker-view-column v-if="showDay">
|
|
43
|
-
<view v-for="(item, index) in days" :key="index" :style="indicatorStyle">{{ item }}日</view>
|
|
44
|
-
</picker-view-column>
|
|
45
|
-
<picker-view-column v-if="showHour">
|
|
46
|
-
<view v-for="(item, index) in hours" :key="index" :style="indicatorStyle">
|
|
47
|
-
{{ item }}时
|
|
48
|
-
</view>
|
|
49
|
-
</picker-view-column>
|
|
50
|
-
<picker-view-column v-if="showMinute">
|
|
51
|
-
<view v-for="(item, index) in minutes" :key="index" :style="indicatorStyle">
|
|
52
|
-
{{ item }}分
|
|
53
|
-
</view>
|
|
54
|
-
</picker-view-column>
|
|
55
|
-
<picker-view-column v-if="showSecond">
|
|
56
|
-
<view v-for="(item, index) in seconds" :key="index" :style="indicatorStyle">
|
|
57
|
-
{{ item }}秒
|
|
32
|
+
<picker-view-column v-for="col in columns" :key="col.field">
|
|
33
|
+
<view v-for="item in col.items" :key="item" :style="indicatorStyle">
|
|
34
|
+
{{ item }}{{ col.unit }}
|
|
58
35
|
</view>
|
|
59
36
|
</picker-view-column>
|
|
60
37
|
</picker-view>
|
|
@@ -68,14 +45,7 @@ import { getConfig } from '../../config'
|
|
|
68
45
|
|
|
69
46
|
const TAG = 'PiDatePicker'
|
|
70
47
|
const { datePicker } = getConfig()
|
|
71
|
-
const
|
|
72
|
-
{ field: 'year', getMethod: 'years', setMethod: 'setYear' },
|
|
73
|
-
{ field: 'month', getMethod: 'months', setMethod: 'setMonth' },
|
|
74
|
-
{ field: 'day', getMethod: 'days', setMethod: 'setDate' },
|
|
75
|
-
{ field: 'hour', getMethod: 'hours', setMethod: 'setHours' },
|
|
76
|
-
{ field: 'minute', getMethod: 'minutes', setMethod: 'setMinutes' },
|
|
77
|
-
{ field: 'second', getMethod: 'seconds', setMethod: 'setSeconds' }
|
|
78
|
-
]
|
|
48
|
+
const FIELDS = ['year', 'month', 'day', 'hour', 'minute', 'second']
|
|
79
49
|
|
|
80
50
|
export default {
|
|
81
51
|
name: 'PiDatePicker',
|
|
@@ -124,13 +94,25 @@ export default {
|
|
|
124
94
|
type: String,
|
|
125
95
|
validator: function(value) {
|
|
126
96
|
// 这个值必须匹配下列字符串中的一个
|
|
127
|
-
return
|
|
97
|
+
return FIELDS.includes(value)
|
|
128
98
|
},
|
|
129
99
|
// 'day'
|
|
130
100
|
default() {
|
|
131
101
|
return datePicker.field
|
|
132
102
|
}
|
|
133
103
|
},
|
|
104
|
+
// 日期类型,date、datetime、time
|
|
105
|
+
dateType: {
|
|
106
|
+
// `'date'` `'datetime'` `'time'`
|
|
107
|
+
type: String,
|
|
108
|
+
validator: function(value) {
|
|
109
|
+
return ['date', 'datetime', 'time'].includes(value)
|
|
110
|
+
},
|
|
111
|
+
// 'datetime'
|
|
112
|
+
default() {
|
|
113
|
+
return datePicker.dateType
|
|
114
|
+
}
|
|
115
|
+
},
|
|
134
116
|
// 日期默认值
|
|
135
117
|
defaultValue: {
|
|
136
118
|
type: [Number, String, Date],
|
|
@@ -245,61 +227,75 @@ export default {
|
|
|
245
227
|
const itemHeight = uni.upx2px(this.itemHeight)
|
|
246
228
|
return `height: ${itemHeight}px;line-height: ${itemHeight}px;`
|
|
247
229
|
},
|
|
248
|
-
|
|
249
|
-
return ['year', 'month', 'day', 'hour', 'minute', 'second'].includes(this.field)
|
|
250
|
-
},
|
|
251
|
-
showMonth() {
|
|
252
|
-
return ['month', 'day', 'hour', 'minute', 'second'].includes(this.field)
|
|
253
|
-
},
|
|
254
|
-
showDay() {
|
|
255
|
-
return ['day', 'hour', 'minute', 'second'].includes(this.field)
|
|
256
|
-
},
|
|
257
|
-
showHour() {
|
|
258
|
-
return ['hour', 'minute', 'second'].includes(this.field)
|
|
259
|
-
},
|
|
260
|
-
showMinute() {
|
|
261
|
-
return ['minute', 'second'].includes(this.field)
|
|
262
|
-
},
|
|
263
|
-
showSecond() {
|
|
264
|
-
return ['second'].includes(this.field)
|
|
265
|
-
},
|
|
266
|
-
years() {
|
|
267
|
-
return this.$pi.common.generateArray(this.startYear, this.endYear)
|
|
268
|
-
},
|
|
269
|
-
months() {
|
|
270
|
-
return this.$pi.common.generateArray(0, 11)
|
|
271
|
-
},
|
|
272
|
-
days() {
|
|
230
|
+
columns() {
|
|
273
231
|
const monthDays = new Date(this.date.year, this.date.month, 0).getDate()
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
232
|
+
let columns = [
|
|
233
|
+
{
|
|
234
|
+
field: 'year',
|
|
235
|
+
unit: '年',
|
|
236
|
+
key: 'year',
|
|
237
|
+
setMethod: 'setYear',
|
|
238
|
+
items: this.$pi.common.generateArray(this.startYear, this.endYear)
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
field: 'month',
|
|
242
|
+
unit: '月',
|
|
243
|
+
key: 'month',
|
|
244
|
+
setMethod: 'setMonth',
|
|
245
|
+
items: this.$pi.common.generateArray(1, 12)
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
field: 'day',
|
|
249
|
+
unit: '日',
|
|
250
|
+
key: 'date',
|
|
251
|
+
setMethod: 'setDate',
|
|
252
|
+
items: this.$pi.common.generateArray(1, monthDays)
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
field: 'hour',
|
|
256
|
+
unit: '时',
|
|
257
|
+
key: 'hour',
|
|
258
|
+
setMethod: 'setHours',
|
|
259
|
+
type: 'time',
|
|
260
|
+
items: this.$pi.common.generateArray(0, 23)
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
field: 'minute',
|
|
264
|
+
unit: '分',
|
|
265
|
+
key: 'minute',
|
|
266
|
+
setMethod: 'setMinutes',
|
|
267
|
+
type: 'time',
|
|
268
|
+
items: this.$pi.common.generateArray(0, 59)
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
field: 'second',
|
|
272
|
+
unit: '秒',
|
|
273
|
+
key: 'second',
|
|
274
|
+
setMethod: 'setSeconds',
|
|
275
|
+
type: 'time',
|
|
276
|
+
items: this.$pi.common.generateArray(0, 59)
|
|
277
|
+
}
|
|
278
|
+
]
|
|
279
|
+
|
|
280
|
+
columns = columns.filter((col, index) => {
|
|
281
|
+
return FIELDS.slice(index).includes(this.field)
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
if (this.dateType === 'time') {
|
|
285
|
+
columns = columns.filter(col => col.type === 'time')
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return columns
|
|
284
289
|
},
|
|
285
290
|
pickerValue() {
|
|
286
|
-
const dateFieldMaps = [
|
|
287
|
-
{ key: 'year', dataKey: 'years', showKey: 'showYear' },
|
|
288
|
-
{ key: 'month', dataKey: 'months', showKey: 'showMonth' },
|
|
289
|
-
{ key: 'date', dataKey: 'days', showKey: 'showDay' },
|
|
290
|
-
{ key: 'hour', dataKey: 'hours', showKey: 'showHour' },
|
|
291
|
-
{ key: 'minute', dataKey: 'minutes', showKey: 'showMinute' },
|
|
292
|
-
{ key: 'second', dataKey: 'seconds', showKey: 'showSecond' }
|
|
293
|
-
]
|
|
294
291
|
const pickerValue = []
|
|
295
|
-
|
|
292
|
+
this.columns.forEach(col => {
|
|
296
293
|
// 当前日期字段
|
|
297
|
-
|
|
298
|
-
if (
|
|
299
|
-
if (map.key === 'month') value--
|
|
294
|
+
const value = this.date[col.key]
|
|
295
|
+
if (value !== null) {
|
|
300
296
|
// 查找当前picker中索引对应的真实值
|
|
301
297
|
const intValue = parseInt(value, 10)
|
|
302
|
-
const val =
|
|
298
|
+
const val = col.items.findIndex(m => m === intValue)
|
|
303
299
|
pickerValue.push(val)
|
|
304
300
|
}
|
|
305
301
|
})
|
|
@@ -338,9 +334,10 @@ export default {
|
|
|
338
334
|
values.forEach((value, index) => {
|
|
339
335
|
if (value !== null) {
|
|
340
336
|
// value为picker列的索引值
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
337
|
+
const col = this.columns[index]
|
|
338
|
+
let val = col.items[value] // 取出对应picker值
|
|
339
|
+
if (col.field === 'month') val--
|
|
340
|
+
time[col.setMethod](val) // 调用原生date方法赋值
|
|
344
341
|
}
|
|
345
342
|
})
|
|
346
343
|
// 重新解析
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: zhangzhenfei
|
|
3
|
+
* @Date: 2022-05-18 11:08:49
|
|
4
|
+
* @LastEditTime: 2022-05-20 17:52:51
|
|
5
|
+
* @LastEditors: zhangzhenfei
|
|
6
|
+
* @Description: 日历输入
|
|
7
|
+
* @FilePath: /hfmp-checkin-front/Users/feilin/workspace/piui/piui-awesome/src/piui/components/pi-date-picker-input/index.vue
|
|
8
|
+
-->
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<view class="pi-datePicker-input">
|
|
12
|
+
<!-- 输入框 -->
|
|
13
|
+
<view v-if="$slots.default || $slots.$default" class="pi-w-100P" @click="show = true">
|
|
14
|
+
<slot />
|
|
15
|
+
</view>
|
|
16
|
+
<pi-input
|
|
17
|
+
v-else
|
|
18
|
+
type="text"
|
|
19
|
+
:value="getInputValue"
|
|
20
|
+
:custom-class="input.customClass"
|
|
21
|
+
:custom-style="input.customStyle"
|
|
22
|
+
:placeholder="input.placeholder"
|
|
23
|
+
:placeholder-style="input.placeholderStyle"
|
|
24
|
+
:placeholder-class="input.placeholderClass"
|
|
25
|
+
:disabled="input.disabled"
|
|
26
|
+
:border="input.border"
|
|
27
|
+
:maxlength="input.maxlength"
|
|
28
|
+
:password="input.password"
|
|
29
|
+
:cursor-spacing="input.cursorSpacing"
|
|
30
|
+
:focus="input.focus"
|
|
31
|
+
:confirm-type="input.confirmType"
|
|
32
|
+
:confirm-hold="input.confirmHold"
|
|
33
|
+
:cursor="input.cursor"
|
|
34
|
+
:selection-start="input.selectionStart"
|
|
35
|
+
:selection-end="input.selectionEnd"
|
|
36
|
+
:adjust-position="input.adjustPosition"
|
|
37
|
+
:hold-keyboard="input.holdKeyboard"
|
|
38
|
+
:auto-blur="input.autoBlur"
|
|
39
|
+
:show-confirmbar="input.showConfirmbar"
|
|
40
|
+
:auto-height="input.autoHeight"
|
|
41
|
+
:fixed="input.fixed"
|
|
42
|
+
:disable-default-padding="input.disableDefaultPadding"
|
|
43
|
+
:clearable="input.clearable"
|
|
44
|
+
:clear-icon="input.clearIcon"
|
|
45
|
+
@click="show = true"
|
|
46
|
+
/>
|
|
47
|
+
|
|
48
|
+
<!-- 日期弹出框 -->
|
|
49
|
+
<pi-date-picker
|
|
50
|
+
v-model="show"
|
|
51
|
+
:default-value="val"
|
|
52
|
+
:custom-class="getDatePicker.customClass"
|
|
53
|
+
:custom-style="getDatePicker.customStyle"
|
|
54
|
+
:start-year="getDatePicker.startYear"
|
|
55
|
+
:end-year="getDatePicker.endYear"
|
|
56
|
+
:field="getDatePicker.field"
|
|
57
|
+
:date-type="getDatePicker.dateType"
|
|
58
|
+
:format="dateFormat"
|
|
59
|
+
:item-height="getDatePicker.itemHeight"
|
|
60
|
+
:item-style="getDatePicker.itemStyle"
|
|
61
|
+
:show-item-bottom-border="getDatePicker.showItemBottomBorder"
|
|
62
|
+
:popup="getDatePicker.popup"
|
|
63
|
+
:popup-select="getDatePicker.popupSelect"
|
|
64
|
+
:confirm-btn="getDatePicker.confirmBtn"
|
|
65
|
+
:cancel-btn="getDatePicker.cancelBtn"
|
|
66
|
+
@confirm="handleDatePickerConfirm"
|
|
67
|
+
/>
|
|
68
|
+
</view>
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<script>
|
|
72
|
+
import ValueSync from '../../mixin/value-sync'
|
|
73
|
+
import { getConfig } from '../../config'
|
|
74
|
+
|
|
75
|
+
const TAG = 'PiDatePickerInput'
|
|
76
|
+
const { datePickerInput } = getConfig()
|
|
77
|
+
|
|
78
|
+
const PI_DEFAULT_FN_FLAG = 'PI_DEFAULT_FN_FLAG'
|
|
79
|
+
|
|
80
|
+
export default {
|
|
81
|
+
name: 'PiDatePickerInput',
|
|
82
|
+
// 混入v-model
|
|
83
|
+
mixins: [ValueSync],
|
|
84
|
+
props: {
|
|
85
|
+
// 初始值
|
|
86
|
+
value: {
|
|
87
|
+
required: false
|
|
88
|
+
},
|
|
89
|
+
// 自定义样式,对象形式
|
|
90
|
+
customStyle: {
|
|
91
|
+
type: Object,
|
|
92
|
+
// {}
|
|
93
|
+
default() {
|
|
94
|
+
return datePickerInput.customStyle
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
// 自定义样式类,字符串形式
|
|
98
|
+
customClass: {
|
|
99
|
+
type: String,
|
|
100
|
+
// ''
|
|
101
|
+
default() {
|
|
102
|
+
return datePickerInput.customClass
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
// input输入设置
|
|
106
|
+
input: {
|
|
107
|
+
type: Object,
|
|
108
|
+
default() {
|
|
109
|
+
// 参照datePicker
|
|
110
|
+
return datePickerInput.input
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
// 日期弹窗参数设置
|
|
114
|
+
datePicker: {
|
|
115
|
+
type: Object,
|
|
116
|
+
default() {
|
|
117
|
+
// 参照datePicker
|
|
118
|
+
return datePickerInput.datePicker
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
// 已选择的时间格式化显示规则,默认('YYYY-MM-DD')
|
|
122
|
+
dateFormat: {
|
|
123
|
+
type: String,
|
|
124
|
+
// 'YYYY-MM-DD'
|
|
125
|
+
default: datePickerInput.dateFormat
|
|
126
|
+
},
|
|
127
|
+
// 范围选择时间分隔符,默认('至')
|
|
128
|
+
rangeSplit: {
|
|
129
|
+
type: String,
|
|
130
|
+
// '至'
|
|
131
|
+
default: datePickerInput.rangeSplit
|
|
132
|
+
},
|
|
133
|
+
// 解析值的方法,如果配置了,则读取该函数的返回值作为显示的内容
|
|
134
|
+
parseValueFn: {
|
|
135
|
+
type: [Object, Function],
|
|
136
|
+
default() {
|
|
137
|
+
return {
|
|
138
|
+
[PI_DEFAULT_FN_FLAG]: true,
|
|
139
|
+
fn: datePickerInput.parseValueFn
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
data() {
|
|
145
|
+
return {
|
|
146
|
+
show: false
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
computed: {
|
|
150
|
+
getDatePicker() {
|
|
151
|
+
return this.$pi.lang.mergeDeep(datePickerInput.datePicker, this.datePicker)
|
|
152
|
+
},
|
|
153
|
+
getInputValue() {
|
|
154
|
+
const parseValueFn = this.parseValueFn[PI_DEFAULT_FN_FLAG]
|
|
155
|
+
? this.parseValueFn.fn
|
|
156
|
+
: this.parseValueFn
|
|
157
|
+
if (this.$pi.lang.isFunction(parseValueFn)) {
|
|
158
|
+
const parseValue = parseValueFn(this.val)
|
|
159
|
+
return parseValue
|
|
160
|
+
}
|
|
161
|
+
if (!this.dateFormat) {
|
|
162
|
+
console.warn('使用pi-datePicker-input组件,请设置.dateFormat,否则无法正常显示')
|
|
163
|
+
}
|
|
164
|
+
if (this.$pi.lang.isEmpty(this.val)) return ''
|
|
165
|
+
const date = this.$pi.date.parseDate(this.val)
|
|
166
|
+
return date.format(this.dateFormat)
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
methods: {
|
|
170
|
+
handlePopupClose() {
|
|
171
|
+
this.val = false
|
|
172
|
+
// 关闭
|
|
173
|
+
this.$emit('close')
|
|
174
|
+
this.handleEmitChange()
|
|
175
|
+
},
|
|
176
|
+
handleDatePickerConfirm(value) {
|
|
177
|
+
this.val = value
|
|
178
|
+
this.handleEmitChange()
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
</script>
|
|
183
|
+
|
|
184
|
+
<style lang="scss" scoped>
|
|
185
|
+
.pi-datePicker-input {
|
|
186
|
+
width: 100%;
|
|
187
|
+
}
|
|
188
|
+
</style>
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
:maxlength="maxlength"
|
|
15
15
|
:cursor-spacing="cursorSpacing"
|
|
16
16
|
:focus="focus"
|
|
17
|
-
:confirmType="confirmType"
|
|
18
17
|
:confirm-hold="confirmHold"
|
|
19
18
|
:cursor="cursor"
|
|
20
19
|
:selection-start="selectionStart"
|
|
@@ -48,7 +47,6 @@
|
|
|
48
47
|
:maxlength="maxlength"
|
|
49
48
|
:cursor-spacing="cursorSpacing"
|
|
50
49
|
:focus="focus"
|
|
51
|
-
:confirmType="confirmType"
|
|
52
50
|
:confirm-hold="confirmHold"
|
|
53
51
|
:cursor="cursor"
|
|
54
52
|
:selection-start="selectionStart"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
v-if="!['text', 'button'].includes(getShape)"
|
|
17
17
|
class="radio-icon"
|
|
18
18
|
:style="[radioStyle]"
|
|
19
|
-
@tap="handleRadioToggle(false)"
|
|
19
|
+
@tap.stop="handleRadioToggle(false)"
|
|
20
20
|
>
|
|
21
21
|
<view v-if="getShape === 'dot'" class="dot" />
|
|
22
22
|
<pi-icon v-else name="blod-check" :size="getIconSize" />
|
|
@@ -260,6 +260,8 @@ $unactive-color: #cccccc;
|
|
|
260
260
|
.pi-radio-wrap {
|
|
261
261
|
display: inline-flex;
|
|
262
262
|
align-items: center;
|
|
263
|
+
cursor: pointer;
|
|
264
|
+
|
|
263
265
|
.radio-icon {
|
|
264
266
|
position: relative;
|
|
265
267
|
display: inline-flex;
|