Project.vue 7.67 KB
Newer Older
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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
<template>
    <v-card 
        width="100%"
        height="850px"
        class="elevation-0 "
    >    
        <v-card-title class="blue-grey white--text ">PROJECT</v-card-title>
            <v-container>
                <v-row>
                    <v-col cols="4">
                        <v-card
                            :class="step === 0 ?'elevation-12':'elevation-0'"
                            :color="step === 0 ? '' : 'grey lighten-2'"
                            class="d-flex justify-center align-center"
                            height="740"
                        >
                            <v-row
                                class="fill-height"
                                align-content="center"
                                justify="center"
                            >
                                <v-col
                                    class="text-center"
                                    cols="12"
                                >
                                    <span v-if="step > 0" class="text-h4">블루투스 연결 <v-icon color="success"  class="pb-4" x-large>mdi-check-bold</v-icon> </span>                                        
                                    <span v-else class="text-h4 "><strong>블루투스</strong>를 연결해주세요</span>
                                </v-col>
                                <v-col v-if="step === 0" cols="8">
                                    <v-progress-linear
                                        color="blue-grey"
                                        indeterminate
                                        rounded
                                        height="8"
                                    ></v-progress-linear>
                                </v-col>
                            </v-row>
                        </v-card>
                    </v-col>
                    <v-col cols="4">
                        <v-card
                            :class="step === 1 ?'elevation-12':'elevation-0'"
                            :color="step === 1 ? '' : 'grey lighten-2'"
                            class="d-flex justify-center align-center "
                            height="740"
                        >
                            <v-row
                                class="fill-height"
                                align-content="center"
                                justify="center"
                            >
                                <v-col
                                    class="text-center"
                                    cols="12"
                                >
                                    <span v-if="step > 1" class="text-h4">데이터 연동<v-icon color="success" class="pb-4" x-large>mdi-check-bold</v-icon> </span>                                        
                                    <div v-else class="text-h4 "><strong>서버</strong>와 DB 연동</div>
                                    <!-- <p class="text-h4 "><strong>S/N : {{id}}</strong></p></div> -->
                                </v-col>
                                <v-col v-if="step === 1" cols="8">
                                    <v-progress-linear
                                        color="blue-grey"
                                        indeterminate
                                        rounded
                                        height="8"
                                    ></v-progress-linear>
                                </v-col>
                            </v-row>
                        </v-card>
                    </v-col>
                    <v-col cols="4">
                        <v-card
                            :class="step === 2 ?'elevation-12':'elevation-0'"
                            :color="step === 2 ? '' : 'grey lighten-2'"
                            class="d-flex justify-center align-center"
                            height="740"
                        >
                            <v-row
                                class="fill-height"
                                align-content="center"
                                justify="center"
                            >
                                <v-col
                                    class="text-center"
                                    cols="12"
                                >
                                
                                    <span v-if="step > 2" class="text-h4">세팅 초기화<v-icon color="success"  class="pb-4" x-large>mdi-check-bold</v-icon> </span>                                        
                                    <span v-else class="text-h4 "><strong>세팅</strong> 초기화</span>
                                </v-col>
                                <v-col v-if="step === 2" cols="8">
                                    <v-progress-linear
                                        color="blue-grey"
                                        indeterminate
                                        rounded
                                        height="8"
                                    ></v-progress-linear>
                                </v-col>
                            </v-row>
                        </v-card>
                    </v-col>
                </v-row>
            </v-container>
    </v-card>
</template>

<script>
import wpoService from '@/service/wpo'
import managerService from '@/service/manager'
import projectService from '@/service/project'

import projectGQL from '@/gql/project'
import aoiGQL from '@/gql/aoi'

import { mapActions } from 'vuex'

import { EventBus } from '@/event-bus'

export default {
    data () {
      return {
            message: '준비중...',
            step:0,
            id:'',
        }
    },

    props: {
        project: Object,
    },

    created(){
        this.getAoi()
        this.getAois()
        this.network()
    },

    methods: {
        ...mapActions([
            'getAois',
        ]),

        async getAoi(){
            let id = await wpoService.getWpoId()  //웹서버에 지정한 WPO ID 가져오기
            this.id = id
        },

        async network(){
            EventBus.$emit('openBluetooth')

            try{
                const msg  = new Object()
                msg.cmd = "network_check"
                let response = await managerService.request(msg)
                if(JSON.parse(response.data).status){
                    EventBus.$emit('closeBluetooth')
                    setTimeout(() => {
                        this.step = 1 
                    }, 3000);
                }else{
                    this.network()
                }    
            }catch(e){
                // EventBus.$emit('openAlert',`${e.message}`, 'error')
            }
        },


        async projectUpdate(){
            let result = await projectGQL.update(this.project)

            if(result){ 
                projectService.save({})
                setTimeout(() => {
                    this.step = 2 
                }, 3000);
            }
        },

        async aoiInit(){
            let aoi = this.$store.state.aoi.aois.filter( aoi => { return aoi.serial === this.id } )
            
            let result = await aoiGQL.updateAoi(aoi[0])

            if(Object.keys(result).length !== 0){
                setTimeout(() => {
                    this.step = 2 
                    EventBus.$emit('setInit')
                }, 3000);
            } 
        },

    },

    watch:{
        async step(current) {
            switch(current) {
                case 1:
                    this.projectUpdate()
                break;

                case 2:
                    this.aoiInit()
                break;
            }
        }
    }
}
</script>

<style>

</style>