141 lines
3.3 KiB
Vue
141 lines
3.3 KiB
Vue
<template>
|
|
<a-space style="margin-bottom: 20px">
|
|
<SelectStaff
|
|
v-if="hasRole('superAdmin') || hasRole('admin')"
|
|
:placeholder="`添加开发成员`"
|
|
@done="addAppDevUser"
|
|
/>
|
|
<SelectUser
|
|
style="margin-left: 10px"
|
|
v-if="hasRole('superAdmin') || hasRole('admin')"
|
|
:placeholder="`添加体验成员`"
|
|
@done="addAppExpUser"
|
|
/>
|
|
<a-button>邀请添加</a-button>
|
|
</a-space>
|
|
<div class="content">
|
|
<table class="ele-table ele-table-border ele-table-stripe ele-table-medium">
|
|
<thead>
|
|
<tr>
|
|
<th>用户ID</th>
|
|
<th>角色</th>
|
|
<th>昵称</th>
|
|
<th>加入时间</th>
|
|
<th>操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr v-for="(user, index) in userList" :key="index">
|
|
<td>{{ user.userId }}</td>
|
|
<td>
|
|
<span v-if="user.role === 10">体验成员</span>
|
|
<span v-if="user.role === 20">开发成员</span>
|
|
<span v-if="user.role === 30" class="ele-text-danger">管理员</span>
|
|
</td>
|
|
<td>
|
|
<span style="padding-left: 5px">{{ user.nickname }}</span>
|
|
</td>
|
|
<td>{{ user.createTime }}</td>
|
|
<td>
|
|
<div v-if="user.role !== 30">
|
|
<a
|
|
@click="removeUser(user)"
|
|
v-if="hasRole('superAdmin') || hasRole('admin')"
|
|
>
|
|
移除
|
|
</a>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</template>
|
|
<script lang="ts" setup>
|
|
import { User } from '@/api/system/user/model';
|
|
import { App } from '@/api/oa/app/model';
|
|
import { hasRole } from '@/utils/permission';
|
|
import { AppUser } from '@/api/oa/app/user/model';
|
|
import { addAppUser, pageAppUser, removeAppUser } from '@/api/oa/app/user';
|
|
import { message } from 'ant-design-vue';
|
|
import { ref, watch } from 'vue';
|
|
|
|
const props = defineProps<{
|
|
appId: any;
|
|
data: App;
|
|
}>();
|
|
|
|
const emit = defineEmits<{
|
|
(e: 'done'): void;
|
|
(e: 'update:visible', visible: boolean): void;
|
|
}>();
|
|
|
|
const userList = ref<AppUser[]>();
|
|
|
|
// 添加开发成员
|
|
const addAppDevUser = (data: User) => {
|
|
addAppUser({
|
|
userId: data.userId,
|
|
appId: props.data?.appId,
|
|
role: 20
|
|
})
|
|
.then((msg) => {
|
|
reload();
|
|
message.success(msg);
|
|
emit('done');
|
|
})
|
|
.catch((e) => {
|
|
message.error(e.message);
|
|
});
|
|
};
|
|
|
|
// 添加体验成员
|
|
const addAppExpUser = (data: User) => {
|
|
addAppUser({
|
|
userId: data.userId,
|
|
appId: props.data?.appId,
|
|
role: 10
|
|
})
|
|
.then((msg) => {
|
|
reload();
|
|
message.success(msg);
|
|
emit('done');
|
|
})
|
|
.catch((e) => {
|
|
message.error(e.message);
|
|
});
|
|
};
|
|
|
|
// 移除成员
|
|
const removeUser = (data: AppUser) => {
|
|
removeAppUser(data.appUserId)
|
|
.then((msg) => {
|
|
reload();
|
|
message.success(msg);
|
|
emit('done');
|
|
})
|
|
.catch((e) => {
|
|
message.error(e.message);
|
|
});
|
|
};
|
|
|
|
const reload = () => {
|
|
// 加载项目成员
|
|
pageAppUser({ appId: props.appId }).then((res) => {
|
|
if (res?.list) {
|
|
userList.value = res.list;
|
|
}
|
|
});
|
|
};
|
|
|
|
watch(
|
|
() => props.appId,
|
|
(appId) => {
|
|
if (appId) {
|
|
reload();
|
|
}
|
|
},
|
|
{ immediate: true }
|
|
);
|
|
</script>
|