Преглед изворни кода

fix(tenant): auto restart page missing

Casper Dai пре 2 година
родитељ
комит
8a1027dc1d

+ 42 - 50
src/views/realm/settings/components/AutoRestartConfigDialog.vue

@@ -1,37 +1,27 @@
 <template>
   <confirm-dialog
     ref="configDialog"
-    title="三轴传感器阈值设置"
+    title="定时重启设置"
     @confirm="onSave"
   >
     <div class="c-grid-form auto u-align-self--center">
-      <div class="c-grid-form__label">一级预警</div>
-      <el-input-number
-        v-model="config.level1"
-        controls-position="right"
-        :min="0"
-        step-strictly
-      />
-      <div class="c-grid-form__label">二级预警</div>
-      <el-input-number
-        v-model="config.level2"
-        controls-position="right"
-        :min="0"
-        step-strictly
-      />
-      <div class="c-grid-form__label">三级预警</div>
-      <el-input-number
-        v-model="config.level3"
-        controls-position="right"
-        :min="0"
-        step-strictly
-      />
-      <div class="c-grid-form__label">四级预警</div>
-      <el-input-number
-        v-model="config.level4"
-        controls-position="right"
-        :min="0"
-        step-strictly
+      <span class="c-grid-form__label">启用</span>
+      <div class="l-flex--row c-grid-form__option u-width--sm">
+        <el-switch
+          v-model="config.enable"
+          active-color="#13ce66"
+          inactive-color="#ff4949"
+        />
+      </div>
+      <span class="c-grid-form__label u-required">时间</span>
+      <el-time-picker
+        v-model="config.time"
+        class="has-info"
+        data-info="设备会进行0~5分钟内的随机时间延长"
+        placeholder="请选择重启时间"
+        value-format="HH:mm:ss"
+        :disabled="!config.enable"
+        :clearable="false"
       />
     </div>
   </confirm-dialog>
@@ -39,50 +29,52 @@
 
 <script>
 import {
-  DEVIATION,
+  AUTORESTART,
   getTenantAttribute,
   updateTenantAttribute
 } from '../api'
 
 export default {
-  name: 'DeviationConfigDialog',
+  name: 'AutoRestartConfigDialog',
   data () {
     return {
-      config: {
-        level1: 0,
-        level2: 0,
-        level3: 0,
-        level4: 0
-      }
+      config: { enable: false }
     }
   },
   methods: {
     show () {
-      getTenantAttribute(DEVIATION).then(({ data }) => {
+      getTenantAttribute(AUTORESTART).then(({ data }) => {
         if (data) {
-          this.$temp = data.attributeValue
-          this.$temp.split(',').forEach((val, index) => {
-            this.config[`level${index + 1}`] = val
-          })
+          const time = data.attributeValue
+          this.config = {
+            enable: !!time,
+            time: time || ''
+          }
         } else {
-          this.$temp = ''
+          this.config = {
+            enable: false,
+            time: ''
+          }
         }
+        this.$temp = this.config.time
         this.$refs.configDialog.show()
       })
     },
     onSave (done) {
-      const val = [
-        this.config.level1,
-        this.config.level2,
-        this.config.level3,
-        this.config.level4
-      ].join(',')
-
+      const { enable, time } = this.config
+      if (enable && !time) {
+        this.$message({
+          type: 'warning',
+          message: '请选择重启时间'
+        })
+        return
+      }
+      const val = enable ? time : ''
       if (this.$temp === val) {
         done()
         return
       }
-      updateTenantAttribute(DEVIATION, val).then(done)
+      updateTenantAttribute(AUTORESTART, val).then(done)
     }
   }
 }

+ 6 - 6
src/views/realm/settings/components/DeviationThresholdConfigDialog.vue

@@ -7,37 +7,37 @@
     <div class="c-grid-form auto u-align-self--center">
       <div class="c-grid-form__label">X轴初始值</div>
       <el-input-number
-        v-model.trim="config.val1"
+        v-model="config.val1"
         controls-position="right"
         :step-strictly="0.01"
       />
       <div class="c-grid-form__label">X轴阈值</div>
       <el-input-number
-        v-model.trim="config.val2"
+        v-model="config.val2"
         controls-position="right"
         :step-strictly="0.01"
       />
       <div class="c-grid-form__label">Y轴初始值</div>
       <el-input-number
-        v-model.trim="config.val3"
+        v-model="config.val3"
         controls-position="right"
         :step-strictly="0.01"
       />
       <div class="c-grid-form__label">Y轴阈值</div>
       <el-input-number
-        v-model.trim="config.val4"
+        v-model="config.val4"
         controls-position="right"
         :step-strictly="0.01"
       />
       <div class="c-grid-form__label">Z轴初始值</div>
       <el-input-number
-        v-model.trim="config.val5"
+        v-model="config.val5"
         controls-position="right"
         :step-strictly="0.01"
       />
       <div class="c-grid-form__label">Z轴阈值</div>
       <el-input-number
-        v-model.trim="config.val6"
+        v-model="config.val6"
         controls-position="right"
         :step-strictly="0.01"
       />