Commit 69dce9e7 by Sweet Zhang

千分位

parent 27b18981
......@@ -74,6 +74,7 @@
<script>
import api from "../../api/api";
import {reactive,provide} from "vue";
export default {
data() {
return {
......@@ -228,32 +229,36 @@
return;
}
}
const params = {
const params = reactive({
...this.calcuteData,
calcuteMethod:2,
decimal:5,
irrAndSimpleInfos:this.policyYearLists
};
api.irrAndSimpleCalcute(params).then(res=>{
if(res.success === true){
this.irrAndSimpleResInfos = res.data.irrAndSimpleResInfos;
// this.resultShowFlag = true;
//计算成功返回上一页
uni.setStorageSync('resIrrAndSimpleResInfos',this.irrAndSimpleResInfos);
// uni.navigateBack({
// delta:1,//返回层数,2则上上页
// })
uni.navigateTo({
url: '/pages/index/index?isBack=1'
});
}else{
uni.showToast({
title: res['message'],
duration: 2000,
icon: 'none'
})
}
})
});
provide("dataImportIrrAndSimpleCalcuteParams", params);
uni.navigateTo({
url: '/pages/index/index'
});
// api.irrAndSimpleCalcute(params).then(res=>{
// if(res.success === true){
// this.irrAndSimpleResInfos = res.data.irrAndSimpleResInfos;
// // this.resultShowFlag = true;
// //计算成功返回上一页
// uni.setStorageSync('resIrrAndSimpleResInfos',this.irrAndSimpleResInfos);
// // uni.navigateBack({
// // delta:1,//返回层数,2则上上页
// // })
// uni.navigateTo({
// url: '/pages/index/index?isBack=1'
// });
// }else{
// uni.showToast({
// title: res['message'],
// duration: 2000,
// icon: 'none'
// })
// }
// })
}
}
......
......@@ -167,7 +167,7 @@
</view>
<view class="resultTd" v-for="item in resIrrAndSimpleResInfos">
<text>{{item.nyear}}</text>
<text>{{item.cashValue}}</text>
<text>{{numberConverter(item.cashValue)}}</text>
<text class="resultNumber">{{(item.irrValue*100).toFixed(3)}}%</text>
<text class="resultNumber">{{(item.simpleValue * 100).toFixed(3)}}%</text>
</view>
......@@ -200,6 +200,7 @@
import {nanoid} from 'nanoid';
import dataHandling from "../../util/dataHandling";
import dataImport from "../dataImport/data-import.vue";
import { inject } from "vue";
export default {
data() {
......@@ -280,6 +281,10 @@
}
},
methods: {
// 数字千分位处理
numberConverter(val){
return dataHandling.numberConverter(val)
},
// 封装报错弹窗
errorDialog(type,content){
// type 1 必填项校验 2 规则校验
......
......@@ -7,5 +7,22 @@ export default{
return r[2];
}
return null;
},
// 数字千分位
numberConverter(value){
if (!value) return 0
// 获取整数部分
const intPart = Math.trunc(value)
// 整数部分处理,增加,
const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
// 预定义小数部分
let floatPart = ''
// 将数值截取为小数部分和整数部分
const valueArray = value.toString().split('.')
if (valueArray.length === 2) { // 有小数部分
floatPart = valueArray[1].toString() // 取得小数部分
return intPartFormat + '.' + floatPart
}
return intPartFormat + floatPart
}
}
\ No newline at end of file
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