Commit 95d23b6c by 胡悦

修改批量员工接口

1 parent 68839c5e
...@@ -125,8 +125,8 @@ const updateStatusApi = params => { ...@@ -125,8 +125,8 @@ const updateStatusApi = params => {
} }
// 批量更新员工角色 // 批量更新员工角色
const updateStaffRoleBatch = params => { const addStaffRoleBatch = params => {
params.method = `${defaultPath}staff.updateStaffRoleBatch` params.method = `${defaultPath}staff.addStaffRoleBatch`
return http({ return http({
url: 'rop-merchants/router', url: 'rop-merchants/router',
method: 'POST', method: 'POST',
...@@ -146,4 +146,4 @@ const updateStatusBatch = params => { ...@@ -146,4 +146,4 @@ const updateStatusBatch = params => {
}) })
} }
export default { getListApi, getAllMerchantListApi, getRoleListApi, getAllDictApi, getMerchantTreeApi, getDetailInfoApi, getDetailLogApi, addEmployeeApi, updateEmployeeApi, deleteEmployeeApi, exportEmployeeApi, updateStatusApi, updateStaffRoleBatch, updateStatusBatch } export default { getListApi, getAllMerchantListApi, getRoleListApi, getAllDictApi, getMerchantTreeApi, getDetailInfoApi, getDetailLogApi, addEmployeeApi, updateEmployeeApi, deleteEmployeeApi, exportEmployeeApi, updateStatusApi, addStaffRoleBatch, updateStatusBatch }
...@@ -530,7 +530,6 @@ export default { ...@@ -530,7 +530,6 @@ export default {
}) })
}, },
batch(type) { batch(type) {
console.log(handleObj[type]);
const name = handleObj[type] const name = handleObj[type]
const selectArr = this.$refs.employeeRef.mutiSelectArr[this.tableParams1.mutiSelectName] const selectArr = this.$refs.employeeRef.mutiSelectArr[this.tableParams1.mutiSelectName]
if (!selectArr.length) { if (!selectArr.length) {
...@@ -548,12 +547,15 @@ export default { ...@@ -548,12 +547,15 @@ export default {
this.roleVisible = true this.roleVisible = true
} }
} else if (name == '启用') { } else if (name == '启用') {
const hasNoRole = selectArr.some(item => !item.roleName)
if (hasNoRole) {
this.$message.error('您选中的员工中包含未设置“角色”账号,请去除选中未设置“角色”员工账号。')
} else {
this.$confirm(`是否将选中的账号批量进行启用?`, '', { this.$confirm(`是否将选中的账号批量进行启用?`, '', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
console.log('点击了确定')
const list = selectArr.map(item => { const list = selectArr.map(item => {
return { return {
staffId: item.id, staffId: item.id,
...@@ -575,6 +577,7 @@ export default { ...@@ -575,6 +577,7 @@ export default {
console.log('点击了取消') console.log('点击了取消')
}) })
} }
}
}, },
// 批量分配角色,确定按钮 // 批量分配角色,确定按钮
...@@ -582,18 +585,20 @@ export default { ...@@ -582,18 +585,20 @@ export default {
this.$refs.roleForm.validate((valid) => { this.$refs.roleForm.validate((valid) => {
if (valid) { if (valid) {
const { roleId } = this.roleForm const { roleId } = this.roleForm
let list = this.$refs.employeeRef.mutiSelectArr[this.tableParams1.mutiSelectName] let staffIds = this.$refs.employeeRef.mutiSelectArr[this.tableParams1.mutiSelectName]
list = list.map(item => { staffIds = staffIds.map(item => item.id)
return { // list = list.map(item => {
staffId: item.id, // return {
roleId // staffId: item.id
} // roleId,
}) // }
// })
const param = { const param = {
list roleId,
staffIds
} }
console.log(param) console.log(param)
this.$apis.employee.updateStaffRoleBatch(param).then(res => { this.$apis.employee.addStaffRoleBatch(param).then(res => {
console.log(res) console.log(res)
if (res) { if (res) {
this.$message.success('操作成功') this.$message.success('操作成功')
...@@ -609,6 +614,8 @@ export default { ...@@ -609,6 +614,8 @@ export default {
}, },
handleClose() { handleClose() {
this.roleVisible = false this.roleVisible = false
this.roleForm = {}
this.$refs.roleForm.resetFields()
}, },
// 表格分页穿透事件 // 表格分页穿透事件
paginationlisteners(val) { paginationlisteners(val) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!