qualifications-analysis.js 4.1 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. dateValue: [],
  21. pickerOptions: {
  22. disabledDate: function(d) {
  23. return d > new Date();
  24. }
  25. },
  26. isloading:false, //加载中
  27. },
  28. components: {
  29. vuedals: Vuedals.Component
  30. },
  31. mounted: function() {
  32. var vm = this
  33. //初始化时间
  34. var end = new Date();
  35. var start = new Date();
  36. start.setDate(1)
  37. vm.dateValue = [start.format("yyyy-MM-dd"), end.format("yyyy-MM-dd")]
  38. vm.initData()
  39. // vm.getDistrict()
  40. //初始化数据
  41. $("#main").removeClass("c-hide");
  42. //监听后退按钮的操作
  43. EventBus.$on("back-click", function(arg) {
  44. history.go(-1);
  45. });
  46. //监听页面刷新
  47. EventBus.$on("refresh-click", function(arg) {
  48. alert("刷新")
  49. vm.initData()
  50. });
  51. window.onresize = function() {
  52. }
  53. },
  54. methods: {
  55. initData: function() {
  56. var vm=this
  57. var startDate,endDate
  58. if(vm.dateValue[0]>vm.dateValue[1]){
  59. vm.$message.warning("开始时间应小于结束时间")
  60. return false
  61. }
  62. vm.isloading=true
  63. startDate=vm.dateValue[0]
  64. endDate=vm.dateValue[1]
  65. var params={
  66. userAgent:localStorage.getItem('wlyyAgentForDoc'),
  67. area:vm.valueArea,startDate:startDate,endDate:endDate,
  68. }
  69. statisticAPI.doorQualificationAnalyze(params).then(function(res) {
  70. vm.isloading=false
  71. if(res.status == 200) {
  72. vm.tableData=res.data
  73. util.treeTableXcode(vm.tableData);
  74. } else {
  75. vm.$message.error(res.msg)
  76. }
  77. })
  78. },
  79. changeDateValue: function() {
  80. alert(JSON.stringify(this.dateValue))
  81. },
  82. getDistrict: function() {
  83. var vm=this
  84. var params={
  85. type:3,code:"350200"
  86. }
  87. homeAPI.getDistrict(params).then(function(res) {
  88. if(res.status == 200) {
  89. vm.optionsArea=res.list
  90. vm.valueArea=vm.optionsArea[0].code
  91. vm.initData()
  92. } else {
  93. vm.$message.error(res.msg)
  94. }
  95. })
  96. },
  97. exportData: function() {
  98. var vm=this
  99. var startDate,endDate
  100. if(typeof(vm.dateValue[0])!="string"){
  101. startDate=vm.dateValue[0].format("yyyy-MM-dd")
  102. endDate=vm.dateValue[1].format("yyyy-MM-dd")
  103. }else{
  104. startDate=vm.dateValue[0]
  105. endDate=vm.dateValue[1]
  106. }
  107. var params={
  108. userAgent:localStorage.getItem('wlyyAgentForDoc'),
  109. area:vm.valueArea,startDate:startDate,endDate:endDate,
  110. }
  111. // var str="http://192.168.131.24:8082/doctor/statisticAnalyze/doorQualificationAnalyzeExport?area=350203&startDate=2018-03-25&endDate=2019-03-25"
  112. var str = statisticAPI.doorQualificationAnalyzeExport+"?area="+vm.valueArea+"&startDate="+startDate+"&endDate="+endDate;
  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. });