xt-element-ui 1.2.7 → 1.2.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xt-element-ui",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "基于 Vue 2.7 + ElementUI 的企业级组件库,提供丰富的自定义组件和扩展组件",
5
5
  "main": "lib/index.common.js",
6
6
  "module": "lib/index.esm.js",
@@ -105,6 +105,7 @@ export default {
105
105
  watch: {
106
106
  value: {
107
107
  deep: true,
108
+ immediate: true,
108
109
  handler(val) {
109
110
  this.localItems = this.normalize(val)
110
111
  }
@@ -196,7 +197,6 @@ export default {
196
197
  },
197
198
 
198
199
  onAdd() {
199
- debugger
200
200
  const list = this.localItems
201
201
  const lim = Number(this.limit)
202
202
  if (lim > 0 && list.length >= lim) return
@@ -90,10 +90,7 @@ export default {
90
90
  },
91
91
 
92
92
  data() {
93
- const v = this.value
94
- const minVal = this.safeNumber(v && v[this.keyMin], 0)
95
- const maxVal = this.isLast ? null : this.safeNumber(v && v[this.keyMax], minVal + 1)
96
- const priceVal = this.safeNumber(v && v[this.keyPrice], 0)
93
+ const { minVal, maxVal, priceVal } = this.getPriceItem(this.value)
97
94
  return {
98
95
  minInput: minVal,
99
96
  maxInput: maxVal,
@@ -104,11 +101,12 @@ export default {
104
101
  watch: {
105
102
  value: {
106
103
  deep: true,
104
+ immediate: true,
107
105
  handler(val) {
108
- const minVal = this.safeNumber(val && val[this.keyMin], 0)
106
+ const { minVal, maxVal, priceVal } = this.getPriceItem(val)
109
107
  this.minInput = minVal
110
- this.maxInput = this.isLast ? null : this.safeNumber(val && val[this.keyMax], minVal + 1)
111
- this.priceInput = this.safeNumber(val && val[this.keyPrice], 0)
108
+ this.maxInput = maxVal
109
+ this.priceInput = priceVal
112
110
  }
113
111
  },
114
112
  isLast(val) {
@@ -123,6 +121,17 @@ export default {
123
121
  },
124
122
 
125
123
  methods: {
124
+ getPriceItem(value) {
125
+ const v = value
126
+ const minVal = this.safeNumber(v && v[this.keyMin], 0)
127
+ const maxVal = this.isLast ? null : this.safeNumber(v && v[this.keyMax], minVal + 1)
128
+ const priceVal = this.safeNumber(v && v[this.keyPrice], 0)
129
+ return {
130
+ minVal,
131
+ maxVal,
132
+ priceVal
133
+ }
134
+ },
126
135
  // 统一兜底:非数字输入一律转为 fallback(默认 0)
127
136
  safeNumber(v, fallback = 0) {
128
137
  if (v === null || v === undefined || v === '' || v === Infinity || v === -Infinity) return fallback