From dc9ab39e4090a41dbf230a0135499c6fb24c4251 Mon Sep 17 00:00:00 2001 From: xiaojiahui Date: Mon, 24 Jun 2024 19:48:51 +0800 Subject: [PATCH 1/3] amount support mask` --- components/amount/README.en-US.md | 1 + components/amount/README.md | 1 + components/amount/demo/cases/demo4.vue | 31 ++++++++++++++++++++++++++ components/amount/demo/index.vue | 3 ++- components/amount/index.vue | 13 ++++++++++- 5 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 components/amount/demo/cases/demo4.vue diff --git a/components/amount/README.en-US.md b/components/amount/README.en-US.md index 31e2ee55c..ce433ce5a 100644 --- a/components/amount/README.en-US.md +++ b/components/amount/README.en-US.md @@ -33,3 +33,4 @@ The font `DIDIFD-Medium` is used in the component for the case show only, if nec |is-capital|convert to chinese capital|Boolean|`false`|-| |transition|use transition when value changes|Boolean|`false`|-| |duration|transition duration|Number|`1000`|unit `ms`| +|mask2.7.2+|use mask|Boolean|`false`|-| diff --git a/components/amount/README.md b/components/amount/README.md index 131a668f0..46925fed4 100644 --- a/components/amount/README.md +++ b/components/amount/README.md @@ -33,3 +33,4 @@ Vue.component(Amount.name, Amount) |is-capital|数字是否转换为大写中文|Boolean|`false`|-| |transition|数字变化是否使用动画|Boolean|`false`|-| |duration|数字变化动画时长|Number|`1000`|单位`ms`| +|mask2.7.2+ |是否掩码|Boolean|`false`|-| diff --git a/components/amount/demo/cases/demo4.vue b/components/amount/demo/cases/demo4.vue new file mode 100644 index 000000000..df13fd4cc --- /dev/null +++ b/components/amount/demo/cases/demo4.vue @@ -0,0 +1,31 @@ + + + + + diff --git a/components/amount/demo/index.vue b/components/amount/demo/index.vue index 620aee34b..f7b545218 100644 --- a/components/amount/demo/index.vue +++ b/components/amount/demo/index.vue @@ -15,9 +15,10 @@ import Demo0 from './cases/demo0' import Demo1 from './cases/demo1' import Demo2 from './cases/demo2' import Demo3 from './cases/demo3' +import Demo4 from './cases/demo4' export default { - ...createDemoModule('amount', [Demo0, Demo1, Demo2, Demo3]), + ...createDemoModule('amount', [Demo0, Demo1, Demo2, Demo3, Demo4]), } diff --git a/components/amount/index.vue b/components/amount/index.vue index 3340b4e26..075b45812 100644 --- a/components/amount/index.vue +++ b/components/amount/index.vue @@ -1,6 +1,6 @@ @@ -18,6 +18,13 @@ export default { const rounded = isRoundUp ? Math.round(exponentialForm) : Math.floor(exponentialForm) return Number(`${rounded}e-${precision}`).toFixed(precision) }, + doMask(value, mask) { + if (mask) { + return value.toString().replace(/\d/g, '*') + } else { + return value + } + }, doFormat(value, hasSeparator, separator) { if (!hasSeparator) { return value @@ -78,6 +85,10 @@ export default { type: Number, default: 1000, }, + mask: { + type: Boolean, + default: false, + }, }, data() { From 09b2564ee944ea8c636baddffbbc0b7fd47de7eb Mon Sep 17 00:00:00 2001 From: xiaojiahui Date: Tue, 25 Jun 2024 11:00:10 +0800 Subject: [PATCH 2/3] modified version --- components/amount/README.en-US.md | 2 +- components/amount/README.md | 2 +- components/amount/demo/cases/demo4.vue | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/amount/README.en-US.md b/components/amount/README.en-US.md index ce433ce5a..aeb2ae9fc 100644 --- a/components/amount/README.en-US.md +++ b/components/amount/README.en-US.md @@ -33,4 +33,4 @@ The font `DIDIFD-Medium` is used in the component for the case show only, if nec |is-capital|convert to chinese capital|Boolean|`false`|-| |transition|use transition when value changes|Boolean|`false`|-| |duration|transition duration|Number|`1000`|unit `ms`| -|mask2.7.2+|use mask|Boolean|`false`|-| +|mask2.7.1+|use mask|Boolean|`false`|-| diff --git a/components/amount/README.md b/components/amount/README.md index 46925fed4..667061105 100644 --- a/components/amount/README.md +++ b/components/amount/README.md @@ -33,4 +33,4 @@ Vue.component(Amount.name, Amount) |is-capital|数字是否转换为大写中文|Boolean|`false`|-| |transition|数字变化是否使用动画|Boolean|`false`|-| |duration|数字变化动画时长|Number|`1000`|单位`ms`| -|mask2.7.2+ |是否掩码|Boolean|`false`|-| +|mask2.7.1+ |是否掩码|Boolean|`false`|-| diff --git a/components/amount/demo/cases/demo4.vue b/components/amount/demo/cases/demo4.vue index df13fd4cc..6539cca26 100644 --- a/components/amount/demo/cases/demo4.vue +++ b/components/amount/demo/cases/demo4.vue @@ -14,7 +14,7 @@ export default { name: 'amount-demo', /* DELETE */ - title: '大写中文', + title: '掩码展示', titleEnUS: 'Capital Chinese', /* DELETE */ components: { From d2afd0ec24000a4f876bf1dafb0d2f61f4d5e7d7 Mon Sep 17 00:00:00 2001 From: xiaojiahui Date: Tue, 25 Jun 2024 11:05:33 +0800 Subject: [PATCH 3/3] modified titleEnUS --- components/amount/demo/cases/demo4.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/amount/demo/cases/demo4.vue b/components/amount/demo/cases/demo4.vue index 6539cca26..5c54da967 100644 --- a/components/amount/demo/cases/demo4.vue +++ b/components/amount/demo/cases/demo4.vue @@ -15,7 +15,7 @@ export default { name: 'amount-demo', /* DELETE */ title: '掩码展示', - titleEnUS: 'Capital Chinese', + titleEnUS: 'Mask Display', /* DELETE */ components: { [Amount.name]: Amount,