No Description

index.js 9.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /**
  2. * Created by TT on 2017/8/9.
  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_resourceinfo_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-contacts").each(function () {
  21. var $e = $(this);
  22. var resourceId = $e.attr("resourceId");
  23. util.get("../ajax/resource/pro", {id: resourceId}, function (data) {
  24. var proName = [];
  25. data.forEach(function (item) {
  26. util.get("../ajax/sys/professor/getName/" + item.professorId, null, function (data) {
  27. // proName = proName + data;
  28. proName.push(data);
  29. $e.text(proName);
  30. })
  31. });
  32. });
  33. $e.removeClass("hand-contacts");
  34. });
  35. root.find(".hand-collectionid").each(function() {
  36. var $e = $(this);
  37. var collectionid = $e.attr("collectionid");
  38. util.get("/ajax/content/countProfessor",{id:collectionid,type:2},function(data){
  39. $e.text(data);
  40. },{});
  41. $e.removeClass("hand-collectionid");
  42. });
  43. root.find(".table-opt a.name").on("click",function () {
  44. var resourceId = $(this).parent().attr("resourceId");
  45. window.open('http://www.ekexiu.com/resourceShow.html?resourceId=' + resourceId);
  46. })
  47. });
  48. root.find(".opt-query").on("click", function () {
  49. pdg.load();
  50. });
  51. pdg.load();
  52. root.find(".dt-tpl").on("click", "th.opt-check>i.icon-st-check", function () {
  53. var $this = $(this);
  54. $this.toggleClass("checked");
  55. if ($this.hasClass("checked")) {
  56. root.find(".dt-tpl td.opt-check>i.icon-st-check").addClass("checked");
  57. } else {
  58. root.find(".dt-tpl td.opt-check>i.icon-st-check").removeClass("checked");
  59. }
  60. });
  61. root.find(".dt-tpl").on("click", "td.opt-check>i.icon-st-check", function () {
  62. var $this = $(this);
  63. $this.toggleClass("checked");
  64. });
  65. root.find(".opt-del").on("click", function() {
  66. var $resource = root.find("td.opt-check>i.checked");
  67. if ($resource.length) {
  68. var ret = [];
  69. $resource.each(function() {
  70. ret.push($(this).attr("resourceId"));
  71. });
  72. util.boxMsg({
  73. title: "确认删除",
  74. content: "您是否要删除选中的资源?",
  75. btns: [{
  76. caption: "删除",
  77. hand: function () {
  78. util.post("../ajax/resource/deleteResource", {resourceIds:ret}, function () {
  79. pdg.reload()
  80. }, {});
  81. }
  82. },
  83. {caption: "取消"}
  84. ]
  85. });
  86. } else {
  87. util.alert("请选择一个资源");
  88. }
  89. });
  90. root.find(".opt-sort-num").on("click", function() {
  91. var $resource = root.find("td.opt-check>i.checked");
  92. if($resource.length) {
  93. if($resource.length > 1) {
  94. util.alert("只能选择一个资源");
  95. } else {
  96. $.util.get("../ajax/resource/id/"+$resource.attr("resourceId"),null,function(rd){
  97. if(rd){
  98. spa.showModal("sys_resourceinfo_sort", { data:rd, hand: function() { pdg.reload() } })
  99. }else{
  100. util.alertMsg("资源不存在", function(){pdg.reload();});
  101. }
  102. },{});
  103. }
  104. } else {
  105. util.alert("请选择一个资源");
  106. }
  107. });
  108. root.find(".opt-subject").on("click", function() {
  109. var $resource = root.find("td.opt-check>i.checked");
  110. if($resource.length) {
  111. if($resource.length > 1) {
  112. util.alert("只能选择一个资源");
  113. } else {
  114. $.util.get("../ajax/resource/id/"+$resource.attr("resourceId"),null,function(rd){
  115. if(rd){
  116. spa.showModal("sys_resourceinfo_subject", { data:rd, hand: function() { pdg.reload() } })
  117. }else{
  118. util.alertMsg("资源不存在", function(){pdg.reload();});
  119. }
  120. },{});
  121. }
  122. } else {
  123. util.alert("请选择一个资源");
  124. }
  125. });
  126. root.find(".opt-view").on("click", function () {
  127. var $resource = root.find("td.opt-check>i.checked");
  128. if ($resource.length) {
  129. if ($resource.length > 1) {
  130. util.alert("只能选择一个资源");
  131. } else {
  132. window.open('http://www.ekexiu.com/resourceShow.html?resourceId=' + $resource.attr("resourceId"));
  133. }
  134. } else {
  135. util.alert("请选择一个资源");
  136. }
  137. });
  138. root.find(".opt-edit").on("click", function() {
  139. var $resource = root.find("td.opt-check>i.checked");
  140. if($resource.length) {
  141. if($resource.length > 1) {
  142. util.alert("只能选择一个资源");
  143. } else {
  144. // $.util.get("../ajax/article/id/"+$resource.attr("articleId"),null,function(rd){
  145. // if(rd){
  146. // window.open('http://www.ekexiu.com:81/html/model/resourceinfo/resourceIssue.html?resourceId=' + $resource.attr("resourceId"));
  147. window.open('http://'+window.location.host+'/html/model/sys/resourceinfo/resourceIssue.html?resourceId=' + $resource.attr("resourceId"));
  148. // }else{
  149. // util.alertMsg("文章不存在", function(){pdg.reload();});
  150. // }
  151. // },{});
  152. }
  153. } else {
  154. util.alert("请选择一个资源");
  155. }
  156. });
  157. root.find(".opt-contacts").on("click", function() {
  158. var $resource = root.find("td.opt-check>i.checked");
  159. if ($resource.length) {
  160. var ret = {ids:[],orgIds:[],category:[]};
  161. $resource.each(function() {
  162. ret.ids.push($(this).attr("resourceId"));
  163. ret.orgIds.push($(this).attr("owner"));
  164. ret.category.push($(this).attr("category"));
  165. });
  166. var nary=ret.orgIds.sort();
  167. var narc=ret.category;
  168. for(var j=0;j<ret.category.length;j++){
  169. if (narc[j]!="2"){
  170. util.alert("列表中有非企业发布的资源");
  171. return;
  172. }
  173. }
  174. if(ret.orgIds.length>1) {
  175. for (var i = 0; i < ret.orgIds.length-1; i++) {
  176. if (nary[i] != nary[i + 1]) {
  177. util.alert("列表中的企业不一致");
  178. return;
  179. }
  180. }
  181. }
  182. spa.showModal("sys_resourceinfo_contacts", {
  183. data: {orgId:ret.orgIds[0],ids:ret.ids}, hand: function () {
  184. pdg.reload()
  185. }
  186. });
  187. } else {
  188. util.alert("请选择一个资源");
  189. }
  190. });
  191. }, mainDestory: function () {
  192. }
  193. };
  194. });
  195. });