sadais-piui 1.2.6-beta6 → 1.2.6
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 +199 -0
- package/components/pi-calendar-panel/index.vue +5 -6
- package/components/pi-checkbox/index.vue +22 -3
- package/components/pi-checkbox-group/index.vue +8 -6
- package/components/pi-date-picker/index.vue +83 -86
- package/components/pi-date-picker-input/index.vue +188 -0
- package/components/pi-form-item/index.vue +5 -2
- package/components/pi-input/index.vue +36 -6
- package/components/pi-radio/index.vue +24 -5
- package/components/pi-radio-group/index.vue +16 -2
- 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/calendarInput.js +18 -0
- package/config/checkbox.js +2 -1
- package/config/checkboxGroup.js +2 -1
- package/config/datePicker.js +1 -0
- package/config/datePickerInput.js +17 -0
- package/config/input.js +10 -1
- package/config/radio.js +4 -3
- package/config/radioGroup.js +3 -2
- 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 -2
|
@@ -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>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<view
|
|
3
3
|
class="pi-form-item"
|
|
4
4
|
:style="[customStyle, itemStyle]"
|
|
5
|
-
:class="
|
|
5
|
+
:class="getFormItemClass"
|
|
6
6
|
@tap="handleItemClick"
|
|
7
7
|
>
|
|
8
8
|
<!-- 表单标题 -->
|
|
@@ -358,7 +358,7 @@ export default {
|
|
|
358
358
|
}
|
|
359
359
|
},
|
|
360
360
|
getFormItemClass() {
|
|
361
|
-
const classList = []
|
|
361
|
+
const classList = [this.customClass]
|
|
362
362
|
if (this.getDisabled) {
|
|
363
363
|
classList.push('disabled')
|
|
364
364
|
}
|
|
@@ -575,5 +575,8 @@ export default {
|
|
|
575
575
|
text-align: right;
|
|
576
576
|
}
|
|
577
577
|
}
|
|
578
|
+
::v-deep pi-calendar-input {
|
|
579
|
+
width: 100%;
|
|
580
|
+
}
|
|
578
581
|
}
|
|
579
582
|
</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"
|
|
@@ -63,6 +61,20 @@
|
|
|
63
61
|
@confirm="handleConfirm"
|
|
64
62
|
@keyboardheightchange="$emit('keyboardheightchange', $event)"
|
|
65
63
|
/>
|
|
64
|
+
<!-- 清空icon -->
|
|
65
|
+
<pi-icon
|
|
66
|
+
v-if="clearable && val"
|
|
67
|
+
:custom-style="clearIcon.customStyle"
|
|
68
|
+
:custom-class="`pi-pd-left-8 ${clearIcon.customClass}`"
|
|
69
|
+
:name="clearIcon.name"
|
|
70
|
+
:dot="clearIcon.dot"
|
|
71
|
+
:dot-radius="clearIcon.dotRadius"
|
|
72
|
+
:badge="clearIcon.badge"
|
|
73
|
+
:color="clearIcon.color"
|
|
74
|
+
:size="clearIcon.size"
|
|
75
|
+
:class-prefix="clearIcon.classPrefix"
|
|
76
|
+
@tap="handleChange('')"
|
|
77
|
+
/>
|
|
66
78
|
</view>
|
|
67
79
|
</template>
|
|
68
80
|
|
|
@@ -241,6 +253,19 @@ export default {
|
|
|
241
253
|
type: Boolean,
|
|
242
254
|
// false
|
|
243
255
|
default: input.disableDefaultPadding
|
|
256
|
+
},
|
|
257
|
+
// 是否可清空
|
|
258
|
+
clearable: {
|
|
259
|
+
type: Boolean,
|
|
260
|
+
// false
|
|
261
|
+
default: input.clearable
|
|
262
|
+
},
|
|
263
|
+
// 清空图标设置
|
|
264
|
+
clearIcon: {
|
|
265
|
+
type: Object,
|
|
266
|
+
default() {
|
|
267
|
+
return input.clearIcon
|
|
268
|
+
}
|
|
244
269
|
}
|
|
245
270
|
},
|
|
246
271
|
data() {
|
|
@@ -275,10 +300,7 @@ export default {
|
|
|
275
300
|
handleInput: debounce(function(e) {
|
|
276
301
|
let value = e.detail.value
|
|
277
302
|
// 输入内容
|
|
278
|
-
this.
|
|
279
|
-
this.handleEmitChange()
|
|
280
|
-
this.dispatch('PiForm', 'form-change', value)
|
|
281
|
-
this.dispatch('PiFormItem', 'form-change', value)
|
|
303
|
+
this.handleChange(value)
|
|
282
304
|
}, 50),
|
|
283
305
|
handleFocus() {
|
|
284
306
|
this.focused = true
|
|
@@ -302,6 +324,12 @@ export default {
|
|
|
302
324
|
handleConfirm(e) {
|
|
303
325
|
// 输入完成事件
|
|
304
326
|
this.$emit('confirm', e.detail.value)
|
|
327
|
+
},
|
|
328
|
+
handleChange(value) {
|
|
329
|
+
this.val = value
|
|
330
|
+
this.handleEmitChange()
|
|
331
|
+
this.dispatch('PiForm', 'form-change', value)
|
|
332
|
+
this.dispatch('PiFormItem', 'form-change', value)
|
|
305
333
|
}
|
|
306
334
|
}
|
|
307
335
|
}
|
|
@@ -310,6 +338,8 @@ export default {
|
|
|
310
338
|
<style lang="scss" scoped>
|
|
311
339
|
.pi-input-wrap {
|
|
312
340
|
width: 100%;
|
|
341
|
+
display: flex;
|
|
342
|
+
align-items: center;
|
|
313
343
|
.pi-input,
|
|
314
344
|
.pi-input-textarea {
|
|
315
345
|
width: 100%;
|
|
@@ -10,9 +10,14 @@
|
|
|
10
10
|
{ stretch: getStretch },
|
|
11
11
|
customClass
|
|
12
12
|
]"
|
|
13
|
-
@tap="handleRadioToggle"
|
|
13
|
+
@tap="handleRadioToggle(true)"
|
|
14
14
|
>
|
|
15
|
-
<view
|
|
15
|
+
<view
|
|
16
|
+
v-if="!['text', 'button'].includes(getShape)"
|
|
17
|
+
class="radio-icon"
|
|
18
|
+
:style="[radioStyle]"
|
|
19
|
+
@tap.stop="handleRadioToggle(false)"
|
|
20
|
+
>
|
|
16
21
|
<view v-if="getShape === 'dot'" class="dot" />
|
|
17
22
|
<pi-icon v-else name="blod-check" :size="getIconSize" />
|
|
18
23
|
</view>
|
|
@@ -133,6 +138,12 @@ export default {
|
|
|
133
138
|
type: Boolean,
|
|
134
139
|
// false
|
|
135
140
|
default: radio.canCancel
|
|
141
|
+
},
|
|
142
|
+
// 是否点击图标才能选中,默认点击整行都能选中
|
|
143
|
+
onlyIconSelect: {
|
|
144
|
+
type: [Boolean],
|
|
145
|
+
// null
|
|
146
|
+
default: radio.onlyIconSelect
|
|
136
147
|
}
|
|
137
148
|
},
|
|
138
149
|
data() {
|
|
@@ -150,8 +161,8 @@ export default {
|
|
|
150
161
|
return this.inheritProps.stretch
|
|
151
162
|
},
|
|
152
163
|
getBorderRadius() {
|
|
153
|
-
return this.
|
|
154
|
-
? this.$pi.common.addUnit(this.
|
|
164
|
+
return this.inheritProps.borderRadius
|
|
165
|
+
? this.$pi.common.addUnit(this.inheritProps.borderRadius)
|
|
155
166
|
: this.$pi.common.addUnit(this.borderRadius)
|
|
156
167
|
},
|
|
157
168
|
getBorder() {
|
|
@@ -181,6 +192,11 @@ export default {
|
|
|
181
192
|
getCanCancel() {
|
|
182
193
|
return this.inheritProps.canCancel !== null ? this.inheritProps.canCancel : this.canCancel
|
|
183
194
|
},
|
|
195
|
+
getOnlyIconSelect() {
|
|
196
|
+
return this.inheritProps.onlyIconSelect !== null
|
|
197
|
+
? this.inheritProps.onlyIconSelect
|
|
198
|
+
: this.onlyIconSelect
|
|
199
|
+
},
|
|
184
200
|
radioStyle() {
|
|
185
201
|
const style = {
|
|
186
202
|
width: this.getSize,
|
|
@@ -227,7 +243,8 @@ export default {
|
|
|
227
243
|
}
|
|
228
244
|
},
|
|
229
245
|
methods: {
|
|
230
|
-
handleRadioToggle() {
|
|
246
|
+
handleRadioToggle(isTapRow) {
|
|
247
|
+
if (this.getOnlyIconSelect && isTapRow) return
|
|
231
248
|
if (this.getDisable) return
|
|
232
249
|
if (this.readonly) return
|
|
233
250
|
this._parent && this._parent.emitChange(this.name)
|
|
@@ -243,6 +260,8 @@ $unactive-color: #cccccc;
|
|
|
243
260
|
.pi-radio-wrap {
|
|
244
261
|
display: inline-flex;
|
|
245
262
|
align-items: center;
|
|
263
|
+
cursor: pointer;
|
|
264
|
+
|
|
246
265
|
.radio-icon {
|
|
247
266
|
position: relative;
|
|
248
267
|
display: inline-flex;
|
|
@@ -31,6 +31,7 @@ export default {
|
|
|
31
31
|
parentInit([
|
|
32
32
|
'val',
|
|
33
33
|
'shape',
|
|
34
|
+
'borderRadius',
|
|
34
35
|
'stretch',
|
|
35
36
|
'border',
|
|
36
37
|
'disabled',
|
|
@@ -38,7 +39,8 @@ export default {
|
|
|
38
39
|
'iconSize',
|
|
39
40
|
'activeColor',
|
|
40
41
|
'activeMode',
|
|
41
|
-
'canCancel'
|
|
42
|
+
'canCancel',
|
|
43
|
+
'onlyIconSelect'
|
|
42
44
|
])
|
|
43
45
|
], // 注入value与val,进行双向绑定
|
|
44
46
|
options: {
|
|
@@ -91,6 +93,12 @@ export default {
|
|
|
91
93
|
return ['', 'square', 'round', 'dot', 'text', 'button'].includes(value)
|
|
92
94
|
}
|
|
93
95
|
},
|
|
96
|
+
// 当shape为square的时候,设置圆角,值为数字时,单位默认rpx
|
|
97
|
+
borderRadius: {
|
|
98
|
+
type: [null, String, Number],
|
|
99
|
+
// 8
|
|
100
|
+
default: radioGroup.borderRadius
|
|
101
|
+
},
|
|
94
102
|
// 当shape为button的时候,选项否均分布局,可选值 `true`
|
|
95
103
|
stretch: {
|
|
96
104
|
type: Boolean,
|
|
@@ -141,9 +149,15 @@ export default {
|
|
|
141
149
|
},
|
|
142
150
|
// 能否取消选中状态
|
|
143
151
|
canCancel: {
|
|
144
|
-
type: Boolean,
|
|
152
|
+
type: [Boolean, null],
|
|
145
153
|
// null
|
|
146
154
|
default: radioGroup.canCancel
|
|
155
|
+
},
|
|
156
|
+
// 是否点击图标才能选中,默认点击整行都能选中
|
|
157
|
+
onlyIconSelect: {
|
|
158
|
+
type: [Boolean, null],
|
|
159
|
+
// null
|
|
160
|
+
default: radioGroup.onlyIconSelect
|
|
147
161
|
}
|
|
148
162
|
},
|
|
149
163
|
methods: {
|