staff.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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('user') },
  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. let switchFlag = index == 2?true:false
  67. this.setData({
  68. active: index,
  69. switchFlag:switchFlag
  70. })
  71. // 默认查询
  72. this.searchData();
  73. },
  74. /**
  75. * @desc : 三个小点点击回调
  76. * @date : 2024年3月8日
  77. * @author : 姜永辉
  78. */
  79. toPoint(e) {
  80. const userInfo = e.detail.item
  81. let buttonList = []
  82. if(userInfo.flgInit){
  83. buttonList = [
  84. { name: 'staffRight', title: mixins.$t('functionalPermissions') },
  85. // { name: 'staffPurview', title: mixins.$t('purviewPermissions') }
  86. ]
  87. }else if(!userInfo.flgCanLogin){
  88. buttonList = [
  89. { name: 'leaveOffice', title: mixins.$t('leaveOffice') },
  90. ]
  91. }else{
  92. if (app.globalData.company.gradeCode == Constants.gradeCode.STD) {
  93. buttonList = [
  94. { name: 'staffRight', title: mixins.$t('functionalPermissions') },
  95. // { name: 'staffPurview', title: mixins.$t('purviewPermissions') },
  96. { name: 'leaveOffice', title: mixins.$t('leaveOffice') },
  97. ]
  98. }else{
  99. buttonList = [
  100. { name: 'staffRight', title: mixins.$t('functionalPermissions') },
  101. { name: 'staffPurview', title: mixins.$t('purviewPermissions') },
  102. { name: 'leaveOffice', title: mixins.$t('leaveOffice') },
  103. ]
  104. }
  105. }
  106. this.setData({
  107. buttonList: buttonList
  108. })
  109. },
  110. /**
  111. * @desc : 设置额外参数
  112. * @date : 2024/2/1 15:49
  113. * @author : 姜永辉
  114. */
  115. setSearchParams(params) {
  116. // 在职离职状态flg_can_login
  117. // 2024.6.20 刘尧 更新切换页面功能
  118. if(this.data.active == 0){
  119. params.hrStatus = 1
  120. }else if(this.data.active == 1){
  121. params.hrStatus = 1
  122. params.flgCanLogin = true
  123. }else if(this.data.active == 2){
  124. params.hrStatus = 2
  125. }
  126. // params.hrStatus = (this.data.active == 0 ? null : this.data.active)
  127. return params
  128. },
  129. /**
  130. * @desc : 查询
  131. * @date : 2024/2/1 15:49
  132. * @author : 姜永辉
  133. */
  134. getData(params) {
  135. return this.excute(this.data.service, this.data.service.selectByCond, params);
  136. },
  137. /**
  138. * @desc : 如果页面需要后续处理,再进行处理
  139. * @date : 2024/2/1 15:49
  140. * @author : 姜永辉
  141. */
  142. handleSearchData(data) {
  143. // 员工的数量
  144. let tableData = this.data.tableData || []
  145. let contentnFootList = this.data.contentnFootList
  146. tableData.forEach(it => {
  147. if (it.hrStatus == 0) {
  148. it.backgroundColor = 'red'
  149. }
  150. })
  151. contentnFootList.forEach(it => {
  152. if (it.type == 'count') {
  153. it.bill = tableData.length
  154. }
  155. })
  156. if(this.data.gradeCode != Constants.gradeCode.PRO){
  157. const contentList = [
  158. { name: 'staffCode', title: mixins.$t('staffCode') },
  159. { name: 'staffPhone', title: mixins.$t('staffPhone') },
  160. { name: 'orgName', title: mixins.$t('orgId') }
  161. ]
  162. this.setData({
  163. contentList: contentList
  164. })
  165. }
  166. this.setData({
  167. tableData,
  168. contentnFootList
  169. })
  170. },
  171. /**
  172. * @desc : 离职
  173. * @date : 2024/2/1 15:49
  174. * @author : 姜永辉
  175. */
  176. leaveOffice(e) {
  177. let item = e
  178. let params = {
  179. staffId: item.staffId,
  180. flgValid: false,
  181. wxUserId: item.wxUserId,
  182. hrStatus: 2 // 离职2 在职1
  183. }
  184. this.excute(this.data.service, this.data.service.leaveOffice, params).then(res => {
  185. if (res.data.code == Constants.SUCESS_CODE) {
  186. // 重新查询
  187. this.searchData()
  188. }
  189. })
  190. },
  191. })