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: {
|
||||
...mapGetters({ user: 'user' }),
|
||||
name() {
|
||||
return this.user.last_name && this.user.first_name && this.user.middle_name
|
||||
? `${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 ?? ''}`
|
||||
: 'Не указано';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,20 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "TheHeader"
|
||||
name: "TheHeader",
|
||||
data() {
|
||||
return {
|
||||
query: '',
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
search() {
|
||||
this.$router.push({
|
||||
path: '/catalog',
|
||||
query: { q: this.query },
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -133,10 +133,23 @@ export default {
|
||||
const offers = await offerService.filter(this.sortParams);
|
||||
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() {
|
||||
const offers = await offerService.all();
|
||||
this.offers = offers.data.data;
|
||||
await this.addSearchParam(this.$route.query);
|
||||
},
|
||||
watch: {
|
||||
'$route.query'(value) {
|
||||
this.addSearchParam(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user