home.js 9.9 KB

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