MWF.xDesktop.requireApp("process.Xform", "$Input", null, false); MWF.xDesktop.requireApp("process.Work", "lp."+o2.language, null, false); /** @class Opinion 意见输入框。 * @example * //可以在脚本中获取该组件 * //方法1: * var field = this.form.get("fieldId"); //获取组件对象 * //方法2 * var field = this.target; //在组件本身的脚本中获取,比如事件脚本、默认值脚本、校验脚本等等 * * var data = field.getData(); //获取值 * field.setData("字符串值"); //设置值 * field.hide(); //隐藏字段 * var id = field.json.id; //获取字段标识 * var flag = field.isEmpty(); //字段是否为空 * field.resetData(); //重置字段的值为默认值或置空 * @extends MWF.xApplication.process.Xform.$Input * @o2category FormComponents * @o2range {Process} * @hideconstructor */ MWF.xApplication.process.Xform.Opinion = MWF.APPOpinion = new Class( /** @lends MWF.xApplication.process.Xform.Opinion# */ { Implements: [Events], Extends: MWF.APP$Input, _loadUserInterface: function(){ this._loadNode(); if (this.json.compute == "show"){ this._setValue(this._computeValue()); }else{ this._loadValue(); } }, _loadNode: function(){ if (this.readonly){ this._loadNodeRead(); }else{ this._loadNodeEdit(); } }, _loadNodeRead: function(){ this.node.empty(); this.node.set({ "nodeId": this.json.id, "MWFType": this.json.type }); this.node.setStyle("display", "none"); }, validationConfigItem: function(routeName, data){ var flag = (data.status==="all") ? true: (routeName === data.decision); if (flag){ var n = this.getInputData(); var v = (data.valueType==="value") ? n : n.length; switch (data.operateor){ case "isnull": if (!v && !(this.handwritingFile && this.handwritingFile[layout.session.user.distinguishedName])){ this.notValidationMode(data.prompt); return false; } break; case "notnull": if (v){ this.notValidationMode(data.prompt); return false; } break; case "gt": if (v>data.value){ this.notValidationMode(data.prompt); return false; } break; case "lt": if (vinputSize.y) offY = inputSize.y; this.selectOpinionNode.setStyle("display","block"); this.selectOpinionNode.position({ "relativeTo": this.node, "position": "leftTop", "edge": "leftTop", "offset": {"x": size.x, "y": offY} }); }, createSelectOpinionNode: function(){ this.selectOpinionNode = new Element("div", {"styles": this.form.css.opinionSelectNode}).inject(this.node); }, createSelectOpinionOption: function(op){ var option = new Element("div", {"styles": this.form.css.opinionSelectOption, "text": op}).inject(this.selectOpinionNode); if (this.json.selectItemStyles) option.setStyles(this.json.selectItemStyles); option.addEvents({ "mouseover": function(){this.setStyle("background-color", "#d2ddf5")}, "mouseout": function(){this.setStyle("background-color", "#ffffff")}, "mousedown": function(){this.setOpinion(op)}.bind(this) }); }, setOpinion: function(op){ var v = this.input.get("value"); var arr = v.split(/(,\s*){1}|(;\s*){1}|\s+/g); t = arr[arr.length-1]; var leftStr = v.substr(0, v.length-t.length); this.input.set("value", leftStr+op); this.hideSelectOpinionNode(); this._setBusinessData(this.getInputData()); }, _afterLoaded: function(){ if (!this.readonly){ this.loadDescription(); } }, loadDescription: function(){ if (this.readonly || this.json.isReadonly)return; var v = this._getBusinessData(); if (!v){ if (this.json.description){ var size = this.node.getFirst().getSize(); var w = size.x - 3 if( this.json.showIcon!='no' && !this.form.json.hideModuleIcon ) { w = size.x - 23; } this.descriptionNode = new Element("div", {"styles": this.form.css.descriptionNode, "text": this.json.description}).inject(this.node); this.descriptionNode.setStyles({ "width": ""+w+"px", "height": ""+size.y+"px", "line-height": ""+size.y+"px" }); this.setDescriptionEvent(); } } }, setDescriptionEvent: function(){ if (this.descriptionNode){ if (COMMON.Browser.Platform.name==="ios"){ this.descriptionNode.addEvents({ "click": function(){ this.descriptionNode.setStyle("display", "none"); this.node.getFirst().focus(); }.bind(this) }); }else if (COMMON.Browser.Platform.name==="android"){ this.descriptionNode.addEvents({ "click": function(){ this.descriptionNode.setStyle("display", "none"); this.node.getFirst().focus(); }.bind(this) }); }else{ this.descriptionNode.addEvents({ "click": function(){ this.descriptionNode.setStyle("display", "none"); this.node.getFirst().focus(); }.bind(this) }); } this.node.getFirst().addEvents({ "focus": function(){ this.descriptionNode.setStyle("display", "none"); }.bind(this), "blur": function(){ if (!this.node.getFirst().get("value")) this.descriptionNode.setStyle("display", "block"); }.bind(this) }); } } });