1
0
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:
Konstantin Vinokurov
2022-06-02 23:00:58 +07:00
parent 4bfe25d887
commit d916977fc8
3 changed files with 31 additions and 5 deletions

View File

@@ -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 ?? ''}`
: 'Не указано'; : 'Не указано';
} }
} }

View File

@@ -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>

View File

@@ -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>