alert3.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_16_0001',//新增人数
  22. 'VIEW_16_0006',//已生产人数
  23. 'VIEW_16_0002',//区县分布
  24. 'VIEW_16_0007',//年龄分布
  25. 'VIEW_16_0008',//疾病前五
  26. 'VIEW_16_0004',//就诊月趋势
  27. 'VIEW_16_0005',//就诊年趋势
  28. 'VIEW_16_0012',//就诊季趋势
  29. ],
  30. qushiMonth:'',
  31. qushiYear:'',
  32. firstDayYear: "", //本年第一天
  33. lastDayYear: "", //本年最后一天
  34. halfYearStartDate: "", //近半年开始时间
  35. halfYearEndDate: "", //近半年结束时间
  36. yesterdayDate:"",//昨天
  37. type:0,
  38. time:'',//42天前
  39. thirdJiDate:"",//三个季度前
  40. qushiSeason:"",//季度趋势
  41. },
  42. mounted: function() {
  43. var vm = this;
  44. updateFontSize();
  45. this.formatDate();
  46. var t = new Date(vm.firstMonth+'-'+'01');
  47. t = Date.parse(t)-3600*24*42*1000
  48. vm.time = new Date(t).Format('yyyy-MM-dd');
  49. this.initData(this.type);
  50. var myDate = new Date();
  51. var maxMonth = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
  52. var maxYear = myDate.getFullYear();
  53. var max = maxYear.toString()+'-'+maxMonth.toString();
  54. console.log(vm.firstMonth,vm.lastMonth)
  55. var moren = vm.firstMonth+' 至 '+vm.lastMonth;
  56. layui.use('laydate', function(){
  57. var laydate = layui.laydate;
  58. //执行一个laydate实例
  59. laydate.render({
  60. elem: '#time', //指定元素,
  61. type:'month',
  62. range: '至', //或 range: '~' 来自定义分割字符
  63. theme: '#05273e',
  64. position: 'abolute',
  65. right:'200px',
  66. value: moren,
  67. max:max,
  68. btns: ['confirm'],
  69. done: function(value, date, endDate){
  70. console.log(value); //得到日期生成的值,如:2017-08-18
  71. console.log(date); //得到日期时间对象:{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
  72. console.log(endDate); //得结束的日期时间对象,开启范围选择(range: true)才会返回。对象成员同上。
  73. console.log(vm.firstDay);
  74. var t = new Date(date.year+'-'+date.month+'-'+'01');
  75. t = Date.parse(t)-3600*24*42*1000
  76. vm.time = new Date(t).Format('yyyy-MM-dd');
  77. if(date.month < 10){
  78. vm.firstDay = date.year+'-0'+date.month+'-01';
  79. }else{
  80. vm.firstDay = date.year+'-'+date.month+'-01';
  81. }
  82. if(endDate.month < 10){
  83. vm.lastDay = endDate.year+'-0'+endDate.month+'-'+vm.getLastDay(endDate.year,endDate.month);
  84. }else{
  85. vm.lastDay = endDate.year+'-'+endDate.month+'-'+vm.getLastDay(endDate.year,endDate.month);
  86. }
  87. vm.halfYearStartDate = getLastHalfMonthArray(endDate.year+'-'+endDate.month)
  88. vm.halfYearEndDate = vm.lastDay;
  89. vm.thirdJiDate = getThirdJiDate(endDate.year,endDate.month);
  90. vm.initData(vm.type);
  91. vm.alertTime = 0;
  92. }
  93. // showBottom: false
  94. });
  95. });
  96. },
  97. methods: {
  98. initData:function(type){
  99. var vm = this;
  100. if(type == 0){
  101. event_type = '';//全部
  102. }else if(type == 1){
  103. event_type = 1;//住院
  104. }else if(type == 2){
  105. event_type = 0;//门诊
  106. }
  107. var linkageFilter1 = "quotaDate >= '" + vm.firstDay + "' and quotaDate <= '" + vm.lastDay + "';";
  108. var linkageFilter2 = "quotaDate >= '" + vm.time + "' and quotaDate <= '" + vm.lastDay + "';";
  109. var linkageFilter3 = "quotaDate >= '" + vm.halfYearStartDate + "' and quotaDate <= '" + vm.halfYearEndDate + "';";
  110. var linkageFilter4 = "quotaDate >= '" + vm.thirdJiDate + "' and quotaDate <= '" + vm.lastDay + "';";
  111. console.log(linkageFilter1)
  112. var code = this.code;
  113. var urlNumber = '/gov/report/getNoChartTemplateData';
  114. var urlChart = '/gov/report/getTemplateDataByViewCode';
  115. var reqUrl = [
  116. {url:urlNumber,reqType: 'get',data: {viewCodeStr:code[0],linkageFilter:linkageFilter1}},//新增人数
  117. {url:urlNumber,reqType: 'get',data: {viewCodeStr:code[1],linkageFilter:linkageFilter2}},//已生产人数
  118. {url:urlChart,reqType: 'get',data: {viewCode:code[2],linkageFilter:linkageFilter1+'eventType='+event_type}},//区县分布
  119. {url:urlChart,reqType: 'get',data: {viewCode:code[3],linkageFilter:linkageFilter1+'eventType='+event_type}},//性别分布
  120. {url:urlChart,reqType: 'get',data: {viewCode:code[4],linkageFilter:linkageFilter1+'eventType='+event_type,'limitCondition':5}},//疾病前五
  121. {url:urlChart,reqType: 'get',data: {viewCode:code[5],linkageFilter:linkageFilter3+'eventType='+event_type}},//老年人就诊趋势-月
  122. {url:urlChart,reqType: 'get',data: {viewCode:code[6],linkageFilter:'eventType='+event_type}},//老年人就诊趋势-年
  123. {url:urlChart,reqType: 'get',data: {viewCode:code[7],linkageFilter:linkageFilter4+'eventType='+event_type}},//老年人就诊趋势-月
  124. ]
  125. $(".div-mask-layer").show();
  126. httpRequest.getReqPromises(reqUrl).then(function(datas) {
  127. console.log(datas);
  128. vm.alertData1 = datas[0].obj.VIEW_16_0001[0].HC_13_0033; //新增
  129. vm.alertData2 = datas[1].obj.VIEW_16_0006[0].HC_13_0034; //已生产人数
  130. var chart1 = datas[2].obj.viewInfos[0].options[0].option;
  131. var chart2 = datas[3].obj.viewInfos[0].options[0].option;
  132. var chart3 = datas[4].obj.viewInfos[0].options[0].option;
  133. var chart4 = datas[5].obj.viewInfos[0].options[0].option;
  134. var chart5 = datas[6].obj.viewInfos[0].options[0].option;
  135. var chart6 = datas[7].obj.viewInfos[0].options[0].option;
  136. vm.qushiMonth = chart4;
  137. vm.qushiYear = chart5;
  138. vm.qushiSeason = chart6;
  139. console.log(chart5)
  140. vm.setAlertChart1(chart1);
  141. vm.setAlertChart2(chart2);
  142. vm.setAlertChart4(chart3);
  143. vm.setAlertChart5(chart4);
  144. $(".div-mask-layer").hide();
  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. this.alertChart2 = options
  178. },
  179. setAlertChart3:function(data){
  180. var options = JSON.parse(data);
  181. options = xingbieChart(options);
  182. options.color = ["#00E7F3","#ff616f"];
  183. options.legend.formatter = function(name) {
  184. var index = 0;
  185. var clientlabels = options.legend.data;
  186. var clientcounts = _.map(options.series[0].data,function(item,idx){
  187. return item.value;
  188. });
  189. clientlabels.forEach(function(value,i){
  190. if(value == name){
  191. index = i;
  192. }
  193. });
  194. return name + " " + clientcounts[index];
  195. }
  196. options.legend.left = '58%';
  197. options.legend.top = 0.0625 * window.screen.width;//120
  198. options.legend.itemWidth = 0.005 * window.screen.width;//10;
  199. options.legend.itemHeight = 0.005 * window.screen.width;//10;
  200. options.legend.itemGap = 0.0078 * window.screen.width;//15;
  201. options.series[0].center = ['35%','55%'];
  202. this.alertChart3 = options
  203. },
  204. setAlertChart4:function(data){
  205. var options = JSON.parse(data);
  206. options = jibingTopChart(options);
  207. options.series[0].label = {show: true,position: "right",color: '#b5e1fc'};
  208. options.series[0].itemStyle.normal.color = '#FFF71A';
  209. this.alertChart4 = options
  210. },
  211. setAlertChart5:function(data){
  212. var options = JSON.parse(data);
  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. }