Commit 69dce9e7 by Sweet Zhang

千分位

parent 27b18981
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
<script> <script>
import api from "../../api/api"; import api from "../../api/api";
import {reactive,provide} from "vue";
export default { export default {
data() { data() {
return { return {
...@@ -228,32 +229,36 @@ ...@@ -228,32 +229,36 @@
return; return;
} }
} }
const params = { const params = reactive({
...this.calcuteData, ...this.calcuteData,
calcuteMethod:2, calcuteMethod:2,
decimal:5, decimal:5,
irrAndSimpleInfos:this.policyYearLists irrAndSimpleInfos:this.policyYearLists
}; });
api.irrAndSimpleCalcute(params).then(res=>{ provide("dataImportIrrAndSimpleCalcuteParams", params);
if(res.success === true){ uni.navigateTo({
this.irrAndSimpleResInfos = res.data.irrAndSimpleResInfos; url: '/pages/index/index'
// this.resultShowFlag = true; });
//计算成功返回上一页 // api.irrAndSimpleCalcute(params).then(res=>{
uni.setStorageSync('resIrrAndSimpleResInfos',this.irrAndSimpleResInfos); // if(res.success === true){
// uni.navigateBack({ // this.irrAndSimpleResInfos = res.data.irrAndSimpleResInfos;
// delta:1,//返回层数,2则上上页 // // this.resultShowFlag = true;
// }) // //计算成功返回上一页
uni.navigateTo({ // uni.setStorageSync('resIrrAndSimpleResInfos',this.irrAndSimpleResInfos);
url: '/pages/index/index?isBack=1' // // uni.navigateBack({
}); // // delta:1,//返回层数,2则上上页
}else{ // // })
uni.showToast({ // uni.navigateTo({
title: res['message'], // url: '/pages/index/index?isBack=1'
duration: 2000, // });
icon: 'none' // }else{
}) // uni.showToast({
} // title: res['message'],
}) // duration: 2000,
// icon: 'none'
// })
// }
// })
} }
} }
......
...@@ -167,7 +167,7 @@ ...@@ -167,7 +167,7 @@
</view> </view>
<view class="resultTd" v-for="item in resIrrAndSimpleResInfos"> <view class="resultTd" v-for="item in resIrrAndSimpleResInfos">
<text>{{item.nyear}}</text> <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.irrValue*100).toFixed(3)}}%</text>
<text class="resultNumber">{{(item.simpleValue * 100).toFixed(3)}}%</text> <text class="resultNumber">{{(item.simpleValue * 100).toFixed(3)}}%</text>
</view> </view>
...@@ -200,6 +200,7 @@ ...@@ -200,6 +200,7 @@
import {nanoid} from 'nanoid'; import {nanoid} from 'nanoid';
import dataHandling from "../../util/dataHandling"; import dataHandling from "../../util/dataHandling";
import dataImport from "../dataImport/data-import.vue"; import dataImport from "../dataImport/data-import.vue";
import { inject } from "vue";
export default { export default {
data() { data() {
...@@ -280,6 +281,10 @@ ...@@ -280,6 +281,10 @@
} }
}, },
methods: { methods: {
// 数字千分位处理
numberConverter(val){
return dataHandling.numberConverter(val)
},
// 封装报错弹窗 // 封装报错弹窗
errorDialog(type,content){ errorDialog(type,content){
// type 1 必填项校验 2 规则校验 // type 1 必填项校验 2 规则校验
......
...@@ -7,5 +7,22 @@ export default{ ...@@ -7,5 +7,22 @@ export default{
return r[2]; return r[2];
} }
return null; 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