diff --git a/components/amount/demo/cases/demo1.vue b/components/amount/demo/cases/demo1.vue index d5d24cc55..98ac463d3 100644 --- a/components/amount/demo/cases/demo1.vue +++ b/components/amount/demo/cases/demo1.vue @@ -3,6 +3,12 @@ +
+ diff --git a/components/amount/index.vue b/components/amount/index.vue index 66ed17214..3340b4e26 100644 --- a/components/amount/index.vue +++ b/components/amount/index.vue @@ -24,10 +24,17 @@ export default { } const numberParts = value.split('.') - const integerValue = numberParts[0] + let integerValue = numberParts[0] const decimalValue = numberParts[1] || '' + + let sign = '' + if (integerValue.startsWith('-')) { + integerValue = integerValue.substring(1) + sign = '-' + } + const formateValue = formatValueByGapStep(3, integerValue, separator, 'right', 0, 1) - return decimalValue ? `${formateValue.value}.${decimalValue}` : `${formateValue.value}` + return decimalValue ? `${sign}${formateValue.value}.${decimalValue}` : `${sign}${formateValue.value}` }, doCapital(value) { return numberCapital(value) diff --git a/components/amount/test/__snapshots__/demo.spec.js.snap b/components/amount/test/__snapshots__/demo.spec.js.snap index f7c1bad5d..08662a805 100644 --- a/components/amount/test/__snapshots__/demo.spec.js.snap +++ b/components/amount/test/__snapshots__/demo.spec.js.snap @@ -10,6 +10,6 @@ exports[`Amount -Demo Basic 1`] = ` exports[`Amount -Demo Disabled unselected 1`] = `
壹仟贰佰叁拾肆元整 壹拾贰元叁角肆分 壹仟贰佰元整 壹仟贰佰零壹元整
`; -exports[`Amount -Demo Thousands Separator 1`] = `
1,234.00
`; +exports[`Amount -Demo Thousands Separator 1`] = `
1,234.00
-123,456.123
`; exports[`Amount -Demo Transition 1`] = `
0.00
`; diff --git a/components/amount/test/cases/demo1.vue b/components/amount/test/cases/demo1.vue index b2c2e7e24..8b48ba63a 100644 --- a/components/amount/test/cases/demo1.vue +++ b/components/amount/test/cases/demo1.vue @@ -3,6 +3,12 @@ +
+