Config.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <div class="container-fluid no-padding">
  3. <section class="content">
  4. <div class="nav-tabs-custom col-lg-offset-2 col-lg-8 no-padding">
  5. <ul class="nav nav-tabs">
  6. <li class="active"><a href="#base-config" data-toggle="tab">{{logoText}} 信令服务配置</a></li>
  7. <li @click.prevent="getSMSList"><a href="#sms-config" data-toggle="tab">{{logoText}} 流媒体服务配置</a></li>
  8. </ul>
  9. <div class="tab-content">
  10. <div class="tab-pane active" id="base-config">
  11. <form role="form" class="form-horizontal" autocomplete="off" @submit.prevent="onSubmit">
  12. <div :class="['form-group' , {'has-error': errors.has('Serial')}]">
  13. <label for="sip-serial" class="col-sm-4 control-label">SIP ID</label>
  14. <div class="col-sm-7">
  15. <input id="sip-serial" type="text" class="form-control" name="Serial" data-vv-as="SIP ID" v-validate="'required'" v-model.trim="Serial">
  16. <span class="help-block">{{errors.first('Serial')}}</span>
  17. </div>
  18. </div>
  19. <div :class="['form-group' , {'has-error': errors.has('Realm')}]">
  20. <label for="sip-realm" class="col-sm-4 control-label">SIP 域</label>
  21. <div class="col-sm-7">
  22. <input id="sip-realm" type="text" class="form-control" name="Realm" data-vv-as="SIP 域" v-validate="'required'" v-model.trim="Realm">
  23. <span class="help-block">{{errors.first('Realm')}}</span>
  24. </div>
  25. </div>
  26. <div :class="['form-group' , {'has-error': errors.has('Host')}]">
  27. <label for="sip-host" class="col-sm-4 control-label">SIP Host</label>
  28. <div class="col-sm-7">
  29. <input type="text" id="sip-host" class="form-control" name="Host" data-vv-as="SIP Host" v-validate="'required'" v-model.trim="Host">
  30. <span class="help-block">{{errors.first('Host')}}</span>
  31. </div>
  32. </div>
  33. <div :class="['form-group' , {'has-error': errors.has('Port')}]">
  34. <label for="sip-port" class="col-sm-4 control-label">SIP 端口</label>
  35. <div class="col-sm-7">
  36. <input type="text" id="sip-port" class="form-control" name="Port" data-vv-as="SIP 端口" v-validate="'required|numeric'" v-model.trim="Port">
  37. <span class="help-block">{{errors.first('Port')}}</span>
  38. </div>
  39. </div>
  40. <div :class="['form-group' , {'has-error': errors.has('DevicePassword')}]">
  41. <label for="sip-dev-pwd" class="col-sm-4 control-label">设备统一接入密码</label>
  42. <div class="col-sm-7">
  43. <input type="text" id="sip-dev-pwd" class="form-control" name="DevicePassword" data-vv-as="设备统一接入密码" v-model.trim="DevicePassword">
  44. <span class="help-block">{{errors.first('DevicePassword')}}</span>
  45. </div>
  46. </div>
  47. <div :class="['form-group' , {'has-error': errors.has('TimeServer')}]">
  48. <label for="sip-time-server" class="col-sm-4 control-label">校时源(可选)</label>
  49. <div class="col-sm-7">
  50. <input type="text" id="sip-time-server" class="form-control" name="TimeServer" data-vv-as="校时源" v-validate="" v-model.trim="TimeServer" placeholder="上级国标编号/NTP">
  51. <span class="help-block">{{errors.first('TimeServer')}}</span>
  52. </div>
  53. </div>
  54. <div class="form-group">
  55. <label for="black-ip-list" class="col-sm-4 control-label">黑名单 IP(可选)</label>
  56. <div class="col-sm-7">
  57. <input type="text" id="black-ip-list" class="form-control" name="BlackIPList" data-vv-as="黑名单 IP" v-model.trim="BlackIPList" placeholder="选填">
  58. <span class="help-block"></span>
  59. </div>
  60. </div>
  61. <div class="form-group">
  62. <label for="black-ua-list" class="col-sm-4 control-label">黑名单 UA(可选)</label>
  63. <div class="col-sm-7">
  64. <input type="text" id="black-ua-list" class="form-control" name="BlackUAList" data-vv-as="黑名单 UA" v-model.trim="BlackUAList" placeholder="选填">
  65. <span class="help-block"></span>
  66. </div>
  67. </div>
  68. <div class="form-group">
  69. <label class="col-sm-4 control-label">其他配置</label>
  70. <div class="col-sm-7 checkbox">
  71. <el-checkbox title="开启后接口调用会校验登录" style="margin-left:-19px;margin-top:-5px;" size="small" v-model.trim="APIAuth" name="APIAuth">HTTP 接口鉴权</el-checkbox>
  72. &nbsp;&nbsp;&nbsp;&nbsp;
  73. <el-checkbox style="margin-left:-19px;margin-top:-5px;" size="small" v-model.trim="SIPLog" name="SIPLog">信令日志</el-checkbox>
  74. &nbsp;&nbsp;&nbsp;&nbsp;
  75. <router-link :to="`/black/1`">
  76. <i title="设备接入黑名单维护" class="fa fa-list cfg-black-list" aria-hidden="true">&nbsp;&nbsp;黑名单</i>
  77. </router-link>
  78. &nbsp;&nbsp;&nbsp;&nbsp;
  79. <router-link :to="`/white/1`">
  80. <i title="设备接入白名单维护" class="fa fa-server cfg-white-list" aria-hidden="true">&nbsp;&nbsp;白名单</i>
  81. </router-link>
  82. <span class="help-block"></span>
  83. </div>
  84. </div>
  85. <div class="form-group">
  86. <div class="col-sm-offset-4 col-sm-7">
  87. <button type="submit" class="btn btn-primary" :disabled="isBasicNoChange || errors.any() || bCommitting">保存</button>
  88. </div>
  89. </div>
  90. </form>
  91. </div>
  92. <div class="tab-pane" id="sms-config">
  93. <form role="form" class="form-horizontal" autocomplete="off">
  94. <div class="form-group" v-if="smss.length > 0">
  95. <label class="col-sm-4 control-label">SMS 服务</label>
  96. <div class="col-sm-7">
  97. <select class="form-control" v-model.trim="smsserial" @change="smschange">
  98. <option v-for="(c, idx) in smss" :value="c.Serial" :key="idx">{{c.Serial}}</option>
  99. </select>
  100. </div>
  101. </div>
  102. <div class="form-group" v-if="smss.length <= 0">
  103. <div class="col-sm-12">
  104. <div class="alert text-center no-margin">SMS {{smstip}}</div>
  105. </div>
  106. </div>
  107. </form>
  108. <form v-if="smsbaseconfig.Host != undefined && smss.length > 0" role="form" class="form-horizontal" autocomplete="off" @submit.prevent="onSubmitSMS">
  109. <div :class="['form-group' , {'has-error': errors.has('smsSerial')}]" title="内部通信使用">
  110. <label class="col-sm-4 control-label">SIP ID</label>
  111. <div class="col-sm-7">
  112. <input type="text" class="form-control" name="smsSerial" data-vv-as="SIP ID" v-validate="'required'" v-model.trim="smsbaseconfig.Serial">
  113. <span class="help-block">{{errors.first('smsSerial')}}</span>
  114. </div>
  115. </div>
  116. <div :class="['form-group' , {'has-error': errors.has('smsRealm')}]" title="内部通信使用">
  117. <label class="col-sm-4 control-label">SIP 域</label>
  118. <div class="col-sm-7">
  119. <input type="text" class="form-control" name="smsRealm" data-vv-as="SIP 域" v-validate="'required'" v-model.trim="smsbaseconfig.Realm">
  120. <span class="help-block">{{errors.first('smsRealm')}}</span>
  121. </div>
  122. </div>
  123. <div :class="['form-group' , {'has-error': errors.has('smsPort')}]" title="内部通信使用">
  124. <label class="col-sm-4 control-label">SIP 端口</label>
  125. <div class="col-sm-7">
  126. <input type="text" class="form-control" name="smsPort" data-vv-as="SIP 端口" v-validate="'required|numeric'" v-model.trim="smsbaseconfig.Port">
  127. <span class="help-block">{{errors.first('smsPort')}}</span>
  128. </div>
  129. </div>
  130. <div :class="['form-group' , {'has-error': errors.has('smsHost')}]" title="内部通信收流. 启用外网IP收流后, 此处配置信令服务可访问的局域网IP如:127.0.0.1">
  131. <label class="col-sm-4 control-label">本地|内网 IP</label>
  132. <div class="col-sm-7">
  133. <input type="text" class="form-control" placeholder="内部通信收流. 启用外网IP收流后, 此处配置信令服务可访问的局域网IP如:127.0.0.1" name="smsHost" data-vv-as="本地|内网 IP" v-validate="'required'" v-model.trim="smsbaseconfig.Host">
  134. <span class="help-block">{{errors.first('smsHost')}}</span>
  135. </div>
  136. </div>
  137. <div :class="['form-group' , {'has-error': errors.has('WanIP')}]">
  138. <label class="col-sm-4 control-label">外网 IP(可选)</label>
  139. <div class="col-sm-7">
  140. <input type="text" class="form-control" name="WanIP" data-vv-as="外网 IP" v-model.trim="smsbaseconfig.WanIP" v-validate="'url'" placeholder="选填">
  141. <span class="help-block">{{errors.first('WanIP')}}</span>
  142. </div>
  143. </div>
  144. <div class="form-group">
  145. <label class="col-sm-4 control-label">RTSP 端口(可选)</label>
  146. <div class="col-sm-7">
  147. <input type="text" class="form-control" name="RTSPPort" data-vv-as="RTSP 端口" v-validate="'numeric'" v-model.trim="smsbaseconfig.RTSPPort" placeholder="选填">
  148. <span class="help-block">{{errors.first('RTSPPort')}}</span>
  149. </div>
  150. </div>
  151. <div :class="['form-group' , {'has-error': errors.has('RTMPPort')}]">
  152. <label class="col-sm-4 control-label">RTMP 端口</label>
  153. <div class="col-sm-7">
  154. <input type="text" class="form-control" name="RTMPPort" data-vv-as="RTMP 端口" v-validate="'required|numeric'" v-model.trim="smsbaseconfig.RTMPPort">
  155. <span class="help-block">{{errors.first('RTMPPort')}}</span>
  156. </div>
  157. </div>
  158. <div :class="['form-group' , {'has-error': errors.has('RecordDir')}]">
  159. <label class="col-sm-4 control-label">云录像目录</label>
  160. <div class="col-sm-7">
  161. <input type="text" class="form-control" name="RecordDir" data-vv-as="云录像目录" v-model.trim="smsbaseconfig.RecordDir">
  162. <span class="help-block">{{errors.first('RecordDir')}}</span>
  163. </div>
  164. </div>
  165. <div class="form-group">
  166. <label class="col-sm-4 control-label">其他配置</label>
  167. <div class="col-sm-7 checkbox">
  168. <el-checkbox title="加快启播速度,相应也会增大一点延时" style="margin-left:-19px;margin-top:-5px;" size="small" v-model.trim="smsbaseconfig.GOPCache" name="GOPCache">直播秒开</el-checkbox>
  169. &nbsp;&nbsp;&nbsp;&nbsp;
  170. <el-checkbox style="margin-left:-19px;margin-top:-5px;" size="small" v-model.trim="smsbaseconfig.HLS" name="HLS">HLS</el-checkbox>
  171. &nbsp;&nbsp;&nbsp;&nbsp;
  172. <el-checkbox style="margin-left:-19px;margin-top:-5px;" size="small" v-model.trim="smsbaseconfig.SIPLog" name="SIPLog">信令日志</el-checkbox>
  173. &nbsp;&nbsp;&nbsp;&nbsp;
  174. <el-checkbox style="margin-left:-19px;margin-top:-5px;" size="small" v-model.trim="smsbaseconfig.UseWanIPRecvStream" name="UseWanIPRecvStream">外网 IP 收流</el-checkbox>
  175. </div>
  176. </div>
  177. <div class="form-group">
  178. <div class="col-sm-offset-4 col-sm-7">
  179. <button type="submit" class="btn btn-primary" :disabled="isSMSNoChange || errors.any() || bCommitting">保存</button>
  180. </div>
  181. </div>
  182. </form>
  183. </div>
  184. </div>
  185. <!-- /.tab-content -->
  186. </div>
  187. </section>
  188. </div>
  189. </template>
  190. <script>
  191. import $ from "jquery";
  192. import {
  193. mapState,
  194. mapActions
  195. } from "vuex"
  196. export default {
  197. data() {
  198. return {
  199. bCommitting: false,
  200. Serial: "",
  201. Realm: "",
  202. Host: "",
  203. Port: 0,
  204. DevicePassword: "",
  205. TimeServer: "",
  206. AckTimeout: 0,
  207. KeepaliveTimeout: 0,
  208. APIAuth: false,
  209. SIPLog: false,
  210. BlackIPList: "",
  211. BlackUAList: "",
  212. remoteBasicData: "",
  213. remoteSMSData: "",
  214. smsserial: "",
  215. smss: [],
  216. sms: {},
  217. smsbaseconfig: {},
  218. smstip: "流媒体服务尚未启动",
  219. };
  220. },
  221. mounted() {
  222. this.getBaseConfig()
  223. },
  224. methods: {
  225. async onSubmit() {
  226. var ok = await this.$validator.validateAll();
  227. if (!ok) {
  228. var e = this.errors.items[0];
  229. this.$message({
  230. type: "error",
  231. message: e.msg
  232. });
  233. $(`[name=${e.field}]`).focus();
  234. return;
  235. }
  236. this.bCommitting = true;
  237. $.get("/api/v1/setbaseconfig", this.getBasicCommitObject()).then(data => {
  238. this.$message({
  239. type: "success",
  240. message: "配置成功!"
  241. });
  242. }).always(() => {
  243. this.getBaseConfig()
  244. this.bCommitting = false;
  245. })
  246. },
  247. async onSubmitSMS() {
  248. var ok = await this.$validator.validateAll();
  249. if (!ok) {
  250. var e = this.errors.items[0];
  251. this.$message({
  252. type: "error",
  253. message: e.msg
  254. });
  255. $(`[name=${e.field}]`).focus();
  256. return;
  257. }
  258. this.bCommitting = true;
  259. $.get("/api/v1/sms/setbaseconfig", this.smsbaseconfig).then(data => {
  260. this.$message({
  261. type: "success",
  262. message: "配置保存中,请稍后..."
  263. });
  264. }).always(() => {
  265. this.smstip = "配置保存中,请稍后..."
  266. this.smsserial = "";
  267. this.getSMSList()
  268. this.bCommitting = false;
  269. })
  270. },
  271. getBasicCommitObject() {
  272. return {
  273. Serial: this.Serial,
  274. Realm: this.Realm,
  275. Host: this.Host,
  276. Port: this.Port,
  277. DevicePassword: this.DevicePassword,
  278. TimeServer: this.TimeServer,
  279. AckTimeout: this.AckTimeout,
  280. KeepaliveTimeout: this.KeepaliveTimeout,
  281. APIAuth: this.APIAuth,
  282. SIPLog: this.SIPLog,
  283. BlackIPList: this.BlackIPList,
  284. BlackUAList: this.BlackUAList,
  285. };
  286. },
  287. getBaseConfig() {
  288. $.get("/api/v1/getbaseconfig").then(ret => {
  289. this.Serial = ret.Serial;
  290. this.Realm = ret.Realm;
  291. this.Host = ret.Host;
  292. this.Port = ret.Port;
  293. this.DevicePassword = ret.DevicePassword;
  294. this.TimeServer = ret.TimeServer;
  295. this.AckTimeout = ret.AckTimeout;
  296. this.KeepaliveTimeout = ret.KeepaliveTimeout;
  297. this.APIAuth = ret.APIAuth;
  298. this.SIPLog = ret.SIPLog;
  299. this.BlackIPList = ret.BlackIPList;
  300. this.BlackUAList = ret.BlackUAList;
  301. this.remoteBasicData = JSON.stringify(this.getBasicCommitObject());
  302. });
  303. },
  304. getSMSList() {
  305. if (this.smsserial == "") {
  306. $.get("/api/v1/sms/list").then(ret => {
  307. this.smss = ret
  308. if (ret.length > 0) {
  309. this.sms = ret[0]
  310. this.smsserial = ret[0].Serial
  311. }
  312. this.getSMSInfo();
  313. if (this.smsserial == "") {
  314. setTimeout(() => {
  315. this.getSMSList()
  316. }, 1000);
  317. } else {
  318. this.smstip = "流媒体服务尚未启动"
  319. }
  320. })
  321. }
  322. },
  323. getSMSInfo() {
  324. if (this.smsserial != "") {
  325. $.get("/api/v1/sms/getbaseconfig", {
  326. serial: this.smsserial
  327. }).then(ret => {
  328. this.smsbaseconfig = ret;
  329. this.smsbaseconfig["PreSerial"] = this.smsserial;
  330. this.remoteSMSData = JSON.stringify(this.smsbaseconfig);
  331. })
  332. }
  333. },
  334. smschange() {
  335. this.getSMSInfo()
  336. }
  337. },
  338. computed: {
  339. ...mapState([
  340. "logoText",
  341. "logoMiniText",
  342. "menus",
  343. "serverInfo"
  344. ]),
  345. isBasicNoChange() {
  346. var localeData = JSON.stringify(this.getBasicCommitObject());
  347. return this.remoteBasicData.localeCompare(localeData) == 0;
  348. },
  349. isSMSNoChange() {
  350. this.smsbaseconfig["PreSerial"] = this.smsserial;
  351. var localeData = JSON.stringify(this.smsbaseconfig);
  352. return this.remoteSMSData.localeCompare(localeData) == 0;
  353. }
  354. }
  355. };
  356. </script>
  357. <style lang="less" scoped>
  358. .fa.cfg-black-list, .fa.cfg-white-list {
  359. font-size: 14px;
  360. line-height: 19px;
  361. display: inline-block;
  362. color: #606266;
  363. }
  364. </style>