home.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. toastr.options = {
  2. "closeButton": true,
  3. "positionClass": "toast-top-center",
  4. "preventDuplicates": true
  5. }
  6. new Vue({
  7. el: '#main',
  8. data: {
  9. type:0,//0:高血压 1:糖尿病 2:孕产妇 3:65岁以上老年人人数
  10. jsonUrl:"../../../dataJson/jumingHealthJson/高血压人群.json",
  11. jsonData:null,
  12. city: '上饶市',
  13. town: [],
  14. cityVal:"0",
  15. diseaseData:[],
  16. mapData:null,
  17. zhongDianData:[],
  18. gaoFaData:null,
  19. siWangData:[],
  20. skipShow:0,
  21. lineHeightIndex:null,
  22. reqUrl:[],
  23. isInit:true,//是否初始化
  24. isClickDisease:true,//是否点击疾病
  25. isClickMap:false//是否点击地图
  26. },
  27. mounted: function() {
  28. this.bindEvents();
  29. this.initData();
  30. },
  31. methods: {
  32. initData:function(){
  33. var vm = this,reqUrl = [],townStr="",viewMapJsonGXY = null,viewMapJsonTNB = null,viewMapJsonYCF = null,viewMapJsonGL = null,zhongDianViewCodeMonth="",zhongDianViewCodeJi="",zhongDianViewCodeYear="";
  34. $(".div-mask-layer").show();
  35. var currentDate = new Date();
  36. //封装参数
  37. vm.cityVal!="0"?townStr = "town="+vm.cityVal+";":townStr = "";//vm.cityVal=0 查询整个市
  38. var diseaseLinkAgeFliter = "quotaDate >= '" + getLastMonthStartDate() + "' and quotaDate <= '" + getLastMonthEndDate() + "';";//疾病列表参数(上个月数据)
  39. var zhongDianLinkageFilter = "quotaDate >= '" + getLastYearMonthArray()[12] + "' and quotaDate <= '" + getLastMonthEndDate() + "';";//重点人群参数(过去12个月数据)
  40. var zhongDianLinkageFilterJi = "quotaDate >= '" + getThirdJiDate(currentDate.getFullYear(),(currentDate.getMonth()+1)) + "' and quotaDate <= '" + getQuarterEndDate() + "';";
  41. var gaoFaLinkageFilterMonth = "quotaDate >= '" + getMonthStartDate() + "' and quotaDate <= '" + getMonthEndDate() + "';";//高发疾病参数(本月数据)
  42. var gaoFaLinkageFilterJi = "quotaDate >= '" + getQuarterStartDate() + "' and quotaDate <= '" + getQuarterEndDate() + "';";//高发疾病参数(本季数据)
  43. var gaoFaLinkageFilterYear = "quotaDate >= '" + getYearStartDate() + "' and quotaDate <= '" + getYearEndDate() + "';";//高发疾病参数(本年数据)
  44. viewMapJsonGXY = {VIEW_13_0013:townStr,VIEW_13_0036:townStr+diseaseLinkAgeFliter,VIEW_13_0037:townStr+diseaseLinkAgeFliter};//高血压
  45. viewMapJsonTNB = {VIEW_13_0026:townStr,VIEW_13_0034:townStr+diseaseLinkAgeFliter,VIEW_13_0027:townStr+diseaseLinkAgeFliter};//糖尿病
  46. viewMapJsonYCF = {VIEW_16_0009:townStr,VIEW_16_0010:townStr+diseaseLinkAgeFliter,VIEW_16_0011:townStr+diseaseLinkAgeFliter};//孕产妇
  47. viewMapJsonGL = {VIEW_15_0001:townStr,VIEW_15_0011:townStr+diseaseLinkAgeFliter,VIEW_15_0008:townStr+diseaseLinkAgeFliter};//65岁以上
  48. if(vm.type==0){//高血压
  49. zhongDianViewCodeMonth = "VIEW_13_0017";//重点人群+按月
  50. zhongDianViewCodeJi = "VIEW_13_0045";//重点人群+按季度
  51. zhongDianViewCodeYear = "VIEW_13_0022";//重点人群+按年
  52. }else if(vm.type==1){//糖尿病
  53. zhongDianViewCodeMonth = "VIEW_13_0028";//重点人群+按月
  54. zhongDianViewCodeJi = "VIEW_13_0046";//重点人群+按季度
  55. zhongDianViewCodeYear = "VIEW_13_0029";//重点人群+按年
  56. }else if(vm.type==2){//孕产妇
  57. zhongDianViewCodeMonth = "VIEW_16_0004";//重点人群+按月
  58. zhongDianViewCodeJi = "VIEW_16_0012";//重点人群+按季度
  59. zhongDianViewCodeYear = "VIEW_16_0005";//重点人群+按年
  60. }else if(vm.type==3){//65岁以上
  61. zhongDianViewCodeMonth = "VIEW_15_0009";//重点人群+按月
  62. zhongDianViewCodeJi = "VIEW_15_0012";//重点人群+按季度
  63. zhongDianViewCodeYear = "VIEW_15_0010";//重点人群+按年
  64. }
  65. if(vm.isInit || vm.isClickMap){//整理请求参数集合(初始化或点击地图时加载所有数据)
  66. reqUrl = [
  67. {url: bigDataAPI.getCityArea,reqType: 'get',data: {}},
  68. {url:bigDataAPI.getMapJingWeiDuInfo,reqType: 'get',data:{}},//上饶地图经纬度数据
  69. {url:bigDataAPI.getMoreNoChartTemplateData,reqType: 'get',data:{viewMapJson:JSON.stringify(viewMapJsonGXY)}},//高血压疾病数据+地图
  70. {url:bigDataAPI.getMoreNoChartTemplateData,reqType: 'get',data:{viewMapJson:JSON.stringify(viewMapJsonTNB)}},//糖尿病疾病数据+地图
  71. {url:bigDataAPI.getMoreNoChartTemplateData,reqType: 'get',data:{viewMapJson:JSON.stringify(viewMapJsonYCF)}},//孕产妇疾病数据+地图
  72. {url:bigDataAPI.getMoreNoChartTemplateData,reqType: 'get',data:{viewMapJson:JSON.stringify(viewMapJsonGL)}},//65岁以上疾病数据+地图
  73. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: zhongDianViewCodeMonth,linkageFilter:zhongDianLinkageFilter+townStr}},//重点人群+按月
  74. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: zhongDianViewCodeJi,linkageFilter:zhongDianLinkageFilterJi+townStr}},//重点人群+按季度
  75. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: zhongDianViewCodeYear,linkageFilter:townStr}},//重点人群+按年
  76. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: "VIEW_13_0007",linkageFilter:gaoFaLinkageFilterMonth+townStr,limitCondition:10}},//高发疾病排行----筛选条件:全部+本月
  77. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: "VIEW_13_0007",linkageFilter:gaoFaLinkageFilterYear+townStr,limitCondition:10}},//高发疾病排行----筛选条件:全部+本年
  78. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: "VIEW_13_0007",linkageFilter:gaoFaLinkageFilterJi+townStr,limitCondition:10}},//高发疾病排行----筛选条件:全部+本季度
  79. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: "VIEW_13_0008",linkageFilter:townStr}},//死亡原因
  80. ];
  81. }else{//点击疾病类型,则本月高发和死亡原因数据不变,不用重新请求
  82. reqUrl = [
  83. {url: bigDataAPI.getCityArea,reqType: 'get',data: {}},
  84. {url:bigDataAPI.getMapJingWeiDuInfo,reqType: 'get',data:{}},//上饶地图经纬度数据
  85. {url:bigDataAPI.getMoreNoChartTemplateData,reqType: 'get',data:{viewMapJson:JSON.stringify(viewMapJsonGXY)}},//高血压疾病数据+地图
  86. {url:bigDataAPI.getMoreNoChartTemplateData,reqType: 'get',data:{viewMapJson:JSON.stringify(viewMapJsonTNB)}},//糖尿病疾病数据+地图
  87. {url:bigDataAPI.getMoreNoChartTemplateData,reqType: 'get',data:{viewMapJson:JSON.stringify(viewMapJsonYCF)}},//孕产妇疾病数据+地图
  88. {url:bigDataAPI.getMoreNoChartTemplateData,reqType: 'get',data:{viewMapJson:JSON.stringify(viewMapJsonGL)}},//65岁以上疾病数据+地图
  89. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: zhongDianViewCodeMonth,linkageFilter:zhongDianLinkageFilter+townStr}},//重点人群+按月
  90. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: zhongDianViewCodeJi,linkageFilter:zhongDianLinkageFilter+townStr}},//重点人群+按季度
  91. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: zhongDianViewCodeYear,linkageFilter:townStr}},//重点人群+按年
  92. ];
  93. }
  94. httpRequest.getReqPromises(reqUrl).then(function(datas) {
  95. vm.town = [{"name": "上饶市","id": "0"}].concat(datas[0]);
  96. echarts.registerMap('上饶',datas[1]);
  97. vm.diseaseData.push(datas[2]);
  98. vm.diseaseData.push(datas[3]);
  99. vm.diseaseData.push(datas[4]);
  100. vm.diseaseData.push(datas[5]);
  101. if(vm.isClickDisease){//点击疾病类型,则地图数据重新加载
  102. if(vm.type==0){//高血压
  103. vm.setMapData(datas[2]);
  104. }else if(vm.type==1){//糖尿病
  105. vm.setMapData(datas[3]);
  106. }else if(vm.type==2){//孕产妇
  107. vm.setMapData(datas[4]);
  108. }else if(vm.type==3){//65岁以上
  109. vm.setMapData(datas[5]);
  110. }
  111. }
  112. vm.zhongDianData = [datas[6],datas[7],datas[8]];//重点人群+按月、重点人群+按季度、重点人群+按年
  113. if(vm.isClickMap || vm.isInit){//点击地图或初始化,则高发和死亡原因数据重新加载
  114. vm.gaoFaData = [datas[9],datas[10],datas[11]];//高发疾病排行----筛选条件:本月(默认)、本年、本季度
  115. vm.siWangData = datas[12];//死亡原因
  116. }
  117. vm.isInit = false;
  118. $(".div-mask-layer").hide();
  119. })
  120. },
  121. setMapData: function(data) {
  122. var optionData = [],vm=this;
  123. if(vm.type==0){//高血压
  124. data = data.successFlg?data.detailModelList&&data.detailModelList[1].VIEW_13_0036 || []:[];
  125. _.map(data, function(item) {
  126. if(item.firstColumn != "合计") {
  127. optionData.push({
  128. name: item.townName,
  129. value: parseInt(item.HC_13_0021)
  130. })
  131. }
  132. })
  133. }else if(vm.type==1){//糖尿病
  134. data = data.successFlg?data.detailModelList&&data.detailModelList[1].VIEW_13_0034 || []:[];
  135. _.map(data, function(item) {
  136. if(item.firstColumn != "合计") {
  137. optionData.push({
  138. name: item.townName,
  139. value: parseInt(item.HC_13_0017)
  140. })
  141. }
  142. })
  143. }else if(vm.type==2){//孕产妇
  144. data = data.successFlg?data.detailModelList&&data.detailModelList[1].VIEW_16_0010 || []:[];
  145. _.map(data, function(item) {
  146. if(item.firstColumn != "合计") {
  147. optionData.push({
  148. name: item.townName,
  149. value: parseInt(item.HC_13_0033)
  150. })
  151. }
  152. })
  153. }else if(vm.type==3){//65岁以上
  154. data = data.successFlg?data.detailModelList&&data.detailModelList[1].VIEW_15_0011 || []:[];
  155. _.map(data, function(item) {
  156. if(item.firstColumn != "合计") {
  157. optionData.push({
  158. name: item.townName,
  159. value: parseInt(item.HC_15_1006)
  160. })
  161. }
  162. })
  163. }
  164. var options = optionData;
  165. this.mapData = {
  166. data: options,
  167. index: this.lineHeightIndex
  168. };
  169. },
  170. bindEvents:function(){
  171. var vm = this;
  172. EventBus.$on("refresh-json-data", function(arg) {
  173. vm.isClickMap = false;
  174. vm.isClickDisease = true;
  175. vm.type = arg.type;//0:高血压 1:糖尿病 2:孕产妇 3:65岁以上老年人人数
  176. vm.initData();
  177. });
  178. },
  179. setCity(item){
  180. this.city = item.name;
  181. },
  182. clickMap:function(res){
  183. this.isClickMap = true;
  184. this.isClickDisease = false;
  185. this.city = res.name;
  186. },
  187. skipClick:function(){
  188. console.log(222)
  189. this.skipShow == 0 ? this.skipShow = 1 : this.skipShow = 0
  190. }
  191. },
  192. watch:{
  193. city:function(value){
  194. var vm =this;
  195. vm.lineHeightIndex =value;
  196. this.town.map(function(v,i){
  197. if(v.name == value) {
  198. vm.cityVal = v.id;
  199. }
  200. })
  201. vm.isClickMap = true;
  202. vm.isClickDisease = false;
  203. vm.initData();
  204. }
  205. }
  206. });
  207. //数字格式化
  208. function toThousands(str) {
  209. if(!str)return
  210. str =parseInt(str);
  211. if(typeof(str) == 'number')str = str.toString()
  212. var newStr = "";
  213. var count = 0;
  214. if(str.indexOf(".") == -1) {
  215. for(var i = str.length - 1; i >= 0; i--) {
  216. if(count % 3 == 0 && count != 0) {
  217. newStr = str.charAt(i) + "," + newStr;
  218. } else {
  219. newStr = str.charAt(i) + newStr;
  220. }
  221. count++;
  222. }
  223. str = newStr;
  224. } else {
  225. for(var i = str.indexOf(".") - 1; i >= 0; i--) {
  226. if(count % 3 == 0 && count != 0) {
  227. newStr = str.charAt(i) + "," + newStr;
  228. } else {
  229. newStr = str.charAt(i) + newStr; //逐个字符相接起来
  230. }
  231. count++;
  232. }
  233. str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
  234. }
  235. return str;
  236. }