myd-wjsj.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. var session = null;
  2. var SubjectId = 0;
  3. $(function(){
  4. SubjectId = QueryString('SubjectId');
  5. if(isEmpty(SubjectId)){
  6. ComWbj.artTips("提示","warning","未知问卷ID",2,null);
  7. // ComWbj.alertIconNo('提示:','未知问卷ID','warning');
  8. history.go(-1);
  9. }
  10. init();
  11. });
  12. function QueryString(val) {
  13. var uri = window.location.search;
  14. var re = new RegExp("" +val+ "\=([^\&\?]*)", "ig");
  15. return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null);
  16. }
  17. //初始化
  18. function init(){
  19. getWJData();
  20. }
  21. function backToEdit(){//返回问卷编辑
  22. window.location.href = 'myd-wjbj.html?SubjectId='+SubjectId;
  23. }
  24. //获取问卷数据
  25. function getWJData(){
  26. var param = {};
  27. param.SubjectId = SubjectId;
  28. var _d = _ajax('../survey/wtbj_querySubjectById.action',param,false);
  29. initHtml(_d);
  30. }
  31. function initHtml(d){
  32. var type = 0;
  33. if(!isEmpty(d.Overtype) && d.Overtype != 0){
  34. type = d.Overtype;
  35. }else type = 3;
  36. $('input[name="endtime"]').each(function(i){
  37. $('#endTime'+(i+1)).val('');
  38. if((i+1) != 3){
  39. if(type == (i+1)){
  40. $(this).attr('checked','checked');
  41. $('#endTime'+(i+1)).removeAttr('disabled');
  42. }else{
  43. $(this).removeAttr('checked');
  44. $('#endTime'+(i+1)).attr('disabled','');
  45. }
  46. }else{
  47. $('#endTime'+type).attr('checked','checked');
  48. }
  49. });
  50. if(type == 1){
  51. $('#endTime'+type).val(d.Quantity);
  52. }else if(type == 2){
  53. $('#endTime'+type).val((d.Overtime.length>16?d.Overtime.substring(0,16):d.Overtime));
  54. }
  55. var Replytype = 0;
  56. if(!isEmpty(d.Replytype) && d.Replytype != 0){
  57. Replytype = d.Replytype;
  58. }else Replytype = 3;
  59. $('#Overtype').val(type);
  60. $('#Replytype').val(Replytype);
  61. /*
  62. $('input[name="replysetting"]').each(function(i){
  63. if(Replytype == (i+1)){
  64. $('#Replytype'+Replytype).attr('checked','checked');
  65. }else $('#Replytype'+(i+1)).removeAttr('checked');
  66. });
  67. */
  68. }
  69. function checkit(o,type){
  70. for(var i = 1 ;i<=3;i++){
  71. $('#endTime'+i).val('');
  72. $('#endTime'+i).attr('disabled','');
  73. }
  74. if(o.checked == true){
  75. $('#'+$(o).attr('key')).removeAttr('disabled');
  76. if($(o).attr('key') == 'endtime2'){
  77. }
  78. }
  79. $('#Overtype').val(type);
  80. $('#endTime3').removeAttr('disabled');
  81. }
  82. function checkit2(type){
  83. $('#Replytype').val(type);
  84. }
  85. function _submitWJ(){//发布
  86. var param = {};
  87. param.SubjectId = SubjectId;
  88. var type = $('#Overtype').val();
  89. param.Overtype = type;
  90. param.Replytype = $('#Replytype').val();
  91. if(type == 1){
  92. if(isEmpty($('#endTime'+type).val())){
  93. // ComWbj.alertIconNo('提示:','请填写具体数量','warning');
  94. ComWbj.artTips("提示","warning","收集数量请填写大于0的整数",1.5,null);
  95. return ;
  96. }else if($('#endTime'+type).val() == 0){
  97. // ComWbj.alertIconNo('提示:','请填写具体数量','warning');
  98. ComWbj.artTips("提示","warning","收集数量请填写大于0的整数",1.5,null);
  99. return ;
  100. }
  101. param.Quantity = $('#endTime'+type).val();
  102. }else if(type == 2){
  103. if(isEmpty($('#endTime'+type).val())){
  104. ComWbj.artTips("提示","warning","请填写截止日期",2,null);
  105. // ComWbj.alertIconNo('提示:','请填写截止日期','warning');
  106. return ;
  107. }
  108. param.OverTime = $('#endTime'+type).val();
  109. }
  110. var _d = _ajax('../survey/wtbj_updateSubjectForNet.action',param,false);
  111. if(parseInt(_d.Code) == 10000){
  112. art.dialog({
  113. id: 'testID',
  114. width: '245px',
  115. height: '109px',
  116. content: '你确定要发布该问卷吗?',
  117. lock: true,
  118. button: [{
  119. name: '确定',
  120. callback: function () {
  121. updateSubject(2);
  122. ComWbj.artTips("提示:","succeed","发布成功",2,null);
  123. setTimeout(function(){
  124. window.location.href = 'myd-wjfb.html?SubjectId='+SubjectId;
  125. },2000);
  126. }
  127. },{
  128. name: '取消',
  129. callback: function(){
  130. updateSubject(1);
  131. //ComWbj.artTips("提示:","succeed","操作成功",2,null);
  132. setTimeout(function(){
  133. window.location.href = 'myd-wjlb.html?SubjectId='+SubjectId;
  134. },2000);
  135. }
  136. }]
  137. });
  138. }else{
  139. ComWbj.artTips("提示","warning","操作异常",2,null);
  140. }
  141. }
  142. function updateSubject(val){//发布
  143. var param = {};
  144. param.SubjectId = SubjectId;
  145. param.Status = val;
  146. param.OperatorId="10011";
  147. param.OperatorName="admin";
  148. var _d = _ajax('../survey/wtbj_updateSubjectbegin.action',param,false);
  149. }
  150. function _ajax(url,param,flag){
  151. var obj = null;
  152. try{
  153. $.ajax({
  154. type: 'POST',
  155. url: url,
  156. data: param,
  157. async: flag,
  158. timeout : 8000,
  159. dataType: 'json',
  160. success: function(data){
  161. obj = data;
  162. }
  163. });
  164. }catch(err){
  165. ComWbj.artTips("提示","error",err,2,null);
  166. // ComWbj.alertIconNo('提示:',err,'error');
  167. }
  168. if(!flag) return obj;
  169. }
  170. function isEmpty(s){
  171. if(s == undefined){
  172. return true;
  173. }else{
  174. s = ComWbj.trimStr(s);
  175. if(s == null || s == '' ||
  176. s == 'null' || s.length < 1){
  177. return true;
  178. }
  179. }
  180. return false;
  181. }