mwf.xscript = mwf.xscript || {};
mwf.xscript.cmsenvironment = function(ev){
var _data = ev.data;
var _form = ev.form;
var _forms = ev.forms;
this.apptype = "cms";
this.library = common;
//this.library.version = "4.0";
//data
var getjsondata = function(jdata){
return new mwf.xscript.cmsjsondata(jdata, function(data, key, _self){
var p = {"getkey": function(){return key;}, "getparent": function(){return _self;}};
while (p && !_forms[p.getkey()]) p = p.getparent();
var k = (p) ? p.getkey() : "";
if (k) if(_forms[k]) if(_forms[k].resetdata) _forms[k].resetdata();
}, "", null, _form);
};
this.setdata = function(data){
this.data = getjsondata(data);
this.data.save = function(callback){
_form.documentaction.savedata(function(json){if (callback) callback();}.bind(this), null, ev.document.id, data);
}
};
this.setdata(_data);
//task
//this.task = ev.task;
//this.task.process = function(routename, opinion, callback){
// _form.submitwork(routename, opinion, callback);
//};
//inquiredroutelist
//this.inquiredroutelist = null;
//workcontext
/**
* 您可以通过documentcontext获取内容管理实例相关的对象数据。
* @module documentcontext
* @o2cn 内容管理实例
* @o2category web
* @o2range {cms}
* @o2ordernumber 30
* @example
* //您可以在内容管理表单中,通过this来获取当前实例的documentcontext对象,如下:
* var context = this.documentcontext;
*/
this.documentcontext = {
// * @o2actionout x_cms_assemble_control.wodocument|ignorenodescr=true|example=document
/**
* 获取当前内容管理实例的文档对象:document对象。
* @method getdocument
* @static
* @return {document} 文档对象.
* {
* "id": "3359aedd-c2d8-4d8c-b8b0-02507da1b3f4", //数据库主键,自动生成.
* "summary": " ", //文档摘要
* "title": "航天科工外部董事调研组到培训中心调研", //文档标题
* "documenttype": "信息", //文档类型,跟随分类类型,信息 | 数据
* "appid": "c295f34c-9ce1-4122-b795-820267e32b68", //栏目id
* "appname": "游戏厅捕鱼达人的公告", //栏目名称
* "appalias": " ", //栏目别名
* "categoryid": "33fb19f0-0670-464d-875c-32fb86148f7a", //分类id
* "categoryname": "游戏厅捕鱼达人的公告", //分类名称
* "categoryalias": "游戏厅捕鱼达人的公告-游戏厅捕鱼达人的公告", //分类别名
* "form": "dddefed4-4411-4e4e-b982-cdd4cd083443", //绑定的表单模板id
* "formname": "游戏厅捕鱼达人的公告编辑表单", //绑定的表单模板名称
* "importbatchname": " ", //文件导入的批次号:一般是分类id 时间缀
* "readformid": "d6f1f596-fcb7-4a87-baaf-7f6cdafe3cec", //绑定的阅读表单模板id
* "readformname": "游戏厅捕鱼达人的公告阅读表单", //绑定的阅读表单模板名称
* "creatorperson": "李义@liyi@p", //创建人,可能为空,如果由系统创建。
* "creatoridentity": "李义@469d1601-c4a5-46ae-b7bf-4da9af07b6fa@i", //创建人identity,可能为空,如果由系统创建。
* "creatorunitname": "浙江兰德纵横@a706f5f0-4a3b-4785-8e1d-0a944bfad4eb@u", //创建人组织,可能为空,如果由系统创建。
* "creatortopunitname": "浙江兰德纵横@a706f5f0-4a3b-4785-8e1d-0a944bfad4eb@u", //创建人顶层组织,可能为空,如果由系统创建。
* "docstatus": "published", //文档状态: waitpublished | published | draft | checking | error
* "description": " ", //说明备注,可以填写说明信息,如导入信息检验失败原因等
* "viewcount": 1, //文档被查看次数
* "commendcount": 1, //文档被赞次数
* "commentcount": 1, //文档评论次数
* "publishtime": "2018-01-04 14:17:16", //文档发布时间
* "modifytime": "2022-09-01 17:05:47", //文档修改时间
* "istop": true, //是否置顶
* "hasindexpic": true, //是否含有游戏厅捕鱼达人首页图片
* "reviewed": true, //是否已经更新review信息.
* "sequencetitle": " ", //用于标题排序的sequence
* "sequenceappalias": " ", //用于栏目别名排序的sequence
* "sequencecategoryalias": " ", //用于分类别名排序的sequence
* "sequencecreatorperson": " ", //用于创建者排序的sequence
* "sequencecreatorunitname": " ", //用于创建者组织排序的sequence
* "readpersonlist": [
* "张三@zhangsan@p"
* "所有人"
* ], //阅读人员
* "readunitlist": [
* ], //阅读组织
* "readgrouplist": [
* ], //阅读群组
* "authorpersonlist": [
* "张三@zhangsan@p"
* ], //作者人员
* "authorunitlist": [
* ], //作者组织
* "authorgrouplist": [
* ], //作者群组
* "remindpersonlist": [
* " "
* ], //发布提醒人员
* "remindunitlist": [
* " "
* ], //发布提醒组织
* "remindgrouplist": [
* " "
* ], //发布提醒群组
* "managerlist": [
* "张三@zhangsan@p"
* ], //管理者
* "picturelist": [
* ], //游戏厅捕鱼达人首页图片列表
* "distributefactor": 1, //分布式存储标识位.
* "createtime": "2022-09-01 17:05:47", //创建时间,自动生成,索引创建在约束中.
* "updatetime": "2022-09-01 17:05:47", //修改时间,自动生成,索引创建在约束中.
* "sequence": " ", //列表序号,由创建时间以及id组成.在保存时自动生成,索引创建在约束中.
* "stringvalue01": "", //业务数据string值01.
* "stringvalue02": "", //业务数据string值02.
* "stringvalue03": "", //业务数据string值03.
* "stringvalue04": "", //业务数据string值04.
* "stringvalue05": "", //业务数据string值05.
* "stringvalue06": "", //业务数据string值06.
* "stringvalue07": "", //业务数据string值07.
* "stringvalue08": "", //业务数据string值08.
* "stringvalue09": "", //业务数据string值09.
* "stringvalue10": "", //业务数据string值10.
* "longvalue01": "", //业务数据long值01.
* "longvalue02": "", //业务数据long值02.
* "doublevalue01": "", //业务数据double值01.
* "doublevalue02": "", //业务数据double值02.
* "datetimevalue01": "", //业务数据datetime值01.
* "datetimevalue02": "", //业务数据datetime值02.
* "datetimevalue03": "", //业务数据datetime值03.
* }
*
* @o2syntax
* var doc = this.documentcontext.getdocument();
*/
"getdocument": function(){return ev.document },
/**
* 获取当前人对文档的权限。
* @method getcontrol
* @static
* @return {documentcontrol} 当前人对文档所拥有的权限.
* {
* "allowread": true, //是否允许阅读文档
* "allowpublishdocument": true, //是否允许发布文档
* "allowsave": true, //是否允许保存文档
* "allowpopulardocument": true, //是否允许设置为热点
* "alloweditdocument": true, //是否允许编辑文档
* "allowdeletedocument": true //是否允许删除文档
* }
* @o2syntax
* var control = this.documentcontext.getcontrol();
*/
"getcontrol": function(){return ev.control;},
/**
* 获取当前文档的附件对象列表。
* @method getattachmentlist
* @static
* @return {documentfileinfo[]} 当前文档的附件对象列表.
* @o2actionout x_cms_assemble_control.fileinfoaction.get|example=attachment|ignoreprops=[properties]
* @o2syntax
* var attachmentlist = this.documentcontext.getattachmentlist();
*/
"getattachmentlist": function(){return ev.attachmentlist;}
//"settitle": function(title){
// if (!this.workaction){
// mwf.require("mwf.xscript.actions.workactions", null, false);
// this.workaction = new mwf.xscript.actions.workactions();
// }
// this.workaction.settitle(ev.work.id, {"title": title});
//}
};
//dict
this.dict = mwf.xscript.createcmsdict(_form.json.application, "cms");
//org
var orgactions = null;
var getorgactions = function(){
// if (!orgactions){
// mwf.xdesktop.requireapp("org", "actions.restactions", null, false);
// orgactions = new mwf.xapplication.org.actions.restactions ();
// }
if (!orgactions){
mwf.require("mwf.xscript.actions.unitactions", null, false);
orgactions = new mwf.xscript.actions.unitactions();
}
};
var getnameflag = function(name){
var t = typeof(name);
if (t==="array"){
var v = [];
name.each(function(id){
v.push((typeof(id)==="object") ? (id.distinguishedname || id.id || id.unique || id.name) : id);
});
return v;
}else{
return [(t==="object") ? (name.distinguishedname || name.id || name.unique || name.name) : name];
}
};
this.org = {
//群组***************
//获取群组--返回群组的对象数组
getgroup: function(name, async){
getorgactions();
var data = {"grouplist": getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
v = (v && v.length===1) ? v[0] : v
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listgroup(data, cb, null, !!async);
return (!!async) ? promise : v;
// var v = null;
// orgactions.listgroup(data, function(json){v = json.data;}, null, false);
// return (v && v.length===1) ? v[0] : v;
},
//查询下级群组--返回群组的对象数组
//nested 布尔 true嵌套下级;false直接下级;默认false;
listsubgroup: function(name, nested, async){
getorgactions();
var data = {"grouplist": getnameflag(name)};
var v = null;
// var cb = ((async && o2.typeof(async)=="function") ? (async.isag ? async : async.ag()) : null) || function(json){
// v = json.data;
// return v;
// }.ag().catch(function(json){ return json; });
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise;
if (nested){
promise = orgactions.listsubgroupnested(data, cb, null, !!async);
}else{
promise = orgactions.listsubgroupdirect(data, cb, null, !!async);
}
return (!!async) ? promise : v;
// var v = null;
// if (nested){
// orgactions.listsubgroupnested(data, function(json){v = json.data;}, null, false);
// }else{
// orgactions.listsubgroupdirect(data, function(json){v = json.data;}, null, false);
// }
// return v;
},
//查询上级群组--返回群组的对象数组
//nested 布尔 true嵌套上级;false直接上级;默认false;
listsupgroup:function(name, nested, async){
getorgactions();
var data = {"grouplist": getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise
if (nested){
var promise = orgactions.listsupgroupnested(data, cb, null, !!async);
}else{
var promise = orgactions.listsupgroupdirect(data, cb, null, !!async);
}
return (!!async) ? promise : v;
// var v = null;
// if (nested){
// orgactions.listsupgroupnested(data, function(json){v = json.data;}, null, false);
// }else{
// orgactions.listsupgroupdirect(data, function(json){v = json.data;}, null, false);
// }
// return v;
},
//人员所在群组(嵌套)--返回群组的对象数组
listgroupwithperson:function(name, async){
getorgactions();
var data = {"personlist": getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listgroupwithperson(data, cb, null, !!async);
return (!!async) ? promise : v;
// var v = null;
// orgactions.listgroupwithperson(data, function(json){v = json.data;}, null, false);
// return v;
},
//身份所在群组(嵌套)--返回群组的对象数组
listgroupwithidentity:function(identity, async){
getorgactions();
var data = {"identitylist": getnameflag(identity)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listgroupwithidentity(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//群组是否拥有角色--返回true, false
grouphasrole: function(name, role, async){
getorgactions();
nameflag = (typeof(name)==="object") ? (name.distinguishedname || name.id || name.unique || name.name) : name;
var data = {"group":nameflag,"rolelist":getnameflag(role)};
var v = false;
var cb = function(json){
v = json.data.value;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.grouphasrole(data, cb, null, !!async);
return (!!async) ? promise : v;
// var v = false;
// orgactions.grouphasrole(data, function(json){v = json.data.value;}, null, false);
// return v;
},
//角色***************
//获取角色--返回角色的对象数组
getrole: function(name, async){
getorgactions();
var data = {"rolelist": getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
v = (v && v.length===1) ? v[0] : v;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listrole(data, cb, null, !!async);
return (!!async) ? promise : v;
// var v = null;
// orgactions.listrole(data, function(json){v = json.data;}, null, false);
// return (v && v.length===1) ? v[0] : v;
},
//人员所有角色(嵌套)--返回角色的对象数组
listrolewithperson:function(name, async){
getorgactions();
var data = {"personlist": getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listrolewithperson(data, cb, null, !!async);
return (!!async) ? promise : v;
// var v = null;
// orgactions.listrolewithperson(data, function(json){v = json.data;}, null, false);
// return v;
},
//人员***************
//人员是否拥有角色--返回true, false
personhasrole: function(name, role, async){
getorgactions();
nameflag = (typeof(name)==="object") ? (name.distinguishedname || name.id || name.unique || name.name) : name;
var data = {"person":nameflag,"rolelist":getnameflag(role)};
var v = false;
var cb = function(json){
v = json.data.value;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.personhasrole(data, cb, null, !!async);
return (!!async) ? promise : v;
// var v = false;
// orgactions.personhasrole(data, function(json){v = json.data.value;}, null, false);
// return v;
},
//获取人员,附带身份,身份所在的组织,个人所在群组,个人拥有角色.
getpersondata: function(name, async){
getorgactions();
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.getperson(null, cb, null, !!async, {"flag": name});
return (!!async) ? promise : v;
},
//获取人员--返回人员的对象数组
getperson: function(name, async, findcn){
getorgactions();
var data = {"personlist": getnameflag(name)};
if( o2.typeof(findcn) === "boolean"){
data.usenamefind = findcn;
}
var v = null;
var cb = function(json){
v = json.data;
v = (v && v.length===1) ? v[0] : v;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listperson(data, cb, null, !!async);
return (!!async) ? promise : v;
// var v = null;
// orgactions.listperson(data, function(json){v = json.data;}, null, false);
// return (v && v.length===1) ? v[0] : v;
},
//查询下级人员--返回人员的对象数组
//nested 布尔 true嵌套下级;false直接下级;默认false;
listsubperson: function(name, nested, async){
getorgactions();
var data = {"personlist": getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise;
if (nested){
promise = orgactions.listpersonsubnested(data, cb, null, !!async);
}else{
promise = orgactions.listpersonsubdirect(data, cb, null, !!async);
}
return (!!async) ? promise : v;
},
//查询上级人员--返回人员的对象数组
//nested 布尔 true嵌套上级;false直接上级;默认false;
listsupperson: function(name, nested, async){
getorgactions();
var data = {"personlist": getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise;
if (nested){
promise = orgactions.listpersonsupnested(data, cb, null, !!async);
}else{
promise = orgactions.listpersonsupdirect(data, cb, null, !!async);
}
return (!!async) ? promise : v;
},
//获取群组的所有人员--返回人员的对象数组
listpersonwithgroup: function(name, async){
getorgactions();
var data = {"grouplist": getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listpersonwithgroup(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//获取角色的所有人员--返回人员的对象数组
listpersonwithrole: function(name, async){
getorgactions();
var data = {"rolelist": getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise
promise = orgactions.listpersonwithrole(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//获取身份的所有人员--返回人员的对象数组
listpersonwithidentity: function(name, async){
getorgactions();
var data = {"identitylist": getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listpersonwithidentity(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//获取身份的所有人员--返回人员的对象数组或人员对象
getpersonwithidentity: function(name, async){
getorgactions();
var data = {"identitylist": getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
v = (v && v.length===1) ? v[0] : v;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listpersonwithidentity(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//查询组织成员的人员--返回人员的对象数组
//nested 布尔 true嵌套的所有成员;false直接成员;默认false;
listpersonwithunit: function(name, nested, async){
getorgactions();
var data = {"unitlist": getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise;
if (nested){
promise = orgactions.listpersonwithunitnested(data, cb, null, !!async);
}else{
promise = orgactions.listpersonwithunitdirect(data, cb, null, !!async);
}
return (!!async) ? promise : v;
},
//根据属性查询人员--返回人员的对象数组
//name string 属性名
//value string 属性值
listpersonwithattribute: function(name, value, async){
getorgactions();
var data = {"name": name, "attribute": value};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listpersonwithattribute(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//根据属性查询人员--返回人员的全称数组
//name string 属性名
//value string 属性值
listpersonnamewithattribute: function(name, value, async){
getorgactions();
var data = {"name": name, "attribute": value};
var v = null;
var cb = function(json){
v = json.data.personlist;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listpersonwithattributevalue(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//人员属性************
//添加人员属性值(在属性中添加values值,如果没有此属性,则创建一个)
appendpersonattribute: function(person, attr, values, success, failure, async){
getorgactions();
var personflag = (typeof(person)==="object") ? (person.distinguishedname || person.id || person.unique || person.name) : person;
var data = {"attributelist":values,"name":attr,"person":personflag};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.appendpersonattribute(data, cb, null, !!async);
return (!!async) ? promise : v;
// var cb = function(json){
// if (success) return success(json);
// }.ag().catch(function(xhr, text, error){
// if (failure) return failure(xhr, text, error);
// });
//
// orgactions.appendpersonattribute(data, cb, null, !!async);
},
//设置人员属性值(将属性值修改为values,如果没有此属性,则创建一个)
setpersonattribute: function(person, attr, values, success, failure, async){
getorgactions();
var personflag = (typeof(person)==="object") ? (person.distinguishedname || person.id || person.unique || person.name) : person;
var data = {"attributelist":values,"name":attr,"person":personflag};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.setpersonattribute(data, cb, null, !!async);
return (!!async) ? promise : v;
// var cb = function(json){
// if (success) return success(json);
// }.ag().catch(function(xhr, text, error){
// if (failure) return failure(xhr, text, error);
// });
//
// orgactions.setpersonattribute(data, cb, null, !!async);
},
//获取人员属性值
getpersonattribute: function(person, attr, async){
getorgactions();
var personflag = (typeof(person)==="object") ? (person.distinguishedname || person.id || person.unique || person.name) : person;
var data = {"name":attr,"person":personflag};
var v = null;
var cb = function(json){
v = json.data.attributelist;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.getpersonattribute(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//列出人员所有属性的名称
listpersonattributename: function(name, async){
getorgactions();
var data = {"personlist":getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data.namelist;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listpersonattributename(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//列出人员的所有属性
listpersonallattribute: function(name, async){
getorgactions();
var data = {"personlist":getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listpersonallattribute(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//身份**********
//获取身份
getidentity: function(name, async){
getorgactions();
var data = {"identitylist":getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
v = (v && v.length===1) ? v[0] : v;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listidentity(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//列出人员的身份
listidentitywithperson: function(name, async, findcn){
getorgactions();
var data = {"personlist":getnameflag(name)};
if( o2.typeof(findcn) === "boolean"){
data.usenamefind = findcn;
}
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listidentitywithperson(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//查询组织成员身份--返回身份的对象数组
//nested 布尔 true嵌套的所有成员;false直接成员;默认false;
listidentitywithunit: function(name, nested, async){
getorgactions();
var data = {"unitlist": getnameflag(name)};
var v = null;
// var cb = function(json){
// v = json.data;
// if (async && o2.typeof(async)=="function") return async(v);
// return v;
// }.ag().catch(function(json){ return json; });
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var method = (nested) ? "listidentitywithunitnested" : "listidentitywithunitdirect";
var promise = orgactions[method](data, cb, null, !!async);
promise.name = "org";
//
// if (nested){
// orgactions.listidentitywithunitnested(data, cb, null, !!async);
// }else{
// orgactions.listidentitywithunitdirect(data, cb, null, !!async);
// }
return (!!async) ? promise : v;
},
//组织**********
//获取组织
getunit: function(name, async, findcn){
getorgactions();
var data = {"unitlist":getnameflag(name)};
if( o2.typeof(findcn) === "boolean"){
data.usenamefind = findcn;
}
var v = null;
var cb = function(json){
v = json.data;
v = (v && v.length===1) ? v[0] : v;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listunit(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//查询组织的下级--返回组织的对象数组
//nested 布尔 true嵌套下级;false直接下级;默认false;
listsubunit: function(name, nested, async){
getorgactions();
var data = {"unitlist": getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise;
if (nested){
promise = orgactions.listunitsubnested(data, cb, null, !!async);
}else{
promise = orgactions.listunitsubdirect(data, cb, null, !!async);
}
return (!!async) ? promise : v;
},
//查询组织的上级--返回组织的对象数组
//nested 布尔 true嵌套上级;false直接上级;默认false;
//async 布尔 true异步请求
listsupunit: function(name, nested, async){
getorgactions();
var data = {"unitlist": getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise;
if (nested){
promise = orgactions.listunitsupnested(data, cb, null, !!async);
}else{
promise = orgactions.listunitsupdirect(data, cb, null, !!async);
}
return (!!async) ? promise : v;
// if (callback){
// if (nested){
// orgactions.listunitsupnested(data, function(json){v = json.data; o2.runcallback(callback, "success", [v], this);});
// }else{
// orgactions.listunitsupdirect(data, function(json){v = json.data; o2.runcallback(callback, "success", [v], this);});
// }
// }else{
// var v = null;
// if (nested){
// orgactions.listunitsupnested(data, function(json){v = json.data;}, null, false);
// }else{
// orgactions.listunitsupdirect(data, function(json){v = json.data;}, null, false);
// }
// return v;
// }
},
//根据个人身份获取组织
//flag 数字 表示获取第几层的组织
// 字符串 表示获取指定类型的组织
// 空 表示获取直接所在的组织
getunitbyidentity: function(name, flag, async){
getorgactions();
var getunitmethod = "current";
var v;
if (flag){
if (typeof(flag)==="string") getunitmethod = "type";
if (typeof(flag)==="number") getunitmethod = "level";
}
var cb;
var promise;
switch (getunitmethod){
case "current":
var data = {"identitylist":getnameflag(name)};
// var cb = ((async && o2.typeof(async)=="function") ? (async.isag ? async : async.ag()) : null) || function(json){
// v = json.data; v=(v&&v.length===1) ? v[0] : v; return v;
// }.ag().catch(function(json){ return json; });
cb = function(json){
v = json.data; v=(v&&v.length===1) ? v[0] : v;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
promise = orgactions.listunitwithidentity(data, cb, null, !!async);
break;
case "type":
var data = {"identity":(typeof(name)==="object") ? (name.distinguishedname || name.id || name.unique || name.name) : name,"type":flag};
cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
// var cb = ((async && o2.typeof(async)=="function") ? (async.isag ? async : async.ag()) : null) || function(json){
// v = json.data; return v;
// }.ag().catch(function(json){ return json; });
promise = orgactions.getunitwithidentityandtype(data, cb, null, !!async);
break;
case "level":
var data = {"identity":(typeof(name)==="object") ? (name.distinguishedname || name.id || name.unique || name.name) : name,"level":flag};
cb = function(json){
v = json.data; v=(v&&v.length===1) ? v[0] : v;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
// var cb = ((async && o2.typeof(async)=="function") ? (async.isag ? async : async.ag()) : null) || function(json){
// v = json.data; return v;
// }.ag().catch(function(json){ return json; });
promise = orgactions.getunitwithidentityandlevel(data, cb, null, !!async);
break;
}
return (!!async) ? promise : v;
},
//列出身份所在组织的所有上级组织
listallsupunitwithidentity: function(name, async){
getorgactions();
var data = {"identitylist":getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listunitsupnestedwithidentity(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//获取人员所在的所有组织
listunitwithperson: function(name, async){
getorgactions();
var data = {"personlist":getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listunitwithperson(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//列出人员所在组织的所有上级组织
listallsupunitwithperson: function(name, async){
getorgactions();
var data = {"personlist":getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listunitsupnestedwithperson(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//根据组织属性,获取所有符合的组织
listunitwithattribute: function(name, attribute, async){
getorgactions();
var data = {"name":name,"attribute":attribute};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
promise = orgactions.listunitwithattribute(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//根据组织职务,获取所有符合的组织
listunitwithduty: function(name, id, async){
getorgactions();
var data = {"name":name,"identity":(typeof(id)==="object") ? (id.distinguishedname || id.id || id.unique || id.name) : id};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listunitwithduty(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//组织职务***********
//获取指定的组织职务的身份
getduty: function(duty, id, async){
getorgactions();
var data = {"name":duty,"unit":(typeof(id)==="object") ? (id.distinguishedname || id.id || id.unique || id.name) : id};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.getduty(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//获取身份的所有职务名称
listdutynamewithidentity: function(name, async){
getorgactions();
var data = {"identitylist":getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data.namelist;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listdutynamewithidentity(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//获取组织的所有职务名称
listdutynamewithunit: function(name, async){
getorgactions();
var data = {"unitlist":getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data.namelist;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listdutynamewithunit(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//获取组织的所有职务
listunitallduty: function(name, async){
getorgactions();
var data = {"unitlist":getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listunitallduty(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//列出顶层组织
listtopunit: function(async){
var action = mwf.actions.get("x_organization_assemble_control");
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = action.listtopunit(cb, null, !!async);
return (!!async) ? promise : v;
},
//组织属性**************
//添加组织属性值(在属性中添加values值,如果没有此属性,则创建一个)
appendunitattribute: function(unit, attr, values, success, failure, async){
getorgactions();
var unitflag = (typeof(unit)==="object") ? (unit.distinguishedname || unit.id || unit.unique || unit.name) : unit;
var data = {"attributelist":values,"name":attr,"unit":unitflag};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.appendunitattribute(data, cb, null, !!async);
return (!!async) ? promise : v;
// var cb = function(json){
// if (success) return success(json);
// }.ag().catch(function(xhr, text, error){
// if (failure) return failure(xhr, text, error);
// });
//
// orgactions.appendpersonattribute(data, cb, null, !!async);
// orgactions.appendunitattribute(data, function(json){
// if (json.data.value){
// if (success) success();
// }else{
// if (failure) failure(null, "", "append values failed");
// }
// }, function(xhr, text, error){
// if (failure) failure(xhr, text, error);
// }, false);
},
//设置组织属性值(将属性值修改为values,如果没有此属性,则创建一个)
setunitattribute: function(unit, attr, values, success, failure, async){
getorgactions();
var unitflag = (typeof(unit)==="object") ? (unit.distinguishedname || unit.id || unit.unique || unit.name) : unit;
var data = {"attributelist":values,"name":attr,"unit":unitflag};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.setunitattribute(data, cb, null, !!async);
return (!!async) ? promise : v;
// var cb = function(json){
// if (success) return success(json);
// }.ag().catch(function(xhr, text, error){
// if (failure) return failure(xhr, text, error);
// });
// orgactions.setunitattribute(data, cb, null, !!async);
// orgactions.setunitattribute(data, function(json){
// if (json.data.value){
// if (success) success();
// }else{
// if (failure) failure(null, "", "append values failed");
// }
// }, function(xhr, text, error){
// if (failure) failure(xhr, text, error);
// }, false);
},
//获取组织属性值
getunitattribute: function(unit, attr, async){
getorgactions();
var unitflag = (typeof(unit)==="object") ? (unit.distinguishedname || unit.id || unit.unique || unit.name) : unit;
var data = {"name":attr,"unit":unitflag};
var v = null;
var cb = function(json){
v = json.data.attributelist;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.getunitattribute(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//列出组织所有属性的名称
listunitattributename: function(name, async){
getorgactions();
var data = {"unitlist":getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data.namelist;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listunitattributename(data, cb, null, !!async);
return (!!async) ? promise : v;
},
//列出组织的所有属性
listunitallattribute: function(name, async){
getorgactions();
var data = {"unitlist":getnameflag(name)};
var v = null;
var cb = function(json){
v = json.data;
if (async && o2.typeof(async)=="function") return async(v);
return v;
};
var promise = orgactions.listunitallattribute(data, cb, null, !!async);
return (!!async) ? promise : v;
}
};
this.action = (function(){
var actions = [];
return function(root, json){
var action = actions[root] || (actions[root] = new mwf.xdesktop.actions.restactions("", root, ""));
action.getactions = function(callback){
if (!this.actions) this.actions = {};
object.merge(this.actions, json);
if (callback) callback();
};
this.invoke = function(option){
action.invoke(option)
}
}
})();
// this.service = {
// "jaxwsclient": {},
// "jaxrsclient":{}
// };
var lookupaction = null;
var getlookupaction = function(callback){
if (!lookupaction){
mwf.require("mwf.xdesktop.actions.restactions", function(){
lookupaction = new mwf.xdesktop.actions.restactions("", "x_cms_assemble_control", "");
lookupaction.getactions = function(actioncallback){
this.actions = {
"lookup": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method":"put"},
"getview": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}"}
};
if (actioncallback) actioncallback();
}
if (callback) callback();
}.bind(this));
}else{
if (callback) callback();
}
};
this.view = {
"lookup": function(view, callback, async){
var filterlist = {"filterlist": (view.filter || null)};
return mwf.actions.load("x_query_assemble_surface").viewaction.executewithquery(view.view, view.application, filterlist, function(json){
var data = {
"grid": json.data.grid || json.data.groupgrid,
"groupgrid": json.data.groupgrid
};
if (callback) callback(data);
return data;
}, null, async);
},
"lookupv1": function(view, callback){
getlookupaction(function(){
lookupaction.invoke({"name": "lookup","async": true, "parameter": {"view": view.view, "application": view.application},"success": function(json){
var data = {
"grid": json.data.grid,
"groupgrid": json.data.groupgrid
};
if (callback) callback(data);
}.bind(this)});
}.bind(this));
},
"select": function(view, callback, options){
if (view.view){
var viewjson = {
"application": view.application || _form.json.application,
"viewname": view.view || "",
"istitle": (view.istitle===false) ? "no" : "yes",
"select": (view.ismulti===false) ? "single" : "multi",
"filter": view.filter
};
if (!options) options = {};
options.width = view.width;
options.height = view.height;
options.title = view.caption;
var width = options.width || "700";
var height = options.height || "400";
if (layout.mobile){
var size = document.body.getsize();
width = size.x;
height = size.y;
options.style = "viewmobile";
}
width = width.toint();
height = height.toint();
var size = _form.app.content.getsize();
var x = (size.x-width)/2;
var y = (size.y-height)/2;
if (x<0) x = 0;
if (y<0) y = 0;
if (layout.mobile){
x = 20;
y = 0;
}
var _self = this;
mwf.require("mwf.xdesktop.dialog", function(){
var dlg = new mwf.xdesktop.dialog({
"title": options.title || "select view",
"style": options.style || "view",
"top": y,
"left": x-20,
"fromtop":y,
"fromleft": x-20,
"width": width,
"height": height,
"html": "",
"masknode": _form.app.content,
"container": _form.app.content,
"buttonlist": [
{
"text": mwf.lp.process.button.ok,
"action": function(){
//if (callback) callback(_self.view.selecteditems);
if (callback) callback(_self.view.getdata());
this.close();
}
},
{
"text": mwf.lp.process.button.cancel,
"action": function(){this.close();}
}
]
});
dlg.show();
if (layout.mobile){
var backaction = dlg.node.getelement(".mwf_dialod_action_back");
var okaction = dlg.node.getelement(".mwf_dialod_action_ok");
if (backaction) backaction.addevent("click", function(e){
dlg.close();
}.bind(this));
if (okaction) okaction.addevent("click", function(e){
//if (callback) callback(this.view.selecteditems);
if (callback) callback(this.view.getdata());
dlg.close();
}.bind(this));
}
mwf.xdesktop.requireapp("query.query", "viewer", function(){
this.view = new mwf.xapplication.query.query.viewer(dlg.content.getfirst(), viewjson, {"style": "select"}, _form.app, _form.macro);
}.bind(this));
}.bind(this));
}
}
};
this.statement = {
execute: function (obj, callback, async) {
if( obj.format ){
return this._execute(obj, callback, async, obj.format);
}else{
if( this.needcheckformat(obj) ){
var result;
var p = mwf.actions.load("x_query_assemble_surface").statementaction.getformat(obj.name, function(json){
result = this._execute(obj, callback, async, json.data.format);
return result;
}.bind(this), null, async);
return result || p;
}else{
return this._execute(obj, callback, async, "");
}
}
},
needcheckformat: function(s){
if( s.format )return false;
if( typeof(s.parameter) === "object" ){
for( var p in s.parameter ){
if( typeof( s.parameter[p] ) === "date" )return true;
}
}
if( typeof(s.filter) === "array" ){
for( var i=0; i< s.filter.length; i ){
var ftype = s.filter[i].formattype;
if( ["datetimevalue", "datetimevalue", "datevalue", "timevalue"].contains( ftype ) )return true;
}
}
return false;
},
_execute: function(statement, callback, async, format){
var parameter = this.parseparameter(statement.parameter, format);
var filterlist = this.parsefilter(statement.filter, parameter, format);
var obj = {
"filterlist": filterlist,
"parameter" : parameter
};
return mwf.actions.load("x_query_assemble_surface").statementaction.executev2(
statement.name, statement.mode || "data", statement.page || 1, statement.pagesize || 20, obj,
function (json) {
if (callback) callback(json);
return json;
}, null, async);
},
parsefilter : function( filter, parameter, format){
if( typeof(filter) !== "array" )return [];
if( !parameter )parameter = {};
var filterlist = [];
( filter || [] ).each( function (d) {
if( !d.logic )d.logic = "and";
//var parametername = d.path.replace(/\./g, "_");
var pname = d.path.replace(/\./g, "_");
var parametername = pname;
var suffix = 1;
while( parameter[parametername] ){
parametername = pname "_" suffix;
suffix ;
}
var value = d.value;
if( d.comparison === "like" || d.comparison === "notlike" ){
if( value.substr(0, 1) !== "%" )value = "%" value;
if( value.substr(value.length-1,1) !== "%" )value = value "%";
parameter[ parametername ] = value; //"%" value "%";
}else{
if( ["sql", "sqlscript"].contains(format) ) {
if (d.formattype === "numbervalue") {
value = parsefloat(value);
}
}else{
if (d.formattype === "datetimevalue" || d.formattype === "datetimevalue") {
value = "{ts '" value "'}"
} else if (d.formattype === "datevalue") {
value = "{d '" value "'}"
} else if (d.formattype === "timevalue") {
value = "{t '" value "'}"
} else if (d.formattype === "numbervalue") {
value = parsefloat(value);
}
}
parameter[ parametername ] = value;
}
d.value = parametername;
filterlist.push( d );
}.bind(this));
return filterlist;
},
parseparameter : function( obj, format ){
if( typeof(obj) !== "object" )return {};
var parameter = {};
//传入的参数
for( var p in obj ){
var value = obj[p];
if( typeof( value ) === "date" ){
if( ["sql", "sqlscript"].contains(format) ){
value = value.format("db");
}else{
value = "{ts '" value.format("db") "'}"
}
}
parameter[ p ] = value;
}
return parameter;
},
"select": function (statement, callback, options) {
if (statement.name) {
// var parameter = this.parseparameter(statement.parameter);
// var filterlist = this.parsefilter(statement.filter, parameter);
var statementjson = {
"statementid": statement.name || "",
"istitle": (statement.istitle === false) ? "no" : "yes",
"select": (statement.ismulti === false) ? "single" : "multi",
"filter": statement.filter,
"parameter": statement.parameter
};
if (!options) options = {};
options.width = statement.width;
options.height = statement.height;
options.title = statement.caption;
var width = options.width || "700";
var height = options.height || "400";
if (layout.mobile) {
var size = document.body.getsize();
width = size.x;
height = size.y;
options.style = "viewmobile";
}
width = width.toint();
height = height.toint();
var size = _form.app.content.getsize();
var x = (size.x - width) / 2;
var y = (size.y - height) / 2;
if (x < 0) x = 0;
if (y < 0) y = 0;
if (layout.mobile) {
x = 20;
y = 0;
}
var _self = this;
mwf.require("mwf.xdesktop.dialog", function () {
var dlg = new mwf.xdesktop.dialog({
"title": options.title || "select statement view",
"style": options.style || "view",
"top": y,
"left": x - 20,
"fromtop": y,
"fromleft": x - 20,
"width": width,
"height": height,
"html": "",
"masknode": _form.app.content,
"container": _form.app.content,
"buttonlist": [
{
"text": mwf.lp.process.button.ok,
"action": function () {
//if (callback) callback(_self.view.selecteditems);
if (callback) callback(_self.statement.getdata());
this.close();
}
},
{
"text": mwf.lp.process.button.cancel,
"action": function () { this.close(); }
}
]
});
dlg.show();
if (layout.mobile) {
var backaction = dlg.node.getelement(".mwf_dialod_action_back");
var okaction = dlg.node.getelement(".mwf_dialod_action_ok");
if (backaction) backaction.addevent("click", function (e) {
dlg.close();
}.bind(this));
if (okaction) okaction.addevent("click", function (e) {
//if (callback) callback(this.view.selecteditems);
if (callback) callback(this.statement.getdata());
dlg.close();
}.bind(this));
}
mwf.xdesktop.requireapp("query.query", "statement", function () {
this.statement = new mwf.xapplication.query.query.statement(dlg.content.getfirst(), statementjson, { "style": "select" }, _form.app, _form.macro);
}.bind(this));
}.bind(this));
}
}
};
this.importer = {
"upload": function (options, callback, async) {
mwf.xdesktop.requireapp("query.query", "importer", function () {
var importer = new mwf.xapplication.query.query.importer(_form.app.content, options, {}, _form.app, _form.macro);
importer.addevent("afterimport", function (data) {
if(callback)callback(data);
});
importer.load();
}.bind(this));
},
"downloadtemplate": function(options, filename, callback){
mwf.xdesktop.requireapp("query.query", "importer", function () {
var importer = new mwf.xapplication.query.query.importer(_form.app.content, options, {}, _form.app, _form.macro);
importer.downloadtemplate(filename, callback);
}.bind(this));
}
};
//var lookupaction = null;
//var getlookupaction = function(callback){
// if (!lookupaction){
// mwf.require("mwf.xdesktop.actions.restactions", function(){
// lookupaction = new mwf.xdesktop.actions.restactions("", "x_cms_assemble_control", "");
// lookupaction.getactions = function(actioncallback){
// this.actions = {
// "lookup": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method":"put"},
// "getview": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}"}
// };
// if (actioncallback) actioncallback();
// }
// if (callback) callback();
// }.bind(this));
// }else{
// if (callback) callback();
// }
//};
//
//this.view = {
// "lookup": function(view, callback){
// getlookupaction(function(){
// lookupaction.invoke({"name": "lookup","async": true, "parameter": {"view": view.view, "application": view.application},"success": function(json){
// var data = {
// "grid": json.data.grid,
// "groupgrid": json.data.groupgrid
// };
// if (callback) callback(data);
// }.bind(this)});
// }.bind(this));
// },
// "select": function(view, callback, options){
// if (view.view){
// var viewjson = {
// "application": view.application || "",
// "viewname": view.view || "",
// "istitle": view.istitle || "yes",
// "select": view.select || "multi",
// "title": view.title || "select view"
// };
// if (!options) options = {};
// var width = options.width || "700";
// var height = options.height || "400";
//
// if (layout.mobile){
// var size = document.body.getsize();
// width = size.x;
// height = size.y;
// options.style = "viewmobile";
// }
// width = width.toint();
// height = height.toint();
//
// var size = _form.app.content.getsize();
// var x = (size.x-width)/2;
// var y = (size.y-height)/2;
// if (x<0) x = 0;
// if (y<0) y = 0;
// if (layout.mobile){
// x = 20;
// y = 0;
// }
//
// var _self = this;
// mwf.require("mwf.xdesktop.dialog", function(){
// var dlg = new mwf.xdesktop.dialog({
// "title": options.title || "select view",
// "style": options.style || "view",
// "top": y,
// "left": x-20,
// "fromtop":y,
// "fromleft": x-20,
// "width": width,
// "height": height,
// "html": "",
// "masknode": _form.app.content,
// "container": _form.app.content,
// "buttonlist": [
// {
// "text": mwf.lp.process.button.ok,
// "action": function(){
// //if (callback) callback(_self.view.selecteditems);
// if (callback) callback(_self.view.getdata());
// this.close();
// }
// },
// {
// "text": mwf.lp.process.button.cancel,
// "action": function(){this.close();}
// }
// ]
// });
// dlg.show();
// if (layout.mobile){
// var backaction = dlg.node.getelement(".mwf_dialod_action_back");
// var okaction = dlg.node.getelement(".mwf_dialod_action_ok");
// if (backaction) backaction.addevent("click", function(e){
// dlg.close();
// }.bind(this));
// if (okaction) okaction.addevent("click", function(e){
// //if (callback) callback(this.view.selecteditems);
// if (callback) callback(this.view.getdata());
// dlg.close();
// }.bind(this));
// }
//
// // mwf.xdesktop.requireapp("cms.xform", "widget.view", function(){
// // this.view = new mwf.xapplication.cms.xform.widget.view(dlg.content.getfirst(), viewjson, {"style": "select"});
// // }.bind(this));
// mwf.xdesktop.requireapp("query.query", "viewer", function(){
// this.view = new mwf.xapplication.query.query.viewer(dlg.content.getfirst(), viewjson, {"style": "select"});
// }.bind(this));
// }.bind(this));
// }
// }
//};
//include 引用脚本
//optionsorname : {
// type : "", 默认为cms, 可以为 portal process cms
// application : "", 门户/流程/cms的名称/别名/id, 默认为当前应用
// name : "" // 脚本名称/别名/id
//}
//或者name: "" // 脚本名称/别名/id
// if( !window.includedscripts ){
// var includedscripts = window.includedscripts = [];
// }else{
// var includedscripts = window.includedscripts;
// }
var includedscripts = [];
var _includesingle = function( optionsorname , callback , async){
var options = optionsorname;
if( typeof( options ) == "string" ){
options = { name : options };
}
var name = options.name;
var type;
if( options.type === "service" ){
type = options.type;
}else{
type = ( options.type && options.application ) ? options.type : "cms";
}
var application = options.application || _form.json.application;
var key = type "-" application "-" name;
if( type === "service" ){
key = type "-" name;
}
if (includedscripts.indexof( key )> -1){
if (callback) callback.apply(this);
return;
}
//if (includedscripts.indexof( name )> -1){
// if (callback) callback.apply(this);
// return;
//}
if( (options.enableanonymous || options.anonymous) && type === "cms" ){
o2.actions.load("x_cms_assemble_control").scriptanonymousaction.getwithappwithname( application, name, function(json){
if (json.data){
includedscripts.push( key );
//名称、别名、id
( json.data.importedlist || [] ).each( function ( flag ) {
includedscripts.push( type "-" json.data.appid "-" flag );
if( json.data.appname )includedscripts.push( type "-" json.data.appname "-" flag );
if( json.data.appalias )includedscripts.push( type "-" json.data.appalias "-" flag );
});
includedscripts = includedscripts.concat(json.data.importedlist || []);
mwf.cmsmacro.exec(json.data.text, this);
if (callback) callback.apply(this);
}else{
if (callback) callback.apply(this);
}
}.bind(this), null, false);
}else{
var scriptaction;
switch ( type ){
case "portal" :
if( this.scriptactionportal ){
scriptaction = this.scriptactionportal;
}else{
mwf.require("mwf.xscript.actions.portalscriptactions", null, false);
scriptaction = this.scriptactionportal = new mwf.xscript.actions.portalscriptactions();
}
break;
case "process" :
if( this.scriptactionprocess ){
scriptaction = this.scriptactionprocess;
}else{
mwf.require("mwf.xscript.actions.scriptactions", null, false);
scriptaction = this.scriptactionprocess = new mwf.xscript.actions.scriptactions();
}
break;
case "cms" :
if( this.scriptactioncms ){
scriptaction = this.scriptactioncms;
}else{
mwf.require("mwf.xscript.actions.cmsscriptactions", null, false);
scriptaction = this.scriptactioncms = new mwf.xscript.actions.cmsscriptactions();
}
break;
case "service" :
if (this.scriptactionservice) {
scriptaction = this.scriptactionservice;
} else {
mwf.require("mwf.xscript.actions.servicescriptactions", null, false);
scriptaction = this.scriptactionservice = new mwf.xscript.actions.servicescriptactions();
}
break;
}
var successcallback = function(json){
if (json.data){
includedscripts.push( key );
//名称、别名、id
json.data.importedlist.each( function ( flag ) {
if( type === "portal" ){
includedscripts.push( type "-" json.data.portal "-" flag );
if( json.data.portalname )includedscripts.push( type "-" json.data.portalname "-" flag );
if( json.data.portalalias )includedscripts.push( type "-" json.data.portalalias "-" flag );
}else if( type === "cms" ){
includedscripts.push( type "-" json.data.appid "-" flag );
if( json.data.appname )includedscripts.push( type "-" json.data.appname "-" flag );
if( json.data.appalias )includedscripts.push( type "-" json.data.appalias "-" flag );
}else if( type === "process" ){
includedscripts.push( type "-" json.data.application "-" flag );
if( json.data.appname )includedscripts.push( type "-" json.data.appname "-" flag );
if( json.data.appalias )includedscripts.push( type "-" json.data.appalias "-" flag );
}else if (type === "service") {
includedscripts.push(type "-" flag);
}
});
includedscripts = includedscripts.concat(json.data.importedlist);
mwf.cmsmacro.exec(json.data.text, this);
if (callback) callback.apply(this);
}else{
if (callback) callback.apply(this);
}
}.bind(this);
if( type === "service" ){
scriptaction.getscriptbyname(name, includedscripts, successcallback, null, !!async);
}else{
scriptaction.getscriptbyname(application, name, includedscripts, successcallback, null, !!async);
}
}
};
this.include = function( optionsorname , callback, async){
if (o2.typeof(optionsorname)=="array"){
if (!!async){
var count = optionsorname.length;
var loaded = 0;
optionsorname.each(function(option){
_includesingle.apply(this, [option, function(){
loaded ;
if (loaded>=count) if (callback) callback.apply(this);
}.bind(this), true]);
}.bind(this));
}else{
optionsorname.each(function(option){
_includesingle.apply(this, [option]);
}.bind(this));
if (callback) callback.apply(this);
}
}else{
_includesingle.apply(this, [optionsorname , callback, async])
}
};
//var includedscripts = [];
//this.include = function(name, callback){
// if (includedscripts.indexof(name)==-1){
// if (!this.scriptaction){
// mwf.require("mwf.xscript.actions.cmsscriptactions", null, false);
// this.scriptaction = new mwf.xscript.actions.cmsscriptactions();
// }
// this.scriptaction.getscriptbyname(_form.json.application, name, includedscripts, function(json){
// includedscripts = includedscripts.concat(json.data.importedlist);
// mwf.cmsmacro.exec(json.data.text, this);
// if (callback) callback.apply(this);
// }.bind(this), null, false);
// }else{
// if (callback) callback.apply(this);
// }
//}.bind(this);
this.define = function(name, fun, overwrite){
var over = true;
if (overwrite===false) over = false;
var o = {};
o[name] = {"value": fun, "configurable": over};
mwf.defineproperties(this, o);
}.bind(this);
//如果前端事件有异步调用,想要在异步调用结束后继续运行页面加载,
//可在调用前执行 var resolve = this.wait();
//在异步调用结束后 执行 resolve.cb();
//目前只有表单的queryload事件支持此方法。
this.wait = function(){
resolve = {};
var setresolve = function(callback){
resolve.cb = callback;
}.bind(this);
this.target.event_resolve = setresolve;
return resolve;
};
//和this.wait配合使用,
//如果没有异步,则resolve.cb方法不存在,
//所以在回调中中使用this.goon();使表单继续加载
this.goon = function(){
this.target.event_resolve = null;
};
//仅前台对象-----------------------------------------
//form
this.form = {
"getinfor": function(){return ev.forminfor;},
"infor": ev.forminfor,
"getapp": function(){return _form.app;},
"app": _form.app,
"node": function(){return _form.node;},
"readonly": _form.options.readonly,
"get": function(name,subformname ){
if( !_form.all )return null;
if( subformname ){
if( _form.all[subformname "_" name] )return _form.all[subformname "_" name];
return _form.all[name];
}else{
return _form.all[name];
}
// return (_form.all) ? _form.all[name] : null;
},
"getfield": function(name){return _forms[name];},
"getaction": function(){return _form.documentaction},
"getdata": function(){return new mwf.xscript.cmsjsondata(_form.getdata());},
"save": function(callback){
_form.savedocument(callback);
},
"close": function(){_form.closedocument();},
/**发布当前文档。(仅内容管理表单中可用)
* @method publish
* @memberof module:form
* @param {function} callback - 发布后的回调方法,如果接收的参数为空表示校验未通过,如果参数不为空为发布后的回调
* @o2syntax
* this.form.publish( callback );
* @sample
* this.form.publish( function(json){
* if( !json ){
* //校验未通过
* }else{
* //校验通过,json.data.id 为文档id
* }
* });
*/
"publish": function(callback){
_form.publishdocument(callback)
},
//"archive": function(option){
// _form.archivedocument()
//},
//"redraft": function(option){
// _form.redraftdocument()
//},
"confirm": function(type, title, text, width, height, ok, cancel, callback, mask, style){
// var p = mwf.getcenter({"x": width, "y": height});
// e = {"event": {"clientx": p.x,"x": p.x,"clienty": p.y,"y": p.y}};
// _form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
if ((arguments.length<=1) || o2.typeof(arguments[1])==="string"){
var p = mwf.getcenter({"x": width, "y": height});
e = {"event": {"clientx": p.x,"x": p.x,"clienty": p.y,"y": p.y}};
_form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
}else{
e = (arguments.length>1) ? arguments[1] : null;
title = (arguments.length>2) ? arguments[2] : null;
text = (arguments.length>3) ? arguments[3] : null;
width = (arguments.length>4) ? arguments[4] : null;
height = (arguments.length>5) ? arguments[5] : null;
ok = (arguments.length>6) ? arguments[6] : null;
cancel = (arguments.length>7) ? arguments[7] : null;
callback = (arguments.length>8) ? arguments[8] : null;
mask = (arguments.length>9) ? arguments[9] : null;
style = (arguments.length>10) ? arguments[10] : null;
_form.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style);
}
},
//"confirm": function(type, e, title, text, width, height, ok, cancel, callback){
// _form.confirm(type, e, title, text, width, height, ok, cancel, callback);
//},
"alert": function(type, title, text, width, height){
_form.alert(type, title, text, width, height);
},
"notice": function(content, type, target, where, offset, option){
_form.notice(content, type, target, where, offset, option);
},
"dialog": function ( options ) {
return _form.dialog( options );
},
"selectorg": function ( container, options, delayload) {
if( !container )container = _form.app.content;
return new mwf.o2selector(container, options, delayload);
},
"addevent": function(e, f){_form.addevent(e, f);},
"openwork": function(id, completedid, title, options){
var op = options || {};
op.workid = id;
op.workcompletedid = completedid;
op.doctitle = title;
op.appid = "process.work" (op.workid || op.workcompletedid);
return layout.desktop.openapplication(this.event, "process.work", op);
},
"openjob": function(id, choice, options, callback){
var workdata = null, handel;
o2.actions.get("x_processplatform_assemble_surface").listworkbyjob(id, function(json){
if (json.data) workdata = json.data;
}.bind(this), null, false);
if( !layout.inbrowser && o2.typeof(callback) === "function" ){
if( !options )options = {};
var queryload = options.onqueryload;
options.onqueryload = function () {
if( o2.typeof(queryload) === "function" )queryload.call(this);
callback(this);
}
}
runcallback = function ( handel ) {
if( o2.typeof(callback) === "function" ) {
if (layout.inbrowser) {
callback(handel);
} else if (options && options.appid) {
if (layout.desktop && layout.desktop.apps && layout.desktop.apps[options.appid]) {
callback(layout.desktop.apps[options.appid], true);
}else{
callback(handel, false);
}
}else{
callback(handel, false);
}
}
};
if (workdata){
var len = workdata.worklist.length workdata.workcompletedlist.length;
if (len){
if (len>1 && choice){
var node = new element("div", {"styles": {"padding": "20px", "width": "500px"}}).inject(_form.node);
workdata.worklist.each(function(work){
var worknode = new element("div", {
"styles": {
"background": "#ffffff",
"border-radius": "10px",
"clear": "both",
"margin-bottom": "10px",
"height": "40px",
"padding": "10px 10px"
}
}).inject(node);
var html = ""
""
"" work.title "
"
"" work.activityname "
"
"
" work.activityarrivedtime "
"
"
" (work.manualtaskidentitytext || "") "
";
worknode.set("html", html);
var action = worknode.getelement(".mwfaction");
action.store("work", work);
action.addevent("click", function(e){
var work = e.target.retrieve("work");
if (work){
handel = this.openwork(work.id, null, work.title, options);
runcallback( handel );
}
dlg.close();
}.bind(this));
}.bind(this));
workdata.workcompletedlist.each(function(work){
var worknode = new element("div", {
"styles": {
"background": "#ffffff",
"border-radius": "10px",
"clear": "both",
"margin-bottom": "10px",
"height": "40px",
"padding": "10px 10px"
}
}).inject(node);
var html = ""
""
"" work.title "
"
"" o2.lp.widget.workcompleted "
"
"
" work.completedtime "
";
worknode.set("html", html);
var action = worknode.getelement(".mwfaction");
action.store("work", work);
action.addevent("click", function(e){
var work = e.target.retrieve("work");
if (work){
handel = this.openwork(null, work.id, work.title, options);
runcallback( handel );
}
dlg.close();
}.bind(this));
}.bind(this));
var height = node.getsize().y 20;
if (height>600) height = 600;
var dlg = o2.dl.open({
"title": o2.lp.widget.choicework,
"style" : "user",
"isresize": false,
"content": node,
"buttonlist": [
{
"type" : "cancel",
"text": o2.lp.widget.close,
"action": function(){dlg.close();}
}
]
});
}else{
if (workdata.worklist.length){
var work = workdata.worklist[0];
handel = this.openwork(work.id, null, work.title, options);
runcallback( handel );
return handel;
}else{
var work = workdata.workcompletedlist[0];
handel = this.openwork(null, work.id, work.title, options);
runcallback( handel );
return handel;
}
}
}else{
runcallback(new error("can't open this job", {
cause: workdata
}));
}
}else{
runcallback(new error("can't open this job", {
cause: workdata
}));
}
},
"opendocument": function(id, title, options){
var op = options || {};
op.documentid = id;
op.doctitle = title || "";
op.appid = (op.appid) || ("cms.document" id);
if( op.onpostpublish ){
op.postpublish = op.onpostpublish;
delete op.onpostpublish;
}
if( op.onafterpublish ){
op.afterpublish = op.onafterpublish;
delete op.onafterpublish;
}
if( op.onaftersave ){
op.aftersave = op.onaftersave;
delete op.onaftersave;
}
if( op.onbeforeclose ){
op.beforeclose = op.onbeforeclose;
delete op.onbeforeclose;
}
if( op.onpostdelete ){
op.postdelete = op.onpostdelete;
delete op.onpostdelete;
}
return layout.desktop.openapplication(this.event, "cms.document", op);
},
"openportal": function (name, page, par) {
var action = mwf.actions.get("x_portal_assemble_surface");
action.getapplication(name, function (json) {
if (json.data) {
if (page) {
action.getpagebyname(page, json.data.id, function (pagejson) {
var pageid = (pagejson.data) ? pagejson.data.id : "";
layout.desktop.openapplication(null, "portal.portal", {
"portalid": json.data.id,
"pageid": pageid,
"parameters": par,
"appid": (par && par.appid) || ("portal.portal" json.data.id pageid)
})
});
} else {
layout.desktop.openapplication(null, "portal.portal", {
"portalid": json.data.id,
"parameters": par,
"appid": (par && par.appid) || ("portal.portal" json.data.id)
})
}
}
});
},
"opencms": function(name){
var action = mwf.actions.get("x_cms_assemble_control");
action.getcolumn(name, function(json){
if (json.data){
layout.desktop.openapplication(null, "cms.module", {
"columnid": json.data.id,
"appid": "cms.module" json.data.id
});
}
});
},
"openprocess": function(name){
var action = mwf.actions.get("x_processplatform_assemble_surface");
action.getapplication(name, function(json){
if (json.data){
layout.desktop.openapplication(null, "process.application", {
"id": json.data.id,
"appid": "process.application" json.data.id
});
}
});
},
"openapplication":function(name, options, status){
return layout.desktop.openapplication(null, name, options, status);
},
"createdocument": function (columnoroptions, category, data, identity, callback, target, latest, selectcolumnenable, ignoretitle, restricttocolumn) {
var column = columnoroptions;
var onafterpublish, onpostpublish;
if (typeof(columnoroptions) == "object") {
column = columnoroptions.column;
category = columnoroptions.category;
data = columnoroptions.data;
identity = columnoroptions.identity;
callback = columnoroptions.callback;
target = columnoroptions.target;
latest = columnoroptions.latest;
selectcolumnenable = columnoroptions.selectcolumnenable;
ignoretitle = columnoroptions.ignoretitle;
restricttocolumn = columnoroptions.restricttocolumn;
onafterpublish = columnoroptions.onafterpublish;
onpostpublish = columnoroptions.onpostpublish;
}
if (target) {
if (layout.app && layout.app.inbrowser) {
layout.app.content.empty();
layout.app = null;
}
}
mwf.xdesktop.requireapp("cms.index", "newer", function () {
var starter = new mwf.xapplication.cms.index.newer(null, null, _form.app, null, {
"documentdata": data,
"identity": identity,
"ignoretitle": ignoretitle === true,
"ignoredrafted": latest === false,
"selectcolumnenable": !category || selectcolumnenable === true,
"restricttocolumn": restricttocolumn === true || (!!category && selectcolumnenable !== true),
"categoryflag": category, //category id or name
"columnflag": column, //column id or name,
"onstarted": function (documentid, data, windowhandle) {
if (callback) callback(documentid, data, windowhandle);
},
"onpostpublish": function () {
if(onpostpublish)onpostpublish();
},
"onafterpublish": function () {
if(onafterpublish)onafterpublish();
}
});
starter.load();
})
},
"startprocess": function(app, process, data, identity, callback, target, latest, aftercreated, skipdraftcheck){
if (arguments.length>2){
for (var i=2; i
=data.length){
data.push(newvalue);
newkey = data.length-1;
}else{
if (overwrite) data[newkey] = newvalue;
newvalue = data[newkey];
flag = false;
}
}
}
if (flag){
var o = {};
o[newkey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newkey, this]),"set": setter.apply(this, [data, callback, newkey, this])};
mwf.defineproperties(this, o);
}
if (!noreset) this[newkey] = newvalue;
}else if (type==="object"){
if (!this.hasownproperty(newkey)){
if (!data[newkey] || overwrite){
data[newkey] = newvalue;
}
newvalue = data[newkey];
if (flag){
var o = {};
o[newkey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newkey, this]),"set": setter.apply(this, [data, callback, newkey, this])};
mwf.defineproperties(this, o);
}
if (!noreset) this[newkey] = newvalue;
}else{
if (!object.getownpropertydescriptor(this, newkey).get){
var o = {};
o[newkey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newkey, this]),"set": setter.apply(this, [data, callback, newkey, this])};
mwf.defineproperties(this, o);
}
if (overwrite){
data[newkey] = newvalue;
if (!noreset) this[newkey] = newvalue;
}
}
}
return this[newkey];
}else{
var keys = newkey.split("..");
var kk = keys.shift();
var d = this.add(kk, {}, false, true);
if (keys.length) return d.add(keys.join(".."), newvalue, overwrite, noreset);
return d;
}
}},
"check": {
"value": function(kk, v){
var value = typeof( v ) === "null" ? "" : v;
this.add(kk, value, false, true);
}
},
"del": {"value": function(delkey){
if (!this.hasownproperty(delkey)) return null;
// delete data[delkey];
// delete this[delkey];
data[delkey] = "";
this[delkey] = "";
return this;
}}
};
mwf.defineproperties(this, methods);
};
var type = typeof(data);
if (type==="object" || type==="array") define.apply(this);
};
// mwf.xscript.cmsjsondata = function(data, callback, key, parent){
// var getter = function(data, callback, k, _self){
// return function(){return (["array","object"].indexof(typeof(data[k]))===-1) ? data[k] : new mwf.xscript.cmsjsondata(data[k], callback, k, _self);};
// };
// var setter = function(data, callback, k, _self){
// return function(v){
// data[k] = v;
// //debugger;
// //this.add(k, v, true);
// if (callback) callback(data, k, _self);
// }
// };
// var define = function(){
// var o = {};
// for (var k in data) o[k] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, k, this]),"set": setter.apply(this, [data, callback, k, this])};
// o["length"] = {"get": function(){return object.keys(data).length;}};
// o["some"] = {"get": function(){return data.some;}};
// mwf.defineproperties(this, o);
//
// var methods = {
// "getkey": {"value": function(){ return key; }},
// "getparent": {"value": function(){ return parent; }},
// "tostring": {"value": function() { return data.tostring();}},
// "add": {"value": function(newkey, newvalue, overwrite){
// var flag = true;
// var type = typeof(data);
// if (type==="array"){
// if (arguments.length<2){
// data.push(newkey);
// newvalue = newkey;
// newkey = data.length-1;
// }else{
// if (!newkey && newkey!==0){
// data.push(newvalue);
// newkey = data.length-1;
// }else{
// flag = false;
// }
// }
// if (flag){
// var o = {};
// o[newkey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newkey, this]),"set": setter.apply(this, [data, callback, newkey, this])};
// mwf.defineproperties(this, o);
// }
// this[newkey] = newvalue;
// }else if (type==="object"){
// if (!this.hasownproperty(newkey)){
// data[newkey] = newvalue;
//
// if (flag){
// var o = {};
// o[newkey] = {"configurable": true, "enumerable": true, "get": getter.apply(this, [data, callback, newkey, this]),"set": setter.apply(this, [data, callback, newkey, this])};
// mwf.defineproperties(this, o);
// }
// this[newkey] = newvalue;
// }else{
// if (overwrite) this[newkey] = newvalue;
// }
// }
//
// return this[newkey];
// }},
// "del": {"value": function(delkey){
// if (!this.hasownproperty(delkey)) return null;
// delete data[delkey];
// delete this[delkey];
// return this;
// }}
// };
// mwf.defineproperties(this, methods);
// };
// var type = typeof(data);
// if (type==="object" || type==="array") define.apply(this);
// };
//mwf.xscript.cmsjsondata = function(data, callback, key, parent){
// var getter = function(data, callback, k, _self){
// return function(){return (["array","object"].indexof(typeof(data[k]))==-1) ? data[k] : new mwf.xscript.cmsjsondata(data[k], callback, k, _self);};
// }
// var setter = function(data, callback, k, _self){
// return function(v){
// data[k] = v;
// if (callback) callback(data, k, _self);
// }
// }
// var define = function(){
// var o = {};
// for (var k in data) o[k] = {
// "configurable": true,
// "get": getter.apply(this, [data, callback, k, this]),
// "set": setter.apply(this, [data, callback, k, this])
// };
// o["length"] = {"get": function(){return object.keys(data).length;}};
// mwf.defineproperties(this, o);
// this.getkey = function(){ return key; };
// this.getparent = function(){ return parent; };
// this.tostring = function() { return data.tostring();};
// this.add = function(newkey, newvalue){
// var type = typeof(data);
// if (!this.hasownproperty(newkey)){
// if (type=="array"){
// data.push(newvalue || {});
// newkey = data.length-1;
// }else{
// data[newkey] = newvalue || {};
// }
// var o = {};
// o[newkey] = {"configurable": true, "get": getter.apply(this, [data, callback, newkey, this]),"set": setter.apply(this, [data, callback, newkey, this])};
// mwf.defineproperties(this, o);
// }
// this[newkey] = newvalue;
// return this;
// };
// this.del = function(delkey){
// if (!this.hasownproperty(delkey)) return null;
// delete data[newkey];
// delete this[newkey];
// return this;
// };
// }
// var type = typeof(data);
// if (type=="object" || type=="array") define.apply(this);
//};
//mwf.xscript.createcmsdict = function(application){
// return function(name){
// var applicationid = application;
// this.name = name;
// mwf.require("mwf.xscript.actions.cmsdictactions", null, false);
// var action = new mwf.xscript.actions.cmsdictactions();
//
// this.get = function(path, success, failure){
// var value = null;
// if( path ){
// var arr = path.split(/\./g);
// var ar = arr.map(function(v){
// return encodeuricomponent(v);
// });
// //var p = path.replace(/\./g, "/");
// var p = ar.join("/");
// action.getdict(applicationid, encodeuricomponent(this.name), p, function(json){
// value = json.data;
// if (success) success(json.data);
// }, function(xhr, text, error){
// if (failure) failure(xhr, text, error);
// }, false);
// }else{
// action.getdictwhole(applicationid, encodeuricomponent(this.name), function(json){
// value = json.data;
// if (success) success(json.data);
// }, function(xhr, text, error){
// if (failure) failure(xhr, text, error);
// }, false);
// }
// return value;
// };
//
// this.set = function(path, value, success, failure){
// var p = path.replace(/\./g, "/");
// action.setdict(applicationid, encodeuricomponent(this.name), p, value, function(json){
// if (success) success(json.data);
// }, function(xhr, text, error){
// if (failure) failure(xhr, text, error);
// });
// };
// this.add = function(path, value, success, failure){
// var p = path.replace(/\./g, "/");
// action.adddict(applicationid, encodeuricomponent(this.name), p, value, function(json){
// if (success) success(json.data);
// }, function(xhr, text, error){
// if (failure) failure(xhr, text, error);
// });
// };
// this["delete"] = function(path, success, failure){
// var p = path.replace(/\./g, "/");
// action.deletedict(applicationid, encodeuricomponent(this.name), p, function(json){
// if (success) success(json.data);
// }, function(xhr, text, error){
// if (failure) failure(xhr, text, error);
// });
// };
// this.destory = this["delete"];
// }
//};
if( !mwf.xscript.dictloaded )mwf.xscript.dictloaded = {};
if( !mwf.xscript.adddicttocache )mwf.xscript.adddicttocache = function ( options, path, json ) {
if( !path )path = "root";
if( path.indexof("root") !== 0 )path = "root." path ;
var type = options.apptype || "process";
var enableanonymous = (options.enableanonymous || options.anonymous) || false;
var appflaglist = [];
if( options.application )appflaglist.push( options.application );
if( options.appid )appflaglist.push( options.appid );
if( options.appname )appflaglist.push( options.appname );
if( options.appalias )appflaglist.push( options.appalias );
var dictflaglist = [];
if( options.id )dictflaglist.push( options.id );
if( options.name )dictflaglist.push( options.name );
if( options.alias )dictflaglist.push( options.alias );
var cache = {};
cache[path] = json;
for( var i=0; i