Browse Source

新增485转换盒设备添加,增加模拟分机设备对语音转换盒和485转换盒id的添加

LAPTOP-LIQ71VDD\m 3 years ago
parent
commit
4928113614

+ 1 - 1
src/api/ncs_device.js

@@ -65,7 +65,7 @@ export function getDeviceById(id) {
 /** 查询某类设备 */
 export function getDeviceByType(partid, type) {
   return request({
-    url: `/ncs/device/${partid}/${type}`,
+    url: `/ncs/device/getNurseDeviceList/${partid}/${type}`,
     method: 'get',
     loading: false
   })

+ 48 - 2
src/views/ncs-device/components/deviceManager.vue

@@ -152,6 +152,22 @@
             </el-form-item>
           </el-col>
         </el-row>
+        <el-row v-if="hasAudioId">
+          <el-col :span="12">
+            <el-form-item label="上属总线转换盒" prop="trans_audio_id">
+              <el-select v-model="deviceModel.trans_audio_id" placeholder="上属总线转换盒" clearable>
+                <el-option v-for="item in audioOptions" :key="item.id" :label="item.name" :value="item.id" />
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="上属485转换盒" prop="trans_rs485_id">
+              <el-select v-model="deviceModel.trans_rs485_id" placeholder="上属485转换盒" clearable>
+                <el-option v-for="item in rs485Options" :key="item.id" :label="item.name" :value="item.id" />
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="handlerFormSubmit('deviceEditForm')">确 定</el-button>
@@ -233,7 +249,13 @@ export default {
         ],
         role_id: [
           { required: true, message: '请选择适用人', trigger: 'blur' }
+        ],
+        trans_audio_id: [
+          { required: true, message: '请选择总线转换盒', trigger: 'blur' }
         ]
+        // trans_rs485_id: [
+        //   { required: true, message: '请选择485转换盒', trigger: 'blur' }
+        // ]
       },
       partFrames: [],
       /** 设备类型转换数组 **/
@@ -254,7 +276,10 @@ export default {
         { key: '模拟门灯', value: 14 },
         { key: '遥控器', value: 15 },
         { key: '信标', value: 16 },
-        { key: '看板', value: 17 }
+        // { key: '看板', value: 17 },
+        // { key: '门禁设备', value: 18 },
+        // { key: '探视机', value: 19 },
+        { key: '485转换盒', value: 20 }
       ],
       deviceStatusTransfer: [
         { key: '启用', value: 1, color: 'green' },
@@ -262,6 +287,9 @@ export default {
       ],
       rolesOptions: [],
       hasRoleId: false,
+      audioOptions: [],
+      rs485Options: [],
+      hasAudioId: false,
       websock: null,
       onlineDevice: []
     }
@@ -576,11 +604,16 @@ export default {
     /** 设备类型选中变化  **/
     deviceTypeChange(val) {
       if (val === 12 || val === 13 || val === 14) { // 模拟设备不需要mac地址
-        this.deviceRules.eth_mac[0].required = false
+        // this.deviceRules.eth_mac[0].required = false
+        this.deviceRules.eth_mac[1].pattern = null
+      } else if (val === 15) {
+        this.deviceRules.eth_mac[1].pattern = null
       } else {
+        this.deviceRules.eth_mac[1].pattern = /^([0-9A-Fa-f]{2}:?){6}/gi
         this.deviceRules.eth_mac[0].required = true
       }
       this.hasRoleId = val === 7
+      this.hasAudioId = val === 12 || val === 13 || val === 14
     },
     /** 添加设备事件 **/
     handleAdd() {
@@ -597,6 +630,8 @@ export default {
       delete this.deviceModel.id
       this.hasRoleId = false
       this.getRoles({ page_size: 200, page_no: 1, fixedCondition: ' shop_id = -1', sort: ' role_id', dir: 'desc' })
+      this.hasAudioId = false
+      this.getDevices(this.$store.getters.partId)
       this.deviceEditTitle = '添加设备'
       this.deviceDialogVisible = true
       this.deviceTypeDisabled = false // 新增设备可以选择设备类型
@@ -604,10 +639,12 @@ 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)
       if (!this.part_view) {
         this.getPartFrames(params.part_id)
       }
       this.hasRoleId = params.device_type === 7
+      this.hasAudioId = params.device_type === 12 || params.device_type === 13 || params.device_type === 14
       this.deviceModel = {
         ...params
       }
@@ -658,6 +695,15 @@ export default {
         this.rolesOptions = response.data
       })
     },
+    getDevices(partId) {
+      // 获取设备列表
+      API_Device.getDeviceByType(partId, 11).then(response => {
+        this.audioOptions = response
+      })
+      API_Device.getDeviceByType(partId, 20).then(response => {
+        this.rs485Options = response
+      })
+    },
 
     initWebSocket: function() {
       var stockbase = DeviceUrl.replace('http', 'ws')

+ 28 - 1
src/views/ncs-device/device-edit.vue

@@ -24,6 +24,7 @@
                 <el-option label="遥控器" :value="15" />
                 <el-option label="信标" :value="16" />
                 <el-option label="看板" :value="17" />
+                <el-option label="485转换盒" :value="20" />
               </el-select>
             </el-form-item>
           </el-col>
@@ -116,6 +117,20 @@
               </el-select>
             </el-form-item>
           </el-col>
+          <el-col :span="12">
+            <el-form-item label="上属总线转换盒" prop="audio_id">
+              <el-select v-model="formmodel.audio_id" placeholder="上属总线转换盒" clearable>
+                <el-option v-for="item in audioOptions" :key="item.id" :label="item.name" :value="item.id" />
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="上属485转换盒" prop="rs485_id">
+              <el-select v-model="formmodel.rs485_id" placeholder="上属485转换盒" clearable>
+                <el-option v-for="item in rs485Options" :key="item.id" :label="item.name" :value="item.id" />
+              </el-select>
+            </el-form-item>
+          </el-col>
         </el-row>
       </el-form>
 
@@ -191,7 +206,9 @@ export default {
       wifiHostReadonly: true,
       /** 设备类型选择禁用 编辑时不允许修改设备类型 */
       deviceTypeDisabled: false,
-      rolesOptions: []
+      rolesOptions: [],
+      audioOptions: [],
+      rs485Options: []
     }
   },
   computed: {
@@ -219,6 +236,7 @@ export default {
       this.handlerAdd()
     }
     this.getRoles({ page_size: 200, page_no: 1, fixedCondition: ' shop_id = -1', sort: ' role_id', dir: 'desc' })
+    this.getDevices(this.$store.getters.partId)
   },
   methods: {
     getRoles(param) {
@@ -227,6 +245,15 @@ export default {
         this.rolesOptions = response.data
       })
     },
+    getDevices(partId) {
+      // 获取设备列表
+      API_Device.getDeviceByType(partId, 11).then(response => {
+        this.audioOptions = response
+      })
+      API_Device.getDeviceByType(partId, 20).then(response => {
+        this.rs485Options = response
+      })
+    },
     /** 新增按钮 */
     async handlerAdd() {
       console.log('nextip', this.nextIp)