Commit d35f57c0 authored by 陈明豪's avatar 陈明豪

bug修改

parent be741ffc
...@@ -403,3 +403,18 @@ export function moneyFormat(data) { ...@@ -403,3 +403,18 @@ export function moneyFormat(data) {
} }
return result.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) return result.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
} }
export function moneyFormatWithFix(data, fixNum) {
let result = 0
// 判断是不是数字
if (typeof data === 'number' && !isNaN(data)) {
result = data
} else {
let temp = parseFloat(data)
if (!isNaN(temp)){
result = temp
}else{
return '-'
}
}
return result.toLocaleString('en-US', { minimumFractionDigits: fixNum, maximumFractionDigits: fixNum })
}
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
</template> </template>
<script> <script>
import { moneyFormatWithFix } from '@/utils'
export default { export default {
name: 'TwoLineChart', name: 'TwoLineChart',
props: { props: {
...@@ -114,12 +116,12 @@ export default { ...@@ -114,12 +116,12 @@ export default {
<div style="display: flex"> <div style="display: flex">
<div style="background-color: ${color1};width: 10px;height: 10px;margin-top: 7px;margin-right:5px;border-radius: 10px"></div> <div style="background-color: ${color1};width: 10px;height: 10px;margin-top: 7px;margin-right:5px;border-radius: 10px"></div>
<span>${label1}</span> <span>${label1}</span>
<span style="margin-left: 5px;color: ${color1}">${Number(axis[0].value).toFixed(fixNum1)}${unit1}</span> <span style="margin-left: 5px;color: ${color1}">${moneyFormatWithFix(Number(axis[0].value), fixNum1)}${unit1}</span>
</div> </div>
<div style="display: flex"> <div style="display: flex">
<div style="background-color: ${color2};width: 10px;height: 10px;margin-top: 7px;margin-right:5px;border-radius: 10px"></div> <div style="background-color: ${color2};width: 10px;height: 10px;margin-top: 7px;margin-right:5px;border-radius: 10px"></div>
<span>${label2}</span> <span>${label2}</span>
<span style="margin-left: 5px;color: ${color2}">${Number(axis[1].value).toFixed(fixNum2)}${unit2}</span> <span style="margin-left: 5px;color: ${color2}">${moneyFormatWithFix(Number(axis[1].value), fixNum2)}${unit2}</span>
</div> </div>
</div>` </div>`
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment