説明なし

index.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /**
  2. * Created by TT on 2017/10/20.
  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_result_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) + "日 " + day.substring(8, 10) + ":" + day.substring(10, 12);
  15. }
  16. return "";
  17. });
  18. pdg.code.listen($.dict.doTransfer);
  19. pdg.code.listen(function(){
  20. root.find(".hand-resultId").each(function() {
  21. var $e = $(this);
  22. var resultId = $e.attr("resultId");
  23. if (resultId) {
  24. util.get("/ajax/resResult/queryResearcher", {id: resultId}, function (data) {
  25. $e.text(oString(data));
  26. }, {});
  27. $e.removeClass("hand-resultId");
  28. }
  29. });
  30. });
  31. function oString(data) {
  32. var arry = new Array();
  33. if (data) {
  34. for (var i = 0; i < data.length; i++) {
  35. arry.push(data[i].name);
  36. }
  37. }
  38. return arry.join(",");
  39. }
  40. root.find(".opt-query").on("click", function () {
  41. pdg.load();
  42. });
  43. pdg.load();
  44. root.find(".dt-tpl").on("click", "th.opt-check>i.icon-st-check", function () {
  45. var $this = $(this);
  46. $this.toggleClass("checked");
  47. if ($this.hasClass("checked")) {
  48. root.find(".dt-tpl td.opt-check>i.icon-st-check").addClass("checked");
  49. } else {
  50. root.find(".dt-tpl td.opt-check>i.icon-st-check").removeClass("checked");
  51. }
  52. });
  53. root.find(".dt-tpl").on("click", "td.opt-check>i.icon-st-check", function () {
  54. var $this = $(this);
  55. $this.toggleClass("checked");
  56. });
  57. root.find(".opt-new").on("click", function() {
  58. spa.showModal("sys_result_new", function () {
  59. pdg.load();
  60. });
  61. });
  62. root.find(".opt-edit").on("click", function() {
  63. var $resultId = root.find("td.opt-check>i.checked");
  64. if($resultId.length) {
  65. if($resultId.length > 1) {
  66. util.alert("只能选择一篇科研成果");
  67. } else {
  68. $.util.get("../ajax/resResult/id/"+$resultId.attr("resultId"),null,function(rd){
  69. if(rd){
  70. spa.showModal("sys_result_edit", {
  71. data: rd, hand: function () {
  72. pdg.reload()
  73. }
  74. })
  75. }else{
  76. util.alertMsg("科研成果不存在", function(){pdg.reload();});
  77. }
  78. },{});
  79. }
  80. } else {
  81. util.alert("请选择一篇科研成果");
  82. }
  83. });
  84. root.find(".opt-del").on("click", function() {
  85. var $resultId = root.find("td.opt-check>i.checked");
  86. if($resultId.length) {
  87. if($resultId.length > 1) {
  88. util.alert("只能选择一个科研成果");
  89. } else {
  90. util.boxMsg({
  91. title: "确认删除",
  92. content: "您是否要删除选中的科研成果?",
  93. btns: [{
  94. caption: "删除",
  95. hand: function () {
  96. util.post("../ajax/resResult/delete", {id: $resultId.attr("resultId")}, function () {
  97. pdg.reload()
  98. }, {});
  99. }
  100. },
  101. {caption: "取消"}
  102. ]
  103. });
  104. }
  105. } else {
  106. util.alert("请选择一个科研成果");
  107. }
  108. });
  109. }, mainDestory: function () {
  110. }
  111. };
  112. });
  113. });