瀏覽代碼

🎨 feat<任务管理>:计划销售额数据展示样式优化

xinyan 7 月之前
父節點
當前提交
a68e739dbd
共有 1 個文件被更改,包括 28 次插入13 次删除
  1. 28 13
      src/views/reportManage/dataCenter/utils/columns.ts

+ 28 - 13
src/views/reportManage/dataCenter/utils/columns.ts

@@ -300,23 +300,38 @@ export const monthDataColumns = ref([
 ]);
 
 // 计划销售额
+function formatEmptyCell(cellValue) {
+  if (cellValue === null || cellValue === undefined || cellValue === '') {
+    return '--';
+  }
+
+  else {
+    const formatter = new Intl.NumberFormat('en-US', {
+      minimumFractionDigits: 2,
+    });
+    return formatter.format(cellValue);
+  }
+
+  // return cellValue; // 如果不是数字,返回原值
+}
+
 export const planSalesColumns = ref([
   // { field: 'platformNumber', title: '平台编号', fixed: 'left', width: 81, align: 'center' },
   // { field: 'platformName', title: '平台名称', fixed: 'left', width: 142, align: 'center' ,},
   // { field: 'country', title: '国家', fixed: 'left', width: 80, align: 'center' },
   // { field: 'brandName', title: '品牌', fixed: 'left', width: 90 ,align: 'center'},
   // { field: 'operater', title: '运营', fixed: 'left', width: 80, align: 'center' },
-    ...universal,
-  { field: '1月', title: '1月计划销售额', minWidth: 90, align: 'center' ,formatter: ({ cellValue }) => cellValue?.planSales || '--' },
-  { field: '2月', title: '2月计划销售额', minWidth: 95,  align: 'center' ,formatter: ({ cellValue }) => cellValue?.planSales || '--'},
-  { field: '3月', title: '3月计划销售额', minWidth: 95,  align: 'center' ,formatter: ({ cellValue }) => cellValue?.planSales || '--'},
-  { field: '4月', title: '4月计划销售额', minWidth: 95,  align: 'center' ,formatter: ({ cellValue }) => cellValue?.planSales || '--'},
-  { field: '5月', title: '5月计划销售额', minWidth: 95,  align: 'center' ,formatter: ({ cellValue }) => cellValue?.planSales || '--'},
-  { field: '6月', title: '6月计划销售额', minWidth: 95, align: 'center' ,formatter: ({ cellValue }) => cellValue?.planSales || '--'},
-  { field: '7月', title: '7月计划销售额', minWidth: 95,  align: 'center' ,formatter: ({ cellValue }) => cellValue?.planSales || '--'},
-  { field: '8月', title: '8月计划销售额', minWidth: 95,  align: 'center' ,formatter: ({ cellValue }) => cellValue?.planSales || '--'},
-  { field: '9月', title: '9月计划销售额', minWidth: 95,  align: 'center' ,formatter: ({ cellValue }) => cellValue?.planSales || '--'},
-  { field: '10月', title: '10月计划销售额', minWidth: 95,  align: 'center' ,formatter: ({ cellValue }) => cellValue?.planSales || '--'},
-  { field: '11月', title: '11月计划销售额', minWidth: 95,  align: 'center' ,formatter: ({ cellValue }) => cellValue?.planSales || '--'},
-  { field: '12月', title: '12月计划销售额', minWidth: 95,  align: 'center' ,formatter: ({ cellValue }) => cellValue?.planSales || '--'},
+  ...universal,
+  { field: '1月', title: '1月计划销售额', minWidth: 105, align: 'center', formatter: ({ cellValue }) => formatEmptyCell(cellValue?.planSales) },
+  { field: '2月', title: '2月计划销售额', minWidth: 105, align: 'center', formatter: ({ cellValue }) => formatEmptyCell(cellValue?.planSales) },
+  { field: '3月', title: '3月计划销售额', minWidth: 105, align: 'center', formatter: ({ cellValue }) => formatEmptyCell(cellValue?.planSales) },
+  { field: '4月', title: '4月计划销售额', minWidth: 105, align: 'center', formatter: ({ cellValue }) => formatEmptyCell(cellValue?.planSales) },
+  { field: '5月', title: '5月计划销售额', minWidth: 105, align: 'center', formatter: ({ cellValue }) => formatEmptyCell(cellValue?.planSales) },
+  { field: '6月', title: '6月计划销售额', minWidth: 105, align: 'center', formatter: ({ cellValue }) => formatEmptyCell(cellValue?.planSales) },
+  { field: '7月', title: '7月计划销售额', minWidth: 105, align: 'center', formatter: ({ cellValue }) => formatEmptyCell(cellValue?.planSales) },
+  { field: '8月', title: '8月计划销售额', minWidth: 105, align: 'center', formatter: ({ cellValue }) => formatEmptyCell(cellValue?.planSales) },
+  { field: '9月', title: '9月计划销售额', minWidth: 105, align: 'center', formatter: ({ cellValue }) => formatEmptyCell(cellValue?.planSales) },
+  { field: '10月', title: '10月计划销售额', minWidth: 105, align: 'center', formatter: ({ cellValue }) => formatEmptyCell(cellValue?.planSales) },
+  { field: '11月', title: '11月计划销售额', minWidth: 105, align: 'center', formatter: ({ cellValue }) => formatEmptyCell(cellValue?.planSales) },
+  { field: '12月', title: '12月计划销售额', minWidth: 105, align: 'center', formatter: ({ cellValue }) => formatEmptyCell(cellValue?.planSales) },
 ])