PersonSetting.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  2. MWF.xDesktop.requireApp("Selector", "package", null, false);
  3. MWF.xDesktop.requireApp("Attendance", "Explorer", null, false);
  4. MWF.xApplication.Attendance.PersonSetting = new Class({
  5. Extends: MWF.xApplication.Attendance.Explorer,
  6. Implements: [Options, Events],
  7. initialize: function(node, app, actions, options){
  8. this.setOptions(options);
  9. this.app = app;
  10. this.path = "../x_component_Attendance/$PersonSetting/";
  11. this.cssPath = "../x_component_Attendance/$PersonSetting/"+this.options.style+"/css.wcss";
  12. this._loadCss();
  13. this.actions = actions;
  14. this.node = $(node);
  15. this.initData();
  16. if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  17. },
  18. load: function(){
  19. this.loadToolbar();
  20. //this.loadFilter();
  21. this.loadContentNode();
  22. this.loadView();
  23. this.setNodeScroll();
  24. },
  25. loadView : function(){
  26. this.view = new MWF.xApplication.Attendance.PersonSetting.View(this.elementContentNode, this.app,this, this.viewData, this.options.searchKey );
  27. this.view.load();
  28. this.setContentSize();
  29. },
  30. createDocument: function(){
  31. if(this.view)this.view._createDocument();
  32. }
  33. });
  34. MWF.xApplication.Attendance.PersonSetting.View = new Class({
  35. Extends: MWF.xApplication.Attendance.Explorer.View,
  36. _createItem: function(data){
  37. return new MWF.xApplication.Attendance.PersonSetting.Document(this.table, data, this.explorer, this);
  38. },
  39. _getCurrentPageData: function(callback, count){
  40. this.actions.listPersonSetting(function(json){
  41. if (callback) callback(json);
  42. });
  43. },
  44. _removeDocument: function(document, all){
  45. this.actions.deletePersonSetting(document.id, function(json){
  46. this.explorer.view.reload();
  47. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  48. }.bind(this));
  49. },
  50. _createDocument: function(){
  51. var form = new MWF.xApplication.Attendance.PersonSetting.Form(this.explorer);
  52. form.create();
  53. },
  54. _openDocument: function( documentData ){
  55. var form = new MWF.xApplication.Attendance.PersonSetting.Form(this.explorer, documentData );
  56. form.edit();
  57. }
  58. });
  59. MWF.xApplication.Attendance.PersonSetting.Document = new Class({
  60. Extends: MWF.xApplication.Attendance.Explorer.Document
  61. });
  62. MWF.xApplication.Attendance.PersonSetting.Form = new Class({
  63. Extends: MWF.xApplication.Attendance.Explorer.PopupForm,
  64. options : {
  65. "width": 600,
  66. "height": 450,
  67. "hasTop" : true,
  68. "hasBottom" : true,
  69. "title" : MWF.xApplication.Attendance.LP.personSetting,
  70. "draggable" : true,
  71. "closeAction" : true
  72. },
  73. _createTableContent: function(){
  74. var lp = MWF.xApplication.Attendance.LP;
  75. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  76. "<tr><td styles='formTabelTitle' lable='configType'></td>"+
  77. " <td styles='formTableValue' item='configType'></td></tr>" +
  78. "<tr><td styles='formTabelTitle' lable='topUnitName'></td>"+
  79. " <td styles='formTableValue' item='topUnitName'></td></tr>" +
  80. "<tr><td styles='formTabelTitle' lable='unitName'></td>"+
  81. " <td styles='formTableValue' item='unitName'></td></tr>" +
  82. "<tr><td styles='formTabelTitle' lable='employeeName'></td>"+
  83. " <td styles='formTableValue' item='employeeName'></td></tr>" +
  84. "<tr><td styles='formTabelTitle' lable='employeeNumber'></td>"+
  85. " <td styles='formTableValue' item='employeeNumber'></td></tr>" +
  86. "<tr><td styles='formTabelTitle' lable='empInTopUnitTime'></td>"+
  87. " <td styles='formTableValue' item='empInTopUnitTime'></td></tr>" +
  88. "</table>";
  89. this.formTableArea.set("html",html);
  90. MWF.xDesktop.requireApp("Template", "MForm", function(){
  91. this.form = new MForm( this.formTableArea, this.data, {
  92. style: "attendance",
  93. isEdited : this.isEdited || this.isNew,
  94. itemTemplate : {
  95. configType : { text:lp.configType, type : "select", selectText : lp.configTypeSelectText, selectValue : ["REQUIRED","NOTREQUIRED"] },
  96. topUnitName : { text: lp.topUnitName, type : "org", orgType : "unit", notEmpty:true },
  97. unitName : { text:lp.unitName, type : "org", orgType : "unit" },
  98. employeeName : { text:lp.employeeName, type : "org", orgType : "person", "event" : {
  99. change : function( item , ev ){
  100. if( typeOf( item.orgObject ) == "array" && item.orgObject.length > 0 ){
  101. var data = item.orgObject[0].data;
  102. if( data ){
  103. item.form.getItem( "employeeNumber").setValue( data.employee );
  104. }
  105. }
  106. }
  107. } },
  108. employeeNumber : { text:lp.employeeNumber },
  109. empInTopUnitTime : { text:lp.joininDate, tType : "date" }
  110. }
  111. }, this.app);
  112. this.form.load();
  113. }.bind(this), true);
  114. },
  115. _ok: function( data, callback ){
  116. this.app.restActions.savePersonSetting( data, function(json){
  117. if( callback )callback(json);
  118. }.bind(this));
  119. }
  120. });