userList수정

This commit is contained in:
khj0414 2025-02-07 10:30:18 +09:00
parent c2ff50061a
commit 854c0c91e9
2 changed files with 57 additions and 32 deletions

View File

@ -1,33 +1,29 @@
<template> <template>
<!-- 컴포넌트 사용 ex) <ul class="list-unstyled users-list d-flex align-items-center">
<li
<UserList @user-list-update="handleUserListUpdate" /> v-for="(user, index) in userList"
:key="index"
--> class="avatar pull-up"
<ul class="list-unstyled users-list d-flex align-items-center"> :class="{ disabled: user.disabled }"
<li @click="toggleDisable(index)"
v-for="(user, index) in userList" data-bs-toggle="tooltip"
:key="index" data-popup="tooltip-custom"
class="avatar pull-up" data-bs-placement="top"
:class="{ disabled: user.disabled }" :aria-label="user.MEMBERSEQ"
@click="toggleDisable(index)" :data-bs-original-title="getTooltipTitle(user)"
data-bs-toggle="tooltip" >
data-popup="tooltip-custom" <img
data-bs-placement="top" class="rounded-circle user-avatar"
:aria-label="user.MEMBERSEQ" :src="`http://localhost:10325/upload/img/profile/${user.MEMBERPRF}`"
:data-bs-original-title="user.MEMBERSEQ" alt="user"
> :style="{ borderColor: user.usercolor}"
<img />
class="rounded-circle" </li>
:src="`http://localhost:10325/upload/img/profile/${user.MEMBERPRF}`" </ul>
alt="profile"
/>
</li>
</ul>
</template> </template>
<script setup> <script setup>
import { onMounted, ref } from 'vue'; import { onMounted, ref, nextTick } from 'vue';
import { useUserStore } from '@s/userList'; import { useUserStore } from '@s/userList';
const emit = defineEmits(); const emit = defineEmits();
@ -38,11 +34,18 @@ const userList = ref([]);
onMounted(async () => { onMounted(async () => {
await userStore.fetchUserList(); await userStore.fetchUserList();
userList.value = userStore.userList; userList.value = userStore.userList;
nextTick(() => {
const tooltips = document.querySelectorAll('[data-bs-toggle="tooltip"]');
tooltips.forEach((tooltip) => {
new bootstrap.Tooltip(tooltip);
});
});
}); });
// / // /
const toggleDisable = (index) => { const toggleDisable = (index) => {
const user = userList.value[index]; const user = userList.value[index];
if (user) { if (user) {
user.disabled = !user.disabled; user.disabled = !user.disabled;
emitUserListUpdate(); emitUserListUpdate();
@ -51,20 +54,30 @@ const user = userList.value[index];
// emit // emit
const emitUserListUpdate = () => { const emitUserListUpdate = () => {
const activeUsers = userList.value.filter(user => !user.disabled); const activeUsers = userList.value.filter((user) => !user.disabled);
const disabledUsers = userList.value.filter(user => user.disabled); const disabledUsers = userList.value.filter((user) => user.disabled);
emit('user-list-update', { activeUsers, disabledUsers }); emit('user-list-update', { activeUsers, disabledUsers });
}; };
const getTooltipTitle = (user) => {
return user.MEMBERSEQ === userStore.userInfo.id ? '나' : user.MEMBERNAM;
};
</script> </script>
<style scoped> <style scoped>
/* disabled 클래스를 적용할 때 사용자의 이미지를 흐리게 */ /* disabled 클래스를 적용할 때 사용자의 이미지를 흐리게 */
.avatar.disabled { .avatar.disabled {
opacity: 0.5; /* 흐리게 만들기 */ opacity: 1.0; /* 흐리게 만들기 */
} }
/* 비활성화된 상태에서 이미지를 회색으로 변환 */ /* 비활성화된 상태에서 이미지를 회색으로 변환 */
.avatar.disabled img { .avatar.disabled img {
filter: grayscale(100%); filter: grayscale(100%);
}
/* 동그란 테두리 설정 */
.user-avatar {
border: 3px solid; /* 테두리 */
padding: 0.1px; /* 테두리와 이미지 사이의 간격 */
} }
</style> </style>

View File

@ -11,11 +11,23 @@ import axios from "@api";
export const useUserStore = defineStore("userStore", { export const useUserStore = defineStore("userStore", {
state: () => ({ state: () => ({
userList: [], userList: [],
userInfo: {}
}), }),
actions: { actions: {
async fetchUserList() { async fetchUserList() {
const response = await axios.get('user/allUserList'); const response = await axios.get('user/allUserList');
this.userList = response.data.data; console.log('response',response)
this.userList = response.data.data.allUserList;
this.userInfo = response.data.data.user;
if (this.userInfo) {
const index = this.userList.findIndex(user => user.MEMBERSEQ === this.userInfo.id);
if (index !== -1) {
const [user] = this.userList.splice(index, 1);
this.userList.unshift(user);
}
}
}, },
}, },
}); });