<script>
import {invoke} from "@tauri-apps/api/tauri";

export default {
  name: "SetName",
  data(){
    return {
      name:"null",
      version:"000"
    }
  },
  methods: {
      async updataName() {
      var comman={command:"set_sensor_info",name:this.name,version:this.version}

        let data={
          data:comman,
          datatype:"json"
        }
        let that = this;
        let message=await invoke("sendtoport",data);
        await new Promise(resolve => setTimeout(resolve, 500));
        console.log(message);
      //其他地方传过来
        if (typeof this.upother === 'function') {
          this.upother();
        } else {
          // 函数未定义
          console.log("need rewrite")
        }
      }
  }
}
</script>

<template>
  <div style="position: relative;width: 100%;height: 100%">
    <BRow class="my-1">
      <BCol sm="2">
        <label for="input-none">设备名称</label>
      </BCol>
      <BCol sm="10">
        <BFormInput id="input-none" :state="null" placeholder="No validation" v-model="name" />
      </BCol>
    </BRow>
    <BRow class="my-1">
      <BCol sm="2">
        <label for="input-none">设备版本号</label>
      </BCol>
      <BCol sm="10">
        <BFormInput id="input-none" :state="null" placeholder="No validation"  v-model="version" />
      </BCol>
    </BRow>




  <p style="position:absolute ;bottom: 10px;width: 100%;height: 30px" >
  <b-button @click="updataName" style="position:absolute;right: 20px ">设置</b-button>
  </p>
  </div>
</template>

<style scoped>

</style>
