<el-table
ref="batchingOrderDetailTable"
:data="tableData"
border
style="width: 100%"
:height="tableHeight"
size="mini"
:default-sort = "{prop: 'levelNo', order: 'ascending'}"
:header-cell-style="{ fontSize: '13px' }"
row-key="keyId"
default-expand-all
:tree-props="{children: 'itemList'}"
:row-class-name="tableRowClassName"
@selection-change="handleSelectionChange">
>
<el-table-column width="105" fixed>
<template slot="header" slot-scope="scope">
<span>全选</span>
<el-checkbox v-model="checkouts" style="padding-left:10px" @change="checkAllIn(scope)" />
</template>
<template slot-scope="scope">
<el-checkbox
v-model="scope.row.checks"
style="padding-left:10px"
@change="checkChange(scope.row)"
/>
</template>
</el-table-column>
</el-table>
checkAllIn() {
this.$refs.batchingOrderDetailTable.data.forEach((items) => {
this.$set(items, 'checks', this.checkouts);
if (items.itemList) {
this.setChildren(items.itemList, this.checkouts);
}
});
this.multipleSelection = [];
this.selectionList(this.tableData);
},
setChildren(children, type) {
children.forEach(j => {
this.$set(j, 'checks', type);
if (j.itemList) {
this.setChildren(j.itemList, type);
}
});
},
selectionList(list) {
list.forEach(item => {
if (item.checks && !item.itemList && item.coreWorkOrderNo) {
this.multipleSelection.push(item);
}
if (item.itemList) {
this.selectionList(item.itemList);
}
});
},
checkChange(row) {
if (row.itemList) {
this.setChildren(row.itemList, row.checks);
}
this.multipleSelection = [];
if(this.tableData){
this.selectionList(this.tableData);
}
},