十五、导入js
new Element("script", { "rel": "javascript", "type": "text/javascript", "href": "http://172.16.91.7/web-apps/apps/api/documents/api.js" }).inject($(document.head));
1、前端脚本调用接口
var data = "{}"; var res=[]; new Request({ method:"post", async:false, url: o2.Actions.getHost("x_program_center") + "/x_program_center/jaxrs/invoke/getData/execute", headers:{'Content-Type':'application/json;charset=utf-8'}, data:JSON.stringify(data), onRequest:function(){ }, onSuccess:function(responseText){ var responsejson = JSON.parse(responseText); var val = responsejson.data.value; res = val.split(","); }, onFailure:function(){ alert("error"); } }).send(); return res;
2、接口获取自表数据
print("this.requestText="+this.requestText); var data = {}; data["type"] = "select"; data["data"] = "select o from newTable o where 1>0"; data["maxResults"] = "20"; data["firstResult"] = "0"; var flag = "newTable"; var res = ""; var string = JSON.stringify(data); var applications = this.applications; var serviceRoot = "x_query_assemble_designer"; var path = "table/"+flag+"/execute"; var resp = applications.postQuery( serviceRoot, path , string); var json = JSON.parse( resp.toString() ); var arr = json.data; for(var i =0 ;i< arr.length;i++){ if(res == ""){ res = arr[i].name; }else{ res =res + "," + arr[i].name; } } res
var tt = this.form.get("personType"); var selData = tt.getData(); var element = this.form.get("table_table$Td_16"); var element17 = this.form.get("table_table$Td_17"); if("合作方"== selData){ debugger; element.node.style.display="none"; element17.node.style.display="none"; }else{ debugger; element.node.style.display=""; element17.node.style.display=""; } 六、通过群组获取人员身份 var groupList = this.org.getGroup( "test" ); var personList =groupList.personList; var ipersonList = []; for(var i=0;i <personList.length;i++){ var personList2 = this.org.listIdentityWithPerson(personList[i] ); if( personList2.length > 0){ ipersonList.push(personList2[0].distinguishedName); } } return ipersonList; 七、通过职务获取人员身份 var dutyName = "班组长"; var unit = "xxhb"; var identityList = this.org.getDuty( dutyName, unit ); return [identityList[0].distinguishedName]; var dutyName = "部门经理"; var task = this.workContext.getTask(); var unit = task.creatorUnit; var identityList = this.org.getDuty( dutyName, unit ); return [identityList[0].distinguishedName]; 八、通过角色获了人员身份 var roleList = this.org.getRole( "test" ); debugger; var personList = roleList.personList; var iperson = []; debugger; for(var i=0;i < personList.length;i++){ var personList2 = this.org.listIdentityWithPerson( personList[i] ); iperson[i] = personList2[0].distinguishedName; } return iperson; 九、获取发起人部门 var task = this.workContext.getTask(); return task.creatorUnit; 十、获起发起人 return this.workContext.getTask().creatorPerson; 十一、获取手机号 var person = this.org.getPerson( this.workContext.getTask().creatorPerson ); return person.mobile; 十二、表单域取值与赋值 var tt = this.form.get("org"); var selData = tt.getData(); var selName = selData[0].personDn; debugger; this.form.get("dep").setData(selData[0].unitName); this.form.get("textfield").setData(selData[0].personEmployee); var person = this.org.getPerson( selName ); this.form.get("mobile").setData(person.mobile); 十三、创建待阅 var data = {}; data["identityList"] = ['办公室员工@a48222f1-8d15-497b-b79c-a11544505809@I']; data["notify"] = "请阅"; //var work = this.workContext.getWork(); //var workId = work.id; var workId = "ae3268d3-88b5-4d62-acc4-5a258e2f34d5"; print("workId=" + workId); var string = JSON.stringify(data); var applications = this.applications; var serviceRoot = "x_processplatform_service_processing"; var path = "read/work/"+workId; var resp = applications.postQuery( serviceRoot, path , string); print(resp.toString() ); 十四、获取编号 var work = this.workContext.getWork(); return work.serial; 十五、保存长文本 var filePath = "e:o2oa_pcp.json"; var readFile = Java.type('com.x.custom.ReadFile'); var testinstan = readFile.encodeBase64File(filePath); print(testinstan); var tableFlag = "z_info"; data = {"id_info":"2","name":"eeee","infofile":testinstan}; var action = this.Actions.load("x_query_assemble_surface"); action.TableAction.rowInsert(//平台封装好的方法 tableFlag,//uri的参数 data,//body请求参数 function( json ){ //服务调用成功的回调函数, json为服务传回的数据 data = json.data; //为变量data赋值 }.bind(this), function( json ){ //服务调用失败的回调函数, json为服务传回的数据 data = json.data; //为变量data赋值 }.bind(this) );
new Element("script", { "rel": "javascript", "type": "text/javascript", "href": "http://172.16.91.7/web-apps/apps/api/documents/api.js" }).inject($(document.head));
上一篇:快速入门-平台相关资料汇总
下一篇:快速入门-自定义表数据分页样例