[Frontend]報表固定欄寬度修正

This commit is contained in:
Celeste 2023-09-08 12:59:42 +08:00
parent 40fcbb3f8d
commit 3a8d5fb81c

View File

@ -806,12 +806,12 @@
switch (tableType) { switch (tableType) {
case "day": case "day":
columns = getDayByMonth($("#elecMonthDate").val()).map((dc) => { columns = getDayByMonth($("#elecMonthDate").val()).map((dc) => {
return { title: dc, data: dc, sWidth: columnWidth }; return { title: dc, data: dc, width: columnWidth };
}); });
break; break;
case "month": case "month":
columns = getMonthByYear($("#elecYearDate").val()).map((dc) => { columns = getMonthByYear($("#elecYearDate").val()).map((dc) => {
return { title: dc, data: dc, sWidth: columnWidth }; return { title: dc, data: dc, width: columnWidth };
}); });
break; break;
case "year": case "year":
@ -819,7 +819,7 @@
$("#elecSYearDate").val(), $("#elecSYearDate").val(),
$("#elecEYearDate").val() $("#elecEYearDate").val()
).map((dc) => { ).map((dc) => {
return { title: dc, data: dc, sWidth: columnWidth }; return { title: dc, data: dc, width: columnWidth };
}); });
break; break;
case "compare": case "compare":
@ -859,10 +859,10 @@
title: dc.value, title: dc.value,
data: dc.value, data: dc.value,
sClass: "compare", sClass: "compare",
sWidth: columnWidth, width: columnWidth,
}; };
} }
return { title: dc, data: dc, sWidth: columnWidth }; return { title: dc, data: dc, width: columnWidth };
}); });
break; break;
@ -909,7 +909,7 @@
value: "last year different", value: "last year different",
}, },
].map((dc) => { ].map((dc) => {
return { title: dc.label, data: dc.value, sWidth: "120px" }; return { title: dc.label, data: dc.value, width: "120px" };
}); });
} else { } else {
datesColumns = setTableColumns(); datesColumns = setTableColumns();
@ -929,12 +929,14 @@
{ {
title: "小計", title: "小計",
data: "total", data: "total",
sWidth: "70px", width: "70px",
className: "text-nowrap",
}, },
{ {
title: "單價", title: "單價",
data: "price", data: "price",
sWidth: "45px", width: "45px",
className: "text-nowrap",
render: function (data) { render: function (data) {
return parseInt(data) === 0 ? "" : data; return parseInt(data) === 0 ? "" : data;
}, },
@ -942,7 +944,8 @@
{ {
title: "金額總計", title: "金額總計",
data: "total_price", data: "total_price",
sWidth: "70px", width: "70px",
className: "text-nowrap",
render: function (data) { render: function (data) {
return parseInt(data) === 0 ? "" : data; return parseInt(data) === 0 ? "" : data;
}, },
@ -966,11 +969,12 @@
totalColumns.splice(i + 1, 0, { totalColumns.splice(i + 1, 0, {
title: com2Time + c.title, title: com2Time + c.title,
data: "_compare_" + c.data, data: "_compare_" + c.data,
sWidth: "70px", width: "70px",
sClass: "compare", sClass: "compare text-nowrap",
}); });
c.title = com1Time + c.title; c.title = com1Time + c.title;
c.sWidth = "70px"; c.width = "70px";
c.className = "text-nowrap";
} }
} }
} }
@ -979,10 +983,13 @@
data: datas, data: datas,
destroy: true, destroy: true,
sDom: '<"toolbar">tipl', sDom: '<"toolbar">tipl',
fixedColumns: { left: 3, right: tableType == "compare" ? 2 : 3 }, fixedColumns: {
leftColumns: 3,
rightColumns: tableType == "compare" ? 2 : 3,
},
scrollX: "auto", scrollX: "auto",
scrollCollapse: true, scrollCollapse: true,
autoWidth: true, autoWidth: false,
language: { url: "/file/BajascriptTest/js/dataTables/zh-HANT.json" }, language: { url: "/file/BajascriptTest/js/dataTables/zh-HANT.json" },
aaSorting: [], aaSorting: [],
columns: [ columns: [
@ -990,18 +997,19 @@
title: "棟別", title: "棟別",
data: "building_name", data: "building_name",
className: "text-nowrap", className: "text-nowrap",
sWidth: "100px", width: "100px",
}, },
{ {
title: "樓層", title: "樓層",
data: "floor_tag", data: "floor_tag",
sWidth: "8%", width: "8%",
className: "text-nowrap", className: "text-nowrap",
}, },
{ {
title: "設備", title: "設備",
data: "device_full_name", data: "device_full_name",
sWidth: "100px", width: "300px",
className: "text-nowrap",
}, },
...datesColumns, ...datesColumns,
...(ElecEachTotal ? [] : totalColumns), ...(ElecEachTotal ? [] : totalColumns),