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