resident-analysis.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. Vue.component('resident-analysis', {
  2. template: '<div>\
  3. <div class="ui-grid plr10 mt20">\
  4. <div class="div-qingkuang-left">\
  5. <div class="div-header-block">\
  6. <div class="div-analysis-title">缴费情况</div>\
  7. </div>\
  8. <div class="ui-grid ui-grid-middle height-140">\
  9. <div class="ui-col-1 c-t-center c-ffc800">\
  10. <div class="y-amount c-f16">{{weiJiaoFeiData}}</div>\
  11. <div class="y-rate c-f14 mt5">{{weiJiaoFeiPer}}</div>\
  12. <div class="y-title c-f12 mt10">未缴费人数</div>\
  13. </div>\
  14. <div id="jiaoFeiChart" class="height-140 ui-col-0" style="width: 40%"></div>\
  15. <div class="ui-col-1 c-t-center c-12b7f5">\
  16. <div class="y-amount c-f16">{{yiJiaoFeiData}}</div>\
  17. <div class="y-rate c-f14 mt5">{{yiJiaoFeiPer}}</div>\
  18. <div class="y-title c-f12 mt10">已缴费人数</div>\
  19. </div>\
  20. </div>\
  21. </div>\
  22. <div class="ui-col-1"></div>\
  23. <div class="div-qingkuang-right">\
  24. <div class="div-header-block">\
  25. <div class="div-analysis-title">健康分布</div>\
  26. </div>\
  27. <div class="ui-grid ui-grid-middle height-140">\
  28. <div id="healthChart" class="height-140 c-t-center" style="width: 40%"></div>\
  29. <div class="ui-col-1 ui-grid ui-grid-vertical">\
  30. <div id="jkCatalogs">\
  31. <div class="ui-col-1">\
  32. <span class="span-frame cb-12b7f5"></span>\
  33. <span class="c-f14 c-12b7f5">{{jianKangRQPer}}%</span>\
  34. <span class="c-f12 c-909090">(健康人群)</span>\
  35. </div>\
  36. <div class="ui-col-1 mt5">\
  37. <span class="span-frame cb-fb5dab"></span>\
  38. <span class="c-f14 c-fb5dab">{{huanBingRQPer}}%</span>\
  39. <span class="c-f12 c-909090">(患病人群)</span>\
  40. </div>\
  41. <div class="ui-col-1 mt5">\
  42. <span class="span-frame cb-cd67fd"></span>\
  43. <span class="c-f14 c-cd67fd">{{gaoWeiRQPer}}%</span>\
  44. <span class="c-f12 c-666">(高危人群)</span>\
  45. </div>\
  46. <div class="ui-col-1 mt5">\
  47. <span class="span-frame cb-ffc800"></span>\
  48. <span class="c-f14 c-ffc800">{{huiFuQiRQPer}}%</span>\
  49. <span class="c-f12 c-666">(恢复期人群)</span>\
  50. </div>\
  51. <div class="ui-col-1 mt5">\
  52. <span class="span-frame cb-61eb41"></span>\
  53. <span class="c-f14 c-61eb41">{{weiBiaoZRQPer}}%</span>\
  54. <span class="c-f12 c-666">(未标注)</span>\
  55. </div>\
  56. </div>\
  57. </div>\
  58. </div>\
  59. </div>\
  60. </div>\
  61. <div class="ui-grid plr10 mt20">\
  62. <div class="div-qingkuang-left">\
  63. <div class="div-header-block">\
  64. <div class="div-analysis-title">服务分布比例</div>\
  65. </div>\
  66. <div id="serviceChart" class="height-140"></div>\
  67. </div>\
  68. <div class="ui-col-1"></div>\
  69. <div class="div-qingkuang-right">\
  70. <div class="div-header-block">\
  71. <div class="div-analysis-title">性别情况</div>\
  72. </div>\
  73. <div class="c-position-r height-140">\
  74. <div class="div-right-info">\
  75. <div class="y-amount c-f16">{{maleData}}</div>\
  76. <div class="y-rate c-f14 mt5">{{malePer}}</div>\
  77. <div class="y-title c-f12 mt10">男性</div>\
  78. </div>\
  79. <div class="div-left-info">\
  80. <div class="y-amount c-f16 c-fb5dab">{{femaleData}}</div>\
  81. <div class="y-rate c-f14 mt5 c-fb5dab">{{femalePer}}</div>\
  82. <div class="y-title c-f12 mt10 c-fb5dab">女性</div>\
  83. </div>\
  84. <div id="sexChart" class="height-140"></div>\
  85. </div>\
  86. </div>\
  87. </div>\
  88. <div class="div-service-kuang">\
  89. <div class="div-header-block">\
  90. <div class="div-analysis-title">年龄分布</div>\
  91. </div>\
  92. <div id="ageChart" class="height-140"></div>\
  93. </div>\
  94. </div>',
  95. props: [],
  96. data: function() {
  97. return {
  98. yiJiaoFeiData: "",
  99. yiJiaoFeiPer: "",
  100. weiJiaoFeiData: "",
  101. weiJiaoFeiPer: "",
  102. jianKangRQPer: "",
  103. huanBingRQPer: "",
  104. gaoWeiRQPer: "",
  105. huiFuQiRQPer: "",
  106. weiBiaoZRQPer: "",
  107. maleData: "",
  108. malePer: "",
  109. femaleData: "",
  110. femalePer: "",
  111. chooseYear: "", //选择年份值
  112. curLevel: null, //当前level值
  113. curCode: null, //当前选中区域的code值
  114. curName: null, //当前选中区域名称值
  115. endDate: null,
  116. userRole: null,
  117. roleLevel: null,
  118. filterHtml: null,
  119. yearHtml: null
  120. }
  121. },
  122. mounted: function() {
  123. var vm = this;
  124. var now = new Date();
  125. if(now.getMonth() >= 6) {
  126. vm.chooseYear = now.getFullYear();
  127. } else {
  128. vm.chooseYear = now.getFullYear() - 1;
  129. }
  130. vm.userRole = JSON.parse(window.sessionStorage.getItem("selectedRole"));
  131. vm.roleLevel = vm.userRole.code == '350200' ? 4 : vm.userRole.code.length == 6 ? 3 : 2;
  132. vm.endDate = getEndDate(vm.chooseYear);
  133. vm.curLevel = vm.roleLevel;
  134. vm.curCode = vm.userRole.code;
  135. vm.curName = vm.userRole.name;
  136. //初始化数据
  137. initData(vm);
  138. //监听后退按钮的操作
  139. EventBus.$on("back-click", function(arg) {
  140. history.go(-1);
  141. });
  142. //刷新数据
  143. EventBus.$on('refresh-click', function(arg) {
  144. initData(vm);
  145. });
  146. //弹出筛选框
  147. EventBus.$on('filter-click', function(arg) {
  148. //弹框显示筛选条件
  149. Vuedals.Bus.$emit('new', {
  150. title: '条件筛选',
  151. onClose: function(data) {
  152. vm.chooseYear = data.year;
  153. vm.curName = data.name;
  154. vm.curCode = data.areaCode;
  155. vm.curLevel = data.level;
  156. vm.endDate = getEndDate(vm.chooseYear);
  157. vm.yearHtml = data.yearHtml;
  158. vm.filterHtml = data.filterHtml;
  159. initData(vm); //刷新数据
  160. },
  161. component: 'resident-analysis-filter',
  162. props: {
  163. curLevel: vm.roleLevel,
  164. curCode: vm.userRole.code,
  165. curName: vm.userRole.name,
  166. yearHtml: vm.yearHtml,
  167. filterHtml: vm.filterHtml
  168. }
  169. });
  170. });
  171. },
  172. methods: {
  173. }
  174. })
  175. //请求接口数据
  176. function initData(vm) {
  177. EventBus.$emit('update-area-name', {
  178. areaName: vm.curName
  179. }); //更新区域名称
  180. EventBus.$emit('update-statistics-time', {}); //更新统计时间
  181. EventBus.$emit('update-statistics-year', {
  182. selectDate: vm.chooseYear + "年"
  183. }); //更新统计年份
  184. var url = "/statistics/leveltwo_increment",
  185. reqPromise = [];
  186. reqPromise.push(httpRequest.get(url, {
  187. data: {
  188. endDate: vm.endDate,
  189. area: vm.curCode,
  190. level: vm.curLevel,
  191. index: 16
  192. }
  193. }));
  194. reqPromise.push(httpRequest.get(url, {
  195. data: {
  196. endDate: vm.endDate,
  197. area: vm.curCode,
  198. level: vm.curLevel,
  199. index: 15
  200. }
  201. }));
  202. reqPromise.push(httpRequest.get(url, {
  203. data: {
  204. endDate: vm.endDate,
  205. area: vm.curCode,
  206. level: vm.curLevel,
  207. index: vm.chooseYear == "2016" ? 7 : 36
  208. }
  209. }));
  210. reqPromise.push(httpRequest.get(url, {
  211. data: {
  212. endDate: vm.endDate,
  213. area: vm.curCode,
  214. level: vm.curLevel,
  215. index: 6
  216. }
  217. }));
  218. reqPromise.push(httpRequest.get(url, {
  219. data: {
  220. endDate: vm.endDate,
  221. area: vm.curCode,
  222. level: vm.curLevel,
  223. index: 8
  224. }
  225. }));
  226. Promise.all(reqPromise).then(function(datas) {
  227. var jiaoFeiArr = datas[0],
  228. healthArr = datas[1],
  229. serviceArr = datas[2],
  230. sexArr = datas[3],
  231. ageArr = datas[4];
  232. //缴费情况处理
  233. if(jiaoFeiArr.status == "200") {
  234. var data = jiaoFeiArr.data.index_16;
  235. var yiJiaoFeiData = "";
  236. var weiJiaoFeiData = "";
  237. if(data && data.length == 1 && data[0].code == 0) { //未缴费率为100%的情况,后台没有返回已缴费的数据
  238. vm.yiJiaoFeiData = "0";
  239. vm.yiJiaoFeiPer = "0.00%";
  240. }
  241. $.each(data, function(i, v) {
  242. if(v.code == 0 || v.code == 1) {
  243. if(v.code == 1) {
  244. yiJiaoFeiData = v.amount;
  245. v.rate = parseFloat(v.rate).toFixed(2);
  246. vm.yiJiaoFeiData = v.amount;
  247. vm.yiJiaoFeiPer = v.rate + "%";
  248. } else {
  249. weiJiaoFeiData = v.amount;
  250. v.rate = parseFloat(v.rate).toFixed(2);
  251. vm.weiJiaoFeiData = v.amount;
  252. vm.weiJiaoFeiPer = v.rate + "%";
  253. }
  254. }
  255. })
  256. jiaoFeiData(yiJiaoFeiData, weiJiaoFeiData);
  257. }
  258. //健康分布处理
  259. if(healthArr.status == "200") {
  260. var data = healthArr.data.index_15;
  261. var wbzdata = data[0].amount;
  262. var jkrqdata = data[1].amount;
  263. var hbrqdata = data[2].amount;
  264. var gwrqdata = data[3].amount;
  265. var hfqrqdata = data[4].amount;
  266. vm.weiBiaoZRQPer = parseFloat(data[0].rate).toFixed(2);
  267. vm.jianKangRQPer = parseFloat(data[1].rate).toFixed(2);
  268. vm.huanBingRQPer = parseFloat(data[2].rate).toFixed(2);
  269. vm.gaoWeiRQPer = parseFloat(data[3].rate).toFixed(2);
  270. vm.huiFuQiRQPer = parseFloat(data[4].rate).toFixed(2);
  271. healthData(jkrqdata, hbrqdata, gwrqdata, hfqrqdata, wbzdata);
  272. }
  273. //服务分布处理
  274. if(serviceArr.status == "200") {
  275. var data = serviceArr.data["index_" + (vm.chooseYear == "2016" ? 7 : 36)];
  276. var colors = "#42C7FF,#FFC84C,#FB5DAB,#CD67FD,#795548,#607d8b,#ff5722,#cddc39,#9e9e9e,#3f51b5,#f44336,#9c27b0".split(',');
  277. var nameArr=[];
  278. var rateArr =[];
  279. if(vm.chooseYear == "2016") {
  280. $.each(data, function(i, v) {
  281. if(v.code == 1 || v.code == 2 || v.code == 3 || v.code == 7) {
  282. v.rate = parseFloat(v.rate).toFixed(2);
  283. nameArr.push(v.name);
  284. rateArr.push(v.rate);
  285. }
  286. })
  287. serviceData(nameArr,rateArr,colors.slice(0, nameArr.length),vm.chooseYear);
  288. }else{
  289. arry = _.chain(data).filter(function(v) {
  290. return !_.contains(["0","2","13"],v.code)
  291. }).map(function(v) {
  292. v.rate = parseFloat(v.rate).toFixed(2);
  293. return {"value":v.rate, "name":v.name}
  294. }).value();
  295. $.map(arry,function(item,index){
  296. nameArr.push(item.name)
  297. rateArr.push(item.value)
  298. })
  299. serviceData(nameArr,rateArr,colors.slice(0, nameArr.length),vm.chooseYear);
  300. }
  301. }
  302. //性别情况处理
  303. if(sexArr.status == "200") {
  304. var data = sexArr.data.index_6;
  305. var femaleData, maleData;
  306. $.each(data, function(i, v) {
  307. if(v.code == "1") { //女
  308. femaleData = v.amount;
  309. vm.femaleData = v.amount;
  310. vm.femalePer = parseFloat(v.rate).toFixed(2) + "%";
  311. } else { //男
  312. maleData = v.amount;
  313. vm.maleData = v.amount;
  314. vm.malePer = parseFloat(v.rate).toFixed(2) + "%";
  315. }
  316. })
  317. sexData(femaleData, maleData);
  318. }
  319. //年龄分布处理
  320. if(ageArr.status == "200") {
  321. var data = ageArr.data.index_8;
  322. var amountArr = [];
  323. $.each(data, function(i, v) {
  324. amountArr.push(v.amount);
  325. })
  326. ageData(amountArr);
  327. }
  328. })
  329. }