Sin Descripción

index.js 9.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /**
  2. * Created by TT on 2017/7/7.
  3. */
  4. ;
  5. spa_define(function () {
  6. return $.use(["spa", "pagedatagrid", "util"], function (spa, pdgf, util) {
  7. return {
  8. main: function () {
  9. var root = spa.findInMain(".sys_userinfo_index");
  10. var pdg = pdgf.build(root);
  11. // validate.form(pdg.form, { name: { required: "not null", len: { val: 5, msg: "我的中国心" } } });
  12. root.find(".opt-query").on("click", function () {
  13. pdg.load();
  14. });
  15. root.find(".opt-new").on("click", function () {
  16. spa.showModal("sys_userinfo_new", function () {
  17. pdg.load()
  18. });
  19. });
  20. root.find(".dt-tpl").on("click", "th.opt-check>i.icon-st-check", function () {
  21. var $this = $(this);
  22. $this.toggleClass("checked");
  23. if ($this.hasClass("checked")) {
  24. root.find(".dt-tpl td.opt-check>i.icon-st-check").addClass("checked");
  25. } else {
  26. root.find(".dt-tpl td.opt-check>i.icon-st-check").removeClass("checked");
  27. }
  28. });
  29. root.find(".dt-tpl").on("click", "td.opt-check>i.icon-st-check", function () {
  30. var $this = $(this);
  31. $this.toggleClass("checked");
  32. });
  33. root.find(".opt-edit").on("click", function () {
  34. var $org = root.find("td.opt-check>i.checked");
  35. if ($org.length) {
  36. if ($org.length > 1) {
  37. util.alert("只能选择一个用户");
  38. } else {
  39. util.get("../ajax/userinfo/id/" + $org.attr("userId"), null, function (data) {
  40. if (data) {
  41. if (data.state == "1" || data.state == "4") {
  42. spa.showModal("sys_userinfo_edit", {
  43. data: data, hand: function () {
  44. pdg.load()
  45. }
  46. })
  47. } else {
  48. util.alert("待审核和审核通过的不可修改。");
  49. }
  50. } else {
  51. util.alert("用户不存在了", function () {
  52. pdg.load();
  53. });
  54. }
  55. }, {});
  56. }
  57. } else {
  58. util.alert("请选择一个用户");
  59. }
  60. });
  61. root.find(".opt-del").on("click", function () {
  62. var $org = root.find("td.opt-check>i.checked");
  63. if ($org.length) {
  64. if ($org.length > 1) {
  65. util.alert("只能选择一个用户");
  66. } else {
  67. util.get("../ajax/userinfo/id/" + $org.attr("userId"), null, function (data) {
  68. if (data) {
  69. if (data.state == "1" || data.state == "4") {
  70. util.boxMsg({
  71. title: "确认删除",
  72. content: "您是否要删除选中的用户信息,信息删除后不可恢复。",
  73. btns: [{
  74. caption: "删除",
  75. hand: function () {
  76. util.del("../ajax/userinfo/del/" + $org.attr("userId"), function (code) {
  77. if (code != 1) {
  78. if (code == 2) {
  79. util.alert("无法删除,请检查状态");
  80. }
  81. if (code == 3) {
  82. util.alert("找不到该账户,请检查");
  83. }
  84. }
  85. pdg.load()
  86. }, {});
  87. }
  88. },
  89. {caption: "取消"}
  90. ]
  91. });
  92. } else {
  93. util.alert("待审核和审核通过的不可删除。");
  94. }
  95. } else {
  96. util.alert("用户不存在了", function () {
  97. pdg.load();
  98. });
  99. }
  100. }, {});
  101. }
  102. } else {
  103. util.alert("请选择一个用户");
  104. }
  105. });
  106. root.find(".opt-details").on("click", function () {
  107. var $org = root.find("td.opt-check>i.checked");
  108. if ($org.length) {
  109. if ($org.length > 1) {
  110. util.alert("只能选择一个用户");
  111. } else {
  112. util.get("../ajax/userinfo/id/" + $org.attr("userId"), null, function (data) {
  113. if (data) {
  114. if (data.state == "1" || data.state == "4") {
  115. spa.showModal("sys_userinfo_details", {
  116. data: data, hand: function () {
  117. pdg.load()
  118. }
  119. })
  120. } else {
  121. util.alert("待审核和审核通过的不可修改。");
  122. }
  123. } else {
  124. util.alert("用户不存在了", function () {
  125. pdg.load();
  126. });
  127. }
  128. }, {});
  129. }
  130. } else {
  131. util.alert("请选择一个用户");
  132. }
  133. });
  134. root.find(".opt-check").on("click", function () {
  135. var $check = root.find("td.opt-check>i.checked");
  136. if ($check.length) {
  137. if ($check.length > 1) {
  138. util.alert("只能选择一个用户")
  139. } else {
  140. util.get("../ajax/userinfo/id/" + $check.attr("userId"), null, function (data) {
  141. if (data) {
  142. if (data.state == "1" || data.state == "4") {
  143. util.boxMsg({
  144. title: "提交审核",
  145. content: "请确认提交审核,提交审核后不可修改!",
  146. btns: [{
  147. caption: "确认提交", hand: function () {
  148. util.post("../ajax/userinfo/updateState", {id: $check.attr("userId")}, function () {
  149. pdg.load()
  150. }, {});
  151. }
  152. }, {caption: "取消"}
  153. ]
  154. });
  155. } else {
  156. util.alert("只有未提交、审核失败的可以点击");
  157. }
  158. } else {
  159. util.alert("用户不存在了", function () {
  160. pdg.load();
  161. });
  162. }
  163. });
  164. }
  165. } else {
  166. util.alert("请选择一名专家");
  167. }
  168. });
  169. pdg.code.listen($.dict.doTransfer);
  170. pdg.load();
  171. },
  172. mainDestory: function () {
  173. },
  174. };
  175. });
  176. });