HomeAccounting

Форк
0
78 строк · 2.3 Кб
1

2
import template from './template.html';
3

4
export default {
5
    name: "MoneyTransaction",
6
    template: template,
7
    props: {
8
        showMoneyTransactionComponent: {
9
            type: Boolean,
10
            default: false,
11
        }
12
    },
13
    data: () => ({
14
        valid: true,
15
        billSource: {},
16
        billDestination: {},
17
        billSumTransaction: '',
18
        billsList: [
19
            {
20
                id: 0,
21
                name: 'test',
22
            }
23
        ],
24
    }),
25
    methods: {
26
        getBills() {
27
            axios.get('/pa/bills-list')
28
                .then(response=> {
29

30
                    this.billsList = new Array();
31

32
                    for (let key in response.data) {
33
                        this.billsList.push({
34
                            id: response.data[key]['id'],
35
                            name: response.data[key]['name'],
36
                        })
37
                    }
38
                })
39
                .catch(error => {
40
                    this.$store.commit('AlertError', error.message);
41
                });
42

43
        },
44
        transactionSend() {
45
            this.$store.commit('setPreloader', true);
46

47
            axios.post('/pa/bills/transfer', {
48
                bill_source: this.billSource,
49
                bill_destination: this.billDestination,
50
                sum: this.billSumTransaction,
51
            })
52
                .then(response=> {
53
                    this.$store.commit('setAlert', {
54
                        type: 'success',
55
                        status: true,
56
                        message: 'Транзакция перевода успешна'
57
                    });
58
                    this.close();
59
                    this.$store.commit('setPreloader', false);
60
                })
61
                .catch(error => {
62
                    this.$store.commit('setAlert', {
63
                        type: 'error',
64
                        status: true,
65
                        message: 'Ошибка передачи транзакции, попробуйте еще раз. Ответ сервера: '+error.message,
66
                    });
67
                });
68

69
        },
70
        close() {
71
            this.$parent.$parent.$emit('closeMoneyTransaction');
72
        },
73
    },
74
    watch: {
75
    },
76
    mounted() {
77
        this.getBills();
78
    },
79
}

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.