功能:添加手机即可绑定人员(前提已经注册),可添加管理门店及信息
类:StoreMemberController
视图:member_list.ftl、member_edit.ftl
遇到的问题:门店显示、获取ID值、列表通过门店ID显示门店Name
一、门店显示
method:
public void getPowerStores() {
String sql = "select 1 as checked,id,name from store_info where user_id=?";
if(!SH.getUser().getStoreUserId().equals("master")) {
sql += "and id in (" +
"select " +
"store_id " +
"from store_user_power " +
"where user_name ='"+SH.getUser().getStoreUserId()+"'" +
")";
}
List<Record> cates=Db.find(sql, SH.getUser().getUserId());
this.renderJson(cates);
}
ftl:使用angular内置的行选择,模仿原生的checkbox,方便排版
<div class="control-group">
<label class="control-label" style="width:100px;">可管理门店: </label>
<div class="controls" style="margin-left:120px;" >
<span style="cursor:pointer;" ng-repeat="store in stores" ng-click="check(store);">
<div class="checker"><span ng-class="{checked:(store.checked==1)}"></span></div>
<lable ng-bind="store.name"></lable>
</span>
</div>
</div>
angularJS:
$scope.check=function(store){ //行单击事件
if(store.checked==1){
store.checked=0;
}else{
store.checked=1;
}
};
$http.post("home/member/getPowerStores").success(function(data){
//alert(angular.toJson(data));
$scope.stores = data;
angular.forEach($scope.stores,function(store){
if($scope.stores.indexOf(store.id) >=0 ){
store.checked == 1;
}
});
});