Commit e0a0ff6f authored by 周远喜's avatar 周远喜

多选ok

parent 30622fe2
...@@ -69,11 +69,11 @@ ...@@ -69,11 +69,11 @@
<!-- 多选 --> <!-- 多选 -->
<label <label
v-if="column.type === 'selection'" v-if="column.type === 'selection'"
@click="rowChecked(item, index, $event)"
> >
<Checkbox <Checkbox
v-model="item._checked" v-model="item._checked"
:indeterminate="item._indeterminate" @on-change="rowChecked($event,item, index,)"
:indeterminate="indeterminateBoys(item)"
></Checkbox> ></Checkbox>
</label> </label>
...@@ -210,7 +210,7 @@ ...@@ -210,7 +210,7 @@
</li> </li>
</ul> </ul>
</Drawer> </Drawer>
<FooterToolbar v-if="batch" v-show="footerToolbar" class="ftball"> <FooterToolbar v-if="batch" v-show="footerToolbar&&selectItems.length>0" class="ftball">
<div class="ib">已选{{ selectItems.length }}</div> <div class="ib">已选{{ selectItems.length }}</div>
<slot name="batch"></slot> <slot name="batch"></slot>
<Button @click="cancelBatch">取消</Button> <Button @click="cancelBatch">取消</Button>
...@@ -357,7 +357,7 @@ export default { ...@@ -357,7 +357,7 @@ export default {
spaceWidth: { spaceWidth: {
//树形表格缩进距离 //树形表格缩进距离
type: Number, type: Number,
default: 20, default: 35,
}, },
exportTitle: { exportTitle: {
type: String, type: String,
...@@ -384,6 +384,7 @@ export default { ...@@ -384,6 +384,7 @@ export default {
isDesc: true, isDesc: true,
conditions: [], conditions: [],
}, },
level:1,
searchConditions: this.search, searchConditions: this.search,
pageSizeOpts: [20, 50, 100], pageSizeOpts: [20, 50, 100],
tableHeight: 0, tableHeight: 0,
...@@ -420,6 +421,7 @@ export default { ...@@ -420,6 +421,7 @@ export default {
}, },
watch: { watch: {
items() { items() {
this.selectItems=[];
if (this.items) { if (this.items) {
this.trs = this.treeToList(this.items); this.trs = this.treeToList(this.items);
} }
...@@ -590,9 +592,8 @@ export default { ...@@ -590,9 +592,8 @@ export default {
return parents; return parents;
}, },
// 点击check勾选框,判断是否有children节点 如果有就一并勾选 // 点击check勾选框,判断是否有children节点 如果有就一并勾选
rowChecked(data, index, event) { rowChecked(event,data, index, ) {
this.$set(this.trs, index, data); this.trs[index]._checked=data._checked;
console.log("rowChecked",data,this.trs[index])
var boys = this.getChildrens(data); var boys = this.getChildrens(data);
if (boys.length>0) { if (boys.length>0) {
this.trs.forEach((u, i) => { this.trs.forEach((u, i) => {
...@@ -600,11 +601,10 @@ export default { ...@@ -600,11 +601,10 @@ export default {
return b[this.keyname] == u[this.keyname]; return b[this.keyname] == u[this.keyname];
}); });
if (items.length == 1) { if (items.length == 1) {
this.$set(this.trs[i], "_checked", !data._checked); this.$set(this.trs[i], "_checked", data._checked);
} }
}); });
} }
this.checkAll = this.checkAll =
this.trs.length > this.trs.length >
this.trs.filter((u) => { this.trs.filter((u) => {
...@@ -614,6 +614,14 @@ export default { ...@@ -614,6 +614,14 @@ export default {
this.selectionChange(); this.selectionChange();
}); });
}, },
indeterminateBoys(item){
var boys = this.getChildrens(item);
if(boys.length==0){
return false;
}else{
return boys.filter(u=>{return u._checked===item._checked}).length<boys.length;
}
},
getChildrens(data) { getChildrens(data) {
var childrens = []; var childrens = [];
var that = this; var that = this;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment