fix ui
This commit is contained in:
@@ -1,11 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<q-badge v-if="isOwner" color="purple">所有者</q-badge>
|
<q-badge class="q-mr-xs" v-if="isOwner" color="secondary">所有者</q-badge>
|
||||||
<q-badge v-else-if="isManager" color="primary">管理者</q-badge>
|
<!-- <q-badge v-else-if="isManager" color="primary">管理者</q-badge> -->
|
||||||
|
<q-badge v-if="isSelf" color="purple">自分</q-badge>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { IDomainOwnerDisplay } from '../../types/DomainTypes';
|
import { IDomainOwnerDisplay } from '../../types/DomainTypes';
|
||||||
|
import { useAuthStore } from 'stores/useAuthStore';
|
||||||
|
|
||||||
|
const authStore = useAuthStore();
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
user: { id: number };
|
user: { id: number };
|
||||||
@@ -14,6 +18,7 @@ interface Props {
|
|||||||
|
|
||||||
const props = defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
|
const isSelf = computed(() => props.user.id === (Number)(authStore.userId));
|
||||||
const isOwner = computed(() => props.user.id === props.domain.owner.id);
|
const isOwner = computed(() => props.user.id === props.domain.owner.id);
|
||||||
const isManager = computed(() => props.user.id === props.domain.owner.id); // TODO
|
const isManager = computed(() => props.user.id === props.domain.owner.id); // TODO
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
<q-item-section>{{scope.opt.fullName}}</q-item-section>
|
<q-item-section>{{scope.opt.fullName}}</q-item-section>
|
||||||
<q-item-section>{{scope.opt.email}}</q-item-section>
|
<q-item-section>{{scope.opt.email}}</q-item-section>
|
||||||
<q-item-section side>
|
<q-item-section side>
|
||||||
<div style="width: 4em;">
|
<div style="width: 6.5em;">
|
||||||
<role-label :domain="domain" :user="scope.opt"></role-label>
|
<role-label :domain="domain" :user="scope.opt"></role-label>
|
||||||
</div>
|
</div>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
<sharing-user-list class="q-mt-md" style="height: 330px" :users="sharedUsers" :loading="loading" :title="userListTitle">
|
<sharing-user-list class="q-mt-md" style="height: 330px" :users="sharedUsers" :loading="loading" :title="userListTitle">
|
||||||
<template v-slot:body-cell-role="{ row }">
|
<template v-slot:body-cell-role="{ row }">
|
||||||
<q-td>
|
<q-td auto-width>
|
||||||
<role-label :domain="domain" :user="row"></role-label>
|
<role-label :domain="domain" :user="row"></role-label>
|
||||||
</q-td>
|
</q-td>
|
||||||
</template>
|
</template>
|
||||||
@@ -84,6 +84,7 @@ interface Props {
|
|||||||
domain: IDomainOwnerDisplay;
|
domain: IDomainOwnerDisplay;
|
||||||
dialogTitle: string;
|
dialogTitle: string;
|
||||||
userListTitle: string;
|
userListTitle: string;
|
||||||
|
hideSelf: boolean;
|
||||||
shareApi: (user: IUserDisplay, domain: IDomainOwnerDisplay) => Promise<any>;
|
shareApi: (user: IUserDisplay, domain: IDomainOwnerDisplay) => Promise<any>;
|
||||||
removeSharedApi: (user: IUserDisplay, domain: IDomainOwnerDisplay) => Promise<any>;
|
removeSharedApi: (user: IUserDisplay, domain: IDomainOwnerDisplay) => Promise<any>;
|
||||||
getSharedApi: (domain: IDomainOwnerDisplay) => Promise<any>;
|
getSharedApi: (domain: IDomainOwnerDisplay) => Promise<any>;
|
||||||
@@ -204,20 +205,28 @@ const loadShared = async () => {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
sharedUsersIdSet.clear();
|
sharedUsersIdSet.clear();
|
||||||
|
|
||||||
|
if(props.hideSelf) {
|
||||||
|
sharedUsersIdSet.add((Number)(authStore.userId));
|
||||||
|
}
|
||||||
|
|
||||||
const { data } = await props.getSharedApi(props.domain);
|
const { data } = await props.getSharedApi(props.domain);
|
||||||
sharedUsers.value = data.data.map((item: IUser) => {
|
|
||||||
|
sharedUsers.value = data.data.reduce((arr: IUserDisplayWithShareRole[], item: IUser) => {
|
||||||
const val = itemToDisplay(item);
|
const val = itemToDisplay(item);
|
||||||
|
if(!sharedUsersIdSet.has(val.id)) {
|
||||||
sharedUsersIdSet.add(val.id);
|
sharedUsersIdSet.add(val.id);
|
||||||
// for sort
|
// for sort
|
||||||
if (isOwner(item.id)) {
|
if (isOwner(val.id)) {
|
||||||
val.role = 2;
|
val.role = 2;
|
||||||
} else if (isManager(item.id)) {
|
} else if (isManager(val.id)) {
|
||||||
val.role = 1;
|
val.role = 1;
|
||||||
} else {
|
} else {
|
||||||
val.role = 0;
|
val.role = 0;
|
||||||
}
|
}
|
||||||
return val;
|
arr.push(val);
|
||||||
}).reverse().sort((a: IUserDisplayWithShareRole, b: IUserDisplayWithShareRole) => b.role - a.role);
|
}
|
||||||
|
return arr;
|
||||||
|
}, []).sort((a: IUserDisplayWithShareRole, b: IUserDisplayWithShareRole) => b.role - a.role);
|
||||||
|
|
||||||
canSharedUsers.value = allUsers.value.filter((item) => !sharedUsersIdSet.has(item.id));
|
canSharedUsers.value = allUsers.value.filter((item) => !sharedUsersIdSet.has(item.id));
|
||||||
canSharedUserFilteredOptions.value = canSharedUsers.value;
|
canSharedUserFilteredOptions.value = canSharedUsers.value;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
:remove-shared-api="removeSharedApi"
|
:remove-shared-api="removeSharedApi"
|
||||||
:get-shared-api="getSharedApi"
|
:get-shared-api="getSharedApi"
|
||||||
:model-value="modelValue"
|
:model-value="modelValue"
|
||||||
|
hide-self
|
||||||
@update:modelValue="updateModelValue"
|
@update:modelValue="updateModelValue"
|
||||||
@close="close"
|
@close="close"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user