Commit 3043763bfe64ad62940fe7a3f3a8fa1ba9bfde68

Authored by 杨泽宇
1 parent d03205eb

debug user list actions

src/api/user/login/index.ts
... ... @@ -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 29 * @description 权限菜单
18 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 3 import { ElMessage } from "element-plus";
3 4 interface LoginUser {
4 5 token: string,
... ... @@ -60,6 +61,7 @@ const actions = {
60 61 this.organizationLogo = obj.organizationLogo
61 62 },
62 63 removeToken(msg: string | null) {
  64 + logout()
63 65 this.token = ''
64 66 window.localStorage.removeItem('store-data')
65 67 ElMessage.success(msg || '已退出登录');
... ...
src/views/role/index.vue
... ... @@ -47,8 +47,8 @@ const getList = async () => {
47 47 data.loading = true;
48 48 try {
49 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 52 } catch (e) {
53 53 console.log(e);
54 54 } finally {
... ...
src/views/user/index.vue
... ... @@ -35,6 +35,7 @@ let data = reactive({
35 35 });
36 36 let asyncData = reactive({
37 37 userInfo: null,
  38 + userType: null,
38 39 });
39 40 /**
40 41 * 列表
... ... @@ -147,6 +148,7 @@ enum statusEnum {
147 148 }
148 149 onMounted(() => {
149 150 asyncData.userInfo = store.family.loginStore().id;
  151 + asyncData.userType = store.family.loginStore().organizationType;
150 152 getList();
151 153 });
152 154 </script>
... ... @@ -210,10 +212,8 @@ onMounted(() =&gt; {
210 212 </el-table-column>
211 213 <el-table-column label="操作" align="center">
212 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 217 <el-button type="text"
218 218 ><router-link :to="{ path: '/user/edit', query: scope.row }"
219 219 >编辑</router-link
... ... @@ -235,18 +235,45 @@ onMounted(() =&gt; {
235 235 >删除</el-button
236 236 >
237 237 </template>
238   - <!-- 物业管理员(机构管理员)、商务管理员只可以改密码 -->
239   - <!-- 其他角色用户不可以做任何操作 以上均通过角色的code判断 -->
240 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 265 <el-button type="text" @click="handleUpdate(scope.row, 'pwd')"
248 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 277 </template>
251 278 </template>
252 279 </el-table-column>
... ...