home.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. },
  94. watch: {
  95. selectedRole: function(val) {
  96. var selected = _.findWhere(this.roles, {
  97. code: val
  98. });
  99. window.localStorage.setItem("selectedRole", JSON.stringify(selected));
  100. getSignData(this);
  101. }
  102. }
  103. })
  104. function getSignData(vm){
  105. var code = vm.selectedRole,
  106. now = new Date(),
  107. params = {
  108. area: code,
  109. level: code == '350200' ? 4 : code.length == 6 ? 3 : 2,
  110. endDate: now.format("yyyy-MM-dd")
  111. };
  112. statisticAPI.getSignInfo(params).then(function(res){
  113. if(res.status == 200){
  114. var data = res.data;
  115. vm.signRateData = {
  116. signTask: {
  117. text: formatRate(data.signTaskRate.rate),
  118. rate: '0.00',
  119. sign: data.signTaskRate.sign,
  120. people: data.signTaskRate.people
  121. },
  122. sign: {
  123. text: formatRate(data.signRate.rate),
  124. rate: '0.00',
  125. sign: data.signRate.sign,
  126. people: data.signRate.people
  127. },
  128. renew: {
  129. text: data.renewRange,
  130. rate: '0.00',
  131. sign: data.renew.split("/")[0],
  132. people: data.renew.split("/")[1]
  133. }
  134. }
  135. var signArr = [
  136. {name: "签约数", value: data.signRate.sign},
  137. {name: "未签约数", value: data.signRate.people - data.signRate.sign},
  138. ],
  139. signTaskArr = [
  140. {name: "签约数", value: data.signTaskRate.sign},
  141. {name: "未达标数", value: data.signTaskRate.people - data.signTaskRate.sign}
  142. ],
  143. val = data.renew.split("/")[1] - data.renew.split("/")[0],
  144. renewArr = [
  145. {name: "续签数", value: data.renew.split("/")[0]},
  146. {name: "未达标数", value: val<0 ? 0 : val}
  147. ],
  148. color = ['#12b7f5', '#EBEBF5'];
  149. var signChart = drawPieChart("signMain", signArr, color, true);
  150. var completeChart = drawPieChart("completeMain", signTaskArr, color, true);
  151. var renewChart = drawPieChart("renewMain", renewArr, color, true);
  152. window.onresize = function() {
  153. signChart.resize();
  154. completeChart.resize();
  155. renewChart.resize();
  156. }
  157. }else{
  158. console.log(res.msg);
  159. }
  160. })
  161. }
  162. function formatRate(str){
  163. var val = parseFloat(str);
  164. return val.toFixed(2)+"%";
  165. }