Vue.component('project-search', {
template: `
<form class="searchbar" v-on:submit.prevent="onSearch()">
<select v-model="searchType" >
<option value="name">프로젝트 이름</option>
<option value="manager">프로젝트 매니저</option>
</select>
<input v-model="newSearch" placeholder="Search for posters" autofocus>
<input type="submit" value="Search" class="btn">
</form>
`,
data() {
return {
projectView: '/project',
memberView: '/member',
userId: '',
uid: window.demoUserUid,
total: 0,
items: {},
searchType:'',
results: {},
newSearch: '',
lastSearch: '',
loading: false,
};
},
methods: {
onSearch() {
if (this.newSearch.length) {
this.items = [];
this.loading = true;
axios.get(this.memberView+'/search/'.concat(this.searchType).concat('/').concat(this.newSearch))
.then(res => {
this.lastSearch = this.newSearch;
this.results = res.data;
this.loading = false;
addedItem=this.results;
})
.catch(err => {
console.log(err);
});
}
}
}
});
new Vue({
el: '#app',
data: {
addedItem:{}
}
<project-search ></project-search>
<div class="product" v-for="(item, index) in addedItem">
<div>
<p>작업 위치: {{ item.project.projectPlaceAddress }}</p>
<div v-if="item.authorityCode == '02'">
<button class="btn add-to-cart" @click="modifyProject(item.project.projectCode)">수정</button>
</div>