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