home.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. new Vue({
  2. el: '#main',
  3. data: {
  4. roles: [],
  5. selectedRole: "",
  6. isopen: true,
  7. signAnalysis: [{
  8. photo: '../../../images/qianyujingzhan_icon.png',
  9. label: '签约进展',
  10. url: 'sign-progress.html'
  11. }, {
  12. photo: '../../../images/xuqianjingzhan_icon.png',
  13. label: '续签进展',
  14. url: 'renew-progress.html'
  15. }, {
  16. photo: '../../../images/jumingfenxi_icon.png',
  17. label: '居民分析',
  18. url: 'resident-analysis.html'
  19. }, {
  20. photo: '../../../images/tuigaiqian_icon.png',
  21. label: '退改签',
  22. url: 'change-back.html'
  23. }, {
  24. photo: '../../../images/lianglvfenxi_icon.png',
  25. label: '两率分析',
  26. url: 'two-rate-analysis.html'
  27. }],
  28. serviceAnalysis: [{
  29. photo: '../../../images/zongtifenxi_icon.png',
  30. label: '总体分析',
  31. url: 'comprehensive-analysis.html'
  32. }, {
  33. photo: '../../../images/zixunfenxi_icon.png',
  34. label: '咨询分析',
  35. url: 'consulting-analysis.html'
  36. }, {
  37. photo: '../../../images/pijianfenxi_icon.png',
  38. label: '评价分析',
  39. url: 'estimate-analysis.html'
  40. }, {
  41. photo: '../../../images/changcufangfenxi_icon.png',
  42. label: '长处方分析',
  43. url: 'prescription-analysis.html'
  44. }],
  45. signRateData: {
  46. signTask: {
  47. text: '',
  48. rate: '0.00',
  49. sign: 0,
  50. people: 0
  51. },
  52. sign: {
  53. text: '',
  54. rate: '0.00',
  55. sign: 0,
  56. people: 0
  57. },
  58. renew: {
  59. text: '',
  60. rate: '0.00',
  61. sign: 0,
  62. people: 0
  63. }
  64. }
  65. },
  66. methods: {
  67. open: function() {
  68. EventBus.$emit('open-click', {});
  69. },
  70. showDetail: function(url) {
  71. window.location.href = url;
  72. },
  73. goToPage: function(val){
  74. var url = "sign-progress.html";
  75. if(val == 2){
  76. url = "renew-progress.html";
  77. }
  78. window.location.href = url;
  79. }
  80. },
  81. mounted: function() {
  82. //获取缓存里面的userRole
  83. var roles = window.localStorage.getItem("userRole");
  84. this.roles = JSON.parse(roles);
  85. var selected = window.localStorage.getItem("selectedRole");
  86. if(selected && selected!= "undefined") {
  87. this.selectedRole = JSON.parse(selected).code;
  88. } else {
  89. this.selectedRole = this.roles[0].code;
  90. var selected = this.roles[0];
  91. window.localStorage.setItem("selectedRole", JSON.stringify(selected));
  92. }
  93. $("#main").removeClass("c-hide")
  94. },
  95. watch: {
  96. selectedRole: function(val) {
  97. var selected = _.findWhere(this.roles, {
  98. code: val
  99. });
  100. window.localStorage.setItem("selectedRole", JSON.stringify(selected));
  101. getSignData(this);
  102. }
  103. }
  104. })
  105. function getSignData(vm){
  106. var code = vm.selectedRole,
  107. now = new Date(),
  108. params = {
  109. area: code,
  110. level: code == '350200' ? 4 : code.length == 6 ? 3 : 2,
  111. endDate: now.format("yyyy-MM-dd")
  112. };
  113. statisticAPI.getSignInfo(params).then(function(res){
  114. if(res.status == 200){
  115. var data = res.data;
  116. vm.signRateData = {
  117. signTask: {
  118. text: formatRate(data.signTaskRate.rate),
  119. rate: '0.00',
  120. sign: data.signTaskRate.sign,
  121. people: data.signTaskRate.people
  122. },
  123. sign: {
  124. text: formatRate(data.signRate.rate),
  125. rate: '0.00',
  126. sign: data.signRate.sign,
  127. people: data.signRate.people
  128. },
  129. renew: {
  130. text: data.renewRange,
  131. rate: '0.00',
  132. sign: data.renew.split("/")[0],
  133. people: data.renew.split("/")[1]
  134. }
  135. }
  136. var signArr = [
  137. {name: "签约数", value: data.signRate.sign},
  138. {name: "未签约数", value: data.signRate.people - data.signRate.sign},
  139. ],
  140. signTaskArr = [
  141. {name: "签约数", value: data.signTaskRate.sign},
  142. {name: "未达标数", value: data.signTaskRate.people - data.signTaskRate.sign}
  143. ],
  144. val = data.renew.split("/")[1] - data.renew.split("/")[0],
  145. renewArr = [
  146. {name: "续签数", value: data.renew.split("/")[0]},
  147. {name: "未达标数", value: val<0 ? 0 : val}
  148. ],
  149. color = ['#12b7f5', '#EBEBF5'];
  150. var signChart = drawPieChart("signMain", signArr, color, true);
  151. var completeChart = drawPieChart("completeMain", signTaskArr, color, true);
  152. var renewChart = drawPieChart("renewMain", renewArr, color, true);
  153. window.onresize = function() {
  154. signChart.resize();
  155. completeChart.resize();
  156. renewChart.resize();
  157. }
  158. }else{
  159. console.log(res.msg);
  160. }
  161. })
  162. }
  163. function formatRate(str){
  164. var val = parseFloat(str);
  165. return val.toFixed(2)+"%";
  166. }