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

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

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