62 lines
1.3 KiB
Vue
62 lines
1.3 KiB
Vue
<template>
|
|
<div>
|
|
<el-table
|
|
ref="table"
|
|
:data="data"
|
|
style="width: 100%"
|
|
@selection-change="handleSelectionChange"
|
|
@cell-click="cellClick"
|
|
>
|
|
<template v-if="type == 'edit'">
|
|
<el-table-column type="selection" width="55"> </el-table-column>
|
|
</template>
|
|
<el-table-column
|
|
prop="productName"
|
|
label="商品名称"
|
|
width="100"
|
|
></el-table-column>
|
|
<el-table-column prop="price" label="商品单价"></el-table-column>
|
|
<el-table-column prop="num" label="商品数量"></el-table-column>
|
|
<el-table-column prop="priceAmount" label="商品总价"></el-table-column>
|
|
</el-table>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
export default {
|
|
props: {
|
|
type: {
|
|
type: String, //edit show
|
|
default: "edit",
|
|
},
|
|
data: {
|
|
type: Array,
|
|
default: () => [],
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
selArr: [],
|
|
};
|
|
},
|
|
watch:{
|
|
|
|
},
|
|
methods: {
|
|
getSelectRows() {
|
|
return this.selArr;
|
|
},
|
|
handleSelectionChange(e) {
|
|
if (this.type == "edit") {
|
|
this.selArr = e;
|
|
}
|
|
},
|
|
cellClick(row) {
|
|
if (this.type == "edit") {
|
|
this.$refs.table.toggleRowSelection(row);
|
|
}
|
|
console.log(row);
|
|
},
|
|
},
|
|
};
|
|
</script>
|