zhangzengfei
2020-10-14 afe0c52d9bad270751c2874dce37882818d0b721
修复ntp测试设置
1个文件已修改
17 ■■■■ 已修改文件
src/pages/settings/components/BasicSetting.vue 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/settings/components/BasicSetting.vue
@@ -232,6 +232,7 @@
              style="position: absolute; left: 330px;"
              :disabled="syncType === '2'"
              @click="testNTP"
              :loading="ntpTestLoading"
            >测试</el-button>
          </el-form-item>
@@ -469,8 +470,9 @@
        cityOptions: [],
        countyOptions: []
      },
      webPort: 0,
      ntpTestLoading: false
    };
    webPort: 0;
  },
  mounted() {
    this.$nextTick(() => {
@@ -529,11 +531,13 @@
      var second = s - day * 24 * 3600 - hour * 3600 - minute * 60;
      return day + "天" + hour + "时" + minute + "分" + second + "秒";
    },
    initClockConf() {
    initClockConf(ntpTest = false) {
      getClockInfo().then(rsp => {
        if (rsp && rsp.success) {
          this.timezone = rsp.data.time_zone;
          this.syncType = rsp.data.ntp ? "1" : "2";
          if (!ntpTest) {
            this.syncType = rsp.data.ntp ? "1" : "2";
          }
          if (rsp.data.ntp) {
            this.ntpServer = rsp.data.ntp_server;
            this.timeInterval = rsp.data.interval;
@@ -690,9 +694,12 @@
            message: "设置成功"
          });
        }
        this.initClockConf();
      })
    },
    testNTP() {
      this.ntpTestLoading = true;
      testNTPserver({ server: this.ntpServer }).then(rsp => {
        if (rsp && rsp.success) {
          this.$notify({
@@ -705,11 +712,15 @@
            message: "时间同步失败"
          });
        }
        this.ntpTestLoading = false;
        this.initClockConf(true);
      }).catch(err => {
        this.$notify({
          type: "error",
          message: "时间同步失败,请检查服务器ip"
        });
        this.ntpTestLoading = false;
      })
    },
    submitAlarm() {