html代码:
<a-table
:columns="columns"
:data-source="data"
:row-selection="{
selectedRowKeys: selectedRowKeys,
onChange: onSelectChange,
}"
style="margin-top: 20px"
:loading="loading"
:fixed="true"
:scroll="{ x: 'calc(700px + 50%)', y: 450 }"
:pagination="pagination"
@change="handleTableChange"
:ellipsis="true"
>
<template slot="name" slot-scope="text, record">
<el-button @click="executeCustomeCell(record)" type="text">
{{ text }}
</el-button>
</template>
<template slot="operation" slot-scope="text, record">
<el-button type="text" @click="followRecord(text, record)"
>跟进</el-button
>
<el-button type="text" @click="showDetail(text, record)"
>查看</el-button
>
<el-button type="text" @click="updateCustomer(text, record)"
>编辑</el-button
>
<template>
<a-popconfirm
title="是否确定删除"
ok-text="确定"
cancel-text="取消"
@confirm="deleteCostomer(text, record)"
>
<el-button type="text"> 删除</el-button>
</a-popconfirm>
</template>
</template>
</a-table>
js代码:
data(){
return{
columns: [
{
title: "客户名称",
dataIndex: "name",
key: 0,
width: 200,
scopedSlots: { customRender: "name" }, //设置单元格操作
},
{
title: "客户星级",
dataIndex: "level",
key: 1,
width: "150px",
//设置数据格式化
customRender: (level) => {
return this.selectDictLabel(this.levelList, level);
},
},
{
title: "客户类型",
dataIndex: "type",
key: 2,
width: "150px",
customRender: (type) => {
return this.selectDictLabel(this.customer_type, type);
},
},
{
title: "操作",
dataIndex: "operation",
width: "200px",
fixed: "right",
scopedSlots: { customRender: "operation" },
},
data: [],//表格数据
selectedRowKeys: [], // 选中的行
}
methods:{
onSelectChange(selectedRowKeys, row)){
console.log(selectedRowKeys, row);
//selectedRowKeys当前选择的行的序号,设置选中行的数据回显,
//row当前选中行的所有数据
}
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了