mirror of
https://github.com/robonen/metr.git
synced 2026-03-20 02:44:42 +00:00
Vue, back edited,added
This commit is contained in:
@@ -22,8 +22,8 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapGetters({ user: 'user' }),
|
...mapGetters({ user: 'user' }),
|
||||||
name() {
|
name() {
|
||||||
return this.user.last_name && this.user.first_name && this.user.middle_name
|
return this.user.last_name && this.user.first_name
|
||||||
? `${this.user.last_name} ${this.user.first_name} ${this.user.middle_name}`
|
? `${this.user.last_name} ${this.user.first_name} ${this.user.middle_name ?? ''}`
|
||||||
: 'Не указано';
|
: 'Не указано';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,20 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "TheHeader"
|
name: "TheHeader",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
query: '',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
search() {
|
||||||
|
this.$router.push({
|
||||||
|
path: '/catalog',
|
||||||
|
query: { q: this.query },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -133,10 +133,23 @@ export default {
|
|||||||
const offers = await offerService.filter(this.sortParams);
|
const offers = await offerService.filter(this.sortParams);
|
||||||
this.offers = offers.data.data;
|
this.offers = offers.data.data;
|
||||||
},
|
},
|
||||||
|
async addSearchParam(value) {
|
||||||
|
if (!value || !value.q) {
|
||||||
|
this.sortParams = this.sortParams.filter((e) => e.name !== 'search');
|
||||||
|
this.reloadOffers();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.addSortParam('search', value.q);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
const offers = await offerService.all();
|
await this.addSearchParam(this.$route.query);
|
||||||
this.offers = offers.data.data;
|
},
|
||||||
|
watch: {
|
||||||
|
'$route.query'(value) {
|
||||||
|
this.addSearchParam(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user