提交 bc4d9549 编写于 作者: KK's avatar KK

树选择调整

上级 7eb050e2
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
<#else> <#else>
<div class="treeNav"> <div class="treeNav">
<template v-for="(item,index) in treeNav"> <template v-for="(item,index) in treeNav">
<ion-label :key="index" class="sc-ion-label-ios-h sc-ion-label-ios-s ios hydrated" :class="index+1 < treeNav.length? 'treeNav-active':'' " @click="nav_click(item)">{{item.text}}</ion-label> <ion-label :key="item.id" class="sc-ion-label-ios-h sc-ion-label-ios-s ios hydrated" :class="index+1 < treeNav.length? 'treeNav-active':'' " @click="nav_click(item)">{{item.text}}</ion-label>
<span class="tree-span" :key="index+'span'" v-if="index+1 < treeNav.length">></span> <span class="tree-span" :key="item.id+'span'" v-if="index+1 < treeNav.length">></span>
</template> </template>
</div> </div>
<div class="tree-partition" v-if="valueNodes.length > 0" ></div> <div class="tree-partition" v-if="valueNodes.length > 0" ></div>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<ion-list v-else-if="viewType == 'DEMOBPICKUPTREEVIEW' && !isSingleSelect"> <ion-list v-else-if="viewType == 'DEMOBPICKUPTREEVIEW' && !isSingleSelect">
<template v-for="item in valueNodes"> <template v-for="item in valueNodes">
<ion-item :key="item.srfkey"> <ion-item :key="item.srfkey">
<ion-checkbox color="secondary" v-if="viewType == 'DEMOBPICKUPTREEVIEW' && !isSingleSelect" :checked="item.selected" :value="item.srfkey" slot="end" @ionChange="onChecked"></ion-checkbox> <ion-checkbox color="secondary" v-if="viewType == 'DEMOBPICKUPTREEVIEW' && !isSingleSelect" :ref="item.srfkey+'checkbox'" :checked="item.selected" :value="item.srfkey" slot="end" @ionChange="onChecked"></ion-checkbox>
<ion-label>{{item.text}}</ion-label> <ion-label>{{item.text}}</ion-label>
</ion-item> </ion-item>
</template> </template>
......
...@@ -183,18 +183,29 @@ import { Util } from '@ibiz-core/utils' ...@@ -183,18 +183,29 @@ import { Util } from '@ibiz-core/utils'
public parseNodes(nodes:any) { public parseNodes(nodes:any) {
let rootNodes :any= []; let rootNodes :any= [];
let valueNodes :any= []; let valueNodes :any= [];
nodes.forEach((item:any) => { for (let index = 0; index < nodes.length; index++) {
const item = nodes[index];
let ele :any= this.$refs[item.srfkey+'checkbox'];
if(!item.leaf){ if(!item.leaf){
rootNodes.push(item); rootNodes.push(item);
}else{ }else{
if(this.selectedNodes.findIndex((temp:any)=>{return temp.srfkey == item.srfkey}) > -1){ if(this.selectedNodes.findIndex((temp:any)=>{return temp.srfkey == item.srfkey}) > -1){
item.selected = true; item.selected = true;
if(ele && ele[0]){
ele[0].ariaChecked = true;
}
}else{
item.selected = false;
if(ele && ele[0]){
ele[0].ariaChecked = false;
}
} }
valueNodes.push(item); valueNodes.push(item);
} }
}); }
this.rootNodes = rootNodes; this.rootNodes = rootNodes;
this.valueNodes = valueNodes; this.valueNodes = valueNodes;
this.$forceUpdate();
} }
/** /**
...@@ -366,6 +377,11 @@ import { Util } from '@ibiz-core/utils' ...@@ -366,6 +377,11 @@ import { Util } from '@ibiz-core/utils'
if (Object.is('refresh_parent', action)) { if (Object.is('refresh_parent', action)) {
this.refresh_parent(); this.refresh_parent();
} }
if (Object.is('refresh', action)) {
this.selectedNodes = data;
this.parseNodes(this.nodes);
this.parseNodes(this.nodes);
}
}); });
} }
if(AppCenterService && AppCenterService.getMessageCenter()){ if(AppCenterService && AppCenterService.getMessageCenter()){
...@@ -788,15 +804,19 @@ ${P.getCtrlCode(childCtrl, 'CONTROL.html').code} ...@@ -788,15 +804,19 @@ ${P.getCtrlCode(childCtrl, 'CONTROL.html').code}
return; return;
} }
let { value } = detail; let { value } = detail;
this.valueNodes.forEach((item: any, index: number) => { for (let index = 0; index < this.valueNodes.length; index++) {
const item = this.valueNodes[index];
if (Object.is(item.srfkey, value)) { if (Object.is(item.srfkey, value)) {
if (detail.checked) { if (detail.checked) {
this.selectedNodes.push(this.valueNodes[index]); this.selectedNodes.push(this.valueNodes[index]);
} else { } else {
this.selectedNodes.splice(this.selectedNodes.findIndex((i: any) => i.srfkey === item.srfkey), 1) let i = this.selectedNodes.findIndex((i: any) => i.srfkey === item.srfkey)
if(i>-1){
this.selectedNodes.splice(i, 1)
}
} }
} }
}); }
this.$emit('selectchange', this.selectedNodes); this.$emit('selectchange', this.selectedNodes);
} }
......
...@@ -32,7 +32,7 @@ ${P.getCtrlCode('pickupviewpanel', 'CONTROL.html').code} ...@@ -32,7 +32,7 @@ ${P.getCtrlCode('pickupviewpanel', 'CONTROL.html').code}
</van-action-sheet> </van-action-sheet>
</#if> </#if>
</#if> </#if>
<div class="selectedCount">已选择:{{viewSelections.length}}<ion-icon name="chevron-up-outline"></ion-icon></div> <div class="selectedCount" @click="select_click">已选择:{{viewSelections.length}}<ion-icon name="chevron-up-outline"></ion-icon></div>
<ion-button class="pick-btn" @click="onClickOk" :disabled="viewSelections.length === 0">{{$t('app.button.confirm')}}</ion-button> <ion-button class="pick-btn" @click="onClickOk" :disabled="viewSelections.length === 0">{{$t('app.button.confirm')}}</ion-button>
</div> </div>
</div> </div>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册