All files / src/components load-round.vue

0% Statements 0/55
0% Branches 0/14
0% Functions 0/25
0% Lines 0/55

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119                                                                                                                                                                                                                                             
<template>
    <v-row no-gutters class="gap ma-3 flex-column">
        <v-col lg=2 class='w100  d-flex flex-column'>
            <v-row no-gutters class="gap">
                <v-col lg=4>
                    <v-card class="h-100">
                        <v-card-title>
                            Ежедневная статистика по сотрудникам 
                        </v-card-title>
                        <v-row no-gutters class="gap">
                            <v-col class="flex-grow-0">
                                <v-card-subtitle class="mt-2 align-self-end">
                                    1. Скачать файл ежедневной статистики 
                                </v-card-subtitle>
                            </v-col>
                            <v-col class="flex-grow-0">
                                <v-icon
                                    icon="mdi-file-excel" 
                                    color="green-darken-3"
                                    @click="excelOp('excround')"
                                />
                            </v-col>
                        </v-row>
                        <v-row no-gutters class="gap mt-5">
                            <v-col class="flex-grow-0">
                                <v-card-subtitle class="mt-3 align-self-end">
                                    2. Загрузить данные на сервер  
                                </v-card-subtitle>
                            </v-col>
                            <v-col >
                                <v-file-input 
                                    accept=".xlsx"
                                    v-model="dailyfiles"
                                    variant="underlined"
                                    density="compact"
                                    label="Прикрепить файл" 
                                    hide-details
                                />
                            </v-col>
                            <v-col class="flex-grow-0 pr-2">
                                <v-icon
                                    icon="mdi-chevron-double-right"
                                    color="blue-grey-darken-2"
                                    @click="onPickFile('roundfilse')"
                                />
                            </v-col>
                        </v-row>
                    </v-card>
                </v-col>         
            </v-row>
        </v-col>
    </v-row>
</template>
 
<script>
import { ref } from 'vue'
import { baseURL } from '@/utils/axios-api'
import { axiosApiInstance } from '@/utils/axios-api'
import { useAlertStore } from '@/store/useAlertStore'

export default {

    setup(){ 

        const dailyfiles = ref([])
        const feedalert = useAlertStore().alert
 
        const excelOp = (ex) => {
            axiosApiInstance.get(`api/general_vacation/dailyroundup/?excel=${ex}`).then(result => {  
                let link = document.createElement("a")
                link.href = baseURL+result.data.path
                link.click()
                link.remove()
            })
        }

        const onPickFile = (ex) => {
            const sdata = new FormData()
            sdata.append('dailyfiles', dailyfiles.value[0])

            axiosApiInstance.post(`api/general_vacation/dailyroundup/?excel=${ex}`, sdata).then(result => {  
                textFromAlert(result.data['mess'])
            })
            dailyfiles.value = []
        }
 
        const textFromAlert = (info) => {
            feedalert.alert = true
            if (info == "Файл загружен") {
                feedalert.text = "Файл загружен"
                feedalert.ico = "mdi-check"
                feedalert.color ="green-darken-4"
            }
            else  {
                feedalert.text = "Ошибка загрузки"
                feedalert.ico = "mdi-alert-circle-outline"
                feedalert.color="pink-accent-4"
            }
        }
 
    return {
        excelOp,
        baseURL,
        dailyfiles,
        onPickFile,
        feedalert
        }
    }
 
}
</script>
 
<style>
.mhight {
    height: 150px;
}

 
</style>