vothin 3 лет назад
Родитель
Сommit
2240050dfd

+ 38 - 0
src/api/ncs_sos_device_settings.js

@@ -0,0 +1,38 @@
+import request from '@/utils/request'
+
+/** 新增设备报警 */
+export function add(params) {
+  return request({
+    url: '/ncs/sos_device_settings',
+    method: 'POST',
+    loading: true,
+    data: params
+  })
+}
+
+/** 删除设备报警 */
+export function deleteByDeviceId(id) {
+  return request({
+    url: `/ncs/sos_device_settings/delete_by_device_id/${id}`,
+    method: 'DELETE',
+    loading: true
+  })
+}
+
+/** 更新设备报警 */
+export function updateByDeviceId(id, params) {
+  return request({
+    url: `/ncs/sos_device_settings/update_by_device_id/${id}`,
+    method: 'put',
+    data: params
+  })
+}
+
+/** 查询某个设备的报警时间 */
+export function getSosDeviceSetting(deviceId) {
+  return request({
+    url: `/ncs/sos_device_settings/get_sos_device_setting/${deviceId}`,
+    method: 'get',
+    loading: false
+  })
+}

+ 95 - 12
src/views/hospital/ncs_device/deviceManager.vue

@@ -184,6 +184,29 @@
             </el-form-item>
           </el-col>
         </el-row>
+        <el-row v-if="hasSosDeviceSettings">
+          <el-col :span="12">
+            <el-form-item label="报警设备模式" prop="type">
+              <el-select v-model="sosDeviceSetting.type" placeholder="报警设备模式" clearable>
+                <el-option v-for="item in sosDeviceSettingsTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row v-if="hasSosDeviceSettings">
+          <el-col :span="12">
+            <el-form-item label="报警时间" prop="setting_time">
+              <el-input-number v-model="sosDeviceSetting.setting_time" controls-position="right" :min="0" :max="60" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-radio-group label="报警时间单位" v-model="sosDeviceSetting.unit" size="mini" prop="unit">
+              <el-radio label="小时">小时</el-radio>
+              <el-radio label="分钟">分钟</el-radio>
+              <el-radio label="秒">秒</el-radio>
+            </el-radio-group>
+          </el-col>
+        </el-row>
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="handlerFormSubmit('deviceEditForm')">确 定</el-button>
@@ -205,6 +228,7 @@ import { DEVICE_TYPE } from '@/utils/enum/DeviceTypeEnum'
 import * as API_Frame from '@/api/ncs_hospitalFrame'
 import { FRAME_TYPE } from '@/utils/enum/FrameTypeEnum'
 import * as shop_API from '@/api/ncs_shop'
+import * as API_SosDeviceSetting from "@/api/ncs_sos_device_settings";
 export default {
   name: 'DeviceManager',
   components: { ButtonCellRender, ListFilter, RadioFilter },
@@ -319,7 +343,20 @@ export default {
       audioOptions: [],
       rs485Options: [],
       hasAudioId: false,
-      hasAdd: true
+      hasSosDeviceSettings: false,
+      sosDeviceSetting: {},
+      sosDeviceSettingsTypeOptions: [
+        {
+          value: 0,
+          label: '不开启'
+        }, {
+          value: 1,
+          label: '疫情防控模式'
+        }, {
+          value: 2,
+          label: '关爱老人模式'
+        }
+      ]
     }
   },
   computed: {
@@ -572,6 +609,12 @@ export default {
             message: response.message
           })
         })
+        if (this.hasSosDeviceSettings) {
+          API_SosDeviceSetting.deleteByDeviceId(id).then(() => {
+            this.hasSosDeviceSettings = false
+            this.getList()
+          })
+        }
       }).catch(() => {
         this.$message({
           type: 'info',
@@ -605,6 +648,8 @@ export default {
           val === DEVICE_TYPE.RS485_DOOR ||
           val === DEVICE_TYPE.SIMULATE_EMERGENCY_BUTTON ||
           val === DEVICE_TYPE.SIMULATE_DOOR_LIGHT
+      this.hasSosDeviceSettings = val === DEVICE_TYPE.ALARM_BODY_INDUCTIVE ||
+          val === DEVICE_TYPE.DOOR_LOCK
     },
     /** 设备类型选中对应的空间结构  **/
     deviceTypeChangeToFrameTypeChange(val) {
@@ -616,31 +661,24 @@ export default {
           val === DEVICE_TYPE.WORKER_WATCH ||
           val === DEVICE_TYPE.TRANSFER_DEVICE ||
           val === DEVICE_TYPE.INFORMATION_BOARD ||
-          val === DEVICE_TYPE.RS485_TRANSFER ||
-          val === DEVICE_TYPE.DOOR_LOCK
+          val === DEVICE_TYPE.RS485_TRANSFER
       ) {
         this.getFramesByType(FRAME_TYPE.PART)
       } else if (val === DEVICE_TYPE.DOOR_DEVICE ||
           val === DEVICE_TYPE.SIMULATE_EMERGENCY_BUTTON ||
           val === DEVICE_TYPE.RS485_DOOR ||
           val === DEVICE_TYPE.SIMULATE_DOOR_LIGHT ||
-          val === DEVICE_TYPE.BEACON ||
-          val === DEVICE_TYPE.DOOR_LOCK
+          val === DEVICE_TYPE.BEACON
       ) {
         this.getFramesByType(FRAME_TYPE.ROOM)
       } else if (val === DEVICE_TYPE.DIGIT_BED_DEVICE ||
           val === DEVICE_TYPE.SIMULATE_BED_DEVICE ||
           val === DEVICE_TYPE.REMOTE_CONTROL ||
-          val === DEVICE_TYPE.CELL_PHONE ||
-          val === DEVICE_TYPE.ALARM_BODY_INDUCTIVE ||
-          val === DEVICE_TYPE.ALARM_WATER_OVERFLOW ||
-          val === DEVICE_TYPE.ALARM_HOUSEHOLD_GAS ||
-          val === DEVICE_TYPE.ALARM_HOUSEHOLD_SMOKE ||
-          val === DEVICE_TYPE.ALARM_BUTTON_SOS ||
-          val === DEVICE_TYPE.DOOR_LOCK
+          val === DEVICE_TYPE.CELL_PHONE
       ) {
         this.getFramesByType(FRAME_TYPE.BED)
       } else {
+        this.getTypeFrame(this.$store.getters.partId)
         this.typeFrames = this.partFrames
       }
     },
@@ -653,6 +691,11 @@ export default {
         code: 'C' + parseInt(Math.random() * 100000),
         model: 'M' + parseInt(Math.random() * 100000)
       }
+      this.sosDeviceSetting = {
+        type: 0,
+        unit: '小时',
+        setting_time: 0,
+      }
       if (Object.keys(this.frame).length > 0) {
         this.$set(this.deviceModel, 'frame_id', this.frame.id)
       }
@@ -660,6 +703,7 @@ export default {
       this.hasRoleId = false
       this.getRoles({ page_size: 200, page_no: 1, fixedCondition: ' shop_id = -1', sort: ' role_id', dir: 'desc' })
       this.hasAudioId = false
+      this.hasSosDeviceSettings = false
       this.getDevices(this.$store.getters.partId)
       this.deviceEditTitle = '添加设备'
       this.deviceDialogVisible = true
@@ -671,12 +715,15 @@ export default {
     handleEdit(params) {
       this.getRoles({ page_size: 200, page_no: 1, fixedCondition: ' shop_id = -1', sort: ' role_id', dir: 'desc' })
       this.getDevices(this.$store.getters.partId)
+      this.getSosDeviceSetting(params.id)
       this.deviceTypeChangeToFrameTypeChange(params.device_type)
       this.hasRoleId = params.device_type === DEVICE_TYPE.NURSE_WATCH
       this.hasAudioId = params.device_type === DEVICE_TYPE.SIMULATE_BED_DEVICE ||
           params.device_type === DEVICE_TYPE.RS485_DOOR ||
           params.device_type === DEVICE_TYPE.SIMULATE_EMERGENCY_BUTTON ||
           params.device_type === DEVICE_TYPE.SIMULATE_DOOR_LIGHT
+      this.hasSosDeviceSettings = params.device_type === DEVICE_TYPE.ALARM_BODY_INDUCTIVE ||
+          params.device_type === DEVICE_TYPE.DOOR_LOCK
       this.deviceModel = {
         ...params
       }
@@ -688,12 +735,24 @@ export default {
     handlerFormSubmit(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
+          const _this = this;
           /** 新增 */
           if (!this.deviceModel.id) {
             this.deviceModel.part_id = this.frame.part_id
             this.deviceModel.frame_id = this.frame.id
             API_Device.add(this.deviceModel).then(() => {
               this.$message.success('保存成功!')
+              _this.device = r
+              this.sosDeviceSetting.device_id = _this.device.id
+              this.sosDeviceSetting.part_id = _this.device.part_id
+
+              if (this.hasSosDeviceSettings) {
+                API_SosDeviceSetting.add(this.sosDeviceSetting).then(() => {
+                  this.$message.success('保存成功!')
+                  this.hasSosDeviceSettings = false
+                })
+              }
+
               this.deviceDialogVisible = false
               this.getList()
             })
@@ -704,6 +763,25 @@ export default {
               this.deviceDialogVisible = false
               this.getList()
             })
+
+            if (this.hasSosDeviceSettings) {
+              this.sosDeviceSetting.device_id = this.deviceModel.id
+              API_SosDeviceSetting.updateByDeviceId(this.deviceModel.id, this.sosDeviceSetting).then(() => {
+                this.$message.success('保存成功!')
+
+                if (this.hasSosDeviceSettings) {
+                  this.sosDeviceSetting.device_id = this.deviceModel.id
+                  this.sosDeviceSetting.part_id = this.deviceModel.part_id
+                  API_SosDeviceSetting.updateByDeviceId(this.deviceModel.id, this.sosDeviceSetting).then(() => {
+                    this.$message.success('保存成功!')
+                    this.hasSosDeviceSettings = false
+                  })
+                }
+
+                this.hasSosDeviceSettings = false
+                this.getList()
+              })
+            }
           }
         }
       })
@@ -734,6 +812,11 @@ export default {
         this.rs485Options = response
       })
     },
+    getSosDeviceSetting(deviceId) {
+      API_SosDeviceSetting.getSosDeviceSetting(deviceId).then(r => {
+        this.sosDeviceSetting = r;
+      })
+    },
     getShopOptions(part_id) {
       shop_API.getShopList(part_id).then(res => {
         this.shopOptions = res

+ 96 - 4
src/views/ncs-device/components/deviceManager.vue

@@ -181,6 +181,29 @@
             </el-form-item>
           </el-col>
         </el-row>
+        <el-row v-if="hasSosDeviceSettings">
+          <el-col :span="12">
+            <el-form-item label="报警设备模式" prop="type">
+              <el-select v-model="sosDeviceSetting.type" placeholder="报警设备模式" clearable>
+                <el-option v-for="item in sosDeviceSettingsTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row v-if="hasSosDeviceSettings">
+          <el-col :span="12">
+            <el-form-item label="报警时间" prop="setting_time">
+              <el-input-number v-model="sosDeviceSetting.setting_time" controls-position="right" :min="0" :max="60" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-radio-group label="报警时间单位" v-model="sosDeviceSetting.unit" size="mini" prop="unit">
+              <el-radio label="小时">小时</el-radio>
+              <el-radio label="分钟">分钟</el-radio>
+              <el-radio label="秒">秒</el-radio>
+            </el-radio-group>
+          </el-col>
+        </el-row>
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="handlerFormSubmit('deviceEditForm')">确 定</el-button>
@@ -198,6 +221,7 @@ import ListFilter from '@/components/AgGridCustomFilter/ListFilter'
 import RadioFilter from '@/components/AgGridCustomFilter/RadioFilter'
 import * as API_Device from '@/api/ncs_device'
 import * as API_Frame from '@/api/ncs_hospitalFrame'
+import * as API_SosDeviceSetting from '@/api/ncs_sos_device_settings'
 import * as clerk_API from '@/api/ncs_clerk'
 import { DeviceUrl } from '@/utils/domain'
 import { FRAME_TYPE } from '@/utils/enum/FrameTypeEnum'
@@ -278,6 +302,15 @@ export default {
         // sip_id: [
         //   { required: true, message: '请输入485地址', trigger: 'blur' }
         // ]
+        // type: [
+        //   { required: true, message: '报警设备模式', trigger: 'blur' }
+        // ],
+        // sosDeviceSetting: [
+        //   { required: true, message: '报警时间', trigger: 'blur' }
+        // ],
+        // unit: [
+        //   { required: true, message: '报警时间单位', trigger: 'blur' }
+        // ],
       },
       partFrames: [],
       typeFrames: [],
@@ -321,6 +354,20 @@ export default {
       audioOptions: [],
       rs485Options: [],
       hasAudioId: false,
+      hasSosDeviceSettings: false,
+      sosDeviceSetting: {},
+      sosDeviceSettingsTypeOptions: [
+        {
+          value: 0,
+          label: '不开启'
+        }, {
+          value: 1,
+          label: '疫情防控模式'
+        }, {
+          value: 2,
+          label: '关爱老人模式'
+        }
+      ],
       websock: null,
       onlineDevice: []
     }
@@ -635,6 +682,12 @@ export default {
             message: response.message
           })
         })
+        if (this.hasSosDeviceSettings) {
+          API_SosDeviceSetting.deleteByDeviceId(id).then(() => {
+            this.hasSosDeviceSettings = false
+            this.getList()
+          })
+        }
       }).catch(() => {
         this.$message({
           type: 'info',
@@ -668,6 +721,8 @@ export default {
                         val === DEVICE_TYPE.RS485_DOOR ||
                         val === DEVICE_TYPE.SIMULATE_EMERGENCY_BUTTON ||
                         val === DEVICE_TYPE.SIMULATE_DOOR_LIGHT
+      this.hasSosDeviceSettings = val === DEVICE_TYPE.ALARM_BODY_INDUCTIVE ||
+          val === DEVICE_TYPE.DOOR_LOCK
     },
     /** 设备类型选中对应的空间结构  **/
     deviceTypeChangeToFrameTypeChange(val) {
@@ -700,6 +755,7 @@ export default {
       ) {
         this.getFramesByType(FRAME_TYPE.BED)
       } else {
+        this.getTypeFrame(this.$store.getters.partId)
         this.typeFrames = this.partFrames
       }
     },
@@ -713,6 +769,11 @@ export default {
         model: 'M' + parseInt(Math.random() * 100000),
         part_id: this.$store.getters.partId
       }
+      this.sosDeviceSetting = {
+        type: 0,
+        unit: '小时',
+        setting_time: 0,
+      }
       if (Object.keys(this.frame).length > 0) {
         this.$set(this.deviceModel, 'frame_id', this.frame.id)
       }
@@ -720,6 +781,7 @@ export default {
       this.hasRoleId = false
       this.getRoles({ page_size: 200, page_no: 1, fixedCondition: ' shop_id = -1', sort: ' role_id', dir: 'desc' })
       this.hasAudioId = false
+      this.hasSosDeviceSettings = false
       this.getDevices(this.$store.getters.partId)
       this.deviceEditTitle = '添加设备'
       this.deviceDialogVisible = true
@@ -730,12 +792,15 @@ export default {
     handleEdit(params) {
       this.getRoles({ page_size: 200, page_no: 1, fixedCondition: ' shop_id = -1', sort: ' role_id', dir: 'desc' })
       this.getDevices(params.part_id)
+      this.getSosDeviceSetting(params.id)
       this.deviceTypeChangeToFrameTypeChange(params.device_type)
       this.hasRoleId = params.device_type === DEVICE_TYPE.NURSE_WATCH
       this.hasAudioId = params.device_type === DEVICE_TYPE.SIMULATE_BED_DEVICE ||
                         params.device_type === DEVICE_TYPE.RS485_DOOR ||
                         params.device_type === DEVICE_TYPE.SIMULATE_EMERGENCY_BUTTON ||
                         params.device_type === DEVICE_TYPE.SIMULATE_DOOR_LIGHT
+      this.hasSosDeviceSettings = params.device_type === DEVICE_TYPE.ALARM_BODY_INDUCTIVE ||
+          params.device_type === DEVICE_TYPE.DOOR_LOCK
       this.deviceModel = {
         ...params
       }
@@ -747,17 +812,39 @@ export default {
     handlerFormSubmit(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
+          const _this = this;
           /** 新增 */
           if (!this.deviceModel.id) {
-            API_Device.add(this.deviceModel).then(() => {
-              this.$message.success('保存成功!')
-              this.deviceDialogVisible = false
-              this.getList()
+             API_Device.add(this.deviceModel).then(r => {
+               this.$message.success('保存成功!')
+               _this.device = r
+               this.sosDeviceSetting.device_id = _this.device.id
+               this.sosDeviceSetting.part_id = _this.device.part_id
+
+               if (this.hasSosDeviceSettings) {
+                 API_SosDeviceSetting.add(this.sosDeviceSetting).then(() => {
+                   this.$message.success('保存成功!')
+                   this.hasSosDeviceSettings = false
+                 })
+               }
+
+               this.deviceDialogVisible = false
+               this.getList()
             })
           } else {
             /** 修改 */
             API_Device.update(this.deviceModel.id, this.deviceModel).then(() => {
               this.$message.success('修改成功!')
+
+              if (this.hasSosDeviceSettings) {
+                this.sosDeviceSetting.device_id = this.deviceModel.id
+                this.sosDeviceSetting.part_id = this.deviceModel.part_id
+                API_SosDeviceSetting.updateByDeviceId(this.deviceModel.id, this.sosDeviceSetting).then(() => {
+                  this.$message.success('保存成功!')
+                  this.hasSosDeviceSettings = false
+                })
+              }
+
               this.deviceDialogVisible = false
               this.getList()
             })
@@ -791,6 +878,11 @@ export default {
         this.rs485Options = response
       })
     },
+    getSosDeviceSetting(deviceId) {
+      API_SosDeviceSetting.getSosDeviceSetting(deviceId).then(r => {
+        this.sosDeviceSetting = r;
+      })
+    },
 
     initWebSocket: function() {
       var stockbase = DeviceUrl.replace('http', 'ws')