vue2server7 7.0.21 → 7.0.23

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.
@@ -8,7 +8,7 @@
8
8
  :disabled="disabled"
9
9
  clearable
10
10
  @input="onMinInput"
11
- @focus="onFocus"
11
+ @focus="onMinFocus"
12
12
  @blur="onMinBlur"
13
13
  @clear="onMinClear"
14
14
  />
@@ -21,7 +21,7 @@
21
21
  :disabled="disabled"
22
22
  clearable
23
23
  @input="onMaxInput"
24
- @focus="onFocus"
24
+ @focus="onMaxFocus"
25
25
  @blur="onMaxBlur"
26
26
  @clear="onMaxClear"
27
27
  />
@@ -33,14 +33,15 @@
33
33
  import { ref, watch, computed } from 'vue'
34
34
 
35
35
  export type RangeValue = [number | null, number | null]
36
+ type RangeInput = [number | string | null, number | string | null]
36
37
 
37
38
  const props = withDefaults(defineProps<{
38
- /** 数组模式绑定值 [min, max] */
39
- modelValue?: RangeValue
40
- /** 双字段模式 - 起始值 */
41
- start?: number | null
42
- /** 双字段模式 - 结束值 */
43
- end?: number | null
39
+ /** 数组模式绑定值 [min, max],接受字符串自动转换 */
40
+ modelValue?: RangeInput
41
+ /** 双字段模式 - 起始值,接受字符串自动转换 */
42
+ start?: number | string | null
43
+ /** 双字段模式 - 结束值,接受字符串自动转换 */
44
+ end?: number | string | null
44
45
  minPlaceholder?: string
45
46
  maxPlaceholder?: string
46
47
  separator?: string
@@ -156,33 +157,36 @@ function onMaxClear() {
156
157
  emitValue()
157
158
  }
158
159
 
159
- function onFocus() {
160
- // 获取焦点时清除错误提示
160
+ function onMinFocus() {
161
+ minFocused.value = true
162
+ hasBlurred.value = false
163
+ }
164
+
165
+ function onMaxFocus() {
166
+ maxFocused.value = true
161
167
  hasBlurred.value = false
162
168
  }
163
169
 
164
170
  function onMinBlur() {
165
171
  minFocused.value = false
166
- // 格式化
167
- let v = toNum(minDisplay.value)
172
+ const v = toNum(minDisplay.value)
168
173
  if (v !== null) {
169
174
  minDisplay.value = String(formatNum(v))
170
175
  }
171
176
  emitValue()
172
- // 两个都失焦后标记
173
- if (!minFocused.value && !maxFocused.value) {
177
+ if (!maxFocused.value) {
174
178
  hasBlurred.value = true
175
179
  }
176
180
  }
177
181
 
178
182
  function onMaxBlur() {
179
183
  maxFocused.value = false
180
- let v = toNum(maxDisplay.value)
184
+ const v = toNum(maxDisplay.value)
181
185
  if (v !== null) {
182
186
  maxDisplay.value = String(formatNum(v))
183
187
  }
184
188
  emitValue()
185
- if (!minFocused.value && !maxFocused.value) {
189
+ if (!minFocused.value) {
186
190
  hasBlurred.value = true
187
191
  }
188
192
  }
@@ -202,7 +206,7 @@ function reset() {
202
206
 
203
207
  defineExpose({ validate, reset })
204
208
 
205
- // 同步外部值
209
+ // 同步外部值(可能是字符串,先转数字再生成显示值)
206
210
  watch(
207
211
  () => ({
208
212
  isArrayMode: isArrayMode.value,
@@ -210,8 +214,10 @@ watch(
210
214
  max: isArrayMode.value ? props.modelValue?.[1] : props.end
211
215
  }),
212
216
  ({ min, max }) => {
213
- const newMin = min !== null && min !== undefined ? String(min) : ''
214
- const newMax = max !== null && max !== undefined ? String(max) : ''
217
+ const minNum = toNum(min)
218
+ const maxNum = toNum(max)
219
+ const newMin = minNum !== null ? String(formatNum(minNum)) : ''
220
+ const newMax = maxNum !== null ? String(formatNum(maxNum)) : ''
215
221
  if (newMin !== minDisplay.value) minDisplay.value = newMin
216
222
  if (newMax !== maxDisplay.value) maxDisplay.value = newMax
217
223
  },
@@ -65,7 +65,7 @@
65
65
  <template v-else-if="col.type === 'action'">
66
66
  <el-button type="text" size="small" @click="onView(row)">详情</el-button>
67
67
  <el-button type="text" size="small" @click="onDelete(row)">删除</el-button>
68
- x x </template>
68
+ </template>
69
69
  <template v-else>
70
70
  {{ row[col.prop] }}
71
71
  </template>
@@ -93,9 +93,9 @@ import NumberRange from '../components/NumberRange.vue'
93
93
  interface SearchForm {
94
94
  keyword: string
95
95
  type: string
96
- amountRange: [number | null, number | null]
97
- ageMin: number | null
98
- ageMax: number | null
96
+ amountRange: [number | string | null, number | string | null]
97
+ ageMin: number | string | null
98
+ ageMax: number | string | null
99
99
  }
100
100
 
101
101
  interface ColumnConfig {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2server7",
3
- "version": "7.0.21",
3
+ "version": "7.0.23",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "nodemon --watch src --ext ts --exec \"ts-node src/app.ts\"",
Binary file