Ver Fonte

09-22 09:33 提交

haodingding há 1 ano atrás
pai
commit
fd6d9cc270
1 ficheiros alterados com 109 adições e 36 exclusões
  1. 109 36
      src/views/system/device/index.vue

+ 109 - 36
src/views/system/device/index.vue

@@ -254,7 +254,7 @@
         <el-button type="primary" style="width: 120px;margin: 0 30px" @click='checkUserConfirm'>确定</el-button>
       </el-row>
     </el-dialog>
-    <el-dialog title="设备设置" :visible.sync="settingOpen" width="1000px" append-to-body>
+    <el-dialog title="设备设置" :visible.sync="settingOpen" width="1000px" append-to-body :before-close="closeSetting">
       <el-row :gutter="20" class="top">
         <el-col :span="5">设备ID:{{ setUser.deviceId }}</el-col>
         <el-col :span="5">{{ setUser.name }}</el-col>
@@ -409,7 +409,7 @@
         <el-button type="primary" style="width: 120px;" @click="setDeviceInfo">保存</el-button>
       </el-row>
     </el-dialog>
-    <el-dialog title="健康阈值设置" :visible.sync="healthInterval" width="1000px" append-to-body>
+    <el-dialog title="健康阈值设置" :visible.sync="healthInterval" width="1000px" append-to-body :before-close="closeHealth">
       <el-form label-width="100px" :data="deviceInterval">
         <el-row>
           <el-col :span="12">
@@ -574,9 +574,9 @@
           <el-select size="mini" v-model="fenceName" @change="selectFence">
             <el-option v-for="item in fenceList" :key="item.name" :label="item.name" :value="item.name"></el-option>
           </el-select>
-          <el-button size="mini" type="primary" style="margin-left: 10px;" @click="editAdd">新增</el-button>
-          <el-button size="mini" type="warning" @click="editUpdate">修改</el-button>
-          <el-button size="mini" type="danger" @click="editDelete">删除</el-button>
+          <el-button size="mini" type="primary" style="margin-left: 10px;" v-hasPermi="['system:device:add']" @click="editAdd">新增</el-button>
+          <el-button size="mini" type="warning" @click="editUpdate" v-hasPermi="['system:device:edit']">修改</el-button>
+          <el-button size="mini" type="danger" @click="editDelete" v-hasPermi="['system:device:remove']">删除</el-button>
         </el-row>
         <el-form class="update-tool" :model="fenceInfo" label-width="70px" size="mini" v-show="fenceEdit">
           <el-form-item label="围栏名称">
@@ -988,6 +988,21 @@ export default {
         shouhuan_body_min: null
       }
     },
+    closeHealth(done) {
+      this.closeInterval()
+      done()
+    },
+    closeSetting(done) {
+      this.sosForm = {}
+      this.intervalForm = {}
+      this.pedoForm = {}
+      this.telForm = {}
+      this.clockForm = {}
+      this.onoffForm = {}
+      this.wearForm = {}
+      this.fallForm = {}
+      done()
+    },
     selectSetting(e) {
       this.settingPage = e
       if (e == 'clock') {
@@ -1032,11 +1047,27 @@ export default {
         })
       }
     },
+
+    isEmpty(object){
+      var isEmpty = true;
+      if (Object.keys(object).length) {
+        Object.keys(object).forEach(function(x) {
+          if(object[x] != null && object[x] != ""){
+            isEmpty = false;
+          }
+      });
+      }
+      return isEmpty;
+    },
     async setDeviceInfo() {
-      if (Object.keys(this.sosForm).length && this.settingPage == 'sos') {
-        let arr = []
-        arr.push(this.sosForm.tel1)
-        arr.push(this.sosForm.tel2)
+      if (!this.isEmpty(this.sosForm) && this.settingPage == 'sos') {
+          let arr = []
+        if (this.sosForm.tel1) {
+          arr.push(this.sosForm.tel1)
+        }
+        if (this.sosForm.tel2) {
+          arr.push(this.sosForm.tel2)
+        }
         let obj = {}
         obj.facility_id = this.setUser.fid
         obj.device_id_code = this.setUser.deviceId
@@ -1063,7 +1094,7 @@ export default {
             this.$modal.msgError('SOS设置失败')
           }
         })
-      } else if (Object.keys(this.intervalForm).length && this.settingPage == 'measureInterval') {
+      } else if (!this.isEmpty(this.intervalForm) && this.settingPage == 'measureInterval') {
         let obj = {}
         obj.facility_id = this.setUser.fid
         obj.device_id_code = this.setUser.deviceId
@@ -1093,7 +1124,7 @@ export default {
             this.$modal.msgError('测量间隔设置失败')
           }
         })
-      } else if (Object.keys(this.pedoForm).length && this.settingPage == 'stepCount') {
+      } else if (!this.isEmpty(this.pedoForm) && this.settingPage == 'stepCount') {
         let is_open = this.pedoForm.isopen
         let obj = {}
         obj.facility_id = this.setUser.fid
@@ -1120,7 +1151,7 @@ export default {
             this.$modal.msgError('计步设置失败')
           }
         })
-      } else if (Object.keys(this.telForm).length && this.settingPage == 'contacts') {
+      } else if (!this.isEmpty(this.telForm) && this.settingPage == 'contacts') {
         let arr = []
         if (this.telForm.tel1 && this.telForm.name1) {
           arr.push({ telno: this.telForm.tel1, name: this.telForm.name1 })
@@ -1167,7 +1198,7 @@ export default {
             this.$modal.msgError('通讯录设置失败')
           }
         })
-      } else if (Object.keys(this.onoffForm).length && this.settingPage == 'timeOnOff') {
+      } else if (!this.isEmpty(this.onoffForm) && this.settingPage == 'timeOnOff') {
         let obj = {}
         obj.facility_id = this.setUser.fid
         obj.device_id_code = this.setUser.deviceId
@@ -1195,7 +1226,7 @@ export default {
             this.$modal.msgError('定时开关机设置失败')
           }
         })
-      } else if (Object.keys(this.wearForm).length && this.settingPage == 'wearNotice') {
+      } else if (!this.isEmpty(this.wearForm) && this.settingPage == 'wearNotice') {
         let obj = {}
         obj.facility_id = this.setUser.fid
         obj.device_id_code = this.setUser.deviceId
@@ -1271,7 +1302,7 @@ export default {
             }
           })
         }
-      } else if (Object.keys(this.fallForm).length && this.settingPage == 'fallNotice') {
+      } else if (!this.isEmpty(this.fallForm) && this.settingPage == 'fallNotice') {
         let obj = {}
         obj.facility_id = this.setUser.fid
         obj.device_id_code = this.setUser.deviceId
@@ -2057,27 +2088,69 @@ export default {
           deviceIdCode: row.deviceId
         }
         getDeviceSetting(data).then(res => {
-          let info = res.rows[0]
-          this.$set(this.sosForm, 'tel1', info.sostelno1)
-          this.$set(this.sosForm, 'tel2', info.sostelno2)
-          this.$set(this.intervalForm, 'cr_interval', info.gpsInterval)
-          this.$set(this.intervalForm, 'hrt_interval', info.heartInterval)
-          this.$set(this.intervalForm, 'wd_interval', info.bodyInterval)
-          this.$set(this.intervalForm, 'bld_interval', info.bloodInterval)
-          this.$set(this.intervalForm, 'ox_interval', info.oxygenInterval)
-          this.$set(this.pedoForm, 'isopen', info.stepStatus)
-          this.$set(this.telForm, 'name1', info.contactPer1)
-          this.$set(this.telForm, 'tel1', info.contactTel1)
-          this.$set(this.telForm, 'name2', info.contactPer2)
-          this.$set(this.telForm, 'tel2', info.contactTel2)
-          this.$set(this.telForm, 'name3', info.contactPer3)
-          this.$set(this.telForm, 'tel3', info.contactTel3)
-          this.$set(this.onoffForm, 'is_open', info.timeStatus)
-          this.$set(this.onoffForm, 'bootup_time', info.timeBegin)
-          this.$set(this.onoffForm, 'shutdown_time', info.timeEnd)
-          this.$set(this.wearForm, 'is_open', info.useStatus)
-          this.$set(this.fallForm, 'is_open', info.fallStatus)
-          this.$set(this.fallForm, 'lsset_type', info.levelStatus)
+          if (res.rows.length) {
+            let info = res.rows[0]
+          if (info.sostelno1) {
+            this.$set(this.sosForm, 'tel1', info.sostelno1)
+          }
+          if (info.sostelno2) {
+            this.$set(this.sosForm, 'tel2', info.sostelno2)
+          }
+          if (info.gpsInterval) {
+            this.$set(this.intervalForm, 'cr_interval', info.gpsInterval)
+          }
+          if (info.heartInterval) {
+            this.$set(this.intervalForm, 'hrt_interval', info.heartInterval)
+          }
+          if (info.bodyInterval) {
+            this.$set(this.intervalForm, 'wd_interval', info.bodyInterval)
+          }
+          if (info.bloodInterval) {
+            this.$set(this.intervalForm, 'bld_interval', info.bloodInterval)
+          }
+          if (info.oxygenInterval) {
+            this.$set(this.intervalForm, 'ox_interval', info.oxygenInterval)
+          }
+          if (info.stepStatus) {
+            this.$set(this.pedoForm, 'isopen', info.stepStatus)
+          }
+          if (info.contactPer1) {
+            this.$set(this.telForm, 'name1', info.contactPer1)
+          }
+          if (info.contactTel1) {
+            this.$set(this.telForm, 'tel1', info.contactTel1)
+          }
+          if (info.contactPer2) {
+            this.$set(this.telForm, 'name2', info.contactPer2)
+          }
+          if (info.contactTel2) {
+            this.$set(this.telForm, 'tel2', info.contactTel2)
+          }
+          if (info.contactPer3) {
+            this.$set(this.telForm, 'name3', info.contactPer3)
+          }
+          if (info.contactTel3) {
+            this.$set(this.telForm, 'tel3', info.contactTel3)
+          }
+          if (info.timeStatus) {
+            this.$set(this.onoffForm, 'is_open', info.timeStatus)
+          }
+          if (info.timeBegin) {
+            this.$set(this.onoffForm, 'bootup_time', info.timeBegin)
+          }
+          if (info.timeEnd) {
+            this.$set(this.onoffForm, 'shutdown_time', info.timeEnd)
+          }
+          if (info.useStatus) {
+            this.$set(this.wearForm, 'is_open', info.useStatus)
+          }
+          if (info.fallStatus) {
+            this.$set(this.fallForm, 'is_open', info.fallStatus)
+          }
+          if (info.levelStatus) {
+            this.$set(this.fallForm, 'lsset_type', info.levelStatus)
+          }
+          }
         })
       } else if (e == 'healthInterval') {
         this.setUser = row