<template>
  <div>
    <div style="margin-left:45%;margin-top:50px;font-size:40px">
        <el-switch
        v-model="value"
        active-text="允许派车给无GPS车辆"
        @change="updateSwitch">
        </el-switch>
    </div>
    
  </div>
</template>
<script>
import { getCookie } from "@/utils/util.js";
export default {
  name: "dispacherSwitch",
  data() {
    return {
      value: true
    };
  },
  mounted() {
   this.getSwitch();
  },
  methods: {
    getSwitch(){
        this.axios.post("/api/v1/uc/getDispachSwitch").then((res)=>{
            if(res.data.data.isOk==0){
                this.value=false;
            }else{
                this.value=true;
            }
        });
    },
    updateSwitch(){
        let map={};
        if(this.value){
            map.isOk=1;
        }else{
            map.isOk=0
        }
        this.axios.post("/api/v1/uc/updateDispachSwitch",map).then((res)=>{
           console.log(res);
        });
    }
  }
};
</script>
<style lang="scss" scoped>

</style>
