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
@@ -7,7 +7,6 @@
7
7
  <view
8
8
  v-if="showAdd"
9
9
  class="pi-stepper-icon pi-icon-subtract"
10
- :class="[{ disabled: disableSubtract }]"
11
10
  hover-class="pi-hover-class"
12
11
  :hover-start-time="10"
13
12
  :hover-stay-time="100"
@@ -15,17 +14,16 @@
15
14
  @tap="handleChange(-1)"
16
15
  />
17
16
  <input
18
- :value="value"
17
+ v-model="val"
19
18
  type="digit"
20
19
  class="step-input"
21
20
  :disabled="disabled || disableInput"
22
21
  :style="[inputStyle, { width: getInputWidth }]"
23
- @input="handleInputChange"
22
+ @blur="handleOnBlur"
24
23
  />
25
24
  <view
26
25
  v-if="showSubtract"
27
26
  class="pi-stepper-icon pi-icon-add"
28
- :class="[{ disabled: disableAdd }]"
29
27
  hover-class="pi-hover-class"
30
28
  :hover-start-time="10"
31
29
  :hover-stay-time="100"
@@ -36,100 +34,100 @@
36
34
  </template>
37
35
 
38
36
  <script>
39
- import ValueSync from '../../mixin/value-sync'
40
- import { getConfig } from '../../config'
41
- const { stepper } = getConfig()
37
+ import ValueSync from "../../mixin/value-sync";
38
+ import { getConfig } from "../../config";
39
+ const { stepper } = getConfig();
42
40
 
43
- const TAG = 'PiStepper'
41
+ const TAG = "PiStepper";
44
42
 
45
43
  export default {
46
- name: 'PiStepper',
44
+ name: TAG,
47
45
  // 混入v-model
48
46
  mixins: [ValueSync],
49
47
  props: {
50
48
  // 初始值
51
49
  value: {
52
- required: false
50
+ required: false,
53
51
  },
54
52
  // 自定义样式,对象形式
55
53
  customStyle: {
56
54
  type: Object,
57
55
  // {}
58
56
  default() {
59
- return stepper.customStyle
60
- }
57
+ return stepper.customStyle;
58
+ },
61
59
  },
62
60
  // 自定义输入样式,对象形式(默认值:{})
63
61
  inputStyle: {
64
62
  type: Object,
65
63
  // {}
66
64
  default() {
67
- return stepper.inputStyle
68
- }
65
+ return stepper.inputStyle;
66
+ },
69
67
  },
70
68
  // 自定义样式类,字符串形式
71
69
  customClass: {
72
70
  type: String,
73
71
  // ''
74
72
  default() {
75
- return stepper.customClass
76
- }
73
+ return stepper.customClass;
74
+ },
77
75
  },
78
76
  // 最小值
79
77
  min: {
80
78
  type: Number,
81
79
  // 1
82
80
  default() {
83
- return stepper.min
84
- }
81
+ return stepper.min;
82
+ },
85
83
  },
86
84
  // 最大值
87
85
  max: {
88
86
  type: Number,
89
87
  // -
90
88
  default() {
91
- return stepper.max
92
- }
89
+ return stepper.max;
90
+ },
93
91
  },
94
92
  // 步长,每次点击时改变的值
95
93
  step: {
96
94
  type: Number,
97
95
  // 1
98
96
  default() {
99
- return stepper.step
100
- }
97
+ return stepper.step;
98
+ },
101
99
  },
102
100
  // 输入框宽度,默认单位为rpx
103
101
  inputWidth: {
104
102
  type: [String, Number],
105
103
  // 64
106
104
  default() {
107
- return stepper.inputWidth
108
- }
105
+ return stepper.inputWidth;
106
+ },
109
107
  },
110
108
  // 按钮大小
111
109
  buttonSize: {
112
110
  type: [String, Number],
113
111
  // 32
114
112
  default() {
115
- return stepper.buttonSize
116
- }
113
+ return stepper.buttonSize;
114
+ },
117
115
  },
118
116
  // 按钮颜色
119
117
  buttonColor: {
120
118
  type: [String, Number],
121
119
  // -
122
120
  default() {
123
- return stepper.buttonColor
124
- }
121
+ return stepper.buttonColor;
122
+ },
125
123
  },
126
124
  // 小数位
127
125
  decimal: {
128
126
  type: Number,
129
127
  // 0
130
128
  default() {
131
- return stepper.decimal
132
- }
129
+ return stepper.decimal;
130
+ },
133
131
  },
134
132
  // 形状
135
133
  shape: {
@@ -137,9 +135,9 @@ export default {
137
135
  type: String,
138
136
  // round
139
137
  default: stepper.shape,
140
- validator: function(value) {
141
- return ['square', 'round'].includes(value)
142
- }
138
+ validator: function (value) {
139
+ return ["square", "round"].includes(value);
140
+ },
143
141
  },
144
142
  // 主题模式
145
143
  theme: {
@@ -147,201 +145,217 @@ export default {
147
145
  type: String,
148
146
  // 'line'
149
147
  default: stepper.theme,
150
- validator: function(value) {
151
- return ['line', 'fill'].includes(value)
152
- }
148
+ validator: function (value) {
149
+ return ["line", "fill"].includes(value);
150
+ },
153
151
  },
154
152
  // 是否只允许输入整数
155
153
  integer: {
156
154
  type: Boolean,
157
155
  // false
158
156
  default() {
159
- return stepper.integer
160
- }
157
+ return stepper.integer;
158
+ },
161
159
  },
162
160
  // 是否显示增加按钮
163
161
  showAdd: {
164
162
  type: Boolean,
165
163
  // true
166
164
  default() {
167
- return stepper.showAdd
168
- }
165
+ return stepper.showAdd;
166
+ },
169
167
  },
170
168
  // 是否显示减少按钮
171
169
  showSubtract: {
172
170
  type: Boolean,
173
171
  // false
174
172
  default() {
175
- return stepper.showSubtract
176
- }
173
+ return stepper.showSubtract;
174
+ },
177
175
  },
178
176
  // 是否禁用步进器
179
177
  disabled: {
180
178
  type: Boolean,
181
179
  // false
182
180
  default() {
183
- return stepper.disabled
184
- }
181
+ return stepper.disabled;
182
+ },
185
183
  },
186
184
  // 是否禁用输入框
187
185
  disableInput: {
188
186
  type: Boolean,
189
187
  // true
190
188
  default() {
191
- return stepper.disableInput
192
- }
193
- }
189
+ return stepper.disableInput;
190
+ },
191
+ },
194
192
  },
195
193
  data() {
196
- return {}
194
+ return {
195
+ oldVal: 0,
196
+ };
197
197
  },
198
198
  computed: {
199
199
  disableAdd() {
200
- return this.max !== null && this.val >= this.max
200
+ return this.max !== null && this.val >= this.max;
201
201
  },
202
202
  disableSubtract() {
203
- return this.min !== null && this.val <= this.min
203
+ return this.min !== null && this.val <= this.min;
204
204
  },
205
205
  getInputWidth() {
206
- return this.$pi.common.addUnit(this.inputWidth)
206
+ return this.$pi.common.addUnit(this.inputWidth);
207
207
  },
208
208
  getButtonSize() {
209
- return this.$pi.common.addUnit(this.buttonSize)
209
+ return this.$pi.common.addUnit(this.buttonSize);
210
210
  },
211
211
  iconStyle() {
212
212
  const style = {
213
213
  width: this.getButtonSize,
214
214
  height: this.getButtonSize,
215
215
  lineHeight: this.getButtonSize,
216
- fontSize: this.getButtonSize
217
- }
216
+ fontSize: this.getButtonSize,
217
+ };
218
218
  if (this.buttonColor) {
219
- if (this.theme === 'line') {
220
- style.color = this.buttonColor
221
- style.borderColor = this.buttonColor
219
+ if (this.theme === "line") {
220
+ style.color = this.buttonColor;
221
+ style.borderColor = this.buttonColor;
222
222
  } else {
223
- style.backgroundColor = this.buttonColor
223
+ style.backgroundColor = this.buttonColor;
224
224
  }
225
225
  }
226
- return style
227
- }
226
+ return style;
227
+ },
228
228
  },
229
229
  methods: {
230
230
  // 点击减少按钮时触发
231
231
  minus() {
232
- this.computeVal('minus')
232
+ this.computeVal("minus");
233
233
  },
234
234
  // 点击增加按钮时触发
235
235
  plus() {
236
- this.computeVal('plus')
236
+ this.computeVal("plus");
237
237
  },
238
238
  // 为了保证小数相加出现精度溢出的问题
239
239
  numAdd(num1, num2) {
240
- let baseNum, baseNum1, baseNum2
240
+ let baseNum, baseNum1, baseNum2;
241
241
  try {
242
- baseNum1 = num1.toString().split('.')[1].length
242
+ baseNum1 = num1.toString().split(".")[1].length;
243
243
  } catch (e) {
244
- baseNum1 = 0
244
+ baseNum1 = 0;
245
245
  }
246
246
  try {
247
- baseNum2 = num2.toString().split('.')[1].length
247
+ baseNum2 = num2.toString().split(".")[1].length;
248
248
  } catch (e) {
249
- baseNum2 = 0
249
+ baseNum2 = 0;
250
250
  }
251
- baseNum = Math.pow(10, Math.max(baseNum1, baseNum2))
252
- let precision = baseNum1 >= baseNum2 ? baseNum1 : baseNum2 // 精度
253
- return ((num1 * baseNum + num2 * baseNum) / baseNum).toFixed(precision)
251
+ baseNum = Math.pow(10, Math.max(baseNum1, baseNum2));
252
+ let precision = baseNum1 >= baseNum2 ? baseNum1 : baseNum2; // 精度
253
+ return ((num1 * baseNum + num2 * baseNum) / baseNum).toFixed(precision);
254
254
  },
255
255
  // 为了保证小数相减出现精度溢出的问题
256
256
  numSub(num1, num2) {
257
- let baseNum, baseNum1, baseNum2
257
+ let baseNum, baseNum1, baseNum2;
258
258
  try {
259
- baseNum1 = num1.toString().split('.')[1].length
259
+ baseNum1 = num1.toString().split(".")[1].length;
260
260
  } catch (e) {
261
- baseNum1 = 0
261
+ baseNum1 = 0;
262
262
  }
263
263
  try {
264
- baseNum2 = num2.toString().split('.')[1].length
264
+ baseNum2 = num2.toString().split(".")[1].length;
265
265
  } catch (e) {
266
- baseNum2 = 0
266
+ baseNum2 = 0;
267
267
  }
268
- baseNum = Math.pow(10, Math.max(baseNum1, baseNum2))
269
- let precision = baseNum1 >= baseNum2 ? baseNum1 : baseNum2
270
- return ((num1 * baseNum - num2 * baseNum) / baseNum).toFixed(precision)
268
+ baseNum = Math.pow(10, Math.max(baseNum1, baseNum2));
269
+ let precision = baseNum1 >= baseNum2 ? baseNum1 : baseNum2;
270
+ return ((num1 * baseNum - num2 * baseNum) / baseNum).toFixed(precision);
271
271
  },
272
272
  computeVal(type) {
273
- if (this.disabled) return
274
- let value = 0
273
+ if (this.disabled) return;
274
+ let value = 0;
275
275
  // 减
276
- if (type === 'minus') {
276
+ if (type === "minus") {
277
277
  // this.value 当前值 this.step 增加步长后的值
278
- value = this.numSub(this.value, this.step)
279
- } else if (type === 'plus') {
280
- value = this.numAdd(this.value, this.step)
278
+ value = this.numSub(this.value, this.step);
279
+ } else if (type === "plus") {
280
+ value = this.numAdd(this.value, this.step);
281
281
  }
282
282
  // 判断是否小于最小值和大于最大值
283
283
  if (value < this.min || value > this.max) {
284
- return
284
+ return;
285
285
  }
286
286
  // this.inputVal = value
287
287
  },
288
288
  handleChange(range) {
289
- if (this.disabled) return
289
+ if (this.disabled) return;
290
290
  // 增加/减少步长后的值
291
291
  // let val = this.val + range * this.step
292
- let val = range === 1 ? this.numAdd(this.val, this.step) : this.numSub(this.val, this.step)
292
+ let val =
293
+ range === 1
294
+ ? this.numAdd(this.val, this.step)
295
+ : this.numSub(this.val, this.step);
293
296
  if (this.max !== null && val > this.max) {
294
- val = this.max
297
+ val = this.max;
295
298
  }
296
299
  if (this.min !== null && val < this.min) {
297
- val = this.min
300
+ val = this.min;
298
301
  }
299
- this.handleInputChange({ detail: { value: `${val}` } })
302
+ this.handleInputChange({ detail: { value: `${val}` } });
303
+ },
304
+ handleOnBlur() {
305
+ this.handleInputChange({ detail: { value: `${this.val}` } });
300
306
  },
301
307
  handleInputChange(e) {
302
- const val = e.detail.value
303
- const reg = /^(\d+)(\.)?(?:(.+)$)?/
304
- const result = val.match(reg)
305
- const decimal = this.decimal
306
- if (!result) {
308
+ let val = e.detail.value;
309
+ const reg = /^-?\d*\.?\d+$/;
310
+ const decimal = this.decimal;
311
+ if (!val || !reg.test(val)) {
307
312
  // 说明开头就不是数字 直接初始化为0
308
- this.val = this.min != null ? this.min : 0
309
- this.handleEmitChange()
313
+ this.val = 0;
314
+ this.$nextTick(() => {
315
+ if (Number.isNaN(Number(val))) {
316
+ this.val = this.oldVal != null ? this.oldVal : 0;
317
+ } else {
318
+ this.val = Number(val);
319
+ }
320
+ this.oldVal = Number(this.val);
321
+ this.handleEmitChange();
322
+ });
310
323
  } else {
324
+ const result = val.split(".");
325
+ const dot = ".";
311
326
  // 分离出 小数点、及其左右2边的数字
312
- const left = result[1]
313
- const dot = result[2]
314
- const right = result[3]
315
- let tmpVal = ''
327
+ const left = result?.[0] || "";
328
+ // const dot = result[2]
329
+ const right = result?.[1] || "";
330
+ let tmpVal = "";
331
+
316
332
  if (!dot || !right) {
317
- tmpVal = dot ? `${left}${dot}` : left
333
+ tmpVal = dot ? `${left}${dot}` : left;
318
334
  } else if (/^\d+/.test(right)) {
319
335
  // 限制小数点位数
320
- const digit = right.match(/^\d+/)[0]
321
- const len = Math.min(digit.length, decimal)
322
- tmpVal = `${left}${dot}${digit.substr(0, len)}`
336
+ const digit = right.match(/^\d+/)[0];
337
+ const len = Math.min(digit.length, decimal);
338
+ tmpVal = `${left}${dot}${digit.substr(0, len)}`;
323
339
  } else {
324
340
  // 若小数点右边不是以数字开头
325
- tmpVal = `${left}${dot}`
341
+ tmpVal = `${left}${dot}`;
326
342
  }
327
- // target.value = tmpVal
328
- console.log(`tmpVal = ${tmpVal}`)
329
- this.val = 0
330
- this.handleEmitChange()
343
+ // this.val = 0
331
344
  this.$nextTick(() => {
332
- let tmp = parseFloat(tmpVal)
345
+ let tmp = parseFloat(tmpVal);
333
346
  if (this.integer) {
334
- tmp = parseInt(tmpVal)
347
+ tmp = parseInt(tmpVal);
335
348
  }
336
- tmp = tmp <= this.max ? tmp : this.max
337
- tmp = tmp >= this.min ? tmp : this.min
338
- this.val = tmp
339
- this.handleEmitChange()
340
- })
349
+ tmp = tmp <= this.max ? tmp : this.max;
350
+ tmp = tmp >= this.min ? tmp : this.min;
351
+ this.val = tmp;
352
+ this.oldVal = Number(this.val);
353
+ this.handleEmitChange();
354
+ });
341
355
  }
342
- }
343
- }
344
- }
356
+ },
357
+ },
358
+ };
345
359
  </script>
346
360
 
347
361
  <style lang="scss" scoped>
@@ -359,7 +373,7 @@ export default {
359
373
  transform: scale(0.8);
360
374
  }
361
375
  &::after {
362
- content: '';
376
+ content: "";
363
377
  }
364
378
  &.disabled {
365
379
  opacity: $pi-disabled-opacity;