@netang/quasar 0.0.27 → 0.0.29
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/components/input-number/index.vue +13 -15
- package/components/search/index.vue +46 -23
- package/package.json +1 -1
- package/utils/$search.js +1 -2
- package/utils/price.js +13 -0
|
@@ -121,6 +121,12 @@ export default {
|
|
|
121
121
|
// 是否为人民币的分转元(值为分, 显示为元)
|
|
122
122
|
// 如果为 true, 则 min / max / step 的值默认的单位为人民币的分
|
|
123
123
|
centToYuan: Boolean,
|
|
124
|
+
// 精度舍入模式(默认: 向下取整)
|
|
125
|
+
// 参考文档: https://mikemcl.github.io/bignumber.js/#constructor-properties
|
|
126
|
+
roundMode: {
|
|
127
|
+
type: Number,
|
|
128
|
+
default: BigNumber.ROUND_DOWN,
|
|
129
|
+
},
|
|
124
130
|
},
|
|
125
131
|
|
|
126
132
|
/**
|
|
@@ -347,18 +353,14 @@ export default {
|
|
|
347
353
|
}
|
|
348
354
|
|
|
349
355
|
// 如果设置了小数位数
|
|
350
|
-
if (currentDecimalLength.value
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
if (val.dp() > currentDecimalLength.value) {
|
|
354
|
-
// 将值向下舍入 xx 位精度(如 68.345 -> 68.34)
|
|
355
|
-
val = val.dp(currentDecimalLength.value, BigNumber.ROUND_DOWN)
|
|
356
|
-
}
|
|
356
|
+
if (currentDecimalLength.value) {
|
|
357
|
+
// 将值舍入 xx 位精度(如 68.345 -> 68.34)
|
|
358
|
+
val = val.dp(currentDecimalLength.value, props.roundMode)
|
|
357
359
|
|
|
358
360
|
// 否则值为整数
|
|
359
361
|
} else {
|
|
360
|
-
//
|
|
361
|
-
val = val.integerValue(
|
|
362
|
+
// 将值取整
|
|
363
|
+
val = val.integerValue(props.roundMode)
|
|
362
364
|
}
|
|
363
365
|
}
|
|
364
366
|
|
|
@@ -388,12 +390,8 @@ export default {
|
|
|
388
390
|
if (props.centToYuan) {
|
|
389
391
|
// 乘以 100
|
|
390
392
|
val = val.times(100)
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
if (val.dp()) {
|
|
394
|
-
// 将值向下取整
|
|
395
|
-
val = val.integerValue(BigNumber.ROUND_DOWN)
|
|
396
|
-
}
|
|
393
|
+
// 再取整(分必须是整数)
|
|
394
|
+
.integerValue(props.roundMode)
|
|
397
395
|
}
|
|
398
396
|
|
|
399
397
|
// 将值转为数字
|
|
@@ -56,35 +56,47 @@
|
|
|
56
56
|
/>
|
|
57
57
|
</template>
|
|
58
58
|
|
|
59
|
-
<!--
|
|
60
|
-
<n-input-
|
|
59
|
+
<!-- 数字输入框 价格 -->
|
|
60
|
+
<n-input-number
|
|
61
61
|
class="n-field-fieldset"
|
|
62
62
|
:label="label"
|
|
63
63
|
v-model="modelValue[itemIndex][index].value"
|
|
64
64
|
dense
|
|
65
65
|
outlined
|
|
66
66
|
clearable
|
|
67
|
+
|
|
68
|
+
:decimal-length="2"
|
|
69
|
+
:cent-to-yuan="centToYuan"
|
|
70
|
+
|
|
71
|
+
v-bind="item.input"
|
|
67
72
|
v-else-if="item.type === 'price'"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
73
|
+
/>
|
|
74
|
+
|
|
75
|
+
<!-- 输入框 -->
|
|
76
|
+
<template v-else-if="item.searchType === 'input'">
|
|
77
|
+
<!-- 输入框 数字 -->
|
|
78
|
+
<n-input-number
|
|
79
|
+
class="n-field-fieldset"
|
|
80
|
+
:label="label"
|
|
81
|
+
v-model="modelValue[itemIndex][index].value"
|
|
82
|
+
dense
|
|
83
|
+
outlined
|
|
84
|
+
clearable
|
|
85
|
+
v-bind="item.input"
|
|
86
|
+
v-if="item.type === 'number'"
|
|
87
|
+
/>
|
|
88
|
+
<!-- 输入框 文字 -->
|
|
89
|
+
<q-input
|
|
90
|
+
class="n-field-fieldset"
|
|
91
|
+
:label="label"
|
|
92
|
+
v-model="modelValue[itemIndex][index].value"
|
|
93
|
+
dense
|
|
94
|
+
outlined
|
|
95
|
+
clearable
|
|
96
|
+
v-bind="item.input"
|
|
97
|
+
v-else
|
|
98
|
+
/>
|
|
99
|
+
</template>
|
|
88
100
|
|
|
89
101
|
<!-- 下拉列表 -->
|
|
90
102
|
<q-select
|
|
@@ -164,13 +176,14 @@
|
|
|
164
176
|
</template>
|
|
165
177
|
|
|
166
178
|
<script>
|
|
179
|
+
import { computed } from 'vue'
|
|
180
|
+
|
|
167
181
|
export default {
|
|
168
182
|
|
|
169
183
|
/**
|
|
170
184
|
* 标识
|
|
171
185
|
*/
|
|
172
186
|
name: 'NSearch',
|
|
173
|
-
|
|
174
187
|
/**
|
|
175
188
|
* 声明属性
|
|
176
189
|
*/
|
|
@@ -184,5 +197,15 @@ export default {
|
|
|
184
197
|
// 重置
|
|
185
198
|
onReset: Function,
|
|
186
199
|
},
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* 组合式
|
|
203
|
+
*/
|
|
204
|
+
setup() {
|
|
205
|
+
return {
|
|
206
|
+
// 如果金额为分
|
|
207
|
+
centToYuan: utils.config('priceCent') === true,
|
|
208
|
+
}
|
|
209
|
+
}
|
|
187
210
|
}
|
|
188
211
|
</script>
|
package/package.json
CHANGED
package/utils/$search.js
CHANGED
|
@@ -221,11 +221,10 @@ async function getOptions(rawSearchOptions, format) {
|
|
|
221
221
|
filter: true,
|
|
222
222
|
}, newItem.table)
|
|
223
223
|
|
|
224
|
-
console.log('111', newItem.table)
|
|
225
|
-
|
|
226
224
|
// 否则为输入框
|
|
227
225
|
} else {
|
|
228
226
|
newItem.searchType = 'input'
|
|
227
|
+
newItem.input = Object.assign({}, newItem.input)
|
|
229
228
|
}
|
|
230
229
|
|
|
231
230
|
lists.push(newItem)
|
package/utils/price.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 换算金额
|
|
3
|
+
*/
|
|
4
|
+
utils.price = function(value, params) {
|
|
5
|
+
return utils.decimal(value, Object.assign({
|
|
6
|
+
// 最小值
|
|
7
|
+
min: 0,
|
|
8
|
+
// 小数点位数
|
|
9
|
+
decimalLength: 2,
|
|
10
|
+
// 是否开启人民币分转元(如值 189 -> 1.89)
|
|
11
|
+
centToYuan: utils.config('priceCent') === true,
|
|
12
|
+
}, params))
|
|
13
|
+
}
|