diff --git a/pages/home/employee-info/index.js b/pages/home/employee-info/index.js index 34f5edd..9d8cfc8 100644 --- a/pages/home/employee-info/index.js +++ b/pages/home/employee-info/index.js @@ -22,9 +22,10 @@ Scene({ let channel = this.getOpenerEventChannel() let that = this channel.on('onParam', function (data) { - console.log(data) - if(data.enterpriseRoleIds.length){ + if(data.enterpriseRoleIds.length && data.enterpriseRoleIds.indexOf(',') > 0){ data.enterpriseRoleIds = data.enterpriseRoleIds.split(',') + } else if(!Array.isArray(data.enterpriseRoleIds) && data.enterpriseRoleIds.length){ + data.enterpriseRoleIds = [data.enterpriseRoleIds] } else { data.enterpriseRoleIds = [] } @@ -63,7 +64,7 @@ Scene({ }, submitForm: function(){ if (util.isEmpty(this.data.form.enterpriseRoleIds) || !this.data.form.enterpriseRoleIds.length) { - util.showToast('员工角色') + util.showToast('请选择员工角色') return } wx.showLoading({ title: '处理中', mask: true }) @@ -73,6 +74,8 @@ Scene({ editEmploye(this.data.form).then(result => { wx.hideLoading() util.showBackToast('修改成功') + const channel = this.getOpenerEventChannel() + channel.emit('onCallback', { what: 120 }) }).catch(err => { wx.hideLoading() util.showToast(err) @@ -80,7 +83,7 @@ Scene({ }, agreeForm: function(){ if (util.isEmpty(this.data.form.enterpriseRoleIds) || !this.data.form.enterpriseRoleIds.length) { - util.showToast('员工角色') + util.showToast('请选择员工角色') return } wx.showLoading({ title: '处理中', mask: true }) @@ -88,17 +91,8 @@ Scene({ auditEmploye(this.data.form).then(result => { wx.hideLoading() util.showBackToast('员工已经加入') - }).catch(err => { - wx.hideLoading() - util.showToast(err) - }) - }, - refuseform: function(){ - wx.showLoading({ title: '处理中', mask: true }) - this.data.form.status = 2 - auditEmploye(this.data.form).then(result => { - wx.hideLoading() - util.showBackToast('员工已经拒绝') + const channel = this.getOpenerEventChannel() + channel.emit('onCallback', { what: 120 }) }).catch(err => { wx.hideLoading() util.showToast(err) @@ -111,7 +105,7 @@ Scene({ wx.hideLoading() util.showBackToast('员工已经删除') const channel = this.getOpenerEventChannel() - channel.emit('onCallback', { what: 120, desc: 'PaymentOrder' }) + channel.emit('onCallback', { what: 120 }) }).catch(err => { wx.hideLoading() util.showToast(err) diff --git a/pages/home/employee-info/index.wxml b/pages/home/employee-info/index.wxml index 2a7e4c5..d238489 100644 --- a/pages/home/employee-info/index.wxml +++ b/pages/home/employee-info/index.wxml @@ -4,10 +4,10 @@ - - + + - + 员工状态: @@ -26,8 +26,6 @@ 保存 - 拒绝 - 同意 diff --git a/pages/home/employee/index.js b/pages/home/employee/index.js index d02655f..f6de77c 100644 --- a/pages/home/employee/index.js +++ b/pages/home/employee/index.js @@ -1,6 +1,6 @@ // pages/home/employee/index.js import Scene from '../../index/scene' -import { getCheckList, auditEmploye, adminEmploye, deleteEmploye, generateCode } from "../../../api/user" +import { getCheckList, auditEmploye, generateCode } from "../../../api/user" import { getEmployeList } from "../../../api/saas" const util = require('../../../utils/util') const app = getApp() @@ -46,9 +46,9 @@ Scene({ }) }, lookItem: function(e){ + var that = this this.data.nowIndex = e.currentTarget.dataset.index var item = this.data.memberList[this.data.nowIndex] - item.apply = 0 wx.navigateTo({ url: `/pages/home/employee-info/index?id=${item.enterpriseMemberId}`, events: { @@ -63,62 +63,36 @@ Scene({ } }) }, - // setAdmin: function(index, item){ - // wx.showLoading({ title: '加载中', mask: true }) - // if(item.position == 'ADMINISTRATOR'){ - // var sindex = -1 - // for (var i = 0; i < this.data.eemidList.length; i++) { - // if (this.data.eemidList[i] == item.id){ - // sindex = i - // break - // } - // } - // this.data.eemidList.splice(sindex, 1) - // } else { - // if(this.data.eemidList.indexOf(item.id) < 0){ - // this.data.eemidList.push(item.id) - // } - // } - // adminEmploye({ids: this.data.eemidList }).then(result => { - // this.setData({ ['memberList[' + index + '].position'] : item.position == 'ADMINISTRATOR' ? 'ORDINARY' : 'ADMINISTRATOR'}) - // wx.hideLoading() - // }).catch(err => { - // wx.hideLoading() - // util.showToast(err) - // }) - // }, - // deleteItem: function(index, item){ - // wx.showLoading({ title: '加载中', mask: true }) - // deleteEmploye({idList: [item.enterpriseMemberId] }).then(result => { - // this.fetchMemberList() - // }).catch(err => { - // wx.hideLoading() - // util.showToast(err) - // }) - // }, - // agreeItem: function(e){ - // wx.showLoading({ title: '加载中', mask: true }) - // var item = this.data.checkList[e.currentTarget.dataset.index] - // auditEmploye({id: item.id, status: 1 }).then(result => { - // this.fetchMemberList() - // }).catch(err => { - // wx.hideLoading() - // console.log(err) - // util.showToast(err) - // }) - // }, - // refuseItem: function(e){ - // wx.showLoading({ title: '加载中', mask: true }) - // var item = this.data.checkList[e.currentTarget.dataset.index] - // auditEmploye({id: item.id, status: 2 }).then(result => { - // this.setData({ ['checkList[' + e.currentTarget.dataset.index + '].status']: 2}) - // wx.hideLoading() - // }).catch(err => { - // wx.hideLoading() - // console.log(err) - // util.showToast(err) - // }) - // }, + agreeItem: function(e){ + var that = this + this.data.nowIndex = e.currentTarget.dataset.index + var item = this.data.checkList[this.data.nowIndex] + wx.navigateTo({ + url: `/pages/home/employee-info/index?id=${item.enterpriseMemberId}`, + events: { + onCallback: (data) => { + if (data.what == 120) { + that.fetchMemberList() + } + } + }, + success: function(res) { + res.eventChannel.emit('onParam', item) + } + }) + }, + refuseItem: function(e){ + wx.showLoading({ title: '加载中', mask: true }) + var item = this.data.checkList[e.currentTarget.dataset.index] + auditEmploye({id: item.id, status: 2 }).then(result => { + this.setData({ ['checkList[' + e.currentTarget.dataset.index + '].status']: 2}) + wx.hideLoading() + }).catch(err => { + wx.hideLoading() + console.log(err) + util.showToast(err) + }) + }, onClickHideEmbedded: function(){ this.setData({ showEmbedded: false }) }, diff --git a/pages/home/employee/index.wxml b/pages/home/employee/index.wxml index 943d8c0..24c5bdd 100644 --- a/pages/home/employee/index.wxml +++ b/pages/home/employee/index.wxml @@ -47,8 +47,7 @@ {{item.enterpriseMemberName || ''}} - 企业主 - 管理员 + {{item.enterpriseRoleNames}} {{item.mobile || ''}}