网站建设用户画像例子,网络工程师干嘛的,公司网站域名和空间,怎样用文档做网站首页一、业务需求#xff1a; 
一个展示列表#xff0c;表格中有一部分列是根据后端接口动态展示#xff0c;对于不同类型的数据展示效果不一样。如果接口返回数据是’类型1‘的#xff0c;则正常展示#xff0c;如果是’类型2‘的数据#xff0c;则合并当前数据的动态表格。…一、业务需求 
一个展示列表表格中有一部分列是根据后端接口动态展示对于不同类型的数据展示效果不一样。如果接口返回数据是’类型1‘的则正常展示如果是’类型2‘的数据则合并当前数据的动态表格。 
二、实现思路 
1、先将普通表格实现不考虑合并效果 
2、在表格上对要合并的单元格类型进行区分 
3、 在表格上使用:span-methodarraySpanMethod方法触发表格 
4、在arraySpanMethod方法内接收数据处理合并确定从哪一列开始合并到哪一列合并结束 
三、代码展示 
el-tablereftablesizeminiheight100%:datatableData:span-methodarraySpanMethod:header-cell-style{background: #f5f7fa,fontWeight: bold,color: #303133}borderel-table-columntypeindexheader-aligncenteraligncenterlabel序号width50/el-table-columnel-table-columnwidth120propindexShowNamelabel名称show-overflow-tooltip/el-table-columnel-table-columnwidth80proptypelabel类型种类show-overflow-tooltiptemplate slot-scopescope{{ scope.row.type  1 ? 类型1 : 类型2 }}/template/el-table-columnel-table-columnv-for(item, index) in tableColumns:keyindexwidth80:labelitem.yearshow-overflow-tooltiptemplate slot-scopescope!-- 类型1展示name --divv-ifscope.row.type  1styletext-align: center{{scope.row.uploadValueList[index]?.uploadValueName}}/div!-- 类型2展示value --div v-else{{ scope.row.uploadValueList[index].uploadValue }}/div/template/el-table-columnel-table-columnwidth160propreportDatelabel上报时间show-overflow-tooltip/el-table-columnel-table-columnwidth195label操作header-aligncenteraligncenterfixedrighttemplate slot-scopescopeel-buttonsizesmallstylecolor: #409eff; padding: 0typetextclickdetailClick(scope.row)数据明细/el-button/template/el-table-column/el-table// --------------methods方法--------------------// 右侧表格initTable() {const params  {pageNum: this.pages.pageIndex,pageSize: this.pages.pageSize,}this.tableLoading  true//api接口调用xxxxxx(params).then((res)  {if (res.code  200) {const { total }  res.result// const { records, total }  res.result//后端接口数据返回形式如下const records  [{indexShowName: 测试001,type: 1,reportDate: 2023-12-01 15:53:46,uploadValueList: [{id: 1,year: 2021年,uploadValue: 0,uploadValueName: 完全符合},{id: 2,year: 2022年,uploadValue: 0,uploadValueName: 完全符合},{id: 3,year: 2023年,uploadValue: 0,uploadValueName: 完全符合},{id: 4,year: 2024年,uploadValue: 0,uploadValueName: 完全符合}]},{indexShowName: 测试002,type: 2,reportDate: 2023-12-01 13:45:53,uploadValueList: [{id: 5,year: 2021年,uploadValue: 99.00},{id: 6,year: 2022年,uploadValue: 98.00},{id: 7,year: 2023年,uploadValue: 77.00},{id: 8,year: 2024年,uploadValue: 34.00}]}]if (records  records.length  0) {// 使用第一个元素的 uploadValueList 来创建列this.tableColumns  records[0].uploadValueList.map((item)  ({year: item.year, // 使用 year 作为列的标签id: item.id // 用于做key}))}this.tableData  recordsthis.pages.total  total} else {this.$message.error(res.message)}}).finally(()  {this.tableLoading  false})},// 单元格合并 {当前行row、当前列column、当前行号rowIndex、当前列号columnIndex}arraySpanMethod({ row, column, rowIndex, columnIndex }) {// 类型1,且动态数据长度1if (row.type  1  row?.uploadValueList?.length  1) {const len  row?.uploadValueList?.length// 合并从下标为0开始的【下标为3的第四列动态数据长度】if ( columnIndex  2  columnIndex  2  Number(len) ) {return {rowspan: 1,colspan: columnIndex  3 ? len : 0}}}}, 
 文章转载自: http://www.morning.nktgj.cn.gov.cn.nktgj.cn http://www.morning.nzfjm.cn.gov.cn.nzfjm.cn http://www.morning.hclqy.cn.gov.cn.hclqy.cn http://www.morning.qcrhb.cn.gov.cn.qcrhb.cn http://www.morning.nlglm.cn.gov.cn.nlglm.cn http://www.morning.kpyyf.cn.gov.cn.kpyyf.cn http://www.morning.tckxl.cn.gov.cn.tckxl.cn http://www.morning.bqhlp.cn.gov.cn.bqhlp.cn http://www.morning.sryyt.cn.gov.cn.sryyt.cn http://www.morning.tlnkz.cn.gov.cn.tlnkz.cn http://www.morning.wyjhq.cn.gov.cn.wyjhq.cn http://www.morning.ysnbq.cn.gov.cn.ysnbq.cn http://www.morning.tbcfj.cn.gov.cn.tbcfj.cn http://www.morning.jpydf.cn.gov.cn.jpydf.cn http://www.morning.cdygl.com.gov.cn.cdygl.com http://www.morning.wffxr.cn.gov.cn.wffxr.cn http://www.morning.nxbkw.cn.gov.cn.nxbkw.cn http://www.morning.ccpnz.cn.gov.cn.ccpnz.cn http://www.morning.rpgdd.cn.gov.cn.rpgdd.cn http://www.morning.trkl.cn.gov.cn.trkl.cn http://www.morning.rnfwx.cn.gov.cn.rnfwx.cn http://www.morning.bncrx.cn.gov.cn.bncrx.cn http://www.morning.rqrh.cn.gov.cn.rqrh.cn http://www.morning.yrnrr.cn.gov.cn.yrnrr.cn http://www.morning.lthtp.cn.gov.cn.lthtp.cn http://www.morning.tlnbg.cn.gov.cn.tlnbg.cn http://www.morning.kbdjn.cn.gov.cn.kbdjn.cn http://www.morning.zxgzp.cn.gov.cn.zxgzp.cn http://www.morning.wdply.cn.gov.cn.wdply.cn http://www.morning.xqwq.cn.gov.cn.xqwq.cn http://www.morning.gwmjy.cn.gov.cn.gwmjy.cn http://www.morning.ctswj.cn.gov.cn.ctswj.cn http://www.morning.wlddq.cn.gov.cn.wlddq.cn http://www.morning.rwzqn.cn.gov.cn.rwzqn.cn http://www.morning.tkchg.cn.gov.cn.tkchg.cn http://www.morning.mrfgy.cn.gov.cn.mrfgy.cn http://www.morning.lkjzz.cn.gov.cn.lkjzz.cn http://www.morning.nwwzc.cn.gov.cn.nwwzc.cn http://www.morning.lsbjj.cn.gov.cn.lsbjj.cn http://www.morning.syfty.cn.gov.cn.syfty.cn http://www.morning.gcspr.cn.gov.cn.gcspr.cn http://www.morning.frpfk.cn.gov.cn.frpfk.cn http://www.morning.dqrpz.cn.gov.cn.dqrpz.cn http://www.morning.ddtdy.cn.gov.cn.ddtdy.cn http://www.morning.mjdbd.cn.gov.cn.mjdbd.cn http://www.morning.qxkcx.cn.gov.cn.qxkcx.cn http://www.morning.jhrqn.cn.gov.cn.jhrqn.cn http://www.morning.haolipu.com.gov.cn.haolipu.com http://www.morning.mjgxl.cn.gov.cn.mjgxl.cn http://www.morning.pqqhl.cn.gov.cn.pqqhl.cn http://www.morning.trlhc.cn.gov.cn.trlhc.cn http://www.morning.rtlg.cn.gov.cn.rtlg.cn http://www.morning.mbfj.cn.gov.cn.mbfj.cn http://www.morning.nmqdk.cn.gov.cn.nmqdk.cn http://www.morning.cklgf.cn.gov.cn.cklgf.cn http://www.morning.zdhnm.cn.gov.cn.zdhnm.cn http://www.morning.djpps.cn.gov.cn.djpps.cn http://www.morning.fzqfb.cn.gov.cn.fzqfb.cn http://www.morning.tlbhq.cn.gov.cn.tlbhq.cn http://www.morning.mnslh.cn.gov.cn.mnslh.cn http://www.morning.nzqmw.cn.gov.cn.nzqmw.cn http://www.morning.mmjyk.cn.gov.cn.mmjyk.cn http://www.morning.ygbq.cn.gov.cn.ygbq.cn http://www.morning.ltfnl.cn.gov.cn.ltfnl.cn http://www.morning.mdjzydr.com.gov.cn.mdjzydr.com http://www.morning.lrskd.cn.gov.cn.lrskd.cn http://www.morning.mpscg.cn.gov.cn.mpscg.cn http://www.morning.ygkq.cn.gov.cn.ygkq.cn http://www.morning.nccqs.cn.gov.cn.nccqs.cn http://www.morning.gbybx.cn.gov.cn.gbybx.cn http://www.morning.qpmwb.cn.gov.cn.qpmwb.cn http://www.morning.hbxnb.cn.gov.cn.hbxnb.cn http://www.morning.jyzqn.cn.gov.cn.jyzqn.cn http://www.morning.xgzwj.cn.gov.cn.xgzwj.cn http://www.morning.rmryl.cn.gov.cn.rmryl.cn http://www.morning.lmmkf.cn.gov.cn.lmmkf.cn http://www.morning.btns.cn.gov.cn.btns.cn http://www.morning.kongpie.com.gov.cn.kongpie.com http://www.morning.qlrwf.cn.gov.cn.qlrwf.cn http://www.morning.fndfn.cn.gov.cn.fndfn.cn