| | |
| | | </template> |
| | | <el-table :data="categorySummary" stripe class="lux-table" height="260"> |
| | | <el-table-column prop="category" label="产品类别" min-width="140" /> |
| | | <el-table-column prop="totalQuantity" label="用量" align="right" min-width="120"> |
| | | <template #default="scope"> |
| | | <span class="quantity-cell"> |
| | | <span class="quantity-value">{{ formatNumber(scope.row.totalQuantity, 2) }}</span> |
| | | <span class="quantity-unit">{{ scope.row.unit || "-" }}</span> |
| | | </span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="totalCost" label="成本(元)" align="right"> |
| | | <template #default="scope"> |
| | | <span class="cost-value">¥{{ formatMoney(scope.row.totalCost) }}</span> |
| | |
| | | <el-table :data="orderSummary" stripe class="lux-table" height="260"> |
| | | <el-table-column prop="orderNo" label="生产订单" min-width="150" /> |
| | | <el-table-column prop="category" label="产品类别" min-width="120" /> |
| | | <el-table-column prop="totalQuantity" label="用量" align="right" min-width="120"> |
| | | <template #default="scope"> |
| | | <span class="quantity-cell"> |
| | | <span class="quantity-value">{{ formatNumber(scope.row.totalQuantity, 2) }}</span> |
| | | <span class="quantity-unit">{{ scope.row.unit || "-" }}</span> |
| | | </span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="totalCost" label="总成本(元)" align="right"> |
| | | <template #default="scope"> |
| | | <span class="cost-value">¥{{ formatMoney(scope.row.totalCost) }}</span> |
| | |
| | | <el-table-column prop="timeLabel" :label="timeColumnLabel" min-width="110" /> |
| | | <el-table-column prop="category" label="产品类别" min-width="120" /> |
| | | <el-table-column prop="orderNo" label="生产订单" min-width="150" /> |
| | | <el-table-column prop="totalQuantity" label="用量" align="right" min-width="130"> |
| | | <template #default="scope"> |
| | | <span class="quantity-cell"> |
| | | <span class="quantity-value">{{ formatNumber(scope.row.totalQuantity, 2) }}</span> |
| | | <span class="quantity-unit">{{ scope.row.unit || "-" }}</span> |
| | | </span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="totalCost" label="成本(元)" align="right"> |
| | | <template #default="scope"> |
| | | <span class="cost-value">¥{{ formatMoney(scope.row.totalCost) }}</span> |
| | |
| | | if (!map.has(key)) { |
| | | map.set(key, { |
| | | totalCost: 0, |
| | | totalQuantity: 0, |
| | | materials: [], |
| | | }); |
| | | } |
| | | const bucket = map.get(key); |
| | | bucket.totalCost += item.cost; |
| | | bucket.totalQuantity += Number(item.quantity) || 0; |
| | | bucket.materials.push(item); |
| | | } |
| | | return map; |
| | |
| | | timeLabel, |
| | | category, |
| | | orderNo, |
| | | totalQuantity: val.totalQuantity, |
| | | unit: val.materials[0]?.unit || "", |
| | | totalCost: val.totalCost, |
| | | materials: val.materials, |
| | | }); |
| | |
| | | for (const [category, val] of map) { |
| | | rows.push({ |
| | | category, |
| | | totalQuantity: val.totalQuantity, |
| | | unit: val.materials[0]?.unit || "", |
| | | totalCost: val.totalCost, |
| | | }); |
| | | } |
| | |
| | | rows.push({ |
| | | orderNo, |
| | | category: val.materials[0]?.category || "-", |
| | | totalQuantity: val.totalQuantity, |
| | | unit: val.materials[0]?.unit || "", |
| | | totalCost: val.totalCost, |
| | | }); |
| | | } |
| | |
| | | }; |
| | | |
| | | const handleExport = () => { |
| | | const headers = [timeColumnLabel.value, "产品类别", "生产订单", "成本(元)"]; |
| | | const headers = [timeColumnLabel.value, "产品类别", "生产订单", "用量", "单位", "成本(元)"]; |
| | | const lines = tableData.value.map((row) => |
| | | [ |
| | | row.timeLabel, |
| | | row.category, |
| | | row.orderNo, |
| | | row.totalQuantity.toFixed(2), |
| | | row.unit || "", |
| | | row.totalCost.toFixed(2), |
| | | ].join(",") |
| | | ); |