alert6.js 14 KB

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