Commit 3043763bfe64ad62940fe7a3f3a8fa1ba9bfde68
1 parent
d03205eb
debug user list actions
Showing
4 changed files
with
54 additions
and
13 deletions
src/api/user/login/index.ts
| @@ -14,6 +14,18 @@ export const login = async ( data: any ) => { | @@ -14,6 +14,18 @@ export const login = async ( data: any ) => { | ||
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | /** | 16 | /** |
| 17 | + * @description 登出 | ||
| 18 | + * @function logout | ||
| 19 | + */ | ||
| 20 | +export const logout = async () => { | ||
| 21 | + let res: any = await request({ | ||
| 22 | + url: '/logout', | ||
| 23 | + method: 'get' | ||
| 24 | + }) | ||
| 25 | + return res | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +/** | ||
| 17 | * @description 权限菜单 | 29 | * @description 权限菜单 |
| 18 | * @function menuData | 30 | * @function menuData |
| 19 | */ | 31 | */ |
src/pinia/modules/login.ts
| 1 | -import router from '@/router' | 1 | +import router from '@/router'; |
| 2 | +import { logout } from '@/api/user/login'; | ||
| 2 | import { ElMessage } from "element-plus"; | 3 | import { ElMessage } from "element-plus"; |
| 3 | interface LoginUser { | 4 | interface LoginUser { |
| 4 | token: string, | 5 | token: string, |
| @@ -60,6 +61,7 @@ const actions = { | @@ -60,6 +61,7 @@ const actions = { | ||
| 60 | this.organizationLogo = obj.organizationLogo | 61 | this.organizationLogo = obj.organizationLogo |
| 61 | }, | 62 | }, |
| 62 | removeToken(msg: string | null) { | 63 | removeToken(msg: string | null) { |
| 64 | + logout() | ||
| 63 | this.token = '' | 65 | this.token = '' |
| 64 | window.localStorage.removeItem('store-data') | 66 | window.localStorage.removeItem('store-data') |
| 65 | ElMessage.success(msg || '已退出登录'); | 67 | ElMessage.success(msg || '已退出登录'); |
src/views/role/index.vue
| @@ -47,8 +47,8 @@ const getList = async () => { | @@ -47,8 +47,8 @@ const getList = async () => { | ||
| 47 | data.loading = true; | 47 | data.loading = true; |
| 48 | try { | 48 | try { |
| 49 | const res = await roleList(data.params.query); | 49 | const res = await roleList(data.params.query); |
| 50 | - data.list = res.data.data.list; | ||
| 51 | - data.params.total = res.data.data.total; | 50 | + data.list = res?.data?.data?.list; |
| 51 | + data.params.total = res?.data?.data?.total; | ||
| 52 | } catch (e) { | 52 | } catch (e) { |
| 53 | console.log(e); | 53 | console.log(e); |
| 54 | } finally { | 54 | } finally { |
src/views/user/index.vue
| @@ -35,6 +35,7 @@ let data = reactive({ | @@ -35,6 +35,7 @@ let data = reactive({ | ||
| 35 | }); | 35 | }); |
| 36 | let asyncData = reactive({ | 36 | let asyncData = reactive({ |
| 37 | userInfo: null, | 37 | userInfo: null, |
| 38 | + userType: null, | ||
| 38 | }); | 39 | }); |
| 39 | /** | 40 | /** |
| 40 | * 列表 | 41 | * 列表 |
| @@ -147,6 +148,7 @@ enum statusEnum { | @@ -147,6 +148,7 @@ enum statusEnum { | ||
| 147 | } | 148 | } |
| 148 | onMounted(() => { | 149 | onMounted(() => { |
| 149 | asyncData.userInfo = store.family.loginStore().id; | 150 | asyncData.userInfo = store.family.loginStore().id; |
| 151 | + asyncData.userType = store.family.loginStore().organizationType; | ||
| 150 | getList(); | 152 | getList(); |
| 151 | }); | 153 | }); |
| 152 | </script> | 154 | </script> |
| @@ -210,10 +212,8 @@ onMounted(() => { | @@ -210,10 +212,8 @@ onMounted(() => { | ||
| 210 | </el-table-column> | 212 | </el-table-column> |
| 211 | <el-table-column label="操作" align="center"> | 213 | <el-table-column label="操作" align="center"> |
| 212 | <template #default="scope"> | 214 | <template #default="scope"> |
| 213 | - <!-- 超管可以做全部操作 --> | ||
| 214 | - <template v-if="!['SUPER_ADMIN'].includes( | ||
| 215 | - scope.row.roleList.map((i) => i.code).join(',') | ||
| 216 | - )"> | 215 | + <template v-if="~~asyncData.userInfo === 1"> |
| 216 | + <!-- 超管可以做所有操作 --> | ||
| 217 | <el-button type="text" | 217 | <el-button type="text" |
| 218 | ><router-link :to="{ path: '/user/edit', query: scope.row }" | 218 | ><router-link :to="{ path: '/user/edit', query: scope.row }" |
| 219 | >编辑</router-link | 219 | >编辑</router-link |
| @@ -235,18 +235,45 @@ onMounted(() => { | @@ -235,18 +235,45 @@ onMounted(() => { | ||
| 235 | >删除</el-button | 235 | >删除</el-button |
| 236 | > | 236 | > |
| 237 | </template> | 237 | </template> |
| 238 | - <!-- 物业管理员(机构管理员)、商务管理员只可以改密码 --> | ||
| 239 | - <!-- 其他角色用户不可以做任何操作 以上均通过角色的code判断 --> | ||
| 240 | <template | 238 | <template |
| 241 | - v-if=" | ||
| 242 | - !['PROPERTY_ADMIN', 'BUSINESS_ADMIN'].includes( | ||
| 243 | - scope.row.roleList.map((i) => i.code).join(',') | ||
| 244 | - ) | 239 | + v-else-if=" |
| 240 | + [ | ||
| 241 | + 'PROPERTY_ADMIN', | ||
| 242 | + 'BUSINESS_ADMIN', | ||
| 243 | + 'PUBLIC_BENEFIT_ADMIN', | ||
| 244 | + ].includes(scope.row.roleList.map((i) => i.code).join(',')) | ||
| 245 | " | 245 | " |
| 246 | > | 246 | > |
| 247 | + <!-- 商务管理员 物业管理员 公益管理员 --> | ||
| 248 | + <template v-if="~~scope.row.id === ~~asyncData.userInfo"> | ||
| 249 | + <!-- 当前登录的人是三种管理员只能初始自己的密码, --> | ||
| 250 | + <el-button type="text" @click="handleUpdate(scope.row, 'pwd')" | ||
| 251 | + >初始密码</el-button | ||
| 252 | + > | ||
| 253 | + </template> | ||
| 254 | + </template> | ||
| 255 | + <template v-else> | ||
| 256 | + <!-- 不是超管,不是三种管理员,随意操作 --> | ||
| 257 | + <el-button type="text" | ||
| 258 | + ><router-link :to="{ path: '/user/edit', query: scope.row }" | ||
| 259 | + >编辑</router-link | ||
| 260 | + ></el-button | ||
| 261 | + > | ||
| 262 | + <el-button type="text" @click="handleUpdate(scope.row, 'status')">{{ | ||
| 263 | + scope.row.status ? "禁用" : "启用" | ||
| 264 | + }}</el-button> | ||
| 247 | <el-button type="text" @click="handleUpdate(scope.row, 'pwd')" | 265 | <el-button type="text" @click="handleUpdate(scope.row, 'pwd')" |
| 248 | >初始密码</el-button | 266 | >初始密码</el-button |
| 249 | > | 267 | > |
| 268 | + <el-button type="text" | ||
| 269 | + ><router-link | ||
| 270 | + :to="{ path: '/user/role', query: { id: scope.row.id } }" | ||
| 271 | + >角色</router-link | ||
| 272 | + ></el-button | ||
| 273 | + > | ||
| 274 | + <el-button type="text" @click="handleDelete(scope.row)" | ||
| 275 | + >删除</el-button | ||
| 276 | + > | ||
| 250 | </template> | 277 | </template> |
| 251 | </template> | 278 | </template> |
| 252 | </el-table-column> | 279 | </el-table-column> |