Browse Source

09-21 14:42 提交

haodingding 1 year ago
parent
commit
35b5a3050d
2 changed files with 63 additions and 30 deletions
  1. 7 0
      src/api/system/device.js
  2. 56 30
      src/views/system/device/index.vue

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

@@ -123,4 +123,11 @@ export function updateFence(data) {
     method: 'put',
     data: data
   })
+}
+export function setDevice(data) {
+  return request({
+    url: '/system/deviceset',
+    method: 'post',
+    data: data
+  })
 }

+ 56 - 30
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"></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">
@@ -741,15 +741,23 @@ export default {
           { required: true, message: '请选择发放方式', trigger: 'change' }
         ],
         name: [
-          {required: true, message: '请选择用户'}
+          { required: true, message: '请选择用户' }
         ],
         deviceId: [
-          {required: true, message: '请输入设备ID', trigger: 'blur'}
+          { required: true, message: '请输入设备ID', trigger: 'blur' }
         ]
       },
       menuInfo: [],
       settingPage: 'sos',
-      clockList: [],
+      clockList: [
+        {
+          clockName: null,
+          time: null,
+          isopen: true,
+          weeks: [],
+          clockId: Date.now()
+        }
+      ],
       silentList: [
         {
           timeRange: ['08:00', '09:00'],
@@ -1176,32 +1184,42 @@ export default {
           }
         })
       } else if (this.clockList.length && this.settingPage == 'clock') {
-        this.clockList.map(item => {
-          if (item.weeks.length) {
-            item.type = 3
-          } else {
-            item.type = 1
-          }
-        })
-        let obj = {}
-        obj.facility_id = this.setUser.fid
-        obj.device_id_code = this.setUser.deviceId
-        obj.command = 'remind'
-        obj.param = this.clockList
-        await axios({
-          method: 'POST',
-          url: 'http://43.138.30.29:4200/index.php/api/shouhuan/createcommand',
-          headers: {
-            Authorization: getToken(),
-          },
-          data: obj,
-        }).then(res => {
-          if (res.data && res.data.code == 200) {
-            this.$modal.msgSuccess('设置成功')
-          } else {
-            this.$modal.msgError('闹钟设置失败')
+        if (this.clockList.length) {
+          let hasValue = 0
+          this.clockList.map(item => {
+            if (item.time) {
+              hasValue += 1
+            }
+            if (item.weeks.length) {
+              item.type = 3
+            } else {
+              item.type = 1
+            }
+          })
+          if (hasValue != this.clockList.length) {
+            this.$modal.msgWarning('时间不能为空')
+            return
           }
-        })
+          let obj = {}
+          obj.facility_id = this.setUser.fid
+          obj.device_id_code = this.setUser.deviceId
+          obj.command = 'remind'
+          obj.param = this.clockList
+          await axios({
+            method: 'POST',
+            url: 'http://43.138.30.29:4200/index.php/api/shouhuan/createcommand',
+            headers: {
+              Authorization: getToken(),
+            },
+            data: obj,
+          }).then(res => {
+            if (res.data && res.data.code == 200) {
+              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 = {}
@@ -1241,7 +1259,15 @@ export default {
       this.onoffForm = {}
       this.wearForm = {}
       this.fallForm = {}
-      this.clockList = []
+      this.clockList = [
+        {
+          clockName: null,
+          time: null,
+          isopen: true,
+          weeks: [],
+          clockId: Date.now()
+        }
+      ]
     },
     handleUploadSuccess(res, file) {
       if (res.code != 200) {