From 80c9de0ee6624ac25172e088baa1ab425ea7e86b Mon Sep 17 00:00:00 2001 From: zhaoxiao Date: Fri, 17 Dec 2021 18:45:42 +0800 Subject: [PATCH] =?UTF-8?q?[update]=20=E7=BC=B4=E8=B4=B9=E5=87=AD=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/util.js | 32 ++++++++++++++++++++++++ src/views/MessagePage/PaymentVoucher.vue | 8 +++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/utils/util.js b/src/utils/util.js index 5f8821b..c5db5ad 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -630,4 +630,36 @@ export function addZero(e) { e.target.value = e.target.value + '.00' } } +} + +//将数字(整数)转为汉字 +export function convertToChinaNum(num) { + let arr1 = new Array('零', '一', '二', '三', '四', '五', '六', '七', '八', '九') + let arr2 = new Array('', '十', '百', '千', '万', '十', '百', '千', '亿', '十', '百', '千', '万', '十', '百', '千', '亿')//可继续追加更高位转换值 + if (!num || isNaN(num)) { + return '零' + } + let english = num.toString().split('') + let result = '' + for (let i = 0; i < english.length; i++) { + let des_i = english.length - 1 - i//倒序排列设值 + result = arr2[i] + result + let arr1_index = english[des_i] + result = arr1[arr1_index] + result + } + //将【零千、零百】换成【零】 【十零】换成【十】 + result = result.replace(/零(千|百|十)/g, '零').replace(/十零/g, '十') + //合并中间多个零为一个零 + result = result.replace(/零+/g, '零') + //将【零亿】换成【亿】【零万】换成【万】 + result = result.replace(/零亿/g, '亿').replace(/零万/g, '万') + //将【亿万】换成【亿】 + result = result.replace(/亿万/g, '亿') + //移除末尾的零 + result = result.replace(/零+$/, '') + //将【零一十】换成【零十】 + //result = result.replace(/零一十/g, '零十');//貌似正规读法是零一十 + //将【一十】换成【十】 + result = result.replace(/^一十/g, '十') + return result } \ No newline at end of file diff --git a/src/views/MessagePage/PaymentVoucher.vue b/src/views/MessagePage/PaymentVoucher.vue index 880881c..5a34af8 100644 --- a/src/views/MessagePage/PaymentVoucher.vue +++ b/src/views/MessagePage/PaymentVoucher.vue @@ -66,7 +66,7 @@ - 添加阶段 + 添加阶段 @@ -162,6 +162,7 @@ import { getAction, postAction } from '@api/manage' import PreviewImgModal from '@views/MessagePage/modules/PreviewImgModal' import ProofInfoModal from '@views/MessagePage/modules/ProofInfoModal' import { getAuditProofRecords } from '@api/incomePaymentsApi' +import { convertToChinaNum } from '@/utils/util' const columns = [ { @@ -171,7 +172,7 @@ const columns = [ width: 120, align: 'center', customRender: function (t, r, index) { - return r.paymentStatus === 'completed' ? `${ parseInt(index) + 1 }阶段` : '' + return r.paymentStatus === 'completed' ? `${ convertToChinaNum(parseInt(index) + 1) }阶段` : '' } }, { title: '缴费金额', @@ -359,7 +360,8 @@ export default { }).finally(() => { this.proofLoading = false }) - } + }, + } }