Commit 33d24b65c8e13a06ce23f34b5449aab508e562dc
1 parent
d1ba992a
调整
Showing
2 changed files
with
86 additions
and
0 deletions
trash-ui/dist.zip
0 → 100644
No preview for this file type
trash-ui/src/views/gar/order/index.vue
| @@ -56,6 +56,20 @@ | @@ -56,6 +56,20 @@ | ||
| 56 | </template> | 56 | </template> |
| 57 | </el-table-column> | 57 | </el-table-column> |
| 58 | <el-table-column label="车辆数量" align="center" prop="garRealCarCount" /> | 58 | <el-table-column label="车辆数量" align="center" prop="garRealCarCount" /> |
| 59 | + <el-table-column label="未发车数" align="center"> | ||
| 60 | + <template slot-scope="scope"> | ||
| 61 | + <span v-if="scope.row.unDispatchedCount !== undefined && scope.row.unDispatchedCount > 0" | ||
| 62 | + style="color: red; font-weight: bold;"> | ||
| 63 | + {{ scope.row.unDispatchedCount }} | ||
| 64 | + </span> | ||
| 65 | + <span v-else-if="scope.row.unDispatchedCount === 0 || scope.row.unDispatchedCount === 0"> | ||
| 66 | + 0 | ||
| 67 | + </span> | ||
| 68 | + <span v-else> | ||
| 69 | + <i class="el-icon-loading"></i> | ||
| 70 | + </span> | ||
| 71 | + </template> | ||
| 72 | + </el-table-column> | ||
| 59 | <!-- <el-table-column label="车子类型" width="200px" align="center" prop="garOrderCarType" />--> | 73 | <!-- <el-table-column label="车子类型" width="200px" align="center" prop="garOrderCarType" />--> |
| 60 | <el-table-column fixed="right" label="操作" width="200px" align="center" class-name="small-padding fixed-width"> | 74 | <el-table-column fixed="right" label="操作" width="200px" align="center" class-name="small-padding fixed-width"> |
| 61 | <template slot-scope="scope"> | 75 | <template slot-scope="scope"> |
| @@ -399,7 +413,12 @@ export default { | @@ -399,7 +413,12 @@ export default { | ||
| 399 | this.loading = true; | 413 | this.loading = true; |
| 400 | listOrder(this.queryParams).then(response => { | 414 | listOrder(this.queryParams).then(response => { |
| 401 | this.orderList = response.data.list; | 415 | this.orderList = response.data.list; |
| 416 | + console.log(response.data.list) | ||
| 402 | this.total = response.data.total; | 417 | this.total = response.data.total; |
| 418 | + | ||
| 419 | + // 自动加载所有订单的未发车信息 | ||
| 420 | + this.loadAllUnDispatchedInfo(); | ||
| 421 | + | ||
| 403 | this.loading = false; | 422 | this.loading = false; |
| 404 | }); | 423 | }); |
| 405 | }, | 424 | }, |
| @@ -457,6 +476,73 @@ export default { | @@ -457,6 +476,73 @@ export default { | ||
| 457 | this.single = selection.length !== 1 | 476 | this.single = selection.length !== 1 |
| 458 | this.multiple = !selection.length | 477 | this.multiple = !selection.length |
| 459 | }, | 478 | }, |
| 479 | + /** | ||
| 480 | + * 批量加载所有订单的未发车信息(带并发限制) | ||
| 481 | + */ | ||
| 482 | + loadAllUnDispatchedInfo() { | ||
| 483 | + if (!this.orderList || this.orderList.length === 0) { | ||
| 484 | + return; | ||
| 485 | + } | ||
| 486 | + | ||
| 487 | + // 限制并发请求数量 | ||
| 488 | + const concurrencyLimit = 5; | ||
| 489 | + const results = []; | ||
| 490 | + let index = 0; | ||
| 491 | + | ||
| 492 | + const processBatch = () => { | ||
| 493 | + const batch = []; | ||
| 494 | + for (let i = 0; i < concurrencyLimit && index < this.orderList.length; i++, index++) { | ||
| 495 | + const order = this.orderList[index]; | ||
| 496 | + batch.push( | ||
| 497 | + getOrder(order.garOrderId).then(response => { | ||
| 498 | + const detailData = response.data; | ||
| 499 | + let unsentCount = 0; | ||
| 500 | + | ||
| 501 | + // 使用与详情页相同的逻辑计算未发车次数 | ||
| 502 | + if (detailData.carReports && detailData.carReports.length > 0) { | ||
| 503 | + detailData.carReports.forEach(carReport => { | ||
| 504 | + // 如果车牌号或载重为空,则认为未发车(与详情页保持一致) | ||
| 505 | + if (!carReport.carNo || !carReport.carWeight) { | ||
| 506 | + unsentCount++; | ||
| 507 | + } | ||
| 508 | + }); | ||
| 509 | + } | ||
| 510 | + | ||
| 511 | + return { | ||
| 512 | + orderId: order.garOrderId, | ||
| 513 | + unDispatchedCount: unsentCount | ||
| 514 | + }; | ||
| 515 | + }).catch(error => { | ||
| 516 | + console.error(`获取订单 ${order.garOrderId} 详情失败:`, error); | ||
| 517 | + return { | ||
| 518 | + orderId: order.garOrderId, | ||
| 519 | + unDispatchedCount: 0 | ||
| 520 | + }; | ||
| 521 | + }) | ||
| 522 | + ); | ||
| 523 | + } | ||
| 524 | + | ||
| 525 | + if (batch.length === 0) { | ||
| 526 | + // 所有请求处理完毕,更新界面 | ||
| 527 | + results.forEach(result => { | ||
| 528 | + const idx = this.orderList.findIndex(item => item.garOrderId === result.orderId); | ||
| 529 | + if (idx !== -1) { | ||
| 530 | + this.$set(this.orderList[idx], 'unDispatchedCount', result.unDispatchedCount); | ||
| 531 | + } | ||
| 532 | + }); | ||
| 533 | + return; | ||
| 534 | + } | ||
| 535 | + | ||
| 536 | + Promise.all(batch).then(batchResults => { | ||
| 537 | + results.push(...batchResults); | ||
| 538 | + // 继续处理下一批 | ||
| 539 | + processBatch(); | ||
| 540 | + }); | ||
| 541 | + }; | ||
| 542 | + | ||
| 543 | + // 开始处理 | ||
| 544 | + processBatch(); | ||
| 545 | + }, | ||
| 460 | /** 修改按钮操作 */ | 546 | /** 修改按钮操作 */ |
| 461 | handleUpdate(row) { | 547 | handleUpdate(row) { |
| 462 | this.reset(); | 548 | this.reset(); |