Ver Fonte

09-21 17:22 增加设备设置回显

haodingding há 1 ano atrás
pai
commit
2f3d29bb51
2 ficheiros alterados com 145 adições e 43 exclusões
  1. 28 0
      src/api/system/device.js
  2. 117 43
      src/views/system/device/index.vue

+ 28 - 0
src/api/system/device.js

@@ -130,4 +130,32 @@ export function setDevice(data) {
     method: 'post',
     data: data
   })
+}
+export function getDeviceSetting(data) {
+  return request({
+    url: '/system/deviceset/list',
+    method: 'get',
+    params: data
+  })
+}
+export function addClock(data) {
+  return request({
+    url: '/system/deviceclock/clockAdd',
+    method: 'post',
+    data: data
+  })
+}
+export function getClock(data) {
+  return request({
+    url: '/system/deviceclock/list',
+    method: 'get',
+    params: data
+  })
+}
+export function deleteClock(data) {
+  return request({
+    url: '/system/deviceclock/list',
+    method: 'delete',
+    params: data
+  })
 }

+ 117 - 43
src/views/system/device/index.vue

@@ -305,7 +305,7 @@
           </el-form>
           <el-form v-if="settingPage == 'stepCount'" label-width="180px" :model="pedoForm">
             <el-form-item label="计步器状态">
-              <el-switch v-model="pedoForm.isopen" active-value="1" inactive-value="0"></el-switch>
+              <el-switch v-model="pedoForm.isopen" :active-value="1" :inactive-value="0"></el-switch>
             </el-form-item>
           </el-form>
           <el-form v-if="settingPage == 'contacts'" label-width="100px" :model="telForm">
@@ -346,7 +346,7 @@
                 <el-input class="clock-input" v-model="item.clockName"></el-input>
                 <el-time-picker :editable="false" value-format="HH:mm" placeholder="请选择时间"
                   v-model="item.time"></el-time-picker>
-                <el-switch class="clock-switch" v-model="item.isopen"></el-switch>
+                <el-switch class="clock-switch" v-model="item.isopen" active-value="1" inactive-value="0"></el-switch>
                 <el-button type="danger" icon="el-icon-delete" circle @click="deleteClock(item.clockId)"></el-button>
               </el-form-item>
               <el-form-item label="日期">
@@ -368,7 +368,7 @@
           </el-form>
           <el-form v-if="settingPage == 'timeOnOff'" label-width="80px" :model="onoffForm">
             <el-form-item label="是否使用">
-              <el-switch v-model="onoffForm.is_open"></el-switch>
+              <el-switch v-model="onoffForm.is_open" :active-value="1" :inactive-value="0"></el-switch>
             </el-form-item>
             <el-form-item label="开机时间">
               <el-time-picker :editable="false" v-model="onoffForm.bootup_time" value-format="HH:mm">
@@ -381,17 +381,17 @@
           </el-form>
           <el-form v-if="settingPage == 'wearNotice'" label-width="120px" :model="wearForm">
             <el-form-item label="佩戴提醒状态">
-              <el-switch v-model="wearForm.is_open"></el-switch>
+              <el-switch v-model="wearForm.is_open" :active-value="1" :inactive-value="0"></el-switch>
             </el-form-item>
           </el-form>
           <el-form v-if="settingPage == 'fallNotice'" label-width="120px" :model="fallForm">
             <el-form-item label="跌倒提醒状态">
-              <el-switch v-model="fallForm.is_open"></el-switch>
+              <el-switch v-model="fallForm.is_open" :active-value="1" :inactive-value="0"></el-switch>
             </el-form-item>
             <el-form-item label="跌倒灵敏度">
               <el-radio-group v-model="fallForm.lsset_type">
-                <el-radio v-for="i in sensitivityList" :key="i.dictValue" :value="i.dictValue"
-                  :label="i.dictLabel"></el-radio>
+                <el-radio v-for="i in sensitivityList" :key="i.dictValue" :label="i.dictValue"
+                  >{{ i.dictLabel }}</el-radio>
               </el-radio-group>
             </el-form-item>
           </el-form>
@@ -668,7 +668,11 @@ import {
   getFenceList,
   deleteFence,
   updateFence,
-  setDevice
+  setDevice,
+  getDeviceSetting,
+  addClock,
+  getClock,
+  deleteClock
 }
   from "@/api/system/device";
 import { listProfile, getProfile } from "@/api/system/profile";
@@ -749,15 +753,7 @@ export default {
       },
       menuInfo: [],
       settingPage: 'sos',
-      clockList: [
-        {
-          clockName: null,
-          time: null,
-          isopen: true,
-          weeks: [],
-          clockId: Date.now()
-        }
-      ],
+      clockList: [],
       silentList: [
         {
           timeRange: ['08:00', '09:00'],
@@ -866,6 +862,9 @@ export default {
       this.clockDate = res.data
     })
     this.getDicts('sys_fall_sensitivity').then(res => {
+      res.data.map(item => {
+        item.dictValue = Number(item.dictValue)
+      })
       this.sensitivityList = res.data
     })
     this.getDicts('sys_device_attribute').then(res => {
@@ -991,6 +990,47 @@ export default {
     },
     selectSetting(e) {
       this.settingPage = e
+      if (e == 'clock') {
+        let data = {
+          deviceIdCode: this.setUser.deviceId
+        }
+        getClock(data).then(res => {
+          if (res.rows.length) {
+            let info = res.rows[0]
+            if (info.length == 0) {
+              if (this.clockList.length == 0) {
+                this.clockList.push({
+                  clockName: null,
+                  time: null,
+                  isopen: '1',
+                  weeks: [],
+                  clockId: Date.now()
+                })
+              }
+            } else {
+              info.map(i => {
+                let item = {}
+                item.clockName = i.alarmClock
+                item.isopen = i.clockUse
+                item.time = i.clockTime
+                item.weeks = i.clockWeek.split(',')
+                item.clockId = i.id
+                this.clockList.push(item)
+              })
+            }
+          } else {
+            if (this.clockList.length == 0) {
+              this.clockList.push({
+                clockName: null,
+                time: null,
+                isopen: '1',
+                weeks: [],
+                clockId: Date.now()
+              })
+            }
+          }
+        })
+      }
     },
     async setDeviceInfo() {
       if (Object.keys(this.sosForm).length && this.settingPage == 'sos') {
@@ -1054,7 +1094,7 @@ export default {
           }
         })
       } else if (Object.keys(this.pedoForm).length && this.settingPage == 'stepCount') {
-        let is_open = this.pedoForm.isopen ? 1 : 0
+        let is_open = this.pedoForm.isopen
         let obj = {}
         obj.facility_id = this.setUser.fid
         obj.device_id_code = this.setUser.deviceId
@@ -1109,18 +1149,18 @@ export default {
               deviceIdCode: this.setUser.deviceId
             }
             if (this.telForm.tel1 && this.telForm.name1) {
-              data.contactPer1 = this.telForm.tel1
-              data.contactTel1 = this.this.telForm.name1
+              data.contactPer1 = this.telForm.name1
+              data.contactTel1 = this.telForm.tel1
             }
             if (this.telForm.tel2 && this.telForm.name2) {
-              data.contactPer2 = this.telForm.tel2
-              data.contactTel2 = this.this.telForm.name2
+              data.contactPer2 = this.telForm.name2
+              data.contactTel2 = this.telForm.tel2
             }
             if (this.telForm.tel3 && this.telForm.name3) {
-              data.contactPer3 = this.telForm.tel3
-              data.contactTel3 = this.this.telForm.name3
+              data.contactPer3 = this.telForm.name3
+              data.contactTel3 = this.telForm.tel3
             }
-            this.setDevice(data).then(res1 => {
+            setDevice(data).then(res1 => {
               this.$modal.msgSuccess('设置成功')
             })
           } else {
@@ -1128,7 +1168,6 @@ export default {
           }
         })
       } else if (Object.keys(this.onoffForm).length && this.settingPage == 'timeOnOff') {
-        this.onoffForm.is_open = this.onoffForm.is_open ? 1 : 0
         let obj = {}
         obj.facility_id = this.setUser.fid
         obj.device_id_code = this.setUser.deviceId
@@ -1157,7 +1196,6 @@ export default {
           }
         })
       } else if (Object.keys(this.wearForm).length && this.settingPage == 'wearNotice') {
-        this.wearForm.is_open = this.wearForm.is_open ? 1 : 0
         let obj = {}
         obj.facility_id = this.setUser.fid
         obj.device_id_code = this.setUser.deviceId
@@ -1214,14 +1252,26 @@ export default {
             data: obj,
           }).then(res => {
             if (res.data && res.data.code == 200) {
-              this.$modal.msgSuccess('设置成功')
+              let clockArr = []
+              this.clockList.map(i => {
+                let data = {
+                  deviceIdCode: this.setUser.deviceId,
+                  alarmClock: i.clockName,
+                  clockTime: i.time,
+                  clockUse: i.isopen,
+                  clockWeek: i.weeks.join(',')
+                }
+                clockArr.push(data)
+              })
+              addClock(clockArr).then(res1 => {
+                this.$modal.msgSuccess('设置成功')
+              })
             } else {
               this.$modal.msgError('闹钟设置失败')
             }
           })
         }
       } else if (Object.keys(this.fallForm).length && this.settingPage == 'fallNotice') {
-        this.fallForm.is_open = this.onoffForm.is_open ? 1 : 0
         let obj = {}
         obj.facility_id = this.setUser.fid
         obj.device_id_code = this.setUser.deviceId
@@ -1236,6 +1286,7 @@ export default {
           data: obj,
         }).then(res => {
           if (res.data && res.data.code == 200) {
+            console.log(this.fallForm.lsset_type);
             let data = {
               deviceIdCode: this.setUser.deviceId,
               fallStatus: this.fallForm.is_open,
@@ -1259,15 +1310,7 @@ export default {
       this.onoffForm = {}
       this.wearForm = {}
       this.fallForm = {}
-      this.clockList = [
-        {
-          clockName: null,
-          time: null,
-          isopen: true,
-          weeks: [],
-          clockId: Date.now()
-        }
-      ]
+      this.clockList = []
     },
     handleUploadSuccess(res, file) {
       if (res.code != 200) {
@@ -1673,11 +1716,11 @@ export default {
       if (this.fenceList.length < 3) {
         this.fenceEdit = true
         this.add_flag = true
-        this.fenceInfo.name = null
-        this.fenceInfo.start_time = null
-        this.fenceInfo.end_time = null
-        this.fenceInfo.type = null
-        this.fenceInfo.state = null
+        delete this.fenceInfo.name
+        delete this.fenceInfo.start_time
+        delete this.fenceInfo.end_time
+        delete this.fenceInfo.type
+        delete this.fenceInfo.state
         if (this.fence) {
           this.map.remove(this.fence)
           this.fence = null
@@ -1988,6 +2031,11 @@ export default {
       this.clockList.map((item, index) => {
         if (item.clockId == e) {
           this.clockList.splice(index, 1)
+          if (typeof e == 'string') {
+            deleteClock({ id: e }).then(res => {
+              this.$modal.msgSuccess('删除成功')
+            })
+          }
         }
       })
     },
@@ -2005,6 +2053,32 @@ export default {
         this.getDeviceLog()
       } else if (e == 'settingOpen') {
         this.setUser = row
+        let data = {
+          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)
+        })
       } else if (e == 'healthInterval') {
         this.setUser = row
       }