56 lines
1.4 KiB
JavaScript
Executable File
56 lines
1.4 KiB
JavaScript
Executable File
/**
|
|
* 获取日期 yyyy-mm-dd hh:mm:ss
|
|
* @param {*} date
|
|
* @returns
|
|
*/
|
|
export function getDateTimeToString(date){
|
|
var year = date.getFullYear();
|
|
var month = date.getMonth()+1;
|
|
var day = date.getDate();
|
|
if(month<10) month = "0"+month;
|
|
if(day<10) day = "0"+day;
|
|
|
|
var hours = date.getHours();
|
|
var mins = date.getMinutes();
|
|
var secs = date.getSeconds();
|
|
// var msecs = date.getMilliseconds();
|
|
if(hours<10) hours = "0"+hours;
|
|
if(mins<10) mins = "0"+mins;
|
|
if(secs<10) secs = "0"+secs;
|
|
// if(msecs<10) secs = "0"+msecs;
|
|
return year+"-"+month+"-"+day+" "+hours+":"+mins+":"+secs;
|
|
}
|
|
|
|
/**
|
|
* 金额百分位
|
|
* @param {*} row
|
|
* @param {*} column
|
|
* @param {*} cellValue
|
|
* @returns
|
|
*/
|
|
export function rbstateFormat(cellValue){
|
|
if(cellValue !== null){
|
|
cellValue = Number(cellValue).toFixed(2)
|
|
cellValue += '';
|
|
if (!cellValue.includes('.')) cellValue += '.';
|
|
return cellValue.replace(/(\d)(?=(\d{2})+\.)/g, function ($0, $1) {
|
|
return $1;
|
|
}).replace(/\.$/, '');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 元转分
|
|
* @param {*} yuan
|
|
* @param {*} digit
|
|
* @returns
|
|
*/
|
|
export function yuanToFen(yuan,digit=100){
|
|
var m=0,
|
|
s1=yuan.toString(),
|
|
s2=digit.toString();
|
|
try{m+=s1.split(".")[1].length}catch(e){}
|
|
try{m+=s2.split(".")[1].length}catch(e){}
|
|
return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
|
|
}
|