Commit e731c91a by cwq0219

公共notify提取

1 parent 6eb7e222
......@@ -8,10 +8,6 @@ function fn(data, pid) {
if (data[i].parent == pid) {
result.push(data[i])
temp = fn(data, data[i].id)
// if (data[i].id === 1013 || data[i].id === 1014) {
// console.log(`i = ${i}`)
// console.log(`pid = ${pid}`)
// }
if (temp.length > 0) {
data[i].children = temp
}
......
import Vue from 'vue'
export default new Vue({
methods: {
okTips(message) {
this.$notify({
type: 'success',
title: message
})
},
errorTips(message) {
this.$notify({
type: 'error',
title: message
})
}
}
})
import { deleteUserRoleById } from '@/api/api'
import notice from './notice'
const roleCreateStructure = {
id: Number,
......@@ -63,13 +64,15 @@ const userRoleDetailConsole = {
type: 'text',
callback: (index, rows) => {
const data = rows[index]
const params = { roleId: data.roleId, userId: data.userId }
const params = {
roleId: data.roleId,
userId: data.userId
}
deleteUserRoleById.req(params).then(res => {
// 加入提示消息!!!
notice.okTips('删除成功')
rows.splice(index, 1)
// console.log(res)
}).catch(err => {
console.log(err)
notice.errorTips(err)
})
}
}]
......
......@@ -53,6 +53,7 @@ import { RoleCreate, RoleDetail, UserDetail } from '@/components/index'
// 接口
import { getRoleList, deleteRoleById, selectMenuTreeRoleId, saveRoleList, updateRole, findDepartTree } from '@/api/api'
import { roleCreateStructure, roleDataColumn, userRoleDetailColumn, userRoleDetailConsole, fn } from '@/common/commonConst'
import notice from '@/common/notice'
export default {
name: 'role',
components: {
......@@ -138,12 +139,6 @@ export default {
}
},
methods: {
message(message, type) {
this.$notify({
type: type,
title: message
})
},
confirmDeleteOrNot(index, rows) {
this.$confirm('确定要删除这条数据?', '', {
confirmButtonText: '确定',
......@@ -177,10 +172,10 @@ export default {
// 删除角色
deleteRole(params) {
deleteRoleById.req({ roleId: params }).then(res => {
this.message('删除成功', 'success')
notice.okTips('删除成功')
this.getList()
}).catch(message => {
this.message(message, 'error')
notice.errorTips(message)
})
},
roleMenuOption(data, pid) {
......@@ -207,27 +202,25 @@ export default {
},
// 添加角色
addRole(params) {
// this.loading = false
saveRoleList.req(params).then((data) => {
this.createOrEditSuccess()
}).catch(err => {
this.message(err, 'error')
notice.errorTips(err)
console.log(err)
this.loading = false
})
this.loading = false
},
// 编辑角色
updateRoleInfo(params) {
// this.loading = false
delete params.createTime
delete params.updateTime
updateRole.req(params).then((data) => {
this.createOrEditSuccess()
}).catch(err => {
this.message(err, 'error')
notice.errorTips(err)
console.log(err)
this.loading = false
})
this.loading = false
},
// 获取部门树
getdepartData() {
......@@ -248,8 +241,8 @@ export default {
createOrEditSuccess() {
this.createDialogVisible()
this.loading = false
this.message(this.flagCOrE ? '创建角色成功!' : '已经成功修改数据!', 'success')
this.loading = false
notice.okTips(this.flagCOrE ? '创建角色成功!' : '已经成功修改数据!')
// this.loading = false
this.roleMenu = []
this.roleParamName = ''
this.getList()
......
......@@ -47,6 +47,7 @@ import { UserCreate, UserDetail } from '@/components/index'
// 接口
import { findAll, updateUser, getRoleList, batcheDelUser, operatUser, findDepartTree } from '@/api/api'
import { userForm, userDetailColumn, fn } from '@/common/commonConst'
import notice from '@/common/notice'
export default {
name: 'user',
components: {
......@@ -157,9 +158,9 @@ export default {
this.$set(rows[index], 'state', '0')
this.operatUser({ id: rows[index].id, state: 0 })
}
this.message('修改成功', 'success')
notice.okTips('修改成功')
}).catch(() => {
this.message('修改失败', 'info')
notice.errorTips('修改失败')
})
}
}, {
......@@ -204,17 +205,6 @@ export default {
console.log(err)
})
},
message(message, type) {
type && this.$notify({
type: type,
title: message,
duration: 2000
})
!type && this.$notify({
title: message,
duration: 2000
})
},
// 获取所有角色选项
getRoleOptions() {
getRoleList.req().then(res => {
......@@ -231,12 +221,12 @@ export default {
// 新增更新用户接口请求
updateUser_Post(params) {
updateUser.req(params).then(res => {
this.message('操作成功', 'success')
notice.okTips('操作成功')
this.dialogFormVisible = !this.dialogFormVisible
this.loading = false
this.findUserList()
}).catch(message => {
this.message(message, 'error')
notice.errorTips(message)
this.loading = false
})
},
......@@ -308,9 +298,10 @@ export default {
type: 'warning'
}).then(() => {
this.batcheDel(ids.join(','))
this.message('删除成功', 'success')
}).catch(() => {
console.log('error')
notice.okTips('删除成功')
}).catch(err => {
notice.errorTips(err)
// console.log('error')
})
}
},
......@@ -335,8 +326,9 @@ export default {
type: 'warning'
}).then(() => {
this.operatUser({ id: rows[index].id, state: 2 })
this.message('成功删除该用户', 'success')
}).catch(() => {
notice.okTips('成功删除该用户')
}).catch(err => {
notice.errorTips(err)
})
},
findRolesName(params) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!