feat(planSheet): 新增排产单批量新增明细功能

实现了批量新增排产单明细的完整流程:添加批量新增按钮,开发批量选择合同和明细的对话框,支持搜索筛选合同、分页展示合同列表,多选明细后批量提交新增,新增成功后刷新列表
This commit is contained in:
2026-05-11 13:14:23 +08:00
parent 806b701c11
commit 07192f22bc

View File

@@ -9,6 +9,7 @@
<h3>{{ currentPlanSheetInfo.planSheetName || '排产单详情' }}</h3> <h3>{{ currentPlanSheetInfo.planSheetName || '排产单详情' }}</h3>
<div> <div>
<el-button type="primary" plain @click="handleAdd">新增明细</el-button> <el-button type="primary" plain @click="handleAdd">新增明细</el-button>
<el-button type="success" plain @click="handleBatchAdd">批量新增</el-button>
<el-button type="info" plain @click="getList">刷新</el-button> <el-button type="info" plain @click="getList">刷新</el-button>
</div> </div>
</div> </div>
@@ -287,6 +288,75 @@
<el-table-column label="备注" align="center" prop="remark" /> <el-table-column label="备注" align="center" prop="remark" />
</el-table> </el-table>
</el-dialog> </el-dialog>
<!-- 批量新增对话框 -->
<el-dialog title="批量新增" :visible.sync="batchAddDialogVisible" width="80%" append-to-body>
<div class="batch-add-content">
<!-- 合同选择 -->
<div class="contract-section">
<div class="section-title">选择合同</div>
<el-form :model="batchQueryParams" ref="batchQueryForm" size="small" :inline="true" label-width="80px">
<el-form-item label="合同号" prop="contractCode">
<el-input v-model="batchQueryParams.contractCode" placeholder="请输入合同号" style="width: 180px" />
</el-form-item>
<el-form-item label="客户">
<el-input v-model="batchQueryParams.customerName" placeholder="请输入客户名称" style="width: 180px" />
</el-form-item>
<el-form-item label="业务员">
<el-input v-model="batchQueryParams.salesman" placeholder="请输入业务员" style="width: 120px" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="getBatchOrderList">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetBatchQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table v-loading="batchOrderLoading" :data="batchOrderList" style="width: 100%" border @row-click="selectBatchContract"
highlight-current-row>
<el-table-column prop="contractCode" label="合同号" />
<el-table-column prop="signTime" label="签订时间" width="150" />
<el-table-column prop="signLocation" label="签订地点" />
<el-table-column prop="companyName" label="客户公司" />
<el-table-column prop="salesman" label="业务员" width="100" />
<el-table-column prop="deliveryDate" label="交货日期" width="150" />
<el-table-column label="操作" width="80" fixed="right">
<template slot-scope="scope">
<el-button type="text" size="small" @click.stop="selectBatchContract(scope.row)">选择</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination-container">
<el-pagination background layout="prev, pager, next, jumper" :total="batchOrderTotal"
:page-size="batchQueryParams.pageSize" :current-page.sync="batchQueryParams.pageNum"
@current-change="getBatchOrderList" />
</div>
</div>
<!-- 明细选择 -->
<div class="item-section" v-if="selectedContract">
<div class="section-title">选择明细多选</div>
<el-table v-loading="batchItemLoading" :data="batchItemList" style="width: 100%" border
@selection-change="handleBatchItemSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="产品类型" align="center" prop="productType" />
<el-table-column label="成品宽度" align="center" prop="width" />
<el-table-column label="成品厚度" align="center" prop="thickness" />
<el-table-column label="成品规格" align="center" prop="finishedProductSpec" />
<el-table-column label="材质" align="center" prop="material" />
<el-table-column label="重量" align="center" prop="weight" />
<el-table-column label="卷数" align="center" prop="productNum" />
<el-table-column label="表面处理" align="center" prop="surfaceTreatment" />
<el-table-column label="包装要求" align="center" prop="packagingReq" />
<el-table-column label="切边要求" align="center" prop="edgeCuttingReq" />
<el-table-column label="用途" align="center" prop="purpose" />
<el-table-column label="备注" align="center" prop="remark" />
</el-table>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="batchAddDialogVisible = false">取消</el-button>
<el-button type="primary" @click="confirmBatchAdd" :disabled="selectedBatchItems.length === 0">确认新增</el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
@@ -351,7 +421,31 @@ export default {
// 订单明细加载状态 // 订单明细加载状态
orderItemLoading: false, orderItemLoading: false,
// 当前编辑的行 // 当前编辑的行
currentEditingRow: null currentEditingRow: null,
// 批量新增对话框
batchAddDialogVisible: false,
// 批量查询参数
batchQueryParams: {
pageNum: 1,
pageSize: 10,
contractCode: undefined,
customerName: undefined,
salesman: undefined
},
// 批量订单列表
batchOrderList: [],
// 批量订单总数
batchOrderTotal: 0,
// 批量订单加载状态
batchOrderLoading: false,
// 批量明细列表
batchItemList: [],
// 批量明细加载状态
batchItemLoading: false,
// 选中的合同
selectedContract: null,
// 选中的明细
selectedBatchItems: []
}; };
}, },
created() { created() {
@@ -582,6 +676,98 @@ export default {
// 处理订单行点击 // 处理订单行点击
handleOrderSelect(row) { handleOrderSelect(row) {
this.selectOrder(row); this.selectOrder(row);
},
// 打开批量新增对话框
handleBatchAdd() {
this.batchAddDialogVisible = true;
this.selectedContract = null;
this.selectedBatchItems = [];
this.getBatchOrderList();
},
// 获取批量订单列表
getBatchOrderList() {
this.batchOrderLoading = true;
listOrder(this.batchQueryParams).then(response => {
this.batchOrderList = response.rows;
this.batchOrderTotal = response.total;
this.batchOrderLoading = false;
});
},
// 重置批量查询参数
resetBatchQuery() {
this.batchQueryParams = {
pageNum: 1,
pageSize: 10,
contractCode: undefined,
customerName: undefined,
salesman: undefined
};
this.getBatchOrderList();
},
// 选择批量合同
selectBatchContract(row) {
this.selectedContract = row;
this.selectedBatchItems = [];
this.batchItemLoading = true;
listOrderItem({ orderId: row.orderId }).then(res => {
this.batchItemList = res.rows;
this.batchItemLoading = false;
});
},
// 处理批量明细选择变更
handleBatchItemSelectionChange(selection) {
this.selectedBatchItems = selection;
},
// 确认批量新增
confirmBatchAdd() {
if (this.selectedBatchItems.length === 0) {
this.$message.warning('请至少选择一条明细');
return;
}
this.$confirm(`确认新增 ${this.selectedBatchItems.length} 条明细?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
const currentMaxSeqNo = this.planDetailList.length > 0
? Math.max(...this.planDetailList.map(item => parseInt(item.bizSeqNo) || 0))
: 0;
const addPromises = this.selectedBatchItems.map((item, index) => {
const newRow = {
planSheetId: this.currentPlanSheetId,
bizSeqNo: currentMaxSeqNo + index + 1,
orderCode: this.selectedContract.orderCode,
contractCode: this.selectedContract.contractCode,
customerName: this.selectedContract.companyName,
salesman: this.selectedContract.salesman,
orderId: this.selectedContract.orderId,
productName: item.productType,
productMaterial: item.material,
productWidth: item.width,
rollingThick: item.thickness,
markCoatThick: item.thickness,
tonSteelLengthRange: 0,
planQty: item.productNum,
planWeight: item.weight,
surfaceTreatment: item.surfaceTreatment,
productPackaging: item.packagingReq,
widthReq: item.edgeCuttingReq,
productEdgeReq: item.widthTolerance,
usageReq: item.purpose
};
return addPlanDetail(newRow);
});
Promise.all(addPromises).then(() => {
this.$message.success('批量新增成功');
this.batchAddDialogVisible = false;
this.getList();
}).catch(error => {
this.$message.error('批量新增失败');
});
});
} }
} }
}; };
@@ -654,4 +840,25 @@ export default {
/* ::v-deep .el-input__inner { /* ::v-deep .el-input__inner {
padding: 0 1px; padding: 0 1px;
} */ } */
.batch-add-content {
padding: 10px 0;
}
.contract-section {
margin-bottom: 30px;
padding-bottom: 20px;
border-bottom: 1px solid #eee;
}
.item-section {
margin-top: 20px;
}
.section-title {
font-size: 14px;
font-weight: 600;
margin-bottom: 15px;
color: #303133;
}
</style> </style>