mwf.xdesktop.requireapp("process.xform", "select", null, false);
/** @class security 密级选择组件。
* 启用密级标识功能后,此组件允许选择客体密级
* @o2cn 下拉选择
* @example
* //可以在脚本中获取该组件
* //方法1:
* var field = this.form.get("fieldid"); //获取组件对象
* //方法2
* var field = this.target; //在组件本身的脚本中获取,比如事件脚本、默认值脚本、校验脚本等等
*
* field.hide(); //隐藏字段
* var id = field.json.id; //获取字段标识
* var flag = field.isempty(); //字段是否为空
* @extends mwf.xapplication.process.xform.$selector
* @o2category formcomponents
* @o2range {process|cms|portal}
* @hideconstructor
*/
mwf.xapplication.process.xform.security = mwf.appsecurity = new class(
/** @lends mwf.xapplication.process.xform.select# */
{
implements: [events],
extends: mwf.appselect,
iconstyle: "selecticon",
/**
* 值改变时触发。可以通过this.event获取修改后的选择项(dom对象)。
* @event mwf.xapplication.process.xform.security#change
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
*/
/**
* @ignore
* @member {element} descriptionnode
* @memberof mwf.xapplication.process.xform.security#
*/
initialize: function(node, json, form, options){
this.node = $(node);
this.node.store("module", this);
this.json = json;
this.form = form;
this.field = true;
this.fieldmoduleloaded = false;
this.nodehtml = this.node.get("html");
},
__showvalue: function(node, value, optionitems){
if (value){
value = value.tostring();
if (typeof(value)!=="array") value = [value];
var texts = [];
optionitems.each(function(item){
var tmps = item.split("|");
var t = tmps[0];
var v = tmps[1] || t;
if (v){
if (value.indexof(v)!=-1){
texts.push(t);
}
}
});
node.set("text", texts.join(", "));
}
},
_getoptions: function(async, refresh){
if (this.securitylabellist) return promise.resolve(this.securitylabellist);
return o2.actions.load("x_general_assemble_control").securityclearanceaction.object().then(function(json){
var opts = ["|"];
object.keys(json.data).foreach(function(k){
opts.push(k "|" json.data[k]);
}.bind(this))
this.securitylabellist = opts;
return this.securitylabellist;
}.bind(this));
},
_setbusinessdata: function(v, id){
var value = v.toint();
this.setbusinessdatabyid(value, id);
// this.form.businessdata.data.$work.objectsecurityclearance = value;
},
getinputdata: function(){
if( this.isreadonly()){
return this._getbusinessdata();
}else{
var ops = this.node.getelements("option");
var value = [];
ops.each(function(op){
if (op.selected){
var v = op.get("value");
value.push(v || "");
}
});
if (!value.length) return null;
return (value.length==1) ? value[0].toint() : value.toint();
}
},
addoption: function(){}
});
source