Нет описания

index.js 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. ;
  2. spa_define(function() {
  3. return $.use(["spa", "pagedatagrid", "util", "validate"], function(spa, pdgf, util, validate) {
  4. return {
  5. main: function() {
  6. var root = spa.findInMain(".sys_user_index");
  7. var pdg = pdgf.build(root);
  8. // validate.form(pdg.form, { name: { required: "not null", len: { val: 5, msg: "我的中国心" } } });
  9. root.find(".opt-query").on("click", function() {
  10. pdg.load();
  11. });
  12. root.find(".opt-new").on("click", function() {
  13. spa.showModal("sys_user_new", function() { pdg.load() });
  14. });
  15. root.find(".dt-tpl").on("click", "th.opt-check>i.icon-st-check", function() {
  16. var $this = $(this);
  17. $this.toggleClass("checked");
  18. if($this.hasClass("checked")) {
  19. root.find(".dt-tpl td.opt-check>i.icon-st-check").addClass("checked");
  20. } else {
  21. root.find(".dt-tpl td.opt-check>i.icon-st-check").removeClass("checked");
  22. }
  23. });
  24. root.find(".dt-tpl").on("click", "td.opt-check>i.icon-st-check", function() {
  25. var $this = $(this);
  26. $this.toggleClass("checked");
  27. });
  28. root.find(".opt-edit").on("click", function() {
  29. var $org = root.find("td.opt-check>i.checked");
  30. if($org.length) {
  31. if($org.length > 1) {
  32. util.alertMsg("只能选择一个用户");
  33. } else {
  34. util.get("../ajax/sys/user/id/" + $org.attr("userId"), null, function(rd) {
  35. if(rd) {
  36. spa.showModal("sys_user_edit", { data: rd, hand: function() { pdg.load() } })
  37. } else {
  38. util.alertMsg("机构已不存在", function() { pdg.load(); });
  39. }
  40. }, {});
  41. }
  42. } else {
  43. util.alert("请选择一个用户");
  44. }
  45. });
  46. root.find(".opt-del").on("click", function() {
  47. var $org = root.find("td.opt-check>i.checked");
  48. if($org.length) {
  49. var ret = [];
  50. $org.each(function() {
  51. ret.push($(this).attr("userId"));
  52. });
  53. util.boxMsg({
  54. title: "确认删除",
  55. content: "您是否要删除选中的用户信息,机构信息删除后不可恢复!!!!!!!!!!!!!!!!!!",
  56. btns: [{
  57. caption: "删除",
  58. hand: function() {
  59. util.post("../ajax/sys/user/del", { ids: ret }, function() { pdg.load() }, {});
  60. }
  61. },
  62. { caption: "取消" }
  63. ]
  64. });
  65. } else {
  66. util.alert("请选择一个用户");
  67. }
  68. });
  69. root.find(".opt-role").on("click", function() {
  70. var $user = root.find("td.opt-check>i.checked");
  71. if($user.length) {
  72. if($user.length > 1) {
  73. util.alert("只能选择一个用户");
  74. } else {
  75. var ud = {
  76. id: $user.attr("userId"),
  77. name: $user.parent().parent().children(".data-name").text(),
  78. mobile: $user.parent().parent().children(".data-mobile").text(),
  79. email: $user.parent().parent().children(".data-email").text(),
  80. userRoles: null,
  81. roles: null
  82. },
  83. sm = function() {
  84. if(ud.userRoles && ud.roles) {
  85. spa.showModal("sys_user_role", ud);
  86. }
  87. };
  88. util.get("../ajax/sys/role/all", null, function(rd) {
  89. ud.roles = rd;
  90. sm();
  91. });
  92. util.get("../ajax/sys/userRole/user/" + ud.id, null, function(rd) {
  93. if(rd) {
  94. ud.userRoles = rd;
  95. sm();
  96. } else {
  97. util.alert("用户不存在了");
  98. }
  99. });
  100. }
  101. } else {
  102. util.alert("请选择一个用户");
  103. }
  104. });
  105. root.find(".opt-right").on("click", function() {
  106. var $user = root.find("td.opt-check>i.checked");
  107. if($user.length) {
  108. if($user.length > 1) {
  109. util.alert("只能选择一个用户");
  110. } else {
  111. var ud = {
  112. id: $user.attr("userId"),
  113. name: $user.parent().parent().children(".data-name").text(),
  114. mobile: $user.parent().parent().children(".data-mobile").text(),
  115. email: $user.parent().parent().children(".data-email").text(),
  116. userRights: null,
  117. rights: null
  118. },
  119. sm = function() {
  120. if(ud.userRights && ud.rights) {
  121. spa.showModal("sys_user_right", ud);
  122. }
  123. };
  124. util.get("../ajax/sys/right/all", null, function(rd) {
  125. ud.rights = rd;
  126. sm();
  127. });
  128. util.get("../ajax/sys/user/right/" + ud.id, null, function(rd) {
  129. if(rd) {
  130. ud.userRights = rd;
  131. sm();
  132. } else {
  133. util.alert("用户不存在了");
  134. }
  135. });
  136. }
  137. } else {
  138. util.alert("请选择一个用户");
  139. }
  140. });
  141. pdg.load();
  142. },
  143. mainDestory: function() {
  144. },
  145. };
  146. });
  147. });