<style scoped>
.van-cell-group {
  width: 680px;
  margin: 20px auto;
}
.van-cell {
  height: 100px;
  line-height: 100px;
  font-size: 26px;
  color: #000000ff;
  font-weight: 500;
  width: 660px;
  margin: auto;
}
.van-cell:after {
  border-bottom: 2px solid #e7e7e7ff;
}

</style>
<template>
  <!--设备信息-->
  <div id="topDiv">
    <van-nav-bar
      :title="$route.meta.name"
      left-arrow
      @click-left="$router.go(-1)"
    >
    </van-nav-bar>
  </div>
  <van-cell-group inset class="cell-flex-1-3">
    <van-cell title="子系统名称" :value="information.name" />
    <van-cell title="设备编码" :value="information.code" />
    <van-cell title="设备SN码" :value="deviceSN" />
    <van-cell title="MAC地址" value="54:E4:3A:16:8E:5C" />
    <van-cell title="负责人" :value="information.userName" />
  </van-cell-group>

  <van-cell-group title="服务器"  inset>
    <van-cell
      title="通讯地址"
      :value="cloudServerAddress.slice(cloudServerAddress.indexOf('//') + 2, cloudServerAddress.indexOf(':', cloudServerAddress.indexOf('//') + 2) !== -1 ? cloudServerAddress.indexOf(':', cloudServerAddress.indexOf('//') + 2) : undefined)"
    />
    <van-cell
      title="端口号"
      :value="cloudServerAddress.slice(7).split(':')[1]"
    />
  </van-cell-group>
</template>

<script>
import { NavBar, CellGroup, Cell } from "vant";
import { getSubSysInfo ,getQrDeviceControlunitByChildSysId} from "@/api/system/registerConfig";
import { mapState } from "vuex";
export default {
  name: "equipmentInformation",
  components: {
    [NavBar.name]: NavBar,
    [CellGroup.name]: CellGroup,
    [Cell.name]: Cell,
  },
  data() {
    return {
      type: ["盒条", "条件", "条零", "盒条人工", "条件人工", "条零人工", "PDA"],
      information: {
        authCode: "",
        //唯一编码
        code: "",
        externalCode: "",
        id: "",
        //ip地址
        ip: null,
        // 系统名称
        name: "",
        //系统类型
        typeCode: 7,
        //产线名
        productLineName: "",
        userId: null,
        //负责人
        userName: "",
        // 版本号
        version: "",
      },
      //SN码
      deviceSN:""
    };
  },
  mounted() {
    this.$nativeQRCode.setStatusBarColor("#006953", "white");
    this.getSubSysInfo();
  },
  computed: {
    ...mapState("sysConf", ["authCode", "cloudServerAddress"]),
  },
  methods: {
    // 获取子系统信息
    getSubSysInfo() {
      console.log(this.authCode);
      getSubSysInfo(this.authCode).then((res) => {
        console.log(res.data);
        if (res.code == 200){
          this.information = res.data;
          getQrDeviceControlunitByChildSysId(res.data.id).then(r=>{
            console.log(r.data,666)
            this.deviceSN=r.data[0].deviceSN
          })

        } else this.information = "";

        // this.information = res.data
      });
    },
  },

};
</script>

