jfDetail.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. is:false,
  25. },
  26. onLoad(e) {
  27. that = this;
  28. dd.setNavigationBar({ title: "积分明细" });
  29. let data = JSON.parse(e.data);
  30. console.log(data);
  31. let newObj = {};
  32. this.setData({type:data.type})
  33. if (data.type == 1) {
  34. let formData = this.data.formData;
  35. let parameter = {
  36. pt_id: data.pt_id || 0,
  37. // dept_ids: data.dept_id || 0,
  38. rule_id: data.rule || 0,
  39. employee_ids: data.item.employee_id,
  40. };
  41. if (data.dataType == '1') {
  42. parameter.year = data.year
  43. } else if (data.dataType == '2' || data.dataType == '4') {
  44. parameter.start_day = data.start_day
  45. parameter.end_day = data.end_day
  46. } else {
  47. parameter.month = data.month
  48. }
  49. Object.assign(newObj, formData, parameter);//合并对象
  50. this.setData({
  51. userInfo: data.item,
  52. formData: newObj
  53. })
  54. } else if (data.type == 2) {
  55. this.setData({
  56. userInfo: data.item,
  57. 'formData.dept_ids': data.dept_id || 0,
  58. 'formData.employee_ids': data.item.employee_id,
  59. })
  60. this.getUserInfo(data.item.employee_id)
  61. } else {
  62. if (data.date_interval == '1') {//统计时间区间只有type为custom时有值 1-月度 2-季度 3-年度
  63. this.setData({
  64. is:true,
  65. userInfo: data.item,
  66. 'formData.month': data.month.slice(0, 4)+'-'+data.month.slice(4),
  67. 'formData.employee_ids': data.item.employee_id,
  68. 'formData.item_id':data.items.toString()
  69. })
  70. }else if(data.date_interval == '3'){
  71. this.setData({
  72. is:true,
  73. userInfo: data.item,
  74. 'formData.year': data.month,
  75. 'formData.employee_ids': data.item.employee_id,
  76. 'formData.item_id':data.items.toString()
  77. })
  78. }else{
  79. this.setData({
  80. is:true,
  81. userInfo: data.item,
  82. 'formData.start_day': data.start_day,
  83. 'formData.end_day': data.end_day,
  84. 'formData.employee_ids': data.item.employee_id,
  85. 'formData.item_id':data.items.toString()
  86. })
  87. }
  88. }
  89. this.getData();
  90. let role_list=this.supremeAuthority();
  91. if(role_list=='dept_manager'&&data.item.employee_id!=app.globalData.userData.id){
  92. let manage_scope=app.globalData.userData.employee_detail.manage_scope;
  93. manage_scope.push(app.globalData.userData)
  94. let is=true;
  95. manage_scope.forEach(item=>{
  96. if(data.item.employee_id==item.id){
  97. is=false;
  98. }
  99. })
  100. this.setData({is:is})
  101. }
  102. if(role_list=='employee'&&data.item.employee_id!=app.globalData.userData.id){
  103. this.setData({is:true})
  104. }
  105. },
  106. supremeAuthority() { //获取当前角色最高权限 判断是否为某项权限:this.$authoritys('dept_manager') 或 this.$supremeAuthority() == 'dept_manager'
  107. if (this.getIsCreator('creator')) {
  108. return 'creator'
  109. } else if (this.getIsCreator('admin')) {
  110. return 'admin'
  111. } else if (this.getIsCreator('point_manager')) {
  112. return 'point_manager'
  113. } else if (this.getIsCreator('dept_manager')) {
  114. return 'dept_manager'
  115. } else if (this.getIsCreator('employee')) {
  116. return 'employee'
  117. }
  118. },
  119. getIsCreator(key) {
  120. let is = false;
  121. app.globalData.userData.employee_detail.role_list.forEach(item => {
  122. if (key == item.name) {
  123. is = true;
  124. }
  125. })
  126. return is
  127. },
  128. getUserInfo(id){
  129. app.$get('/api/employee/detail',{target:id}).then(res => {
  130. this.setData({
  131. base_point:res.data.data.user.site_config.base_point,//基础分
  132. service_point:res.data.data.user.point_config.service_point //工龄发
  133. })
  134. })
  135. },
  136. onShareAppMessage() {
  137. return {
  138. title: '累计B分排名',
  139. desc: '积分排名有变动了,快来看看!',
  140. path: 'pages/statistics/B_ranking/B_ranking'
  141. };
  142. },
  143. onShow() {
  144. // if (app.globalData.userData) {
  145. // if (that.data.page == 1) {
  146. // dd.hideLoading();
  147. // that.getData();
  148. // }
  149. // } else {
  150. // app.login(app.globalData.corpId, function (is) {
  151. // if (is) {
  152. // if (that.data.page == 1) {
  153. // dd.hideLoading();
  154. // that.getData();
  155. // }
  156. // } else {
  157. // dd.reLaunch({
  158. // url: '../../noJurisdiction/noJurisdiction'
  159. // })
  160. // }
  161. // },function(){})
  162. // }
  163. },
  164. open2() {
  165. if (this.data.formData.pt_id == '2') {//A分
  166. dd.navigateTo({
  167. url: '../../workbench/statistics_A/statistics_A?employee_id=' + that.data.userInfo.employee_id + '&name=' + that.data.userInfo.employee_name
  168. })
  169. } else {
  170. dd.navigateTo({
  171. url: '../../workbench/statistics_B/statistics_B?employee_id=' + that.data.userInfo.employee_id + '&name=' + that.data.userInfo.employee_name
  172. })
  173. }
  174. },
  175. getData(is) {
  176. app.$get('api/integral/statistics/integral', this.data.formData).then((res) => {
  177. var data = res.data.data.list;
  178. data.map((item) => {
  179. item.ptObj = app.getTypesItem(item.pt_id);
  180. })
  181. if (is) {
  182. if (data.length == 0) {
  183. this.setData({
  184. isData: true
  185. })
  186. return;
  187. }
  188. var list = that.data.list;
  189. this.setData({
  190. list: list.concat(data)
  191. })
  192. } else {
  193. this.setData({ list: [] });
  194. this.setData({
  195. list: data,
  196. isData: false
  197. })
  198. }
  199. })
  200. },
  201. //选择事件来源
  202. bingIntegralType(e) {
  203. if (e.detail.value == 0) {
  204. this.setData({
  205. 'formData.order_key': 'create_time',
  206. 'formData.order_type': 'desc',
  207. });
  208. }
  209. if (e.detail.value == 1) {
  210. this.setData({
  211. 'formData.order_key': 'point',
  212. 'formData.order_type': 'desc',
  213. });
  214. }
  215. if (e.detail.value == 2) {
  216. this.setData({
  217. 'formData.order_key': 'point',
  218. 'formData.order_type': 'asc',
  219. });
  220. }
  221. this.setData({
  222. typesIndex: e.detail.value,
  223. 'formData.page': 1,
  224. });
  225. this.getData();
  226. },
  227. //上啦加载
  228. onScrollToLower() {
  229. if (!that.data.isData) {
  230. this.setData({ 'formData.page': ++that.data.formData.page })
  231. this.getData(true);
  232. }
  233. },
  234. //打开兴趣
  235. openDetail(e) {
  236. var item = e.target.dataset.item;
  237. dd.navigateTo({
  238. url: '../prizeBuckleDetail/prizeBuckleDetail?id=' + item.id
  239. })
  240. },
  241. });