当前位置:网站首页>根据数字显示中文汉字
根据数字显示中文汉字
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()
}
}
边栏推荐
- 团体程序设计天梯赛-练习集 L1-006 连续因子
- Introduction to neural network (Part 2)
- SSRF vulnerability exploitation - attack redis
- 21个战略性目标实例,推动你的公司快速发展
- Scanf read in data type symbol table
- 谷歌官方回应:我们没有放弃TensorFlow,未来与JAX并肩发展
- Mouse over to change the transparency of web page image
- Comprendre la méthode de détection des valeurs aberrantes des données
- 【Go基础】2 - Go基本语句
- Const string inside function - C #
猜你喜欢

【性能测试】一文读懂Jmeter

How to use MOS tube to realize the anti reverse connection circuit of power supply

zabbix監控系統自定義監控內容

Heap concept in JVM

DM8 uses different databases to archive and recover after multiple failures

Fault analysis | MySQL: unique key constraint failure

snipaste 方便的截图软件,可以复制在屏幕上

墨者学院-phpMyAdmin后台文件包含分析溯源

Devops Practice Guide - reading notes (long text alarm)

深入浅出:了解时序数据库 InfluxDB
随机推荐
deno debugger
Fault analysis | MySQL: unique key constraint failure
What sparks can applet container technology collide with IOT
Is l1-029 too fat (5 points)
R language uses cforest function in Party package to build random forest based on conditional inference trees, uses varimp function to check feature importance, and uses table function to calculate co
DM8 database recovery based on point in time
Snipaste convenient screenshot software, which can be copied on the screen
DM database password policy and login restriction settings
Redis sentinel mechanism
SQL statement view SQL Server 2005 version number
deno debugger
Relations courantes de la fiche de données d'exploitation pour les activités
Li Kou today's question -1200 Minimum absolute difference
Technology sharing | MySQL parallel DDL
时序数据库 InfluxDB 2.2 初探
Learn nuxt js
Google's official response: we have not given up tensorflow and will develop side by side with Jax in the future
[go basics] 2 - go basic sentences
Project 1 household accounting software (goal + demand description + code explanation + basic fund and revenue and expenditure details record + realization of keyboard access)
How to reset IntelliSense in vs Code- How to reset intellisense in VS Code?