qualifications-analysis.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. defaultValue: ['00:00:00', '23:59:59'],
  22. pickerOptions: {
  23. shortcuts: [{
  24. text: '最近一周',
  25. onClick: function(picker) {
  26. var end = new Date();
  27. var start = new Date();
  28. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  29. picker.$emit('pick', [start, end]);
  30. }
  31. }, {
  32. text: '最近一个月',
  33. onClick: function(picker) {
  34. var end = new Date();
  35. var start = new Date();
  36. start.setMonth(start.getMonth() - 1);
  37. picker.$emit('pick', [start, end]);
  38. }
  39. }, {
  40. text: '最近三个月',
  41. onClick: function(picker) {
  42. var end = new Date();
  43. var start = new Date();
  44. start.setMonth(start.getMonth() - 3);
  45. picker.$emit('pick', [start, end]);
  46. },
  47. }, {
  48. text: '最近半年',
  49. onClick: function(picker) {
  50. var end = new Date();
  51. var start = new Date();
  52. start.setMonth(start.getMonth() - 6);
  53. picker.$emit('pick', [start, end]);
  54. },
  55. }, {
  56. text: '最近一年',
  57. onClick: function(picker) {
  58. var end = new Date();
  59. var start = new Date();
  60. start.setFullYear(start.getFullYear() - 1);
  61. picker.$emit('pick', [start, end]);
  62. },
  63. }],
  64. disabledDate: function(d) {
  65. return d > new Date();
  66. }
  67. }
  68. },
  69. components: {
  70. vuedals: Vuedals.Component
  71. },
  72. mounted: function() {
  73. var vm = this
  74. //初始化时间
  75. var end = new Date();
  76. var start = new Date();
  77. start.setFullYear(start.getFullYear() - 1);
  78. vm.dateValue = [start, end]
  79. vm.initData()
  80. // vm.getDistrict()
  81. //初始化数据
  82. $("#main").removeClass("c-hide");
  83. //监听后退按钮的操作
  84. EventBus.$on("back-click", function(arg) {
  85. history.go(-1);
  86. });
  87. //监听页面刷新
  88. EventBus.$on("refresh-click", function(arg) {
  89. alert("刷新")
  90. vm.initData()
  91. });
  92. window.onresize = function() {
  93. }
  94. },
  95. methods: {
  96. initData: function() {
  97. var vm=this
  98. var startDate,endDate
  99. if(typeof(vm.dateValue[0])!="string"){
  100. startDate=vm.dateValue[0].format("yyyy-MM-dd")
  101. endDate=vm.dateValue[1].format("yyyy-MM-dd")
  102. }else{
  103. startDate=vm.dateValue[0]
  104. endDate=vm.dateValue[1]
  105. }
  106. var params={
  107. userAgent:localStorage.getItem('wlyyAgentForDoc'),
  108. area:vm.valueArea,startDate:startDate,endDate:endDate,
  109. }
  110. statisticAPI.doorQualificationAnalyze(params).then(function(res) {
  111. if(res.status == 200) {
  112. vm.tableData=res.data
  113. util.treeTableXcode(vm.tableData);
  114. } else {
  115. vm.$message.error(res.msg)
  116. }
  117. })
  118. },
  119. changeDateValue: function() {
  120. alert(JSON.stringify(this.dateValue))
  121. },
  122. getDistrict: function() {
  123. var vm=this
  124. var params={
  125. type:3,code:"350200"
  126. }
  127. homeAPI.getDistrict(params).then(function(res) {
  128. if(res.status == 200) {
  129. vm.optionsArea=res.list
  130. vm.valueArea=vm.optionsArea[0].code
  131. vm.initData()
  132. } else {
  133. vm.$message.error(res.msg)
  134. }
  135. })
  136. },
  137. exportData: function() {
  138. var vm=this
  139. var startDate,endDate
  140. if(typeof(vm.dateValue[0])!="string"){
  141. startDate=vm.dateValue[0].format("yyyy-MM-dd")
  142. endDate=vm.dateValue[1].format("yyyy-MM-dd")
  143. }else{
  144. startDate=vm.dateValue[0]
  145. endDate=vm.dateValue[1]
  146. }
  147. var params={
  148. userAgent:localStorage.getItem('wlyyAgentForDoc'),
  149. area:vm.valueArea,startDate:startDate,endDate:endDate,
  150. }
  151. // var str="http://192.168.131.24:8082/doctor/statisticAnalyze/doorQualificationAnalyzeExport?area=350203&startDate=2018-03-25&endDate=2019-03-25"
  152. var str = statisticAPI.doorQualificationAnalyzeExport+"?area="+vm.valueArea+"&startDate="+startDate+"&endDate="+endDate;
  153. window.open(str, "接收包数据导出")//导出数据
  154. },
  155. treeClick: function(item, index) {
  156. if(item.open) {
  157. this.collapse(item, index);
  158. } else {
  159. this.expand(item, index);
  160. }
  161. },
  162. expand: function(item, index) {
  163. if(!item.children) {
  164. return index;
  165. }
  166. //展开
  167. for(var i = 0; item.children && i < item.children.length; i++) {
  168. var child = item.children[i];
  169. this.tableData.splice(++index, 0, child);
  170. if(child.children && child.children.length > 0 && child.open) {
  171. index = this.expand(child, index);
  172. }
  173. }
  174. item.open = true;
  175. return index;
  176. },
  177. collapse: function(item, index) {
  178. if(!item.children) {
  179. return index;
  180. }
  181. //收缩
  182. item.open = false;
  183. var len = 1;
  184. for(var i = index + 1; i < this.tableData.length - 1; i++) {
  185. var xcode = this.tableData[i].xcode;
  186. if(xcode.startsWith(item.xcode + "-")) {
  187. len++;
  188. } else {
  189. break;
  190. }
  191. }
  192. this.tableData.splice(index + 1, len);
  193. }
  194. }
  195. });