mtmain.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /**
  2. *码头
  3. *
  4. */
  5. $.namespace("mt.main");
  6. mt.main.sfdwkfData=null;
  7. mt.main.sfdwkf=null;
  8. mt.main.sfwhpData=null;
  9. mt.main.sfwhp=null;
  10. mt.main.init=function(){
  11. //把form传入,构造翻页控件
  12. pageinfo($("#mtform"));
  13. };
  14. mt.main.search=function(){
  15. $('#pagejump').val(1);
  16. $("#mtform").submit();
  17. };
  18. mt.main.del=function(data){
  19. $.confirm({
  20. title: '确认框',
  21. content: '确认删除吗',
  22. confirm: function(){
  23. $.post($.app + "/mt/delete", {
  24. id : data
  25. }, function(data) {
  26. if (data.success) {
  27. $.alert({
  28. title: '提示',
  29. content: '操作成功',
  30. confirm: function(){
  31. $("#mtform").submit();
  32. }
  33. });
  34. } else {
  35. $.alert({
  36. title: '提示',
  37. content: data.message,
  38. confirm: function(){
  39. }
  40. });
  41. }
  42. }, "json");
  43. },
  44. cancel: function(){
  45. }
  46. });
  47. }
  48. mt.main.edit=function(data){
  49. location.href=$.app+"/mt/edit?id="+data;
  50. }
  51. mt.main.view=function(data){
  52. location.href=$.app+"/mt/view?id="+data;
  53. }
  54. /**
  55. * 弹出新增页面
  56. * */
  57. mt.main.add=function(){
  58. location.href=$.app+"/mt/add";
  59. }
  60. mt.main.initSfdwkfSel=function(existVal){
  61. $.post($.app + "/selectSf", {
  62. }, function(data) {
  63. var str = "";
  64. str+="<select class='selectpicker' name='sfdwkfid' id='sfdwkfid' >";
  65. str+="<option></option>";
  66. if(data){
  67. for(var i=0;i<data.length;i++){
  68. var sf = data[i];
  69. if(sf.id==existVal){
  70. str+=" <option selected='selected' value='"+sf.id+"' >"+sf.text+"</option>";
  71. }else{
  72. str+=" <option value='"+sf.id+"' >"+sf.text+"</option>";
  73. }
  74. }
  75. }
  76. str+="</select>";
  77. $("#sfdwkfDiv").empty();
  78. $("#sfdwkfDiv").append(str);
  79. $('.selectpicker').selectpicker({
  80. width:'80%'
  81. });
  82. }, "json");
  83. };
  84. mt.main.initSfwhpSel=function(existVal){
  85. $.post($.app + "/selectSf", {
  86. }, function(data) {
  87. var str = "";
  88. str+="<select class='selectpicker' name='sfwhpid' id='sfwhpid' >";
  89. str+="<option></option>";
  90. if(data){
  91. for(var i=0;i<data.length;i++){
  92. var sf = data[i];
  93. if(sf.id==existVal){
  94. str+=" <option selected='selected' value='"+sf.id+"' >"+sf.text+"</option>";
  95. }else{
  96. str+=" <option value='"+sf.id+"' >"+sf.text+"</option>";
  97. }
  98. }
  99. }
  100. str+="</select>";
  101. $("#sfwhpDiv").empty();
  102. $("#sfwhpDiv").append(str);
  103. $('.selectpicker').selectpicker({
  104. width:'80%'
  105. });
  106. }, "json");
  107. }
  108. mt.main.initFwlx=function(divid, existVal){
  109. $.post($.app + "/bw/selectFwlx", {
  110. }, function(data) {
  111. if (data) {
  112. var str = "";
  113. str+="<select class='fwlxselectpicker' name='fwlxid' >";
  114. str+="<option></option>";
  115. for(var i=0;i<data.length;i++){
  116. var fwlx = data[i];
  117. if(fwlx.id==existVal){
  118. str+=" <option selected='selected' value='"+fwlx.id+"' >"+fwlx.text+"</option>";
  119. }else{
  120. str+=" <option value='"+fwlx.id+"' >"+fwlx.text+"</option>";
  121. }
  122. }
  123. str+="</select>";
  124. $("#"+divid).empty();
  125. $("#"+divid).append(str);
  126. $('.fwlxselectpicker').selectpicker({
  127. width:'80%'
  128. });
  129. } else {
  130. }
  131. }, "json");
  132. };
  133. mt.main.initMtyt=function(divid, existVal){
  134. $.post($.app + "/bw/selectMtyt", {
  135. }, function(data) {
  136. var str = "";
  137. str+="<select multiple='multiple' class='mtytselectpicker' name='mtyt' id='mtytid'>";
  138. str+="<option></option>";
  139. if (data) {
  140. var existValArr = new Array;
  141. if(existVal!=null){
  142. existValArr=existVal.split(";");
  143. }
  144. for(var i=0;i<data.length;i++){
  145. var flag = false;
  146. var mtyt= data[i];
  147. for(var j = 0; j < existValArr.length; j++){
  148. if(mtyt.id==existValArr[j]){
  149. flag = true;
  150. str+=" <option selected='selected' value='"+mtyt.id+"' >"+mtyt.text+"</option>";
  151. break;
  152. } else {
  153. flag = false;
  154. }
  155. }
  156. if(!flag){
  157. str+=" <option value='"+mtyt.id+"' >"+mtyt.text+"</option>";
  158. }
  159. }
  160. }
  161. str+="</select>";
  162. $("#"+divid).empty();
  163. $("#"+divid).append(str);
  164. $('.mtytselectpicker').selectpicker({
  165. width: '80%'
  166. });
  167. }, "json");
  168. };