Administrator.js 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. MWF.xDesktop.requireApp("Setting", "servers.DataServers", null, false);
  2. MWF.xApplication.Setting.resource = MWF.xApplication.Setting.resource || {};
  3. MWF.xApplication.Setting.resource.Administrator = new Class({
  4. Extends: MWF.xApplication.Setting.servers.DataServer.Document,
  5. Implements: [Events],
  6. initialize: function(explorer){
  7. this.explorer = explorer;
  8. this.app = this.explorer.app;
  9. this.container = this.explorer.adminContent;
  10. this.css = this.explorer.app.css;
  11. this.load();
  12. },
  13. load: function(){
  14. this.app.actions.getResAdministrator(function(json){
  15. this.json = json.data;
  16. this.node = new Element("div", {"styles": this.css.centerServerDocumentNode}).inject(this.container);
  17. this.createForm();
  18. }.bind(this));
  19. },
  20. createActions: function(){
  21. this.actionNode = new Element("div", {"styles": this.css.applicationServerDocumentActionNode}).inject(this.node);
  22. this.saveAction = new Element("div", {"styles": this.css.applicationServerDocumentSaveNode}).inject(this.actionNode);
  23. //this.closeAction = new Element("div", {"styles": this.css.applicationServerDocumentCloseNode}).inject(this.actionNode);
  24. this.saveAction.addEvents({
  25. "mouseover": function(){this.saveAction.setStyles(this.css.applicationServerDocumentSaveNode_over);}.bind(this),
  26. "mouseout": function(){this.saveAction.setStyles(this.css.applicationServerDocumentSaveNode);}.bind(this),
  27. "mousedown": function(){this.saveAction.setStyles(this.css.applicationServerDocumentSaveNode_down);}.bind(this),
  28. "mouseup": function(){this.saveAction.setStyles(this.css.applicationServerDocumentSaveNode_over);}.bind(this),
  29. "click": function(e){this.saveDocument();}.bind(this)
  30. });
  31. },
  32. createBaseInfo: function(){
  33. this.inforAreaNode = new Element("div", {"styles": this.css.applicationServerDocumentInforAreaNode}).inject(this.node);
  34. this.inforNode = new Element("div", {"styles": this.css.dataServerDocumentInforNode}).inject(this.inforAreaNode);
  35. var html = "<table cellSpacing='8px' width='90%' align='center'>" +
  36. "<tr><td width='120px'>id</td><td>"+(this.json.id || "")+"</td></tr>" +
  37. "<tr><td>name</td><td>"+(this.json.name || "")+"</td></tr>" +
  38. "<tr><td>password</td><td><input value='"+(this.json.password || "")+"'/></td></tr>" +
  39. "<tr><td>employee</td><td><input value='"+(this.json.employee || "")+"'/></td></tr>" +
  40. "<tr><td>display</td><td><input value='"+(this.json.display || "")+"'/></td></tr>" +
  41. "<tr><td>mobile</td><td><input value='"+(this.json.mobile || "")+"'/></td></tr>" +
  42. "<tr><td>mail</td><td><input value='"+(this.json.mail || "")+"'/></td></tr>" +
  43. "<tr><td>weixin</td><td><input value='"+(this.json.qq || "")+"'/></td></tr>" +
  44. "<tr><td>qq</td><td><input value='"+(this.json.cipher || "")+"'/></td></tr>" +
  45. "<tr><td>weibo</td><td><input value='"+(this.json.weibo || "")+"'/></td></tr>" +
  46. "<tr><td>roleList</td><td><textarea>"+this.json.roleList.join(", ")+"</textarea></td></tr>" +
  47. "<tr><td>icon</td><td><textarea>"+(this.json.icon || "")+"</textarea></td></tr>" +
  48. "</table>";
  49. this.inforNode.set("html", html);
  50. var tds = this.inforNode.getElements("td");
  51. var inputs = this.inforNode.getElements("input");
  52. var textareas = this.inforNode.getElements("textarea");
  53. tds.setStyles(this.css.applicationServerDocumentTdNode);
  54. inputs.setStyles(this.css.applicationServerDocumentInputNode);
  55. textareas.setStyles(this.css.applicationServerDocumentTextareasNode);
  56. },
  57. saveDocument: function(){
  58. var inputs = this.inforNode.getElements("input");
  59. var textareas = this.inforNode.getElements("textarea");
  60. this.json.password = inputs[0].get("value");
  61. this.json.employee = inputs[1].get("value");
  62. this.json.display = inputs[2].get("value");
  63. this.json.mobile = inputs[3].get("value");
  64. this.json.mail = inputs[4].get("value");
  65. this.json.weixin = inputs[5].get("value");
  66. this.json.qq = inputs[6].get("value");
  67. this.json.weibo = inputs[7].get("value");
  68. this.json.roleList = textareas[0].get("value").split(/,\s*/g);
  69. this.json.icon = textareas[1].get("value");
  70. this.app.actions.updateResAdministrator(this.json, function(){
  71. this.app.notice(this.app.lp.centerSaveInfor, "success");
  72. }.bind(this));
  73. },
  74. destroy: function(){
  75. if (this.node) this.node.destroy();
  76. MWF.release(this);
  77. },
  78. });