sadais-piui 1.2.7-beta95 → 1.2.7-beta96

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.
@@ -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="val"
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"
@@ -193,7 +191,9 @@ export default {
193
191
  },
194
192
  },
195
193
  data() {
196
- return {};
194
+ return {
195
+ oldVal: 0,
196
+ };
197
197
  },
198
198
  computed: {
199
199
  disableAdd() {
@@ -301,14 +301,25 @@ export default {
301
301
  }
302
302
  this.handleInputChange({ detail: { value: `${val}` } });
303
303
  },
304
+ handleOnBlur() {
305
+ this.handleInputChange({ detail: { value: `${this.val}` } });
306
+ },
304
307
  handleInputChange(e) {
305
308
  let val = e.detail.value;
306
309
  const reg = /^-?\d*\.?\d+$/;
307
310
  const decimal = this.decimal;
308
- if (!reg.test(val)) {
311
+ if (!val || !reg.test(val)) {
309
312
  // 说明开头就不是数字 直接初始化为0
310
- this.val = this.min != null ? this.min : 0;
311
- 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
+ });
312
323
  } else {
313
324
  const result = val.split(".");
314
325
  const dot = ".";
@@ -329,7 +340,7 @@ export default {
329
340
  // 若小数点右边不是以数字开头
330
341
  tmpVal = `${left}${dot}`;
331
342
  }
332
- this.val = 0;
343
+ // this.val = 0
333
344
  this.$nextTick(() => {
334
345
  let tmp = parseFloat(tmpVal);
335
346
  if (this.integer) {
@@ -338,6 +349,7 @@ export default {
338
349
  tmp = tmp <= this.max ? tmp : this.max;
339
350
  tmp = tmp >= this.min ? tmp : this.min;
340
351
  this.val = tmp;
352
+ this.oldVal = Number(this.val);
341
353
  this.handleEmitChange();
342
354
  });
343
355
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sadais-piui",
3
- "version": "1.2.7-beta95",
3
+ "version": "1.2.7-beta96",
4
4
  "description": "piui组件库",
5
5
  "main": "index.js",
6
6
  "scripts": {