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,317 +1,332 @@
|
|
|
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
|
-
<slot name="header" />
|
|
21
|
-
<picker-view
|
|
22
|
-
v-if="val"
|
|
23
|
-
class="pi-text-center pi-h-100P"
|
|
24
|
-
:style="[customStyle]"
|
|
25
|
-
:class="[customClass]"
|
|
26
|
-
:indicator-style="indicatorStyle"
|
|
27
|
-
:value="pickerValue"
|
|
28
|
-
@pickstart="handlePickstart"
|
|
29
|
-
@pickend="handlePickend"
|
|
30
|
-
@change="handlePickerChange"
|
|
31
|
-
>
|
|
32
|
-
<picker-view-column v-for="(column, index) in columns" :key="index">
|
|
33
|
-
<view
|
|
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
|
-
|
|
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
|
-
const
|
|
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
|
-
return this.items
|
|
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
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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
|
+
<slot name="header" />
|
|
21
|
+
<picker-view
|
|
22
|
+
v-if="val"
|
|
23
|
+
class="pi-text-center pi-h-100P"
|
|
24
|
+
:style="[customStyle]"
|
|
25
|
+
:class="[customClass]"
|
|
26
|
+
:indicator-style="indicatorStyle"
|
|
27
|
+
:value="pickerValue"
|
|
28
|
+
@pickstart="handlePickstart"
|
|
29
|
+
@pickend="handlePickend"
|
|
30
|
+
@change="handlePickerChange"
|
|
31
|
+
>
|
|
32
|
+
<picker-view-column v-for="(column, index) in columns" :key="index">
|
|
33
|
+
<view
|
|
34
|
+
v-for="item in column"
|
|
35
|
+
:key="item[keyField]"
|
|
36
|
+
:style="indicatorStyle"
|
|
37
|
+
>
|
|
38
|
+
{{ item[displayField] }}
|
|
39
|
+
</view>
|
|
40
|
+
</picker-view-column>
|
|
41
|
+
</picker-view>
|
|
42
|
+
<slot name="footer" />
|
|
43
|
+
</pi-popup-select>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<script>
|
|
47
|
+
import ValueSync from '../../mixin/value-sync'
|
|
48
|
+
import { getConfig } from '../../config'
|
|
49
|
+
|
|
50
|
+
const TAG = 'PiPicker'
|
|
51
|
+
const { picker } = getConfig()
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 注意: default-value数组的长度,必须与列数相同,否则无效。
|
|
55
|
+
* 单列模式 如设置default-value为[1]表示默认选中第2个(从0开始),[5]表示选中第6个。
|
|
56
|
+
* 多列模式 如设置default-value为[1, 3]表示第一列默认选中第2个,第二列默认选中第4个。
|
|
57
|
+
*/
|
|
58
|
+
export default {
|
|
59
|
+
name: 'PiPicker',
|
|
60
|
+
// 混入v-model
|
|
61
|
+
mixins: [ValueSync],
|
|
62
|
+
props: {
|
|
63
|
+
// 初始值
|
|
64
|
+
value: {
|
|
65
|
+
required: false
|
|
66
|
+
},
|
|
67
|
+
// 自定义样式
|
|
68
|
+
customStyle: {
|
|
69
|
+
type: Object,
|
|
70
|
+
// {}
|
|
71
|
+
default() {
|
|
72
|
+
return picker.customStyle
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
// 自定义样式类
|
|
76
|
+
customClass: {
|
|
77
|
+
type: String,
|
|
78
|
+
// ''
|
|
79
|
+
default() {
|
|
80
|
+
return picker.customClass
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
// 选项列表
|
|
84
|
+
items: {
|
|
85
|
+
type: Array,
|
|
86
|
+
// []
|
|
87
|
+
default() {
|
|
88
|
+
return picker.items
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
// 选项id字段
|
|
92
|
+
keyField: {
|
|
93
|
+
type: String,
|
|
94
|
+
// 'id'
|
|
95
|
+
default: picker.keyField
|
|
96
|
+
},
|
|
97
|
+
// 选项显示字段
|
|
98
|
+
displayField: {
|
|
99
|
+
type: String,
|
|
100
|
+
// 'text'
|
|
101
|
+
default: picker.displayField
|
|
102
|
+
},
|
|
103
|
+
// 自定义多列联动模式的children属性名
|
|
104
|
+
childField: {
|
|
105
|
+
type: String,
|
|
106
|
+
// 'children'
|
|
107
|
+
default: picker.childField
|
|
108
|
+
},
|
|
109
|
+
// 默认值,单选是传Object,多选时传Array
|
|
110
|
+
defaultValue: {
|
|
111
|
+
type: Array,
|
|
112
|
+
// null
|
|
113
|
+
default: picker.defaultValue
|
|
114
|
+
},
|
|
115
|
+
// 选择器类型
|
|
116
|
+
type: {
|
|
117
|
+
// 'single', 'multi', 'multi-auto'
|
|
118
|
+
type: String,
|
|
119
|
+
// 'single'
|
|
120
|
+
default: picker.type,
|
|
121
|
+
validator: function(value) {
|
|
122
|
+
return ['single', 'multi', 'multi-auto'].includes(value)
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
// 行高 单位默认rpx
|
|
126
|
+
itemHeight: {
|
|
127
|
+
type: [String, Number],
|
|
128
|
+
// 110
|
|
129
|
+
default: picker.itemHeight
|
|
130
|
+
},
|
|
131
|
+
// 是否显示item下边框
|
|
132
|
+
showItemBottomBorder: {
|
|
133
|
+
type: Boolean,
|
|
134
|
+
// true
|
|
135
|
+
default: picker.showItemBottomBorder
|
|
136
|
+
},
|
|
137
|
+
// 行样式
|
|
138
|
+
itemStyle: {
|
|
139
|
+
type: Object,
|
|
140
|
+
// {}
|
|
141
|
+
default() {
|
|
142
|
+
return picker.itemStyle
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
// 弹窗选择参数设置
|
|
146
|
+
popupSelect: {
|
|
147
|
+
type: Object,
|
|
148
|
+
default() {
|
|
149
|
+
// 参照popup
|
|
150
|
+
return picker.popupSelect
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
// 确认按钮配置
|
|
154
|
+
confirmBtn: {
|
|
155
|
+
type: Object,
|
|
156
|
+
default() {
|
|
157
|
+
return picker.confirmBtn
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
// 取消按钮配置
|
|
161
|
+
cancelBtn: {
|
|
162
|
+
type: Object,
|
|
163
|
+
default() {
|
|
164
|
+
return picker.cancelBtn
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
// 弹窗参数设置
|
|
168
|
+
popup: {
|
|
169
|
+
type: Object,
|
|
170
|
+
default() {
|
|
171
|
+
// 参照popup
|
|
172
|
+
return picker.popup
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
data() {
|
|
177
|
+
return {
|
|
178
|
+
pickerValue: [],
|
|
179
|
+
scrolling: false // picker是否在滚动中,小程序在scrolling中点确定,选择的项目不正确
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
computed: {
|
|
183
|
+
getPopupSelect() {
|
|
184
|
+
return this.$pi.lang.mergeDeep(picker.popupSelect, this.popupSelect)
|
|
185
|
+
},
|
|
186
|
+
getConfirmBtn() {
|
|
187
|
+
const pickerConfirmBtn = this.$pi.lang.mergeDeep(
|
|
188
|
+
picker.confirmBtn,
|
|
189
|
+
this.popupSelect.confirmBtn
|
|
190
|
+
)
|
|
191
|
+
const mergeConfirmBtn = this.$pi.lang.mergeDeep(
|
|
192
|
+
pickerConfirmBtn,
|
|
193
|
+
this.confirmBtn
|
|
194
|
+
)
|
|
195
|
+
if (!mergeConfirmBtn.disabled) {
|
|
196
|
+
mergeConfirmBtn.disabled = this.scrolling
|
|
197
|
+
}
|
|
198
|
+
return mergeConfirmBtn
|
|
199
|
+
},
|
|
200
|
+
getCancelBtn() {
|
|
201
|
+
const pickerCancelBtn = this.$pi.lang.mergeDeep(
|
|
202
|
+
picker.cancelBtn,
|
|
203
|
+
this.popupSelect.cancelBtn
|
|
204
|
+
)
|
|
205
|
+
return this.$pi.lang.mergeDeep(pickerCancelBtn, this.cancelBtn)
|
|
206
|
+
},
|
|
207
|
+
getPopup() {
|
|
208
|
+
const pickerPopup = this.$pi.lang.mergeDeep(
|
|
209
|
+
picker.popup,
|
|
210
|
+
this.popupSelect.popup
|
|
211
|
+
)
|
|
212
|
+
return this.$pi.lang.mergeDeep(pickerPopup, this.popup)
|
|
213
|
+
},
|
|
214
|
+
getItemStyle() {
|
|
215
|
+
const itemHeight = this.$pi.common.addUnit(this.itemHeight)
|
|
216
|
+
return {
|
|
217
|
+
height: itemHeight,
|
|
218
|
+
lineHeight: itemHeight
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
indicatorStyle() {
|
|
222
|
+
const itemHeight = uni.upx2px(this.itemHeight)
|
|
223
|
+
return `height: ${itemHeight}px;line-height: ${itemHeight}px;`
|
|
224
|
+
},
|
|
225
|
+
columns() {
|
|
226
|
+
if (this.type === 'single') return [this.items]
|
|
227
|
+
if (this.type === 'multi') return this.items
|
|
228
|
+
if (this.type === 'multi-auto') {
|
|
229
|
+
let columns = this.items
|
|
230
|
+
return this.pickerValue.map((value, index) => {
|
|
231
|
+
const returnValue = [...columns]
|
|
232
|
+
const column = columns[value]
|
|
233
|
+
if (column[this.childField] && column[this.childField].length) {
|
|
234
|
+
columns = column[this.childField]
|
|
235
|
+
}
|
|
236
|
+
return returnValue
|
|
237
|
+
})
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return this.items
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
watch: {
|
|
244
|
+
value: {
|
|
245
|
+
deep: true,
|
|
246
|
+
immediate: true,
|
|
247
|
+
handler(value) {
|
|
248
|
+
// 每次弹窗显示,进行数据初始化
|
|
249
|
+
value && this.init()
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
methods: {
|
|
254
|
+
init() {
|
|
255
|
+
if (this.defaultValue) {
|
|
256
|
+
this.pickerValue = this.defaultValue
|
|
257
|
+
} else {
|
|
258
|
+
if (this.type === 'single') this.pickerValue = [0]
|
|
259
|
+
if (this.type === 'multi') return (this.pickerValue = [0, 0])
|
|
260
|
+
if (this.type === 'multi-auto') {
|
|
261
|
+
let count = 1
|
|
262
|
+
let column = this.items
|
|
263
|
+
// 只要有元素并且第一个元素有children属性,继续历遍
|
|
264
|
+
while (column[0][this.childField]) {
|
|
265
|
+
column = column[0] ? column[0][this.childField] : {}
|
|
266
|
+
count++
|
|
267
|
+
}
|
|
268
|
+
this.pickerValue = new Array(count).fill(0)
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
handlePickstart() {
|
|
273
|
+
this.scrolling = true
|
|
274
|
+
},
|
|
275
|
+
// 标识滑动结束
|
|
276
|
+
handlePickend() {
|
|
277
|
+
this.scrolling = false
|
|
278
|
+
},
|
|
279
|
+
handlePopupClose() {
|
|
280
|
+
this.val = false
|
|
281
|
+
// 弹窗关闭
|
|
282
|
+
this.$emit('close')
|
|
283
|
+
this.handleEmitChange()
|
|
284
|
+
},
|
|
285
|
+
handlePickerChange(e) {
|
|
286
|
+
let pickerValue = e.detail.value
|
|
287
|
+
|
|
288
|
+
if (this.type === 'multi-auto') {
|
|
289
|
+
// 如果是多列联动,pickerValue的值需要重新生成
|
|
290
|
+
// 第几列发生变化
|
|
291
|
+
let columnIndex = this.pickerValue.findIndex(
|
|
292
|
+
(p, i) => pickerValue[i] !== p
|
|
293
|
+
)
|
|
294
|
+
pickerValue = pickerValue.slice(0, columnIndex + 1)
|
|
295
|
+
let columnValue = pickerValue[columnIndex]
|
|
296
|
+
let columns = this.columns[columnIndex]
|
|
297
|
+
let column = columns[columnValue]
|
|
298
|
+
while (column[this.childField]) {
|
|
299
|
+
columns = column[this.childField]
|
|
300
|
+
column = columns[0]
|
|
301
|
+
columnIndex++
|
|
302
|
+
pickerValue[columnIndex] = 0
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
this.pickerValue = pickerValue
|
|
306
|
+
},
|
|
307
|
+
/**
|
|
308
|
+
* @vuese
|
|
309
|
+
* 取消选择
|
|
310
|
+
*/
|
|
311
|
+
handleCancel() {
|
|
312
|
+
this.$emit('cancel')
|
|
313
|
+
this.onCancelClose && this.handlePopupClose()
|
|
314
|
+
},
|
|
315
|
+
/**
|
|
316
|
+
* @vuese
|
|
317
|
+
* 确认选择
|
|
318
|
+
*/
|
|
319
|
+
handleConfirm() {
|
|
320
|
+
if (this.scrolling) return
|
|
321
|
+
this.$emit('confirm', this.pickerValue)
|
|
322
|
+
this.onConfirmClose && this.handlePopupClose()
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
</script>
|
|
327
|
+
|
|
328
|
+
<style lang="scss" scoped>
|
|
329
|
+
.pi-picker {
|
|
330
|
+
height: 50vh;
|
|
331
|
+
}
|
|
332
|
+
</style>
|