staff.js 3.7 KB

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