refactor(crm): 优化订单明细查询逻辑,移除内存排序并迁移到SQL层
1. 新增联表分页查询方法,在数据库层完成排序和分页 2. 移除前端页面冗余的合同信息缓存和内存排序逻辑 3. 新增钢卷导入组件,支持调拨单钢批量化导入 4. 补充订单明细VO类的联表查询字段
This commit is contained in:
@@ -314,7 +314,6 @@
|
||||
|
||||
<script>
|
||||
import { listOrderItem, updateOrderItem } from '@/api/crm/orderItem'
|
||||
import { listOrder } from '@/api/crm/order'
|
||||
import { listCategory } from '@/api/wms/category'
|
||||
|
||||
export default {
|
||||
@@ -340,8 +339,6 @@ export default {
|
||||
deliveryDateStart: undefined,
|
||||
deliveryDateEnd: undefined
|
||||
},
|
||||
// 缓存合同信息
|
||||
contractMap: {},
|
||||
// 存储原始数据,用于判断是否有修改
|
||||
originalData: {},
|
||||
// 表面处理选项
|
||||
@@ -372,49 +369,8 @@ export default {
|
||||
getList() {
|
||||
this.loading = true
|
||||
listOrderItem(this.queryParams).then(res => {
|
||||
const items = res.rows || []
|
||||
this.orderItemList = res.rows || []
|
||||
this.total = res.total || 0
|
||||
// 获取所有相关的合同ID
|
||||
const orderIds = [...new Set(items.map(item => item.orderId).filter(id => id))]
|
||||
if (orderIds.length > 0) {
|
||||
// 批量获取合同信息
|
||||
this.loadContractInfo(orderIds, items)
|
||||
} else {
|
||||
this.orderItemList = items
|
||||
this.loading = false
|
||||
}
|
||||
}).catch(e => {
|
||||
console.error(e)
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
|
||||
// 加载合同信息
|
||||
loadContractInfo(orderIds, items) {
|
||||
// 使用listOrder获取合同信息,通过params传递orderIds
|
||||
const params = {
|
||||
pageNum: 1,
|
||||
pageSize: 9999,
|
||||
orderIds: orderIds.join(',')
|
||||
}
|
||||
listOrder(params).then(res => {
|
||||
const contracts = res.rows || []
|
||||
// 构建合同ID到合同信息的映射
|
||||
contracts.forEach(contract => {
|
||||
this.contractMap[contract.orderId] = contract
|
||||
})
|
||||
// 直接合并数据(后端已按 deliveryDate DESC + createTime DESC 排序)
|
||||
this.orderItemList = items.map(item => {
|
||||
const contract = this.contractMap[item.orderId] || {}
|
||||
return {
|
||||
...item,
|
||||
contractCode: contract.contractCode || '',
|
||||
supplier: contract.supplier || '',
|
||||
customer: contract.customer || '',
|
||||
signTime: contract.signTime || '',
|
||||
deliveryDate: contract.deliveryDate || ''
|
||||
}
|
||||
})
|
||||
// 保存原始数据副本
|
||||
this.originalData = {}
|
||||
this.orderItemList.forEach(row => {
|
||||
@@ -422,22 +378,11 @@ export default {
|
||||
})
|
||||
}).catch(e => {
|
||||
console.error(e)
|
||||
this.orderItemList = items
|
||||
}).finally(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
|
||||
// 分组行样式:同一合同组使用交替背景色
|
||||
groupRowClassName({ row, rowIndex }) {
|
||||
// 记录上一个orderId,切换时翻转颜色
|
||||
if (rowIndex === 0 || (this._lastOrderId !== undefined && this._lastOrderId !== row.orderId)) {
|
||||
this._groupColorIndex = (this._groupColorIndex || 0) + 1
|
||||
}
|
||||
this._lastOrderId = row.orderId
|
||||
return this._groupColorIndex % 2 === 1 ? 'group-row-a' : 'group-row-b'
|
||||
},
|
||||
|
||||
// 判断数据是否有变化
|
||||
hasChanged(row) {
|
||||
const id = row.itemId || row.detailId
|
||||
|
||||
Reference in New Issue
Block a user