吉安感知网项目-前端
张含笑
2026-01-30 6c4bd2467bb6651c6edcf8a9741dcd4e9b1aa6d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
import { Decimal } from 'decimal.js'
 
export function dataUnitConversion (data) {
    if (data > 10000000000) {
        return {
            val: new Decimal(data).dividedBy(1000000).toNumber().toFixed(2),
            unit: '万km²'
        }
    } else if (data > 1000000000) {
        return {
            val: new Decimal(data).dividedBy(1000000).toNumber().toFixed(2),
            unit: '千km²'
        }
    } else if (data > 1000000) {
        return {
            val: new Decimal(data).dividedBy(1000000).toNumber().toFixed(2),
            unit: 'km²'
        }
    } else {
        return {
            val: data.toFixed(2),
            unit: 'm²'
        }
    }
}