增加店铺名和等级等的更新

This commit is contained in:
zhl 2021-05-08 14:25:30 +08:00
parent 1d7a350bb0
commit 8f90002491
2 changed files with 32 additions and 1 deletions

View File

@ -21,6 +21,8 @@ export interface IUserState {
email: string
permissions: string[][]
department?: string
deptname?: string
level: number
}
@Module({ dynamic: true, store, name: 'user' })
@ -33,6 +35,8 @@ class User extends VuexModule implements IUserState {
public permissions: string[][] = []
public email = ''
public department = ''
public deptname = ''
public level = 999
@Action
public async Login(userInfo: { username: string, password: string }) {
@ -60,7 +64,7 @@ class User extends VuexModule implements IUserState {
if (!data) {
throw Error('Verification failed, please Login again.')
}
const { roles, showname, avatar, introduction, permissions, department } = data
const { roles, showname, avatar, introduction, permissions, department, level, deptname } = data
// roles must be a non-empty array
if (!roles || roles.length <= 0) {
throw Error('GetUserInfo: roles must be a non-null array!')
@ -71,6 +75,8 @@ class User extends VuexModule implements IUserState {
this.SET_INTRODUCTION(introduction)
this.SET_PERMISSIONS(permissions)
this.SET_DEPARTMENT(department)
this.SET_LEVEL(level)
this.SET_DEPTNAME(deptname)
}
@Action
@ -132,6 +138,16 @@ class User extends VuexModule implements IUserState {
this.department = department
}
@Mutation
private SET_DEPTNAME(deptname: string) {
this.deptname = deptname
}
@Mutation
private SET_LEVEL(level: number) {
this.level = level
}
@Mutation
private SET_PERMISSIONS(permissions: string[]) {
const results: string[][] = []

View File

@ -9,6 +9,13 @@
:key="role"
>{{ role }}</span>
</div>
<div class="dashboard-text">
level:{{ level }}
</div>
<div class="dashboard-text">
店铺:{{ deptname }}
</div>
</div>
</template>
@ -27,6 +34,14 @@ export default class extends Vue {
get roles() {
return UserModule.roles
}
get level() {
return UserModule.level
}
get deptname() {
return UserModule.deptname
}
}
</script>