participation.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. employeeDet(id,fun) {
  36. app.$get('api/per/package/employee/info',{id:id}).then(res => {
  37. let data = res.data.data;
  38. fun(data)
  39. })
  40. },
  41. openVas(e) {
  42. let id=e.target.dataset.item.record_id
  43. this.employeeDet(id,(res)=>{
  44. let data = {
  45. know: 'admnin',
  46. apList: JSON.stringify(res.dimension),
  47. packId: res.id,
  48. assessID: app.globalData.usersList[res.relevance_employee.id].id, // 考核人员信息,
  49. planIndex: [],
  50. recordMemberIds: res.record_member_ids || []
  51. };
  52. setCache('actionplanList', data);
  53. dd.navigateTo({
  54. url: `../actionplanList/actionplanList`
  55. })
  56. })
  57. },
  58. openDetail(e) {
  59. let item = e.target.dataset.item
  60. dd.navigateTo({
  61. url: `../performanceDetails/performanceDetails?id=${item.record_id}&tel=${item.package_name}`
  62. })
  63. },
  64. //选择弹窗
  65. openSelect(e) {
  66. animation.translateY(0).step();
  67. that.setData({
  68. isShowType: true,
  69. animationInfo: animation.export(),
  70. popupCx: 'container__mask',
  71. });
  72. },
  73. //关闭规则
  74. onClose() {
  75. animation.translateY(1200).step();
  76. that.setData({
  77. isShowType: false,
  78. animationInfo: animation.export(),
  79. popupCx: '',
  80. });
  81. },
  82. onSelectItem(e) {
  83. that.setData({
  84. defaultRuleId: e.id,
  85. jxName: e.name,
  86. });
  87. if (that.data.tabIndex == 1) {
  88. this.getManagement();
  89. } else {
  90. this.getScorerRecord();
  91. }
  92. },
  93. onScrollToLower() {
  94. if (!that.data.isData) {
  95. this.setData({ page: ++that.data.page })
  96. if (that.data.tabIndex == 1) {
  97. this.getManagement(true);
  98. } else {
  99. this.getScorerRecord(true);
  100. }
  101. }
  102. },
  103. //管理记录列表
  104. getManagement(e) {
  105. if (!e) {
  106. this.setData({ page: 1 })
  107. }
  108. if (!this.data.defaultRuleId) {
  109. return false
  110. }
  111. let range = this.data.minuteArray[this.data.minuteIndex].value;
  112. this.setData({ list: [] })
  113. 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 => {
  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. //我评分的
  133. getScorerRecord(e) {
  134. if (!e) {
  135. this.setData({ page: 1 })
  136. }
  137. this.setData({ list: [] })
  138. let range = this.data.minuteArray[this.data.minuteIndex].value;
  139. 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 => {
  140. let list = res.data.data.list;
  141. list.forEach(item => {
  142. item.returnStr = returnStr(item.action_update)
  143. if (item.employee_id && app.globalData.usersList[item.employee_id]) {
  144. //当是导入导出时,显示登录者
  145. item.userInfo = app.globalData.usersList[item.employee_id];
  146. item.dept_list = app.globalData.usersList[item.employee_id].dept_list
  147. }
  148. });
  149. if (this.data.page !== 1) {
  150. list = this.data.list.concat(list);
  151. }
  152. this.setData({
  153. list: list,
  154. isData: list.length == res.data.data.total
  155. })
  156. })
  157. },
  158. onReset() {
  159. this.setData({
  160. isVal: false,
  161. keyword: ''
  162. })
  163. if (that.data.tabIndex == 1) {
  164. this.getManagement();
  165. } else {
  166. this.getScorerRecord();
  167. }
  168. },
  169. bindKeyInput: _debounce(function (e) {
  170. this.setData({
  171. isVal: e.detail.value ? true : false,
  172. keyword: e.detail.value ? e.detail.value : '',
  173. })
  174. if (that.data.tabIndex == 1) {
  175. this.getManagement();
  176. } else {
  177. this.getScorerRecord();
  178. }
  179. }),
  180. activeItem(e) {
  181. this.setData({ minuteIndex: e.detail.value, })
  182. if (that.data.tabIndex == 1) {
  183. this.getManagement();
  184. } else {
  185. this.getScorerRecord();
  186. }
  187. },
  188. tabAction(e) {
  189. let index = e.target.dataset.index
  190. this.setData({
  191. tabIndex: index
  192. })
  193. if (that.data.tabIndex == 1) {
  194. this.getManagement();
  195. } else {
  196. this.getScorerRecord();
  197. }
  198. },
  199. getRange() {
  200. app.$get("api/per/package/tree").then((res) => {
  201. var list = res.data.data
  202. let obj;
  203. list.some(item => {
  204. if (item.list.length > 0) {
  205. obj = item.list
  206. return true;
  207. }
  208. });
  209. that.setData({
  210. defaultRuleId: obj ? obj[0].id : '',
  211. jxName: obj ? obj[0].name : '',
  212. })
  213. this.getManagement();
  214. })
  215. },
  216. });