alert1.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. new Vue({
  2. el: '#main',
  3. data: {
  4. alertData1:'',//总人数
  5. alertData2:'',//新增人数
  6. alertData3:'',//门诊人次
  7. alertData4:'',//住院人次
  8. alertChart1:'',//左边第一块表格
  9. alertChart2:'',//右上第一块
  10. alertChart3:'',//右上第二块
  11. alertChart4:'',//右上第三块
  12. alertChart5:'',//右下
  13. bigData:'',//总数据
  14. alertType:0,
  15. alertTime:0,
  16. firstDay: "", //上月第一天
  17. lastDay: "", //上月最后一天
  18. firstMonth:'',
  19. lastMonth:'',
  20. code:[
  21. 'VIEW_13_0015',//总人数和新增人数
  22. 'VIEW_13_0016',//门诊和住院人次
  23. 'VIEW_13_0009',//区县分布
  24. 'VIEW_13_0011',//性别分布
  25. 'VIEW_13_0012',//疾病前五
  26. 'VIEW_13_0017',//就诊月趋势
  27. 'VIEW_13_0022',//就诊年趋势
  28. 'VIEW_13_0010',//年龄分布
  29. 'VIEW_13_0045',//季趋势
  30. ],
  31. qushiMonth:'',
  32. qushiYear:'',
  33. firstDayYear: "", //本年第一天
  34. lastDayYear: "", //本年最后一天
  35. halfYearStartDate: "", //近半年开始时间
  36. halfYearEndDate: "", //近半年结束时间
  37. yesterdayDate:"",//昨天
  38. type:0,
  39. thirdJiDate:"",//三个季度前
  40. qushiSeason:"",//季度趋势
  41. },
  42. mounted: function() {
  43. var vm = this;
  44. this.formatDate();
  45. updateFontSize();
  46. this.initData(this.type);
  47. var myDate = new Date();
  48. var maxMonth = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
  49. var maxYear = myDate.getFullYear();
  50. var max = maxYear.toString()+'-'+maxMonth.toString();
  51. console.log(vm.firstMonth,vm.lastMonth)
  52. var moren = vm.firstMonth+' 至 '+vm.lastMonth;
  53. layui.use('laydate', function(){
  54. var laydate = layui.laydate;
  55. //执行一个laydate实例
  56. laydate.render({
  57. elem: '#time', //指定元素,
  58. type:'month',
  59. range: '至', //或 range: '~' 来自定义分割字符
  60. theme: '#05273e',
  61. position: 'abolute',
  62. right:'200px',
  63. value: moren,
  64. max:max,
  65. btns: ['confirm'],
  66. done: function(value, date, endDate){
  67. console.log(value); //得到日期生成的值,如:2017-08-18
  68. console.log(date); //得到日期时间对象:{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
  69. console.log(endDate); //得结束的日期时间对象,开启范围选择(range: true)才会返回。对象成员同上。
  70. console.log(vm.firstDay);
  71. if(date.month < 10){
  72. vm.firstDay = date.year+'-0'+date.month+'-01';
  73. }else{
  74. vm.firstDay = date.year+'-'+date.month+'-01';
  75. }
  76. if(endDate.month < 10){
  77. vm.lastDay = endDate.year+'-0'+endDate.month+'-'+vm.getLastDay(endDate.year,endDate.month);
  78. }else{
  79. vm.lastDay = endDate.year+'-'+endDate.month+'-'+vm.getLastDay(endDate.year,endDate.month);
  80. }
  81. vm.halfYearStartDate = getLastHalfMonthArray(endDate.year+'-'+endDate.month)
  82. vm.halfYearEndDate = vm.lastDay;
  83. vm.thirdJiDate = getThirdJiDate(endDate.year,endDate.month)
  84. vm.initData(vm.type);
  85. vm.alertTime = 0;
  86. }
  87. // showBottom: false
  88. });
  89. });
  90. },
  91. methods: {
  92. initData:function(type){
  93. var vm = this;
  94. if(type == 0){
  95. event_type = '';//全部
  96. }else if(type == 1){
  97. event_type = 1;//住院
  98. }else if(type == 2){
  99. event_type = 0;//门诊
  100. }
  101. var linkageFilter1 = "quotaDate >= '" + vm.firstDay + "' and quotaDate <= '" + vm.lastDay + "';";
  102. var linkageFilter2 = "quotaDate >= '" + vm.thirdJiDate + "' and quotaDate <= '" + vm.lastDay + "';";
  103. var linkageFilter3 = "quotaDate >= '" + vm.halfYearStartDate + "' and quotaDate <= '" + vm.halfYearEndDate + "';";
  104. console.log(linkageFilter1)
  105. var code = this.code;
  106. var urlNumber = '/gov/report/getNoChartTemplateData';
  107. var urlChart = '/gov/report/getTemplateDataByViewCode';
  108. var reqUrl = [
  109. {url:urlNumber,reqType: 'get',data: {viewCodeStr:code[0]}},//总人数
  110. {url:urlNumber,reqType: 'get',data: {viewCodeStr:code[0],linkageFilter:linkageFilter1}},//新增人数
  111. {url:urlNumber,reqType: 'get',data: {viewCodeStr:code[1],linkageFilter:linkageFilter1}},//门诊,住院人次
  112. {url:urlChart,reqType: 'get',data: {viewCode:code[2],linkageFilter:linkageFilter1+'eventType='+event_type}},//区县分布
  113. {url:urlChart,reqType: 'get',data: {viewCode:code[3],linkageFilter:linkageFilter1+'eventType='+event_type}},//性别分布
  114. {url:urlChart,reqType: 'get',data: {viewCode:code[4],linkageFilter:linkageFilter1+'eventType='+event_type,'limitCondition':5}},//疾病前五
  115. {url:urlChart,reqType: 'get',data: {viewCode:code[5],linkageFilter:linkageFilter3+'eventType='+event_type}},//老年人就诊趋势-月
  116. {url:urlChart,reqType: 'get',data: {viewCode:code[6],linkageFilter:'eventType='+event_type}},//老年人就诊趋势-年
  117. {url:urlChart,reqType: 'get',data: {viewCode:code[7],linkageFilter:linkageFilter1+'eventType='+event_type}},//年龄分布
  118. {url:urlChart,reqType: 'get',data: {viewCode:code[8],linkageFilter:linkageFilter2+'eventType='+event_type}},//老年人就诊趋势-季
  119. ]
  120. $(".div-mask-layer").show();
  121. httpRequest.getReqPromises(reqUrl).then(function(datas) {
  122. console.log(datas);
  123. vm.alertData1 = datas[0].obj.VIEW_13_0015[0].HC_13_0021;
  124. vm.alertData2 = datas[1].obj.VIEW_13_0015[0].HC_13_0021;
  125. vm.alertData3 = datas[2].obj.VIEW_13_0016[0].HC_13_0015;
  126. vm.alertData4 = datas[2].obj.VIEW_13_0016[0].HC_13_0016;
  127. var chart1 = datas[3].obj.viewInfos[0].options[0].option;
  128. var chart2 = datas[4].obj.viewInfos[0].options[0].option;
  129. var chart3 = datas[5].obj.viewInfos[0].options[0].option;
  130. var chart4 = datas[6].obj.viewInfos[0].options[0].option;
  131. var chart5 = datas[7].obj.viewInfos[0].options[0].option;
  132. var chart6 = datas[8].obj.viewInfos[0].options[0].option;
  133. var chart7 = datas[9].obj.viewInfos[0].options[0].option;
  134. vm.qushiMonth = chart4;
  135. vm.qushiYear = chart5;
  136. vm.qushiSeason = chart7;
  137. vm.setAlertChart1(chart1);
  138. vm.setAlertChart2(chart6);
  139. vm.setAlertChart3(chart2);
  140. vm.setAlertChart4(chart3);
  141. vm.setAlertChart5(chart4);
  142. $(".div-mask-layer").hide();
  143. })
  144. },
  145. setAlertChart1:function(data){
  146. var options = JSON.parse(data);
  147. options = quxianChart(options);
  148. // var options = this.bigData[t]['区县分布'];
  149. // options.series[0].label = {show: true,position: "right",color: '#b5e1fc'}
  150. this.alertChart1 = options;
  151. },
  152. setAlertChart2:function(data){
  153. var options = JSON.parse(data);
  154. options = nianlingChart(options);
  155. options.color = ["#6576e0","#03fa6c","#ff616f","#0fa5f2","#00e6f3"];
  156. options.legend.formatter = function(name) {
  157. var index = 0;
  158. var clientlabels = options.legend.data;
  159. var clientcounts = _.map(options.series[0].data,function(item,idx){
  160. return item.value;
  161. });
  162. clientlabels.forEach(function(value,i){
  163. if(value == name){
  164. index = i;
  165. }
  166. });
  167. return name + " " + clientcounts[index];
  168. }
  169. options.legend.left = '58%';
  170. options.legend.top = 0.044 * window.screen.width;//85;
  171. options.legend.itemWidth = 0.005 * window.screen.width;//10;
  172. options.legend.itemHeight = 0.005 * window.screen.width;//10;
  173. options.legend.itemGap = 0.0078 * window.screen.width;//15;
  174. options.series[0].center = ['35%','55%'];
  175. console.log(options)
  176. this.alertChart2 = options
  177. },
  178. setAlertChart3:function(data){
  179. var options = JSON.parse(data);
  180. options = xingbieChart(options);
  181. options.color = ["#00E7F3","#ff616f"];
  182. options.legend.formatter = function(name) {
  183. var index = 0;
  184. var clientlabels = options.legend.data;
  185. var clientcounts = _.map(options.series[0].data,function(item,idx){
  186. return item.value;
  187. });
  188. clientlabels.forEach(function(value,i){
  189. if(value == name){
  190. index = i;
  191. }
  192. });
  193. return name + " " + clientcounts[index];
  194. }
  195. options.legend.left = '58%';
  196. options.legend.top = 0.0625 * window.screen.width;//120
  197. options.legend.itemWidth = 0.005 * window.screen.width;//10;
  198. options.legend.itemHeight = 0.005 * window.screen.width;//10;
  199. options.legend.itemGap = 0.0078 * window.screen.width;//15;
  200. options.series[0].center = ['35%','55%'];
  201. this.alertChart3 = options
  202. },
  203. setAlertChart4:function(data){
  204. var options = JSON.parse(data);
  205. options = jibingTopChart(options);
  206. options.series[0].label = {show: true,position: "right",color: '#b5e1fc'};
  207. options.series[0].itemStyle.normal.color = '#FFF71A';
  208. this.alertChart4 = options
  209. },
  210. setAlertChart5:function(data){
  211. var options = JSON.parse(data);
  212. console.log(options)
  213. options = qushiChart(options);
  214. // var options = this.bigData[t]['区县分布'];
  215. // options.series[0].label = {show: true,position: "right",color: '#b5e1fc'}
  216. this.alertChart5 = options;
  217. },
  218. alertTitle:function(type){
  219. this.alertTime = 0;
  220. this.type = type;
  221. this.initData(type)
  222. },
  223. alertChart:function(time){
  224. var vm = this;
  225. this.alertTime = time;
  226. if(time == 0){
  227. vm.setAlertChart5(vm.qushiMonth);
  228. }else if(time == 1){
  229. vm.setAlertChart5(vm.qushiYear);
  230. }else if(time == 2){
  231. vm.setAlertChart5(vm.qushiSeason);
  232. }
  233. },
  234. closeAlertClick:function(){
  235. parent.layer.closeAll();
  236. },
  237. GetQueryString :function (name){
  238. var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  239. var r = window.location.search.substr(1).match(reg);
  240. if(r!=null)return unescape(r[2]); return null;
  241. },
  242. chartArea:function(param){
  243. console.log(param);
  244. },
  245. clickBarItem:function(item){
  246. console.log(item)
  247. },
  248. formatDate: function() {
  249. //获取上个月第一天
  250. var firstdate = new Date(new Date().getFullYear(), new Date().getMonth() - 1, 1);
  251. //获取上个月最后一天
  252. var date = new Date();
  253. var day = new Date(date.getFullYear(), date.getMonth(), 0).getDate();
  254. var enddate = new Date(new Date().getFullYear(), new Date().getMonth() - 1, day);
  255. //格式化结果
  256. var year = date.getFullYear();
  257. debugger
  258. this.thirdJiDate = getThirdJiDate(year,lastMonth+1);
  259. this.firstDay = getLastMonthStartDate();
  260. this.firstMonth = firstdate.format("yyyy-MM");
  261. this.lastDay = getLastMonthEndDate();
  262. this.lastMonth = enddate.format("yyyy-MM");
  263. this.firstDayYear = getYearStartDate();
  264. this.lastDayYear = getYearEndDate();
  265. this.halfYearStartDate = getHalfYearStartDate();
  266. this.halfYearEndDate = getHalfYearEndDate();
  267. this.yesterdayDate = getYearEndDate();
  268. },
  269. getLastDay(year, month) {
  270. var new_year = year; //取当前的年份
  271. var new_month = month++; //取下一个月的第一天,方便计算(最后一天不固定)
  272. if (month > 12) {
  273. //如果当前大于12月,则年份转到下一年
  274. new_month -= 12; //月份减
  275. new_year++; //年份增
  276. }
  277. var new_date = new Date(new_year, new_month, 1); //取当年当月中的第一天
  278. return new Date(new_date.getTime() - 1000 * 60 * 60 * 24).getDate(); //获取当月最后一天日期
  279. },
  280. }
  281. });
  282. //数字格式化
  283. function toThousands(str) {
  284. if(!str)return
  285. str =parseInt(str);
  286. if(typeof(str) == 'number')str = str.toString()
  287. var newStr = "";
  288. var count = 0;
  289. if(str.indexOf(".") == -1) {
  290. for(var i = str.length - 1; i >= 0; i--) {
  291. if(count % 3 == 0 && count != 0) {
  292. newStr = str.charAt(i) + "," + newStr;
  293. } else {
  294. newStr = str.charAt(i) + newStr;
  295. }
  296. count++;
  297. }
  298. str = newStr;
  299. } else {
  300. for(var i = str.indexOf(".") - 1; i >= 0; i--) {
  301. if(count % 3 == 0 && count != 0) {
  302. newStr = str.charAt(i) + "," + newStr;
  303. } else {
  304. newStr = str.charAt(i) + newStr; //逐个字符相接起来
  305. }
  306. count++;
  307. }
  308. str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
  309. }
  310. return str;
  311. }