Org.js 95 KB

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