<template>
<BasicContainer>
<el-table
ref="multipleTable"
highlight-current-row
:data="tableData"
tooltip-effect="dark"
style="width: 100%"
@current-change="chooseMcaterialChange"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55"> </el-table-column>
<el-table-column label="日期" width="120">
<template slot-scope="scope">{{ scope.row.date }}</template>
</el-table-column>
<el-table-column label="xuanze" prop="radioBox">
<template slot-scope="scope">
<el-radio-group
v-model="scope.row.radioNum"
@change="chooseRadioChange"
>
<el-radio
v-for="i in scope.row.radioBox"
:label="i.lable"
:key="i.lable"
></el-radio>
</el-radio-group>
</template>
</el-table-column>
<el-table-column label="xuanze" prop="checkBox">
<template slot-scope="scope">
<el-checkbox-group
v-model="scope.row.checkList"
@change="chooseCheckChange"
>
<el-checkbox
v-for="i in scope.row.checkBox"
:label="i.val"
:key="i.lable"
>{{ i.lable }}</el-checkbox
>
</el-checkbox-group>
</template>
</el-table-column>
<el-table-column prop="name" label="姓名" width="120"> </el-table-column>
<el-table-column prop="address" label="地址" show-overflow-tooltip>
</el-table-column>
</el-table>
<div v-show="aaa">
<el-table
ref="Table"
highlight-current-row
:data="TableData"
tooltip-effect="dark"
style="width: 100%"
>
<el-table-column label="日期" width="120">
<template slot-scope="scope">{{ scope.row.date }}</template>
</el-table-column>
<el-table-column prop="name" label="姓名" width="120">
</el-table-column>
<el-table-column prop="address" label="地址" show-overflow-tooltip>
</el-table-column>
</el-table>
</div>
</BasicContainer>
</template>
<script>
import Vue from "vue";
import BasicContainer from "@/components/BasicContainer";
import Element, { Table } from "element-ui";
Vue.use(Element, { size: "small", zIndex: 3000 });
export default {
components: {
BasicContainer,
},
data() {
return {
tableData: [
{
date: "2016-05-03",
name: "王小虎",
address: "上海市普陀区金沙江路 1518 弄",
radioBox: [
{ val: 1, lable: "aaa" },
{ val: 2, lable: "bbb" },
{ val: 3, lable: "ccc" },
{ val: 4, lable: "ddd" },
{ val: 5, lable: "eee" },
],
radioNum: 1,
checkBox: [
{ val: 1, lable: "aaa" },
{ val: 2, lable: "bbb" },
{ val: 3, lable: "ccc" },
{ val: 4, lable: "ddd" },
{ val: 5, lable: "eee" },
],
checkList: [],
},
{
date: "2016-05-02",
name: "王小虎",
address: "上海市普陀区金沙江路 1518 弄",
radioBox: [
{ val: 1, lable: "aaa" },
{ val: 2, lable: "bbb" },
{ val: 3, lable: "ccc" },
{ val: 4, lable: "ddd" },
{ val: 5, lable: "eee" },
],
radioNum: 1,
},
{
date: "2016-05-04",
name: "王小虎",
address: "上海市普陀区金沙江路 1518 弄",
},
{
date: "2016-05-01",
name: "王小虎",
address: "上海市普陀区金沙江路 1518 弄",
},
{
date: "2016-05-08",
name: "王小虎",
address: "上海市普陀区金沙江路 1518 弄",
},
{
date: "2016-05-06",
name: "王小虎",
address: "上海市普陀区金沙江路 1518 弄",
},
{
date: "2016-05-07",
name: "王小虎",
address: "上海市普陀区金沙江路 1518 弄",
},
],
multipleSelection: [],
aaa: false,
TableData: [],
};
},
methods: {
handleSelectionChange(val) {
if (val.length > 1) {
this.$refs.multipleTable.clearSelection();
this.$refs.multipleTable.toggleRowSelection(val.pop());
} else {
this.multipleSelection = val;
this.aaaaShow();
console.log(this.multipleSelection);
}
},
chooseMcaterialChange(val) {
this.$refs.multipleTable.toggleRowSelection(val);
},
aaaaShow() {
if (this.multipleSelection.length > 0) {
this.aaa = true;
this.TableData = [];
this.TableData.push(this.multipleSelection[0]);
} else {
this.aaa = false;
this.TableData = [];
}
},
chooseRadioChange(val) {
console.log(val);
},
chooseCheckChange(val) {
console.log(val);
},
},
};
</script>
table表格之间的联动 以及内部插槽单选框和复选框
发布于 2021-10-14 1065 次阅读
Comments | NOTHING