Nenhuma Descrição

index.js 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /**
  2. * Created by TT on 2017/8/3.
  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_professornew_index");
  10. var pdg = pdgf.build(root);
  11. pdg.code.shell("showDay", function (env) {
  12. if (env.cd && env.cd[this.k]) {
  13. var day = env.cd[this.k];
  14. return day.substring(0, 4) + "年" + day.substring(4, 6) + "月" + day.substring(6, 8) + "日";
  15. }
  16. return "";
  17. });
  18. pdg.code.shell("bool", function (env) {
  19. var v = env.cd[this.k];
  20. return v === 1 ? "是" : (v === 0 ? "否" : "");
  21. });
  22. pdg.code.listen($.dict.doTransfer);
  23. pdg.code.listen(function () {
  24. root.find(".hand-fans").each(function () {
  25. var $e = $(this);
  26. var collectionid = $e.attr("id");
  27. util.get("/ajax/content/countProfessor", {id: collectionid, type: 1}, function (data) {
  28. $e.text(data);
  29. }, {});
  30. $e.removeClass("hand-fans");
  31. });
  32. });
  33. root.find(".opt-query").on("click", function () {
  34. pdg.load();
  35. });
  36. pdg.load();
  37. root.find(".dt-tpl").on("click", "th.opt-check>i.icon-st-check", function () {
  38. var $this = $(this);
  39. $this.toggleClass("checked");
  40. if ($this.hasClass("checked")) {
  41. root.find(".dt-tpl td.opt-check>i.icon-st-check").addClass("checked");
  42. } else {
  43. root.find(".dt-tpl td.opt-check>i.icon-st-check").removeClass("checked");
  44. }
  45. });
  46. root.find(".dt-tpl").on("click", "td.opt-check>i.icon-st-check", function () {
  47. var $this = $(this);
  48. $this.toggleClass("checked");
  49. });
  50. root.find(".opt-new").on("click", function () {
  51. spa.showModal("sys_professornew_new", function () {
  52. pdg.load()
  53. });
  54. });
  55. root.find(".opt-edit").on("click", function () {
  56. var $org = root.find("td.opt-check>i.checked");
  57. if ($org.length) {
  58. if ($org.length > 1) {
  59. util.alert("只能选择一个用户");
  60. } else {
  61. util.get("../ajax/sys/professor/luserId/" + $org.attr("professorId"), null, function (data) {
  62. if (data) {
  63. spa.showModal("sys_professornew_edit", {
  64. data: data, name: $org.attr("na"), hand: function () {
  65. pdg.reload()
  66. }
  67. })
  68. } else {
  69. util.alert("用户不存在了", function () {
  70. pdg.load();
  71. });
  72. }
  73. }, {});
  74. }
  75. } else {
  76. util.alert("请选择一个用户");
  77. }
  78. });
  79. root.find(".opt-details").on("click", function () {
  80. var $professor = root.find("td.opt-check>i.checked");
  81. if ($professor.length) {
  82. if ($professor.length > 1) {
  83. util.alert("只能选择一个用户");
  84. } else {
  85. util.get("../ajax/sys/professor/detail/" + $professor.attr("professorId"), null, function (data) {
  86. if (data) {
  87. // if (data.activeStatus != "1") {
  88. spa.showModal("sys_professornew_details", {
  89. data: data, hand: function () {
  90. pdg.reload()
  91. }
  92. });
  93. // }else {
  94. // util.alert("只能修改未激活的用户");
  95. // }
  96. } else {
  97. util.alert("用户不存在了", function () {
  98. pdg.load();
  99. });
  100. }
  101. }, {});
  102. }
  103. } else {
  104. util.alert("请选择一个用户");
  105. }
  106. });
  107. root.find(".opt-data").on("click", function () {
  108. var $professor = root.find("td.opt-check>i.checked");
  109. if ($professor.length) {
  110. if ($professor.length > 1) {
  111. util.alert("只能选择一个用户");
  112. } else {
  113. util.get("../ajax/sys/professor/id/" + $professor.attr("professorid"), null, function (data) {
  114. if (data) {
  115. spa.showModal("sys_professornew_data", {
  116. data: data, hand: function () {
  117. pdg.load()
  118. }
  119. })
  120. } else {
  121. util.alert("用户不存在了", function () {
  122. pdg.load();
  123. });
  124. }
  125. }, {});
  126. }
  127. } else {
  128. util.alert("请选择一个用户");
  129. }
  130. });
  131. root.find(".opt-view").on("click", function () {
  132. var $professor = root.find("td.opt-check>i.checked");
  133. if ($professor.length) {
  134. if ($professor.length > 1) {
  135. util.alert("只能选择一个用户");
  136. } else {
  137. window.open('http://www.ekexiu.com/userInforShow.html?professorId=' + $professor.attr("professorid"));
  138. }
  139. } else {
  140. util.alert("请选择一个用户");
  141. }
  142. });
  143. }, mainDestory: function () {
  144. }
  145. };
  146. });
  147. });