statistics_A.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. var app = getApp()
  2. var that;
  3. var chart1;
  4. Page({
  5. data: {
  6. date: app.globalData.month,
  7. data_a: [],
  8. chartData: [],//折线图数据
  9. employee_id:0,
  10. },
  11. onLoad(e) {
  12. if(e.employee_id){
  13. this.setData({employee_id:e.employee_id})
  14. dd.setNavigationBar({ title: `${e.name}的A分统计` });
  15. }else{
  16. dd.setNavigationBar({ title: "我的A分统计" });
  17. }
  18. that = this;
  19. },
  20. //打开更多
  21. openMore() {
  22. dd.navigateTo({
  23. url: '../../statistics/integralEvent/integralEvent?month=' + this.data.date + '&type=AF'
  24. })
  25. },
  26. //则线图
  27. onInitChart(F2, config) {
  28. chart1 = new F2.Chart(config);
  29. chart1.source(that.data.chartData, {
  30. date: {
  31. range: [0, 1],
  32. tickCount: 5
  33. }
  34. });
  35. chart1.tooltip({
  36. showCrosshairs: true,
  37. showItemMarker: false,
  38. onShow: function onShow(ev) {
  39. const items = ev.items;
  40. items[0].name = "月份:" + items[0].origin.date;
  41. items[0].value = "分值:" + items[0].value;
  42. }
  43. });
  44. chart1.line().position('date*value');
  45. chart1.point().position('date*value').style({
  46. stroke: '#fff',
  47. lineWidth: 1
  48. });
  49. chart1.render();
  50. that.getIncidentLsit();
  51. return chart1;
  52. },
  53. openDate() {
  54. that.setData({ showDate: true });
  55. dd.datePicker({
  56. format: 'yyyy-MM',
  57. currentDate: that.data.date,
  58. success: (res) => {
  59. that.setData({
  60. date: res.date
  61. })
  62. if (res.date) {
  63. that.getIncidentLsit();
  64. }
  65. },
  66. complete: (res) => {
  67. that.setData({
  68. showDate: false
  69. })
  70. }
  71. });
  72. },
  73. //获取积分事件
  74. getIncidentLsit() {
  75. app.$get("api/integral/statistics/a", { employee_id: that.data.employee_id, month: that.data.date }).then((res) => {
  76. const { a, chart, list } = res.data.data
  77. const points = chart.reward.map((rewardItem, index) => {
  78. return { date: rewardItem.month, value: rewardItem.point - (chart.deduction[index].point || 0) }
  79. })
  80. chart1.changeData(points);
  81. that.setData({
  82. data_a: a,
  83. dataList: list
  84. });
  85. })
  86. },
  87. });