|
@@ -793,33 +793,53 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
//合计
|
|
|
- getSum(param) {
|
|
|
+ getSum(param) {
|
|
|
const { columns, data } = param;
|
|
|
const sums = [];
|
|
|
+ var values = [];
|
|
|
columns.forEach((column, index) => {
|
|
|
if (index === 0) {
|
|
|
- sums[index] = "总计";
|
|
|
- } else if (
|
|
|
- index === 13 ||
|
|
|
- index === 10 ||
|
|
|
- index === 11 ||
|
|
|
- index === 12
|
|
|
+ sums[index] = "";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (column.property === "fGrossweight") {
|
|
|
+ values = data.map((item) => Number(item["fGrossweight"]));
|
|
|
+ }
|
|
|
+ if (column.property === "fNetweight") {
|
|
|
+ values = data.map((item) => Number(item["fNetweight"]));
|
|
|
+ }
|
|
|
+ if (column.property === "fQty") {
|
|
|
+ values = data.map((item) => Number(item["fQty"]));
|
|
|
+ }
|
|
|
+ if (column.property === "fPlanqty") {
|
|
|
+ values = data.map((item) => Number(item.fPlanqty));
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ column.property === "fGrossweight" ||
|
|
|
+ column.property === "fNetweight" ||
|
|
|
+ column.property === "fQty" ||
|
|
|
+ column.property === "fPlanqty"
|
|
|
) {
|
|
|
- const values = data.map((item) => Number(item[column.property]));
|
|
|
- if (!values.every((value) => isNaN(value))) {
|
|
|
- sums[index] = values.reduce((prev, curr) => {
|
|
|
- const value = Number(curr);
|
|
|
- if (!isNaN(value)) {
|
|
|
- return prev + curr;
|
|
|
- } else {
|
|
|
- return prev;
|
|
|
- }
|
|
|
- }, 0);
|
|
|
- if (index === 13 || index === 12) {
|
|
|
- sums[index] = (sums[index] / 1000).toFixed(2) + "(吨)";
|
|
|
+ sums[index] = values.reduce((prev, curr) => {
|
|
|
+ const value = Number(curr);
|
|
|
+ if (!isNaN(value)) {
|
|
|
+ return prev + curr;
|
|
|
+ } else {
|
|
|
+ return prev;
|
|
|
}
|
|
|
- if (index === 11) {
|
|
|
- sums[index] = sums[index];
|
|
|
+ }, 0);
|
|
|
+ if (column.property === "fGrossweight") {
|
|
|
+ sums[index] = sums[index].toFixed(2) + "吨";
|
|
|
+ }
|
|
|
+ if (column.property === "fNetweight") {
|
|
|
+ sums[index] = sums[index].toFixed(2) + "吨";
|
|
|
+ }
|
|
|
+ if (column.property === "fQty") {
|
|
|
+ sums[index] = sums[index].toFixed(2);
|
|
|
+ }
|
|
|
+ if (column.property === "fPlanqty") {
|
|
|
+ if (sums[index]) {
|
|
|
+ sums[index] = sums[index]
|
|
|
}
|
|
|
}
|
|
|
}
|