现在将custId相同的合并为一组(同时将其保存在嵌套表格中),所以需要的数据格式为下图的额格式
具体代码:
//嵌套表格:
<a-tabs type="card" v-model="defaultActiveKeyGc">
<a-tab-pane :tab="item.name" v-for=" (item,index) in checkedList" :key="item.custId">
<a-table
:columns="columnsGcReq"
:data-source="item.order"
class="components-table-demo-nested"
:rowKey="(record)=>record.infoId"
:expandedRowKeys="expandedRowKeys"
:loading="tableLoading"
@expand="expand"
>
<div slot="expandedRowRender" slot-scope="record" style="margin: 0">
<!-- {{item}}-->
<!-- {{record}}-->
<!-- {{item[record.no]}}-->
<a-table
slot="expandedRowRender"
:columns="innerColumnsGcReq"
:data-source="item[record.no]"
:rowKey="(records)=>records.infoId"
:pagination="false"
>
<template #materClass="text,records,index">
<span>{{judgeObj(dictDataMap['materielClassify'],records.spuId,'text')}}</span>
</template>
<template #materName="text,records,index">
<span>{{judgeObj(dictDataMap['ts-materiel'],records.subSpuId,'name')}}</span>
</template>
<template #spec="text,records,index">
<span>{{dictDataMap['ts-materiel'][records.subSpuId]?dictDataMap['ts-materiel'][records.subSpuId].spec:''}}</span>
</template>
<template #unit="text,records,index">
<span>{{dictDataMap['ts-materiel'][records.subSpuId]?judgeObj(dictDataMap['materielUnit'],dictDataMap['ts-materiel'][records.subSpuId].unit,'text'):''}}</span>
</template>
<template #price="text,records,index">
<span>{{dictDataMap['ts-materiel'][records.subSpuId]?dictDataMap['ts-materiel'][records.subSpuId].price:''}}</span>
</template>
<template #number="text,records,index">
<span>{{records.number}}</span>
</template>
</a-table>
</div>
</a-table>
</a-tab-pane>
</a-tabs>
//具体数据整理========================================
getCheckedCustId() {
this.allCustId.length=0
this.allInfoId.length=0
if (this.selectedTableRow.length) {
const requestParameters = Object.assign({
pageName: 'ts-order-search',
formName: 'searchForm',
'tsOrder.no': this.selectedTableRow.toString()
})
getCommonList(requestParameters).then(res => {
console.log(res.rows,'res.rows')
if (res.rows.length) {
const list = res.rows
const map = {}
const ids = []
list.forEach(item => {
const {custId} = item
ids.push(custId)
})
console.log(ids,'ids')
ids.forEach(id => {
map[id] = list.filter(item => item.custId === id)
})
console.log(map,'map')
for (const [k, v] of Object.entries(map)) {
const o = []
const d = []
v.forEach(item => {
const {order, orderDetail} = item
o.push(...order)
d.push(...orderDetail)
})
map[k] = {
order: o,
orderDetail: d,
name: judgeObj(this.dictDataMap['ts-customer'], k, 'name'),
custId: k,
}
}
this.defaultActiveKeyGc = ids[0]
this.checkedList = map
} else {
this.checkedList = []
}
console.log(this.checkedList,'this.checkedList')
this.allInfoId=[]
this.selectedTableRow.forEach(item => {
this.loadData.forEach(lItem => {
if (item == lItem.tsOrder.no) {
this.allCustId.push(lItem.tsOrder.custId)
this.allInfoId.push(lItem.tsOrder.infoId)
}
})
})
console.log(this.selectedTableRow, 'no')
console.log(this.allCustId, 'custid')
})
}
},