| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- /*******************************************************************************
- * Copyright(c) 2024 dongke All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:续费明细
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 周兴 2024-5-23 1.00 新建
- *******************************************************************************/
- const Constants = require('@/utils/Constants.js');
- const util = require('@/utils/util.js')
- const mixins = require('@/mixins/index.js');
- const app = getApp()
- Page({
- mixins: [mixins],
- /**
- * 页面的初始数据
- */
- data: {
- // 企业名称
- staffInfo: null,
- saveParams: null,
- staffService: app.globalData['staffService'],
- routeObjName: 'company',
- active: 0,
- pageFlag: false,
- tableDataSocial: null,
- tagList: [{ title: mixins.$t('wxRight'), code: 'wx' }, { title: mixins.$t('webRight'), code: 'web' }],
- 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') },
- ],
- //按钮
- buttonSaveList: [
- { code: 'save', title: mixins.$t('save') }
- ],
- // 取消授权的staffid
- delStaffIds:[],
- },
- /**
- * @desc : 给参数赋值
- * @date : 2024/5/30 15:49
- * @author : 周兴
- */
- setSearchParams(params) {
- params.flgCanLogin = true;
- params.flgValid = true;
- params.currentPage = 1;
- params.pageSize = Constants.MAX_PAGE_SIZE;
- if (this.data.gradeCode == Constants.gradeCode.STD) {
- // 标准版需要排除掉 企业授权的那个用户
- // params.flgInit = false;
- }
- return params;
- },
- /**
- * @desc : 查询
- * @date : 2024/5/30 15:49
- * @author : 周兴
- */
- getData(params) {
- return this.excute(this.data.staffService, this.data.staffService.selectByCond, params);
- },
- /**
- * @desc : 处理数据
- * @date : 2024/5/30 15:49
- * @author : 周兴
- */
- handleSearchData(tableData) {
- this.setData({
- tableDataSocial: [...tableData]
- })
- // 过滤出手机授权(默认展示)
- tableData = tableData.filter(it => it.loginType == Constants.loginType.loginTypeWx
- || it.loginType == Constants.loginType.loginTypeWxPc);
- this.setData({
- tableData: tableData
- })
- // 刷新数量
- this.refreshTag();
- },
- /**
- * @desc : 刷新量
- * @date : 2024/5/23 15:49
- * @author : 周兴
- */
- refreshTag() {
- if (this.data.gradeCode == Constants.gradeCode.STD) {
- let staffInfo = this.data.staffInfo;
- let filters = staffInfo.filter(it => it.code == 'current');
- if (filters && filters.length > 0) {
- let tableData = [...this.data.tableDataSocial]
- tableData = tableData.filter(it => it.loginType == Constants.loginType.loginTypeWx
- || it.loginType == Constants.loginType.loginTypeWxPc);
- filters[0].userCount = tableData.length;
- this.setData({
- staffInfo: staffInfo
- })
- }
- } else {
- let tagList = this.data.tagList
- let tableData = [...this.data.tableDataSocial]
- tableData = tableData.filter(it => it.loginType == Constants.loginType.loginTypeWx
- || it.loginType == Constants.loginType.loginTypeWxPc);
- let filters = tagList.filter(it => it.code == 'wx');
- if (filters && filters.length > 0) {
- filters[0].title = mixins.$t('wxRight') + '【' + tableData.length + '】'
- }
- let webData = [...this.data.tableDataSocial]
- // 电脑端授权
- webData = webData.filter(it => it.loginType == Constants.loginType.loginTypePc
- || it.loginType == Constants.loginType.loginTypeWxPc);
- filters = tagList.filter(it => it.code == 'web');
- if (filters && filters.length > 0) {
- filters[0].title = mixins.$t('webRight') + '【' + webData.length + '】'
- }
- this.setData({
- tagList: tagList
- })
- }
- },
- /**
- * @desc : 停用用户,不再续费
- * @date : 2024/5/23 15:49
- * @author : 周兴
- */
- handleStaff(e) {
- let item = e.detail.item
- if (item.flgInit) {
- util.showToast('责任人不能取消授权')
- return
- }
- let staffId = item.staffId
- let delStaffIds = this.data.delStaffIds
- delStaffIds.push(staffId)
- // 过滤掉停用的这条数据
- let tableDataSocial = this.data.tableDataSocial
- tableDataSocial = tableDataSocial.filter(it => it.staffId != staffId)
- let tableData = this.data.tableData
- tableData = tableData.filter(it => it.staffId != staffId)
- this.setData({
- tableDataSocial: tableDataSocial,
- tableData: tableData,
- delStaffIds,
- })
- // 刷新数量
- this.refreshTag();
- // 不调用接口 240718
- // return this.excute(this.data.staffService, this.data.staffService.disable, staffId).then(res => {
- // if (res.data.code == Constants.SUCESS_CODE) {
- // wx.showToast({
- // title: '操作成功',
- // image: '/static/image/success.png',
- // duration: 2000
- // })
- // // 过滤掉停用的这条数据
- // let tableDataSocial = this.data.tableDataSocial
- // tableDataSocial = tableDataSocial.filter(it => it.staffId != staffId)
- // let tableData = this.data.tableData
- // tableData = tableData.filter(it => it.staffId != staffId)
- // this.setData({
- // tableDataSocial: tableDataSocial,
- // tableData: tableData
- // })
- // // 刷新数量
- // this.refreshTag();
- // }
- // });
- },
- /**
- * @desc : 校验数据
- * @date : 2024/5/30 15:49
- * @author : 周兴
- */
- validData() {
- // 校验现在的用户数是否超过续费授权数
- let tableDataSocial = this.data.tableDataSocial
- let staffInfo = this.data.staffInfo
- let staffFilters = staffInfo.filter(it => it.code == 'renew');
- // 判断手机授权
- let wxFilters = tableDataSocial.filter(it => it.loginType == Constants.loginType.loginTypeWx
- || it.loginType == Constants.loginType.loginTypeWxPc);
- if (wxFilters.length > staffFilters[0].wxMaxNum) {
- util.showToast('当前手机授权数超过续费手机授权数')
- return false;
- }
- // 判断电脑授权
- let webFilters = tableDataSocial.filter(it => it.loginType == Constants.loginType.loginTypePc
- || it.loginType == Constants.loginType.loginTypeWxPc);
- if (webFilters.length > staffFilters[0].webMaxNum) {
- util.showToast('当前电脑授权数超过续费电脑授权数')
- return false;
- }
- return true;
- },
- /**
- * @desc : 设置保存参数
- * @author : 周兴
- * @date : 2024/4/1
- */
- setParams(params) {
- params = this.data.saveParams
- // 取消授权的staffid
- if (this.data.delStaffIds.length > 0 && params.reNew!=null){
- params.reNew.del_staff_ids = this.data.delStaffIds
- }
- return params;
- },
- /**
- * @desc : 保存数据
- * @author : 周兴
- * @date : 2024/5/17
- */
- saveData(params) {
- return this.excute(this.data.service, this.data.service.reNewCompany, params).then(res => {
- if (res.data.code == Constants.SUCESS_CODE) {
- // 成功后跳转支付
- this.toPay(res.data.data);
- }else {
- // 调转主页
- wx.reLaunch({
- url: '/pages/welcome/welcome',
- })
- }
- })
- },
- /**
- * @desc : 切换,查询用户
- * @date : 2024/5/23 15:49
- * @author : 周兴
- */
- onChangeTabs(e) {
- let code = e.detail.detail.code
- let tableDataSocial = [...this.data.tableDataSocial];
- let tableData = null;
- let tagList = this.data.tagList
- let filters = []
- if (code == 'web') {
- // 过滤出电脑授权
- tableData = tableDataSocial.filter(it => it.loginType == Constants.loginType.loginTypePc
- || it.loginType == Constants.loginType.loginTypeWxPc);
- filters = tagList.filter(it => it.code == 'web');
- if (filters && filters.length > 0) {
- filters[0].title = mixins.$t('webRight') + '【' + tableData.length + '】'
- }
- } else {
- // 过滤出手机授权
- tableData = tableDataSocial.filter(it => it.loginType == Constants.loginType.loginTypeWx
- || it.loginType == Constants.loginType.loginTypeWxPc);
- filters = tagList.filter(it => it.code == 'wx');
- if (filters && filters.length > 0) {
- filters[0].title = mixins.$t('wxRight') + '【' + tableData.length + '】'
- }
- }
- this.setData({
- tableData: tableData,
- tagList: tagList
- })
- },
- /**
- * @desc : 初始加载
- * @date : 2024/5/23 15:49
- * @author : 周兴
- */
- loadInit() {
- this.setData({
- saveParams: { ...this.data.params }
- })
- },
- /**
- * @desc : 初始加载(生命周期函数)
- * @date : 2024/5/23 15:49
- * @author : 周兴
- */
- onLoad(options) {
- this.setData({
- staffInfo: JSON.parse(options.staffInfo)
- })
- }
- })
|