index.js 3.1 KB
import locale from '../assets/i18n/i18n'

var formatHuman = (val) => {
    if (!val) return '--';
    let humanNum = null;
    humanNum = val >= 100000 ? (val / 10000).toFixed(2) : val;
    // humanNum = val;
    return humanNum;
}

var formatHumanUnit = (val) => {
    if (!val) return '';
    let humanUnit = null;
    humanUnit = val >= 100000 ? locale.t('format.millionTime') : locale.t('format.perTime');
    // humanUnit = '人次';
    return humanUnit;
}

var formatEffHuman = (val) => {
    if (!val) return '--';
    let humanNum = null;
    humanNum = val >= 100000 ? (val / 10000).toFixed(2) : val;
    // humanNum = val;
    return humanNum;
}

var formatEffHumanUnit = (val) => {
    if (!val) return '';
    let humanUnit = null;
    humanUnit = val >= 100000 ? locale.t('format.millionNum') : locale.t('format.perNum');
    // humanUnit = '人';
    return humanUnit;
}

var formatSales = (val) => {
    if (!val) return '--';
    let salesNum = null;
    salesNum = (val >= 100000) ? (val / 10000).toFixed(2) : val;
    // salesNum = val;
    return salesNum;
}

var formatSalesUnit = (val) => {
    if (!val) return '';
    let salesUnit = null;
    salesUnit = (val >= 100000) ? locale.t('format.salesUnit') : locale.t('format.saleUnit');
    // salesUnit = '元';
    return salesUnit;
}

var formatArea = (val) => {
    if (!val) return '--';
    let areaNum = null;
    areaNum = (val >= 100000) ? (val / 10000).toFixed(2) : val;
    // areaNum = val;
    return areaNum;
}
var formatAreaUnit = (val) => {
    if (!val) return '';
    let areaUnit = null;
    areaUnit = (val >= 100000) ? locale.t('format.millionSquareM') : locale.t('format.squareMeters');
    // areaUnit = '平米';
    return areaUnit;
}

var formatTime = (val) => {
    if (!val || isNaN(Number(val))) return '--';
    let timeNum = null;
    timeNum = (val >= 1) ? val : (val * 60).toFixed(2);
    // timeNum = val * 60;
    return timeNum;
}

var formatTimeUnit = (val) => {
    if (!val) return '';
    let timeUnit = null;
    timeUnit = (val >= 1) ? locale.t('format.hoursUnit') : locale.t('format.minutesUnit');
    // timeUnit = '分';
    return timeUnit;
}

var formatDensity = (val) => {
    if (!val) return '';
    let densityNum = null;
    densityNum = (val > 100000) ? (val / 10000).toFixed(2) : val;
    return densityNum;
}

var formatDensityUnit = (val) => {
    if (!val) return '';
    let DensityUnit = null;
    DensityUnit = (val > 100000) ? locale.t('format.millionTime') : locale.t('format.perTime');
    return DensityUnit;
}

var formatdayDensity = (val) => {
    if (!val) return '';
    let densityNum = null;
    densityNum = (val > 100000) ? (val / 10000).toFixed(2) : val;
    return densityNum;
}

var formatdayDensityUnit = (val) => {
    if (!val) return '';
    let DensityUnit = null;
    DensityUnit = (val > 100000) ? locale.t('format.millionflDensity') : locale.t('format.flDensity');
    return DensityUnit;
}
export { formatHuman, formatHumanUnit, formatEffHuman, formatEffHumanUnit, formatSales, formatSalesUnit, formatArea, formatAreaUnit, formatTime, formatTimeUnit, formatDensity, formatDensityUnit, formatdayDensity, formatdayDensityUnit}