index.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. active: "业绩目标",
  5. targetYear: null,
  6. "year": new Date().getFullYear().toString(),
  7. "content": {
  8. "nocache": true,
  9. "year": new Date().getFullYear().toString(), //年
  10. "targettype": "人员目标", //1
  11. "type": 1, //
  12. "where": {
  13. "condition": ""
  14. }
  15. },
  16. target: null, //目标
  17. showActions: false,
  18. actionSheet: "开票金额",
  19. actions: [{
  20. name: '开票金额',
  21. value: "1"
  22. }, {
  23. name: '订单金额',
  24. value: "2"
  25. }, {
  26. name: '出货金额',
  27. value: "3"
  28. }],
  29. },
  30. onLoad(options) {
  31. this.getData();
  32. },
  33. toDetail() {
  34. if (this.data.active == "业绩目标") {
  35. wx.navigateTo({
  36. url: './person',
  37. })
  38. } else {
  39. }
  40. },
  41. getData() {
  42. _Http.basic({
  43. "id": 20220920133102,
  44. "content": this.data.content
  45. }).then(res => {
  46. if (res.msg != '成功') return wx.showToast({
  47. title: res.data,
  48. icon: "none"
  49. })
  50. let lineData = [],
  51. histogram = [];
  52. res.data.month.forEach(v => {
  53. lineData = lineData.concat([{
  54. label: v.month + '月',
  55. value: v.l,
  56. type: "基本目标金额"
  57. },
  58. {
  59. label: v.month + '月',
  60. value: v.h,
  61. type: "挑战目标金额"
  62. },
  63. {
  64. label: v.month + '月',
  65. value: v.a,
  66. type: "实际订单金额"
  67. }
  68. ])
  69. histogram = histogram.concat([{
  70. label: v.month + '月',
  71. value: v.pl,
  72. type: "基础目标实际完成率"
  73. },
  74. {
  75. label: v.month + '月',
  76. value: v.ph,
  77. type: "挑战目标实际完成率"
  78. }
  79. ])
  80. });
  81. //绘制线图
  82. this.selectComponent("#line").render(lineData);
  83. this.selectComponent("#histogram").render(histogram);
  84. this.setData({
  85. targetYear: {
  86. yl: res.data.y1l,
  87. yh: res.data.y1h,
  88. ya: res.data.y1a,
  89. }
  90. });
  91. if (this.data.year == this.data.content.year) {
  92. const m = new Date().getMonth() + 1;
  93. let s = [
  94. [1, 2, 3],
  95. [4, 5, 6],
  96. [7, 8, 9],
  97. [10, 11, 12]
  98. ].findIndex(v => v.some(va => va == m)) + 1;
  99. this.setData({
  100. targetSeason: {
  101. sl: res.data[`s${s}l`],
  102. sh: res.data[`s${s}h`],
  103. sa: res.data[`s${s}a`],
  104. },
  105. targetMonth: {
  106. ml: res.data[`m${m}l`],
  107. mh: res.data[`m${m}h`],
  108. ma: res.data[`m${m}a`]
  109. }
  110. })
  111. }
  112. })
  113. },
  114. /* 弹出选择 */
  115. select({
  116. detail
  117. }) {
  118. if (this.data.actionSheet == detail.name) return;
  119. this.setData({
  120. actionSheet: detail.name,
  121. "content.type": detail.value,
  122. showActions: false
  123. });
  124. this.getData();
  125. },
  126. cancelActions() {
  127. this.setData({
  128. showActions: false
  129. })
  130. },
  131. openActions() {
  132. this.setData({
  133. showActions: true
  134. })
  135. },
  136. /* 选择年份 */
  137. bindDateChange({
  138. detail
  139. }) {
  140. if (this.data.content.year == detail.value) return;
  141. this.setData({
  142. "content.year": detail.value
  143. });
  144. this.getData();
  145. },
  146. /* tabs切换 */
  147. tabsChange({
  148. detail
  149. }) {
  150. this.setData({
  151. "content.targettype": detail.title == '业绩目标' ? '人员目标' : '项目目标',
  152. active: detail.title
  153. });
  154. this.getData();
  155. },
  156. onShareAppMessage() {}
  157. })