8134fbd0014788d876aa09f71909f0c74ed9240b.svn-base 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. var fb_sTime = $("#beginTime").val();//发布时间 start
  2. var fb_eTime = $("#endTime").val(); //发布时间 end
  3. var zt = $("#tzdzt").attr("relvalue");//状态
  4. var fbTime = $("#fbTime").val(); //发布时间
  5. var eventType = $("#eventType").attr("relvalue"); //突发事件类型
  6. var eventName = $("#eventType").attr("reltext"); //突发事件类型名称
  7. var compId = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  8. //数据表格使用
  9. var g1 =null;
  10. var g2 =null;
  11. var g3 =null;
  12. var columns = [ {
  13. display : '发布单位',
  14. name : 'unitName',
  15. width : '20%',
  16. id:"dept",
  17. align : 'left',
  18. render: addStatus
  19. },
  20. {
  21. display : '预警发布情况',
  22. name : 'ztplan',
  23. align : 'center',
  24. columns : [
  25. {
  26. display : '红色',
  27. name : 'YJ_H1',
  28. width : '6%',
  29. align : 'center'
  30. },{
  31. display : '橙色',
  32. name : 'YJ_C',
  33. width : '6%',
  34. align : 'center'
  35. },{
  36. display : '黄色',
  37. name : 'YJ_H2',
  38. width : '6%',
  39. align : 'center'
  40. },{
  41. display : '蓝色',
  42. name : 'YJ_L',
  43. width : '6%',
  44. align : 'center'
  45. },{
  46. display : '合计',
  47. name : 'YJ_HJ',
  48. width : '6%',
  49. align : 'center'
  50. }
  51. ]
  52. }, {
  53. display : '响应启动情况',
  54. align : 'center',
  55. columns : [
  56. {
  57. display : 'Ⅰ级',
  58. name : 'XY_I',
  59. width : '6%',
  60. align : 'center'
  61. },{
  62. display : 'Ⅱ级',
  63. name : 'XY_II',
  64. width : '6%',
  65. align : 'center'
  66. },{
  67. display : 'Ⅲ级',
  68. name : 'XY_III',
  69. width : '6%',
  70. align : 'center'
  71. },{
  72. display : 'Ⅳ级',
  73. name : 'XY_IV',
  74. width : '6%',
  75. align : 'center'
  76. },{
  77. display : '合计',
  78. name : 'XY_HJ',
  79. width : '6%',
  80. align : 'center'
  81. }
  82. ]
  83. }, {
  84. display : '总计',
  85. name : 'HJ',
  86. width : '10%',
  87. align : 'center',
  88. }];
  89. $(function(){
  90. //初始化表格
  91. // _initGrid(g1);
  92. //加载数据
  93. // getCount1();
  94. //tab页签绑定点击事件,切换不同的统计视角
  95. $("#tabHuiBtnCon").live("actived",function(e,index){
  96. if(index==0){
  97. getCount1();
  98. }else if(index==1){
  99. getCount2();
  100. }else if(index==2){
  101. getCount3();
  102. }
  103. });
  104. //绑定筛选单选框点击事件
  105. $(".radioDiv input:radio").live("change",function(){
  106. var name = $(this).parent().find("input").attr("name");
  107. if(name=="xxsj2"){
  108. getCount2();
  109. }else if(name=="xxsj3"){
  110. getCount3();
  111. }
  112. });
  113. //点击查询事件
  114. $("#searchBtn").on("click",function(){
  115. var index = $("#tabHuiBtnCon").attr("selectedIdx");
  116. if(index==0){
  117. getCount1();
  118. }else if(index==1){
  119. getCount2();
  120. }else if(index==2){
  121. getCount3();
  122. }
  123. });
  124. //根据单位层级创建tab页签
  125. renderTabCon();
  126. });
  127. $(window).load(function(){
  128. getCount1();
  129. });
  130. /**
  131. * 初始化表格
  132. */
  133. function _initGrid(index,options,id){
  134. var g = null;
  135. if(index==1){
  136. g = g1 = $("#"+id).quiGrid(options);
  137. }else if(index==2){
  138. g = g2 = $("#"+id).quiGrid(options);
  139. }else if(index==3){
  140. g = g3 = $("#"+id).quiGrid(options);
  141. }
  142. return g;
  143. }
  144. function addStatus(rowdata, rowindex, value, column){
  145. var comp_id='"'+rowdata.unitId+'"';
  146. var name = '"'+value+'"';
  147. if("总计"==rowdata.unitName){
  148. return value;
  149. }else{
  150. // return "<a href='javascript:newHtml("+comp_id+","+name+")'>" + value +" </a>";
  151. return "<div class='pading_left15'>" + value +" </div>";
  152. }
  153. }
  154. function newHtml(comp_id,name){
  155. if(name=="总计"){
  156. return;
  157. }else if(unitId==comp_id){
  158. return;
  159. }else{
  160. // window.open("/nwyj/page/business/am/contingencyPlan/ContingencyPlanHuiZong1.jsp?"+comp_id);
  161. $.indexOpenNextWindow("/nwyj/page/business/em/alert/warning/WarningHuiZong.jsp?unitId="+comp_id);
  162. }
  163. }
  164. function getCount1(){
  165. var url = "/nwyj/ws/alertToImpl_queryEquip/AlertToImplService_queryEquip/getNoticeNum1";
  166. var col1 = $.extend(true, [], columns);
  167. col1.splice(1,0,{
  168. display : '单位数量',
  169. name : 'unitNum',
  170. width : '6%',
  171. align : 'center'
  172. });
  173. var options = {
  174. columns : col1,
  175. data:{rows:[]},
  176. height: '260px',
  177. rownumbers : false,
  178. usePager : false
  179. };
  180. getCount(url ,col1,1,options,"maingrid1");
  181. }
  182. function getCount2(){
  183. var url = "/nwyj/ws/alertToImpl_queryEquip/AlertToImplService_queryEquip/getNoticeNum2";
  184. var col1 = $.extend(true, [], columns);
  185. col1[3].width = "16%";
  186. var options = {
  187. columns : col1,
  188. data:{rows:[]},
  189. height: '500px',
  190. rownumbers : false,
  191. usePager : false
  192. };
  193. var value = $("input:radio[name=xxsj2]").filter("[checked]").val();
  194. getCount(url ,columns,2,options,"maingrid2",value);
  195. }
  196. function getCount3(){
  197. var url = "/nwyj/ws/alertToImpl_queryEquip/AlertToImplService_queryEquip/getNoticeNum3";
  198. var col1 = $.extend(true, [], columns);
  199. col1[3].width = "16%";
  200. // col1[0].id = "unitName";
  201. var value = $("input:radio[name=xxsj3]").filter("[checked]").val();
  202. var options = {
  203. columns : col1,
  204. data:{rows:[]},
  205. height: '500px',
  206. rownumbers : false,
  207. usePager : false,
  208. autoCheckChildren : true,
  209. tree : { columnId : 'dept'},
  210. treeAjax : true,
  211. treeChildDataPath : "/nwyj/ws/alertToImpl_queryEquip/AlertToImplService_queryEquip/getNoticeNum2?fb_sTime="+fb_sTime+"&fb_eTime="+fb_eTime+"&tongjiType="+zt+"&eventType="+eventType+"&issueTime="+fbTime+"&value="+value+"&async=1"+"&thisUnit=",
  212. treeAutoParam : "id"
  213. };
  214. getCount(url ,col1,3,options,"maingrid3",value);
  215. }
  216. /**
  217. * 统计
  218. */
  219. function getCount(url ,col,index,options,id,value){
  220. fb_sTime = $("#beginTime").val();//发布时间 start
  221. fb_eTime = $("#endTime").val(); //发布时间 end
  222. zt = $("#tzdzt").attr("relvalue");//状态
  223. fbTime = $("#fbTime").val(); //发布时间
  224. eventType = $("#eventType").attr("relvalue"); //突发事件类型
  225. eventName = $("#eventType").attr("reltext"); //突发事件类型名称
  226. if(zt==1){
  227. if(fbTime==""){
  228. top.Dialog.alert("请选择时间!");
  229. return ;
  230. }
  231. $(".GridtitleStyle").empty();
  232. $(".GridtitleStyle").append("<div class='conStyle'>统计范围: <div>"+getNowTimeForTimeStr(fbTime,1)+",因“"+eventName+"”类突发事件仍处于预警状态或响应状态的情况。</div></div>");
  233. }else{
  234. if(fb_sTime=="" || fb_eTime==""){
  235. top.Dialog.alert("请选择时间!");
  236. return ;
  237. }
  238. $(".GridtitleStyle").empty();
  239. $(".GridtitleStyle").append("<div class='conStyle'>统计范围: <div>"+getTimeArea(fb_sTime,fb_eTime)+",因“"+eventName+"”类突发事件发布预警或启动响应的情况。</div></div>");
  240. }
  241. var params = {
  242. fb_sTime:fb_sTime,
  243. fb_eTime:fb_eTime,
  244. tongjiType:zt,
  245. thisUnit:unitId,
  246. eventType:eventType,
  247. issueTime:fbTime,
  248. value:value,//用于判断是筛选全量单位的数据还是只看有数据的
  249. comp_id:compId
  250. };
  251. $("body").eq(0).showLoading();
  252. $.ajax({
  253. url :url,
  254. type : 'post',
  255. data : params,
  256. dataType : 'json',
  257. success : function(data){
  258. $("body").eq(0).hideLoading();
  259. var g = null;
  260. if(index==1){
  261. g = g1;
  262. }else if(index==2){
  263. g = g2;
  264. }else if(index==3){
  265. g = g3;
  266. }
  267. if(!g){
  268. g = _initGrid(index, options,id);
  269. }
  270. g.setOptions({data:data,columns:col,treeChildDataPath:"/nwyj/ws/alertToImpl_queryEquip/AlertToImplService_queryEquip/getNoticeNum2?fb_sTime="+fb_sTime+"&fb_eTime="+fb_eTime+"&tongjiType="+zt+"&eventType="+eventType+"&value="+value+"&issueTime="+fbTime+"&async=1"+"&thisUnit="});
  271. g.loadData();
  272. setHight();
  273. $("body").eq(0).hideLoading();
  274. },
  275. error : function(e){
  276. $("body").eq(0).hideLoading();
  277. top.Dialog.alert("查询失败!");
  278. }
  279. });
  280. }
  281. //重置
  282. function resetSearch(){
  283. document.location.reload();
  284. }
  285. function export_report() {
  286. var sql = {
  287. "report_type" : "yuanhz",
  288. "json" : JSON.stringify(g.getData())
  289. };
  290. excelExport("", sql, "预警/响应统计", "", "预警/响应统计", 'zjdaochu');
  291. }
  292. /**
  293. * 通过日期时间字符串获取下一秒时间
  294. * 返回字符串
  295. * @param timeStr
  296. */
  297. function getNowTimeForTimeStr(timeStr,index){
  298. var re = "yyyy年MM月dd日";
  299. if(index==1){
  300. re += "hh时mm分";
  301. }
  302. timeStr = timeStr.stringToDate();
  303. var newDate = Date.parse(timeStr);
  304. var result = getFormatDateByLong(newDate,re);
  305. return result;
  306. }
  307. //扩展Date的format方法
  308. Date.prototype.format = function (format) {
  309. var o = {
  310. "M+": this.getMonth() + 1,
  311. "d+": this.getDate(),
  312. "h+": this.getHours(),
  313. "m+": this.getMinutes(),
  314. "s+": this.getSeconds(),
  315. "q+": Math.floor((this.getMonth() + 3) / 3),
  316. "S": this.getMilliseconds()
  317. };
  318. if (/(y+)/.test(format)) {
  319. format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  320. }
  321. for (var k in o) {
  322. if (new RegExp("(" + k + ")").test(format)) {
  323. format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
  324. }
  325. }
  326. return format;
  327. };
  328. /**
  329. *转换long值为日期字符串
  330. * @param l long值
  331. * @param pattern 格式字符串,例如:yyyy-MM-dd hh:mm:ss
  332. * @return 符合要求的日期字符串
  333. */
  334. function getFormatDateByLong(l, pattern) {
  335. return getFormatDate(new Date(l), pattern);
  336. }
  337. /**
  338. *转换日期对象为日期字符串
  339. * @param l long值
  340. * @param pattern 格式字符串,例如:yyyy-MM-dd hh:mm:ss
  341. * @return 符合要求的日期字符串
  342. */
  343. function getFormatDate(date, pattern) {
  344. if (date == undefined) {
  345. date = new Date();
  346. }
  347. if (pattern == undefined) {
  348. pattern = "yyyy-MM-dd hh:mm:ss";
  349. }
  350. return date.format(pattern);
  351. }
  352. /**
  353. * 判断两个日期的重复部分,返回简洁的显示形式
  354. * 如:2017-06-01,2017-06-17
  355. * 结果:2017年6月1日~17日
  356. * @param time1
  357. * @param time2
  358. */
  359. function getTimeArea(time1,time2){
  360. var yearFlag = false;
  361. var monthFlag = false;
  362. var dayFlag = false;
  363. var time2Arr = time2.split("-");
  364. if(time1.indexOf(time2Arr[0])>-1){//如果年份相同
  365. yearFlag = true;
  366. if(time1.indexOf(time2Arr[0]+"-"+time2Arr[1])>-1){//在年份相同的基础上,月份相同
  367. monthFlag = true;
  368. if(time1.indexOf(time2Arr[0]+"-"+time2Arr[1]+"-"+time2Arr[2])>-1){//同一天
  369. dayFlag = true;
  370. }
  371. }
  372. }
  373. time1 = getNowTimeForTimeStr(time1,2);
  374. if(dayFlag){
  375. return time1;
  376. }
  377. if(yearFlag){
  378. if(monthFlag){
  379. time2 = time2Arr[2]+"日";
  380. }else{
  381. time2 = time2Arr[1]+"月"+time2Arr[2]+"日";
  382. }
  383. }else{
  384. time2 = getNowTimeForTimeStr(time2,2);
  385. }
  386. return time1+"~"+time2;
  387. }
  388. function renderTabCon(){
  389. var url = "/nwyj/ws/alertToImpl_queryEquip/AlertToImplService_queryEquip/getDeptLevel";
  390. $.ajax({
  391. url :url,
  392. type : 'post',
  393. data : {thisUnit:unitId},
  394. dataType : 'text',
  395. success : function(data){
  396. var con = $("#tabHuiBtnCon");
  397. var str = "";
  398. var beizhu1 = "";
  399. if(data==1){
  400. beizhu1 = "按网、省、地、县四个维度统计。";
  401. }else if(data==2){
  402. beizhu1 = "按省、地、县三个维度统计。";
  403. }else if(data==3){
  404. beizhu1 = "按地、县两个维度统计。";
  405. }
  406. str+="<div name='各层级情况' >";
  407. str+="<div>"+beizhu1+"</div>";
  408. str+="<div style='margin:0px 20px 10px 20px;'>";
  409. str+="<div id='maingrid1'></div>";
  410. str+="</div>";
  411. str+="</div>";
  412. if(data<=3){//网省地
  413. str+="<div name='直属下级' >";
  414. str+="<div class='radioDiv'>";
  415. str+="<input type='radio' name='xxsj2' id='allUnit' value='1' checked='checked' class='radioBtn' /><label for='allUnit' class='radioBtn'>显示所有单位</label>";
  416. str+="<input type='radio' name='xxsj2' value='2' id='hasData' class='radioBtn'/ ><label for='hasData' class='radioBtn' >仅显示有数据单位</label>";
  417. str+="</div>";
  418. str+="<div>表中的数据均为该单位本部的数据。</div>";
  419. str+="<div style='margin:0px 20px 10px 20px;'>";
  420. str+="<div id='maingrid2'></div>";
  421. str+="</div>";
  422. str+="</div>";
  423. }
  424. if(data<=2){//网省
  425. str+="<div name='所属各级单位' >";
  426. str+="<div class='radioDiv'>";
  427. str+="<input type='radio' name='xxsj3' id='allUnit3' value='1' checked='checked' class='radioBtn'/><label for='allUnit3' class='radioBtn'>显示所有单位</label>";
  428. str+="<input type='radio' name='xxsj3' id='hasData3' value='2' class='radioBtn'/><label for='hasData3' class='radioBtn'>仅显示有数据单位</label>";
  429. str+="</div>";
  430. str+="<div>单位名称前有“+”或“-”的,代表该行的数据为该单位本部及所属下级单位的合计。</div>";
  431. str+="<div style='margin:0px 20px 10px 20px;'>";
  432. str+="<div id='maingrid3'></div>";
  433. str+="</div>";
  434. str+="</div>";
  435. }
  436. con.append(str);
  437. con.render();
  438. },
  439. error:function(e){
  440. }});
  441. }
  442. $.messager=top.Dialog;