Commit e731c91a by cwq0219

公共notify提取

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