alert5.js 12 KB

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