保留两个小数

This commit is contained in:
stt
2025-11-14 16:18:38 +08:00
parent af05b9c810
commit f66dd649c7

View File

@@ -93,7 +93,11 @@ const tableStore: any = new TableStore({
minWidth: '60', minWidth: '60',
render: 'customTemplate', render: 'customTemplate',
customTemplate: (row: any) => { customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.maxValue}</span>` const extentValue =
row.maxValue !== null && row.maxValue !== undefined && row.maxValue !== ''
? Math.floor(row.maxValue * 100) / 100
: '/'
return `<span style='cursor: pointer;text-decoration: underline;'>${extentValue}</span>`
} }
}, },
{ {
@@ -104,7 +108,16 @@ const tableStore: any = new TableStore({
{ {
title: '越限程度(%)', title: '越限程度(%)',
field: 'extent', field: 'extent',
minWidth: '60' minWidth: '60',
render: 'customTemplate',
customTemplate: (row: any) => {
// 保留两个小数
const extentValue =
row.extent !== null && row.extent !== undefined && row.extent !== ''
? Math.floor(row.extent * 100) / 100
: '/'
return `<span>${extentValue}</span>`
}
}, },
{ {
title: '发生日期', title: '发生日期',
@@ -145,8 +158,9 @@ const tableStore: any = new TableStore({
const chartData = xAxisLabels.map(label => { const chartData = xAxisLabels.map(label => {
// 在表格数据中查找对应指标名称的数据项 // 在表格数据中查找对应指标名称的数据项
const item = tableStore.table.data.find((row: any) => row.name === label) const item = tableStore.table.data.find((row: any) => row.name === label)
// 如果找到对应项,则返回 extent 值,否则返回 0 // 如果找到对应项,则返回 extent 值,否则返回 0,并保留两位小数
return item ? item.extent || 0 : 0 const extentValue = item ? item.extent || 0 : 0
return Math.round(extentValue * 100) / 100
}) })
echartList.value = { echartList.value = {
title: { title: {