response-speed-analysis.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. var reqList = [];
  2. var util = {};
  3. util.treeTableXcode = function(data, xcode) {
  4. xcode = xcode || "";
  5. for(var i = 0; i < data.length; i++) {
  6. var item = data[i];
  7. item.xcode = xcode + i;
  8. if(item.children && item.children.length > 0) {
  9. util.treeTableXcode(item.children, item.xcode + "-");
  10. }
  11. }
  12. };
  13. Vue.use(Vuedals.default);
  14. new Vue({
  15. el: "#main",
  16. data: {
  17. tableData: [],
  18. valueArea: "350203",
  19. optionsArea: [{code:"350203",name:"思明区"}],
  20. roleType:"1", //1、调度员,2、服务医生
  21. dateValue: [],
  22. pickerOptions: {
  23. disabledDate: function(d) {
  24. return d > new Date();
  25. }
  26. },
  27. isloading:false, //加载中
  28. },
  29. components: {
  30. vuedals: Vuedals.Component
  31. },
  32. mounted: function() {
  33. var vm = this
  34. //初始化时间
  35. var end = new Date();
  36. var start = new Date();
  37. start.setDate(1)
  38. vm.dateValue = [start.format("yyyy-MM-dd"), end.format("yyyy-MM-dd")]
  39. //初始化数据
  40. vm.initData()
  41. // vm.getDistrict()
  42. $("#main").removeClass("c-hide");
  43. //监听后退按钮的操作
  44. EventBus.$on("back-click", function(arg) {
  45. history.go(-1);
  46. });
  47. //监听页面刷新
  48. EventBus.$on("refresh-click", function(arg) {
  49. // alert("刷新")
  50. vm.initData()
  51. });
  52. window.onresize = function() {
  53. }
  54. },
  55. methods: {
  56. initData: function() {
  57. var vm=this
  58. var startDate,endDate
  59. if(vm.dateValue[0]>vm.dateValue[1]){
  60. vm.$message.warning("开始时间应小于结束时间")
  61. return false
  62. }
  63. vm.isloading=true
  64. startDate=vm.dateValue[0]
  65. endDate=vm.dateValue[1]
  66. var params={
  67. userAgent:localStorage.getItem('wlyyAgentForDoc'),
  68. area:vm.valueArea,startDate:startDate,endDate:endDate,roleType:vm.roleType
  69. }
  70. statisticAPI.doorResponseAnalyze(params).then(function(res) {
  71. vm.isloading=false
  72. if(res.status == 200) {
  73. vm.tableData=res.data
  74. util.treeTableXcode(vm.tableData);
  75. } else {
  76. vm.$message.error(res.msg)
  77. }
  78. })
  79. },
  80. changeDateValue: function() {
  81. alert(JSON.stringify(this.dateValue))
  82. },
  83. getDistrict: function() {
  84. var vm=this
  85. var params={
  86. type:3,code:"350200"
  87. }
  88. homeAPI.getDistrict(params).then(function(res) {
  89. if(res.status == 200) {
  90. vm.optionsArea=res.list
  91. vm.valueArea=vm.optionsArea[0].code
  92. vm.initData()
  93. } else {
  94. vm.$message.error(res.msg)
  95. }
  96. })
  97. },
  98. exportData: function() {
  99. var vm=this
  100. var startDate,endDate
  101. if(typeof(vm.dateValue[0])!="string"){
  102. startDate=vm.dateValue[0].format("yyyy-MM-dd")
  103. endDate=vm.dateValue[1].format("yyyy-MM-dd")
  104. }else{
  105. startDate=vm.dateValue[0]
  106. endDate=vm.dateValue[1]
  107. }
  108. var params={
  109. userAgent:localStorage.getItem('wlyyAgentForDoc'),
  110. area:vm.valueArea,startDate:startDate,endDate:endDate,
  111. }
  112. var str = statisticAPI.doorResponseAnalyzeExport+"?area="+vm.valueArea+"&startDate="+startDate+"&endDate="+endDate+"&roleType="+vm.roleType;
  113. window.open(str, "接收包数据导出")//导出数据
  114. },
  115. treeClick: function(item, index) {
  116. if(item.open) {
  117. this.collapse(item, index);
  118. } else {
  119. this.expand(item, index);
  120. }
  121. },
  122. expand: function(item, index) {
  123. if(!item.children) {
  124. return index;
  125. }
  126. //展开
  127. for(var i = 0; item.children && i < item.children.length; i++) {
  128. var child = item.children[i];
  129. this.tableData.splice(++index, 0, child);
  130. if(child.children && child.children.length > 0 && child.open) {
  131. index = this.expand(child, index);
  132. }
  133. }
  134. item.open = true;
  135. return index;
  136. },
  137. collapse: function(item, index) {
  138. if(!item.children) {
  139. return index;
  140. }
  141. //收缩
  142. item.open = false;
  143. var len = this.tableData[index].children.length;
  144. this.tableData.splice(index + 1, len);
  145. }
  146. }
  147. });