通过设置type="expand"
和 Scoped slot
可以开启展开行功能,el-table-column
的模板会被渲染成为展开行的内容,展开行可访问的属性与使用自定义列模板时的 Scoped slot
相同。
重点:
1.表格绑定的数据 :data="showPolicyListDate"
2.展开列表的方法@expand-change="expandPolicyList"
3.必须要写的:type="expand"
和slot-scope="scope"
投保人信息
{{item.applyName?item.applyName:''}}
{{item.applyGender?item.applyGender:''}}
{{item.applyIdType?item.applyIdType:''}}
{{item.applyIdNo?item.applyIdNo:''}}
{{item.applyBirthDate}}
{{item.applyIdTerm?item.applyIdTerm:''}}
{{item.profession?item.profession:''}}
{{item.applyMobile?item.applyMobile:''}}
{{item.applyAddres?item.applyAddres:''}}
被保人信息
{{item.insurName?item.insurName:''}}
{{item.insurGender?item.insurGender:''}}
{{item.insurIdType?item.insurIdType:''}}
{{item.insurIdNo?item.insurIdNo:''}}
{{item.insurBirthDate}}
{{item.insurIdTerm?item.insurIdTerm:''}}
{{item.insurprofession?item.insurprofession:''}}
{{item.insurMobile?item.insurMobile:''}}
{{item.insurAddres?item.insurAddres:''}}
{{item.insurRelationToAppnt?item.insurRelationToAppnt:''}}
险种信息
{{row.amnt|formatSemicolon|formatAddWorld}}
{{row.sumPrem|formatSemicolon|formatAddWorld}}
{{row.cvalidate|formatCreateTime}}
调用后台接口获取数据:给每一条数据添加一个可展开列表的数据,防止数据为空报错
//联系方式变更详情
async getbussMsgInfor(){
const res = await ContactChanged.getbussMsgInfo({bussNo:this.bussNo})
if(res.result==='0'){
// 已选保单
this.showPolicyListDate = res.campContactInfo.policyList.map(item=>{
return {
...item,
flag:true,
expandData:{
policyHolderInfo:{},
insurHolderInfo:{},
riskInfoList:[]
}
}
})
}else{
this.$message.error(res.resultMessage)
return
}
点击展开调用方法:给每一条数据里面的展开列表赋值
// 展开列表保单基本信息
async expandPolicyList(row){
const res = await ContactChanged.getPolicyDetails({policyNo:row.contNo})
row.expandData.policyHolderInfo = res.applyInfo
row.expandData.insurHolderInfo = res.insurInfo
row.expandData.riskInfoList = res.riskInfo
},
效果: