complain.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>用户统计</title>
  8. <link rel="stylesheet" href="/static/antv/f2.style.css" />
  9. <script type="text/javascript" src="/static/jquery-2.2.4.min.js"></script>
  10. <script src="/static/antv/f2.min.js"></script>
  11. <style>
  12. html,body {
  13. margin: 0;
  14. padding: 0;
  15. overflow-y: scroll;
  16. -webkit-overflow-scrolling: touch;
  17. background: #f1f1f1;
  18. }
  19. .chart-wrapper {
  20. margin: 10px;
  21. border-radius: 10px;
  22. }
  23. ul {
  24. margin: 0;
  25. padding: 0;
  26. }
  27. .nav-tabs>li>a {
  28. margin-right: 0;
  29. border-radius: 0;
  30. }
  31. a {
  32. text-align: center;
  33. font-size: 16px;
  34. font-weight:bold;
  35. color: #999;
  36. text-decoration: none;
  37. }
  38. .daily-record {
  39. margin: 0 10px;
  40. background-color: #fff;
  41. border-radius: 10px;
  42. }
  43. .record-data {
  44. display: flex;
  45. display: -webkit-flex;
  46. justify-content: space-between;
  47. align-items: center;
  48. height: 7vh;
  49. }
  50. .line {
  51. margin: 0 15px;
  52. height: 1px;
  53. background-color: #CCCCCC;
  54. }
  55. .daily-title, .daily-nums {
  56. display: inline;
  57. font-size: 17px;
  58. font-weight: 500;
  59. }
  60. .daily-title {
  61. margin-left: 25px;
  62. display: flex;
  63. display: -webkit-flex;
  64. align-items: center;
  65. }
  66. .daily-nums {
  67. margin-right: 25px;
  68. color:rgba(153,153,153,1);
  69. }
  70. .select-tab {
  71. margin: 10px 10px 0;
  72. border-radius: 10px;
  73. background: #fff;
  74. }
  75. .nav {
  76. display: flex;
  77. display: -webkit-flex;
  78. justify-content: center;
  79. -webkit-justify-content: center;
  80. align-items: center;
  81. border:1px solid #148d8f;
  82. border-radius:5px;
  83. list-style: none;
  84. }
  85. .nav>li {
  86. width: 100%;
  87. flex: 1;
  88. text-align: center;
  89. display: block;
  90. }
  91. .nav-tabs>li.active>a {
  92. line-height: 2;
  93. font-size: 16px;
  94. color: #fff;
  95. font-weight: 500;
  96. cursor: default;
  97. background-color: #148d8f;
  98. }
  99. .nav-tabs>li>a {
  100. line-height: 2;
  101. font-size: 16px;
  102. color: #999999;
  103. font-weight: 500;
  104. }
  105. a {
  106. display: block;
  107. text-decoration: none;
  108. }
  109. </style>
  110. </head>
  111. <body>
  112. <div class="select-tab">
  113. <ul class="nav nav-tabs">
  114. <li {eq name="type" value="0"}class="active"{/eq}>
  115. <a href="{:url('complain',['type'=>0,'orgId'=>$orgId])}">周统计</a>
  116. </li>
  117. <li {eq name="type" value="1"}class="active"{/eq}>
  118. <a href="{:url('complain',['type'=>1,'orgId'=>$orgId])}">月统计</a>
  119. </li>
  120. <li {eq name="type" value="2"}class="active"{/eq}>
  121. <a href="{:url('complain',['type'=>2,'orgId'=>$orgId])}">总统计</a>
  122. </li>
  123. </ul>
  124. </div>
  125. <div class="chart-wrapper">
  126. <canvas id="mountNode" style="width: 100%;"></canvas>
  127. </div>
  128. <div class="daily-record">
  129. <div class="record-data first" onclick="complainList(this)" data-orgId="{$orgId}" data-status="-1" data-type="{$type}" >
  130. <span class="daily-title">历史总投诉数</span>
  131. <span class="daily-nums">{$count}</span>
  132. </div>
  133. {foreach $list as $k=>$v}
  134. <div class="line"></div>
  135. <div class="record-data" onclick="complainList(this)" data-orgId="{$orgId}" data-status="{$v['status']}" data-type="{$type}">
  136. <span class="daily-title"><span style="display: inline-block;margin-right:10px;width: 6px;height: 6px;border-radius:5px;"></span>{$v['name']}</span>
  137. <span class="daily-nums">{$v['cost']}</span>
  138. </div>
  139. {/foreach}
  140. </div>
  141. <script>
  142. var Util = F2.Util;
  143. var G = F2.G;
  144. var Group = G.Group;
  145. function drawLabel(shape, coord, canvas) {
  146. var center = coord.center;
  147. var origin = shape.get('origin');
  148. var points = origin.points;
  149. var x1 = (points[2].x - points[1].x) * 0.75 + points[1].x;
  150. var x2 = (points[2].x - points[1].x) * 1.8 + points[1].x;
  151. var y = (points[0].y + points[1].y) / 2;
  152. var point1 = coord.convertPoint({
  153. x: x1,
  154. y: y
  155. });
  156. var point2 = coord.convertPoint({
  157. x: x2,
  158. y: y
  159. });
  160. var group = new Group();
  161. group.addShape('Line', {
  162. attrs: {
  163. x1: point1.x,
  164. y1: point1.y,
  165. x2: point2.x,
  166. y2: point2.y,
  167. lineDash: [0, 2, 2],
  168. stroke: '#808080'
  169. }
  170. });
  171. var text = group.addShape('Text', {
  172. attrs: {
  173. x: point2.x,
  174. y: point2.y,
  175. text: origin._origin.type + ' ' + origin._origin.cost,
  176. fill: '#808080',
  177. textAlign: 'start',
  178. textBaseline: 'bottom'
  179. }
  180. });
  181. var textWidth = text.getBBox().width;
  182. var baseLine = group.addShape('Line', {
  183. attrs: {
  184. x1: point2.x,
  185. y1: point2.y,
  186. x2: point2.x,
  187. y2: point2.y,
  188. stroke: '#808080'
  189. }
  190. });
  191. if (point2.x > center.x) {
  192. baseLine.attr('x2', point2.x + textWidth);
  193. } else if (point2.x < center.x) {
  194. text.attr('textAlign', 'end');
  195. baseLine.attr('x2', point2.x - textWidth);
  196. } else {
  197. text.attr('textAlign', 'center');
  198. text.attr('textBaseline', 'top');
  199. }
  200. canvas.add(group);
  201. shape.label = group;
  202. }
  203. var data = {:json_encode($list)};
  204. var sum = 0;
  205. data.map(function(obj) {
  206. sum += obj.cost;
  207. });
  208. var chart = new F2.Chart({
  209. id: 'mountNode',
  210. pixelRatio: window.devicePixelRatio
  211. });
  212. chart.source(data);
  213. var lastClickedShape;
  214. chart.legend({
  215. position: 'bottom',
  216. offsetY: -5,
  217. marker: 'circle',
  218. align: 'center',
  219. onClick: function onClick(ev) {
  220. var clickedItem = ev.clickedItem;
  221. var dataValue = clickedItem.get('dataValue');
  222. var canvas = chart.get('canvas');
  223. var coord = chart.get('coord');
  224. var geom = chart.get('geoms')[0];
  225. var container = geom.get('container');
  226. var shapes = geom.get('shapes'); // 只有带精细动画的 geom 才有 shapes 这个属性
  227. var clickedShape;
  228. // 找到被点击的 shape
  229. Util.each(shapes, function(shape) {
  230. var origin = shape.get('origin');
  231. if (origin && origin._origin.type === dataValue) {
  232. clickedShape = shape;
  233. return false;
  234. }
  235. });
  236. if (lastClickedShape) {
  237. lastClickedShape.animate().to({
  238. attrs: {
  239. lineWidth: 0
  240. },
  241. duration: 200
  242. }).onStart(function() {
  243. if (lastClickedShape.label) {
  244. lastClickedShape.label.hide();
  245. }
  246. }).onEnd(function() {
  247. lastClickedShape.set('selected', false);
  248. });
  249. }
  250. if (clickedShape.get('selected')) {
  251. clickedShape.animate().to({
  252. attrs: {
  253. lineWidth: 0
  254. },
  255. duration: 200
  256. }).onStart(function() {
  257. if (clickedShape.label) {
  258. clickedShape.label.hide();
  259. }
  260. }).onEnd(function() {
  261. clickedShape.set('selected', false);
  262. });
  263. } else {
  264. var color = clickedShape.attr('fill');
  265. clickedShape.animate().to({
  266. attrs: {
  267. lineWidth: 5
  268. },
  269. duration: 350,
  270. easing: 'bounceOut'
  271. }).onStart(function() {
  272. clickedShape.attr('stroke', color);
  273. clickedShape.set('zIndex', 1);
  274. container.sort();
  275. }).onEnd(function() {
  276. clickedShape.set('selected', true);
  277. clickedShape.set('zIndex', 0);
  278. container.sort();
  279. lastClickedShape = clickedShape;
  280. if (clickedShape.label) {
  281. clickedShape.label.show();
  282. } else {
  283. drawLabel(clickedShape, coord, canvas);
  284. }
  285. canvas.draw();
  286. });
  287. }
  288. }
  289. });
  290. chart.coord('polar', {
  291. transposed: true,
  292. innerRadius: 0.8,
  293. radius: 1
  294. });
  295. chart.axis(false);
  296. chart.tooltip(false);
  297. chart.interval().position('a*cost').color('name', ['#F7B762','#1EC498','#775cff']).adjust('stack');
  298. chart.guide().html({
  299. position: ['50%', '50%'],
  300. html: '<div style="width: 250px;height: 40px;text-align: center;">' + '<div style="font-size: 24px;color:#089875;">{$count}</div>' + '<div style="font-size: 16px;color:#089875;">投诉总数</div>' + '</div>'
  301. });
  302. chart.render();
  303. </script>
  304. </body>
  305. </html>
  306. <script>
  307. function complainList(obj) {
  308. var type = $(obj).attr('data-type');
  309. var orgId = $(obj).attr('data-orgId');
  310. var status = $(obj).attr('data-status');
  311. var url = "{:url('Statistics/complainList')}?type="+type+'&orgId='+orgId+'&status='+status;
  312. window.location.href=url;
  313. }
  314. </script>