js 输出数据类型为decimal(18, 2),加0

<script>
function fixed(str) {
if (!str) str = '0.00';
let ret = Math.round(parseFloat(str) * 100) / 100;
let decimal = ret.toString().split('.');
if (decimal.length === 1) {
return ret.toString() + '.00'
};
if (decimal.length > 1) {
if (decimal[1].length < 2) {
return ret.toString() + '0'
}
return ret
};
return ret;
}
</script>
<script type="text/html" id="tplMoney">{{fixed(d.inputMoney)}}</script>
数据表格列设置
{field: 'inputMoney', title: '投入总资金', width: 105, templet: '#tplMoney'}
posted @ 2018-11-13 17:37  #i小龙#  阅读(2016)  评论(0编辑  收藏  举报