L
L
Lawrence2021-08-19 10:27:21
Vue.js
Lawrence, 2021-08-19 10:27:21

How to correctly override parameters in a mixin?

Tell me this moment. I decided to put a constantly repeating piece of code (working with a table) into a mixin.

Read, tested everything works. But I don’t understand a little how I can pass (more precisely, override) the line in the component itself: this.PersonalService.getBlaBlaMethod() , which is responsible for receiving data.
The idea is to prescribe all the parameters I need for the table in the tableLazyParams object , and override it in the component. But I don’t understand how to correctly write a call to this.PersonalService.getBlaBlaMethod() .

// Пример части в миксине
export default {
    data() {
        return {
            tableLazyParams : {
                ref:        'dtable',
                service: ''
            }
        }
    },
    methods: {       
        updateDataTable() {
            this.loadingDataTable = true;
            this.PersonalService.geTestMethodName(this.customer.id, {lazy: JSON.stringify( this.getLazyParams() )}).then(response => {
                if(response && response.status && response.status == 200) {
                    this.tableLazySuccess(response);
                } else {
                    this.tableLazyError(response)
                }
            });
        }
    }
}


// Пример части в сервисе
export default class PersonalService {
    geTestMethodName(customer_id, params) {
        let url = '/app/nk/personal/s/customer/' + customer_id + '/schedule'
        return axios.get(url, { params })
            .then(response => response)
            .catch(function (error) {
                return error.response;
            });
    },
    ......
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question