diff --git a/src/utils/index.js b/src/utils/index.js index dc2d15808b8b3b5c6c2277cc3ed5c262a4561d76..43759a909952542e74119d86b928cf5cc915e28d 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -153,7 +153,7 @@ export function getInfoByIdCard(idCard, type = "birthDate") { d.getFullYear() - birthdays.getFullYear() - (d.getMonth() < birthdays.getMonth() || - (d.getMonth() == birthdays.getMonth() && d.getDate() < birthdays.getDate()) + (d.getMonth() == birthdays.getMonth() && d.getDate() < birthdays.getDate()) ? 1 : 0) @@ -182,12 +182,12 @@ export function paramObj(url) { } return JSON.parse( '{"' + - decodeURIComponent(search) - .replace(/"/g, '\\"') - .replace(/&/g, '","') - .replace(/=/g, '":"') - .replace(/\+/g, " ") + - '"}' + decodeURIComponent(search) + .replace(/"/g, '\\"') + .replace(/&/g, '","') + .replace(/=/g, '":"') + .replace(/\+/g, " ") + + '"}' ) } @@ -522,7 +522,51 @@ export function changeTime(time) { let seconds = Math.floor(time % 60) //秒 return `${day ? day + "天" : ""} ${hours ? hours + "小时" : ""}${ minutes ? minutes + "分" : "" - }${seconds}秒` + }${seconds}秒` } -export default { formatDicList, excelExport } +/** + * 数字转中文(万亿一下) + * @export + * @param num + * @returns {string} + */ +export function toChineseNumber(num) { + const str = num + .toString() + .replace(/(?=(\d{4})+$)/g, ",") + .split(",") + .filter(Boolean) + const chars = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九"] + const units = ["", "十", "百", "千"] + const bigUnits = ["", "万", "亿"] + function _transform(numStr) { + let result = "" + for (let i = 0; i < numStr.length; i++) { + const digit = +numStr[i] + const c = chars[digit] + const u = units[numStr.length - 1 - i] + if (digit === 0) { + if (result[result.length - 1] !== chars[0]) { + result += c + } + } else { + result += c + u + } + } + if (result[result.length - 1] === chars[0]) { + result = result.slice(0, -1) + } + return result + } + let result = "" + for (let i = 0; i < str.length; i++) { + const part = str[i] + const c = _transform(part) + const u = c ? bigUnits[str.length - 1 - i] : "" + result += c + u + } + return result +} + +export default { formatDicList, excelExport, toChineseNumber } diff --git a/src/views/followupquery/FollowUpDetail.vue b/src/views/followupquery/FollowUpDetail.vue index afc204d105b457c26d963de5728b734a7b179026..ffa5171b57f57fa64147eeeafcba1322618d5421 100644 --- a/src/views/followupquery/FollowUpDetail.vue +++ b/src/views/followupquery/FollowUpDetail.vue @@ -5,6 +5,8 @@ titlePosition="top" @update="update" > + +