Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat, fix] 상품 목록 조회 화면 구성 완료 #7

Merged
merged 3 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/assets/scss/component/modal.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
}
3 changes: 3 additions & 0 deletions src/assets/scss/component/table.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@mixin base-table() {
width: 100%;
}
8 changes: 3 additions & 5 deletions src/components/common/TheNavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ export default {
};
},
async mounted() {
// const result = await mainAxios.get('users/current');
// this.clientName = result.data.clientName
// this.userName = result.data.userName
this.clientName = "KOSA"
this.userName = "홍길동"
const result = await mainAxios.get('users/current');
this.clientName = result.data.clientName
this.userName = result.data.userName
},
method: {
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/btn/ThemeIconBtn.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<Button class="icon-btn" @click="func">
<button class="icon-btn" @click="func">
<span>{{ title }}</span>
<i :class="icon"></i>
</Button>
</button>
</template>

<script>
Expand Down
27 changes: 12 additions & 15 deletions src/components/common/pagination/PageChoice.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<div class="page-choice">
<div class="btn-box">
<div class="move-icon" @click="this.store.setPage(0)">&lt;&lt;</div>
<div class="move-icon" @click="this.store.setPage(store.page - 1)">&lt;</div>
<i class="bi bi-chevron-double-left move-icon" @click="this.store.setPage(0)"></i>
<i class="bi bi-chevron-left move-icon" @click="this.store.setPage(store.page - 1)"></i>
</div>
<div class="number-box">
<div
Expand All @@ -11,12 +11,12 @@
:key="page"
:class="{ 'active': store.page === page }"
class="page-number">
<span>{{ page + 1 }}</span>
{{ page + 1 }}
</div>
</div>
<div class="btn-box">
<div class="move-icon" @click="this.store.setPage(store.page + 1)">></div>
<div class="move-icon" @click="this.store.setPage(store.maxPage)">>></div>
<i class="bi bi-chevron-right move-icon" @click="this.store.setPage(store.page + 1)"></i>
<i class="bi bi-chevron-double-right move-icon" @click="this.store.setPage(store.maxPage)"></i>
</div>
</div>
</template>
Expand Down Expand Up @@ -55,25 +55,22 @@ export default {

<style lang="scss" scoped>
.page-choice {
@include flex-box(row, center, 20px);
@include flex-box(row, center, 40px);
.btn-box {
@include flex-box(row, center, 10px)
}
.number-box {
@include flex-box(row, center, 15px)
@include flex-box(row, center, 30px)
}
}

.move-icon {
@include flex-box(row, center, 0px);
@include base-icon;
width: 32px;
height: 32px;
background-color: $theme-color;
color: $theme-color;
border-radius: 50%;
font-size: 14px;
font-size: 28px;
font-weight: bold;
color : white;
}

.page-number {
Expand All @@ -84,11 +81,11 @@ export default {
}

.active {
width: 28px;
height: 28px;
width: 34px;
height: 34px;
background-color: $theme-color;
border-radius: 50%;
font-size: 18px !important;///
font-size: 16px !important;///
color : white;
}
</style>
2 changes: 1 addition & 1 deletion src/components/common/pagination/SizeChoice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default {

.size-box {
@include flex-box(row, center, 5px);
padding: 3px 7px;
padding: 3px 10px;
border-radius: 10px;
box-shadow: 0px 1px 5px 1px rgb(0, 0, 0, 0.3);
transition: all 0.5s;
Expand Down
54 changes: 54 additions & 0 deletions src/components/common/table/TableHaeder.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<template>
<tr class="table-header">
<th v-for="(column, key) in store.columns" :key="key">
<div class="column-item">
<span>{{column.name}}</span>
<i :class="column.sort? sortIcon[column.sort] : nonSortIcon" @click="changeSort(column)"></i>
</div>
</th>
</tr>
</template>

<script>
export default {
name: 'TableHaederVue',
props: {
store: {
type: Object,
required: true
}
},
data(){
return {
nonSortIcon : 'bi bi-arrow-down-up',
sortIcon : {
'asc' : 'bi bi-sort-numeric-down sort-active',
'desc' : 'bi bi-sort-numeric-down-alt sort-active'
}
}
},
methods: {
changeSort(column) {
if (column.sort == 'asc') {
this.store.setColumnSort(column.data, 'desc');
} else if (column.sort == 'desc') {
this.store.setColumnSort(column.data, null);
} else {
this.store.setColumnSort(column.data, 'asc');
}
}
}
}
</script>

<style lang="scss" scoped>
.column-item {
@include white-text(16px);
@include flex-box(row, space-between, 0px);
background: $theme-color;
padding: 5px 20px;
i {
@include base-icon;
}
}
</style>
23 changes: 23 additions & 0 deletions src/components/item/ItemModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<div v-if="isVisible" class="modal-overlay" @click.self="closeModal">
<div class="modal-content">
<slot></slot>
<button @click="closeModal">Close</button>
</div>
</div>
</template>

<script>
export default {
props: {
isVisible: Boolean,
closeModal: Function
}
}
</script>

<style lang="scss" scoped>
@import '@/assets/scss/component/modal.scss';


</style>
40 changes: 40 additions & 0 deletions src/components/item/ItemTable.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>

<table class="item-table">
<thead>
<TableHaederVue :store="itemStore"/>
</thead>
<tbody>
<ItemTableRowVue v-for="(value, key) in itemStore.itemList" :key="key" :itemData="value"/>
</tbody>
</table>
</template>

<script>
import { mapActions, mapStores } from 'pinia';
import { useItemStore } from '@/stores/item';
import TableHaederVue from '../common/table/TableHaeder.vue';
import ItemTableRowVue from './ItemTableRow.vue';

export default {
name: 'ItemTableVue',
components: {
TableHaederVue,
ItemTableRowVue
},
computed: {
...mapStores(useItemStore),
},
methods: {
...mapActions(useItemStore, ['setColumnSort'])
}
}
</script>

<style lang="scss" scoped>
@import "@/assets/scss/component/table.scss";
.item-table {
@include base-table();

}
</style>
52 changes: 52 additions & 0 deletions src/components/item/ItemTableRow.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<template>
<tr class="item-row">
<td class="item-column"><span>{{ itemData.id }}</span></td>
<td class="item-column"><img :src="itemData.imageUrl" alt="item-image" class="item-image"></td>
<td class="item-column"><span>{{ itemData.name }}</span></td>
<td class="item-column"><span>{{ itemData.price }}원</span></td>
<td class="item-column"><span>{{ itemData.contractCount }}건</span></td>
<td class="item-column"><span>{{ createdAtDate }}</span></td>
<td class="item-column"><span>{{ updatedAtDate }}</span></td>
</tr>
</template>

<script>
import { toDateFromDateTime } from '@/utils/date';

export default {
name: 'ItemTableRowVue',
props: {
itemData: Object
},
computed: {
createdAtDate() {
return toDateFromDateTime(this.itemData.createdAt)
},
updatedAtDate() {
return toDateFromDateTime(this.itemData.updatedAt)
}
},
}
</script>

<style lang="scss" scoped>
.item-row {
transition: all 0.5s;
cursor: pointer;
&:hover {
background-color: $back-color;
opacity: 0.5;
}
}

.item-column {
font-weight: bold;
padding: 10px 20px;
}

.item-image {
width: 120px;
height: 120px;
object-fit: contain;
}
</style>
25 changes: 23 additions & 2 deletions src/stores/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,40 @@ export const useItemStore = defineStore('item', {
return {
page : 0,
size : 10,
maxPage: 10,
maxPage: 0,
itemList : [],
currentItem: {}
currentItem: {},
columns: [
{data: 'id', name:'상품번호', sort:null},
{data:'imageUrl', name:'상품 이미지', sort:null},
{data: 'name', name:'상품명', sort:null},
{data: 'price', name:'가격', sort:null},
{data: 'contractCount', name:'계약 건수', sort:null},
{data: 'createdAt', name:'생성일', sort:null},
{data: 'updatedAt', name:'수정일', sort:null}
]
}
},
actions: {
setSize(number) {
this.size = number;
},
setMaxPage(number) {
this.maxPage = number;
},
setPage(number) {
if (number <= this.maxPage && number >= 0) {
this.page = number;
}
},
setItemList(itemList) {
this.itemList = itemList;
},
setColumnSort(columnData, sortValue) {
const column = this.columns.find(col => col.data === columnData);
if (column) {
column.sort = sortValue;
}
}
},
})
6 changes: 3 additions & 3 deletions src/utils/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ const authAxios = axios.create({

authAxios.interceptors.response.use(
(response) => {
return response.data;
return response;
},
(error) => {
return error.response.data;
return error.response;
}
);

Expand Down Expand Up @@ -62,7 +62,7 @@ authAxios.interceptors.response.use(
return response.data;
},
(error) => {
return error.response.data;
return error.response;
}
);

Expand Down
10 changes: 10 additions & 0 deletions src/utils/date.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function toDateFromDateTime(dateTime) {
const date = new Date(dateTime);
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();

return `${year}.${month < 10? "0" + month : month}.${day < 10? "0"+ day : day}`
}

export {toDateFromDateTime}
2 changes: 2 additions & 0 deletions src/views/MobileView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ export default {
position: absolute;
top: $mobile-header-height;
width: 100%;
height: calc(100vh - $mobile-header-height);
width: 100%;
}
</style>
Loading
Loading