zhangzengfei
2022-02-22 2f306b4925e30cb1aa685716a045aca620231c11
添加域名配置
1个文件已修改
496 ■■■■■ 已修改文件
src/pages/settings/components/BasicSetting.vue 496 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/settings/components/BasicSetting.vue
@@ -8,11 +8,7 @@
      type="border-card"
    >
      <!-- 本机信息 -->
      <el-tab-pane
        label="本机信息"
        name="sysInfo"
        v-if="isShow('settings:sysInfo')"
      >
      <el-tab-pane label="本机信息" name="sysInfo" v-if="isShow('settings:sysInfo')">
        <el-menu
          :default-openeds="openeds"
          background-color="#fff"
@@ -29,29 +25,23 @@
              <b class="tree-font">本机信息</b>
            </template>
            <el-menu-item-group class="item-group">
              <el-form
                :model="sysinfo"
                :rules="rules"
                ref="sysinfo"
                label-width="100px"
              >
              <el-form :model="sysinfo" :rules="rules" ref="sysinfo" label-width="100px">
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="名称" prop="server_name">
                      <el-input
                        v-model="sysinfo.server_name"
                        placeholder="服务器名称"
                        size="small"
                      ></el-input>
                    <el-form-item label="服务器名称" prop="server_name">
                      <el-input v-model="sysinfo.server_name" placeholder="服务器名称" size="small"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="域名" prop="server_name">
                      <el-input v-model="sysinfo.server_domain" placeholder="WEB服务域名" size="small"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="端口" prop="server_port">
                      <el-input
                        v-model="sysinfo.server_port"
                        placeholder="WEB服务端口"
                        size="small"
                      ></el-input>
                      <el-input v-model="sysinfo.server_port" placeholder="WEB服务端口" size="small"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
@@ -59,18 +49,12 @@
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="IP" prop="ip">
                      <ip-input
                        :ip="sysinfo.ip"
                        @on-blur="sysinfo.ip = arguments[0]"
                      ></ip-input>
                      <ip-input :ip="sysinfo.ip" @on-blur="sysinfo.ip = arguments[0]"></ip-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="子网掩码" prop="subMask">
                      <ip-input
                        :ip="sysinfo.subMask"
                        @on-blur="sysinfo.subMask = arguments[0]"
                      ></ip-input>
                      <ip-input :ip="sysinfo.subMask" @on-blur="sysinfo.subMask = arguments[0]"></ip-input>
                    </el-form-item>
                  </el-col>
                </el-row>
@@ -78,25 +62,17 @@
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="网关" prop="gateway">
                      <ip-input
                        :ip="sysinfo.gateway"
                        @on-blur="sysinfo.gateway = arguments[0]"
                      ></ip-input>
                      <ip-input :ip="sysinfo.gateway" @on-blur="sysinfo.gateway = arguments[0]"></ip-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="DNS" prop="dns">
                      <ip-input
                        :ip="sysinfo.dns"
                        @on-blur="sysinfo.dns = arguments[0]"
                      ></ip-input>
                      <ip-input :ip="sysinfo.dns" @on-blur="sysinfo.dns = arguments[0]"></ip-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <div class="mt15 mb10 save-btn">
                  <el-button type="primary" @click="submitSysinfo" size="small"
                    >保存</el-button
                  >
                  <el-button type="primary" @click="submitSysinfo" size="small">保存</el-button>
                </div>
              </el-form>
            </el-menu-item-group>
@@ -161,11 +137,7 @@
              <b class="tree-font">事件录像时长</b>
            </template>
            <el-menu-item-group class="item-group">
              <el-form
                label-width="150px"
                class="alarmSetting"
                style="padding-left: 5px; padding-right: 5px"
              >
              <el-form label-width="150px" class="alarmSetting" style="padding-left: 5px; padding-right: 5px">
                <el-form-item label="视频截取最短时长" style="width: 724px">
                  <el-slider
                    id="cut_min_duration"
@@ -211,9 +183,7 @@
                  >&nbsp;s
                </el-form-item>
                <div class="mt15 mb10 save-btn">
                  <el-button type="primary" @click="submitAlarm" size="small"
                    >保存</el-button
                  >
                  <el-button type="primary" @click="submitAlarm" size="small">保存</el-button>
                </div>
              </el-form>
            </el-menu-item-group>
@@ -223,11 +193,7 @@
      </el-tab-pane>
      <!-- 时间配置 -->
      <el-tab-pane
        label="时间配置"
        name="timeSet"
        v-if="isShow('settings:timeSet')"
      >
      <el-tab-pane label="时间配置" name="timeSet" v-if="isShow('settings:timeSet')">
        <el-form label-width="100px">
          <el-form-item label="设备时间">
            {{ equipmentTime }}
@@ -240,11 +206,7 @@
          </div>
          <el-form-item label="服务器地址">
            <ip-input
              :ip="ntpServer"
              @on-blur="ntpServer = arguments[0]"
              :disabled="syncType === '2'"
            ></ip-input>
            <ip-input :ip="ntpServer" @on-blur="ntpServer = arguments[0]" :disabled="syncType === '2'"></ip-input>
          </el-form-item>
          <el-form-item label="校时时间间隔" style="width: 41.3%">
@@ -295,20 +257,14 @@
          <el-col :span="12" style="padding-right: 40px">
            <el-form-item>
              <el-button type="primary" @click="submitClock" size="small"
                >保存</el-button
              >
              <el-button type="primary" @click="submitClock" size="small">保存</el-button>
            </el-form-item>
          </el-col>
        </el-form>
      </el-tab-pane>
      <!-- 集群管理 -->
      <el-tab-pane
        label="集群管理"
        name="cluster"
        v-if="isShow('settings:cluster')"
      >
      <el-tab-pane label="集群管理" name="cluster" v-if="isShow('settings:cluster')">
        <cluster-management></cluster-management>
      </el-tab-pane>
      <!-- <el-tab-pane label="外部访问" name="fourth">
@@ -351,20 +307,10 @@
          </el-submenu>
        </el-menu>
      </el-tab-pane>-->
      <el-tab-pane
        label="权限管理"
        name="permission"
        v-if="isShow('settings:permission')"
      >
        <authority-management
          v-if="activeName === 'permission'"
        ></authority-management>
      <el-tab-pane label="权限管理" name="permission" v-if="isShow('settings:permission')">
        <authority-management v-if="activeName === 'permission'"></authority-management>
      </el-tab-pane>
      <el-tab-pane
        label="广播设置"
        name="broadcast"
        v-if="isShow('settings:broadcast')"
      >
      <el-tab-pane label="广播设置" name="broadcast" v-if="isShow('settings:broadcast')">
        <radio-set v-if="activeName === 'broadcast'"></radio-set>
      </el-tab-pane>
    </el-tabs>
@@ -381,17 +327,17 @@
  saveClockInfo,
  testNTPserver,
  getResourceConfig,
  saveResourceConfig,
} from "@/api/system";
  saveResourceConfig
} from "@/api/system"
import { isPort, isIPv4 } from "@/scripts/validate";
import ipInput from "@/components/subComponents/IPInput";
import TimeZones from "@/Pool/TimeZones";
import { isPort, isIPv4 } from "@/scripts/validate"
import ipInput from "@/components/subComponents/IPInput"
import TimeZones from "@/Pool/TimeZones"
import ClusterManagement from "./ClusterManagement";
import AuthorityManagement from "./AuthorityManagement";
import RadioSet from "./RadioSet";
import config from "../../../../package.json";
import ClusterManagement from "./ClusterManagement"
import AuthorityManagement from "./AuthorityManagement"
import RadioSet from "./RadioSet"
import config from "../../../../package.json"
export default {
  name: "BasicSettings",
@@ -399,34 +345,31 @@
    ipInput,
    ClusterManagement,
    AuthorityManagement,
    RadioSet,
    RadioSet
  },
  computed: {
    min_video_len() {
      // return +(this.fakeObj.min * 1.2).toFixed(0);
      return Math.round(this.fakeObj.min * 1.2);
      return Math.round(this.fakeObj.min * 1.2)
    },
    max_video_len() {
      return Math.round(this.fakeObj.max * 1.2);
      return Math.round(this.fakeObj.max * 1.2)
      // return +(this.fakeObj.max * 1.2).toFixed(0);
    },
    isAdmin() {
      if (
        sessionStorage.getItem("userInfo") &&
        sessionStorage.getItem("userInfo") !== ""
      ) {
        let loginName = JSON.parse(sessionStorage.getItem("userInfo")).username;
        return loginName === "superadmin" || loginName === "basic";
      if (sessionStorage.getItem("userInfo") && sessionStorage.getItem("userInfo") !== "") {
        let loginName = JSON.parse(sessionStorage.getItem("userInfo")).username
        return loginName === "superadmin" || loginName === "basic"
      }
      return false;
    },
      return false
    }
  },
  directives: {
    focus: {
      inserted: function (el) {
        el.querySelector("input").focus();
      },
    },
      inserted: function(el) {
        el.querySelector("input").focus()
      }
    }
  },
  data() {
    return {
@@ -451,81 +394,79 @@
      max_len: 0,
      fakeObj: {
        min: 0,
        max: 0,
        max: 0
      },
      originNetConfig: {
        ip: "",
        gw: "",
        mask: "",
        dns: "",
        dns: ""
      },
      rules: {
        ip: [
          {
            required: true,
            message: "请输入IP地址",
            trigger: "change",
            trigger: "change"
          },
          { validator: isIPv4, trigger: "change" },
          { validator: isIPv4, trigger: "change" }
        ],
        ServerIp: [
          {
            required: true,
            message: "请输入IP地址",
            trigger: "change",
            trigger: "change"
          },
          { validator: isIPv4, trigger: "change" },
          { validator: isIPv4, trigger: "change" }
        ],
        ServerPort: [
          {
            required: true,
            message: "请输入端口",
            trigger: "change",
            trigger: "change"
          },
          { validator: isPort, trigger: "change" },
          { validator: isPort, trigger: "change" }
        ],
        GbServerPort: [
          {
            required: true,
            message: "请输入端口",
            trigger: "change",
            trigger: "change"
          },
          { validator: isPort, trigger: "change" },
          { validator: isPort, trigger: "change" }
        ],
        gateway: [
          {
            required: true,
            message: "请输入网关",
            trigger: "change",
            trigger: "change"
          },
          { validator: isIPv4, trigger: "change" },
          { validator: isIPv4, trigger: "change" }
        ],
        dns: [
          {
            required: true,
            message: "请输入dns地址",
            trigger: "change",
            trigger: "change"
          },
          { validator: isIPv4, trigger: "change" },
          { validator: isIPv4, trigger: "change" }
        ],
        server_name: [
          { required: true, message: "请输入名称", trigger: "change" },
        ],
        server_name: [{ required: true, message: "请输入名称", trigger: "change" }],
        subMask: [
          {
            required: true,
            message: "请输入子网掩码",
            trigger: "change",
            trigger: "change"
          },
          { validator: isIPv4, trigger: "change" },
        ],
          { validator: isIPv4, trigger: "change" }
        ]
      },
      openeds: ["0"],
      ipServer: {
        diyOrLocalIP: "1",
        ip: "",
        localhost: "",
        localFilePort: "",
        localFilePort: ""
      },
      locationCity: {
        province: "",
@@ -533,119 +474,116 @@
        county: "",
        provinceOptions: [],
        cityOptions: [],
        countyOptions: [],
        countyOptions: []
      },
      webPort: 0,
      ntpTestLoading: false,
      buttonAuthority: sessionStorage.getItem("buttonAuthoritys") || [],
    };
      buttonAuthority: sessionStorage.getItem("buttonAuthoritys") || []
    }
  },
  created() {
    if (this.isShow("settings:sysInfo")) {
      this.activeName = "sysInfo";
      this.activeName = "sysInfo"
    } else if (this.isShow("settings:timeSet")) {
      this.activeName = "timeSet";
      this.activeName = "timeSet"
    } else if (this.isShow("settings:cluster")) {
      this.activeName = "cluster";
      this.activeName = "cluster"
    } else if (this.isShow("settings:permission")) {
      this.activeName = "permission";
      this.activeName = "permission"
    } else if (this.isShow("settings:broadcast")) {
      this.activeName = "broadcast";
      this.activeName = "broadcast"
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.initSysinfo();
      this.initSysinfo()
      // this.initAlarmConf();
      this.initResourceConfig();
      this.initClockConf();
      this.initResourceConfig()
      this.initClockConf()
      //this.markStartTime();
    });
    })
  },
  beforeDestroy() {
    clearTimeout(this.clockTimer);
    clearInterval(this.browserTimer);
    clearTimeout(this.clockTimer)
    clearInterval(this.browserTimer)
  },
  methods: {
    formatTooltip(v){
      return Math.round(v*1.2)
    formatTooltip(v) {
      return Math.round(v * 1.2)
    },
    isShow(authority) {
      return (
        this.isAdmin || this.buttonAuthority.indexOf("," + authority + ",") > -1
      );
      return this.isAdmin || this.buttonAuthority.indexOf("," + authority + ",") > -1
    },
    initSysinfo() {
      this.loadingText = "正在获取设备信息...";
      this.loadingText = "正在获取设备信息..."
      getDevInfo()
        .then((rsp) => {
          if (rsp && rsp.success) {
            this.sysinfo = rsp.data;
            this.sysinfo.gateway = this.sysinfo.gateway.trim();
            this.originNetConfig.ip = this.sysinfo.ip;
            this.originNetConfig.mask = this.sysinfo.subMask;
            this.originNetConfig.gw = this.sysinfo.gateway.trim();
            this.originNetConfig.dns = this.sysinfo.dns ? this.sysinfo.dns : "";
            this.sysinfo = rsp.data
            this.sysinfo.gateway = this.sysinfo.gateway.trim()
            this.originNetConfig.ip = this.sysinfo.ip
            this.originNetConfig.mask = this.sysinfo.subMask
            this.originNetConfig.gw = this.sysinfo.gateway.trim()
            this.originNetConfig.dns = this.sysinfo.dns ? this.sysinfo.dns : ""
            // this.alarmConf.min_video_len = rsp.data.min_video_len;
            // this.alarmConf.max_video_len = rsp.data.max_video_len;
            this.fakeObj.min = rsp.data.min_video_len / 1.2
            this.fakeObj.max = rsp.data.max_video_len / 1.2
            if (this.sysinfo.deviceInfo) {
              let devInfo = this.sysinfo.deviceInfo;
              let devInfo = this.sysinfo.deviceInfo
              this.sysinfo.cpuInfo = devInfo.cpu[0].modelName;
              this.sysinfo.disks = "( " + devInfo.disk + ") ";
              this.sysinfo.mem =
                (devInfo.mem.total / 1024 / 1024 / 1024).toFixed(2) + "GB";
              this.sysinfo.cpuInfo = devInfo.cpu[0].modelName
              this.sysinfo.disks = "( " + devInfo.disk + ") "
              this.sysinfo.mem = (devInfo.mem.total / 1024 / 1024 / 1024).toFixed(2) + "GB"
              // this.sysinfo.arch = devInfo.host.kernelArch;
              this.sysinfo.uptime = this.secondsFormat(devInfo.host.uptime);
              this.sysinfo.uptime = this.secondsFormat(devInfo.host.uptime)
            }
            if (!this.sysinfo.server_port) {
              this.sysinfo.server_port = 7003;
              this.sysinfo.server_port = 7003
            }
            this.webPort = this.sysinfo.server_port;
            this.webPort = this.sysinfo.server_port
            this.sysinfo.webVersion = "V" + config.version;
            this.sysinfo.webVersion = "V" + config.version
          }
          this.loading = false;
          this.loading = false
        })
        .catch((err) => {
          this.loading = false;
        });
          this.loading = false
        })
    },
    secondsFormat(s) {
      var day = Math.floor(s / (24 * 3600)); // Math.floor()向下取整
      var hour = Math.floor((s - day * 24 * 3600) / 3600);
      var minute = Math.floor((s - day * 24 * 3600 - hour * 3600) / 60);
      var second = s - day * 24 * 3600 - hour * 3600 - minute * 60;
      return day + "天" + hour + "时" + minute + "分" + second + "秒";
      var day = Math.floor(s / (24 * 3600)) // Math.floor()向下取整
      var hour = Math.floor((s - day * 24 * 3600) / 3600)
      var minute = Math.floor((s - day * 24 * 3600 - hour * 3600) / 60)
      var second = s - day * 24 * 3600 - hour * 3600 - minute * 60
      return day + "天" + hour + "时" + minute + "分" + second + "秒"
    },
    initClockConf(ntpTest = false) {
      getClockInfo().then((rsp) => {
        if (rsp && rsp.success) {
          this.timezone = rsp.data.time_zone;
          this.timezone = rsp.data.time_zone
          if (!ntpTest) {
            this.syncType = rsp.data.ntp ? "1" : "2";
            this.syncType = rsp.data.ntp ? "1" : "2"
          }
          if (rsp.data.ntp) {
            this.ntpServer = rsp.data.ntp_server;
            this.timeInterval = rsp.data.interval;
            this.ntpServer = rsp.data.ntp_server
            this.timeInterval = rsp.data.interval
          }
          this.timestamp = rsp.data.local_time;
          this.timestamp = rsp.data.local_time
          if (this.clockTimer === null) {
            this.runClock();
            this.runClock()
          }
        }
      });
      })
    },
    runClock() {
      this.equipmentTime = this.formatTime(++this.timestamp, "Y-M-D h:m:s");
      this.equipmentTime = this.formatTime(++this.timestamp, "Y-M-D h:m:s")
      this.clockTimer = setTimeout(() => {
        this.runClock();
      }, 1000);
        this.runClock()
      }, 1000)
    },
    initAlarmConf() {
      // getAlarmConfig().then(rsp => {
@@ -657,26 +595,26 @@
    initResourceConfig() {
      getResourceConfig().then((rsp) => {
        if (rsp && rsp.success) {
          this.ipServer.diyOrLocalIP = rsp.data.ipType;
          this.ipServer.ip = rsp.data.serviceIp;
          this.ipServer.localhost = rsp.data.domain;
          this.ipServer.localFilePort = rsp.data.filePort;
          this.ipServer.diyOrLocalIP = rsp.data.ipType
          this.ipServer.ip = rsp.data.serviceIp
          this.ipServer.localhost = rsp.data.domain
          this.ipServer.localFilePort = rsp.data.filePort
        }
      });
      })
    },
    syncBrowser(enable) {
      if (!enable) {
        clearInterval(this.browserTimer);
        clearInterval(this.browserTimer)
      } else {
        this.browserTimer = setInterval(() => {
          let timestamp = new Date().getTime() / 1000;
          this.settime = this.formatTime(timestamp, "Y-M-D h:m:s");
        }, 1000);
          let timestamp = new Date().getTime() / 1000
          this.settime = this.formatTime(timestamp, "Y-M-D h:m:s")
        }, 1000)
      }
    },
    markStartTime() {
      let timestamp = new Date().getTime() / 1000;
      this.settime = this.formatTime(timestamp, "Y-M-D h:m:s");
      let timestamp = new Date().getTime() / 1000
      this.settime = this.formatTime(timestamp, "Y-M-D h:m:s")
    },
    submitSysinfo() {
      this.$refs["sysinfo"].validate((valid) => {
@@ -685,97 +623,77 @@
            this.sysinfo.ip !== this.originNetConfig.ip ||
            this.sysinfo.subMask !== this.originNetConfig.mask ||
            this.sysinfo.dns !== this.originNetConfig.dns ||
            this.sysinfo.gateway !== this.originNetConfig.gw
            this.sysinfo.gateway !== this.originNetConfig.gw ||
            this.sysinfo.server_port !== this.originNetConfig.server_port ||
            this.sysinfo.server_domain !== this.originNetConfig.server_domain
          ) {
            if (this.sysinfo.ip !== this.originNetConfig.ip) {
              let newUri =
                location.protocol +
                "//" +
                this.sysinfo.ip +
                ":" +
                this.sysinfo.server_port;
              let newUri = location.protocol + "//" + this.sysinfo.ip + ":" + this.sysinfo.server_port
              var changeIPTimer = setTimeout(() => {
                this.$alert(
                  '<strong>您已修改了服务器ip, 请重新登录</strong><a target="_parent" href="' +
                  '<strong>您已修改了服务器配置, 请重新登录</strong><a target="_parent" href="' +
                    newUri +
                    '"> ' +
                    newUri +
                    "<a/>",
                  "提示",
                  {
                    dangerouslyUseHTMLString: true,
                    dangerouslyUseHTMLString: true
                  }
                );
              }, 10000);
                )
              }, 10000)
            }
            this.$confirm("确认需要修改服务器网络配置吗?", {
            this.$confirm("确认需要修改服务器配置吗?", {
              center: true,
              cancelButtonClass: "comfirm-class-cancle",
              confirmButtonClass: "comfirm-class-sure",
              confirmButtonClass: "comfirm-class-sure"
            })
              .then(() => {
                this.loading = true;
                this.loadingText = "正在处理...";
                this.loading = true
                this.loadingText = "正在处理..."
                saveDevInfo(this.sysinfo)
                  .then((rsp) => {
                    if (rsp && rsp.success) {
                      this.$notify({
                        type: "success",
                        message: "本机信息保存成功",
                      });
                        message: "服务器配置成功"
                      })
                    }
                    this.initSysinfo();
                    this.loading = false;
                    this.initSysinfo()
                    this.loading = false
                  })
                  .catch((err) => {
                    this.loading = false;
                    clearTimeout(changeIPTimer);
                    this.loading = false
                    clearTimeout(changeIPTimer)
                    this.$notify({
                      type: "error",
                      message: "保存失败",
                    });
                  });
                      message: "保存失败"
                    })
                  })
              })
              .catch((err) => {});
              .catch((err) => {})
          } else {
            saveDevInfo(this.sysinfo).then((rsp) => {
              if (rsp && rsp.success) {
                this.$notify({
                  type: "success",
                  message: "本机信息保存成功",
                });
                this.initSysinfo();
                  message: "本机信息修改成功"
                })
                this.initSysinfo()
              } else {
                this.$notify({
                  type: "error",
                  message: "保存失败"
                })
              }
            });
            if (this.sysinfo.server_port !== this.webPort) {
              let newUri =
                location.protocol +
                "//" +
                this.sysinfo.ip +
                ":" +
                this.sysinfo.server_port;
              var changeIPTimer = setTimeout(() => {
                this.$alert(
                  '<strong>您已修改了服务器端口, 请重新登录</strong><a target="_parent" href="' +
                    newUri +
                    '"> ' +
                    newUri +
                    "<a/>",
                  "提示",
                  {
                    dangerouslyUseHTMLString: true,
                  }
                );
              }, 5000);
            }
            })
          }
        } else {
          console.log("error submit!!");
          return false;
          console.log("error submit!!")
          return false
        }
      });
      })
    },
    checkTimeZone(val) {},
    submitClock() {
@@ -783,19 +701,19 @@
        if (this.ntpServer === "") {
          this.$notify({
            type: "error",
            message: "NTP 服务器地址不能为空",
          });
          return false;
            message: "NTP 服务器地址不能为空"
          })
          return false
        } else if (this.timeInterval === "") {
          this.timeInterval = 1;
          this.timeInterval = 1
        }
      } else {
        if (this.settime === "") {
          this.$notify({
            type: "error",
            message: "设置时间不能为空",
          });
          return false;
            message: "设置时间不能为空"
          })
          return false
        }
      }
      let requestBody = {
@@ -803,56 +721,56 @@
        ntp: this.syncType === "1",
        ntpServer: this.ntpServer,
        interval: this.timeInterval,
        newTime: this.settime,
      };
        newTime: this.settime
      }
      saveClockInfo(requestBody).then((rsp) => {
        if (rsp && rsp.success) {
          this.$notify({
            type: "success",
            message: "设置成功",
          });
            message: "设置成功"
          })
        }
        this.initClockConf();
      });
        this.initClockConf()
      })
    },
    testNTP() {
      this.ntpTestLoading = true;
      this.ntpTestLoading = true
      testNTPserver({ server: this.ntpServer })
        .then((rsp) => {
          if (rsp && rsp.success) {
            this.$notify({
              type: "success",
              message: "时间同步成功",
            });
              message: "时间同步成功"
            })
          } else {
            this.$notify({
              type: "error",
              message: "时间同步失败",
            });
              message: "时间同步失败"
            })
          }
          this.ntpTestLoading = false;
          this.initClockConf(true);
          this.ntpTestLoading = false
          this.initClockConf(true)
        })
        .catch((err) => {
          this.$notify({
            type: "error",
            message: "时间同步失败,请检查服务器ip",
          });
          this.ntpTestLoading = false;
        });
            message: "时间同步失败,请检查服务器ip"
          })
          this.ntpTestLoading = false
        })
    },
    submitAlarm() {
      saveAlarmConfig({
        min_video_len: this.min_video_len,
        max_video_len: this.max_video_len,
        max_video_len: this.max_video_len
      }).then((rsp) => {
        if (rsp && rsp.success) {
          this.$notify({
            type: "success",
            message: "保存成功",
          });
            message: "保存成功"
          })
        }
      });
      })
    },
    // submitResource() {
    //   let regNum = /^[0-9]*$/;
@@ -893,28 +811,28 @@
    //   console.log(e, ip);
    // },
    formatTime(number, format) {
      var formateArr = ["Y", "M", "D", "h", "m", "s"];
      var returnArr = [];
      var formateArr = ["Y", "M", "D", "h", "m", "s"]
      var returnArr = []
      var date = new Date(number * 1000);
      returnArr.push(date.getFullYear());
      returnArr.push(this.formatNumber(date.getMonth() + 1));
      returnArr.push(this.formatNumber(date.getDate()));
      var date = new Date(number * 1000)
      returnArr.push(date.getFullYear())
      returnArr.push(this.formatNumber(date.getMonth() + 1))
      returnArr.push(this.formatNumber(date.getDate()))
      returnArr.push(this.formatNumber(date.getHours()));
      returnArr.push(this.formatNumber(date.getMinutes()));
      returnArr.push(this.formatNumber(date.getSeconds()));
      returnArr.push(this.formatNumber(date.getHours()))
      returnArr.push(this.formatNumber(date.getMinutes()))
      returnArr.push(this.formatNumber(date.getSeconds()))
      for (var i in returnArr) {
        format = format.replace(formateArr[i], returnArr[i]);
        format = format.replace(formateArr[i], returnArr[i])
      }
      return format;
      return format
    },
    //数据转化
    formatNumber(n) {
      n = n.toString();
      return n[1] ? n : "0" + n;
      n = n.toString()
      return n[1] ? n : "0" + n
    },
    menuOpen(event) {},
    menuClose(event) {},
@@ -936,11 +854,11 @@
    // },
    //校验域名
    vaildHost(str) {
      let re = /^(?=^.{3,255}$)(http(s)?:\/\/)?(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/\w+\.\w+)*$/;
      return re.test(str);
    },
  },
};
      let re = /^(?=^.{3,255}$)(http(s)?:\/\/)?(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/\w+\.\w+)*$/
      return re.test(str)
    }
  }
}
</script>
<style lang="scss">
.s-basic-setting {