participation.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. var app = getApp();
  2. var that;
  3. var animation;
  4. import { returnStr,setCache,getCache,_debounce } from '../../../utils/util'
  5. Page({
  6. data: {
  7. tabIndex: 1,//条件选择
  8. list: [],
  9. minuteIndex: 0,//条件选择
  10. minuteArray: [
  11. { value: 0, name: '全部' },
  12. { value: 1, name: '我的下级' },
  13. { value: 2, name: '我协助的' },
  14. ],
  15. selectGlData: {}, // 当前选中项
  16. keyword: '',
  17. page: 1,
  18. defaultRuleId: '',
  19. isData: false,
  20. },
  21. onLoad() {
  22. that = this;
  23. dd.setNavigationBar({ title: "消息通知" });
  24. },
  25. onShow() {
  26. animation = dd.createAnimation({
  27. duration: 200,
  28. timeFunction: "linear",
  29. });
  30. if(this.data.page==1){
  31. this.getRange();
  32. }
  33. },
  34. openDetail(e) {
  35. let item=e.target.dataset.item
  36. dd.navigateTo({
  37. url: `../performanceDetails/performanceDetails?id=${item.record_id}&tel=${item.package_name}`
  38. })
  39. },
  40. //选择弹窗
  41. openSelect(e) {
  42. animation.translateY(0).step();
  43. that.setData({
  44. isShowType: true,
  45. animationInfo: animation.export(),
  46. popupCx: 'container__mask',
  47. });
  48. },
  49. //关闭规则
  50. onClose() {
  51. animation.translateY(1200).step();
  52. that.setData({
  53. isShowType: false,
  54. animationInfo: animation.export(),
  55. popupCx: '',
  56. });
  57. },
  58. onSelectItem(e) {
  59. that.setData({
  60. defaultRuleId: e.id,
  61. jxName: e.name,
  62. });
  63. if (that.data.tabIndex == 1) {
  64. this.getManagement();
  65. } else {
  66. this.getScorerRecord();
  67. }
  68. },
  69. onScrollToLower() {
  70. if (!that.data.isData) {
  71. this.setData({ page: ++that.data.page })
  72. if (that.data.tabIndex == 1) {
  73. this.getManagement(true);
  74. } else {
  75. this.getScorerRecord(true);
  76. }
  77. }
  78. },
  79. //管理记录列表
  80. getManagement(e) {
  81. if (!e) {
  82. this.setData({ page: 1 })
  83. }
  84. let range = this.data.minuteArray[this.data.minuteIndex].value;
  85. this.setData({ list: [] })
  86. app.$get('api/per/package/management_record', { package_id: this.data.defaultRuleId, range: range, name: this.data.keyword, page: this.data.page, page_size: 20 }).then(res => {
  87. let list = res.data.data.list;
  88. list.forEach(item => {
  89. item.returnStr = returnStr(item.action_update)
  90. if (item.employee_id&&app.globalData.usersList[item.employee_id]) {
  91. //当是导入导出时,显示登录者
  92. item.userInfo = app.globalData.usersList[item.employee_id];
  93. item.dept_list = app.globalData.usersList[item.employee_id].dept_list
  94. }
  95. });
  96. if (this.data.page !== 1) {
  97. list = this.data.list.concat(list);
  98. }
  99. this.setData({
  100. list: list,
  101. isData: list.length == res.data.data.total
  102. })
  103. })
  104. },
  105. //我评分的
  106. getScorerRecord(e) {
  107. if (!e) {
  108. this.setData({ page: 1 })
  109. }
  110. this.setData({ list: [] })
  111. let range = this.data.minuteArray[this.data.minuteIndex].value;
  112. app.$get('api/per/package/score_record', { package_id: this.data.defaultRuleId, range: range, name: this.data.keyword, page: this.data.page, page_size: 20 }).then(res => {
  113. let list = res.data.data.list;
  114. list.forEach(item => {
  115. item.returnStr = returnStr(item.action_update)
  116. if (item.employee_id&&app.globalData.usersList[item.employee_id]) {
  117. //当是导入导出时,显示登录者
  118. item.userInfo = app.globalData.usersList[item.employee_id];
  119. item.dept_list = app.globalData.usersList[item.employee_id].dept_list
  120. }
  121. });
  122. if (this.data.page !== 1) {
  123. list = this.data.list.concat(list);
  124. }
  125. this.setData({
  126. list: list,
  127. isData: list.length == res.data.data.total
  128. })
  129. })
  130. },
  131. onReset() {
  132. this.setData({
  133. isVal: false,
  134. keyword: ''
  135. })
  136. if (that.data.tabIndex == 1) {
  137. this.getManagement();
  138. } else {
  139. this.getScorerRecord();
  140. }
  141. },
  142. bindKeyInput:_debounce(function(e){
  143. this.setData({
  144. isVal: e.detail.value ? true : false,
  145. keyword: e.detail.value ? e.detail.value : '',
  146. })
  147. if (that.data.tabIndex == 1) {
  148. this.getManagement();
  149. } else {
  150. this.getScorerRecord();
  151. }
  152. }),
  153. activeItem(e) {
  154. this.setData({ minuteIndex: e.detail.value, })
  155. if (that.data.tabIndex == 1) {
  156. this.getManagement();
  157. } else {
  158. this.getScorerRecord();
  159. }
  160. },
  161. tabAction(e) {
  162. let index = e.target.dataset.index
  163. this.setData({
  164. tabIndex: index
  165. })
  166. if (that.data.tabIndex == 1) {
  167. this.getManagement();
  168. } else {
  169. this.getScorerRecord();
  170. }
  171. },
  172. getRange() {
  173. app.$get("api/per/package/tree").then((res) => {
  174. var list = res.data.data
  175. let obj;
  176. list.some(item => {
  177. if (item.list.length > 0) {
  178. obj = item.list
  179. return true;
  180. }
  181. });
  182. that.setData({
  183. defaultRuleId: obj[0].id,
  184. jxName: obj[0].name,
  185. })
  186. }).finally(() => {
  187. this.getManagement();
  188. })
  189. },
  190. });