实现效果:
建设起止年限,使用两个字段进行拼接
html部分:
<a-table
:columns="listColumns"
:data-source="data"
:scroll="{y:630}"
:pagination="false"
:rowKey="record =>record.id"
>
<template slot="action" slot-scope="status,row">
<a @click="next(row)">查看</a>
</template>
</a-table>
表格列的设置
listColumns:[
{
dataIndex: "projectProgress",
title: "整体进展",
customRender: (text) => {
return this.getProcessCodeValue(text);
}
},
{
dataIndex: "carryOverType",
title: "结转/新列",
customRender: (text) => {
if (text==="1"||text===1) {
return "结转";
}else if (text==="2"||text===2) {
return "新列";
}else if (text==="3"||text===3) {
return "新建";
}else if (text==="4"||text===4) {
return "改扩建";
}else{
return "-";
}
}
},
{
dataIndex: "internalWorkshopProgress",
title: "里程碑进度",
customRender: (text) => {
return text || "-";
}
},
{
title: "建设起止年限",
customRender: (record) => {
const year = `${record.constructionStartTime}~${record.constructionEndTime}`;
return year;
}
},
{
dataIndex: "action",
title: "操作",
scopedSlots: {customRender: "action"},
}
],