comprehensive-analysis.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. var reqList = []; //记录请求的参数和url,用于后退时使用
  2. var pieChart1,
  3. pieChart2; //全局设置饼图的对象,window.resize时,触发chart的resize方法
  4. Vue.use(Vuedals.default);
  5. new Vue({
  6. el: "#main",
  7. data: {
  8. appname: "总体分析",
  9. isback: true,
  10. isrefresh: true,
  11. isfilter: true,
  12. isopen: true,
  13. //请求页面所需参数
  14. level: '',
  15. area: '',
  16. areaTitle: '',
  17. index: '3',
  18. selectedDateType: 1,
  19. selectedDateType5:1,
  20. endDate: '',
  21. startDate: '',
  22. lowLevel: '',
  23. chooseYear: '',
  24. userRole: '',
  25. //数据结果
  26. topDatas: {
  27. index_3: 0,
  28. index_4: 0,
  29. index_5: 0,
  30. index_83: 0,
  31. index_103:0,
  32. index_106:0,
  33. index_20: 0,
  34. index_21: 0,
  35. index_27: 0,
  36. index_124: 0,
  37. index_125: 0,
  38. index_86: 0
  39. },
  40. //微信绑定统计数据
  41. wxTotal:{
  42. label: '',
  43. amount1: '', //已缴费人数
  44. amount2: '', //未缴费人数
  45. rate: ''//绑定率
  46. },
  47. isloading:false, //加载中
  48. },
  49. components: {
  50. vuedals: Vuedals.Component
  51. },
  52. methods: {
  53. changeTag: function(val){
  54. this.index = val;
  55. loadData([1,2], this);
  56. //存储请求所带的参数
  57. reqList.push({
  58. level: this.level,
  59. area: this.area,
  60. areaTitle: this.areaTitle,
  61. index: this.index,
  62. endDate: this.endDate,
  63. startDate: this.startDate,
  64. lowLevel: this.lowLevel
  65. })
  66. },
  67. getNewLineData: function(arg){
  68. this.selectedDateType = arg.dateType;
  69. loadData([1], this);
  70. },
  71. getNewLineData5:function(arg){
  72. this.selectedDateType5 = arg.dateType;
  73. getArticleData(this)
  74. },
  75. jumpTip:function(tab){
  76. console.log("mouseenter");
  77. $('#shadow'+tab).css("visibility","visible")
  78. },
  79. leaveTip:function(tab){
  80. $('#shadow'+tab).css("visibility","hidden")
  81. },
  82. getAreaData: function(arg){
  83. //如果level改变,则需要重新加载整个页面的数据,否则只需加载底部区域数据
  84. if(arg.level == this.level){
  85. this.lowLevel = arg.lowLevel;
  86. loadData([2], this);
  87. }else{
  88. this.level = arg.level;
  89. this.lowLevel = arg.lowLevel;
  90. this.area = arg.area;
  91. this.areaTitle = arg.areaTitle;
  92. loadData([0,1,2], this);
  93. }
  94. EventBus.$emit('update-area-name', {areaName: this.areaTitle});
  95. //存储请求所带的参数
  96. reqList.push({
  97. level: this.level,
  98. area: this.area,
  99. areaTitle: this.areaTitle,
  100. index: this.index,
  101. endDate: this.endDate,
  102. startDate: this.startDate,
  103. lowLevel: this.lowLevel,
  104. selectedDateType: this.selectedDateType
  105. })
  106. }
  107. },
  108. mounted: function(){
  109. $(".tip").on('mouseenter', function(){
  110. console.log("mouse enter");
  111. var val = $(this).attr("data-val");
  112. $('#shadow'+val).css("visibility","visible")
  113. })
  114. $(".tip").on('mouseleave', function(){
  115. console.log("mouse leave");
  116. var val = $(this).attr("data-val");
  117. $('#shadow'+val).css("visibility","hidden")
  118. })
  119. //初始化数据
  120. initData(this);
  121. //获得顶部各tab的值
  122. loadData([0,1,2], this); //参数组数表示请求的区域为上中下
  123. //存储请求所带的参数
  124. reqList.push({
  125. level: this.level,
  126. area: this.area,
  127. areaTitle: this.areaTitle,
  128. index: this.index,
  129. endDate: this.endDate,
  130. startDate: this.startDate,
  131. lowLevel: this.lowLevel,
  132. selectedDateType: this.selectedDateType
  133. });
  134. //设置监听器, 监听折线图日期变化
  135. var vm = this;
  136. //监听后退按钮的操作
  137. EventBus.$on("back-click", function(arg){
  138. EventBus.$emit('update-statistics-time', {}); //更新统计时间
  139. if(reqList.length == 1){
  140. history.go(-1);
  141. }
  142. else{
  143. var preInfo = reqList.pop();
  144. var info = reqList[reqList.length - 1];
  145. vm.level = info.level;
  146. vm.area = info.area;
  147. vm.areaTitle = info.areaTitle;
  148. vm.lowLevel = info.lowLevel;
  149. vm.index = info.index;
  150. loadData([0,1,2], vm);
  151. EventBus.$emit('update-area-name', {areaName: vm.areaTitle});
  152. }
  153. });
  154. //监听页面刷新
  155. EventBus.$on("refresh-click", function(arg){
  156. loadData([0,1,2], vm);
  157. });
  158. //弹出筛选框
  159. EventBus.$on('filter-click', function(arg) {
  160. //弹框显示筛选条件
  161. Vuedals.Bus.$emit('new', {
  162. title: '条件筛选',
  163. onClose:function(data){
  164. vm.chooseYear = data.chooseYear;
  165. vm.startDate = getStartDate(vm.chooseYear);
  166. vm.endDate = getEndDate(vm.chooseYear);
  167. //请求参数重置,页面类型重新开始
  168. vm.level = vm.userRole.code == '350200' ? 4 : vm.userRole.code.length == 6 ? 3 : 2;
  169. vm.area = vm.userRole.code;
  170. vm.areaTitle = vm.userRole.name;
  171. EventBus.$emit('update-area-name', {areaName: vm.areaTitle});
  172. vm.selectedDateType = 1;
  173. //然后清空请求列表数组
  174. reqList.splice(0, reqList.length);
  175. loadData([0, 1, 2], vm);//刷新数据
  176. //存储请求所带的参数
  177. reqList.push({
  178. level: vm.level,
  179. area: vm.area,
  180. areaTitle: vm.areaTitle,
  181. index: vm.index,
  182. endDate: vm.endDate,
  183. startDate: vm.startDate,
  184. lowLevel: vm.lowLevel,
  185. selectedDateType: vm.selectedDateType
  186. });
  187. EventBus.$emit('update-statistics-year', {selectDate: vm.chooseYear + "年"});//更新年份
  188. EventBus.$emit('update-statistics-time', {});//更新统计时间
  189. },
  190. component: 'year-filter',
  191. props: {
  192. selectedYear: vm.chooseYear
  193. }
  194. });
  195. });
  196. $("#main").removeClass("c-hide");
  197. window.onresize = function() {
  198. if(pieChart1){
  199. pieChart1.resize();
  200. }
  201. if(pieChart2){
  202. pieChart2.resize();
  203. }
  204. window.lineCharts.resize(); //日周月折线图
  205. }
  206. }
  207. })
  208. function initData(vm){
  209. //获得缓存中缓存的角色权限
  210. var userRole = window.sessionStorage.getItem("selectedRole");
  211. if(!userRole){
  212. return false;
  213. }
  214. vm.userRole = JSON.parse(userRole);
  215. vm.level = vm.userRole.code == '350200' ? 4 : vm.userRole.code.length == 6 ? 3 : 2;
  216. vm.area = vm.userRole.code;
  217. vm.areaTitle = vm.userRole.name;
  218. EventBus.$emit('update-area-name', {areaName: vm.areaTitle});
  219. var now = new Date();
  220. if(now.getMonth() >= 6 || now.getFullYear()>=2023){
  221. vm.chooseYear = now.getFullYear();
  222. }else{
  223. vm.chooseYear = now.getFullYear() - 1;
  224. }
  225. vm.startDate = getStartDate(vm.chooseYear);
  226. vm.endDate = getEndDate(vm.chooseYear);
  227. EventBus.$emit('update-statistics-year', {selectDate: vm.chooseYear + "年"});
  228. }
  229. function initReqParams(vm){
  230. //增量(咨询量3、随访量4、健康教育5、代预约量27),到达量(绑定微信21、绑定设备20)
  231. var url2 = "statistics/interval",
  232. url3 = "statistics/lowlevel_total";
  233. if(vm.index == '20' || vm.index == '21'){
  234. url2 = "statistics/interval_total";
  235. url3 = "statistics/lowlevel_all";
  236. }else if(vm.index == '3'){
  237. url3 = "statistics/lowlevel_total_mesh";
  238. }else if(vm.index == '5'){
  239. url3 = '/statistics/article_lowlevel_total';
  240. }else if(vm.index == '27'){
  241. url3 = '/statistics/lowlevel_all';
  242. }
  243. reqParam = [{
  244. url: url2,
  245. data:{
  246. index: vm.index == '5' ? '5,83' : vm.index == 27 ? '27,124,125' : vm.index,
  247. level: vm.level,
  248. area: vm.area,
  249. startDate: vm.startDate,
  250. endDate: vm.endDate,
  251. interval: vm.selectedDateType
  252. }
  253. },{
  254. url: url3,
  255. data: {
  256. index: (vm.index == '3') ? "3,22" : vm.index,
  257. level: vm.level,
  258. area: vm.area,
  259. sort: 1,
  260. year: vm.chooseYear
  261. }
  262. },{
  263. //如果是微信绑定,则增加置顶展示当面层级的总绑定率及已缴费 未缴费居民数.只针对微信绑定时使用
  264. url: '/statistics/getLevelTotalSingle',
  265. data: {
  266. date: vm.endDate,
  267. level: vm.level,
  268. area: vm.area
  269. }
  270. }];
  271. if(vm.index == '20' || vm.index == '21' || vm.index == '27'){
  272. reqParam[1].data.date = vm.endDate;
  273. }else{
  274. reqParam[1].data.endDate = vm.endDate;
  275. }
  276. if(vm.lowLevel){
  277. reqParam[1].data.lowLevel = vm.lowLevel;
  278. }
  279. return reqParam;
  280. }
  281. function getTopReqParams(index1, vm){
  282. var url = "statistics/total",
  283. data = {
  284. index: index1 == '5' ? '5,83,103,106' : index1,
  285. level: vm.level,
  286. area: vm.area,
  287. year: vm.chooseYear,
  288. endDate: vm.endDate,
  289. startDate: vm.startDate
  290. };
  291. if(index1 == '20' || index1 == '21'){
  292. url = "statistics/index_all";
  293. }
  294. if(index1 == '5'){
  295. url = "/statistics/article_total";
  296. }
  297. return {
  298. url: url,
  299. data: data
  300. };
  301. }
  302. function getTopTagDatas(vm){
  303. var reqs = [],
  304. indexs = ['3', '4', '5', '27', '21', '20','124','125'];
  305. for(i=0; i<indexs.length; i++){
  306. var item = getTopReqParams(indexs[i], vm);
  307. reqs.push(httpRequest.get(item.url, {data: item.data}));
  308. }
  309. Promise.all(reqs).then(function(ress){
  310. for(i=0; i<ress.length; i++){
  311. var res = ress[i];
  312. if(res.status == 200){
  313. for(key in res.data){
  314. vm.topDatas[key] = res.data[key];
  315. if(vm.chooseYear<2019&&(key=="index_124"||key=="index_125")){
  316. vm.topDatas[key]="--"
  317. }
  318. }
  319. }else{
  320. console.log(res.msg);
  321. }
  322. }
  323. })
  324. }
  325. function loadData(loadArr, vm){
  326. if(loadArr.indexOf(0) > -1){
  327. getTopTagDatas(vm);
  328. }
  329. vm.isloading=true
  330. //获取其他请求的参数
  331. var reqParams = initReqParams(vm),
  332. reqPromise = [],
  333. newArr = []; //记录非顶部请求的请求数组
  334. for(i=0; i<loadArr.length; i++){
  335. if(loadArr[i] == 0){
  336. // do nothing
  337. }else{
  338. var j = loadArr[i] - 1;
  339. var param = reqParams[j];
  340. reqPromise.push(httpRequest.get(param.url, {data: param.data}));
  341. newArr.push(loadArr[i]);
  342. }
  343. }
  344. if(vm.index == 21){ //微信绑定的数据需要再请求一个数据
  345. reqPromise.push(httpRequest.get(reqParams[2].url, {data: reqParams[2].data}))
  346. newArr.push(3);
  347. }
  348. if(reqPromise.length > 0){
  349. Promise.all(reqPromise).then(function(ress){
  350. vm.isloading=false
  351. var res2, res3, res4;
  352. for(var i=0; i<newArr.length; i++){
  353. var j = newArr[i] + 1;
  354. if(j == 2){
  355. res2 = ress[i];
  356. }
  357. if(j == 3){
  358. res3 = ress[i];
  359. }
  360. //微信绑定时,多获取一个请求数据
  361. if(j == 4){
  362. res4 = ress[i];
  363. }
  364. }
  365. if(res2){
  366. if(res2.status == 200){
  367. handleSecondPanelData(res2.data, vm);
  368. if(vm.index == '5'){
  369. getArticleData(vm)
  370. var arr = [{
  371. name: '健康文章',
  372. value: vm.topDatas.index_83
  373. },{
  374. name: '健康指导',
  375. value: vm.topDatas.index_5
  376. }];
  377. pieChart2 = drawPieChart('pieChart', arr, ['#ffc800', '#17b3ec']);
  378. }
  379. }else{
  380. console.log(res2.msg);
  381. }
  382. }
  383. if(res3){
  384. if(res3.status == 200){
  385. listHandle(res3.data, vm);
  386. }else{
  387. console.log(res3.msg);
  388. }
  389. }
  390. if(res4){
  391. if(res4.status == 200){
  392. handleWXBindData(res4.data, vm);
  393. }else{
  394. console.log(res4.msg);
  395. }
  396. }
  397. })
  398. }
  399. }
  400. function handleSecondPanelData(data, vm){
  401. var xDatas = [],
  402. yDatas = [],
  403. names = [],
  404. colors = ['#12b7f5', '#cd67fd','#FF9526'],
  405. labels = {'3': '咨询量新增趋势', '4': '随访量新增趋势', '5': '触达人数新增趋势', '20': '绑定设备新增趋势', '21': '绑定微信新增趋势', '27': '代预约量新增趋势'}
  406. index_names = {'index_3': '咨询量', 'index_4': '随访量', 'index_5': '健康指导','index_27':'代预约量','index_21': '绑定微信','index_20': '绑定设备', 'index_83': "健康文章", 'index_124': "代预约等级医院", 'index_125': "代预约社区医院"};
  407. for(var p in data){
  408. names.push(index_names[p]);
  409. if(p == 'index_21' || p == 'index_20' || p == "index_86"){
  410. xData = _.map(data[p].data, function(o){
  411. return o.range;
  412. });
  413. yData = _.map(data[p].data, function(o){
  414. return o.amount;
  415. });
  416. }else{
  417. if(data[p][0].range){
  418. xData = _.map(data[p], function(o){
  419. return o.range;
  420. });
  421. yData = _.map(data[p], function(o){
  422. return o.amount;
  423. });
  424. }else{
  425. if(p=='index_124'||p=='index_125'){
  426. xData=[];yData=[]
  427. _.each(data["index_27"], function(o){
  428. yData.push(0)
  429. xData.push(o.range)
  430. });
  431. }
  432. }
  433. }
  434. // console.log(xData);
  435. xDatas.push(xData);
  436. yDatas.push(yData);
  437. }
  438. EventBus.$emit("draw-line-chart", {
  439. panelName : labels[vm.index],
  440. quotaNames : names,
  441. xData : xDatas[0],
  442. yDatas : yDatas,
  443. colors : colors,
  444. selectedDateType: vm.selectedDateType,
  445. nowlineid : "lineChart"
  446. });
  447. }
  448. function listHandle(data, vm){
  449. for(i in data){
  450. var list = data[i];
  451. var topArr = [];
  452. if(vm.index == "21"){
  453. topArr = soreRank(getKeyValueArr(list, 'bindRate'));
  454. }else if(vm.index == '3'){
  455. topArr = soreRank(getKeyValueArr2(list, 'amount'));
  456. }else if(vm.index == '27'){
  457. topArr = soreRank(getKeyValueArr(list, 'reservationTotalAmount0'));
  458. }else{
  459. topArr = soreRank(getKeyValueArr(list, 'amount'));
  460. }
  461. var arr = _.map(list, function(o, index){
  462. var cols = [o.name];
  463. if(vm.index == '3'){
  464. var amount = o.amount.split(","); // 咨询量, 未回复咨询量
  465. cols.push(amount[0]);
  466. cols.push(amount[1]);
  467. }else if(vm.index == '21'){
  468. cols.push(o.bindRate + '%');
  469. cols.push(o.weChatAmount1);
  470. cols.push(o.weChatAmount0);
  471. }else if(vm.index == '27'){
  472. if(vm.chooseYear<2019){
  473. cols.push("--");
  474. cols.push("--");
  475. }else{
  476. cols.push(o.reservationTotal1Amount0);
  477. cols.push(o.reservationTota2Amount0);
  478. }
  479. cols.push(o.reservationTotalAmount0);
  480. }else{
  481. cols.push(o.amount);
  482. if(vm.index == '5'){
  483. cols.push(o.readNum);
  484. cols.push(o.readRate);
  485. }
  486. }
  487. return {
  488. rank: topArr[index],
  489. code: o.code,
  490. name: o.name,
  491. cols: cols
  492. }
  493. });
  494. var headers = {
  495. '3': ["排名", "咨询量", "未回复"],
  496. '4': ["排名", "随访量"],
  497. '5': ["排名", "总触达人数", "阅读量", "阅读率"],
  498. '20': ["排名", "绑定设备"],
  499. '21': ["排名", "绑定率", "已缴费", "未缴费"],
  500. "27": ["排名", "代预约等级医院", "代预约社区医院", "代预约量"]
  501. };
  502. EventBus.$emit("render-area-data",{
  503. index: vm.index,
  504. level: vm.level,
  505. area: vm.area,
  506. lowLevel: vm.lowLevel,
  507. headers: headers[vm.index],
  508. year:vm.chooseYear,
  509. rows: arr
  510. });
  511. }
  512. }
  513. function handleWXBindData(data, vm){
  514. switch(vm.level){
  515. case 4:
  516. vm.wxTotal.label = "全市概况";
  517. break;
  518. case 3:
  519. vm.wxTotal.label = "全区概况";
  520. break;
  521. case 2:
  522. vm.wxTotal.label = "全社区概况";
  523. break;
  524. }
  525. vm.wxTotal.rate = (data.bindRate || 0) + "%";
  526. vm.wxTotal.amount1 = data.weChatAmount1;
  527. vm.wxTotal.amount2 = data.weChatAmount0;
  528. var arr = [{
  529. name: '已缴费人数',
  530. value: data.weChatAmount1
  531. },{
  532. name: '未缴费人数',
  533. value: data.weChatAmount0
  534. }];
  535. pieChart1 = drawPieChart('pieChart2', arr, ['#17b3ec', '#909090']);
  536. }
  537. /*
  538. * 获取用来排序的字段值,返回数组
  539. * 参数: list - 列表, key - 字段的名称
  540. */
  541. function getKeyValueArr2(list, key){
  542. var arr = [];
  543. for(var k in list){
  544. var item = list[k][key].split(",");
  545. arr.push(item[0]);
  546. }
  547. return arr;
  548. }
  549. //获得健康文章相关的其他的内容
  550. function getArticleData(vm){
  551. vm.isloading=true
  552. var reqss=[],reqs = [{
  553. url: "/statistics/getAppActicleStatisticsData",
  554. data: {startDate: vm.startDate, endDate: vm.endDate, area: vm.area},
  555. reqType: 'get'
  556. }, {
  557. url: "/statistics/getAppActicleTrendStatisticsData",
  558. data: {startDate: vm.startDate, endDate: vm.endDate, area: vm.area},
  559. reqType: 'get'
  560. }];
  561. _.each(reqs,function(item){
  562. reqss.push(httpRequest.get(item.url, {data: item.data}))
  563. })
  564. Promise.all(reqss).then(function(ress){
  565. var res1 = ress[0],
  566. res2 = ress[1];
  567. if(res1.status == 200){
  568. var data1 = res1.data;
  569. $(".article-total-count").text(data1.totalContentCount);
  570. $(".article-send-count").text(data1.totalPushCount);
  571. var per = '',
  572. full = '50%';
  573. if(parseInt(data1.totalContentCount) > parseInt(data1.totalPushCount)){
  574. per = data1.totalPushCount / data1.totalContentCount * 50;
  575. $(".article-bar").css('width', "50%");
  576. $(".send-bar").css('width', per+"%");
  577. }else{
  578. if(data1.totalPushCount != 0){
  579. per = data1.totalContentCount / data1.totalPushCount * 50;
  580. $(".send-bar").css('width', "50%");
  581. }else{
  582. per = 0;
  583. $(".send-bar").css('width', 0);
  584. }
  585. $(".article-bar").css('width', per+"%");
  586. }
  587. var legend = {
  588. orient: 'vertical',
  589. // type: 'scroll',
  590. x: '40%',
  591. data: [],
  592. itemGap: 15,
  593. top: 'middle',
  594. icon: 'circle',
  595. align: 'left',
  596. };
  597. var colors = ["#15c1b0", "#428ffd", "#9892fb", "#f67279", "#fdc44f"];
  598. legendNames = [];
  599. var arr1 = _.map(data1.contentDistrPie, function(o){
  600. var obj = {
  601. name: o.categoryName,
  602. count: parseInt(o.contentCount)
  603. };
  604. legend.data.push(o.categoryName)
  605. legendNames.push(obj);
  606. return {
  607. value: parseInt(o.contentCount),
  608. name: o.categoryName
  609. }
  610. });
  611. legend.formatter = function(name){
  612. var total = 0;
  613. var target;
  614. // console.log(this)
  615. for (var i = 0, l = legendNames.length; i < l; i++) {
  616. total += parseInt(legendNames[i].count);
  617. if (legendNames[i].name == name) {
  618. target = parseInt(legendNames[i].count);
  619. }
  620. }
  621. // console.log(((target/total)*100).toFixed(2)+'% (' + name +')');
  622. return ((target/total)*100).toFixed(2)+'% (' + name +')';
  623. }
  624. var title = {
  625. text: '内容分布',
  626. x:'left',
  627. textStyle:{
  628. fontWeight: 400,
  629. fontSize: 16
  630. }
  631. }
  632. drawPie("articleChart", arr1, colors, legend, ['25%', '50%'], ['55%', '70%'], title);
  633. var arr2 = [
  634. {value: parseInt(data1.userBehaviorPie.shareCount), name: '分享'},
  635. {value: parseInt(data1.userBehaviorPie.browseCount), name: '浏览'},
  636. {value: parseInt(data1.userBehaviorPie.collectCount), name: '收藏'},
  637. {value: parseInt(data1.userBehaviorPie.zanCount), name: '点赞'},
  638. ];
  639. var legendNames2 = [{name: "分享", count: parseInt(data1.userBehaviorPie.shareCount)},
  640. {name: "浏览", count: parseInt(data1.userBehaviorPie.browseCount)},
  641. {name: "收藏", count: parseInt(data1.userBehaviorPie.collectCount)},
  642. {name: "点赞", count: parseInt(data1.userBehaviorPie.zanCount)}];
  643. legend.data=["分享","浏览","收藏","点赞"]
  644. legend.formatter = function(name){
  645. var total = 0;
  646. var target;
  647. for (var i = 0, l = legendNames2.length; i < l; i++) {
  648. total += legendNames2[i].count;
  649. if (legendNames2[i].name == name) {
  650. target = legendNames2[i].count;
  651. // console.log(target)
  652. }
  653. }
  654. var rs = "";
  655. if(total == 0){
  656. rs = "0% ("+name+")";
  657. }else{
  658. rs = ((target/total)*100).toFixed(2)+'% (' + name +')'
  659. }
  660. return rs;
  661. }
  662. var title = {
  663. text: '推送分析',
  664. x:'left',
  665. textStyle:{
  666. fontWeight: 400,
  667. fontSize: 16
  668. }
  669. }
  670. drawPie("sendChart", arr2, colors, legend, ['25%', '50%'], ['55%', '70%'], title)
  671. }else{
  672. vm.$message.error(res1.msg);
  673. }
  674. if(res2.status == 200){
  675. articleTrendData = res2.data;
  676. handleArticleTrendChart(articleTrendData,vm);
  677. }else{
  678. vm.$message.error(res2.msg);
  679. }
  680. vm.isloading=false
  681. })
  682. }
  683. /*
  684. * 处理健康文章运营统计折线图数据
  685. */
  686. function handleArticleTrendChart(articleTrendData,vm){
  687. var data = {};
  688. if(vm.selectedDateType5 == 1){
  689. data = articleTrendData.day;
  690. }else if(vm.selectedDateType5 == 2){
  691. data = articleTrendData.week;
  692. }else{
  693. data = articleTrendData.month;
  694. }
  695. var dataZoom_end,
  696. xDatas = [],
  697. yDatas = [],
  698. names = [],
  699. colors = [];
  700. for(var p in data){
  701. if(p == 'contentList'){
  702. names.push("新增内容量");
  703. colors.push('#1dff67');
  704. }else if(p == 'pushList'){
  705. names.push("新增推送量");
  706. colors.push('#ffd132');
  707. }else if(p == 'readList'){
  708. names.push("新增阅读量");
  709. colors.push('#00deff');
  710. }
  711. var xData = _.map(data[p], function(o){
  712. return o.date;
  713. });
  714. var yData = _.map(data[p], function(o){
  715. return o.count;
  716. });
  717. xDatas.push(xData);
  718. yDatas.push(yData);
  719. }
  720. EventBus.$emit("draw-line-chart", {
  721. panelName : "运营统计",
  722. quotaNames : names,
  723. xData : xDatas[0],
  724. yDatas : yDatas,
  725. colors : colors,
  726. selectedDateType: vm.selectedDateType5,
  727. nowlineid : "lineChart5",
  728. unit:"篇"
  729. });
  730. }