提交 02f0514f authored 作者: pengxiaohui's avatar pengxiaohui

设置模块更新删除操作,更新用户详情信息store

上级 1ee97c2d
...@@ -47,12 +47,13 @@ export default { ...@@ -47,12 +47,13 @@ export default {
toggleSideBar() { toggleSideBar() {
this.$store.dispatch('app/toggleSideBar') this.$store.dispatch('app/toggleSideBar')
}, },
toMeeting() {
this.$router.push('/meeting-create')
},
async logout() { async logout() {
await this.$store.dispatch('logout') await this.$store.dispatch('logout')
this.$router.push(this.$route.fullPath) let path = this.$route.fullPath
if (path.includes('error-page')) {
path = '/content-manage/ads'
}
this.$router.push(path)
} }
} }
} }
......
...@@ -112,6 +112,7 @@ ...@@ -112,6 +112,7 @@
</template> </template>
<script> <script>
import TableList from '@/components/TableList' import TableList from '@/components/TableList'
import { mapGetters } from 'vuex'
import { import {
getProjectList, getProjectList,
getTypeList, getTypeList,
...@@ -134,10 +135,6 @@ export default { ...@@ -134,10 +135,6 @@ export default {
data() { data() {
return { return {
activeName: '0', activeName: '0',
projectList: [
{ project_id: '111', project_name: '官网' },
{ project_id: '222', project_name: 'kellet' }
],
statusList: [ statusList: [
{ id: '1', name: '启用' }, { id: '1', name: '启用' },
{ id: '0', name: '停用' } { id: '0', name: '停用' }
...@@ -172,6 +169,10 @@ export default { ...@@ -172,6 +169,10 @@ export default {
} }
}, },
computed: { computed: {
...mapGetters(['projects']),
userProjectIds() {
return this.projects.map(item => item.id)
},
// 权限列表 // 权限列表
permissions() { permissions() {
return this.$store.state.user.permissions || [] return this.$store.state.user.permissions || []
...@@ -236,6 +237,7 @@ export default { ...@@ -236,6 +237,7 @@ export default {
} }
}, },
created() { created() {
console.log(this.userProjectIds)
this.fetchProjectTypeList() this.fetchProjectTypeList()
this.fetchContentTypeList() this.fetchContentTypeList()
}, },
...@@ -334,6 +336,10 @@ export default { ...@@ -334,6 +336,10 @@ export default {
if (res.code === 0 && res.message === 'SUCCESS') { if (res.code === 0 && res.message === 'SUCCESS') {
this.$message.success(msg + '成功') this.$message.success(msg + '成功')
this.$refs.tabList.refetch() this.$refs.tabList.refetch()
// 刷新用户user_detail
if (this.userProjectIds.includes(data.project_id)) {
this.$store.dispatch('checkRolesPermissions')
}
} else { } else {
this.$message.error(res.message || msg + '失败') this.$message.error(res.message || msg + '失败')
} }
...@@ -344,6 +350,10 @@ export default { ...@@ -344,6 +350,10 @@ export default {
if (res.code === 0 && res.data && res.data.status) { if (res.code === 0 && res.data && res.data.status) {
this.$message.success('删除项目成功') this.$message.success('删除项目成功')
this.$refs.tabList.refetch() this.$refs.tabList.refetch()
// 刷新用户user_detail
if (this.userProjectIds.includes(this.multipleSelection[0])) {
this.$store.dispatch('checkRolesPermissions')
}
} else { } else {
this.$message.error(res.message || '删除项目失败') this.$message.error(res.message || '删除项目失败')
} }
......
...@@ -104,6 +104,11 @@ export default { ...@@ -104,6 +104,11 @@ export default {
} }
}, },
computed: { computed: {
userRoleId() {
let roleId = ''
if (this.$store.state.user.roles.length) roleId = this.$store.state.user.roles[0].id
return roleId
},
dialogTitle() { dialogTitle() {
let text = '新建角色' let text = '新建角色'
switch (this.dialogType) { switch (this.dialogType) {
...@@ -155,6 +160,7 @@ export default { ...@@ -155,6 +160,7 @@ export default {
} }
}, },
created() { created() {
console.log(this.$store.state.user.roles)
this.fetchPermissionList() this.fetchPermissionList()
}, },
methods: { methods: {
...@@ -218,7 +224,6 @@ export default { ...@@ -218,7 +224,6 @@ export default {
this.checkAll = this.isCheckAll this.checkAll = this.isCheckAll
this.indeterminate = this.isIndeterminate this.indeterminate = this.isIndeterminate
}, },
// isCheckedAll() {},
handleDialogClose() { handleDialogClose() {
this.dialogVisible = false this.dialogVisible = false
this.assignForm() this.assignForm()
...@@ -280,6 +285,10 @@ export default { ...@@ -280,6 +285,10 @@ export default {
const data = { const data = {
role_id: this.selectedTableItem.id role_id: this.selectedTableItem.id
} }
if (this.userRoleId === data.role_id) {
this.$message.error('不能删除你自己账户所分配的角色')
return
}
deleteRole(data).then((res) => { deleteRole(data).then((res) => {
if (res.code === 0 && res.data && res.data.status) { if (res.code === 0 && res.data && res.data.status) {
this.fetchRoleList() this.fetchRoleList()
...@@ -307,6 +316,10 @@ export default { ...@@ -307,6 +316,10 @@ export default {
if (res.code === 0 && res.data && res.data.status) { if (res.code === 0 && res.data && res.data.status) {
this.fetchRoleList() this.fetchRoleList()
this.$message.success('权限配置成功') this.$message.success('权限配置成功')
// 刷新用户user_detail
if (this.userRoleId === data.role_id) {
this.$store.dispatch('checkRolesPermissions')
}
} else { } else {
this.$message.error('权限配置失败') this.$message.error('权限配置失败')
} }
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
</template> </template>
<!-- 项目 --> <!-- 项目 -->
<template v-slot:table-project="{ row }"> <template v-slot:table-project="{ row }">
<p class="details-handle" v-for="(item, index) in row.projects" :key="index">{{index > 0 ? '、' : ''}}{{item.name}}</p> <p class="details-handle">
<span v-for="(item, index) in row.projects" :key="index">{{index > 0 ? '、' : ''}}{{item.name}}</span>
</p>
</template> </template>
<!-- 创建人 --> <!-- 创建人 -->
<template v-slot:table-creator="{ row }"> <template v-slot:table-creator="{ row }">
...@@ -25,10 +27,10 @@ ...@@ -25,10 +27,10 @@
<el-switch v-model="row.status" :active-value="0" :inactive-value="1" active-text="启用" inactive-text="停用" @change="statusChange(row)" :disabled="!hasCreate"></el-switch> <el-switch v-model="row.status" :active-value="0" :inactive-value="1" active-text="启用" inactive-text="停用" @change="statusChange(row)" :disabled="!hasCreate"></el-switch>
</template> </template>
<!-- 操作 --> <!-- 操作 -->
<template v-slot:tools="{ row }"> <!-- <template v-slot:tools="{ row }">
<el-button type="text" @click="changePassword(row)">重置密码</el-button> <el-button type="text" @click="changePassword(row)">重置密码</el-button>
<el-button type="text" @click="changePhone(row)">更换手机号</el-button> <el-button type="text" @click="changePhone(row)">更换手机号</el-button>
</template> </template> -->
<template #footer> <template #footer>
<el-button size="mini" :disabled="!multipleSelection.length" @click="handleRemove" v-if="hasDelete" <el-button size="mini" :disabled="!multipleSelection.length" @click="handleRemove" v-if="hasDelete"
>删除</el-button >删除</el-button
...@@ -129,6 +131,7 @@ import TableList from '@/components/TableList' ...@@ -129,6 +131,7 @@ import TableList from '@/components/TableList'
import { getStaffList, getProjectList, getRoleList, createStaff, updateStaff, batchDeleteStaff, clearUserCached } from '@/api/settings' import { getStaffList, getProjectList, getRoleList, createStaff, updateStaff, batchDeleteStaff, clearUserCached } from '@/api/settings'
import { sendCode, updatePassword, updateUserInfo } from '@/api/account' import { sendCode, updatePassword, updateUserInfo } from '@/api/account'
import { searchUserList } from '@/api/system' import { searchUserList } from '@/api/system'
import { mapGetters } from 'vuex'
const MOBILE_REG = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{4,8}$/ const MOBILE_REG = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{4,8}$/
const EMAIL_REG = /^[A-Za-z0-9]+([_.][A-Za-z0-9]+)*@[A-Za-z0-9-.]+$/ const EMAIL_REG = /^[A-Za-z0-9]+([_.][A-Za-z0-9]+)*@[A-Za-z0-9-.]+$/
const drawerForm = { const drawerForm = {
...@@ -182,6 +185,7 @@ export default { ...@@ -182,6 +185,7 @@ export default {
} }
}, },
computed: { computed: {
...mapGetters(['user']),
// 权限列表 // 权限列表
permissions() { permissions() {
return this.$store.state.user.permissions || [] return this.$store.state.user.permissions || []
...@@ -240,8 +244,8 @@ export default { ...@@ -240,8 +244,8 @@ export default {
{ prop: 'projects', label: '项目', minWidth: '130px', slots: 'table-project' }, { prop: 'projects', label: '项目', minWidth: '130px', slots: 'table-project' },
{ prop: 'create_user', label: '创建人', minWidth: '80px', slots: 'table-creator' }, { prop: 'create_user', label: '创建人', minWidth: '80px', slots: 'table-creator' },
{ prop: 'created_at', label: '创建时间', minWidth: '150px' }, { prop: 'created_at', label: '创建时间', minWidth: '150px' },
{ prop: 'status', label: '状态', slots: 'status', minWidth: '140px', fixed: 'right' }, { prop: 'status', label: '状态', slots: 'status', minWidth: '140px', fixed: 'right' }
{ prop: 'x', label: '操作', slots: 'tools', minWidth: '200px', fixed: 'right', visible: this.hasCreate } // { prop: 'x', label: '操作', slots: 'tools', minWidth: '200px', fixed: 'right', visible: this.hasCreate }
] ]
} }
} }
...@@ -259,6 +263,10 @@ export default { ...@@ -259,6 +263,10 @@ export default {
// 删除 // 删除
handleRemove() { handleRemove() {
const ids = this.multipleSelection.map(item => item.sso_id) const ids = this.multipleSelection.map(item => item.sso_id)
if (ids.includes(this.user.id)) {
this.$message.error('您所删除的员工包含你的账户,删除后将导致您没法使用此系统')
return
}
batchDeleteStaff({ sso_ids: ids }).then(res => { batchDeleteStaff({ sso_ids: ids }).then(res => {
if (res.code === 0) { if (res.code === 0) {
this.$message.success('删除成功') this.$message.success('删除成功')
...@@ -296,13 +304,11 @@ export default { ...@@ -296,13 +304,11 @@ export default {
}, },
// 重置密码 // 重置密码
changePassword(data) { changePassword(data) {
console.log(data)
this.operateItem = data this.operateItem = data
this.dialogVisible = true this.dialogVisible = true
this.dialogType = 'pwd' this.dialogType = 'pwd'
}, },
sendCode() { sendCode() {
console.log(this.dialogForm)
if (!this.dialogForm.phone) { if (!this.dialogForm.phone) {
this.$message('请填写手机号') this.$message('请填写手机号')
} else if (!MOBILE_REG.test(this.dialogForm.phone)) { } else if (!MOBILE_REG.test(this.dialogForm.phone)) {
...@@ -342,7 +348,7 @@ export default { ...@@ -342,7 +348,7 @@ export default {
form.role_id = val.roles[0] ? val.roles[0].id : '' form.role_id = val.roles[0] ? val.roles[0].id : ''
form.project_ids = val.projects.map(item => item.id) || [] form.project_ids = val.projects.map(item => item.id) || []
this.operateItem = val this.operateItem = val
console.log(val) this.userList = [val.sso_user]
this.drawerVisible = true this.drawerVisible = true
this.drawerType = 'details' this.drawerType = 'details'
} }
...@@ -440,6 +446,10 @@ export default { ...@@ -440,6 +446,10 @@ export default {
this.$message.success(msg + '成功') this.$message.success(msg + '成功')
this.$refs.tabList.refetch() this.$refs.tabList.refetch()
this.handleDrawerClose() this.handleDrawerClose()
// 刷新用户user_detail
if (this.user.id === data.sso_id) {
this.$store.dispatch('checkRolesPermissions')
}
} else { } else {
this.$message.error(res.message || msg + '失败') this.$message.error(res.message || msg + '失败')
} }
......
...@@ -237,6 +237,8 @@ export default { ...@@ -237,6 +237,8 @@ export default {
if (res.code === 0) { if (res.code === 0) {
this.$message.success('删除成功') this.$message.success('删除成功')
this.$refs.tableList.refetch(true) this.$refs.tableList.refetch(true)
// 刷新用户user_detail
this.$store.dispatch('checkRolesPermissions')
} else { } else {
this.$message.error(res.message) this.$message.error(res.message)
} }
...@@ -311,6 +313,8 @@ export default { ...@@ -311,6 +313,8 @@ export default {
if (res.code === 0 && res.data && res.data.status) { if (res.code === 0 && res.data && res.data.status) {
this.$message.success(msg + '成功') this.$message.success(msg + '成功')
this.$refs.tableList.refetch() this.$refs.tableList.refetch()
// 刷新用户user_detail
if (type === 'status') this.$store.dispatch('checkRolesPermissions')
} else { } else {
this.$message.error(res.message || msg + '失败') this.$message.error(res.message || msg + '失败')
} }
......
...@@ -70,7 +70,7 @@ const user = { ...@@ -70,7 +70,7 @@ const user = {
let permissions = [] let permissions = []
let projects = [] let projects = []
if (data.roles && Array.isArray(data.roles)) { if (data.roles && Array.isArray(data.roles)) {
roles = data.roles.map(it => it.name) roles = data.roles
} }
commit('setRoles', roles) commit('setRoles', roles)
if (data.permissions && Array.isArray(data.permissions)) { if (data.permissions && Array.isArray(data.permissions)) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论