header-prompt.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. Vue.component('header-prompt', {
  2. template: '<div class="cb-ebebf5 height-30 lheight-30 pl20 c-f12">\
  3. <span class="c-666">{{areaName}}</span> (\
  4. <span class="c-666">{{jieZhiTime}}</span>)\
  5. <span class="c-12b7f5 ml20 mr20">{{selectDate}}</span>\
  6. <span class="c-12b7f5 mr20">{{dimensionVal}}</span>\
  7. <span v-show="dimensionVal2" class="c-12b7f5">{{dimensionVal2}}</span>\
  8. </div>',
  9. props: [],
  10. data: function() {
  11. return {
  12. areaName:"",
  13. jieZhiTime:"",
  14. selectDate:"",
  15. dimensionVal:"",
  16. dimensionVal2: ""
  17. }
  18. },
  19. mounted: function() {
  20. var vm = this;
  21. getJieZhiTime(vm);
  22. //更新区域名称
  23. EventBus.$on('update-area-name', function(arg) {
  24. vm.areaName = arg.areaName;
  25. });
  26. //更新统计时间
  27. EventBus.$on('update-statistics-time', function(arg) {
  28. getJieZhiTime(vm);
  29. });
  30. //更新年份
  31. EventBus.$on('update-statistics-year', function(arg) {
  32. vm.selectDate = arg.selectDate;
  33. });
  34. //更新维度名称
  35. EventBus.$on('update-dimension-name', function(arg) {
  36. vm.dimensionVal = arg.dimensionVal;
  37. });
  38. //更新维度2名称
  39. EventBus.$on('update-dimension2-name', function(arg){
  40. vm.dimensionVal2 = arg.dimensionVal2;
  41. });
  42. //更新所有信息
  43. EventBus.$on('update-all-prompt-info', function(arg) {
  44. vm.areaName = arg.areaName;
  45. getJieZhiTime(vm);
  46. vm.selectDate = arg.selectDate;
  47. vm.dimensionVal = arg.dimensionVal;
  48. });
  49. },
  50. methods: {
  51. }
  52. })
  53. //获取统计时间
  54. function getJieZhiTime(vm){
  55. statisticAPI.statisticsTime({}).then(function(res) {
  56. if(res.status=="200"){
  57. var date = (res.data && res.data.substring(11,16)) || "";
  58. vm.jieZhiTime = date;
  59. }
  60. })
  61. }