service_formCtrl.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. 'use strict';
  2. app.controller('service_formCtrl', ["$scope", "$rootScope", "$state", "$timeout", "$interval", "$http", "$cookieStore", "SweetAlert", "Restangular", "api_report", "api_statistic", "moment", 'api_user_data','api_event_form', function ($scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, SweetAlert, Restangular, api_report, api_statistic, moment, api_user_data, api_event_form) {
  3. //默认显示综合统计
  4. $scope.tap = 'ZHTJ';
  5. //默认显示上一周
  6. $scope.searchstate = 'none';
  7. //日期选择
  8. $scope.nowtimes = moment().format('YYYY-MM-DD')//当前日期;
  9. //上周
  10. $scope.week = function () {
  11. $scope.searchstate = "week";
  12. var weeks = new Date().getDay();
  13. $scope.starttimesModel = moment(new Date().getTime() - 86400000 * (weeks + 6)).format('YYYY-MM-DD');
  14. $scope.endtimesModel = moment(new Date().getTime() - 86400000 * (weeks)).format('YYYY-MM-DD');
  15. }
  16. //上月
  17. $scope.month = function () {
  18. $scope.searchstate = "month";
  19. $scope.starttimesModel = moment().startOf('month').add(-1, 'M').format('YYYY-MM-DD');
  20. $scope.endtimesModel = moment().endOf('month').add(-1, 'M').format('YYYY-MM-DD');
  21. }
  22. //去年
  23. $scope.year = function () {
  24. $scope.searchstate = "year";
  25. $scope.starttimesModel = moment().startOf('year').add(-1, 'y').format('YYYY-MM-DD');
  26. $scope.endtimesModel = moment().endOf('year').add(-1, 'y').format('YYYY-MM-DD');
  27. }
  28. //近N日
  29. $scope.day = function (num) {
  30. num = num > 1 ? num : 1;
  31. $scope.searchstate = "none";
  32. $scope.starttimesModel = moment().subtract(num, "days").format("YYYY-MM-DD");
  33. $scope.endtimesModel = moment().subtract(1, "days").format("YYYY-MM-DD");
  34. }
  35. //默认显示最近7天
  36. $scope.day(7);
  37. //选择上一周,上个月,去年
  38. $scope.chooseDate = function (date) {
  39. switch (date) {
  40. case 'week':
  41. $scope.week();
  42. break;
  43. case 'month':
  44. $scope.month();
  45. break;
  46. case 'year':
  47. $scope.year();
  48. break;
  49. }
  50. };
  51. /**
  52. *日历
  53. */
  54. //打开开始日期选择框
  55. $scope.startOpen = function ($event) {
  56. $event.preventDefault();
  57. $event.stopPropagation();
  58. $scope.endOpened = false;
  59. $scope.startOpened = !$scope.startOpened;
  60. };
  61. //打开结束日期选择框
  62. $scope.endOpen = function ($event) {
  63. $event.preventDefault();
  64. $event.stopPropagation();
  65. $scope.startOpened = false;
  66. $scope.endOpened = !$scope.endOpened;
  67. };
  68. //重置
  69. $scope.reload = function(){
  70. $scope.day(7);
  71. $scope.searchstate = 'none';
  72. $scope.sortActive = 'totaltop';
  73. $scope.name = 'total';//表格排序,字段名称
  74. $scope.type = 'desc';//表格排序,排序方式desc,asc
  75. $scope.direction = 'top';//箭头方向 top,bottom
  76. switch ($scope.tap) {
  77. case 'ZHTJ'://综合统计
  78. $scope.mdxquery('total', 'desc');
  79. break;
  80. case 'DHTJ'://电话统计
  81. $scope.mdxquery('total', 'desc');
  82. break;
  83. case 'WEB'://微信/WEB统计
  84. $scope.mdxquery('total', 'desc');
  85. break;
  86. case 'DHLYTJ'://电话留言统计
  87. $scope.mdxquery('total', 'desc');
  88. break;
  89. }
  90. };
  91. //选择类型,综合统计,电话统计,微信/WEB统计,电话留言统计
  92. $scope.active = function (name) {
  93. $scope.tap = name;
  94. $scope.reload();
  95. };
  96. //综合统计,无限滚动加载
  97. $scope.topEndComplete = function(){
  98. console.log('滚动');
  99. };
  100. // 请求人
  101. // api_user_data.fetchDataList('requester', {
  102. // "idx": 0,
  103. // "sum": 10
  104. // }).then(function (response) {
  105. // if (response) {
  106. // if (response.status = 200) {
  107. // $scope.requester = response.list;
  108. // }
  109. // }
  110. // })
  111. //表格排序------------------------------------------------
  112. $scope.sortActive = '';//表格排序,箭头高亮选中状态
  113. $scope.name = '';//表格排序,字段名称
  114. $scope.type = '';//表格排序,排序方式desc,asc
  115. $scope.direction = '';//箭头方向 top,bottom
  116. /**
  117. * 表格排序
  118. *
  119. * @param {string} name 字段名称
  120. * @param {string} type 排序方式desc,asc
  121. * @param {string} direction 箭头方向 top,bottom
  122. */
  123. $scope.tableSort = function (name) {
  124. if($scope.name == name){
  125. $scope.type = $scope.type == 'desc'?'asc':'desc';
  126. $scope.direction = $scope.direction == 'top'?'bottom':'top';
  127. }else{
  128. $scope.type = 'desc';
  129. $scope.direction = 'top';
  130. }
  131. $scope.name = name;
  132. $scope.sortActive = name + $scope.direction;
  133. $scope.mdxquery(name, $scope.type);
  134. };
  135. $scope.isArrays = function (arr) {
  136. return Array.isArray(arr);
  137. };
  138. //综合统计
  139. $scope.zhtj_list = null;//表格列表
  140. $scope.zhtj_req_total = 0;//请求总数
  141. $scope.zhtj_req_phone = 0;//请求电话总数
  142. $scope.zhtj_req_wxweb = 0;//请求微信/web总数
  143. $scope.zhtj_req_msg = 0;//请求电话留言总数
  144. $scope.zhtj_req_desk = 0;//请求柜台总数
  145. $scope.zhtj_trans_total = 0;//工单转换总数
  146. $scope.zhtj_p_total = 0;//工单转换直接处理数
  147. $scope.zhtj_unp_total = 0;//工单转换处理工单数
  148. //电话统计
  149. $scope.dhtj_list = null;//表格列表
  150. $scope.dhtj_req_total = 0;//来电总数
  151. $scope.dhtj_req_answer = 0;//接听数量
  152. $scope.dhtj_req_miss = 0;//未接数量
  153. $scope.dhtj_p_total = 0;//电话建单总数
  154. $scope.dhtj_p_phone = 0;//直接解决
  155. $scope.dhtj_unp_phone = 0;//派单数量
  156. //微信/WEB统计
  157. $scope.web_list = null;//表格列表
  158. $scope.web_req_total = 0;//微信/WEB报修总数
  159. $scope.web_req_trans = 0;//转换数量
  160. $scope.web_req_reject = 0;//未转换数量
  161. $scope.web_trans_total = 0;//微信/WEB转换总数
  162. $scope.web_p_total = 0;//直接解决
  163. $scope.web_unp_total = 0;//派单
  164. //电话留言统计
  165. $scope.dhlytj_list = null;//表格列表
  166. $scope.dhlytj_req_total = 0;//电话留言总数
  167. $scope.dhlytj_req_trans = 0;//建单总数
  168. $scope.dhlytj_req_reject = 0;//不受理总数
  169. $scope.dhlytj_trans_total = 0;//电话留言转换总数
  170. $scope.dhlytj_p_total = 0;//直接解决总数
  171. $scope.dhlytj_unp_total = 0;//派单总数
  172. /**
  173. *
  174. *
  175. * @param {string} name 排序字段
  176. * @param {string} type 排序方式 desc,asc
  177. */
  178. $scope.mdxquery = function (name, type) {
  179. if (!name) {
  180. // name = $scope.tap == 'ZHTJ' ? 'accdate' : 'sum';
  181. name = 'total';
  182. }
  183. type = type || 'desc';
  184. switch ($scope.tap) {
  185. case 'ZHTJ'://综合统计
  186. $scope.zhtj_list = null;
  187. // 请求列表
  188. api_event_form.fetchZhtjList({
  189. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  190. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  191. "sortData": name,
  192. "sortType": type
  193. }).then(function (res) {
  194. if (res.stats == 200) {
  195. $scope.zhtj_list = res.dataList || [];//表格列表
  196. $scope.zhtj_req_total = res.title.req_total;//请求总数
  197. $scope.zhtj_req_phone = res.title.req_phone;//请求电话总数
  198. $scope.zhtj_req_wxweb = res.title.req_wxweb;//请求微信/web总数
  199. $scope.zhtj_req_msg = res.title.req_msg;//请求电话留言总数
  200. $scope.zhtj_req_desk = res.title.req_desk;//请求柜台总数
  201. $scope.zhtj_trans_total = res.title.trans_total;//工单转换总数
  202. $scope.zhtj_p_total = res.title.p_total;//工单转换直接处理数
  203. $scope.zhtj_unp_total = res.title.unp_total;//工单转换处理工单数
  204. }
  205. })
  206. break;
  207. case 'DHTJ'://电话统计
  208. $scope.dhtj_list = null;
  209. // 请求列表
  210. api_event_form.fetchDhtjList({
  211. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  212. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  213. "sortData": name,
  214. "sortType": type
  215. }).then(function (res) {
  216. if (res.stats == 200) {
  217. $scope.dhtj_list = res.dataList || [];//表格列表
  218. $scope.dhtj_req_total = res.title.req_total;//来电总数
  219. $scope.dhtj_req_answer = res.title.req_answer;//接听数量
  220. $scope.dhtj_req_miss = res.title.req_miss;//未接数量
  221. $scope.dhtj_p_total = res.title.p_total;//电话建单总数
  222. $scope.dhtj_p_phone = res.title.p_phone;//直接解决
  223. $scope.dhtj_unp_phone = res.title.unp_phone;//派单数量
  224. }
  225. })
  226. break;
  227. case 'WEB'://微信/WEB统计
  228. $scope.web_list = null;
  229. // 请求列表
  230. api_event_form.fetchWebList({
  231. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  232. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  233. "sortData": name,
  234. "sortType": type
  235. }).then(function (res) {
  236. if (res.stats == 200) {
  237. $scope.web_list = res.dataList || [];//表格列表
  238. $scope.web_req_total = res.title.req_total;//微信/WEB报修总数
  239. $scope.web_req_trans = res.title.req_trans;//转换数量
  240. $scope.web_req_reject = res.title.req_reject;//未转换数量
  241. $scope.web_trans_total = res.title.trans_total;//微信/WEB转换总数
  242. $scope.web_p_total = res.title.p_total;//直接解决
  243. $scope.web_unp_total = res.title.unp_total;//派单
  244. }
  245. })
  246. break;
  247. case 'DHLYTJ'://电话留言统计
  248. $scope.dhlytj_list = null;
  249. // 请求列表
  250. api_event_form.fetchDhlytjList({
  251. "startTime": moment($scope.starttimesModel).format('YYYY-MM-DD'),
  252. "endTime": moment($scope.endtimesModel).format('YYYY-MM-DD'),
  253. "sortData": name,
  254. "sortType": type
  255. }).then(function (res) {
  256. if (res.stats == 200) {
  257. $scope.dhlytj_list = res.dataList || [];//表格列表
  258. $scope.dhlytj_req_total = res.title.req_total;//电话留言总数
  259. $scope.dhlytj_req_trans = res.title.req_trans;//建单总数
  260. $scope.dhlytj_req_reject = res.title.req_reject;//不受理总数
  261. $scope.dhlytj_trans_total = res.title.trans_total;//电话留言转换总数
  262. $scope.dhlytj_p_total = res.title.p_total;//直接解决总数
  263. $scope.dhlytj_unp_total = res.title.unp_total;//派单总数
  264. }
  265. })
  266. break;
  267. }
  268. };
  269. //初始化
  270. $scope.mdxquery('total', 'desc');
  271. $scope.sortActive = 'totaltop';
  272. $scope.name = 'total';//表格排序,字段名称
  273. $scope.type = 'desc';//表格排序,排序方式desc,asc
  274. $scope.direction = 'top';//箭头方向 top,bottom
  275. }])