/******************************************************************************* * Copyright(c) 2022 dongke All rights reserved. / Confidential * 类的信息: * 1.程序名称: * 2.员工资料列表 * 编辑履历: * 作者 日期 版本 修改内容 * admin 2024-2-12 1.00 *******************************************************************************/ const mixins = require('@/mixins/index.js') const Constants = require('@/utils/Constants.js') const app = getApp() Page({ mixins: [mixins], /** * 页面的初始数据 */ data: { // 查询条件 searchContent: [], // 底部保存按钮 buttonFootList: [ { code: 'buy', title: mixins.$t('buyUser') }, { code: 'add', title: mixins.$t('add') }], contentnFootList: [ ], btnFormData: null, active: 0, tagList: [ // { title: mixins.$t('all') }, { title: mixins.$t('resignation') }, { title: mixins.$t('user') }, { title: mixins.$t('leaveOffice') } ], // 列表区(内容) contentList: [ { name: 'staffCode', title: mixins.$t('staffCode') }, { name: 'staffPhone', title: mixins.$t('staffPhone') }, { name: 'orgName', title: mixins.$t('orgId') }, { name: 'roleNames', title: mixins.$t('roleName') }, ], // 弹出按钮 buttonList: [ { name: 'staffRight', title: mixins.$t('functionalPermissions') }, // { name: 'staffPurview', title: mixins.$t('purviewPermissions') }, { name: 'leaveOffice', title: mixins.$t('leaveOffice') }, ], // 主键Id primaryKey: 'staffId', // 路由 routeObjName: 'staff' }, /** * @desc : 切换页面 * @date : 2024/2/1 15:49 * @author : 姜永辉 */ onChangeTabs(e) { let index = e.detail.detail.index let switchFlag = index == 2?true:false this.setData({ active: index, switchFlag:switchFlag }) // 默认查询 this.searchData(); }, /** * @desc : 三个小点点击回调 * @date : 2024年3月8日 * @author : 姜永辉 */ toPoint(e) { const userInfo = e.detail.item let buttonList = [] if(userInfo.flgInit){ buttonList = [ { name: 'staffRight', title: mixins.$t('functionalPermissions') }, // { name: 'staffPurview', title: mixins.$t('purviewPermissions') } ] }else if(!userInfo.flgCanLogin){ buttonList = [ { name: 'leaveOffice', title: mixins.$t('leaveOffice') }, ] }else{ if (app.globalData.company.gradeCode == Constants.gradeCode.STD) { buttonList = [ { name: 'staffRight', title: mixins.$t('functionalPermissions') }, // { name: 'staffPurview', title: mixins.$t('purviewPermissions') }, { name: 'leaveOffice', title: mixins.$t('leaveOffice') }, ] }else{ buttonList = [ { name: 'staffRight', title: mixins.$t('functionalPermissions') }, { name: 'staffPurview', title: mixins.$t('purviewPermissions') }, { name: 'leaveOffice', title: mixins.$t('leaveOffice') }, ] } } this.setData({ buttonList: buttonList }) }, /** * @desc : 设置额外参数 * @date : 2024/2/1 15:49 * @author : 姜永辉 */ setSearchParams(params) { // 在职离职状态flg_can_login // 2024.6.20 刘尧 更新切换页面功能 if(this.data.active == 0){ params.hrStatus = 1 }else if(this.data.active == 1){ params.hrStatus = 1 params.flgCanLogin = true }else if(this.data.active == 2){ params.hrStatus = 2 } // params.hrStatus = (this.data.active == 0 ? null : this.data.active) return params }, /** * @desc : 查询 * @date : 2024/2/1 15:49 * @author : 姜永辉 */ getData(params) { return this.excute(this.data.service, this.data.service.selectByCond, params); }, /** * @desc : 如果页面需要后续处理,再进行处理 * @date : 2024/2/1 15:49 * @author : 姜永辉 */ handleSearchData(data) { // 员工的数量 let tableData = this.data.tableData || [] let contentnFootList = this.data.contentnFootList tableData.forEach(it => { if (it.hrStatus == 0) { it.backgroundColor = 'red' } }) contentnFootList.forEach(it => { if (it.type == 'count') { it.bill = tableData.length } }) if(this.data.gradeCode != Constants.gradeCode.PRO){ const contentList = [ { name: 'staffCode', title: mixins.$t('staffCode') }, { name: 'staffPhone', title: mixins.$t('staffPhone') }, { name: 'orgName', title: mixins.$t('orgId') } ] this.setData({ contentList: contentList }) } this.setData({ tableData, contentnFootList }) }, /** * @desc : 离职 * @date : 2024/2/1 15:49 * @author : 姜永辉 */ leaveOffice(e) { let item = e let params = { staffId: item.staffId, flgValid: false, wxUserId: item.wxUserId, hrStatus: 2 // 离职2 在职1 } this.excute(this.data.service, this.data.service.leaveOffice, params).then(res => { if (res.data.code == Constants.SUCESS_CODE) { // 重新查询 this.searchData() } }) }, })