staff.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*******************************************************************************
  2. * Copyright(c) 2022 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:
  5. * 2.员工资料列表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * admin 2024-2-12 1.00
  9. *******************************************************************************/
  10. const mixins = require('@/mixins/index.js')
  11. const Constants = require('@/utils/Constants.js')
  12. const app = getApp()
  13. Page({
  14. mixins: [mixins],
  15. /**
  16. * 页面的初始数据
  17. */
  18. data: {
  19. // 查询条件
  20. searchContent: [],
  21. // 底部保存按钮
  22. buttonFootList: [
  23. {
  24. code: 'buy',
  25. title: mixins.$t('buyUser')
  26. },
  27. {
  28. code: 'add',
  29. title: mixins.$t('add')
  30. }],
  31. contentnFootList: [
  32. ],
  33. btnFormData: null,
  34. active: 0,
  35. tagList: [
  36. // { title: mixins.$t('all') },
  37. { title: mixins.$t('resignation') },
  38. { title: mixins.$t('login') },
  39. { title: mixins.$t('leaveOffice') }
  40. ],
  41. // 列表区(内容)
  42. contentList: [
  43. { name: 'staffCode', title: mixins.$t('staffCode') },
  44. { name: 'staffPhone', title: mixins.$t('staffPhone') },
  45. { name: 'orgName', title: mixins.$t('orgId') },
  46. { name: 'roleNames', title: mixins.$t('roleName') },
  47. ],
  48. // 弹出按钮
  49. buttonList: [
  50. { name: 'staffRight', title: mixins.$t('functionalPermissions') },
  51. { name: 'staffPurview', title: mixins.$t('purviewPermissions') },
  52. { name: 'leaveOffice', title: mixins.$t('leaveOffice') },
  53. ],
  54. // 主键Id
  55. primaryKey: 'staffId',
  56. // 路由
  57. routeObjName: 'staff'
  58. },
  59. /**
  60. * @desc : 切换页面
  61. * @date : 2024/2/1 15:49
  62. * @author : 姜永辉
  63. */
  64. onChangeTabs(e) {
  65. let index = e.detail.detail.index
  66. this.setData({
  67. active: index,
  68. })
  69. // 默认查询
  70. this.searchData();
  71. },
  72. /**
  73. * @desc : 三个小点点击回调
  74. * @date : 2024年3月8日
  75. * @author : 姜永辉
  76. */
  77. toPoint(e) {
  78. const userInfo = e.detail.item
  79. let buttonList = []
  80. if(userInfo.flgInit){
  81. buttonList = [
  82. { name: 'staffRight', title: mixins.$t('functionalPermissions') },
  83. { name: 'staffPurview', title: mixins.$t('purviewPermissions') }
  84. ]
  85. }else if(!userInfo.flgCanLogin){
  86. buttonList = [
  87. { name: 'leaveOffice', title: mixins.$t('leaveOffice') },
  88. ]
  89. }else{
  90. buttonList = [
  91. { name: 'staffRight', title: mixins.$t('functionalPermissions') },
  92. { name: 'staffPurview', title: mixins.$t('purviewPermissions') },
  93. { name: 'leaveOffice', title: mixins.$t('leaveOffice') },
  94. ]
  95. }
  96. this.setData({
  97. buttonList: buttonList
  98. })
  99. },
  100. /**
  101. * @desc : 设置额外参数
  102. * @date : 2024/2/1 15:49
  103. * @author : 姜永辉
  104. */
  105. setSearchParams(params) {
  106. // 在职离职状态flg_can_login
  107. // 2024.6.20 刘尧 更新切换页面功能
  108. if(this.data.active == 0){
  109. params.hrStatus = 1
  110. }else if(this.data.active == 1){
  111. params.hrStatus = 1
  112. params.flgCanLogin = true
  113. }else if(this.data.active == 2){
  114. params.hrStatus = 2
  115. }
  116. // params.hrStatus = (this.data.active == 0 ? null : this.data.active)
  117. return params
  118. },
  119. /**
  120. * @desc : 查询
  121. * @date : 2024/2/1 15:49
  122. * @author : 姜永辉
  123. */
  124. getData(params) {
  125. return this.excute(this.data.service, this.data.service.selectByCond, params);
  126. },
  127. /**
  128. * @desc : 如果页面需要后续处理,再进行处理
  129. * @date : 2024/2/1 15:49
  130. * @author : 姜永辉
  131. */
  132. handleSearchData(data) {
  133. // 员工的数量
  134. let tableData = this.data.tableData || []
  135. let contentnFootList = this.data.contentnFootList
  136. tableData.forEach(it => {
  137. if (it.hrStatus == 0) {
  138. it.backgroundColor = 'red'
  139. }
  140. })
  141. contentnFootList.forEach(it => {
  142. if (it.type == 'count') {
  143. it.bill = tableData.length
  144. }
  145. })
  146. if(this.data.gradeCode != Constants.gradeCode.PRO){
  147. const contentList = [
  148. { name: 'staffCode', title: mixins.$t('staffCode') },
  149. { name: 'staffPhone', title: mixins.$t('staffPhone') },
  150. { name: 'orgName', title: mixins.$t('orgId') }
  151. ]
  152. this.setData({
  153. contentList: contentList
  154. })
  155. }
  156. this.setData({
  157. tableData,
  158. contentnFootList
  159. })
  160. },
  161. /**
  162. * @desc : 离职
  163. * @date : 2024/2/1 15:49
  164. * @author : 姜永辉
  165. */
  166. leaveOffice(e) {
  167. let item = e
  168. let params = {
  169. staffId: item.staffId,
  170. flgValid: false,
  171. wxUserId: item.wxUserId,
  172. hrStatus: 2 // 离职2 在职1
  173. }
  174. this.excute(this.data.service, this.data.service.leaveOffice, params).then(res => {
  175. if (res.data.code == Constants.SUCESS_CODE) {
  176. // 重新查询
  177. this.searchData()
  178. }
  179. })
  180. },
  181. })