<!-- 有线网关设置 -->
<template>
  <div>
    <!-- <div> <el-button type="info" plain @click="dialogFormVisible = true">IP设置</el-button></div> -->
    <el-dialog v-loading="loading" :append-to-body="true" :visible.sync="dialogFormVisible" :title="$t('wiredgatewayip.title')"
               width="894px">
      <div class="form_content">
        <span class="title_center">{{ $t('wiredgatewayip.prompt') }}</span>
        <el-form ref="formData" :label-position="labelPosition" :model="formData" :rules="rules_ippz_wirle"
                 label-width="80px">
          <div :class="$i18n.locale === 'zh'?'zh wired':'wired'">
            <el-row>
              <el-col :span="12">
                <el-form-item :label-width="formLabelWidth" :label="$t('wiredgatewayip.port')" prop="ippz_wangkou">
                  <el-select v-model="formData.ippz_wangkou" style="width: 200px; height: 30px">
                    <el-option label="ETH0" value="ETH0"></el-option>
                    <el-option label="ETH1" value="ETH1"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item :label-width="formLabelWidth" :label="$t('wiredgatewayip.IP')" prop="ippz_ip">
                  <el-row>
                    <el-col :span="5">
                      <el-input v-model="ippz_ip1" maxlength="3"></el-input>
                    </el-col>
                    <el-col :span="1">.</el-col>
                    <el-col :span="5">
                      <el-input v-model="ippz_ip2" maxlength="3"></el-input>
                    </el-col>
                    <el-col :span="1">.</el-col>
                    <el-col :span="5">
                      <el-input v-model="ippz_ip3" maxlength="3"></el-input>
                    </el-col>
                    <el-col :span="1">.</el-col>
                    <el-col :span="5">
                      <el-input v-model="ippz_ip4" maxlength="3"></el-input>
                    </el-col>
                  </el-row>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item :label-width="formLabelWidth" :label="$t('wiredgatewayip.SubnetMask')" prop="ippz_zwym">
                  <el-row>
                    <el-col :span="5">
                      <el-input v-model="ippz_zwym1" maxlength="3"></el-input>
                    </el-col>
                    <el-col :span="1">.</el-col>
                    <el-col :span="5">
                      <el-input v-model="ippz_zwym2" maxlength="3"></el-input>
                    </el-col>
                    <el-col :span="1">.</el-col>
                    <el-col :span="5">
                      <el-input v-model="ippz_zwym3" maxlength="3"></el-input>
                    </el-col>
                    <el-col :span="1">.</el-col>
                    <el-col :span="5">
                      <el-input v-model="ippz_zwym4" maxlength="3"></el-input>
                    </el-col>
                  </el-row>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item :label-width="formLabelWidth" :label="$t('wiredgatewayip.gateway')" prop="ippz_mrwg">
                  <el-row>
                    <el-col :span="5">
                      <el-input v-model="ippz_mrwg1" maxlength="3"></el-input>
                    </el-col>
                    <el-col :span="1">.</el-col>
                    <el-col :span="5">
                      <el-input v-model="ippz_mrwg2" maxlength="3"></el-input>
                    </el-col>
                    <el-col :span="1">.</el-col>
                    <el-col :span="5">
                      <el-input v-model="ippz_mrwg3" maxlength="3"></el-input>
                    </el-col>
                    <el-col :span="1">.</el-col>
                    <el-col :span="5">
                      <el-input v-model="ippz_mrwg4" maxlength="3"></el-input>
                    </el-col>
                  </el-row>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item :label-width="formLabelWidth" :label="$t('wiredgatewayip.DNS1')" prop="ippz_dns_sx">
                  <el-row>
                    <el-col :span="5">
                      <el-input v-model="ippz_dns_sx1" maxlength="3"></el-input>
                    </el-col>
                    <el-col :span="1">.</el-col>
                    <el-col :span="5">
                      <el-input v-model="ippz_dns_sx2" maxlength="3"></el-input>
                    </el-col>
                    <el-col :span="1">.</el-col>
                    <el-col :span="5">
                      <el-input v-model="ippz_dns_sx3" maxlength="3"></el-input>
                    </el-col>
                    <el-col :span="1">.</el-col>
                    <el-col :span="5">
                      <el-input v-model="ippz_dns_sx4" maxlength="3"></el-input>
                    </el-col>
                  </el-row>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item :label-width="formLabelWidth" :label="$t('wiredgatewayip.DNS2')" prop="ippz_dns_by">
                  <el-row>
                    <el-col :span="5">
                      <el-input v-model="ippz_dns_by1" maxlength="3"></el-input>
                    </el-col>
                    <el-col :span="1">.</el-col>
                    <el-col :span="5">
                      <el-input v-model="ippz_dns_by2" maxlength="3"></el-input>
                    </el-col>
                    <el-col :span="1">.</el-col>
                    <el-col :span="5">
                      <el-input v-model="ippz_dns_by3" maxlength="3"></el-input>
                    </el-col>
                    <el-col :span="1">.</el-col>
                    <el-col :span="5">
                      <el-input v-model="ippz_dns_by4" maxlength="3"></el-input>
                    </el-col>
                  </el-row>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item :label-width="formLabelWidth" :label="$t('wiredgatewayip.DNS2')" prop="ippz_mac">
                  <el-row>
                    <el-col :span="24" class="mac">
                      <el-input v-model="formData.ippz_mac" style="width: 200px; height: 30px"></el-input>
                      <el-button
                          v-copy="formData.ippz_mac" @click="CopyText">{{ $t('wiredgatewayip.copy') }}
                      </el-button>
                    </el-col>
                  </el-row>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </el-form>

        <div slot="footer" class="dialog-footer footer">
          <el-button type="primary" @click="submitForm">{{ $t('save') }}</el-button>
          <el-button @click="dialogFormVisible = false">{{ $t('cancel') }}</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {SaveUserAnswer, GetUserAnswer, getQueryAnswer} from "../api/user";

export default {
  name: "GateWay",
  data() {
    return {
      // disabled: true,
      user_id: "",
      // 判断是否保存过
      loading: false,
      step: "",
      formData: {
        ippz_wangkou: "",
        ippz_zwym: "",
        ippz_mrwg: "",
        ippz_dns_sx: "",
        ippz_dns_by: "",
        ippz_ip: "",
        ippz_mac: "",
        wgpz_wgmc: "",
        wgpz_wgid: "",
        wgpz_wglx: "",
        tdpz_tdmc: "",
        tdpz_td: "",
        tdpz_qdmc: "",
        tdpz_ip: "",
        tdpz_port: "",
        tdpz_cssj: "",
        tdpz_jgsj: "",
        tdpz_lxsj: "",
        tdpz_cfcs: "",
        tdpz_watchtime: "",
        tdpz_cjsylxdz: "",
        tdpz_dxzkb: "",
        tdpz_050F: "",
        tdpz_0610: "",
        sbpz_sbid: "",
        sbpz_sbmc: "",
        sbpz_mac: "",
        sbpz_jysb: "",
        sbpz_jdzxz: "",
        cjdpz_tagid: "",
        cjdpz_mc: "",
        cjdpz_sjq: "",
        cjdpz_jcqdz: "",
        cjdpz_cjsjlx: "",
        cjdpz_zjx: "",
        cjdpz_dxsx: "",
        cjdpz_beilv: "",
        mqtt_qiyong: "",
        mqtt_ip: "",
        mqtt_port: "",
        mqtt_wgsn: "",
        mqtt_sssjfbzt: "",
        mqtt_qos: "",
        mqtt_scms: "",
        mqtt_sczq: "",
        mqtt_sjgl: "",
        mqtt_cjd_sbmc: "",
        mqtt_cjd_tagid: "",
      },
      labelPosition: "left",
      ippz_zwym1: "",
      ippz_zwym2: "",
      ippz_zwym3: "",
      ippz_zwym4: "",
      ippz_ip1: "",
      ippz_ip2: "",
      ippz_ip3: "",
      ippz_ip4: "",
      ippz_mrwg1: "",
      ippz_mrwg2: "",
      ippz_mrwg3: "",
      ippz_mrwg4: "",
      ippz_dns_sx1: "",
      ippz_dns_sx2: "",
      ippz_dns_sx3: "",
      ippz_dns_sx4: "",

      ippz_dns_by1: "",
      ippz_dns_by2: "",
      ippz_dns_by3: "",
      ippz_dns_by4: "",
      dialogFormVisible: true,
      formLabelWidth: this.$i18n.locale === 'zh'?"140px":"100px",
      // 有线的规则校验
      rules_ippz_wirle: {
        ippz_wangkou: [
          {
            required: true,
            message: this.$t('Please') + this.$t('wiredgatewayip.port'),
            trigger: "change",
          },
        ],
        ippz_zwym: [
          {
            required: true,
            message: "",
            validator: this.validateZwym,
            trigger: "blur",
          },
        ],
        ippz_ip: [
          {
            required: true,
            message: "",
            validator: this.validateIp,
            trigger: "blur",
          },
        ],
        ippz_mrwg: [
          {
            required: true,
            message: "",
            validator: this.validateMrwg,
            trigger: "blur",
          },
        ],
        ippz_dns_sx: [
          {
            required: true,
            message: "",
            validator: this.validateDnsSx,
            trigger: "blur",
          },
        ],
        ippz_dns_by: [
          {
            required: true,
            message: "",
            validator: this.validateDnsBy,
            trigger: "blur",
          },
        ],
        ippz_mac: [
          {required: true, message: this.$t('Please') + this.$t('wiredgatewayip.MAC'), trigger: "blur"},
        ],
      },
    };
  },
  computed: {
    // isSaveButtonDisabled() {
    //   return (
    //     !this.$refs.rules_ippz_wirle ||
    //     this.$refs.rules_ippz_wirle.validateSync().length > 0
    //   );
    // },
  },
  methods: {
    // 提交时的校验
    submitForm() {
      this.$refs["formData"].validate((valid) => {
        if (valid) {
          this.saveAll();
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    //子网掩码验证
    validateZwym(rule, value, callback) {
      if (
          this.ippz_zwym1 +
          "." +
          this.ippz_zwym2 +
          "." +
          this.ippz_zwym3 +
          "." +
          this.ippz_zwym4 ===
          "..."
      ) {
        callback(new Error( this.$t('Please') + this.$t('wiredgatewayip.SubnetMask')));
      } else if (
          !/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/.test(
              this.ippz_zwym1 +
              "." +
              this.ippz_zwym2 +
              "." +
              this.ippz_zwym3 +
              "." +
              this.ippz_zwym4
          )
      ) {
        callback(new Error( this.$t('Please') +this.$t('valid')+ this.$t('wiredgatewayip.SubnetMask')));
      } else {
        callback();
      }
    },
    //ip地址验证
    validateIp(rule, value, callback) {
      if (
          this.ippz_ip1 +
          "." +
          this.ippz_ip2 +
          "." +
          this.ippz_ip3 +
          "." +
          this.ippz_ip4 ===
          "..."
      ) {
        callback(new Error(this.$t('Please') + this.$t('wiredgatewayip.IP')));
      } else if (
          !/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/.test(
              this.ippz_ip1 +
              "." +
              this.ippz_ip2 +
              "." +
              this.ippz_ip3 +
              "." +
              this.ippz_ip4
          )
      ) {
        callback(new Error(this.$t('Please') +this.$t('valid')+ this.$t('wiredgatewayip.IP')));
      } else {
        callback();
      }
    },
    //默认网关验证
    validateMrwg(rule, value, callback) {
      if (
          this.ippz_mrwg1 +
          "." +
          this.ippz_mrwg2 +
          "." +
          this.ippz_mrwg3 +
          "." +
          this.ippz_mrwg4 ===
          "..."
      ) {
        callback(new Error(this.$t('Please') + this.$t('wiredgatewayip.gateway')));
      } else if (
          !/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/.test(
              this.ippz_mrwg1 +
              "." +
              this.ippz_mrwg2 +
              "." +
              this.ippz_mrwg3 +
              "." +
              this.ippz_mrwg4
          )
      ) {
        callback(new Error(this.$t('Please') + this.$t('valid') + this.$t('wiredgatewayip.gateway')));
      } else {
        callback();
      }
    },
    //首选DNS服务验证
    validateDnsSx(rule, value, callback) {
      if (
          this.ippz_dns_sx1 +
          "." +
          this.ippz_dns_sx2 +
          "." +
          this.ippz_dns_sx3 +
          "." +
          this.ippz_dns_sx4 ===
          "..."
      ) {
        callback(new Error(this.$t('Please') +  this.$t('wiredgatewayip.DNS1')));
      } else if (
          !/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/.test(
              this.ippz_dns_sx1 +
              "." +
              this.ippz_dns_sx2 +
              "." +
              this.ippz_dns_sx3 +
              "." +
              this.ippz_dns_sx4
          )
      ) {
        callback(new Error(this.$t('Please') + this.$t('valid') + this.$t('wiredgatewayip.DNS1')));
      } else {
        callback();
      }
    },
    //备选dns服务验证
    validateDnsBy(rule, value, callback) {
      if (
          this.ippz_dns_by1 +
          "." +
          this.ippz_dns_by2 +
          "." +
          this.ippz_dns_by3 +
          "." +
          this.ippz_dns_by4 ===
          "..."
      ) {
        callback(new Error(this.$t('Please') +  this.$t('wiredgatewayip.DNS2')));
      } else if (
          !/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/.test(
              this.ippz_dns_by1 +
              "." +
              this.ippz_dns_by2 +
              "." +
              this.ippz_dns_by3 +
              "." +
              this.ippz_dns_by4
          )
      ) {
        callback(new Error(this.$t('Please') + this.$t('valid') + this.$t('wiredgatewayip.DNS2')));
      } else {
        callback();
      }
    },

    // 保存数据, 发送请求
    async saveAll() {
      var obj = {
        ippz_ip: this.ippz_ip1 + "." + this.ippz_ip2 + "." + this.ippz_ip3 + "." + this.ippz_ip4,
        ippz_zwym: this.ippz_zwym1 + "." + this.ippz_zwym2 + "." + this.ippz_zwym3 + "." + this.ippz_zwym4,
        ippz_mrwg: this.ippz_mrwg1 + "." + this.ippz_mrwg2 + "." + this.ippz_mrwg3 + "." + this.ippz_mrwg4,
        ippz_dns_sx: this.ippz_dns_sx1 + "." + this.ippz_dns_sx2 + "." + this.ippz_dns_sx3 + "." + this.ippz_dns_sx4,
        ippz_dns_by: this.ippz_dns_by1 + "." + this.ippz_dns_by2 + "." + this.ippz_dns_by3 + "." + this.ippz_dns_by4,
      }
      let datas = {...this.formData, ...obj};

      let res = await SaveUserAnswer({
        mark: "DB-IotLite_yx",
        user_id: this.user_id,
        // user_id: "USER202307301114011710",
        mark_value: JSON.stringify(datas),
        step: this.step
      });
      // console.log(res);
      if (res.data.state) {
        this.$message({
          message: this.$t('success'),
          type: "success",
        });
      } else {
        this.$message({
          message: `保存失败`,
          type: "error",
        });
      }
      // console.log(res);
    },
    CopyText() {
      this.$message({
        message: "复制成功",
        type: "success",
      });
    },
    async getUserAnswer() {
      this.loading = true;
      let res2 = await GetUserAnswer({
        mark: "DB-IotLite_yx",
        user_id: this.user_id,
        // user_id: "USER202307301114011710",
      });
      this.loading = false;
      console.log(res2.data.message, '缓存数据');
      // alert(JSON.stringify(res2));
      // 没有缓存处理方法
      if (!res2.data.state)  {
        getQueryAnswer({
          mark: "DB-IotLite_yx",
          user_id: this.user_id
        }).then(res => {

          // console.log(JSON.parse(res.data.data.r3),'xxx')
          // let data = JSON.parse(res.data.data.r3)
          let data = null;
          if (this.$i18n.locale === "zh") {
            data = JSON.parse(res.data.data.r3_en_default);
          } else {
            data = JSON.parse(res.data.data.r3);
          }
          this.formData.ippz_mac = data.ippz_mac
          this.formData.ippz_wangkou = data.ippz_wangkou;
          this.formData.ippz_mrwg = data.ippz_mrwg;
          this.formData.ippz_ip = data.ippz_ip;
          this.formData.ippz_zwym = data.ippz_zwym;
          this.formData.ippz_dns_sx = data.ippz_dns_sx;
          this.formData.ippz_dns_by = data.ippz_dns_by;
          this.ippz_mrwg1 = data.ippz_mrwg.split(".")[0];
          this.ippz_mrwg2 = data.ippz_mrwg.split(".")[1];
          this.ippz_mrwg3 = data.ippz_mrwg.split(".")[2];
          this.ippz_mrwg4 = data.ippz_mrwg.split(".")[3];
          this.ippz_ip1 = data.ippz_ip.split(".")[0];
          this.ippz_ip2 = data.ippz_ip.split(".")[1];
          this.ippz_ip3 = data.ippz_ip.split(".")[2];
          this.ippz_ip4 = data.ippz_ip.split(".")[3];
          this.ippz_zwym1 = data.ippz_zwym.split(".")[0];
          this.ippz_zwym2 = data.ippz_zwym.split(".")[1];
          this.ippz_zwym3 = data.ippz_zwym.split(".")[2];
          this.ippz_zwym4 = data.ippz_zwym.split(".")[3];
          this.ippz_dns_sx1 = data.ippz_dns_sx.split(".")[0];
          this.ippz_dns_sx2 = data.ippz_dns_sx.split(".")[1];
          this.ippz_dns_sx3 = data.ippz_dns_sx.split(".")[2];
          this.ippz_dns_sx4 = data.ippz_dns_sx.split(".")[3];
          this.ippz_dns_by1 = data.ippz_dns_by.split(".")[0];
          this.ippz_dns_by2 = data.ippz_dns_by.split(".")[1];
          this.ippz_dns_by3 = data.ippz_dns_by.split(".")[2];
          this.ippz_dns_by4 = data.ippz_dns_by.split(".")[3];
        })
        return
      }
      if (res2.data.data && res2.data.state) {
        if (res2.data.data.step) {
          this.step = res2.data.data.step;
        }
        let res3 = JSON.parse(res2.data.data.mark_value);
        // console.log(res3);
        if (res3.ippz_mac) {
          this.formData.ippz_mac = res3.ippz_mac;
        }
        if (res3.ippz_mrwg) {
          this.formData.ippz_wangkou = res3.ippz_wangkou;
          this.formData.ippz_mrwg = res3.ippz_mrwg;
          this.formData.ippz_ip = res3.ippz_ip;
          this.formData.ippz_zwym = res3.ippz_zwym;
          this.formData.ippz_dns_sx = res3.ippz_dns_sx;
          this.formData.ippz_dns_by = res3.ippz_dns_by;
          this.ippz_mrwg1 = res3.ippz_mrwg.split(".")[0];
          this.ippz_mrwg2 = res3.ippz_mrwg.split(".")[1];
          this.ippz_mrwg3 = res3.ippz_mrwg.split(".")[2];
          this.ippz_mrwg4 = res3.ippz_mrwg.split(".")[3];
          this.ippz_ip1 = res3.ippz_ip.split(".")[0];
          this.ippz_ip2 = res3.ippz_ip.split(".")[1];
          this.ippz_ip3 = res3.ippz_ip.split(".")[2];
          this.ippz_ip4 = res3.ippz_ip.split(".")[3];
          this.ippz_zwym1 = res3.ippz_zwym.split(".")[0];
          this.ippz_zwym2 = res3.ippz_zwym.split(".")[1];
          this.ippz_zwym3 = res3.ippz_zwym.split(".")[2];
          this.ippz_zwym4 = res3.ippz_zwym.split(".")[3];
          this.ippz_dns_sx1 = res3.ippz_dns_sx.split(".")[0];
          this.ippz_dns_sx2 = res3.ippz_dns_sx.split(".")[1];
          this.ippz_dns_sx3 = res3.ippz_dns_sx.split(".")[2];
          this.ippz_dns_sx4 = res3.ippz_dns_sx.split(".")[3];
          this.ippz_dns_by1 = res3.ippz_dns_by.split(".")[0];
          this.ippz_dns_by2 = res3.ippz_dns_by.split(".")[1];
          this.ippz_dns_by3 = res3.ippz_dns_by.split(".")[2];
          this.ippz_dns_by4 = res3.ippz_dns_by.split(".")[3];
        }
        this.formData.wgpz_wgmc = res3.wgpz_wgmc;
        this.formData.wgpz_wgid = res3.wgpz_wgid;
        this.formData.wgpz_wglx = res3.wgpz_wglx;
        this.formData.tdpz_tdmc = res3.tdpz_tdmc;
        this.formData.tdpz_td = res3.tdpz_td;
        this.formData.tdpz_qdmc = res3.tdpz_qdmc;
        this.formData.tdpz_ip = res3.tdpz_ip;
        this.formData.tdpz_port = res3.tdpz_port;
        this.formData.tdpz_cssj = res3.tdpz_cssj;
        this.formData.tdpz_jgsj = res3.tdpz_jgsj;
        this.formData.tdpz_lxsj = res3.tdpz_lxsj;
        this.formData.tdpz_cfcs = res3.tdpz_cfcs;
        this.formData.tdpz_watchtime = res3.tdpz_watchtime;
        this.formData.tdpz_cjsylxdz = res3.tdpz_cjsylxdz;
        this.formData.tdpz_dxzkb = res3.tdpz_dxzkb;
        this.formData.tdpz_050F = res3.tdpz_050F;
        this.formData.tdpz_0610 = res3.tdpz_0610;
        this.formData.sbpz_sbid = res3.sbpz_sbid;
        this.formData.sbpz_sbmc = res3.sbpz_sbmc;
        this.formData.sbpz_mac = res3.sbpz_mac;
        this.formData.sbpz_jysb = res3.sbpz_jysb;
        this.formData.sbpz_jdzxz = res3.sbpz_jdzxz;

        this.formData.cjdpz_tagid = res3.cjdpz_tagid;
        this.formData.cjdpz_mc = res3.cjdpz_mc;
        this.formData.cjdpz_sjq = res3.cjdpz_sjq;
        this.formData.cjdpz_jcqdz = res3.cjdpz_jcqdz;
        this.formData.cjdpz_cjsjlx = res3.cjdpz_cjsjlx;
        this.formData.cjdpz_zjx = res3.cjdpz_zjx;
        this.formData.cjdpz_dxsx = res3.cjdpz_dxsx;
        this.formData.cjdpz_beilv = res3.cjdpz_beilv;

        this.formData.mqtt_qiyong = res3.mqtt_qiyong;
        this.formData.mqtt_ip = res3.mqtt_ip;
        this.formData.mqtt_port = res3.mqtt_port;
        this.formData.mqtt_wgsn = res3.mqtt_wgsn;
        this.formData.mqtt_sssjfbzt = res3.mqtt_sssjfbzt;
        this.formData.mqtt_qos = res3.mqtt_qos;
        this.formData.mqtt_scms = res3.mqtt_scms;
        this.formData.mqtt_sczq = res3.mqtt_sczq;
        this.formData.mqtt_sjgl = res3.mqtt_sjgl;
        this.formData.mqtt_cjd_sbmc = res3.mqtt_cjd_sbmc;
        this.formData.mqtt_cjd_tagid = res3.mqtt_cjd_tagid;
      }
    },
  },
  created() {
    this.user_id = window.location.href.split("?")[1];
    console.log(this.user_id)

  },
  mounted() {
    this.getUserAnswer();
  },
  directives: {
    copy: {
      bind(el, {value}) {
        // 给元素赋值一个$value值,即指令绑定的值
        el.$value = value;
        el.handler = () => {
          // 如果可复制的值为空的时候，给出提示；
          if (!el.$value) {
            console.log("无复制内容");
            return;
          }
          // 动态创建 textarea 标签
          const textarea = document.createElement("textarea");
          // 将该 textarea 设为 readonly 防止 IOS 下自动唤起键盘，同时将 textarea 移除可视区域
          textarea.readOnly = "readonly";
          textarea.style.position = "absolute";
          textarea.style.left = "-9999px";
          // 将要copy的值赋值给textarea 标签的value属性
          textarea.value = el.$value;
          // 将textarea 插入到body中
          document.body.appendChild(textarea);
          // 选中值并复制
          textarea.select();
          const result = document.execCommand("Copy");
          if (result) {
            console.log("复制成功");
          }
          document.body.removeChild(textarea);
        };
        // 绑定点击事件，点击的时候copy值
        el.addEventListener("click", el.handler);
      },
      // 当传递进来的值更新的时候触发
      componentUpdated(el, {value}) {
        el.$value = value;
      },
      // 指令与元素解绑的时候，移除事件绑定
      unbind(el) {
        el.removeEventListener("click", el.handler);
      },
    },
  },
};
</script>

<style lang="less" scoped>
.title_center {
  font-size: 14px;
  color: red;
  position: absolute;
  left: 190px;
  top: 24px;
}
/deep/ .zh{
    .el-row {
      .el-col-12:last-child {
        padding-right: 50px !important;
      }

      .el-col-12:first-child {
        padding-right: 68px !important;
      }
    }
}

/deep/ .wired,
/deep/ .wifi {
  .el-row {
    .el-col-12:last-child {
      padding-right: 120px;
    }

    .el-col-12:first-child {
      padding-right: 118px;
    }

    .el-input__inner {
      height: 30px;
      text-align: center;
      padding: 0;
    }

    .el-row {
      display: flex;
      align-items: flex-end;

      .el-col-1 {
        text-align: center;
        line-height: 20px;
        height: 20px;
      }

      .mac {
        // display: flex;
        align-items: center;

        .el-button {
          position: absolute;
          left: 200px;
          bottom: 5px;
          margin-left: 10px;
          margin-top: 10px;
          width: 80px;
          height: 30px;
          line-height: 0.5;
        }
      }
    }
  }
}

.netWay {
  margin-bottom: 20px;
  width: 80px;
  color: rgba(16, 16, 16, 1);
  font-size: 20px;
  text-align: left;
}

.footer {
  position: absolute;
  left: 360px;
  bottom: 2px;
}
</style>
