Commit 5e8a7ce21e35b2c4d7faeede04e60b3537db2f3c

Authored by 648540858
1 parent 69734af3

添加utf-8解析设备信息

sql/mysql.sql
@@ -23,7 +23,8 @@ create table device @@ -23,7 +23,8 @@ create table device
23 updateTime varchar(50) not null, 23 updateTime varchar(50) not null,
24 port int not null, 24 port int not null,
25 expires int not null, 25 expires int not null,
26 - hostAddress varchar(50) not null 26 + hostAddress varchar(50) not null,
  27 + charset varchar(50) not null
27 ); 28 );
28 29
29 create table device_channel 30 create table device_channel
src/main/java/com/genersoft/iot/vmp/gb28181/auth/RegisterLogicHandler.java
1 package com.genersoft.iot.vmp.gb28181.auth; 1 package com.genersoft.iot.vmp.gb28181.auth;
2 2
  3 +import org.slf4j.Logger;
  4 +import org.slf4j.LoggerFactory;
3 import org.springframework.beans.factory.annotation.Autowired; 5 import org.springframework.beans.factory.annotation.Autowired;
4 import org.springframework.stereotype.Component; 6 import org.springframework.stereotype.Component;
5 7
@@ -14,13 +16,17 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; @@ -14,13 +16,17 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
14 @Component 16 @Component
15 public class RegisterLogicHandler { 17 public class RegisterLogicHandler {
16 18
  19 + private Logger logger = LoggerFactory.getLogger(RegisterLogicHandler.class);
  20 +
17 @Autowired 21 @Autowired
18 private SIPCommander cmder; 22 private SIPCommander cmder;
19 23
20 public void onRegister(Device device) { 24 public void onRegister(Device device) {
21 - // TODO 后续处理,只有第一次注册时调用查询设备信息,如需更新调用更新API接口  
22 - cmder.deviceInfoQuery(device);  
23 -  
24 - cmder.catalogQuery(device, null); 25 + // 只有第一次注册时调用查询设备信息,如需更新调用更新API接口
  26 + if (device.isFirsRegister()) {
  27 + logger.info("[{}] 首次注册,查询设备信息以及通道信息", device.getDeviceId());
  28 + cmder.deviceInfoQuery(device);
  29 + cmder.catalogQuery(device, null);
  30 + }
25 } 31 }
26 } 32 }
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java
@@ -99,6 +99,18 @@ public class Device { @@ -99,6 +99,18 @@ public class Device {
99 */ 99 */
100 private String mediaServerId; 100 private String mediaServerId;
101 101
  102 + /**
  103 + * 首次注册
  104 + */
  105 + private boolean firsRegister;
  106 +
  107 + /**
  108 + * 字符集, 支持 utf-8 与 gb2312
  109 + */
  110 + private String charset ;
  111 +
  112 +
  113 +
102 public String getDeviceId() { 114 public String getDeviceId() {
103 return deviceId; 115 return deviceId;
104 } 116 }
@@ -242,4 +254,20 @@ public class Device { @@ -242,4 +254,20 @@ public class Device {
242 public void setMediaServerId(String mediaServerId) { 254 public void setMediaServerId(String mediaServerId) {
243 this.mediaServerId = mediaServerId; 255 this.mediaServerId = mediaServerId;
244 } 256 }
  257 +
  258 + public boolean isFirsRegister() {
  259 + return firsRegister;
  260 + }
  261 +
  262 + public void setFirsRegister(boolean firsRegister) {
  263 + this.firsRegister = firsRegister;
  264 + }
  265 +
  266 + public String getCharset() {
  267 + return charset;
  268 + }
  269 +
  270 + public void setCharset(String charset) {
  271 + this.charset = charset;
  272 + }
245 } 273 }
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
@@ -172,6 +172,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { @@ -172,6 +172,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
172 String deviceId = deviceIdElement.getTextTrim().toString(); 172 String deviceId = deviceIdElement.getTextTrim().toString();
173 Device device = storager.queryVideoDevice(deviceId); 173 Device device = storager.queryVideoDevice(deviceId);
174 if (device != null) { 174 if (device != null) {
  175 + rootElement = getRootElement(evt, device.getCharset());
175 if (!StringUtils.isEmpty(device.getName())) { 176 if (!StringUtils.isEmpty(device.getName())) {
176 mobilePosition.setDeviceName(device.getName()); 177 mobilePosition.setDeviceName(device.getName());
177 } 178 }
@@ -449,8 +450,11 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { @@ -449,8 +450,11 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
449 Element rootElement = getRootElement(evt); 450 Element rootElement = getRootElement(evt);
450 String requestName = rootElement.getName(); 451 String requestName = rootElement.getName();
451 Element deviceIdElement = rootElement.element("DeviceID"); 452 Element deviceIdElement = rootElement.element("DeviceID");
452 - String deviceId = deviceIdElement.getTextTrim().toString(); 453 + String deviceId = deviceIdElement.getTextTrim();
453 Device device = storager.queryVideoDevice(deviceId); 454 Device device = storager.queryVideoDevice(deviceId);
  455 + if (device != null ) {
  456 + rootElement = getRootElement(evt, device.getCharset());
  457 + }
454 if (requestName.equals("Query")) { 458 if (requestName.equals("Query")) {
455 logger.info("接收到DeviceInfo查询消息"); 459 logger.info("接收到DeviceInfo查询消息");
456 FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); 460 FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME);
@@ -470,7 +474,9 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { @@ -470,7 +474,9 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
470 if (device == null) { 474 if (device == null) {
471 return; 475 return;
472 } 476 }
  477 +
473 device.setName(XmlUtil.getText(rootElement, "DeviceName")); 478 device.setName(XmlUtil.getText(rootElement, "DeviceName"));
  479 +
474 device.setManufacturer(XmlUtil.getText(rootElement, "Manufacturer")); 480 device.setManufacturer(XmlUtil.getText(rootElement, "Manufacturer"));
475 device.setModel(XmlUtil.getText(rootElement, "Model")); 481 device.setModel(XmlUtil.getText(rootElement, "Model"));
476 device.setFirmware(XmlUtil.getText(rootElement, "Firmware")); 482 device.setFirmware(XmlUtil.getText(rootElement, "Firmware"));
@@ -569,12 +575,14 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { @@ -569,12 +575,14 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
569 575
570 576
571 } else { 577 } else {
  578 + Device device = storager.queryVideoDevice(deviceId);
  579 + if (device == null) {
  580 + return;
  581 + }
  582 + deviceListElement = getRootElement(evt, device.getCharset()).element("DeviceList");
572 Iterator<Element> deviceListIterator = deviceListElement.elementIterator(); 583 Iterator<Element> deviceListIterator = deviceListElement.elementIterator();
573 if (deviceListIterator != null) { 584 if (deviceListIterator != null) {
574 - Device device = storager.queryVideoDevice(deviceId);  
575 - if (device == null) {  
576 - return;  
577 - } 585 +
578 // 遍历DeviceList 586 // 遍历DeviceList
579 while (deviceListIterator.hasNext()) { 587 while (deviceListIterator.hasNext()) {
580 Element itemDevice = deviceListIterator.next(); 588 Element itemDevice = deviceListIterator.next();
@@ -693,6 +701,9 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { @@ -693,6 +701,9 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
693 if (device == null) { 701 if (device == null) {
694 return; 702 return;
695 } 703 }
  704 + if (device.getCharset() != null) {
  705 + rootElement = getRootElement(evt, device.getCharset());
  706 + }
696 707
697 if (rootElement.getName().equals("Notify")) { // 处理报警通知 708 if (rootElement.getName().equals("Notify")) { // 处理报警通知
698 DeviceAlarm deviceAlarm = new DeviceAlarm(); 709 DeviceAlarm deviceAlarm = new DeviceAlarm();
@@ -816,6 +827,10 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { @@ -816,6 +827,10 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
816 Element rootElement = getRootElement(evt); 827 Element rootElement = getRootElement(evt);
817 Element deviceIdElement = rootElement.element("DeviceID"); 828 Element deviceIdElement = rootElement.element("DeviceID");
818 String deviceId = deviceIdElement.getText().toString(); 829 String deviceId = deviceIdElement.getText().toString();
  830 + Device device = storager.queryVideoDevice(deviceId);
  831 + if (device != null ) {
  832 + rootElement = getRootElement(evt, device.getCharset());
  833 + }
819 recordInfo.setDeviceId(deviceId); 834 recordInfo.setDeviceId(deviceId);
820 recordInfo.setName(XmlUtil.getText(rootElement, "Name")); 835 recordInfo.setName(XmlUtil.getText(rootElement, "Name"));
821 if (XmlUtil.getText(rootElement, "SumNum")== null || XmlUtil.getText(rootElement, "SumNum") =="") { 836 if (XmlUtil.getText(rootElement, "SumNum")== null || XmlUtil.getText(rootElement, "SumNum") =="") {
@@ -1009,9 +1024,15 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { @@ -1009,9 +1024,15 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
1009 } 1024 }
1010 1025
1011 private Element getRootElement(RequestEvent evt) throws DocumentException { 1026 private Element getRootElement(RequestEvent evt) throws DocumentException {
  1027 +
  1028 + return getRootElement(evt, "gb2312");
  1029 + }
  1030 +
  1031 + private Element getRootElement(RequestEvent evt, String charset) throws DocumentException {
  1032 + if (charset == null) charset = "gb2312";
1012 Request request = evt.getRequest(); 1033 Request request = evt.getRequest();
1013 SAXReader reader = new SAXReader(); 1034 SAXReader reader = new SAXReader();
1014 - reader.setEncoding("gbk"); 1035 + reader.setEncoding(charset);
1015 Document xml = reader.read(new ByteArrayInputStream(request.getRawContent())); 1036 Document xml = reader.read(new ByteArrayInputStream(request.getRawContent()));
1016 return xml.getRootElement(); 1037 return xml.getRootElement();
1017 } 1038 }
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/NotifyRequestProcessor.java
@@ -156,6 +156,7 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { @@ -156,6 +156,7 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
156 if (device == null) { 156 if (device == null) {
157 return; 157 return;
158 } 158 }
  159 + rootElement = getRootElement(evt, device.getCharset());
159 DeviceAlarm deviceAlarm = new DeviceAlarm(); 160 DeviceAlarm deviceAlarm = new DeviceAlarm();
160 deviceAlarm.setDeviceId(deviceId); 161 deviceAlarm.setDeviceId(deviceId);
161 deviceAlarm.setAlarmPriority(XmlUtil.getText(rootElement, "AlarmPriority")); 162 deviceAlarm.setAlarmPriority(XmlUtil.getText(rootElement, "AlarmPriority"));
@@ -218,6 +219,9 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { @@ -218,6 +219,9 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
218 Element deviceIdElement = rootElement.element("DeviceID"); 219 Element deviceIdElement = rootElement.element("DeviceID");
219 String deviceId = deviceIdElement.getText(); 220 String deviceId = deviceIdElement.getText();
220 Device device = storager.queryVideoDevice(deviceId); 221 Device device = storager.queryVideoDevice(deviceId);
  222 + if (device != null ) {
  223 + rootElement = getRootElement(evt, device.getCharset());
  224 + }
221 Element deviceListElement = rootElement.element("DeviceList"); 225 Element deviceListElement = rootElement.element("DeviceList");
222 if (deviceListElement == null) { 226 if (deviceListElement == null) {
223 return; 227 return;
@@ -347,11 +351,14 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { @@ -347,11 +351,14 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
347 serverTransaction.sendResponse(response); 351 serverTransaction.sendResponse(response);
348 if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete(); 352 if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete();
349 } 353 }
350 -  
351 private Element getRootElement(RequestEvent evt) throws DocumentException { 354 private Element getRootElement(RequestEvent evt) throws DocumentException {
  355 + return getRootElement(evt, "gb2312");
  356 + }
  357 + private Element getRootElement(RequestEvent evt, String charset) throws DocumentException {
  358 + if (charset == null) charset = "gb2312";
352 Request request = evt.getRequest(); 359 Request request = evt.getRequest();
353 SAXReader reader = new SAXReader(); 360 SAXReader reader = new SAXReader();
354 - reader.setEncoding("gbk"); 361 + reader.setEncoding(charset);
355 Document xml = reader.read(new ByteArrayInputStream(request.getRawContent())); 362 Document xml = reader.read(new ByteArrayInputStream(request.getRawContent()));
356 return xml.getRootElement(); 363 return xml.getRootElement();
357 } 364 }
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java
@@ -134,7 +134,9 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { @@ -134,7 +134,9 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor {
134 if (device == null) { 134 if (device == null) {
135 device = new Device(); 135 device = new Device();
136 device.setStreamMode("UDP"); 136 device.setStreamMode("UDP");
  137 + device.setCharset("gb2312");
137 device.setDeviceId(deviceId); 138 device.setDeviceId(deviceId);
  139 + device.setFirsRegister(true);
138 } 140 }
139 device.setIp(received); 141 device.setIp(received);
140 device.setPort(rPort); 142 device.setPort(rPort);
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
@@ -32,6 +32,7 @@ public interface DeviceMapper { @@ -32,6 +32,7 @@ public interface DeviceMapper {
32 "keepaliveTime," + 32 "keepaliveTime," +
33 "createTime," + 33 "createTime," +
34 "updateTime," + 34 "updateTime," +
  35 + "charset," +
35 "online" + 36 "online" +
36 ") VALUES (" + 37 ") VALUES (" +
37 "#{deviceId}," + 38 "#{deviceId}," +
@@ -49,6 +50,7 @@ public interface DeviceMapper { @@ -49,6 +50,7 @@ public interface DeviceMapper {
49 "#{keepaliveTime}," + 50 "#{keepaliveTime}," +
50 "#{createTime}," + 51 "#{createTime}," +
51 "#{updateTime}," + 52 "#{updateTime}," +
  53 + "#{charset}," +
52 "#{online}" + 54 "#{online}" +
53 ")") 55 ")")
54 int add(Device device); 56 int add(Device device);
@@ -69,6 +71,7 @@ public interface DeviceMapper { @@ -69,6 +71,7 @@ public interface DeviceMapper {
69 "<if test=\"registerTime != null\">, registerTime='${registerTime}'</if>" + 71 "<if test=\"registerTime != null\">, registerTime='${registerTime}'</if>" +
70 "<if test=\"keepaliveTime != null\">, keepaliveTime='${keepaliveTime}'</if>" + 72 "<if test=\"keepaliveTime != null\">, keepaliveTime='${keepaliveTime}'</if>" +
71 "<if test=\"expires != null\">, expires=${expires}</if>" + 73 "<if test=\"expires != null\">, expires=${expires}</if>" +
  74 + "<if test=\"charset != null\">, charset='${charset}'</if>" +
72 "WHERE deviceId='${deviceId}'"+ 75 "WHERE deviceId='${deviceId}'"+
73 " </script>"}) 76 " </script>"})
74 int update(Device device); 77 int update(Device device);
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
@@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.vmanager.gb28181.device; @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.vmanager.gb28181.device;
3 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; 3 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
4 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; 4 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
5 import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 5 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
  6 +import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
6 import com.github.pagehelper.PageInfo; 7 import com.github.pagehelper.PageInfo;
7 import io.swagger.annotations.*; 8 import io.swagger.annotations.*;
8 import org.slf4j.Logger; 9 import org.slf4j.Logger;
@@ -22,6 +23,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; @@ -22,6 +23,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
22 import com.genersoft.iot.vmp.storager.IVideoManagerStorager; 23 import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
23 24
24 import javax.sip.message.Response; 25 import javax.sip.message.Response;
  26 +import java.io.UnsupportedEncodingException;
25 27
26 @Api(tags = "国标设备查询", value = "国标设备查询") 28 @Api(tags = "国标设备查询", value = "国标设备查询")
27 @SuppressWarnings("rawtypes") 29 @SuppressWarnings("rawtypes")
@@ -274,6 +276,32 @@ public class DeviceQuery { @@ -274,6 +276,32 @@ public class DeviceQuery {
274 } 276 }
275 277
276 /** 278 /**
  279 + * 更新设备信息
  280 + * @param device 设备信息
  281 + * @return
  282 + */
  283 + @ApiOperation("更新设备信息")
  284 + @ApiImplicitParams({
  285 + @ApiImplicitParam(name = "device", value = "设备信息", required = true, dataTypeClass = Device.class)
  286 + })
  287 + @PostMapping("/device/update/")
  288 + public ResponseEntity<WVPResult<String>> updateDevice(Device device){
  289 +
  290 + if (device != null && device.getDeviceId() != null) {
  291 + Device deviceInStore = storager.queryVideoDevice(device.getDeviceId());
  292 + if (!StringUtils.isEmpty(device.getName())) deviceInStore.setName(device.getName());
  293 + if (!StringUtils.isEmpty(device.getCharset())) deviceInStore.setCharset(device.getCharset());
  294 + if (!StringUtils.isEmpty(device.getMediaServerId())) deviceInStore.setMediaServerId(device.getMediaServerId());
  295 + storager.updateDevice(deviceInStore);
  296 + cmder.deviceInfoQuery(deviceInStore);
  297 + }
  298 + WVPResult<String> result = new WVPResult<>();
  299 + result.setCode(0);
  300 + result.setMsg("success");
  301 + return new ResponseEntity<>(result,HttpStatus.OK);
  302 + }
  303 +
  304 + /**
277 * 设备状态查询请求API接口 305 * 设备状态查询请求API接口
278 * 306 *
279 * @param deviceId 设备id 307 * @param deviceId 设备id
src/main/resources/wvp.sqlite
No preview for this file type
web_src/src/components/DeviceList.vue
@@ -60,7 +60,7 @@ @@ -60,7 +60,7 @@
60 <el-button-group> 60 <el-button-group>
61 <el-button size="mini" icon="el-icon-video-camera-solid" v-bind:disabled="scope.row.online==0" type="primary" @click="showChannelList(scope.row)">通道</el-button> 61 <el-button size="mini" icon="el-icon-video-camera-solid" v-bind:disabled="scope.row.online==0" type="primary" @click="showChannelList(scope.row)">通道</el-button>
62 <el-button size="mini" icon="el-icon-location" v-bind:disabled="scope.row.online==0" type="primary" @click="showDevicePosition(scope.row)">定位</el-button> 62 <el-button size="mini" icon="el-icon-location" v-bind:disabled="scope.row.online==0" type="primary" @click="showDevicePosition(scope.row)">定位</el-button>
63 - <el-button size="mini" icon="el-icon-s-tools" v-bind:disabled="scope.row.online==0" type="primary">控制</el-button> 63 + <el-button size="mini" icon="el-icon-delete" type="primary" @click="edit(scope.row)">编辑</el-button>
64 <el-button size="mini" icon="el-icon-delete" type="danger" v-if="scope.row.online==0" @click="deleteDevice(scope.row)">删除</el-button> 64 <el-button size="mini" icon="el-icon-delete" type="danger" v-if="scope.row.online==0" @click="deleteDevice(scope.row)">删除</el-button>
65 </el-button-group> 65 </el-button-group>
66 </template> 66 </template>
@@ -76,7 +76,7 @@ @@ -76,7 +76,7 @@
76 layout="total, sizes, prev, pager, next" 76 layout="total, sizes, prev, pager, next"
77 :total="total"> 77 :total="total">
78 </el-pagination> 78 </el-pagination>
79 - 79 + <deviceEdit ref="deviceEdit" ></deviceEdit>
80 </el-main> 80 </el-main>
81 </el-container> 81 </el-container>
82 </div> 82 </div>
@@ -84,10 +84,12 @@ @@ -84,10 +84,12 @@
84 84
85 <script> 85 <script>
86 import uiHeader from './UiHeader.vue' 86 import uiHeader from './UiHeader.vue'
  87 + import deviceEdit from './dialog/deviceEdit.vue'
87 export default { 88 export default {
88 name: 'app', 89 name: 'app',
89 components: { 90 components: {
90 - uiHeader 91 + uiHeader,
  92 + deviceEdit
91 }, 93 },
92 data() { 94 data() {
93 return { 95 return {
@@ -239,6 +241,19 @@ @@ -239,6 +241,19 @@
239 241
240 }).catch(function(e) { 242 }).catch(function(e) {
241 }); 243 });
  244 + },
  245 + edit: function (row) {
  246 + console.log(row);
  247 + this.$refs.deviceEdit.openDialog(row, ()=>{
  248 + this.$refs.deviceEdit.close();
  249 + this.$message({
  250 + showClose: true,
  251 + message: "设备修改成功,通道字符集将在下次更新生效",
  252 + type: "success",
  253 + });
  254 + setTimeout(this.getDeviceList, 200)
  255 +
  256 + })
242 } 257 }
243 258
244 } 259 }
web_src/src/components/dialog/deviceEdit.vue 0 → 100644
  1 +<template>
  2 + <div id="deviceEdit" v-loading="isLoging">
  3 + <el-dialog
  4 + title="设备编辑"
  5 + width="40%"
  6 + top="2rem"
  7 + :close-on-click-modal="false"
  8 + :visible.sync="showDialog"
  9 + :destroy-on-close="true"
  10 + @close="close()"
  11 + >
  12 + <div id="shared" style="margin-top: 1rem;margin-right: 100px;">
  13 + <el-form ref="form" :rules="rules" :model="form" label-width="140px" >
  14 + <el-form-item label="设备编号" >
  15 + <el-input v-model="form.deviceId" disabled></el-input>
  16 + </el-form-item>
  17 +
  18 + <el-form-item label="设备名称" prop="name">
  19 + <el-input v-model="form.name" clearable></el-input>
  20 + </el-form-item>
  21 +<!-- <el-form-item label="流媒体ID" prop="mediaServerId">-->
  22 +<!-- <el-select v-model="form.mediaServerId" style="float: left; width: 100%" >-->
  23 +<!-- <el-option key="auto" label="自动负载最小" value="null"></el-option>-->
  24 +<!-- <el-option-->
  25 +<!-- v-for="item in mediaServerList"-->
  26 +<!-- :key="item.id"-->
  27 +<!-- :label="item.id"-->
  28 +<!-- :value="item.id">-->
  29 +<!-- </el-option>-->
  30 +<!-- </el-select>-->
  31 +<!-- </el-form-item>-->
  32 +
  33 + <el-form-item label="字符集" prop="charset" >
  34 + <el-select v-model="form.charset" style="float: left; width: 100%" >
  35 + <el-option key="GB2312" label="GB2312" value="gb2312"></el-option>
  36 + <el-option key="UTF-8" label="UTF-8" value="utf-8"></el-option>
  37 + </el-select>
  38 + </el-form-item>
  39 + <el-form-item>
  40 + <div style="float: right;">
  41 + <el-button type="primary" @click="onSubmit" >确认</el-button>
  42 + <el-button @click="close">取消</el-button>
  43 + </div>
  44 +
  45 + </el-form-item>
  46 + </el-form>
  47 + </div>
  48 + </el-dialog>
  49 + </div>
  50 +</template>
  51 +
  52 +<script>
  53 +import MediaServer from '../service/MediaServer'
  54 +export default {
  55 + name: "deviceEdit",
  56 + props: {},
  57 + computed: {},
  58 + created() {},
  59 + data() {
  60 + return {
  61 + listChangeCallback: null,
  62 + showDialog: false,
  63 + isLoging: false,
  64 + hostNames:[],
  65 + mediaServerList: [], // 滅体节点列表
  66 + mediaServerObj : new MediaServer(),
  67 + form: {},
  68 + rules: {
  69 + name: [{ required: true, message: "请输入名称", trigger: "blur" }]
  70 + },
  71 + };
  72 + },
  73 + methods: {
  74 + openDialog: function (row, callback) {
  75 + console.log(row)
  76 + this.showDialog = true;
  77 + this.listChangeCallback = callback;
  78 + if (row != null) {
  79 + this.form = row;
  80 + }
  81 + this.getMediaServerList();
  82 + },
  83 + getMediaServerList: function (){
  84 + let that = this;
  85 + that.mediaServerObj.getMediaServerList((data)=>{
  86 + that.mediaServerList = data.data;
  87 + })
  88 + },
  89 + onSubmit: function () {
  90 + console.log("onSubmit");
  91 + console.log(this.form);
  92 + this.$axios({
  93 + method: 'post',
  94 + url:`/api/device/query/device/update/`,
  95 + params: this.form
  96 + }).then((res) => {
  97 + console.log(res.data)
  98 + if (res.data.code == 0) {
  99 + this.listChangeCallback()
  100 + }else {
  101 + this.$message({
  102 + showClose: true,
  103 + message: res.data.msg,
  104 + type: "error",
  105 + });
  106 + }
  107 + }).catch(function (error) {
  108 + console.log(error);
  109 + });
  110 + },
  111 + close: function () {
  112 + this.showDialog = false;
  113 + this.$refs.form.resetFields();
  114 + },
  115 + },
  116 +};
  117 +</script>