integralEvent.js 6.4 KB

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