integralEvent.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. var app = getApp()
  2. var that;
  3. var typeArr = [];
  4. Page({
  5. data: {
  6. date: app.globalData.month,
  7. minuteIndex: 0,//条件选择
  8. minuteArray: [
  9. { id: 0, name: '总分' },
  10. { id: 1, name: '加班' },
  11. { id: 2, name: '迟到' },
  12. ],
  13. showDate: false,//是否显示时间组件
  14. selectDateVal: '本月',
  15. showStaff: false,//显示员工选择
  16. staffVal: '员工',
  17. types: [],//积分分类
  18. typesIndex: '0',
  19. showRuleTwo: false,
  20. ruleVal: "规则分类",
  21. page: 1,
  22. popupCx: '',
  23. rule_item_id: '',//细则ID
  24. showZp: false,//显示sx选择
  25. sxObj:['1','0']
  26. },
  27. onLoad(e) {
  28. that = this;
  29. var userData = app.globalData.userData;
  30. typeArr = [{ id: 0, name: '全部' }];
  31. var arr = typeArr.concat(app.globalData.types);
  32. arr = app.globalData.arrRemoveObj(arr, arr[1]);
  33. console.log(e)
  34. dd.setNavigationBar({ title: "积分事件" });
  35. if (e.month || e.employee_ids) {
  36. var typesIndex = "0";
  37. if (e.type) {
  38. let index=e.type=='AF'? '2':'3';
  39. this.setData({
  40. sxObj:['1',index]
  41. })
  42. }
  43. this.setData({
  44. date: e.month ? e.month : app.globalData.month,
  45. typesIndex: typesIndex,
  46. selectDateVal: e.month == app.globalData.month ? '本月' : '月',
  47. defaultDate: { type: '1', date: e.month },
  48. employee_ids: e.employee_ids>0 ? e.employee_ids : [userData.id],
  49. staffVal: e.userName ? e.userName : userData.name,
  50. })
  51. }
  52. // this.setData({
  53. // employee_ids: e.employee_ids>0 ? e.employee_ids : [userData.id],
  54. // staffVal: e.userName ? e.userName : userData.name,
  55. // })
  56. if (e.rule_item_id) {//周报进来
  57. this.setData({
  58. rule_item_id: e.rule_item_id,
  59. })
  60. }
  61. },
  62. onShow() {
  63. typeArr = [{ id: 0, name: '全部' }];
  64. if (app.globalData.userData) {
  65. var arr = typeArr.concat(app.globalData.types);
  66. arr = app.globalData.arrRemoveObj(arr, arr[1]);
  67. if (arr) {
  68. that.setData({ types: arr })
  69. }
  70. if (that.data.page == 1) {
  71. that.getData();
  72. }
  73. } else {
  74. app.login(app.globalData.corpId, function (is) {
  75. if (is) {
  76. var arr = typeArr.concat(app.globalData.types);
  77. arr = app.globalData.arrRemoveObj(arr, arr[1]);
  78. if (arr) {
  79. that.setData({ types: arr })
  80. }
  81. if (that.data.page == 1) {
  82. that.getData();
  83. }
  84. } else {
  85. dd.reLaunch({
  86. url: '../../noJurisdiction/noJurisdiction'
  87. })
  88. }
  89. }, function () { })
  90. }
  91. },
  92. onReset() {
  93. this.setData({
  94. page: 1,
  95. isVal: false,
  96. keyword: ''
  97. })
  98. this.getData();
  99. },
  100. selectSx() {
  101. this.setData({ showZp: true })
  102. },
  103. //选择筛选
  104. onConfirmSx(data) {
  105. this.setData({
  106. page: 1,
  107. sxObj:data
  108. })
  109. this.getData();
  110. },
  111. bindKeyInput(e) {
  112. this.setData({
  113. page: 1,
  114. isVal: e.detail.value ? true : false,
  115. keyword: e.detail.value ? e.detail.value : '',
  116. })
  117. this.getData();
  118. },
  119. getData(is) {
  120. var data = {
  121. page: that.data.page,
  122. page_size: 20,
  123. rule_id: that.data.rule_id||0,
  124. pt_id: this.data.sxObj[1],
  125. employee_ids: that.data.employee_ids,
  126. keyword:that.data.keyword,
  127. dc_status: JSON.stringify([this.data.sxObj[0]]),
  128. // order_key:'update_time'
  129. }
  130. if (that.data.date_type == 2) {
  131. data.start_day = that.data.dateObj[0];
  132. data.end_day = that.data.dateObj[1];
  133. } else {
  134. data.month = that.data.dateObj || that.data.date;
  135. }
  136. if (that.data.rule_item_id) {//周报进来的细则ID
  137. data.item_id = that.data.rule_item_id
  138. }
  139. app.$get('api/integral/statistics/integral', data).then((res) => {
  140. var data = res.data.data.list;
  141. data.map((item) => {
  142. item.ptObj = app.getTypesItem(item.pt_id);
  143. })
  144. if (is) {
  145. if (data.length == 0) {
  146. this.setData({
  147. isData: true
  148. })
  149. return;
  150. }
  151. var list = that.data.list;
  152. this.setData({
  153. list: list.concat(data)
  154. })
  155. } else {
  156. this.setData({ list: [] });
  157. this.setData({
  158. list: data,
  159. isData: false
  160. })
  161. }
  162. })
  163. },
  164. //上啦加载
  165. onScrollToLower() {
  166. if (!that.data.isData) {
  167. this.setData({ page: ++that.data.page })
  168. this.getData(true);
  169. }
  170. },
  171. //打开兴趣
  172. openDetail(e) {
  173. var item = e.target.dataset.item;
  174. dd.navigateTo({
  175. url: '../prizeBuckleDetail/prizeBuckleDetail?id=' + item.id
  176. })
  177. },
  178. //显示规则组件
  179. selectRule() {
  180. this.setData({
  181. popupCx: 'container__mask',
  182. showRuleTwo: true
  183. })
  184. },
  185. //显示选择时间组件
  186. selectDate() {
  187. this.setData({
  188. popupCx: 'container__mask',
  189. showDate: true
  190. })
  191. },
  192. //显示选择员工
  193. selectStaff() {
  194. this.setData({
  195. popupCx: 'container__mask',
  196. showStaff: true
  197. })
  198. },
  199. //选择时间
  200. onConfirmDate(data) {
  201. that.setData({
  202. defaultDate: data,
  203. dateObj: data.date,
  204. date_type: data.type == 1 ? 3 : data.type,
  205. page: 1,
  206. selectDateVal: data.type == 1 ? (data.date == that.data.date ? '本月' : '月') : '日',
  207. rule_item_id: ''
  208. })
  209. this.getData();
  210. },
  211. //关闭弹窗
  212. onClose() {
  213. this.setData({
  214. showDate: false,
  215. showStaff: false,
  216. showRuleTwo: false,
  217. popupCx: '',
  218. rule_item_id: '',
  219. showZp: false,
  220. })
  221. },
  222. //选择积分分类
  223. bingIntegralType(e) {
  224. this.setData({
  225. typesIndex: e.detail.value,
  226. page: 1,
  227. rule_item_id: ''
  228. });
  229. this.getData();
  230. },
  231. //选择员工
  232. onConfirmStaff(data) {
  233. if (!data) {
  234. this.setData({ staffVal: '员工', employee_ids: '', page: 1, rule_item_id: '' })
  235. this.getData();
  236. return false;
  237. }
  238. if (data.length > 0) {
  239. if (data.length > 1) {
  240. var str = "";
  241. var arr = [];
  242. data.forEach((item) => {
  243. str += item.name + ','
  244. arr.push(item.id);
  245. })
  246. var employee_ids = arr.join(',');
  247. this.setData({ staffVal: str.substring(0, str.length - 1), employee_ids: employee_ids, page: 1, rule_item_id: '' })
  248. } else {
  249. this.setData({ staffVal: data[0].name, employee_ids: [data[0].id], page: 1, rule_item_id: '' })
  250. }
  251. } else {
  252. this.setData({ staffVal: '员工', employee_ids: [], page: 1, rule_item_id: '' })
  253. }
  254. this.getData();
  255. },
  256. //选择规则
  257. onConfirmRule(e) {
  258. this.setData({
  259. rule_id: e.id ? e.id : '',
  260. page: 1,
  261. ruleVal: e.name,
  262. rule_item_id: ''
  263. })
  264. this.getData();
  265. },
  266. });