Org.js 95 KB

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