Org.js 95 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291
  1. MWF.xDesktop.requireApp("process.Xform", "$Input", null, false);
  2. MWF.xDesktop.requireApp("Selector", "package", null, false);
  3. MWF.require("MWF.widget.O2Identity", null, false);
  4. /** @class Org 人员组织组件。
  5. * @example
  6. * //可以在脚本中获取该组件
  7. * //方法1:
  8. * var field = this.form.get("fieldId"); //获取组件对象
  9. * //方法2
  10. * var field = this.target; //在组件本身的脚本中获取,比如事件脚本、默认值脚本、校验脚本等等
  11. *
  12. * var data = field.getData(); //获取值
  13. * field.setData("字符串值"); //设置值
  14. * field.hide(); //隐藏字段
  15. * var id = field.json.id; //获取字段标识
  16. * var flag = field.isEmpty(); //字段是否为空
  17. * field.resetData(); //重置字段的值为默认值或置空
  18. * @extends MWF.xApplication.process.Xform.$Input
  19. * @o2category FormComponents
  20. * @o2range {Process|CMS|Portal}
  21. * @hideconstructor
  22. */
  23. MWF.xApplication.process.Xform.Org = MWF.APPOrg = new Class(
  24. /** @lends MWF.xApplication.process.Xform.Org# */
  25. {
  26. Implements: [Events],
  27. Extends: MWF.APP$Input,
  28. options: {
  29. /**
  30. * 组件加载前触发。
  31. * @event MWF.xApplication.process.Xform.Org#queryLoad
  32. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  33. */
  34. /**
  35. * 组件加载时触发.
  36. * @event MWF.xApplication.process.Xform.Org#load
  37. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  38. */
  39. /**
  40. * 组件加载后触发.
  41. * @event MWF.xApplication.process.Xform.Org#postLoad
  42. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  43. */
  44. /**
  45. * 当组件值改变时触发。
  46. * @event MWF.xApplication.process.Xform.Org#change
  47. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  48. */
  49. /**
  50. * 当组件不允许输入(使用人员选择框)时,完成选择人员,并且给组件赋值后执行。
  51. * @event MWF.xApplication.process.Xform.Org#select
  52. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  53. */
  54. "moduleEvents": ["load", "queryLoad", "postLoad", "change", "select"],
  55. /**
  56. * 人员选择框事件:加载前执行。this.target指向人员选择框。
  57. * @event MWF.xApplication.process.Xform.Org#queryLoadSelector
  58. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  59. */
  60. /**
  61. * 人员选择框事件:加载后执行,由于选择项为异步加载,此时选择项并未加载完成。this.target指向人员选择框。
  62. * @event MWF.xApplication.process.Xform.Org#postLoadSelector
  63. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  64. */
  65. /**
  66. * 人员选择框事件:加载选择框容器节点前执行。this.target指向人员选择框。
  67. * @event MWF.xApplication.process.Xform.Org#queryLoadCategory
  68. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  69. */
  70. /**
  71. * 人员选择框事件:加载选择框容器节点后执行。this.target指向人员选择框。
  72. * @event MWF.xApplication.process.Xform.Org#postLoadContent
  73. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  74. */
  75. /**
  76. * 人员选择框事件:加载分类前执行。this.target指向分类,this.target.selector指向人员选择框。
  77. * @event MWF.xApplication.process.Xform.Org#queryLoadCategory
  78. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  79. */
  80. /**
  81. * 人员选择框事件:加载分类后执行。this.target指向分类,this.target.selector指向人员选择框。
  82. * @event MWF.xApplication.process.Xform.Org#postLoadCategory
  83. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  84. */
  85. /**
  86. * 人员选择框事件:选择分类后执行。this.target指向分类,this.target.selector指向人员选择框。
  87. * @event MWF.xApplication.process.Xform.Org#selectCategory
  88. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  89. */
  90. /**
  91. * 人员选择框事件:取消选择分类后执行。this.target指向分类,this.target.selector指向人员选择框。
  92. * @event MWF.xApplication.process.Xform.Org#unselectCategory
  93. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  94. */
  95. /**
  96. * 人员选择框事件:展开分类后执行。this.target指向分类,this.target.selector指向人员选择框。
  97. * @event MWF.xApplication.process.Xform.Org#expand
  98. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  99. */
  100. /**
  101. * 人员选择框事件:折叠分类后执行。this.target指向分类,this.target.selector指向人员选择框。
  102. * @event MWF.xApplication.process.Xform.Org#collapse
  103. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  104. */
  105. /**
  106. * 人员选择框事件:加载选择项前执行。this.target指向选择项,this.target.selector指向人员选择框。
  107. * @event MWF.xApplication.process.Xform.Org#queryLoadItem
  108. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  109. */
  110. /**
  111. * 人员选择框事件:加载选择项后执行。this.target指向选择项,this.target.selector指向人员选择框。
  112. * @event MWF.xApplication.process.Xform.Org#postLoadItem
  113. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  114. */
  115. /**
  116. * 人员选择框事件:选择选择项后执行。this.target指向选择项,this.target.selector指向人员选择框。
  117. * @event MWF.xApplication.process.Xform.Org#selectItem
  118. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  119. */
  120. /**
  121. * 人员选择框事件:取消选择选择项后执行。this.target指向选择项,this.target.selector指向人员选择框。
  122. * @event MWF.xApplication.process.Xform.Org#unselectItem
  123. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  124. */
  125. "selectorEvents" : ["queryLoadSelector","postLoadSelector","queryLoadContent","postLoadContent","queryLoadCategory","postLoadCategory",
  126. "selectCategory", "unselectCategory","queryLoadItem","postLoadItem","selectItem", "unselectItem","change","expand","collapse"],
  127. "readonly": true
  128. },
  129. iconStyle: "orgIcon",
  130. getTextData: function(){
  131. //var value = this.node.get("value");
  132. //var text = this.node.get("text");
  133. var value = this.getValue();
  134. //var text = (this.node.getFirst()) ? this.node.getFirst().get("text") : this.node.get("text");
  135. var text = [];
  136. value.each(function(v){
  137. if( typeOf(v) === "string" ){
  138. text.push(v);
  139. }else{
  140. text.push(v.name+((v.unitName) ? "("+v.unitName+")" : ""));
  141. }
  142. }.bind(this));
  143. return {"value": value || "", "text": [text.join(",")]};
  144. },
  145. loadDescription: function(){
  146. if (this.readonly || this.json.isReadonly)return;
  147. var v = this._getBusinessData();
  148. if (!v || !v.length){
  149. if (this.json.description){
  150. var size = this.node.getFirst().getSize();
  151. var w = size.x-3;
  152. if( this.json.showIcon!='no' && !this.form.json.hideModuleIcon ) {
  153. if (COMMON.Browser.safari) w = w - 20;
  154. }
  155. this.descriptionNode = new Element("div", {"styles": this.form.css.descriptionNode, "text": this.json.description}).inject(this.node);
  156. this.descriptionNode.setStyles({
  157. "width": ""+w+"px",
  158. "height": ""+size.y+"px",
  159. "line-height": ""+size.y+"px"
  160. });
  161. this.setDescriptionEvent();
  162. }
  163. }
  164. },
  165. setDescriptionEvent: function(){
  166. if (this.descriptionNode){
  167. this.descriptionNode.addEvents({
  168. "mousedown": function( ev ){
  169. this.descriptionNode.setStyle("display", "none");
  170. this.clickSelect( ev );
  171. }.bind(this)
  172. });
  173. }
  174. },
  175. _loadNode: function(){
  176. this.field = true;
  177. if (this.readonly || this.json.isReadonly){
  178. this._loadNodeRead();
  179. }else{
  180. this._getOrgOptions();
  181. if (this.json.isInput){
  182. this._loadNodeInputEdit();
  183. }else{
  184. this._loadNodeEdit();
  185. }
  186. }
  187. },
  188. _getOrgOptions: function(){
  189. this.selectTypeList = typeOf( this.json.selectType ) == "array" ? this.json.selectType : [this.json.selectType];
  190. if( this.selectTypeList.contains( "identity" ) ) {
  191. this.identityOptions = new MWF.APPOrg.IdentityOptions(this.form, this.json);
  192. }
  193. if( this.selectTypeList.contains( "unit" ) ) {
  194. this.unitOptions = new MWF.APPOrg.UnitOptions(this.form, this.json);
  195. }
  196. if( this.selectTypeList.contains( "group" ) ){
  197. this.groupOptions = new MWF.APPOrg.GroupOptions( this.form, this.json );
  198. }
  199. //this.selectUnits = this.getSelectRange();
  200. //if (this.json.selectType=="identity"){
  201. // this.selectDutys = this.getSelectRangeDuty();
  202. //}
  203. },
  204. _valueMerge: function(values, v){
  205. if (o2.typeOf(v)=="function"){
  206. return v.then(function(re){
  207. this._valueMerge(values, re)
  208. }.bind(this), function(){});
  209. }else{
  210. return values.concat(v);
  211. }
  212. },
  213. _computeValue: function(){
  214. var simple = this.json.storeRange === "simple";
  215. var values = [];
  216. if (this.json.identityValue) {
  217. this.json.identityValue.each(function(v){
  218. if (v) values.push(MWF.org.parseOrgData(v, true, simple))
  219. });
  220. }
  221. if (this.json.unitValue) {
  222. this.json.unitValue.each(function(v){ if (v) values.push(MWF.org.parseOrgData(v, true, simple))});
  223. }
  224. if (this.json.dutyValue) {
  225. var dutys = JSON.decode(this.json.dutyValue);
  226. var par;
  227. if (dutys.length){
  228. dutys.each(function(duty){
  229. if (duty.code) par = this.form.Macro.exec(duty.code, this);
  230. if (par){
  231. var promise = o2.promiseAll(par).then(function(p){
  232. var uName = p.distinguishedName || p;
  233. if (o2.typeOf(p)=="array") uName = p[0].distinguishedName || p[0];
  234. var code = "return this.org.getDuty(\""+duty.name+"\", \""+uName+"\", true)";
  235. var r = (!!uName) ? this.form.Macro.exec(code, this) : "";
  236. return o2.promiseAll(r).then(function(d){
  237. if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
  238. var arr = [];
  239. d.each(function(dd){
  240. if (dd) arr.push(MWF.org.parseOrgData(dd, true, simple));
  241. });
  242. return arr;
  243. }.bind(this)).catch(function(){
  244. console.log("catch error : can not get duty : " + duty.name, + "-" + uName);
  245. });
  246. }.bind(this), function(){});
  247. values.push(promise);
  248. }
  249. }.bind(this));
  250. }
  251. }
  252. if (this.json.defaultValue && this.json.defaultValue.code){
  253. var fd = this.form.Macro.exec(this.json.defaultValue.code, this);
  254. if (o2.typeOf(fd)=="array"){
  255. fd.each(function(v){values.push(v);});
  256. }else{
  257. values.push(fd);
  258. }
  259. // if (fd && fd.isAG){
  260. // values.push(fd);
  261. // }else{
  262. // if (typeOf(fd)!=="array") fd = (fd) ? [fd] : [];
  263. // fd.each(function(fdd){
  264. // if (fdd){
  265. // if (typeOf(fdd)==="string"){
  266. // var data;
  267. // this.getOrgAction()[this.getValueMethod(fdd)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), null, fdd, false);
  268. // values.push(data);
  269. // }else{
  270. // values.push(fdd);
  271. // }
  272. // }
  273. // }.bind(this));
  274. // }
  275. }
  276. // if (this.json.count>0){
  277. // return values.slice(0, this.json.count);
  278. // }
  279. return values;
  280. //return (this.json.defaultValue.code) ? this.form.Macro.exec(this.json.defaultValue.code, this): (value || "");
  281. },
  282. __computeValue: function(){
  283. var simple = this.json.storeRange === "simple";
  284. var values = [];
  285. if (this.json.identityValue) {
  286. this.json.identityValue.each(function(v){
  287. if (v) values.push(MWF.org.parseOrgData(v, true, simple))
  288. });
  289. }
  290. if (this.json.unitValue) {
  291. this.json.unitValue.each(function(v){ if (v) values.push(MWF.org.parseOrgData(v, true, simple))});
  292. }
  293. if (this.json.dutyValue) {
  294. var dutys = JSON.decode(this.json.dutyValue);
  295. var par;
  296. if (dutys.length){
  297. dutys.each(function(duty){
  298. if (duty.code) par = this.form.Macro.exec(duty.code, this);
  299. if (par && par.isAG){
  300. var ag = o2.AG.all(par).then(function(p){
  301. var uName = "";
  302. if (p && p.length) uName = p[0].distinguishedName || p[0];
  303. var code = "return this.org.getDuty(\""+duty.name+"\", \""+uName+"\", true)";
  304. var r = this.form.Macro.exec(code, this);
  305. o2.AG.all(r).then(function(d) {
  306. //var d = rd[0];
  307. if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
  308. var arr = [];
  309. d.each(function(dd){
  310. if (dd) arr.push(MWF.org.parseOrgData(dd, true, simple));
  311. });
  312. return arr;
  313. }.bind(this));
  314. }.bind(this));
  315. values.push(ag);
  316. }else{
  317. var code = "return this.org.getDuty(\""+duty.name+"\", \""+par+"\", true)";
  318. var r = this.form.Macro.exec(code, this);
  319. var ag = o2.AG.all(r).then(function(d) {
  320. //var d = rd[0];
  321. if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
  322. var arr = [];
  323. d.each(function(dd){
  324. if (dd) arr.push(MWF.org.parseOrgData(dd, true, simple));
  325. });
  326. return arr;
  327. }.bind(this));
  328. values.push(ag);
  329. // if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
  330. // d.each(function(dd){if (dd) values.push(MWF.org.parseOrgData(dd, true, simple));});
  331. }
  332. }.bind(this));
  333. }
  334. }
  335. if (this.json.defaultValue && this.json.defaultValue.code){
  336. var fd = this.form.Macro.exec(this.json.defaultValue.code, this);
  337. if (fd && fd.isAG){
  338. // value.addResolve(function(v){
  339. // this._setBusinessData(v);
  340. // if (this.node.getFirst()) this.node.getFirst().set("value", v || "");
  341. // if (this.readonly || this.json.isReadonly) this.node.set("text", v);
  342. // }.bind(this));
  343. values.push(fd);
  344. // fd.then(function(v){
  345. // return this._valueMerge(values, v);
  346. // }.bind(this));
  347. // return fd;
  348. }else{
  349. if (typeOf(fd)!=="array") fd = (fd) ? [fd] : [];
  350. fd.each(function(fdd){
  351. if (fdd){
  352. if (typeOf(fdd)==="string"){
  353. var data;
  354. this.getOrgAction()[this.getValueMethod(fdd)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), null, fdd, false);
  355. values.push(data);
  356. }else{
  357. values.push(fdd);
  358. }
  359. }
  360. }.bind(this));
  361. }
  362. }
  363. if (this.json.count>0){
  364. return values.slice(0, this.json.count);
  365. }
  366. return values;
  367. //return (this.json.defaultValue.code) ? this.form.Macro.exec(this.json.defaultValue.code, this): (value || "");
  368. },
  369. getOrgAction: function(){
  370. if (!this.orgAction) this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  371. //if (!this.orgAction) this.orgAction = new MWF.xApplication.Selector.Actions.RestActions();
  372. return this.orgAction;
  373. },
  374. getOptions: function(){
  375. var _self = this;
  376. if( this.selectTypeList.length === 0 )return false;
  377. var values = this.getInputData() || [];
  378. var exclude = [];
  379. if( this.json.exclude ){
  380. var v = this.form.Macro.exec(this.json.exclude.code, this);
  381. exclude = typeOf(v)==="array" ? v : [v];
  382. }
  383. //var count = (this.json.count) ? this.json.count : 0;
  384. var identityOpt;
  385. if( this.identityOptions ){
  386. identityOpt = this.identityOptions.getOptions();
  387. if (this.json.identityRange!=="all"){
  388. if ( !identityOpt.noUnit && (!identityOpt.units || !identityOpt.units.length) ){
  389. this.form.notice(MWF.xApplication.process.Xform.LP.noIdentitySelectRange, "error", this.node);
  390. identityOpt.disabled = true;
  391. // return false;
  392. }
  393. }
  394. if ( !identityOpt.noUnit && this.json.dutyRange && this.json.dutyRange!=="all"){
  395. if (!identityOpt.dutys || !identityOpt.dutys.length){
  396. this.form.notice(MWF.xApplication.process.Xform.LP.noIdentityDutySelectRange, "error", this.node);
  397. identityOpt.disabled = true;
  398. // return false;
  399. }
  400. }
  401. identityOpt.values = (this.json.isInput) ? [] : values;
  402. identityOpt.exclude = exclude;
  403. if( this.form.json.selectorStyle )identityOpt = Object.merge( identityOpt, this.form.json.selectorStyle );
  404. }
  405. var unitOpt;
  406. if( this.unitOptions ){
  407. unitOpt = this.unitOptions.getOptions();
  408. if (this.json.unitRange!=="all"){
  409. if ( !unitOpt.units || !unitOpt.units.length){
  410. this.form.notice(MWF.xApplication.process.Xform.LP.noUnitSelectRange, "error", this.node);
  411. unitOpt.disabled = true;
  412. // return false;
  413. }
  414. }
  415. unitOpt.values = (this.json.isInput) ? [] : values;
  416. unitOpt.exclude = exclude;
  417. if( this.form.json.selectorStyle )unitOpt = Object.merge( unitOpt, this.form.json.selectorStyle );
  418. }
  419. var groupOpt;
  420. if( this.groupOptions ){
  421. groupOpt = this.groupOptions.getOptions();
  422. groupOpt.values = (this.json.isInput) ? [] : values;
  423. groupOpt.exclude = exclude;
  424. if( this.form.json.selectorStyle )groupOpt = Object.merge( groupOpt, this.form.json.selectorStyle );
  425. }
  426. //var selectUnits = this.getSelectRange();
  427. //if (this.json.selectType=="identity"){
  428. // var selectDutys = this.getSelectRangeDuty();
  429. //}
  430. //if (this.json.range!=="all"){
  431. // if (!selectUnits.length){
  432. // this.form.notice(MWF.xApplication.process.Xform.LP.noSelectRange, "error", this.node);
  433. // return false;
  434. // }
  435. //}
  436. //if (this.json.selectType=="identity"){
  437. // if ((this.json.dutyRange) && this.json.dutyRange!=="all"){
  438. // if (!selectDutys || !selectDutys.length){
  439. // this.form.notice(MWF.xApplication.process.Xform.LP.noSelectRange, "error", this.node);
  440. // return false;
  441. // }
  442. // }
  443. //}
  444. var defaultOpt = {};
  445. if( this.json.events && typeOf(this.json.events) === "object" ){
  446. Object.each(this.json.events, function(e, key){
  447. if (e.code){
  448. if (this.options.selectorEvents.indexOf(key)!==-1){
  449. if( key === "postLoadSelector" ) {
  450. this.addEvent("loadSelector", function (selector) {
  451. return this.form.Macro.fire(e.code, selector);
  452. }.bind(this))
  453. }else if( key === "queryLoadSelector"){
  454. defaultOpt["onQueryLoad"] = function(target){
  455. return this.form.Macro.fire(e.code, target);
  456. }.bind(this)
  457. }else{
  458. defaultOpt["on"+key.capitalize()] = function(target){
  459. return this.form.Macro.fire(e.code, target);
  460. }.bind(this)
  461. }
  462. }
  463. }
  464. }.bind(this));
  465. }
  466. if( this.selectTypeList.length === 1 ){
  467. return Object.merge( {
  468. "type": this.selectTypeList[0],
  469. "onComplete": function(items){
  470. this.selectOnComplete(items);
  471. }.bind(this),
  472. "onCancel": this.selectOnCancel.bind(this),
  473. // "onLoad": this.selectOnLoad.bind(this),
  474. "onLoad": function(){
  475. //this 为 selector
  476. _self.selectOnLoad(this, this.selector );
  477. },
  478. "onClose": this.selectOnClose.bind(this)
  479. }, defaultOpt, identityOpt || unitOpt || groupOpt )
  480. }else if( this.selectTypeList.length > 1 ){
  481. var options = {
  482. "type" : "",
  483. "types" : this.selectTypeList,
  484. "onComplete": function(items){
  485. this.selectOnComplete(items);
  486. }.bind(this),
  487. "onCancel": this.selectOnCancel.bind(this),
  488. // "onLoad": this.selectOnLoad.bind(this),
  489. "onLoad": function(){
  490. //this 为 selector
  491. _self.selectOnLoad(this)
  492. },
  493. "onClose": this.selectOnClose.bind(this)
  494. };
  495. if( this.form.json.selectorStyle ){
  496. options = Object.merge( options, this.form.json.selectorStyle );
  497. }
  498. if( identityOpt )options.identityOptions = Object.merge( {}, defaultOpt, identityOpt );
  499. if( unitOpt )options.unitOptions = Object.merge( {}, defaultOpt, unitOpt );
  500. if( groupOpt )options.groupOptions = Object.merge( {}, defaultOpt, groupOpt );
  501. return options;
  502. }
  503. //return {
  504. // "type": this.json.selectType,
  505. // "unitType": (this.json.selectUnitType==="all") ? "" : this.json.selectUnitType,
  506. // "values": (this.json.isInput) ? [] : values,
  507. // "count": count,
  508. // "units": selectUnits,
  509. // "dutys": (this.json.selectType=="identity") ? selectDutys : [],
  510. // "exclude" : exclude,
  511. // "expandSubEnable" : (this.json.expandSubEnable=="no") ? false : true,
  512. // "categoryType": this.json.categoryType || "unit",
  513. // "onComplete": function(items){
  514. // this.selectOnComplete(items);
  515. // }.bind(this),
  516. // "onCancel": this.selectOnCancel.bind(this),
  517. // "onLoad": this.selectOnLoad.bind(this),
  518. // "onClose": this.selectOnClose.bind(this)
  519. //};
  520. },
  521. selectOnComplete: function(items){
  522. var array = [];
  523. items.each(function(item){
  524. array.push(item.data);
  525. }.bind(this));
  526. var simple = this.json.storeRange === "simple";
  527. this.checkEmpower( array, function( data ){
  528. var values = [];
  529. data.each(function(d){
  530. values.push(MWF.org.parseOrgData(d, true, simple));
  531. }.bind(this));
  532. if (this.json.isInput){
  533. this.addData(values);
  534. }else{
  535. this.setData(values);
  536. }
  537. //this._setBusinessData(values);
  538. this.validationMode();
  539. this.validation();
  540. this.fireEvent("select");
  541. }.bind(this))
  542. },
  543. selectOnCancel: function(){
  544. this.validation();
  545. },
  546. selectOnLoad: function( selector ){
  547. if (this.descriptionNode) this.descriptionNode.setStyle("display", "none");
  548. this.fireEvent("loadSelector", [selector])
  549. },
  550. selectOnClose: function(){
  551. v = this._getBusinessData();
  552. if (!v || !v.length) if (this.descriptionNode) this.descriptionNode.setStyle("display", "block");
  553. },
  554. /**
  555. * @summary 弹出选择界面.
  556. * @example
  557. * this.form.get('org').clickSelect();
  558. */
  559. clickSelect: function( ev ){
  560. if (this.readonly)return;
  561. if( layout.mobile ){
  562. setTimeout( function(){ //如果有输入法界面,这个时候页面的计算不对,所以等100毫秒
  563. var options = this.getOptions();
  564. if(options){
  565. if( this.selector && this.selector.loading ) {
  566. }else if( this.selector && this.selector.selector && this.selector.selector.active ){
  567. }else{
  568. /**
  569. * @summary 人员选择框package的对象
  570. * @member {o2.O2Selector}
  571. * @example
  572. * //可以在脚本中获取该组件
  573. * var selector = this.form.get("fieldId").selector.selector; //获取人员选择框对象
  574. * var options = selector.options; //获取人员选择框的选项
  575. */
  576. this.selector = new MWF.O2Selector(this.form.app.content, options);
  577. }
  578. }
  579. }.bind(this), 100 )
  580. }else{
  581. var options = this.getOptions();
  582. if(options){
  583. if( this.selector && this.selector.loading ) {
  584. }else if( this.selector && this.selector.selector && this.selector.selector.active ){
  585. }else {
  586. this.selector = new MWF.O2Selector(this.form.app.content, options);
  587. }
  588. }
  589. }
  590. },
  591. resetData: function(){
  592. var v = this.getValue();
  593. //this.setData((v) ? v.join(", ") : "");
  594. this.setData(v);
  595. },
  596. isEmpty: function(){
  597. var data = this.getData();
  598. if( typeOf(data) !== "array" )return true;
  599. if( data.length === 0 )return true;
  600. return false;
  601. },
  602. getInputData: function(){
  603. if (this.json.isInput){
  604. if (this.combox)return this.combox.getData();
  605. //return this._getBusinessData();
  606. return this.node.retrieve("data");
  607. }else{
  608. //return this._getBusinessData();
  609. return this.node.retrieve("data");
  610. }
  611. },
  612. _loadNodeRead: function(){
  613. this.node.empty();
  614. var node = new Element("div").inject(this.node);
  615. this.node.set({
  616. "nodeId": this.json.id,
  617. "MWFType": this.json.type
  618. });
  619. },
  620. _searchConfirmPerson: function(item){
  621. var inforNode = item.inforNode || new Element("div");
  622. var simple = this.json.storeRange === "simple";
  623. if (item.data){
  624. var data = item.data;
  625. if( this.selectTypeList.contains("identity") && this.json.identityResultType === "person"){
  626. var dn = data.distinguishedName || data;
  627. if( dn.substr( dn.length-1, 1).toLowerCase() === "i" ){
  628. MWF.Actions.get("x_organization_assemble_express").listPersonWithIdentity({
  629. identityList : [dn]
  630. }, function(json){
  631. if( json.data.length > 0 ){
  632. if( data["person"] )json.data[0].id = data["person"];
  633. item.data = MWF.org.parseOrgData( json.data[0], true, simple );
  634. item.value = this.getDataText( item.data );
  635. if(item.node)item.node.set("text", item.value);
  636. }
  637. }.bind(this), null, false)
  638. }
  639. }
  640. if( item.data && ( item.data.createTime || item.data.updateTime ) ){
  641. item.data = MWF.org.parseOrgData( item.data, true, simple );
  642. }
  643. var text = "";
  644. var flag = item.data.distinguishedName.substr(item.data.distinguishedName.length-2, 2);
  645. switch (flag.toLowerCase()){
  646. case "@i":
  647. text = item.data.name+"("+item.data.unitName+")";
  648. break;
  649. case "@p":
  650. text = item.data.name+(item.data.employee ? "("+item.data.employee+")" : "");
  651. break;
  652. case "@u":
  653. text = item.data.levelName;
  654. break;
  655. case "@g":
  656. text = item.data.name;
  657. break;
  658. default:
  659. text = item.data.name;
  660. }
  661. inforNode.set({
  662. "styles": {"font-size": "14px", "color": ""},
  663. "text": text
  664. });
  665. }else{
  666. inforNode.set({
  667. "styles": {"font-size": "14px", "color": "#bd0000"},
  668. "text": MWF.xApplication.process.Xform.LP.noOrgObject
  669. });
  670. }
  671. if (!item.inforNode){
  672. new mBox.Tooltip({
  673. content: inforNode,
  674. setStyles: {content: {padding: 15, lineHeight: 20}},
  675. attach: item.node,
  676. transition: 'flyin'
  677. });
  678. item.inforNode = inforNode;
  679. }
  680. },
  681. getSearchOptions: function(){
  682. if( this.selectTypeList.length === 0 )return false;
  683. var identityOpt;
  684. if( this.identityOptions ){
  685. identityOpt = this.identityOptions.getSearchOptions();
  686. //if (this.json.identityRange!=="all"){
  687. // if ( !identityOpt.units || !identityOpt.units.length){
  688. // this.form.notice(MWF.xApplication.process.Xform.LP.noIdentitySelectRange, "error", this.node);
  689. // return false;
  690. // }
  691. //}
  692. //if ((this.json.dutyRange) && this.json.dutyRange!=="all"){
  693. // if (!identityOpt.dutys || !identityOpt.dutys.length){
  694. // this.form.notice(MWF.xApplication.process.Xform.LP.noIdentityDutySelectRange, "error", this.node);
  695. // return false;
  696. // }
  697. //}
  698. }
  699. var unitOpt;
  700. if( this.unitOptions ){
  701. unitOpt = this.unitOptions.getSearchOptions();
  702. //if (this.json.unitRange!=="all"){
  703. // if ( !unitOpt.units || !unitOpt.units.length){
  704. // this.form.notice(MWF.xApplication.process.Xform.LP.noUnitSelectRange, "error", this.node);
  705. // return false;
  706. // }
  707. //}
  708. }
  709. var groupOpt;
  710. if( this.groupOptions ){
  711. groupOpt = this.groupOptions.getOptions();
  712. }
  713. if( this.selectTypeList.length === 1 ){
  714. return Object.merge( {
  715. "type": this.selectTypeList[0]
  716. }, identityOpt || unitOpt || groupOpt )
  717. }else if( this.selectTypeList.length > 1 ){
  718. var options = {
  719. "type" : "",
  720. "types" : this.selectTypeList
  721. };
  722. if( identityOpt )options.identityOptions = identityOpt;
  723. if( unitOpt )options.unitOptions = unitOpt;
  724. if( groupOpt )options.groupOptions = groupOpt;
  725. return options;
  726. }
  727. //return {
  728. // "type": this.json.selectType,
  729. // "unitType": (this.json.selectUnitType==="all") ? "" : this.json.selectUnitType,
  730. // "values": (this.json.isInput) ? [] : values,
  731. // "count": count,
  732. // "units": selectUnits,
  733. // "dutys": (this.json.selectType=="identity") ? selectDutys : [],
  734. // "exclude" : exclude,
  735. // "expandSubEnable" : (this.json.expandSubEnable=="no") ? false : true,
  736. // "categoryType": this.json.categoryType || "unit",
  737. // "onComplete": function(items){
  738. // this.selectOnComplete(items);
  739. // }.bind(this),
  740. // "onCancel": this.selectOnCancel.bind(this),
  741. // "onLoad": this.selectOnLoad.bind(this),
  742. // "onClose": this.selectOnClose.bind(this)
  743. //};
  744. },
  745. _searchOptions: function(value, callback){
  746. //var options = {
  747. // "type": this.json.selectType,
  748. // "unitType": (this.json.selectUnitType==="all") ? "" : this.json.selectUnitType,
  749. // "units": this.selectUnits,
  750. // "dutys": (this.json.selectType=="identity") ? this.selectDutys : []
  751. //};
  752. var options = this.getSearchOptions();
  753. if (!this.comboxFilter) this.comboxFilter = new MWF.O2SelectorFilter(value, options);
  754. this.comboxFilter.filter(value, function(data){
  755. data.map(function(d){
  756. var value = Object.clone(d);
  757. d.value = value;
  758. var flag = d.distinguishedName.substr(d.distinguishedName.length-2, 2);
  759. switch (flag.toLowerCase()){
  760. case "@i":
  761. d.text = d.name+"("+d.unitName+")";
  762. break;
  763. case "@p":
  764. d.text = d.name+(d.employee ? "("+d.employee+")" : "");
  765. break;
  766. case "@u":
  767. d.text = d.name;
  768. break;
  769. case "@g":
  770. d.text = d.name;
  771. break;
  772. default:
  773. d.text = d.name;
  774. }
  775. });
  776. if (callback) callback(data);
  777. });
  778. },
  779. _resetNodeInputEdit: function(){
  780. var node = new Element("div", {
  781. "styles": {
  782. "overflow": "hidden",
  783. //"position": "relative",
  784. "margin-right": "20px"
  785. }
  786. }).inject(this.node, "after");
  787. this.node.destroy();
  788. this.node = node;
  789. },
  790. _loadNodeInputEdit: function(){
  791. this.node.setStyle("overflow","visible");
  792. var input=null;
  793. MWF.require("MWF.widget.Combox", function(){
  794. this.combox = input = new MWF.widget.Combox({
  795. "count": this.json.count || 0,
  796. "splitShow": this.json.splitShow || ", ",
  797. "onCommitInput": function(item){
  798. this._searchConfirmPerson(item);
  799. //this.fireEvent("change");
  800. }.bind(this),
  801. "onChange": function(){
  802. this.node.store("data", this.getInputData());
  803. this._setBusinessData(this.getInputData());
  804. this.fireEvent("change");
  805. }.bind(this),
  806. "optionsMethod": this._searchOptions.bind(this)
  807. });
  808. }.bind(this), false);
  809. input.setStyles({
  810. "background": "transparent",
  811. "border": "0px"
  812. });
  813. input.set(this.json.properties);
  814. if (!this.json.preprocessing) this._resetNodeInputEdit();
  815. this.node.empty();
  816. input.inject(this.node);
  817. this.node.set({
  818. "id": this.json.id,
  819. "MWFType": this.json.type
  820. });
  821. if (this.json.showIcon!='no' && !this.form.json.hideModuleIcon) {
  822. this.iconNode = new Element("div", {
  823. "styles": this.form.css[this.iconStyle],
  824. "events": {
  825. "click": function (ev) {
  826. this.clickSelect(ev);
  827. }.bind(this)
  828. //this.clickSelect.bind(this)
  829. }
  830. }).inject(this.node, "before");
  831. }else if( this.form.json.nodeStyleWithhideModuleIcon ){
  832. this.node.setStyles(this.form.json.nodeStyleWithhideModuleIcon)
  833. }
  834. this.combox.addEvent("change", function(){
  835. this.validationMode();
  836. if (this.validation()){
  837. this.node.store("data", this.getInputData());
  838. this._setBusinessData(this.getInputData("change"));
  839. }
  840. }.bind(this));
  841. },
  842. _resetNodeEdit: function(){
  843. var input = new Element("div", {
  844. "styles": {
  845. "background": "transparent",
  846. "border": "0px",
  847. "min-height": "24px"
  848. }
  849. });
  850. var node = new Element("div", {"styles": {
  851. "overflow": "hidden",
  852. "position": "relative",
  853. "margin-right": "20px",
  854. "min-height": "24px"
  855. }}).inject(this.node, "after");
  856. input.inject(node);
  857. this.node.destroy();
  858. this.node = node;
  859. },
  860. _loadNodeEdit: function(){
  861. if (!this.json.preprocessing) this._resetNodeEdit();
  862. var input = this.node.getFirst();
  863. input.set(this.json.properties);
  864. this.node.set({
  865. "id": this.json.id,
  866. "MWFType": this.json.type,
  867. "events": {
  868. "click": function (ev) {
  869. this.clickSelect(ev);
  870. }.bind(this)
  871. //this.clickSelect.bind(this)
  872. }
  873. });
  874. if (this.json.showIcon!='no' && !this.form.json.hideModuleIcon) {
  875. this.iconNode = new Element("div", {
  876. "styles": this.form.css[this.iconStyle],
  877. "events": {
  878. "click": function (ev) {
  879. this.clickSelect(ev);
  880. }.bind(this)
  881. //this.clickSelect.bind(this)
  882. }
  883. }).inject(this.node, "before");
  884. }else if( this.form.json.nodeStyleWithhideModuleIcon ){
  885. this.node.setStyles(this.form.json.nodeStyleWithhideModuleIcon)
  886. }
  887. this.node.getFirst().setStyle("height", "auto");
  888. this.node.getFirst().addEvent("change", function(){
  889. this.validationMode();
  890. if (this.validation()){
  891. this.node.store("data", this.getInputData());
  892. this._setBusinessData(this.getInputData("change"));
  893. }
  894. }.bind(this));
  895. },
  896. getDataText: function(data){
  897. if (typeOf(data)=="string") return data;
  898. var text = "";
  899. var flag = data.distinguishedName.substr(data.distinguishedName.length-2, 2);
  900. switch (flag.toLowerCase()){
  901. case "@i":
  902. text = data.name+"("+data.unitName+")";
  903. break;
  904. case "@p":
  905. text = data.name+ (data.employee ? ("("+data.employee+")") : "");
  906. break;
  907. case "@u":
  908. text = data.name;
  909. break;
  910. case "@g":
  911. text = data.name;
  912. break;
  913. default:
  914. text = data.name;
  915. }
  916. return text;
  917. },
  918. addData: function(value){
  919. if (!value) return false;
  920. var simple = this.json.storeRange === "simple";
  921. value.each(function(v){
  922. var vtype = typeOf(v);
  923. if (vtype==="string"){
  924. var data;
  925. this.getOrgAction()[this.getValueMethod(v)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), null, v, false);
  926. if (data) this.combox.addNewValue(this.getDataText(data), data);
  927. }
  928. if (vtype==="object"){
  929. var d = MWF.org.parseOrgData(v, true, simple);
  930. this.combox.addNewValue(this.getDataText(d), d);
  931. }
  932. }.bind(this));
  933. },
  934. checkChange: function(oldValues, values){
  935. var change = false;
  936. if (!values) values = [];
  937. if (oldValues.length && (values && values.length)){
  938. if (oldValues.length === values.length){
  939. for (var i=0; i<oldValues.length; i++){
  940. if ((oldValues[i].distinguishedName!==values[i].distinguishedName) || (oldValues[i].name!==values[i].name) || (oldValues[i].unique!==values[i].unique)){
  941. change = true;
  942. break;
  943. }
  944. }
  945. }else{
  946. change = true;
  947. }
  948. }else if (values.length || oldValues.length) {
  949. change = true;
  950. }
  951. if (change) this.fireEvent("change");
  952. },
  953. setData: function(value){
  954. if (!value) return false;
  955. var oldValues = this.getData();
  956. if (value.length==1 && !(value[0])) value=[];
  957. var promise = this._setValue(value);
  958. promise.then(function(values){
  959. o2.promiseAll(values).then(function(v){
  960. this.checkChange(oldValues, v)
  961. }.bind(this), function(){});
  962. // if (values && values.isAG){
  963. // values.then(function(v){
  964. // this.checkChange(oldValues, v)
  965. // }.bind(this));
  966. // }else{
  967. // this.checkChange(oldValues, values)
  968. // }
  969. }.bind(this), function(){});
  970. },
  971. // __setData: function(value){
  972. // if (!value) return false;
  973. // var oldValues = this.getData();
  974. // var values = [];
  975. // var comboxValues = [];
  976. //
  977. // var simple = this.json.storeRange === "simple";
  978. //
  979. // var type = typeOf(value);
  980. // if (type==="array"){
  981. // value.each(function(v){
  982. // var vtype = typeOf(v);
  983. // var data = null;
  984. // if (vtype==="string"){
  985. // var error = (this.json.isInput) ? function(){ comboxValues.push(v); } : null;
  986. // this.getOrgAction()[this.getValueMethod(v)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), error, v, false);
  987. // }
  988. // if (vtype==="object") {
  989. // data = MWF.org.parseOrgData(v, true, simple);
  990. // if(data.woPerson)delete data.woPerson;
  991. // }
  992. // if (data){
  993. // values.push(data);
  994. // comboxValues.push({"text": this.getDataText(data),"value": data});
  995. // }
  996. // }.bind(this));
  997. // }
  998. // if (type==="string"){
  999. // var vData;
  1000. // var error = (this.json.isInput) ? function(){ comboxValues.push(value); } : null;
  1001. // this.getOrgAction()[this.getValueMethod(value)](function(json){ vData = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), error, value, false);
  1002. // if (vData){
  1003. // values.push(vData);
  1004. // comboxValues.push({"text": this.getDataText(vData),"value": vData});
  1005. // }
  1006. // }
  1007. // if (type==="object"){
  1008. // var vData = MWF.org.parseOrgData(value, true, simple);
  1009. // if(vData.woPerson)delete vData.woPerson;
  1010. // values.push( vData );
  1011. // comboxValues.push({"text": this.getDataText(value),"value": vData});
  1012. // }
  1013. //
  1014. // var change = false;
  1015. // if (oldValues.length && values.length){
  1016. // if (oldValues.length === values.length){
  1017. // for (var i=0; i<oldValues.length; i++){
  1018. // if ((oldValues[i].distinguishedName!==values[i].distinguishedName) || (oldValues[i].name!==values[i].name) || (oldValues[i].unique!==values[i].unique)){
  1019. // change = true;
  1020. // break;
  1021. // }
  1022. // }
  1023. // }else{
  1024. // change = true;
  1025. // }
  1026. // }else if (values.length || oldValues.length) {
  1027. // change = true;
  1028. // }
  1029. // this._setBusinessData(values);
  1030. // if (change) this.fireEvent("change");
  1031. //
  1032. // if (this.json.isInput){
  1033. // if (this.combox){
  1034. // this.combox.clear();
  1035. // this.combox.addNewValues(comboxValues);
  1036. // }else{
  1037. // var node = this.node.getFirst();
  1038. // if (node){
  1039. // node.empty();
  1040. // comboxValues.each(function(v, i){
  1041. // this.creteShowNode(v, (i===comboxValues.length-1)).inject(node);
  1042. // }.bind(this));
  1043. // }
  1044. // }
  1045. // }else{
  1046. // if (this.node.getFirst()){
  1047. // var node = this.node.getFirst();
  1048. // node.empty();
  1049. // this.loadOrgWidget(values, node)
  1050. // }else{
  1051. // this.node.empty();
  1052. // this.loadOrgWidget(values, this.node);
  1053. // }
  1054. // }
  1055. // },
  1056. creteShowNode: function(data, islast){
  1057. var nodeText = (data.text) ? data.text : data;
  1058. if (!islast) nodeText = nodeText + (this.json.splitShow || ", ");
  1059. var node = new Element("div", {
  1060. "styles": {
  1061. "float": "left",
  1062. "margin-right": "5px"
  1063. },
  1064. "text": nodeText
  1065. });
  1066. var text = "";
  1067. if (data.value){
  1068. var flag = data.value.distinguishedName.substr(data.value.distinguishedName.length-2, 2);
  1069. switch (flag.toLowerCase()){
  1070. case "@i":
  1071. text = data.value.name+"("+data.value.unitName+")";
  1072. break;
  1073. case "@p":
  1074. text = data.value.name+ (data.value.employee ? "("+data.value.employee+")" : "");
  1075. break;
  1076. case "@u":
  1077. text = data.value.levelName;
  1078. break;
  1079. case "@g":
  1080. text = data.value.name;
  1081. break;
  1082. default:
  1083. text = data.value.name;
  1084. }
  1085. var inforNode = new Element("div").set({
  1086. "styles": {"font-size": "14px", "color": ""},
  1087. "text": text
  1088. });
  1089. new mBox.Tooltip({
  1090. content: inforNode,
  1091. setStyles: {content: {padding: 15, lineHeight: 20}},
  1092. attach: node,
  1093. transition: 'flyin'
  1094. });
  1095. }
  1096. return node;
  1097. },
  1098. _setValue: function(value){
  1099. var values = [];
  1100. var ags = [];
  1101. var simple = this.json.storeRange === "simple";
  1102. var flag = false;
  1103. if (typeOf(value)!=="array") value = (!!value) ? [value] : [];
  1104. //value = (value.flat) ? value.flat() : value.flatten();
  1105. var p = o2.promiseAll(value).then(function(d){
  1106. if (typeOf(d)!=="array") d = (!!d) ? [d] : [];
  1107. d.each(function(da){
  1108. if (typeOf(da)!=="array") da = (!!da) ? [da] : [];
  1109. da.each(function(dd){
  1110. if (dd){
  1111. if (typeOf(dd)==="string"){
  1112. var pp = this.getOrgAction()[this.getValueMethod(dd)](function(json){
  1113. return MWF.org.parseOrgData(json.data, true, simple);
  1114. }.bind(this), null, dd, true).catch(function(e){
  1115. console.log("error:" + e);
  1116. console.log(e);
  1117. });
  1118. ags.push(pp);
  1119. }else{
  1120. values.push(dd);
  1121. }
  1122. }
  1123. }.bind(this));
  1124. }.bind(this));
  1125. if (ags.length){
  1126. return o2.promiseAll(ags).then(function(data){
  1127. values = values.concat(data);
  1128. flag = true;
  1129. this.__setValue(values);
  1130. return values;
  1131. }.bind(this), function(){});
  1132. }else{
  1133. flag = true;
  1134. this.__setValue(values);
  1135. return values
  1136. }
  1137. }.bind(this), function(){});
  1138. this.moduleValueAG = p;
  1139. if (p) p.then(function(){
  1140. this.moduleValueAG = null;
  1141. }.bind(this), function(){
  1142. this.moduleValueAG = null;
  1143. }.bind(this));
  1144. return p;
  1145. // var ag = o2.AG.all(value).then(function(d) {
  1146. // if (typeOf(d)!=="array") d = (d) ? [d.toString()] : [];
  1147. //
  1148. // d.each(function(dd){
  1149. // //if (dd) arr.push(MWF.org.parseOrgData(dd, true, simple));
  1150. // if (dd){
  1151. // if (typeOf(dd)==="string"){
  1152. // ags.push(this.getOrgAction()[this.getValueMethod(dd)](function(json){
  1153. // return MWF.org.parseOrgData(json.data, true, simple);
  1154. // }.bind(this).ag(), null, dd, true));
  1155. // }else{
  1156. // values.push(dd);
  1157. // }
  1158. // }
  1159. // }.bind(this));
  1160. // if (ags.length){
  1161. // return o2.AG.all(ags).then(function(data){
  1162. // values = values.concat(data);
  1163. // flag = true;
  1164. // this.__setValue(values);
  1165. // return values;
  1166. // }.bind(this));
  1167. // }else{
  1168. // flag = true;
  1169. // this.__setValue(values);
  1170. // return values
  1171. // }
  1172. // }.bind(this));
  1173. //
  1174. // this.moduleValueAG = ag;
  1175. // if (ag) ag.then(function(){
  1176. // this.moduleValueAG = null;
  1177. // }.bind(this));
  1178. // return ag;
  1179. },
  1180. __setValue: function(value){
  1181. this.moduleValueAG = null;
  1182. if (value.length==1 && !(value[0])) value=[];
  1183. if (this.json.count>0){
  1184. value = value.slice(0, this.json.count);
  1185. }
  1186. var values = [];
  1187. var comboxValues = [];
  1188. var type = typeOf(value);
  1189. var simple = this.json.storeRange === "simple";
  1190. if (type==="array"){
  1191. value.each(function(v){
  1192. var data=null;
  1193. var vtype = typeOf(v);
  1194. if (vtype==="string"){
  1195. var error = (this.json.isInput) ? function(){ comboxValues.push(v); } : null;
  1196. this.getOrgAction()[this.getValueMethod(v)](function(json){ data = MWF.org.parseOrgData(json.data, true, simple); }.bind(this), error, v, false);
  1197. }
  1198. if (vtype==="object") data = v;
  1199. if (data){
  1200. var d = MWF.org.parseOrgData(data, true, simple)
  1201. values.push(d);
  1202. comboxValues.push({"text": this.getDataText(d),"value": d});
  1203. }
  1204. }.bind(this));
  1205. }
  1206. if (type==="string"){
  1207. var vData;
  1208. var error = (this.json.isInput) ? function(){ comboxValues.push(value); } : null;
  1209. this.getOrgAction()[this.getValueMethod(value)](function(json){ vData = MWF.org.parseOrgData(json.data, true,simple); }.bind(this), error, value, false);
  1210. if (vData){
  1211. values.push(vData);
  1212. comboxValues.push({"text": this.getDataText(vData),"value": vData});
  1213. }
  1214. }
  1215. if (type==="object"){
  1216. var v = MWF.org.parseOrgData(value, true, simple)
  1217. values.push(v);
  1218. comboxValues.push({"text": this.getDataText(v),"value": v});
  1219. }
  1220. this.node.store("data", values);
  1221. this._setBusinessData(values);
  1222. if (this.json.isInput){
  1223. if (this.combox){
  1224. this.combox.clear();
  1225. this.combox.addNewValues(comboxValues);
  1226. // values.each(function(v){
  1227. // if (typeOf(v)=="string"){
  1228. // this.combox.addNewValue(v);
  1229. // }else{
  1230. // this.combox.addNewValue(this.getDataText(v), v);
  1231. // }
  1232. // }.bind(this));
  1233. }else{
  1234. var node = this.node.getFirst();
  1235. if (node){
  1236. node.empty();
  1237. comboxValues.each(function(v, i){
  1238. this.creteShowNode(v, (i===comboxValues.length-1)).inject(node);
  1239. }.bind(this));
  1240. }
  1241. }
  1242. }else{
  1243. if (this.node.getFirst()){
  1244. var node = this.node.getFirst();
  1245. node.empty();
  1246. this.loadOrgWidget(values, node)
  1247. }else{
  1248. this.node.empty();
  1249. this.loadOrgWidget(values, this.node);
  1250. }
  1251. }
  1252. //if (this.readonly) this.loadOrgWidget(values, this.node)
  1253. //this.node.set("text", value);
  1254. },
  1255. getValueMethod: function(value){
  1256. if (value){
  1257. var flag = value.substr(value.length-2, 2);
  1258. switch (flag.toLowerCase()){
  1259. case "@i":
  1260. return "getIdentity";
  1261. case "@p":
  1262. return "getPerson";
  1263. case "@u":
  1264. return "getUnit";
  1265. case "@g":
  1266. return "getGroup";
  1267. default:
  1268. return (this.json.selectType==="unit") ? "getUnit" : "getIdentity";
  1269. }
  1270. }
  1271. return (this.json.selectType==="unit") ? "getUnit" : "getIdentity";
  1272. },
  1273. loadOrgWidget: function(value, node){
  1274. var disableInfor = layout.mobile ? true : false;
  1275. if( this.json.showCard === "no" )disableInfor = true;
  1276. var height = node.getStyle("height").toInt();
  1277. if (node.getStyle("overflow")==="visible" && !height) node.setStyle("overflow", "hidden");
  1278. if (value && value.length){
  1279. value.each(function(data){
  1280. var flag = data.distinguishedName.substr(data.distinguishedName.length-2, 2);
  1281. var copyData = Object.clone(data);
  1282. if( this.json.displayTextScript && this.json.displayTextScript.code ){
  1283. this.currentData = copyData;
  1284. var displayName = this.form.Macro.exec(this.json.displayTextScript.code, this);
  1285. if( displayName ){
  1286. copyData.displayName = displayName;
  1287. }
  1288. this.currentData = null;
  1289. }
  1290. var widget;
  1291. switch (flag.toLowerCase()){
  1292. case "@i":
  1293. widget = new MWF.widget.O2Identity(copyData, node, {"style": "xform","lazy":true,"disableInfor" : disableInfor});
  1294. break;
  1295. case "@p":
  1296. widget = new MWF.widget.O2Person(copyData, node, {"style": "xform","lazy":true,"disableInfor" : disableInfor});
  1297. break;
  1298. case "@u":
  1299. widget = new MWF.widget.O2Unit(copyData, node, {"style": "xform","lazy":true,"disableInfor" : disableInfor});
  1300. break;
  1301. case "@g":
  1302. widget = new MWF.widget.O2Group(copyData, node, {"style": "xform","lazy":true,"disableInfor" : disableInfor});
  1303. break;
  1304. default:
  1305. widget = new MWF.widget.O2Other(copyData, node, {"style": "xform","lazy":true,"disableInfor" : disableInfor});
  1306. }
  1307. widget.field = this;
  1308. if( layout.mobile ){
  1309. widget.node.setStyles({
  1310. "float" : "none"
  1311. })
  1312. }
  1313. }.bind(this));
  1314. }
  1315. },
  1316. _loadStyles: function(){
  1317. if (this.readonly || this.json.isReadonly){
  1318. if (this.json.styles) this.node.setStyles(this.json.styles);
  1319. }else{
  1320. if (this.json.styles) this.node.setStyles(this.json.styles);
  1321. if (this.json.inputStyles) if (this.node.getFirst()) this.node.getFirst().setStyles(this.json.inputStyles);
  1322. if (this.iconNode && this.iconNode.offsetParent !== null ){
  1323. var size = this.node.getSize();
  1324. this.iconNode.setStyle("height", ""+size.y+"px");
  1325. }
  1326. }
  1327. },
  1328. checkEmpower : function( data, callback ){
  1329. if( typeOf(data)==="array" && this.identityOptions && this.json.isCheckEmpower && this.json.identityResultType === "identity" ) {
  1330. var empowerChecker = new MWF.APPOrg.EmpowerChecker(this.form, this.json);
  1331. empowerChecker.load(data, callback);
  1332. }else{
  1333. if( callback )callback( data );
  1334. }
  1335. }
  1336. });
  1337. MWF.APPOrg.EmpowerChecker = new Class({
  1338. Implements: [Events],
  1339. initialize: function (form, json) {
  1340. this.form = form;
  1341. this.json = json;
  1342. this.css = this.form.css;
  1343. this.checkedAllItems = true;
  1344. },
  1345. load : function( data, callback, container ){
  1346. if( typeOf(data)==="array" && this.json.isCheckEmpower && this.json.identityResultType === "identity" ){
  1347. var array = [];
  1348. data.each( function( d ){
  1349. if( d.distinguishedName ){
  1350. var flag = d.distinguishedName.substr(d.distinguishedName.length-1, 1).toLowerCase();
  1351. if( flag === "i" ){
  1352. array.push( d.distinguishedName )
  1353. }
  1354. }
  1355. }.bind(this));
  1356. if( array.length > 0 ){
  1357. o2.Actions.get("x_organization_assemble_express").listEmpowerWithIdentity({
  1358. "application" : (this.form.businessData.work || this.form.businessData.workCompleted).application,
  1359. "process" : (this.form.businessData.work || this.form.businessData.workCompleted).process,
  1360. "work" : (this.form.businessData.work || this.form.businessData.workCompleted).id,
  1361. "identityList" : array
  1362. }, function( json ){
  1363. var arr = [];
  1364. json.data.each( function(d){
  1365. if(d.fromIdentity !== d.toIdentity )arr.push(d);
  1366. });
  1367. if( arr.length > 0 ){
  1368. this.openSelectEmpowerDlg( arr, data, callback, container );
  1369. }else{
  1370. if( callback )callback( data );
  1371. }
  1372. }.bind(this), function(){
  1373. if( callback )callback( data );
  1374. }.bind(this))
  1375. }else{
  1376. if( callback )callback( data );
  1377. }
  1378. }else{
  1379. if( callback )callback( data );
  1380. }
  1381. },
  1382. getIgnoreEmpowerArray : function( callback ){
  1383. var array = [];
  1384. if( this.empowerSelectNodes && this.empowerSelectNodes.length ){
  1385. this.empowerSelectNodes.each(function(node){
  1386. if( !node.retrieve("isSelected") ){
  1387. var d = node.retrieve("data");
  1388. array.push( d.fromIdentity );
  1389. }
  1390. }.bind(this));
  1391. }
  1392. if( callback )callback( array );
  1393. return array;
  1394. },
  1395. setIgnoreEmpowerFlag : function(data, callback){
  1396. var ignoreList = this.getIgnoreEmpowerArray();
  1397. for( var i=0; i<data.length; i++ ){
  1398. var d = data[i];
  1399. if( ignoreList.indexOf( d.distinguishedName ) > -1 ){
  1400. d.ignoreEmpower = true;
  1401. }else if( d.ignoreEmpower ){
  1402. delete d.ignoreEmpower;
  1403. }
  1404. }
  1405. if( callback )callback( data );
  1406. },
  1407. replaceEmpowerIdentity : function(data, callback){
  1408. var empowerData = {};
  1409. this.empowerSelectNodes.each(function(node){
  1410. if( node.retrieve("isSelected") ){
  1411. var d = node.retrieve("data");
  1412. empowerData[ d.fromIdentity ] = d;
  1413. }
  1414. }.bind(this));
  1415. if( Object.keys(empowerData).length === 0 ){
  1416. callback( data );
  1417. }else{
  1418. var identityList = [];
  1419. for( var key in empowerData ){
  1420. identityList.push( empowerData[key].toIdentity );
  1421. }
  1422. o2.Actions.get("x_organization_assemble_express").listIdentity({ "identityList" : identityList }, function(json){
  1423. var newData = data.clone();
  1424. var d = {};
  1425. json.data.each( function(j){
  1426. d[j.distinguishedName] = j;
  1427. });
  1428. for( var i=0; i<newData.length; i++ ){
  1429. var nd = newData[i];
  1430. if( nd.distinguishedName && empowerData[nd.distinguishedName]){
  1431. if( d[empowerData[nd.distinguishedName].toIdentity] ){
  1432. newData[i] = d[empowerData[nd.distinguishedName].toIdentity]
  1433. }
  1434. }
  1435. }
  1436. callback( newData );
  1437. },function(){
  1438. callback( data );
  1439. });
  1440. }
  1441. },
  1442. openSelectEmpowerDlg : function( data, orginData, callback, container ){
  1443. if( layout.mobile ){
  1444. this.openSelectEmpowerDlg_mobile(data, orginData, callback, container);
  1445. }else{
  1446. this.openSelectEmpowerDlg_pc(data, orginData, callback, container);
  1447. }
  1448. },
  1449. openSelectEmpowerDlg_mobile : function( data, orginData, callback, container ){
  1450. var that = this;
  1451. //处理json
  1452. var subItemList = [];
  1453. // var empowerMap = {};
  1454. // var selectableItems = [];
  1455. var valueList = [];
  1456. data.each( function( d ){
  1457. subItemList.push({
  1458. "name" : d.fromIdentity.split("@")[0] + " 授权给 " + d.toIdentity.split("@")[0],
  1459. "id" : d.fromIdentity + "#" + d.toIdentity
  1460. })
  1461. valueList.push({
  1462. "name" : d.fromIdentity.split("@")[0] + " 授权给 " + d.toIdentity.split("@")[0],
  1463. "id" : d.fromIdentity + "#" + d.toIdentity
  1464. })
  1465. // empowerMap[ d.fromIdentity ] = d.toIdentity;
  1466. }.bind(this));
  1467. if( subItemList.length === 0 ){
  1468. callback();
  1469. return;
  1470. }
  1471. var empowerList = Array.clone(subItemList);
  1472. // selectableItems.push({
  1473. // "empowerMap" : empowerMap,
  1474. // "subItemList" : subItemList
  1475. // });
  1476. // if( selectableItems.length === 0 ){
  1477. // callback();
  1478. // return;
  1479. // }
  1480. // var empowerList = Array.clone(selectableItems);
  1481. o2.xDesktop.requireApp("Template", "Selector.Custom", function () {
  1482. var options = {
  1483. "count": 0,
  1484. "title": MWF.xApplication.process.Xform.LP.selectEmpower,
  1485. "selectAllEnable" : true,
  1486. "selectableItems": subItemList,
  1487. "expand": false,
  1488. "category": false,
  1489. "values": valueList,
  1490. "zIndex" : 3001,
  1491. "closeOnclickOk" : true,
  1492. "onComplete": function (items) {
  1493. var arr = [];
  1494. items.each(function (item) {
  1495. arr.push( item.data.id )
  1496. }.bind(this));
  1497. var ignoreList = [];
  1498. empowerList.each( function (obj) {
  1499. if( arr.indexOf( obj.id ) === -1 )ignoreList.push( obj.id.split("#")[0] )
  1500. });
  1501. for( var i=0; i<orginData.length; i++ ){
  1502. var d = orginData[i];
  1503. if( ignoreList.indexOf( d.distinguishedName ) > -1 ){
  1504. d.ignoreEmpower = true;
  1505. }else if( d.ignoreEmpower ){
  1506. delete d.ignoreEmpower;
  1507. }
  1508. }
  1509. if( callback )callback( orginData );
  1510. // empowerList.each( function(obj){
  1511. // var list = obj.subItemList.filter(function(item, index){
  1512. // return !arr.contains( item.id );
  1513. // }.bind(this));
  1514. // ignoreList = ignoreList.map(function(item,index){
  1515. // return item.id.split("#")[1];
  1516. // })
  1517. // });
  1518. // empowerList.each( function(obj){
  1519. // var org = that.orgItemsObject[obj.orgId];
  1520. // // if( obj.ignoreList.length > 0 ){
  1521. // var data = org.getData();
  1522. // for( var i=0; i<data.length; i++ ){
  1523. // var d = data[i];
  1524. // if( obj.ignoreList.indexOf( d.distinguishedName ) > -1 ){
  1525. // d.ignoreEmpower = true;
  1526. // }else if( d.ignoreEmpower ){
  1527. // delete d.ignoreEmpower;
  1528. // }
  1529. // }
  1530. // org.setData( data );
  1531. // }
  1532. // if( obj.empowerMap ){
  1533. // var data = org.getValue();
  1534. // for( var i=0; i<data.length; i++ ){
  1535. // var d = data[i];
  1536. // if( obj.empowerMap[ d.distinguishedName ] ){
  1537. // d.empowerToIdentity = obj.empowerMap[ d.distinguishedName ];
  1538. // }
  1539. // }
  1540. // org.empowerData = Array.clone(data);
  1541. // }
  1542. // if(callback)callback();
  1543. // })
  1544. }.bind(this)
  1545. };
  1546. if( this.form.json.selectorStyle ){
  1547. Object.merge(options, this.form.json.selectorStyle );
  1548. }
  1549. options.flatCategory = false;
  1550. var selector = new o2.xApplication.Template.Selector.Custom($(document.body), options);
  1551. selector.load();
  1552. }.bind(this))
  1553. },
  1554. openSelectEmpowerDlg_pc : function( data, orginData, callback, container ){
  1555. var node = new Element("div", {"styles": this.css.empowerAreaNode});
  1556. var html = "<div style=\"line-height: 20px; color: #333333; overflow: hidden\">"+MWF.xApplication.process.Xform.LP.empowerDlgText+"</div>";
  1557. html += "<div style=\"margin-bottom:10px; margin-top:10px; overflow-y:auto;\"></div>";
  1558. node.set("html", html);
  1559. var itemNode = node.getLast();
  1560. this.getEmpowerItems(itemNode, data);
  1561. node.inject( container || this.form.app.content);
  1562. var dlg = o2.DL.open({
  1563. "title": MWF.xApplication.process.Xform.LP.selectEmpower,
  1564. "style": this.form.json.dialogStyle || "user",
  1565. "isResize": true,
  1566. "content": node,
  1567. "width": 630,
  1568. //"height" : 500,
  1569. "buttonList": [
  1570. {
  1571. "type" : "ok",
  1572. "text": MWF.LP.process.button.ok,
  1573. "action": function(d, e){
  1574. //this.replaceEmpowerIdentity( orginData, callback ); //直接替换已授权的人,已废弃
  1575. this.setIgnoreEmpowerFlag( orginData, callback ); //然后设置忽略的人的标志
  1576. dlg.close();
  1577. }.bind(this)
  1578. },
  1579. {
  1580. "type" : "cancel",
  1581. "text": MWF.LP.process.button.cancel,
  1582. "action": function(){dlg.close();}
  1583. }
  1584. ],
  1585. "onPostShow": function(){
  1586. var selectNode = this.createSelectAllEmpowerNode();
  1587. selectNode.inject( dlg.button );
  1588. if( layout.mobile ){
  1589. dlg.node.inject( $(document.body) );
  1590. dlg.node.setStyles({
  1591. "width":"100%",
  1592. "height": "100%",
  1593. "top" : "0px",
  1594. "left" : "0px"
  1595. });
  1596. var y = dlg.node.getSize().y - 190;
  1597. itemNode.setStyle("height",y+"px");
  1598. dlg.options.contentHeight = dlg.node.getSize().y - 100 ; //+100;
  1599. dlg.setContentSize();
  1600. }else{
  1601. dlg.content.setStyle("overflow","hidden");
  1602. var y = Math.min(300, itemNode.getSize().y);
  1603. var marginTop = itemNode.getStyle("margin-top");
  1604. var marginBottom = itemNode.getStyle("margin-bottom");
  1605. itemNode.setStyle("height",y+"px");
  1606. dlg.options.contentHeight = y + 30 + 20 ; //+100;
  1607. dlg.setContentSize();
  1608. dlg.node.setStyles({
  1609. "height": ""+(dlg.options.height) +"px"
  1610. });
  1611. dlg.reCenter();
  1612. }
  1613. }.bind(this)
  1614. });
  1615. },
  1616. getEmpowerItems: function(itemNode, data){
  1617. var _self = this;
  1618. this.empowerSelectNodes = [];
  1619. var count = 1;
  1620. var node;
  1621. data.each(function( d ){
  1622. if(d.fromIdentity == d.toIdentity )return;
  1623. if( count % 2 === 1 ){
  1624. node = new Element("div", {"styles": this.css.empowerItemOddNode}).inject(itemNode);
  1625. node.store("nodeType","Odd");
  1626. //node.setStyle("margin-right","10px");
  1627. }else{
  1628. node = new Element("div", {"styles": this.css.empowerItemEvenNode}).inject(itemNode);
  1629. node.store("nodeType","Even");
  1630. }
  1631. count++;
  1632. this.empowerSelectNodes.push( node );
  1633. node.store("data", d);
  1634. var iconNode = new Element("div.empowerItemIconNode", {"styles": this.css.empowerItemIconNode}).inject(node);
  1635. node.store("iconNode",iconNode);
  1636. var contentNode = new Element("div.empowerItemContentNode", {"styles": this.css.empowerItemContentNode}).inject(node);
  1637. var formIdentityNode = new Element("div.empowerItemPersonNode", {"styles": this.css.empowerItemPersonNode, text : d.fromIdentity.split("@")[0] }).inject(contentNode);
  1638. var titleNode = new Element("div.empowerItemTitleNode", {"styles": this.css.empowerItemTitleNode, text : MWF.xApplication.process.Xform.LP.empowerTo }).inject(contentNode);
  1639. var toIdentityNode = new Element("div.empowerItemPersonNode", {"styles": this.css.empowerItemPersonNode, text : d.toIdentity.split("@")[0] }).inject(contentNode);
  1640. node.addEvents({
  1641. "mouseover": function(){
  1642. var isSelected = this.retrieve("isSelected");
  1643. if (!isSelected){
  1644. this.setStyles(_self.css[ "empowerItem"+this.retrieve("nodeType")+"Node_over" ]);
  1645. if( _self.css.empowerItemIconNode_over ){
  1646. var iconNode = this.retrieve("iconNode");
  1647. if(iconNode)iconNode.setStyles(_self.css.empowerItemIconNode_over);
  1648. }
  1649. }
  1650. },
  1651. "mouseout": function(){
  1652. var isSelected = this.retrieve("isSelected");
  1653. if (!isSelected){
  1654. this.setStyles(_self.css[ "empowerItem"+this.retrieve("nodeType")+"Node" ])
  1655. if( _self.css.empowerItemIconNode_over ){
  1656. var iconNode = this.retrieve("iconNode");
  1657. if(iconNode)iconNode.setStyles(_self.css.empowerItemIconNode);
  1658. }
  1659. }
  1660. },
  1661. "click": function(){
  1662. var isSelected = this.retrieve("isSelected");
  1663. if (isSelected){
  1664. _self.unselectEmpowerItem( this)
  1665. }else{
  1666. _self.selectEmpowerItem(this)
  1667. }
  1668. }
  1669. });
  1670. if( this.checkedAllItems )node.click();
  1671. }.bind(this));
  1672. },
  1673. unselectEmpowerItem : function( itemNode ){
  1674. itemNode.store("isSelected", false);
  1675. itemNode.setStyles( this.css[ "empowerItem"+itemNode.retrieve("nodeType")+"Node" ] );
  1676. itemNode.getElements("div").each( function( div ){
  1677. var className = div.get("class");
  1678. if( className && this.css[className] )div.setStyles( this.css[className] )
  1679. }.bind(this))
  1680. },
  1681. selectEmpowerItem : function( itemNode ){
  1682. itemNode.store("isSelected", true);
  1683. itemNode.setStyles( this.css[ "empowerItem"+itemNode.retrieve("nodeType")+"Node_selected" ] );
  1684. itemNode.getElements("div").each( function( div ){
  1685. var className = div.get("class");
  1686. if( className && this.css[className+"_selected"] )div.setStyles( this.css[className+"_selected"] )
  1687. }.bind(this))
  1688. },
  1689. createSelectAllEmpowerNode : function(){
  1690. var _self = this;
  1691. var node = new Element("div", {
  1692. styles : this.css.empowerSelectAllItemNode,
  1693. text : MWF.xApplication.process.Xform.LP.selectAll
  1694. });
  1695. node.addEvents({
  1696. "mouseover": function(){
  1697. var isSelected = this.retrieve("isSelected");
  1698. if (!isSelected) this.setStyles(_self.css.empowerSelectAllItemNode_over);
  1699. },
  1700. "mouseout": function(){
  1701. var isSelected = this.retrieve("isSelected");
  1702. if (!isSelected) this.setStyles(_self.css.empowerSelectAllItemNode)
  1703. },
  1704. "click": function(){
  1705. var isSelected = this.retrieve("isSelected");
  1706. if (isSelected){
  1707. this.store("isSelected", false);
  1708. this.setStyles( _self.css.empowerSelectAllItemNode );
  1709. _self.empowerSelectNodes.each( function(itemNode){
  1710. _self.unselectEmpowerItem(itemNode)
  1711. }.bind(this))
  1712. }else{
  1713. this.store("isSelected", true);
  1714. this.setStyles( _self.css.empowerSelectAllItemNode_selected );
  1715. _self.empowerSelectNodes.each( function(itemNode){
  1716. _self.selectEmpowerItem(itemNode)
  1717. }.bind(this))
  1718. }
  1719. }
  1720. });
  1721. if( this.checkedAllItems ){
  1722. node.store("isSelected", true);
  1723. node.setStyles( _self.css.empowerSelectAllItemNode_selected );
  1724. }
  1725. return node;
  1726. }
  1727. });
  1728. MWF.APPOrg.GroupOptions = new Class({
  1729. Implements: [Events],
  1730. initialize: function (form, json) {
  1731. this.form = form;
  1732. this.json = json;
  1733. this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  1734. },
  1735. getOptions: function(){
  1736. var count = (this.json.groupCount) ? this.json.groupCount : 0;
  1737. if( this.json.groupRange==="group" ){
  1738. return {
  1739. "count": count,
  1740. "include": this.getSelectRange( true )
  1741. }
  1742. }else{
  1743. return {
  1744. "count": count
  1745. }
  1746. }
  1747. },
  1748. getSearchOptions : function(){
  1749. return {};
  1750. },
  1751. getSelectRange : function( refresh ){
  1752. if( !this.selectRange || refresh){
  1753. this.selectRange = this._getSelectRange();
  1754. }
  1755. return this.selectRange;
  1756. },
  1757. _getSelectRange : function(){
  1758. var rangeValues = [];
  1759. if (this.json.groupRangeKey && this.json.groupRangeKey.code){
  1760. var v = this.form.Macro.exec(this.json.groupRangeKey.code, this);
  1761. if (typeOf(v)!=="array") v = (v) ? [v.toString()] : [];
  1762. rangeValues = v;
  1763. //v.each(function(d){
  1764. // if (d){
  1765. // if (typeOf(d)==="string"){
  1766. // var data;
  1767. // this.orgAction.getGroup(function(json){ data = json.data }.bind(this), null, d, false);
  1768. // rangeValues.push(data);
  1769. // }else{
  1770. // rangeValues.push(d);
  1771. // }
  1772. // }
  1773. //}.bind(this));
  1774. }
  1775. return rangeValues;
  1776. }
  1777. });
  1778. MWF.APPOrg.UnitOptions = new Class({
  1779. Implements: [Events],
  1780. initialize : function( form, json ){
  1781. this.form = form;
  1782. this.json = json;
  1783. this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  1784. },
  1785. getOptions: function(){
  1786. var count = (this.json.unitCount) ? this.json.unitCount : 0;
  1787. var selectUnits = this.getSelectRange( true );
  1788. return {
  1789. "count": count,
  1790. "units": selectUnits,
  1791. "unitType": (this.json.selectUnitType==="all") ? "" : this.json.selectUnitType,
  1792. "expandSubEnable" : (this.json.unitExpandSubEnable=="no") ? false : true
  1793. };
  1794. },
  1795. getSearchOptions : function(){
  1796. var selectUnits = this.getSelectRange( true );
  1797. return {
  1798. "units": selectUnits,
  1799. "unitType": (this.json.selectUnitType==="all") ? "" : this.json.selectUnitType
  1800. };
  1801. },
  1802. getSelectRange : function( refresh ){
  1803. if( !this.selectRange || refresh){
  1804. this.selectRange = this._getSelectRange();
  1805. }
  1806. return this.selectRange;
  1807. },
  1808. _getSelectRange : function(){
  1809. if (this.json.unitRange==="unit"){
  1810. return this.getScriptSelectUnit();
  1811. }
  1812. if (this.json.unitRange==="draftUnit"){
  1813. var dn = (this.form.businessData.work || this.form.businessData.workCompleted).creatorIdentityDn;
  1814. if (!dn){
  1815. if ( layout.session.user.identityList && layout.session.user.identityList.length){
  1816. var ids = [];
  1817. layout.session.user.identityList.each(function(id){ ids.push(id.id); });
  1818. return this.getNextSelectUnit(ids);
  1819. }else{
  1820. return [];
  1821. }
  1822. }else{
  1823. return this.getNextSelectUnit((this.form.businessData.work || this.form.businessData.workCompleted).creatorIdentityDn);
  1824. }
  1825. }
  1826. if (this.json.unitRange==="currentUnit"){
  1827. if (this.form.app.currentTask){
  1828. return this.getNextSelectUnit(this.form.app.currentTask.identityDn);
  1829. }else{
  1830. if (this.form.app.taskList && this.form.app.taskList.length){
  1831. var ids = [];
  1832. this.form.app.taskList.each(function(task){ ids.push(task.identity); });
  1833. return this.getNextSelectUnit(ids);
  1834. }else{
  1835. if ( layout.session.user.identityList && layout.session.user.identityList.length){
  1836. var ids = [];
  1837. layout.session.user.identityList.each(function(id){ ids.push(id.id); });
  1838. return this.getNextSelectUnit(ids);
  1839. }else{
  1840. return [];
  1841. }
  1842. }
  1843. }
  1844. }
  1845. return [];
  1846. },
  1847. getScriptSelectUnit: function(){
  1848. var rangeValues = [];
  1849. if (this.json.unitRangeUnit && this.json.unitRangeUnit.length){
  1850. this.json.unitRangeUnit.each(function(unit){
  1851. //var unitFlag = unit.distinguishedName || unit.id || unit.unique || unit.levelName;
  1852. //if (unitFlag) rangeValues.push(unitFlag);
  1853. rangeValues.push(unit);
  1854. }.bind(this));
  1855. }
  1856. if (this.json.unitRangeField && this.json.unitRangeField.length){
  1857. this.json.unitRangeField.each(function(field){
  1858. var n = (typeOf(field)=="object") ? field.name : field;
  1859. var v = this.form.businessData.data[n];
  1860. if (typeOf(v)!=="array") v = (v) ? [v.toString()] : [];
  1861. v.each(function(d){
  1862. if (d){
  1863. // if (typeOf(d)==="string"){
  1864. // var data;
  1865. // this.orgAction.getUnit(function(json){ data = json.data }.bind(this), null, d, false);
  1866. // rangeValues.push(data);
  1867. // }else{
  1868. rangeValues.push(d);
  1869. // }
  1870. }
  1871. }.bind(this));
  1872. }.bind(this));
  1873. }
  1874. if (this.json.unitRangeKey && this.json.unitRangeKey.code){
  1875. var v = this.form.Macro.exec(this.json.unitRangeKey.code, this);
  1876. if (typeOf(v)!=="array") v = (v) ? [v.toString()] : [];
  1877. v.each(function(d){
  1878. if (d){
  1879. // if (typeOf(d)==="string"){
  1880. // var data;
  1881. // this.orgAction.getUnit(function(json){ data = json.data }.bind(this), null, d, false);
  1882. // rangeValues.push(data);
  1883. // }else{
  1884. rangeValues.push(d);
  1885. // }
  1886. }
  1887. }.bind(this));
  1888. }
  1889. return rangeValues;
  1890. },
  1891. getNextSelectUnit: function(id){
  1892. var ids = typeOf(id)==="array" ? id : [id];
  1893. var data;
  1894. var units = [];
  1895. ids.each( function(i){
  1896. if (this.json.unitRangeNext === "direct"){
  1897. this.orgAction.getIdentity(function(json){ data = json.data }.bind(this), function(){data={"woUnit": null}}, i, false);
  1898. if (data && data.woUnit) units.push(data.woUnit);
  1899. }else if(this.json.unitRangeNext==="level"){
  1900. this.orgAction.getUnitWithIdentityWithLevel(i, this.json.unitRangeNextLevel, function(json){ data = json.data }.bind(this), function(){data=null;}, false);
  1901. if (data) units.push(data);
  1902. }else if (this.json.unitRangeNext==="type"){
  1903. if (this.json.unitRangeNextUnitType==="all"){
  1904. this.orgAction.getUnitWithIdentityWithLevel(i, 1, function(json){ data = json.data }.bind(this), function(){data=null;}, false);
  1905. }else{
  1906. this.orgAction.getUnitWithIdentityWithType(i, this.json.unitRangeNextUnitType, function(json){ data = json.data }.bind(this), function(){data=null;}, false);
  1907. }
  1908. if (data) units.push(data);
  1909. }
  1910. data = null;
  1911. }.bind(this));
  1912. return units;
  1913. //if (this.json.unitRangeNext === "direct"){
  1914. // if (typeOf(id)==="array"){
  1915. // var units = [];
  1916. // id.each(function(i){
  1917. // this.orgAction.getIdentity(function(json){ data = json.data }.bind(this), function(){data={"woUnit": null}}, i, false);
  1918. // if (data && data.woUnit) units.push(data.woUnit);
  1919. // data = null;
  1920. // }.bind(this));
  1921. // return units;
  1922. // }else{
  1923. // this.orgAction.getIdentity(function(json){ data = json.data }.bind(this), function(){data={"woUnit": null}}, id, false);
  1924. // return (data.woUnit) ? [data.woUnit] : [];
  1925. // }
  1926. //}
  1927. //if (this.json.unitRangeNext==="level"){
  1928. // this.orgAction.getUnitWithIdentityWithLevel(id, this.json.unitRangeNextLevel, function(json){ data = json.data }.bind(this), function(){data=null;}, false);
  1929. // //this.json.rangeNextLevel
  1930. // return (data) ? [data] : [];
  1931. //}
  1932. //if (this.json.unitRangeNext==="type"){
  1933. // if (this.json.unitRangeNextUnitType==="all"){
  1934. // this.orgAction.getUnitWithIdentityWithLevel(id, 1, function(json){ data = json.data }.bind(this), function(){data=null;}, false);
  1935. // }else{
  1936. // this.orgAction.getUnitWithIdentityWithType(id, this.json.unitRangeNextUnitType, function(json){ data = json.data }.bind(this), function(){data=null;}, false);
  1937. // }
  1938. //
  1939. // return (data) ? [data] : [];
  1940. //}
  1941. }
  1942. });
  1943. MWF.APPOrg.IdentityOptions = new Class({
  1944. Implements: [Events],
  1945. initialize : function( form, json ){
  1946. this.form = form;
  1947. this.json = json;
  1948. this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  1949. },
  1950. getOptions: function(){
  1951. var count = (this.json.identityCount) ? this.json.identityCount : 0;
  1952. if( this.json.identityOnlyUseInclude ){
  1953. return {
  1954. "noUnit" : true,
  1955. "count": count,
  1956. "resultType" : this.json.identityResultType,
  1957. "include" : this._getInclude()
  1958. };
  1959. }else{
  1960. var selectUnits = this.getSelectRange( true );
  1961. var selectDutys = this.getSelectRangeDuty( true );
  1962. return {
  1963. "count": count,
  1964. "units": selectUnits,
  1965. "dutys": selectDutys,
  1966. "expandSubEnable" : (this.json.identityExpandSubEnable=="no") ? false : true,
  1967. "resultType" : this.json.identityResultType,
  1968. "categoryType": this.json.categoryType || "unit",
  1969. "dutyUnitLevelBy" : this.json.dutyUnitLevelBy || "duty",
  1970. "include" : this._getInclude()
  1971. };
  1972. }
  1973. },
  1974. getSearchOptions : function(){
  1975. var selectUnits = this.getSelectRange( true );
  1976. var selectDutys = this.getSelectRangeDuty( true );
  1977. return {
  1978. "units": selectUnits,
  1979. "dutys": selectDutys,
  1980. "resultType" : this.json.identityResultType
  1981. };
  1982. },
  1983. getSelectRange : function( refresh ){
  1984. if( !this.selectRange || refresh ){
  1985. this.selectRange = this._getSelectRange();
  1986. }
  1987. return this.selectRange;
  1988. },
  1989. _getInclude : function(){
  1990. var include = [];
  1991. if( this.json.identityIncludeKey ){
  1992. var v = this.form.Macro.exec(this.json.identityIncludeKey.code, this);
  1993. if( v )include = typeOf(v)==="array" ? v : [v];
  1994. }
  1995. return include;
  1996. },
  1997. _getSelectRange : function(){
  1998. if (this.json.identityRange==="unit"){
  1999. return this.getScriptSelectUnit();
  2000. }
  2001. if (this.json.identityRange==="draftUnit"){
  2002. var dn = (this.form.businessData.work || this.form.businessData.workCompleted).creatorIdentityDn;
  2003. if (!dn){
  2004. if ( layout.session.user.identityList && layout.session.user.identityList.length){
  2005. var ids = [];
  2006. layout.session.user.identityList.each(function(id){ ids.push(id.id); });
  2007. return this.getNextSelectUnit(ids);
  2008. }else{
  2009. return [];
  2010. }
  2011. }else{
  2012. return this.getNextSelectUnit((this.form.businessData.work || this.form.businessData.workCompleted).creatorIdentityDn);
  2013. }
  2014. }
  2015. if (this.json.identityRange==="currentUnit"){
  2016. if (this.form.app.currentTask){
  2017. return this.getNextSelectUnit(this.form.app.currentTask.identityDn);
  2018. }else{
  2019. if (this.form.app.taskList && this.form.app.taskList.length){
  2020. var ids = [];
  2021. this.form.app.taskList.each(function(task){ ids.push(task.identity); });
  2022. return this.getNextSelectUnit(ids);
  2023. }else{
  2024. if ( layout.session.user.identityList && layout.session.user.identityList.length){
  2025. var ids = [];
  2026. layout.session.user.identityList.each(function(id){ ids.push(id.id); });
  2027. return this.getNextSelectUnit(ids);
  2028. }else{
  2029. return [];
  2030. }
  2031. }
  2032. }
  2033. }
  2034. return [];
  2035. },
  2036. getScriptSelectUnit: function(){
  2037. var rangeValues = [];
  2038. if (this.json.identityRangeUnit && this.json.identityRangeUnit.length){
  2039. this.json.identityRangeUnit.each(function(unit){
  2040. //var unitFlag = unit.distinguishedName || unit.id || unit.unique || unit.levelName ;
  2041. //if (unitFlag) rangeValues.push(unitFlag);
  2042. rangeValues.push(unit);
  2043. }.bind(this));
  2044. }
  2045. if (this.json.identityRangeField && this.json.identityRangeField.length){
  2046. this.json.identityRangeField.each(function(field){
  2047. var n = (typeOf(field)=="object") ? field.name : field;
  2048. var v = this.form.businessData.data[n];
  2049. if (typeOf(v)!=="array") v = (v) ? [v.toString()] : [];
  2050. v.each(function(d){
  2051. if (d){
  2052. // if (typeOf(d)==="string"){
  2053. // var data;
  2054. // this.orgAction.getUnit(function(json){ data = json.data }.bind(this), null, d, false);
  2055. // rangeValues.push(data);
  2056. // }else{
  2057. rangeValues.push(d);
  2058. // }
  2059. }
  2060. }.bind(this));
  2061. }.bind(this));
  2062. }
  2063. if (this.json.identityRangeKey && this.json.identityRangeKey.code){
  2064. var v = this.form.Macro.exec(this.json.identityRangeKey.code, this);
  2065. if (typeOf(v)!=="array") v = (v) ? [v.toString()] : [];
  2066. v.each(function(d){
  2067. if (d){
  2068. // if (typeOf(d)==="string"){
  2069. // var data;
  2070. // this.orgAction.getUnit(function(json){ data = json.data }.bind(this), null, d, false);
  2071. // rangeValues.push(data);
  2072. // }else{
  2073. rangeValues.push(d);
  2074. // }
  2075. }
  2076. }.bind(this));
  2077. }
  2078. return rangeValues;
  2079. },
  2080. getNextSelectUnit: function(id){
  2081. var ids = typeOf(id)==="array" ? id : [id];
  2082. var data;
  2083. var units = [];
  2084. ids.each(function(i){
  2085. if (this.json.identityRangeNext === "direct"){
  2086. this.orgAction.getIdentity(function(json){ data = json.data }.bind(this), function(){data={"woUnit": null}}, i, false);
  2087. if (data && data.woUnit) units.push(data.woUnit);
  2088. }else if (this.json.identityRangeNext==="level"){
  2089. this.orgAction.getUnitWithIdentityWithLevel(i, this.json.identityRangeNextLevel, function(json){ data = json.data }.bind(this), function(){data=null;}, false);
  2090. if (data) units.push(data);
  2091. }else if (this.json.identityRangeNext==="type"){
  2092. if (this.json.identityRangeNextUnitType==="all"){
  2093. this.orgAction.getUnitWithIdentityWithLevel(i, 1, function(json){ data = json.data }.bind(this), function(){data=null;}, false);
  2094. }else{
  2095. this.orgAction.getUnitWithIdentityWithType(i, this.json.identityRangeNextUnitType, function(json){ data = json.data }.bind(this), function(){data=null;}, false);
  2096. }
  2097. if (data) units.push(data);
  2098. }
  2099. data = null;
  2100. }.bind(this));
  2101. return units;
  2102. //if (this.json.identityRangeNext === "direct"){
  2103. //if (typeOf(id)==="array"){
  2104. // var units = [];
  2105. // id.each(function(i){
  2106. // this.orgAction.getIdentity(function(json){ data = json.data }.bind(this), function(){data={"woUnit": null}}, i, false);
  2107. // if (data && data.woUnit) units.push(data.woUnit);
  2108. // data = null;
  2109. // }.bind(this));
  2110. // return units;
  2111. //}else{
  2112. // this.orgAction.getIdentity(function(json){ data = json.data }.bind(this), function(){data={"woUnit": null}}, id, false);
  2113. // return (data.woUnit) ? [data.woUnit] : [];
  2114. //}
  2115. //}
  2116. //if (this.json.identityRangeNext==="level"){
  2117. // this.orgAction.getUnitWithIdentityWithLevel(id, this.json.identityRangeNextLevel, function(json){ data = json.data }.bind(this), function(){data=null;}, false);
  2118. // return (data) ? [data] : [];
  2119. // //this.json.rangeNextLevel
  2120. //}
  2121. //if (this.json.identityRangeNext==="type"){
  2122. // if (this.json.identityRangeNextUnitType==="all"){
  2123. // this.orgAction.getUnitWithIdentityWithLevel(id, 1, function(json){ data = json.data }.bind(this), function(){data=null;}, false);
  2124. // }else{
  2125. // this.orgAction.getUnitWithIdentityWithType(id, this.json.identityRangeNextUnitType, function(json){ data = json.data }.bind(this), function(){data=null;}, false);
  2126. // }
  2127. // return (data) ? [data] : [];
  2128. //}
  2129. },
  2130. getSelectRangeDuty: function( refresh ){
  2131. if( !this.selectRangeDuty || refresh ){
  2132. this.selectRangeDuty = this._getSelectRangeDuty();
  2133. }
  2134. return this.selectRangeDuty;
  2135. },
  2136. _getSelectRangeDuty: function(){
  2137. if (this.json.dutyRange==="duty"){
  2138. return this.getScriptSelectDuty();
  2139. }
  2140. return [];
  2141. },
  2142. getScriptSelectDuty: function(){
  2143. var rangeValues = [];
  2144. if( this.json.rangeDuty && this.json.rangeDuty.length ){
  2145. var rangeDuty = this.json.rangeDuty;
  2146. if( typeOf(rangeDuty) === "string" ){
  2147. rangeDuty = JSON.parse( rangeDuty );
  2148. }
  2149. if( typeOf(rangeDuty) === "array" ){
  2150. rangeDuty.each(function(unit){
  2151. var unitFlag = typeOf(unit) === "string" ? unit : (unit.id || unit.name);
  2152. if (unitFlag) rangeValues.push(unitFlag);
  2153. }.bind(this));
  2154. }
  2155. }
  2156. //if (this.json.rangeDuty && this.json.rangeDuty.length){
  2157. // this.json.rangeDuty.each(function(unit){
  2158. // var unitFlag = unit.id || unit.name;
  2159. // if (unitFlag) rangeValues.push(unitFlag);
  2160. // }.bind(this));
  2161. //}
  2162. if (this.json.rangeDutyField && this.json.rangeDutyField.length){
  2163. this.json.rangeDutyField.each(function(field){
  2164. var n = (typeOf(field)=="object") ? field.name : field;
  2165. var v = this.form.businessData.data[n];
  2166. if (typeOf(v)!=="array") v = (v) ? [v.toString()] : [];
  2167. v.each(function(d){
  2168. if (d) rangeValues.push(d);
  2169. }.bind(this));
  2170. }.bind(this));
  2171. }
  2172. if (this.json.rangeDutyKey && this.json.rangeDutyKey.code){
  2173. var v = this.form.Macro.exec(this.json.rangeDutyKey.code, this);
  2174. if (typeOf(v)!=="array") v = (v) ? [v.toString()] : [];
  2175. v.each(function(d){
  2176. if (d) rangeValues.push(d);
  2177. }.bind(this));
  2178. }
  2179. return rangeValues;
  2180. }
  2181. });