//安装点设置搜索帮助框
var setPointInputField = new com.sap.me.control.Input({
id : this.createId('setPointInput'),
maxLength : 40,
width : "230px",
placeholder : util.I18NUtility.getLocaleSpecificText("slotconfig.default.label"),
showClear : true,
showBrowse : true,
upperCase : true,
browseTap : [ oCon.browseSetPointTap, oCon ],//搜索帮助框
//change : [ oCon.setPointInputChange, oCon ],//值改变事件
,clearTap : [ oCon.clearResourceTap, oCon ]//清楚按钮
});
处理事件:
// 安装点设置搜索帮助框
browseSetPointTap : function(evt) {
var oView = this.getView();
if (!oView) {
jQuery.sap.log.error("ResourceSlot.browseResourceTap: view for controller not defined");
return;
}
var setPointInputValue = oView.byId("setPointInput").getValue();
var uriParam = "site=" + util.Model.getData(util.CommonKey.CurrentSite);
if (!util.StringUtil.isBlank(setPointInputValue)) {
uriParam = uriParam + "&setPointInput=" + setPointInputValue;
}
var OModel = null;
//请求后台获取data
var data = util.IOUtil.sendRemoteRequest("/atlmesodata/ResourceSlot.svc/CusBrowsers?" + uriParam, "GET",
null,this.completeSuccessCallback,
this.errorCallback, null, false);
oModel = util.IOUtil.toModel(data, "CusBrowsers");
if (oModel) {
sap.ui.getCore().setModel(oModel,"codeModel");
util.Model.setData("oModel",data);
}
var bus = sap.ui.getCore().getEventBus();
bus.publish("nav", "to", {
id : "CustomBrowse",//跳转界面类名
data : {
namespace : "com.sap.me.browse.view",//跳转界面类路径
fromId : "ResourceSlot",//当前界面类名
fromNamespace : "com.sap.me.production.view"//当前界面类路径
}
});
},
sap.ui.jsview("com.sap.me.browse.view.CustomBrowse", {
//客制化搜索帮助框
getControllerName : function() {
return "com.sap.me.browse.view.CustomBrowse";
},
onBeforeShow : function(evt) {
this.getController().onBeforeShow(evt);
},
createContent : function(oCon) {
// 创建一个list容器存放数据
this.browseList = new sap.m.List( {
id : this.createId('browseList'),
showNoData : false,
includeItemInSelection : true,
inset : true
});
//给list绑定数据
this.browseList.bindAggregation("items", {
path : "codeModel>/CusBrowsers",
template : new sap.m.StandardListItem( {
title : "{codeModel>codes}",
description : "{codeModel>description}",
type : sap.m.ListType.Navigation,
tap : [ oCon.browseListTap, oCon ]//双击选中的值时回到主界面
})
});
// create page
this.page = new sap.m.Page( {
id : this.createId('CustomBrowsePage'),
title : util.I18NUtility.getLocaleSpecificText("OPERATION_BROWSE.title.TEXT"),
icon : util.I18NUtility.getLocaleSpecificText("ME_MOBILE.title.ICON"),
showNavButton : true,
navButtonTap : [ oCon.navButtonTap, oCon ],
content : [ this.browseList ]//上面定义的list
});
return this.page;
}
});
jQuery.sap.require("sap.m.MessageBox");
sap.ui.controller("com.sap.me.browse.view.CustomBrowse", {
onInit : function() {
},
onBeforeShow : function(evt) {
jQuery.sap.log.debug("odataRequestErrorCallback: ");
if (evt.data.context) {
this.getView().setBindingContext(evt.data.context);
}
util.Model.setData("TEMP_FromId", evt.data.fromId);
util.Model.setData("TEMP_FromNamespace", evt.data.fromNamespace);
},
//点击选中的值带回到主界面
browseListTap : function(evt) {
var oSource = evt.getSource();
if (oSource) {
util.Model.setData(util.ModelKey.CustomBrowser, oSource.getTitle());
}
//在util.ModelKey下新建CustomBrowser为ModelKey新定义的//客制化browser by wenfengxing
// CustomBrowser : "CustomBrowser"
this.navButtonTap();
},
navButtonTap : function(evt) {
var fromId = util.Model.getData("TEMP_FromId");
var fromNamespace = util.Model.getData("TEMP_FromNamespace");
var bus = sap.ui.getCore().getEventBus();
bus.publish("nav", "back", {
id : fromId,
data : {
namespace : fromNamespace
}
});
}
});
@Override
public ODataResponse readEntitySet(GetEntitySetUriInfo uriInfo, String contentType) throws ODataException {
Utils.traceMsg("ResourceSlotSingleProcessor readEntitySet started", Utils.DEBUGGING);
EdmEntitySet entitySet;
if (uriInfo.getNavigationSegments().size() == 0) {
entitySet = uriInfo.getStartEntitySet();
if ("Tables".equals(entitySet.getName())) {// 检索
String record = uriInfo.getCustomQueryOptions().get("RESOURCE");// 资源
return EntityProvider.writeFeed(contentType, entitySet, this.getTable(record), EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build());
}
if ("CusBrowsers".equals(entitySet.getName())) {// 搜索帮助框
String setPointInputValue = uriInfo.getCustomQueryOptions().get("setPointInput");// 设置点
String site = uriInfo.getCustomQueryOptions().get("site");
return EntityProvider.writeFeed(contentType, entitySet, this.getBrowser(site,setPointInputValue), EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build());
}
Utils.traceMsg("ResourceSlotSingleProcessor readEntitySet Ended", Utils.DEBUGGING);
}
return super.readEntitySet(uriInfo, contentType);
}
private List<Map<String, Object>> getBrowser(String site, String setPointInputValue) throws ODataApplicationException {
Utils.traceMsg("EquipmentInspectionSingleProcessor getTable excuted Started ", Utils.DEBUGGING);
List<Map<String, Object>> res = new ArrayList<Map<String, Object>>();
try {
//String site = CommonMethods.getSite();
//String user = CommonMethods.getUserId();
for (int i = 0; i < 5; i++) {
BrowserObject recordConfig = new BrowserObject();
recordConfig.setCodes("001");
recordConfig.setDescription("第一个");
Map<String, Object> row = OdataUtils.convertToMap(recordConfig);
row.put("site", CommonMethods.getSite());
res.add(row);
}
} catch (Exception e) {
String msg = e.getMessage();
throw new ODataApplicationException(msg, MessageHandler.getUserPreferedLocale(), HttpStatusCodes.INTERNAL_SERVER_ERROR, e);
}
Utils.traceMsg("EquipmentInspectionSingleProcessor getTable excuted Ended ", Utils.DEBUGGING);
return res;
}