当前位置:网站首页>根据数字显示中文汉字
根据数字显示中文汉字
2022-07-04 08:13:00 【Э时间行者于我】
根据数字显示中文汉字
<div class="money">
<div class="left">
<span>合计</span>
<br>
<span>金额</span>
</div>
<div class="nums">
<span class="unit">{
{payDetail.moneyArr[0]}} 仟</span>
<span class="unit">{
{payDetail.moneyArr[1]}} 佰</span>
<span class="unit">{
{payDetail.moneyArr[2]}} 拾</span>
<span class="unit">{
{payDetail.moneyArr[3]}} 万</span>
<span class="unit">{
{payDetail.moneyArr[4]}} 仟</span>
<span class="unit">{
{payDetail.moneyArr[5]}} 佰</span>
<span class="unit">{
{payDetail.moneyArr[6]}} 拾</span>
<span class="unit">{
{payDetail.moneyArr[7]}} 元</span>
<span class="unit">{
{payDetail.moneyArr[8]}} 角</span>
<span class="unit">{
{payDetail.moneyArr[9]}} 分</span>
</div>
<div class="right">
¥<span class="underline">{
{Number(payDetail.payAmount||0).toFixed(2)}}</span>元
</div>
</div>
data() {
return {
modalShow: false,
id: '',
payDetail: {
paymentOrderNo: '', // 请款单号
payAmount: '', // 应付金额
accountName: '', // 账户名称
bank: '', // 开户银行
accountNumber: '', // 银行账户
billDateStart: '', // 账单开始时间
billDateEnd: '', // 账单结束时间
applyTime: '', // 申请时间
applicant: '', // 申请人
settlementType: '', // 结算方式
remarks: '', // 备注
moneyArr: []
}
}
},
created() {
console.log(this.$route.query)
this.init()
},
methods: {
async init() {
let id = this.$route.query.id
if (!id) return
this.$Spin.show()
try {
let res = await getPaymentOrder({
id })
this.payDetail = res.data.result || {
}
this.payDetail.moneyArr = this.convertCurrency(Number(this.payDetail.payAmount)) // 就是这个数值是我们用到的
} catch (error) {
console.log(error)
this.$Message.error('网络异常')
} finally {
this.$Spin.hide()
}
},
convertCurrency(money) {
console.log(this.payDetail.payAmount) // egg:123456 数字类型
// 汉字的数字
var cnNums = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
// 最大处理的数字
var maxNum = 99999999999999.99
// 分离金额后用的数组,预定义
if (!money) {
return '' }
money = parseFloat(money)
if (money >= maxNum) {
// 超出最大处理数字
return ''
}
// 转换为字符串
money = Number(money).toFixed(2)
let arr = Array.from(money).filter(item => item !== '.').map(item => cnNums[item])
console.log(arr)
let len = arr.length
if (len < 10) {
for (let i = 0; i < 10 - len; i++) {
arr.unshift('零')
}
}
console.log(arr) // 这块就可以打印出中文数值
return arr
},
// 打印
doPrint() {
window.print()
}
}
边栏推荐
- 21 examples of strategic goals to promote the rapid development of your company
- Sports [running 01] a programmer's half horse challenge: preparation before running + adjustment during running + recovery after running (experience sharing)
- Div hidden in IE 67 shows blank problem IE 8 is normal
- Const string inside function - C #
- [gurobi] establishment of simple model
- 墨者学院-Webmin未经身份验证的远程代码执行
- 学习Nuxt.js
- BUUCTF(3)
- ZABBIX 5.0 monitoring client
- 没有Kubernetes怎么玩Dapr?
猜你喜欢
ES6 summary
Flask 常用组件
[gurobi] establishment of simple model
论文学习——基于极值点特征的时间序列相似性查询方法
Comprendre la méthode de détection des valeurs aberrantes des données
PCIE知识点-010:PCIE 热插拔资料从哪获取
[test de performance] lire jmeter
L2-013 red alarm (C language) and relevant knowledge of parallel search
zabbix 5.0监控客户端
时序数据库 InfluxDB 2.2 初探
随机推荐
力扣今日题-1200. 最小绝对差
广和通高性能4G/5G无线模组解决方案全面推动高效、低碳智能电网
Email alarm configuration of ZABBIX monitoring system
一文了解數據异常值檢測方法
Flask 常用组件
[go basics] 1 - go go
ZABBIX 5.0 monitoring client
ZABBIX monitoring system custom monitoring content
【Go基础】1 - Go Go Go
zabbix监控系统部署
What determines vacuum permittivity and vacuum permeability? Why do these two physical quantities exist?
1、卡尔曼滤波-最佳的线性滤波器
DM8 database recovery based on point in time
Use preg_ Match extracts the string into the array between: & | people PHP
Moher college phpMyAdmin background file contains analysis traceability
Système de surveillance zabbix contenu de surveillance personnalisé
Sqli labs download, installation and reset of SQL injection test tool one of the solutions to the database error (# 0{main}throw in d:\software\phpstudy_pro\www\sqli labs-...)
How to get bytes containing null terminators from a string- c#
@Role of requestparam annotation
Introduction to neural network (Part 2)