alert2.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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_0026',//总人数和新增人数
  22. 'VIEW_13_0033',//门诊和住院人次
  23. 'VIEW_13_0030',//区县分布
  24. 'VIEW_13_0032',//性别分布
  25. 'VIEW_13_0035',//疾病前五
  26. 'VIEW_13_0028',//就诊月趋势
  27. 'VIEW_13_0029',//就诊年趋势
  28. 'VIEW_13_0031',//年龄分布
  29. 'VIEW_13_0046',//就诊季趋势
  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. updateFontSize();
  45. this.formatDate();
  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_0026[0].HC_13_0017;
  124. vm.alertData2 = datas[1].obj.VIEW_13_0026[0].HC_13_0017;
  125. vm.alertData3 = datas[2].obj.VIEW_13_0033[0].HC_13_0029;
  126. vm.alertData4 = datas[2].obj.VIEW_13_0033[0].HC_13_0030;
  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. }).catch(function(res){
  144. console.log(res);
  145. })
  146. },
  147. setAlertChart1:function(data){
  148. var options = JSON.parse(data);
  149. options = quxianChart(options);
  150. // var options = this.bigData[t]['区县分布'];
  151. // options.series[0].label = {show: true,position: "right",color: '#b5e1fc'}
  152. this.alertChart1 = options;
  153. },
  154. setAlertChart2:function(data){
  155. var options = JSON.parse(data);
  156. options = nianlingChart(options);
  157. options.color = ["#6576e0","#03fa6c","#ff616f","#0fa5f2","#00e6f3"];
  158. options.legend.formatter = function(name) {
  159. var index = 0;
  160. var clientlabels = options.legend.data;
  161. var clientcounts = _.map(options.series[0].data,function(item,idx){
  162. return item.value;
  163. });
  164. clientlabels.forEach(function(value,i){
  165. if(value == name){
  166. index = i;
  167. }
  168. });
  169. return name + " " + clientcounts[index];
  170. }
  171. options.legend.left = '58%';
  172. options.legend.top = 0.044 * window.screen.width;//85;
  173. options.legend.itemWidth = 0.005 * window.screen.width;//10;
  174. options.legend.itemHeight = 0.005 * window.screen.width;//10;
  175. options.legend.itemGap = 0.0078 * window.screen.width;//15;
  176. options.series[0].center = ['35%','55%'];
  177. console.log(options)
  178. this.alertChart2 = options
  179. },
  180. setAlertChart3:function(data){
  181. var options = JSON.parse(data);
  182. options = xingbieChart(options);
  183. options.color = ["#00E7F3","#ff616f"];
  184. options.legend.formatter = function(name) {
  185. var index = 0;
  186. var clientlabels = options.legend.data;
  187. var clientcounts = _.map(options.series[0].data,function(item,idx){
  188. return item.value;
  189. });
  190. clientlabels.forEach(function(value,i){
  191. if(value == name){
  192. index = i;
  193. }
  194. });
  195. return name + " " + clientcounts[index];
  196. }
  197. options.legend.left = '58%';
  198. options.legend.top = 0.0625 * window.screen.width;//120
  199. options.legend.itemWidth = 0.005 * window.screen.width;//10;
  200. options.legend.itemHeight = 0.005 * window.screen.width;//10;
  201. options.legend.itemGap = 0.0078 * window.screen.width;//15;
  202. options.series[0].center = ['35%','55%'];
  203. this.alertChart3 = options
  204. },
  205. setAlertChart4:function(data){
  206. var options = JSON.parse(data);
  207. options = jibingTopChart(options);
  208. options.series[0].label = {show: true,position: "right",color: '#b5e1fc'};
  209. options.series[0].itemStyle.normal.color = '#FFF71A';
  210. this.alertChart4 = options
  211. },
  212. setAlertChart5:function(data){
  213. console.log(data)
  214. var options = JSON.parse(data);
  215. console.log(options)
  216. options = qushiChart(options);
  217. // var options = this.bigData[t]['区县分布'];
  218. // options.series[0].label = {show: true,position: "right",color: '#b5e1fc'}
  219. this.alertChart5 = options;
  220. },
  221. alertTitle:function(type){
  222. this.alertTime = 0;
  223. this.type = type;
  224. this.initData(type)
  225. },
  226. alertChart:function(time){
  227. var vm = this;
  228. this.alertTime = time;
  229. if(time == 0){
  230. vm.setAlertChart5(vm.qushiMonth);
  231. }else if(time == 1){
  232. vm.setAlertChart5(vm.qushiYear);
  233. }else if(time == 2){
  234. vm.setAlertChart5(vm.qushiSeason);
  235. }
  236. },
  237. closeAlertClick:function(){
  238. parent.layer.closeAll();
  239. },
  240. GetQueryString :function (name){
  241. var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  242. var r = window.location.search.substr(1).match(reg);
  243. if(r!=null)return unescape(r[2]); return null;
  244. },
  245. chartArea:function(param){
  246. console.log(param);
  247. },
  248. clickBarItem:function(item){
  249. console.log(item)
  250. },
  251. formatDate: function() {
  252. //获取上个月第一天
  253. var firstdate = new Date(new Date().getFullYear(), new Date().getMonth() - 1, 1);
  254. //获取上个月最后一天
  255. var date = new Date();
  256. var day = new Date(date.getFullYear(), date.getMonth(), 0).getDate();
  257. var enddate = new Date(new Date().getFullYear(), new Date().getMonth() - 1, day);
  258. //格式化结果
  259. var year = date.getFullYear();
  260. debugger
  261. this.thirdJiDate = getThirdJiDate(year,lastMonth+1);
  262. this.firstDay = getLastMonthStartDate();
  263. this.firstMonth = firstdate.format("yyyy-MM");
  264. this.lastDay = getLastMonthEndDate();
  265. this.lastMonth = enddate.format("yyyy-MM");
  266. this.firstDayYear = getYearStartDate();
  267. this.lastDayYear = getYearEndDate();
  268. this.halfYearStartDate = getHalfYearStartDate();
  269. this.halfYearEndDate = getHalfYearEndDate();
  270. this.yesterdayDate = getYearEndDate();
  271. },
  272. getLastDay(year, month) {
  273. var new_year = year; //取当前的年份
  274. var new_month = month++; //取下一个月的第一天,方便计算(最后一天不固定)
  275. if (month > 12) {
  276. //如果当前大于12月,则年份转到下一年
  277. new_month -= 12; //月份减
  278. new_year++; //年份增
  279. }
  280. var new_date = new Date(new_year, new_month, 1); //取当年当月中的第一天
  281. return new Date(new_date.getTime() - 1000 * 60 * 60 * 24).getDate(); //获取当月最后一天日期
  282. },
  283. }
  284. });
  285. //数字格式化
  286. function toThousands(str) {
  287. if(!str)return
  288. str =parseInt(str);
  289. if(typeof(str) == 'number')str = str.toString()
  290. var newStr = "";
  291. var count = 0;
  292. if(str.indexOf(".") == -1) {
  293. for(var i = str.length - 1; i >= 0; i--) {
  294. if(count % 3 == 0 && count != 0) {
  295. newStr = str.charAt(i) + "," + newStr;
  296. } else {
  297. newStr = str.charAt(i) + newStr;
  298. }
  299. count++;
  300. }
  301. str = newStr;
  302. } else {
  303. for(var i = str.indexOf(".") - 1; i >= 0; i--) {
  304. if(count % 3 == 0 && count != 0) {
  305. newStr = str.charAt(i) + "," + newStr;
  306. } else {
  307. newStr = str.charAt(i) + newStr; //逐个字符相接起来
  308. }
  309. count++;
  310. }
  311. str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
  312. }
  313. return str;
  314. }