Personfield.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. MWF.xDesktop.requireApp("process.Xform", "Personfield", null, false);
  2. MWF.xApplication.cms.Xform.Personfield = MWF.CMSPersonfield = new Class({
  3. Extends: MWF.APPPersonfield,
  4. //getDepartments: function(){
  5. // if (this.json.range=="depart"){
  6. // return this.getRange();
  7. // }
  8. // if (this.json.range=="currentdepart"){
  9. // return [this.form.businessData.document.creatorUnitName];
  10. // }
  11. // return [];
  12. //},
  13. //getCompanys: function(){
  14. // if (this.json.range=="company"){
  15. // var comp = "";
  16. // //if (this.json.rangeKey){
  17. // return this.getRange();
  18. // //}
  19. // }
  20. // if (this.json.range=="currentcompany"){
  21. // return [this.form.businessData.document.creatorTopUnitName];
  22. // }
  23. // return [];
  24. //}
  25. getSelectRange: function(){
  26. if (this.json.range==="unit"){
  27. return this.getScriptSelectUnit();
  28. }
  29. if (this.json.range==="draftUnit"){
  30. return this.getNextSelectUnit((this.form.businessData.document.creatorIdentity));
  31. }
  32. if (this.json.range==="currentUnit"){
  33. if (layout.session.user.identityList.length){
  34. var ids = [];
  35. layout.session.user.identityList.each(function(id){ ids.push(id.id); });
  36. return this.getNextSelectUnit(ids);
  37. }else{
  38. return [];
  39. }
  40. }
  41. return [];
  42. },
  43. getSelectRangeDuty: function(){
  44. if (this.json.dutyRange==="duty"){
  45. return this.getScriptSelectDuty();
  46. }
  47. return [];
  48. },
  49. clickSelect: function(){
  50. //var names = (nameValue) ? this.getInputData().split(MWF.splitStr) : [];
  51. var values = this.getInputData();
  52. var count = (this.json.count) ? this.json.count : 0;
  53. switch (this.json.range){
  54. case "":
  55. }
  56. var selectUnits = this.getSelectRange();
  57. if (this.json.selectType=="identity"){
  58. var selectDutys = this.getSelectRangeDuty();
  59. }
  60. if (this.json.range!=="all"){
  61. if (!selectUnits.length){
  62. this.form.notice(MWF.xApplication.process.Xform.LP.noSelectRange, "error", this.node);
  63. return false;
  64. }
  65. }
  66. if (this.json.selectType=="identity"){
  67. if ((this.json.dutyRange) && this.json.dutyRange!=="all"){
  68. if (!selectDutys || !selectDutys.length){
  69. this.form.notice(MWF.xApplication.process.Xform.LP.noSelectRange, "error", this.node);
  70. return false;
  71. }
  72. }
  73. }
  74. var exclude = [];
  75. if( this.json.exclude ){
  76. var v = this.form.Macro.exec(this.json.exclude.code, this);
  77. exclude = typeOf(v)==="array" ? v : [v];
  78. }
  79. var simple = this.json.storeRange === "simple";
  80. var options = {
  81. "type": this.json.selectType,
  82. "unitType": (this.json.selectUnitType==="all") ? "" : this.json.selectUnitType,
  83. "values": (this.json.isInput) ? [] : values,
  84. "count": count,
  85. "units": selectUnits,
  86. "exclude" : exclude,
  87. "expandSubEnable" : (this.json.expandSubEnable=="no") ? false : true,
  88. "dutys": (this.json.selectType=="identity") ? selectDutys : [],
  89. "onComplete": function(items){
  90. var values = [];
  91. items.each(function(item){
  92. values.push(MWF.org.parseOrgData(item.data, true, simple));
  93. }.bind(this));
  94. if (this.json.isInput){
  95. this.addData(values);
  96. }else{
  97. this.setData(values);
  98. }
  99. //this._setBusinessData(values);
  100. this.validationMode();
  101. this.validation();
  102. this.fireEvent("select");
  103. }.bind(this),
  104. "onCancel": function(){
  105. this.validation();
  106. }.bind(this),
  107. "onLoad": function(){
  108. if (this.descriptionNode) this.descriptionNode.setStyle("display", "none");
  109. }.bind(this),
  110. "onClose": function(){
  111. v = this._getBusinessData();
  112. if (!v || !v.length) if (this.descriptionNode) this.descriptionNode.setStyle("display", "block");
  113. }.bind(this)
  114. };
  115. if( this.selector && this.selector.loading ) {
  116. }else if( this.selector && this.selector.selector && this.selector.selector.active ){
  117. }else {
  118. this.selector = new MWF.O2Selector(this.form.app.content, options);
  119. }
  120. }
  121. });