weeklyMeeting.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. var index;
  2. var startTime;
  3. var endTime;
  4. $(function(){
  5. })
  6. function queryList(){
  7. var diffWeek = $('#diffWeek').val();
  8. var watchType = $('#watchType').val();
  9. var urgent = $('#urgent').val();
  10. var importance = $('#importance').val();
  11. var executionStatus = $('#executionStatus').val();
  12. location='weeklyMeetingController.do?goAdd&diffWeek='+diffWeek+"&watchType="+watchType+"&urgent="+urgent+"&importance="+importance+"&executionStatus="+executionStatus;
  13. }
  14. function removeRow(){
  15. $("#add_table").find("input:checked").parent().parent().each(function(){
  16. var id = $(this).attr("id");
  17. var tr = $(this);
  18. if(!id) {
  19. tr.remove();
  20. resetTrNum('add_table');
  21. }else {
  22. $.post('weeklyMeetingController.do?deleteRecord', {"id" : id}, function (d) {
  23. if(d.code == 200){
  24. tr.remove();
  25. resetTrNum('add_table');
  26. }
  27. }, "json");
  28. }
  29. })
  30. }
  31. function addRow(){
  32. var tr = $("#add_template tr").clone();
  33. if($('#add_table tr').length != 0){
  34. $(tr).find('td:eq(2)').find('input:eq(1)').val($('#meetingTime0').val());
  35. }
  36. var tableBody = $("#add_table");
  37. tableBody.append(tr);
  38. resetTrNum('add_table');
  39. }
  40. //初始化下标
  41. function resetTrNum(tableId) {
  42. $tbody = $("#"+tableId+"");
  43. $tbody.find('>tr').each(function(i){
  44. $(':input, select,button,a', this).each(function(){
  45. var $this = $(this), name = $this.attr('name'),id=$this.attr('id'),onclick_str=$this.attr('onclick'), val = $this.val();
  46. if(name!=null){
  47. if (name.indexOf("#index#") >= 0){
  48. $this.attr("name",name.replace('#index#',i));
  49. }else{
  50. var s = name.indexOf("[");
  51. var e = name.indexOf("]");
  52. var new_name = name.substring(s+1,e);
  53. $this.attr("name",name.replace(new_name,i));
  54. }
  55. }
  56. if(id!=null){
  57. if (id.indexOf("#index#") >= 0){
  58. $this.attr("id",id.replace('#index#',i));
  59. }else{
  60. var s = id.indexOf("[");
  61. var e = id.indexOf("]");
  62. if(s>0&&e>0) {
  63. var new_id = id.substring(s + 1, e);
  64. $this.attr("id", id.replace(new_id, i));
  65. }else{
  66. var new_id = id.substring(id.length - 1);
  67. $this.attr("id", id.replace(new_id, i));
  68. }
  69. }
  70. }
  71. if(onclick_str!=null){
  72. if (onclick_str.indexOf("#index#") >= 0){
  73. $this.attr("onclick",onclick_str.replace(/#index#/g,i));
  74. }else{
  75. }
  76. }
  77. });
  78. $(this).find('div[name=\'xh\']').html(i+1);
  79. });
  80. }
  81. function btn_ok(){
  82. $("#btnsub").click();
  83. }
  84. function btn_issue(){
  85. var msg ='请确定是否要下发';
  86. layer.open({
  87. title:'确认信息',
  88. content:msg,
  89. icon:7,
  90. yes:function(index){
  91. var url ='weeklyMeetingController.do?issueTask';
  92. var weekNum = $('#weekNum').val();
  93. var data = {};
  94. data.weekNum = weekNum;
  95. $.post(url,data,function(){
  96. tip('下发成功');
  97. layer.close(index);
  98. location.reload();
  99. },'json');
  100. },
  101. btn:['确定','取消'],
  102. btn2:function(index){
  103. layer.close(index);
  104. }
  105. });
  106. }
  107. function openAllSelect(parameter1, parameter2) {
  108. if(parameter1 == 'propose'){
  109. index = parameter2.substring("proposeName".length);
  110. selectAllUser('选择提出人', proposeCallback);
  111. }else{
  112. index = parameter2.substring("implementationName".length);
  113. selectAllUser('选择落实人', implementationCallback, true);
  114. }
  115. }
  116. function proposeCallback(selectedRows){
  117. for(var i = 0; i < selectedRows.length; i++){
  118. $('#proposeId' + index).val(selectedRows[i].id);
  119. $('#proposeName' + index).val(selectedRows[i].realName);
  120. }
  121. }
  122. function implementationCallback(selectedRows){
  123. for(var i = 0; i < selectedRows.length; i++){
  124. if(i == 0){
  125. $('#implementationId' + index).val(selectedRows[i].id);
  126. $('#implementationName' + index).val(selectedRows[i].realName);
  127. }else{
  128. addRow();
  129. $('#meetingTime' + (parseInt(index) + i)).val($('#meetingTime' + index).val());
  130. $('#meetingContent' + (parseInt(index) + i)).val($('#meetingContent' + index).val());
  131. $('#urgent' + (parseInt(index) + i)).val($('#urgent' + index).val());
  132. $('#importance' + (parseInt(index) + i)).val($('#importance' + index).val());
  133. $('#proposeId' + (parseInt(index) + i)).val($('#proposeId' + index).val());
  134. $('#proposeName' + (parseInt(index) + i)).val($('#proposeName' + index).val());
  135. $('#implementationId' + (parseInt(index) + i)).val(selectedRows[i].id);
  136. $('#implementationName' + (parseInt(index) + i)).val(selectedRows[i].realName);
  137. $('#expectedCompletion' + (parseInt(index) + i)).val($('#expectedCompletion' + index).val());
  138. }
  139. }
  140. }
  141. function getNowTime() {
  142. var curr = new Date;
  143. var first = curr.getDate() - curr.getDay() + 1;
  144. var firstday = new Date(curr.setDate(first));
  145. startTime = xx(firstday);
  146. endTime = AddDays(firstday,6);
  147. $('#startTime').text(startTime);
  148. $('#endTime').text(endTime);
  149. }
  150. function goBefore(){
  151. $('#watchType').val('before');
  152. queryList();
  153. }
  154. function goNext(){
  155. $('#watchType').val('next');
  156. queryList();
  157. }
  158. function xx(rq) {
  159. return rq.getFullYear() + "-" + ((rq.getMonth() + 1) < 10 ? "0" : "") + (rq.getMonth() + 1) + "-" + (rq.getDate() < 10 ? "0" : "") + rq.getDate() ;
  160. }
  161. function AddDays(date,days){
  162. var nd = new Date(date);
  163. nd = nd.valueOf();
  164. nd = nd + days * 24 * 60 * 60 * 1000;
  165. nd = new Date(nd);
  166. var y = nd.getFullYear();
  167. var m = nd.getMonth()+1;
  168. var d = nd.getDate();
  169. if(m <= 9) m = "0"+m;
  170. if(d <= 9) d = "0"+d;
  171. var cdate = y+"-"+m+"-"+d;
  172. return cdate;
  173. }
  174. function stringTodate(str){
  175. return new Date(Date.parse(str.replace(/-/g, "/")));
  176. }