n20-common-lib 3.0.63 → 3.0.65
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,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n20-common-lib",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.65",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
|
-
"publish": "npm run build:css && npm version patch && npm publish --tag legacy",
|
|
7
6
|
"serve": "vue-cli-service serve",
|
|
8
7
|
"build": "node versionInfo.js && npm run build:css && vue-cli-service build --testTheme",
|
|
9
8
|
"test:unit": "vue-cli-service test:unit",
|
|
@@ -43,11 +43,17 @@ export default {
|
|
|
43
43
|
type: [Number, String],
|
|
44
44
|
default: undefined
|
|
45
45
|
},
|
|
46
|
+
/**
|
|
47
|
+
* 输入框类型
|
|
48
|
+
* - money: 金额类型,默认保留2位小数,启用千分位格式化
|
|
49
|
+
* - rate: 比率类型,默认保留4位小数,显示%后缀
|
|
50
|
+
* - number: 纯数字类型,不启用千分位格式化
|
|
51
|
+
*/
|
|
46
52
|
type: {
|
|
47
53
|
type: String,
|
|
48
54
|
default: 'money',
|
|
49
55
|
validator(v) {
|
|
50
|
-
return ['money', 'rate'].includes(v)
|
|
56
|
+
return ['money', 'rate', 'number'].includes(v)
|
|
51
57
|
}
|
|
52
58
|
},
|
|
53
59
|
maxlength: {
|
|
@@ -122,6 +128,12 @@ export default {
|
|
|
122
128
|
return $lc('请输入')
|
|
123
129
|
}
|
|
124
130
|
},
|
|
131
|
+
/**
|
|
132
|
+
* 计算小数位数
|
|
133
|
+
* - 优先使用format属性解析
|
|
134
|
+
* - 其次使用dNum属性
|
|
135
|
+
* - 根据type类型设置默认值:rate=4, money=2, number=2
|
|
136
|
+
*/
|
|
125
137
|
fNum() {
|
|
126
138
|
if (this.format) {
|
|
127
139
|
let i_f = this.format.indexOf('.')
|
|
@@ -133,7 +145,8 @@ export default {
|
|
|
133
145
|
if (this.type === 'rate') {
|
|
134
146
|
return 4
|
|
135
147
|
}
|
|
136
|
-
|
|
148
|
+
// number类型不限制小数位,默认返回2
|
|
149
|
+
if (this.type === 'money' || this.type === 'number') {
|
|
137
150
|
return 2
|
|
138
151
|
}
|
|
139
152
|
return 2
|
|
@@ -142,6 +155,24 @@ export default {
|
|
|
142
155
|
watch: {
|
|
143
156
|
value: {
|
|
144
157
|
handler(val) {
|
|
158
|
+
// number类型不启用千分位格式化,但应用小数位限制
|
|
159
|
+
if (this.type === 'number') {
|
|
160
|
+
if (val === undefined || val === null) {
|
|
161
|
+
this.valueStr = ''
|
|
162
|
+
} else if (this.rangeAuto) {
|
|
163
|
+
// rangeAuto模式下,仅当小数位不足时补零
|
|
164
|
+
let nF = N.toString(val).split('.')[1] || ''
|
|
165
|
+
if (nF.length < this.fNum) {
|
|
166
|
+
this.valueStr = N.subFixed(val, this.fNum)
|
|
167
|
+
} else {
|
|
168
|
+
this.valueStr = N.toString(val)
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
// 非rangeAuto模式,强制应用小数位
|
|
172
|
+
this.valueStr = N.subFixed(val, this.fNum)
|
|
173
|
+
}
|
|
174
|
+
return
|
|
175
|
+
}
|
|
145
176
|
if (this.rangeAuto) {
|
|
146
177
|
if (val || val === 0) {
|
|
147
178
|
let nF = N.toString(val).split('.')[1] || ''
|
|
@@ -161,7 +192,10 @@ export default {
|
|
|
161
192
|
focusFn() {
|
|
162
193
|
this.isFocus = true
|
|
163
194
|
if (!this.disabled && this.valueStr) {
|
|
164
|
-
|
|
195
|
+
// number类型不处理千分位(因为根本没有千分位)
|
|
196
|
+
if (this.type !== 'number') {
|
|
197
|
+
this.valueStr = this.valueStr.replace(/,/g, '')
|
|
198
|
+
}
|
|
165
199
|
this.preValue = this.valueStr
|
|
166
200
|
}
|
|
167
201
|
},
|
|
@@ -186,8 +220,10 @@ export default {
|
|
|
186
220
|
val = this.max
|
|
187
221
|
}
|
|
188
222
|
if (this.rangeAuto) {
|
|
223
|
+
// rangeAuto模式下,直接转换为字符串,不固定小数位
|
|
189
224
|
this.valueStr = N.toString(val)
|
|
190
225
|
} else {
|
|
226
|
+
// 应用小数位限制(number类型默认2位)
|
|
191
227
|
this.valueStr = N.subFixed(val, this.fNum)
|
|
192
228
|
}
|
|
193
229
|
}
|
|
@@ -220,14 +256,30 @@ export default {
|
|
|
220
256
|
}
|
|
221
257
|
|
|
222
258
|
let nStr
|
|
223
|
-
|
|
259
|
+
// number类型不启用千分位格式化,但应用小数位限制
|
|
260
|
+
if (this.type === 'number') {
|
|
261
|
+
if (this.stepStrictly) {
|
|
262
|
+
let stepCount = val / this.step
|
|
263
|
+
if (val % this.step !== 0) {
|
|
264
|
+
val = Math.round(stepCount) * this.step
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (val < this.min) {
|
|
268
|
+
val = this.min
|
|
269
|
+
} else if (val > this.max) {
|
|
270
|
+
val = this.max
|
|
271
|
+
}
|
|
272
|
+
// 应用小数位限制(默认2位)
|
|
273
|
+
nStr = N.subFixed(val, this.fNum)
|
|
274
|
+
this.valueStr = nStr
|
|
275
|
+
} else if (this.rangeAuto) {
|
|
224
276
|
nStr = N.toString(val)
|
|
225
277
|
this.valueStr = N.addThousands(valStr)
|
|
226
278
|
} else {
|
|
227
279
|
if (this.stepStrictly) {
|
|
228
|
-
let
|
|
280
|
+
let stepCount = val / this.step
|
|
229
281
|
if (val % this.step !== 0) {
|
|
230
|
-
val = Math.round(
|
|
282
|
+
val = Math.round(stepCount) * this.step
|
|
231
283
|
}
|
|
232
284
|
}
|
|
233
285
|
if (val < this.min) {
|
|
@@ -219,6 +219,11 @@ export default {
|
|
|
219
219
|
initialValue: {
|
|
220
220
|
type: Object,
|
|
221
221
|
default: () => ({})
|
|
222
|
+
},
|
|
223
|
+
// 筛选器默认展开/收起状态
|
|
224
|
+
defaultExpanded: {
|
|
225
|
+
type: Boolean,
|
|
226
|
+
default: false
|
|
222
227
|
}
|
|
223
228
|
},
|
|
224
229
|
data() {
|
|
@@ -231,7 +236,7 @@ export default {
|
|
|
231
236
|
isAdd: false,
|
|
232
237
|
form: { userNo: sessionStorage.getItem('userNo'), pageNo: this.filterId },
|
|
233
238
|
|
|
234
|
-
multiple:
|
|
239
|
+
multiple: this.defaultExpanded,
|
|
235
240
|
// 保存的筛选字段
|
|
236
241
|
checkData: [],
|
|
237
242
|
key: 0,
|