<!-- IP设置-网络方式 -->
<template>
  <div>
    <!-- 无线网关 -->
    <el-dialog
      :title="$t('wirelessgatewayip.title')"
      :visible.sync="dialogFormVisible"
      v-loading="loading"
      :append-to-body="true"
      width="894px"
    >
      <span class="title_center">{{ $t("wirelessgatewayip.prompt") }}</span>
      <div class="form_content">
        <div>
          <p class="netWay">{{ $t("wirelessgatewayip.method") }}</p>
          <el-radio
            v-model="ruleForm.ippz_lwfs"
            label="有线"
            style="color: white"
            >{{ $t("wirelessgatewayip.Wired") }}</el-radio
          >
          <el-radio
            v-model="ruleForm.ippz_lwfs"
            label="无线"
            style="color: white"
            >{{ $t("wirelessgatewayip.WIFI") }}</el-radio
          >
          <el-divider></el-divider>
          <!-- {{ ruleForm.ippz_lwfs }} -->
        </div>
        <!-- v-if="ippz_lwfs == 1 ? true : false" -->
        <!-- <div>
          <h2>有线</h2>
          <div class="wired">
            <el-form :model="ruleForm" :label-position="labelPosition" label-width="80px" :rules="rules_ippz_wirle"
              ref="rule">
              <el-row>
                <el-col :span="12">
                  <el-form-item label="网口:" :label-width="formLabelWidth" prop="ippz_wangkou">
                    <el-select v-model="ruleForm.ippz_wangkou" placeholder="" 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="默认网关:" :label-width="formLabelWidth" 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="子网掩码:" :label-width="formLabelWidth" 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="IP地址:" :label-width="formLabelWidth" 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="首选DNS:" :label-width="formLabelWidth" 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="备选DNS:" :label-width="formLabelWidth" 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="MAC地址:" :label-width="formLabelWidth" prop="ippz_mac">
                    <el-row>
                      <el-col :span="24" class="mac">
                        <el-input style="width: 200px; height: 30px" v-model="ruleForm.ippz_mac"></el-input><el-button
                          v-copy="ruleForm.ippz_mac" @click="CopyText">复制</el-button>
                      </el-col>
                    </el-row>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </div>
        </div> -->
        <!-- v-if="ippz_lwfs == 2 ? true : false" -->
        <div>
          <h2>WIFI</h2>
          <div :class="$i18n.locale === 'zh' ? 'zh wifi' : 'wifi'">
            <el-form
              :model="ruleForm"
              :label-position="labelPosition"
              label-width="80px"
              :rules="rules_ippz_wirle"
              ref="ruleForm"
            >
              <el-row>
                <el-col :span="12">
                  <el-form-item
                    label="SSID:"
                    :label-width="formLabelWidth"
                    prop="ippz_wifi_ssid"
                  >
                    <el-input
                      v-model="ruleForm.ippz_wifi_ssid"
                      :placeholder="$t('Please')"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    :label="$t('wirelessgatewayip.password')"
                    :label-width="formLabelWidth"
                    prop="ippz_wifi_mm"
                  >
                    <el-input
                      v-model="ruleForm.ippz_wifi_mm"
                      placeholder=""
                      style="width: 200px; height: 30px"
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item
                    :label="$t('wirelessgatewayip.IP')"
                    :label-width="formLabelWidth"
                  >
                    <el-row>
                      <el-col :span="5">
                        <el-input v-model.number="ippz_ip1"></el-input>
                      </el-col>
                      <el-col :span="1">. </el-col>
                      <el-col :span="5">
                        <el-input v-model.number="ippz_ip2"></el-input>
                      </el-col>
                      <el-col :span="1">.</el-col>
                      <el-col :span="5">
                        <el-input v-model.number="ippz_ip3"></el-input>
                      </el-col>
                      <el-col :span="1">.</el-col>
                      <el-col :span="5">
                        <el-input v-model.number="ippz_ip4"></el-input>
                      </el-col>
                    </el-row>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    :label="$t('wirelessgatewayip.SubnetMask')"
                    :label-width="formLabelWidth"
                  >
                    <el-row>
                      <el-col :span="5">
                        <el-input v-model="ippz_zwym1"></el-input>
                      </el-col>
                      <el-col :span="1">.</el-col>
                      <el-col :span="5">
                        <el-input v-model="ippz_zwym2"></el-input>
                      </el-col>
                      <el-col :span="1">.</el-col>
                      <el-col :span="5">
                        <el-input v-model="ippz_zwym3"></el-input>
                      </el-col>
                      <el-col :span="1">.</el-col>
                      <el-col :span="5">
                        <el-input v-model="ippz_zwym4"></el-input>
                      </el-col>
                    </el-row>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item
                    :label="$t('wirelessgatewayip.gateway')"
                    :label-width="formLabelWidth"
                  >
                    <el-row>
                      <el-col :span="5">
                        <el-input v-model="ippz_mrwg1"></el-input>
                      </el-col>
                      <el-col :span="1">. </el-col>
                      <el-col :span="5">
                        <el-input v-model="ippz_mrwg2"></el-input>
                      </el-col>
                      <el-col :span="1">.</el-col>
                      <el-col :span="5">
                        <el-input v-model="ippz_mrwg3"></el-input>
                      </el-col>
                      <el-col :span="1">.</el-col>
                      <el-col :span="5">
                        <el-input v-model="ippz_mrwg4"></el-input>
                      </el-col>
                    </el-row>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    :label="$t('wirelessgatewayip.DNS1')"
                    :label-width="formLabelWidth"
                    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-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item
                    :label="$t('wirelessgatewayip.DNS2')"
                    :label-width="formLabelWidth"
                    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-col :span="12">
                  <el-form-item
                    :label="$t('wirelessgatewayip.MAC')"
                    :label-width="formLabelWidth"
                    prop="ippz_mac"
                  >
                    <el-row>
                      <el-col :span="24" class="mac">
                        <el-input
                          style="width: 200px"
                          v-model="ruleForm.ippz_mac"
                        /><el-button
                          v-copy="ruleForm.ippz_mac"
                          @click="CopyText"
                          >{{ $t("wirelessgatewayip.copy") }}</el-button
                        >
                      </el-col>
                    </el-row>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </div>
        </div>
        <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 { getQueryAnswer, GetUserAnswer, SaveUserAnswer } from "../api/user";
export default {
  name: "DataView",
  data() {
    return {
      user_id: "",
      step: "",
      ruleForm: {
        // ippz_wangkou:"",
        ippz_lwfs: "",
        ippz_zwym: "",
        ippz_mrwg: "",
        ippz_dns_sx: "",
        ippz_dns_by: "",
        ippz_ip: "",
        ippz_mac: "",
        ippz_wifi_ssid: "",
        ippz_wifi_mm: "",
        wgpz_wgmc: "",
        wgpz_wgid: "",
        wgpz_wglx: "",
        tdpz_tdmc: "",
        tdpz_td: "",
        tdpz_qdmc: "",
        tdpz_chuankou: "",
        tdpz_btl: "",
        tdpz_sjw: "",
        tdpz_tzw: "",
        tdpz_jojy: "",
        tdpz_cgsj: "",
        tdpz_jgsj: "",
        tdpz_lxsj: "",
        tdpz_cfcs: "",
        tdpz_watchtime: "",
        tdpz_cjsylxdz: "",
        tdpz_dxzkb: "",
        tdpz_050F: "",
        tdpz_0610: "",
        sbpz_sbid: "",
        sbpz_sbmc: "",
        sbpz_sbdz: "",
        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: "",
        mqtt_retained: "",
      },

      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: "",
      ippz_mac: "",
      loading: false,

      dialogFormVisible: true,
      formLabelWidth: this.$i18n.locale === "zh" ? "140px" : "100px",
      // 测试数据的变量
      // 有线的规则校验
      rules_ippz_wirle: {
        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("wirelessgatewayip.rules.ippz_mac"),
            trigger: "blur",
          },
        ],
        ippz_wifi_ssid: [
          {
            required: true,
            message: this.$t("wirelessgatewayip.rules.ippz_wifi_ssid"),
            trigger: "blur",
          },
        ],
        ippz_wifi_mm: [
          {
            required: true,
            message: this.$t("wirelessgatewayip.rules.ippz_wifi_mm"),
            trigger: "blur",
          },
        ],
      },

      // rules_ippz_wifi: {

      //   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: "请输入mac地址", trigger: "blur" },
      //   ],
      // },
    };
  },
  methods: {
    // 表单的校验
    //子网掩码验证
    validateZwym(rule, value, callback) {
      if (
        this.ippz_zwym1 +
          "." +
          this.ippz_zwym2 +
          "." +
          this.ippz_zwym3 +
          "." +
          this.ippz_zwym4 ===
        "..."
      ) {
        callback(new Error(this.$t("wirelessgatewayip.rules.ippz_zwym")));
      } 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("wirelessgatewayip.rules.ippz_zwym1")));
      } 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("wirelessgatewayip.rules.ip1")));
      } 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("wirelessgatewayip.rules.ip2")));
      } else {
        callback();
      }
    },
    //默认网关验证
    validateMrwg(rule, value, callback) {
      if (
        this.ippz_mrwg1 +
          "." +
          this.ippz_mrwg2 +
          "." +
          this.ippz_mrwg3 +
          "." +
          this.ippz_mrwg4 ===
        "..."
      ) {
        callback(new Error(this.$t("wirelessgatewayip.rules.ippz_mrwg")));
      } 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("wirelessgatewayip.rules.ippz_mrwg1")));
      } 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("wirelessgatewayip.rules.ippz_dns_sx")));
      } 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("wirelessgatewayip.rules.ippz_dns_sx1")));
      } 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("wirelessgatewayip.rules.ippz_dns_by")));
      } 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("wirelessgatewayip.rules.ippz_dns_by1")));
      } else {
        callback();
      }
    },
    // 登陆时进行校验
    submitForm() {
      this.$refs["ruleForm"].validate((valid) => {
        if (valid) {
          this.saveAll();
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 封装合并输入框的数据
    Merge(value, value1, value2, value3, value4) {
      value = value1 + "." + value2 + "." + value3 + "." + value4;
      return value;
    },
    SliceData(value) {
      let res = value.split(".");
      // console.log(res);
      return res;
    },
    // 保存数据,发送请求
    async saveAll() {
      this.dialogFormVisible = false;
      console.log(
        this.ippz_ip1 +
          "." +
          this.ippz_ip2 +
          "." +
          this.ippz_ip3 +
          "." +
          this.ippz_ip4,
        "提交数据"
      );
      var obj = {
        // ippz_wangkou:this.ruleForm.ippz_wangkou,
        ippz_lwfs: this.ruleForm.ippz_lwfs,
        ippz_zwym:
          this.ippz_zwym1 +
          "." +
          this.ippz_zwym2 +
          "." +
          this.ippz_zwym3 +
          "." +
          this.ippz_zwym4,
        ippz_ip:
          this.ippz_ip1 +
          "." +
          this.ippz_ip2 +
          "." +
          this.ippz_ip3 +
          "." +
          this.ippz_ip4,
        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,
        ippz_mac: this.ruleForm.ippz_mac,
        ippz_wifi_ssid: this.ruleForm.ippz_wifi_ssid,
        ippz_wifi_mm: this.ruleForm.ippz_wifi_mm,
      };
      let datas = { ...this.ruleForm, ...obj };
      console.log(obj, datas, "xxxxxx");
      let res = await SaveUserAnswer({
        mark: "DB-IotLite_wx",
        // user_id: "USER202307301114011710",
        user_id: this.user_id,
        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);
      sessionStorage.setItem("DB-IotLite_wx", JSON.stringify(datas));
    },
    CopyText() {
      this.$message({
        message: "复制成功",
        type: "success",
      });
    },
    async GetUserAnswer() {
      this.loading = true;
      let res2 = await GetUserAnswer({
        mark: "DB-IotLite_wx",
        // user_id: "USER202307301114011710",
        user_id: this.user_id,
      });
      this.loading = false;
      console.log(res2);
      if (!res2.data.state) {
        getQueryAnswer({
          mark: "DB-IotLite_wx",
          user_id: this.user_id,
        }).then((res) => {
          let res3 = JSON.parse(res.data.data.r3);

          if (res3.ippz_ip.indexOf(".") == -1) {
            res3.ippz_ip = "...";
          }
          if (res3.ippz_zwym.indexOf(".") == -1) {
            res3.ippz_zwym = "...";
          }
          if (res3.ippz_mrwg.indexOf(".") == -1) {
            res3.ippz_mrwg = "...";
          }
          if (res3.ippz_dns_sx.indexOf(".") == -1) {
            res3.ippz_dns_sx = "...";
          }
          if (res3.ippz_dns_by.indexOf(".") == -1) {
            res3.ippz_dns_by = "...";
          }
          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_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_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.ruleForm.ippz_wangkou = res3.ippz_wangkou;
          this.ruleForm.ippz_lwfs = res3.ippz_lwfs;
          this.ruleForm.ippz_zwym = res3.ippz_zwym;
          this.ruleForm.ippz_mrwg = res3.ippz_mrwg;
          this.ruleForm.ippz_dns_sx = res3.ippz_dns_sx;
          this.ruleForm.ippz_dns_by = res3.ippz_dns_by;
          this.ruleForm.ippz_mac = res3.ippz_mac;
          this.ruleForm.ippz_wifi_ssid = res3.ippz_wifi_ssid;
          this.ruleForm.ippz_wifi_mm = res3.ippz_wifi_mm;

          this.ruleForm.wgpz_wgmc = res3.wgpz_wgmc;
          this.ruleForm.wgpz_wgid = res3.wgpz_wgid;
          this.ruleForm.wgpz_wglx = res3.wgpz_wglx;
          this.ruleForm.tdpz_tdmc = res3.tdpz_tdmc;
          this.ruleForm.tdpz_td = res3.tdpz_td;
          this.ruleForm.tdpz_qdmc = res3.tdpz_qdmc;
          this.ruleForm.tdpz_chuankou = res3.tdpz_chuankou;
          this.ruleForm.tdpz_btl = res3.tdpz_btl;
          this.ruleForm.tdpz_sjw = res3.tdpz_sjw;
          this.ruleForm.tdpz_tzw = res3.tdpz_tzw;
          this.ruleForm.tdpz_jojy = res3.tdpz_jojy;
          this.ruleForm.tdpz_cgsj = res3.tdpz_cgsj;
          this.ruleForm.tdpz_jgsj = res3.tdpz_jgsj;
          this.ruleForm.tdpz_lxsj = res3.tdpz_lxsj;
          this.ruleForm.tdpz_cfcs = res3.tdpz_cfcs;
          this.ruleForm.tdpz_watchtime = res3.tdpz_watchtime;
          this.ruleForm.tdpz_cjsylxdz = res3.tdpz_cjsylxdz;
          this.ruleForm.tdpz_dxzkb = res3.tdpz_dxzkb;
          this.ruleForm.tdpz_050F = res3.tdpz_050F;
          this.ruleForm.tdpz_0610 = res3.tdpz_0610;
          this.ruleForm.sbpz_sbid = res3.sbpz_sbid;
          this.ruleForm.sbpz_sbmc = res3.sbpz_sbmc;
          this.ruleForm.sbpz_sbdz = res3.sbpz_sbdz;
          this.ruleForm.sbpz_jysb = res3.sbpz_jysb;
          this.ruleForm.sbpz_jdzxz = res3.sbpz_jdzxz;

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

          this.ruleForm.mqtt_qiyong = res3.mqtt_qiyong;
          this.ruleForm.mqtt_ip = res3.mqtt_ip;
          this.ruleForm.mqtt_port = res3.mqtt_port;
          this.ruleForm.mqtt_wgsn = res3.mqtt_wgsn;
          this.ruleForm.mqtt_sssjfbzt = res3.mqtt_sssjfbzt;
          this.ruleForm.mqtt_qos = res3.mqtt_qos;
          this.ruleForm.mqtt_scms = res3.mqtt_scms;
          this.ruleForm.mqtt_sczq = res3.mqtt_sczq;
          this.ruleForm.mqtt_sjgl = res3.mqtt_sjgl;
          this.ruleForm.mqtt_cjd_sbmc = res3.mqtt_cjd_sbmc;
          this.ruleForm.mqtt_cjd_tagid = res3.mqtt_cjd_tagid;
        });
      }
      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_mrwg) {
          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_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_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.ruleForm.ippz_wangkou = res3.ippz_wangkou;
          this.ruleForm.ippz_lwfs = res3.ippz_lwfs;
          this.ruleForm.ippz_zwym = res3.ippz_zwym;
          this.ruleForm.ippz_mrwg = res3.ippz_mrwg;
          this.ruleForm.ippz_dns_sx = res3.ippz_dns_sx;
          this.ruleForm.ippz_dns_by = res3.ippz_dns_by;
          this.ruleForm.ippz_mac = res3.ippz_mac;
          this.ruleForm.ippz_wifi_ssid = res3.ippz_wifi_ssid;
          this.ruleForm.ippz_wifi_mm = res3.ippz_wifi_mm;
        }
        this.ruleForm.wgpz_wgmc = res3.wgpz_wgmc;
        this.ruleForm.wgpz_wgid = res3.wgpz_wgid;
        this.ruleForm.wgpz_wglx = res3.wgpz_wglx;
        this.ruleForm.tdpz_tdmc = res3.tdpz_tdmc;
        this.ruleForm.tdpz_td = res3.tdpz_td;
        this.ruleForm.tdpz_qdmc = res3.tdpz_qdmc;
        this.ruleForm.tdpz_chuankou = res3.tdpz_chuankou;
        this.ruleForm.tdpz_btl = res3.tdpz_btl;
        this.ruleForm.tdpz_sjw = res3.tdpz_sjw;
        this.ruleForm.tdpz_tzw = res3.tdpz_tzw;
        this.ruleForm.tdpz_jojy = res3.tdpz_jojy;
        this.ruleForm.tdpz_cgsj = res3.tdpz_cgsj;
        this.ruleForm.tdpz_jgsj = res3.tdpz_jgsj;
        this.ruleForm.tdpz_lxsj = res3.tdpz_lxsj;
        this.ruleForm.tdpz_cfcs = res3.tdpz_cfcs;
        this.ruleForm.tdpz_watchtime = res3.tdpz_watchtime;
        this.ruleForm.tdpz_cjsylxdz = res3.tdpz_cjsylxdz;
        this.ruleForm.tdpz_dxzkb = res3.tdpz_dxzkb;
        this.ruleForm.tdpz_050F = res3.tdpz_050F;
        this.ruleForm.tdpz_0610 = res3.tdpz_0610;
        this.ruleForm.sbpz_sbid = res3.sbpz_sbid;
        this.ruleForm.sbpz_sbmc = res3.sbpz_sbmc;
        this.ruleForm.sbpz_sbdz = res3.sbpz_sbdz;
        this.ruleForm.sbpz_jysb = res3.sbpz_jysb;
        this.ruleForm.sbpz_jdzxz = res3.sbpz_jdzxz;

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

        this.ruleForm.mqtt_qiyong = res3.mqtt_qiyong;
        this.ruleForm.mqtt_ip = res3.mqtt_ip;
        this.ruleForm.mqtt_port = res3.mqtt_port;
        this.ruleForm.mqtt_wgsn = res3.mqtt_wgsn;
        this.ruleForm.mqtt_sssjfbzt = res3.mqtt_sssjfbzt;
        this.ruleForm.mqtt_qos = res3.mqtt_qos;
        this.ruleForm.mqtt_scms = res3.mqtt_scms;
        this.ruleForm.mqtt_sczq = res3.mqtt_sczq;
        this.ruleForm.mqtt_sjgl = res3.mqtt_sjgl;
        this.ruleForm.mqtt_cjd_sbmc = res3.mqtt_cjd_sbmc;
        this.ruleForm.mqtt_cjd_tagid = res3.mqtt_cjd_tagid;
      }
    },
  },
  created() {
    this.user_id = window.location.href.split("?")[1];
    this.GetUserAnswer();
  },
  mounted() {},
  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>
:deep(.el-dialog__body) {
  padding: 40px 20px;
}
/deep/ .zh {
  .el-row {
    .el-col-12:last-child {
      padding-right: 70px !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;
}

.title_center {
  font-size: 14px;
  color: red;
  position: absolute;
  left: 190px;
  top: 24px;
}
</style>
