t20-common-lib 0.9.8 → 0.9.10
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": "t20-common-lib",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.10",
|
|
4
4
|
"description": "T20",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"t20-common-lib",
|
|
27
27
|
"store"
|
|
28
28
|
],
|
|
29
|
-
"author": "
|
|
29
|
+
"author": "liuzongxi",
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"core-js": "^2.6.12",
|
|
@@ -29,8 +29,24 @@
|
|
|
29
29
|
<div class="content-item-title">{{ conItem.title }}
|
|
30
30
|
<i v-if="conItem.tips" v-title="conItem.tips" class="n20-icon-xinxitishi"></i>
|
|
31
31
|
</div>
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
<!-- 支持三种情况:
|
|
33
|
+
1) 同时存在金额和笔数(优先使用 conItem.amount,如无则使用 conItem.value) -> 在一行显示:金额(格式化) / 笔数(单位)
|
|
34
|
+
2) 只有金额(conItem.amountFormat 为 true 或 amount/value 为数字) -> 使用过滤器格式化
|
|
35
|
+
3) 只有普通值 -> 直接显示 value + unit
|
|
36
|
+
-->
|
|
37
|
+
<div class="content-item-val" @click="$emit('click', conItem)">
|
|
38
|
+
<template v-if="hasAmountAndCount(conItem)">
|
|
39
|
+
{{ formatAmount(conItem, 'value') }}<span class="content-item-unit">{{ formatAmount(conItem, 'unit') }}</span>
|
|
40
|
+
<span class="divider-inline"> / </span>
|
|
41
|
+
<span class="count-val">{{ conItem.count }}<span class="content-item-unit">{{ conItem.countUnit || conItem.unit || '笔' }}</span></span>
|
|
42
|
+
</template>
|
|
43
|
+
<template v-else-if="conItem.amountFormat">
|
|
44
|
+
{{ formatAmount(conItem, 'value') }}<span class="content-item-unit">{{ formatAmount(conItem, 'unit') }}</span>
|
|
45
|
+
</template>
|
|
46
|
+
<template v-else>
|
|
47
|
+
{{ conItem.value }}<span class="content-item-unit">{{ conItem.unit }}</span>
|
|
48
|
+
</template>
|
|
49
|
+
</div>
|
|
34
50
|
</div>
|
|
35
51
|
<div
|
|
36
52
|
v-if="index !== item.subList.length - 1"
|
|
@@ -113,6 +129,35 @@ export default {
|
|
|
113
129
|
return '';
|
|
114
130
|
}
|
|
115
131
|
}
|
|
132
|
+
,
|
|
133
|
+
/**
|
|
134
|
+
* 判断是否同时包含金额和笔数
|
|
135
|
+
* 支持两种字段表示:优先使用 item.amount,其次使用 item.value
|
|
136
|
+
*/
|
|
137
|
+
hasAmountAndCount(item) {
|
|
138
|
+
if (!item) return false;
|
|
139
|
+
const amount = item.amount !== undefined && item.amount !== null ? item.amount : item.value;
|
|
140
|
+
// amount 必须是数字(或能被转为数字),count 存在(0 也认为有效)
|
|
141
|
+
const hasAmount = amount !== undefined && amount !== null && !isNaN(Number(amount));
|
|
142
|
+
const hasCount = item.count !== undefined && item.count !== null;
|
|
143
|
+
return hasAmount && hasCount;
|
|
144
|
+
},
|
|
145
|
+
/**
|
|
146
|
+
* 统一走过滤器来格式化金额/单位(保持与现有过滤器行为一致)
|
|
147
|
+
*/
|
|
148
|
+
formatAmount(item, type = 'value') {
|
|
149
|
+
const amount = item.amount !== undefined && item.amount !== null ? item.amount : item.value;
|
|
150
|
+
// 通过 this.$options.filters 调用组件内定义的过滤器
|
|
151
|
+
if (this.$options && this.$options.filters && typeof this.$options.filters.cardFormatAmount === 'function') {
|
|
152
|
+
try {
|
|
153
|
+
return this.$options.filters.cardFormatAmount(amount, type);
|
|
154
|
+
} catch (e) {
|
|
155
|
+
// 兜底返回原值或空字符串
|
|
156
|
+
return type === 'value' ? amount : '';
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return type === 'value' ? amount : '';
|
|
160
|
+
}
|
|
116
161
|
}
|
|
117
162
|
}
|
|
118
163
|
</script>
|
|
@@ -170,6 +215,16 @@ export default {
|
|
|
170
215
|
font-size: 20px;
|
|
171
216
|
text-align: center;
|
|
172
217
|
}
|
|
218
|
+
|
|
219
|
+
.divider-inline {
|
|
220
|
+
margin: 0 6px;
|
|
221
|
+
color: rgba(255,255,255,0.9);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.count-val {
|
|
225
|
+
font-size: 14px;
|
|
226
|
+
vertical-align: middle;
|
|
227
|
+
}
|
|
173
228
|
|
|
174
229
|
&-unit {
|
|
175
230
|
font-size: 14px;
|