提交 68a6d5df 编写于 作者: Neuromancer255's avatar Neuromancer255

多数据部件全选ui逻辑调整

上级 bb96071a
...@@ -43,10 +43,11 @@ ...@@ -43,10 +43,11 @@
<#--多数据视图||多数据视图(部件视图)--> <#--多数据视图||多数据视图(部件视图)-->
<template v-if="(viewType == 'DEMOBMDVIEW') && controlStyle != 'SWIPERVIEW' "> <template v-if="(viewType == 'DEMOBMDVIEW') && controlStyle != 'SWIPERVIEW' ">
<div class="selectall"> <div class="selectall">
<ion-checkbox :checked="selectAllIschecked" v-show="showCheack" @ionChange="checkboxAll"></ion-checkbox> <van-checkbox class="checkAllBtn" v-model="selectAllIschecked" v-show="showCheack" @click="checkboxAll">全选</van-checkbox>
<ion-label class="selectal-label" v-show="showCheack">全选</ion-label>
</div> </div>
<ion-item-sliding :ref="item.srfkey" v-for="(item, index) in items" @click="item_click(item)" :key="index" class="app-mob-mdctrl-item"> <van-checkbox-group v-model="checkedResult" ref="checkboxGroup">
<van-cell-group>
<van-swipe-cell v-for="(item, index) in items" :key="index" class="app-mob-mdctrl-item">
<#-- BENGIN:输出界面行为组 --> <#-- BENGIN:输出界面行为组 -->
<@outPutActionGroup ctrl /> <@outPutActionGroup ctrl />
<#-- END:输出界面行为组 --> <#-- END:输出界面行为组 -->
...@@ -55,20 +56,27 @@ ...@@ -55,20 +56,27 @@
<@outPutItemLaoutPanel ctrl /> <@outPutItemLaoutPanel ctrl />
<#-- END:输出项布局面板 --> <#-- END:输出项布局面板 -->
<#else> <#else>
<ion-item> <van-cell :ref="item.srfkey" @click="item_click(item)">
<ion-checkbox :checked="item.checked" v-show="showCheack" @click.stop="checkboxSelect(item)"></ion-checkbox>
<#--实体列表项集合--> <#--实体列表项集合-->
<#if ctrl.getPSDEListItems()??> <#if ctrl.getPSDEListItems()??>
<!-- 列表视图样式 --> <!-- 列表视图样式 -->
<app-list-default <#if ctrl.getPSDEListItems()??>:dataItemNames = "[<#list ctrl.getPSDEListItems() as item><#if item.getDataItemName()??>'${item.getDataItemName()}',</#if></#list>]"</#if> :item="item" major="<#if appde.getMajorPSAppDEField()??>${appde.getMajorPSAppDEField().getCodeName()?lower_case}<#else>srfmajortext</#if>" v-if="controlStyle.substring(0,8) === 'LISTVIEW'"></app-list-default> <app-list-default <#if ctrl.getPSDEListItems()??>:dataItemNames = "[<#list ctrl.getPSDEListItems() as item><#if item.getDataItemName()??>'${item.getDataItemName()}',</#if></#list>]"</#if> :item="item" major="<#if appde.getMajorPSAppDEField()??>${appde.getMajorPSAppDEField().getCodeName()?lower_case}<#else>srfmajortext</#if>" v-if="controlStyle.substring(0,8) === 'LISTVIEW'"></app-list-default>
<!-- 图标视图样式 --> <!-- 图标视图样式 -->
<app-icon-list :item="item" v-if="controlStyle === 'ICONVIEW'"></app-icon-list> <app-icon-list :item="item" v-if="controlStyle === 'ICONVIEW'"></app-icon-list>
<template #right-icon>
<van-checkbox :checked="item.checked" v-show="showCheack" :name="item.mobentityname"/>
</template>
<#else> <#else>
<div>暂无数据</div> <div>暂无数据</div>
</#if> </#if>
</ion-item> </van-cell>
<template #right>
<van-button square type="danger" text="删除" style="height:100%" @click="remove([item])"/>
</template>
</#if> </#if>
</ion-item-sliding> </van-swipe-cell>
</van-cell-group>
</van-checkbox-group>
<ion-button size="small" color="secondary" v-if="!isTempMode && !allLoaded" style ="position: relative;left: calc( 50% - 44px);" @click="loadBottom">{{$t('app.button.loadmore')}}</ion-button> <ion-button size="small" color="secondary" v-if="!isTempMode && !allLoaded" style ="position: relative;left: calc( 50% - 44px);" @click="loadBottom">{{$t('app.button.loadmore')}}</ion-button>
</template> </template>
<template v-else-if="(viewType == 'DEMOBMDVIEW9')"> <template v-else-if="(viewType == 'DEMOBMDVIEW9')">
......
...@@ -565,26 +565,6 @@ ...@@ -565,26 +565,6 @@
return response; return response;
} }
/**
* 点击回调事件
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public item_click(item:any){
if(this.showCheack){
let count = this.selectedArray.findIndex((i) => {
return i.mobentityid == item.mobentityid;
});
if (count === -1) {
this.selectedArray.push(item);
} else {
this.selectedArray.splice(count, 1);
}
} else {
this.goPage(item)
}
}
/** /**
* 点击列表数据跳转 * 点击列表数据跳转
* *
...@@ -743,6 +723,34 @@ ...@@ -743,6 +723,34 @@
*/ */
@Prop({default:false}) showCheack?: boolean; @Prop({default:false}) showCheack?: boolean;
/**
* 全选按钮选中状态
*
* @memberof ${srfclassname('${ctrl.name}')}
*/
public selectAllIschecked = false;
/**
* 列表项点击回调事件
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public item_click(item:any){
if(this.showCheack){
let count = this.selectedArray.findIndex((i) => {
return i.mobentityid == item.mobentityid;
});
if (count === -1) {
this.selectedArray.push(item);
} else {
this.selectedArray.splice(count, 1);
}
this.checkboxSelect(item)
} else {
this.goPage(item)
}
}
/** /**
* 选中或取消事件 * 选中或取消事件
* *
...@@ -750,20 +758,20 @@ ...@@ -750,20 +758,20 @@
*/ */
public checkboxSelect(item:any){ public checkboxSelect(item:any){
let count = this.selectedArray.findIndex((i) => { let count = this.selectedArray.findIndex((i) => {
return i.${appde.getKeyPSAppDEField().getCodeName()?lower_case} == item.${appde.getKeyPSAppDEField().getCodeName()?lower_case}; return i.mobentityid == item.mobentityid;
}); });
let re = false; let re = true;
if(count == -1){ if(count == -1){
re = true; re = false;
this.selectedArray.push(item);
}else{
this.selectedArray.splice(count,1);
} }
this.items.forEach((_item:any,index:number)=>{ this.items.forEach((_item:any,index:number)=>{
if(_item.${appde.getKeyPSAppDEField().getCodeName()?lower_case} == item.${appde.getKeyPSAppDEField().getCodeName()?lower_case}){ if(_item.mobentityid == item.mobentityid){
this.items[index].checked = re; this.items[index].checked = re;
} }
}); });
console.log(this.items);
this.$forceUpdate();
}
} }
/** /**
...@@ -771,8 +779,8 @@ ...@@ -771,8 +779,8 @@
* *
* @memberof ${srfclassname('${ctrl.name}')} * @memberof ${srfclassname('${ctrl.name}')}
*/ */
public checkboxAll(item:any) { public checkboxAll() {
this.selectAllIschecked = item.detail.checked; this.$refs.checkboxGroup.toggleAll();
if(this.selectAllIschecked){ if(this.selectAllIschecked){
this.selectedArray = JSON.parse(JSON.stringify(this.items)); this.selectedArray = JSON.parse(JSON.stringify(this.items));
}else{ }else{
...@@ -781,17 +789,27 @@ ...@@ -781,17 +789,27 @@
this.items.forEach((item:any,index:number)=>{ this.items.forEach((item:any,index:number)=>{
this.items[index].checked = this.selectAllIschecked this.items[index].checked = this.selectAllIschecked
}); });
this.$forceUpdate();
} }
/** /**
* 全选按钮选中状态 * 监听选中数组(全选,反选)
* *
* @memberof ${srfclassname('${ctrl.name}')} * @memberof ${srfclassname('${ctrl.name}')}
*/ */
public selectAllIschecked = false; @Watch('selectedArray')
onItemSelectChange(newVal: any, oldVal: any) {
if (!newVal) {
return;
}
let flag = this.items.every((currVal: any)=>{
return currVal.checked === true
})
if(flag){
this.selectAllIschecked = true
} else {
this.selectAllIschecked = false
}
}
/** /**
* 关闭滑动项 * 关闭滑动项
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册