staff.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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('leaveOffice') }
  39. ],
  40. // 列表区(内容)
  41. contentList: [
  42. { name: 'staffCode', title: mixins.$t('staffCode') },
  43. { name: 'staffPhone', title: mixins.$t('staffPhone') },
  44. { name: 'orgName', title: mixins.$t('orgId') },
  45. { name: 'roleNames', title: mixins.$t('roleName') },
  46. ],
  47. // 弹出按钮
  48. buttonList: [],
  49. // 主键Id
  50. primaryKey: 'staffId',
  51. // 路由
  52. routeObjName: 'staff',
  53. },
  54. /**
  55. * @desc : 切换页面
  56. * @date : 2024/2/1 15:49
  57. * @author : 姜永辉
  58. */
  59. onChangeTabs(e) {
  60. let index = e.detail.detail.index
  61. this.setData({
  62. active: index,
  63. })
  64. // 默认查询
  65. this.searchData();
  66. },
  67. /**
  68. * @desc : 三个小点点击回调
  69. * @date : 2024年3月8日
  70. * @author : 姜永辉
  71. */
  72. toPoint(e) {
  73. let item = e.detail.item
  74. if (app.globalData.company.gradeCode == Constants.gradeCode.STD) {
  75. this.setData({
  76. buttonList: [
  77. { name: 'leaveOffice', title: mixins.$t('leaveOffice') },
  78. ],
  79. })
  80. } else {
  81. this.setData({
  82. buttonList: [
  83. { name: 'staffRight', title: mixins.$t('functionalPermissions') },
  84. { name: 'staffPurview', title: mixins.$t('purviewPermissions') },
  85. { name: 'leaveOffice', title: mixins.$t('leaveOffice') },
  86. ],
  87. })
  88. }
  89. },
  90. /**
  91. * @desc : 设置额外参数
  92. * @date : 2024/2/1 15:49
  93. * @author : 姜永辉
  94. */
  95. setSearchParams(params) {
  96. // 在职离职状态
  97. params.hrStatus = (this.data.active == 0 ? null : this.data.active)
  98. return params
  99. },
  100. /**
  101. * @desc : 查询
  102. * @date : 2024/2/1 15:49
  103. * @author : 姜永辉
  104. */
  105. getData(params) {
  106. return this.excute(this.data.service, this.data.service.selectByCond, params);
  107. },
  108. /**
  109. * @desc : 如果页面需要后续处理,再进行处理
  110. * @date : 2024/2/1 15:49
  111. * @author : 姜永辉
  112. */
  113. handleSearchData(data) {
  114. // 员工的数量
  115. let tableData = this.data.tableData || []
  116. let contentnFootList = this.data.contentnFootList
  117. tableData.forEach(it => {
  118. if (it.hrStatus == 0) {
  119. it.backgroundColor = 'red'
  120. }
  121. })
  122. contentnFootList.forEach(it => {
  123. if (it.type == 'count') {
  124. it.bill = tableData.length
  125. }
  126. })
  127. this.setData({
  128. tableData,
  129. contentnFootList
  130. })
  131. },
  132. /**
  133. * @desc : 离职
  134. * @date : 2024/2/1 15:49
  135. * @author : 姜永辉
  136. */
  137. leaveOffice(e) {
  138. let item = e
  139. let params = {
  140. staffId: item.staffId,
  141. flgValid: false,
  142. wxUserId: item.wxUserId,
  143. hrStatus: 2 // 离职2 在职1
  144. }
  145. this.excute(this.data.service, this.data.service.leaveOffice, params).then(res => {
  146. if (res.data.code == Constants.SUCESS_CODE) {
  147. // 重新查询
  148. this.searchData()
  149. }
  150. })
  151. },
  152. })