jfDetail.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. var app = getApp()
  2. var that;
  3. Page({
  4. data: {
  5. userInfo: {},
  6. type: 1,//判断那个列表进入 1阶段排名,2累计排名,3自定义排名
  7. point: 0,
  8. base_point: 0,//基础分
  9. service_point: 0, //工龄发
  10. formData: {
  11. page: 1,
  12. page_size: 20,
  13. dc_status: JSON.stringify([1]),
  14. order_key: 'create_time',
  15. order_type: 'desc',
  16. pt_id: "3"
  17. },
  18. typesIndex: 0,//条件选择
  19. types: [
  20. { id: 0, name: '按最新事件时间排序' },
  21. { id: 1, name: '按积分由高到低排序' },
  22. { id: 2, name: '按积分由低到高排序' },
  23. ],
  24. },
  25. onLoad(e) {
  26. console.log(JSON.parse(e.data))
  27. that = this;
  28. dd.setNavigationBar({ title: "积分明细" });
  29. let data = JSON.parse(e.data);
  30. let newObj = {};
  31. this.setData({type:data.type})
  32. if (data.type == 1) {
  33. let formData = this.data.formData;
  34. let parameter = {
  35. pt_id: data.pt_id || 0,
  36. dept_ids: data.dept_id || 0,
  37. rule_id: data.rule || 0,
  38. employee_ids: data.item.employee_id,
  39. };
  40. if (data.dataType == '1') {
  41. parameter.year = data.year
  42. } else if (data.dataType == '2' || data.dataType == '4') {
  43. parameter.start_day = data.start_day
  44. parameter.end_day = data.end_day
  45. } else {
  46. parameter.month = data.month
  47. }
  48. Object.assign(newObj, formData, parameter);//合并对象
  49. this.setData({
  50. userInfo: data.item,
  51. formData: newObj
  52. })
  53. } else if (data.type == 2) {
  54. this.setData({
  55. userInfo: data.item,
  56. 'formData.dept_ids': data.dept_id || 0,
  57. 'formData.employee_ids': data.item.employee_id,
  58. })
  59. this.getUserInfo(data.item.employee_id)
  60. } else {
  61. if (data.date_interval == '1') {//统计时间区间只有type为custom时有值 1-月度 2-季度 3-年度
  62. this.setData({
  63. userInfo: data.item,
  64. 'formData.month': data.month.slice(0, 4)+'-'+data.month.slice(4),
  65. 'formData.employee_ids': data.item.employee_id,
  66. 'formData.item_id':data.items.toString()
  67. })
  68. }else if(data.date_interval == '3'){
  69. this.setData({
  70. userInfo: data.item,
  71. 'formData.year': data.month,
  72. 'formData.employee_ids': data.item.employee_id,
  73. 'formData.item_id':data.items.toString()
  74. })
  75. }else{
  76. this.setData({
  77. userInfo: data.item,
  78. 'formData.start_day': data.start_day,
  79. 'formData.end_day': data.end_day,
  80. 'formData.employee_ids': data.item.employee_id,
  81. 'formData.item_id':data.items.toString()
  82. })
  83. }
  84. }
  85. console.log(this.data.userInfo)
  86. this.getData();
  87. },
  88. getUserInfo(id){
  89. app.$get('/api/employee/detail',{target:id}).then(res => {
  90. this.setData({
  91. base_point:res.data.data.user.site_config.base_point,//基础分
  92. service_point:res.data.data.user.point_config.service_point //工龄发
  93. })
  94. })
  95. },
  96. onShareAppMessage() {
  97. return {
  98. title: '累计B分排名',
  99. desc: '积分排名有变动了,快来看看!',
  100. path: 'pages/statistics/B_ranking/B_ranking'
  101. };
  102. },
  103. onShow() {
  104. // if (app.globalData.userData) {
  105. // if (that.data.page == 1) {
  106. // dd.hideLoading();
  107. // that.getData();
  108. // }
  109. // } else {
  110. // app.login(app.globalData.corpId, function (is) {
  111. // if (is) {
  112. // if (that.data.page == 1) {
  113. // dd.hideLoading();
  114. // that.getData();
  115. // }
  116. // } else {
  117. // dd.reLaunch({
  118. // url: '../../noJurisdiction/noJurisdiction'
  119. // })
  120. // }
  121. // },function(){})
  122. // }
  123. },
  124. open2() {
  125. if (this.data.formData.pt_id == '2') {//A分
  126. dd.navigateTo({
  127. url: '../../workbench/statistics_A/statistics_A?employee_id=' + that.data.userInfo.employee_id + '&name=' + that.data.userInfo.employee_name
  128. })
  129. } else {
  130. dd.navigateTo({
  131. url: '../../workbench/statistics_B/statistics_B?employee_id=' + that.data.userInfo.employee_id + '&name=' + that.data.userInfo.employee_name
  132. })
  133. }
  134. },
  135. getData(is) {
  136. app.$get('api/integral/statistics/integral', this.data.formData).then((res) => {
  137. var data = res.data.data.list;
  138. data.map((item) => {
  139. item.ptObj = app.getTypesItem(item.pt_id);
  140. })
  141. if (is) {
  142. if (data.length == 0) {
  143. this.setData({
  144. isData: true
  145. })
  146. return;
  147. }
  148. var list = that.data.list;
  149. this.setData({
  150. list: list.concat(data)
  151. })
  152. } else {
  153. this.setData({ list: [] });
  154. this.setData({
  155. list: data,
  156. isData: false
  157. })
  158. }
  159. })
  160. },
  161. //选择事件来源
  162. bingIntegralType(e) {
  163. if (e.detail.value == 0) {
  164. this.setData({
  165. 'formData.order_key': 'create_time',
  166. 'formData.order_type': 'desc',
  167. });
  168. }
  169. if (e.detail.value == 1) {
  170. this.setData({
  171. 'formData.order_key': 'point',
  172. 'formData.order_type': 'desc',
  173. });
  174. }
  175. if (e.detail.value == 2) {
  176. this.setData({
  177. 'formData.order_key': 'point',
  178. 'formData.order_type': 'asc',
  179. });
  180. }
  181. this.setData({
  182. typesIndex: e.detail.value,
  183. 'formData.page': 1,
  184. });
  185. this.getData();
  186. },
  187. //上啦加载
  188. onScrollToLower() {
  189. if (!that.data.isData) {
  190. this.setData({ 'formData.page': ++that.data.formData.page })
  191. this.getData(true);
  192. }
  193. },
  194. //打开兴趣
  195. openDetail(e) {
  196. var item = e.target.dataset.item;
  197. dd.navigateTo({
  198. url: '../prizeBuckleDetail/prizeBuckleDetail?id=' + item.id
  199. })
  200. },
  201. });