feat(aps): 新增排产单明细合并功能及优化界面展示

- 在排产单明细表格中添加多选合并功能
- 实现排产单明细合并对话框及合并逻辑
- 优化排产单明细表格列配置和表单布局
- 添加合并校验和接收产需单API接口
- 重构订单绑定解绑逻辑提升用户体验
- 添加ScheduleDetailCoilBind组件引入
This commit is contained in:
2026-06-29 16:07:29 +08:00
parent da01bfaa48
commit ee376f922f
19 changed files with 1547 additions and 154 deletions

View File

@@ -158,7 +158,7 @@
<div v-for="order in currentReq.orderList" :key="order.orderId" class="bound-order-card">
<div class="bound-order-card-header">
<span>{{ order.orderCode || ('订单 #' + order.orderId) }}</span>
<button v-if="canEdit" class="link-btn" @click="handleUnbindByOrderId(order.orderId)">解绑</button>
<button v-if="canEdit" class="link-btn" @click="handleUnbindByOrderId(order)">解绑</button>
</div>
<div class="bound-order-card-body">
<div style="font-size:12px; color:#7f8c8d; margin-bottom:3px;">
@@ -399,6 +399,7 @@ import {
delRequirement,
addRel,
delRel,
listRel,
addRequirementDetail,
updateRequirementDetail,
delRequirementDetail
@@ -628,7 +629,8 @@ export default {
searchBindOrders() {
this.bindSearchLoading = true
listCrmOrder(this.bindQuery).then(res => {
this.candidateOrderList = res.rows || []
const boundOrderIds = (this.currentReq?.orderList || []).map(o => o.orderId)
this.candidateOrderList = (res.rows || []).filter(o => !boundOrderIds.includes(o.orderId))
}).catch(() => {
this.candidateOrderList = []
}).finally(() => {
@@ -672,65 +674,87 @@ export default {
}
this.bindBtnLoading = true
const scheduleId = this.currentReq.scheduleId
const allPromises = []
this.selectedBindOrders.forEach(order => {
// 1. 创建订单关联
allPromises.push(
addRel({
orderId: order.orderId,
scheduleId: scheduleId,
relWeight: null,
remark: ''
})
)
// 2. 解析 productContent每行产品创建一条排产明细
if (order.productContent) {
const parsed = parseProductContent(order.productContent)
const products = parsed.products || []
const productType = parsed.productName || ''
products.forEach(prod => {
allPromises.push(
addRequirementDetail({
scheduleId: scheduleId,
orderDetailId: order.orderId,
spec: prod.spec || '',
material: prod.material || '',
scheduleWeight: prod.quantity || 0,
productType: productType,
remark: prod.remark || ''
})
)
})
}
const orderTasks = this.selectedBindOrders.map(order => {
return addRel({
orderId: order.orderId,
scheduleId: scheduleId,
relWeight: null,
remark: ''
}).then(() => {
if (!order.productContent) return
let products = []
let productType = ''
try {
const parsed = parseProductContent(order.productContent)
products = (parsed.products || []).filter(p => p.spec && p.material)
productType = parsed.productName || ''
} catch (e) {
return
}
if (products.length === 0) return
const detailPromises = products.map(prod =>
addRequirementDetail({
scheduleId: scheduleId,
orderDetailId: order.orderId,
spec: prod.spec,
material: prod.material,
scheduleWeight: prod.quantity || 0,
productType: productType,
remark: prod.remark || ''
})
)
return Promise.all(detailPromises)
})
})
Promise.all(allPromises).then(() => {
this.$modal.msgSuccess('绑定成功,排产明细已生成')
Promise.allSettled(orderTasks).then(results => {
const successCount = results.filter(r => r.status === 'fulfilled').length
const failCount = results.filter(r => r.status === 'rejected').length
this.bindDialogVisible = false
this.handleReqClick(this.currentReq)
}).catch(() => {
this.$modal.msgError('绑定或创建明细失败')
if (failCount === 0) {
this.$modal.msgSuccess(`成功绑定 ${successCount} 个订单,排产明细已生成`)
} else if (successCount === 0) {
this.$modal.msgError('绑定失败,请重试')
} else {
this.$modal.msgWarning(`成功绑定 ${successCount} 个,${failCount} 个失败`)
}
}).finally(() => {
this.bindBtnLoading = false
})
},
handleUnbindByOrderId(orderId) {
const order = (this.currentReq.orderList || []).find(o => o.orderId === orderId)
if (!order) {
this.$message.warning('未找到关联记录')
return
}
this.$confirm('确认解绑该订单吗?', '提示', {
handleUnbindByOrderId(order) {
this.$confirm('确认解绑该订单吗?解绑将同时删除对应的排产明细。', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delRel(order.relId || orderId).then(() => {
const tasks = []
// 1. 删除该订单关联的排产明细
const detailIds = this.requirementDetailList
.filter(d => d.orderDetailId === order.orderId)
.map(d => d.scheduleDetailId)
detailIds.forEach(id => {
tasks.push(delRequirementDetail(id))
})
// 2. 查询并删除关联表记录
tasks.push(
listRel({ orderId: order.orderId, scheduleId: this.currentReq.scheduleId }).then(res => {
const rows = res.rows || []
if (rows.length === 0) {
throw new Error('未找到关联记录')
}
const relId = rows[0].id || rows[0].relId
return delRel(relId)
})
)
Promise.all(tasks).then(() => {
this.$modal.msgSuccess('解绑成功')
this.handleReqClick(this.currentReq)
}).catch(() => {
this.$modal.msgError('解绑失败')
})
}).catch(() => { })
},