CascadeEditDlg.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <FormDlg title="编辑上级平台级联" @hide="onHide" @show="onShow" @submit="onSubmit" ref="dlg" :disabled="errors.any()" size="modal-lgg">
  3. <input type="hidden" name="ID" v-model.trim="form.ID">
  4. <div class="col-md-6">
  5. <div :class="{'form-group':true, 'has-error': errors.has('Name')}">
  6. <label for="name" class="col-sm-4 control-label">名称
  7. <span class="text-red">*</span>
  8. </label>
  9. <div class="col-sm-7">
  10. <input type="text" class="form-control" id="name" name="Name" v-model.trim="form.Name" data-vv-as="名称" v-validate="'required'" @keydown.enter="$el.querySelector('#serial').focus()">
  11. </div>
  12. </div>
  13. <div :class="{'form-group':true, 'has-error': errors.has('Serial')}">
  14. <label for="serial" class="col-sm-4 control-label">SIP服务国标编码
  15. <span class="text-red">*</span>
  16. </label>
  17. <div class="col-sm-7">
  18. <input type="text" class="form-control" id="serial" name="Serial" v-model.trim="form.Serial" data-vv-as="SIP服务国标编码" v-validate="'required'" @keydown.enter="$el.querySelector('#realm').focus()">
  19. </div>
  20. </div>
  21. <div :class="{'form-group':true, 'has-error': errors.has('Realm')}">
  22. <label for="realm" class="col-sm-4 control-label">SIP服务国标域
  23. <!-- <span class="text-red">*</span> -->
  24. </label>
  25. <div class="col-sm-7">
  26. <input type="text" class="form-control" id="realm" name="Realm" v-model.trim="form.Realm" data-vv-as="SIP服务国标域" v-validate="" placeholder="选填" @keydown.enter="$el.querySelector('#host').focus()">
  27. </div>
  28. </div>
  29. <div :class="{'form-group':true, 'has-error': errors.has('Host')}">
  30. <label for="host" class="col-sm-4 control-label">SIP服务IP
  31. <span class="text-red">*</span>
  32. </label>
  33. <div class="col-sm-7">
  34. <input type="text" class="form-control" id="host" name="Host" v-model.trim="form.Host" data-vv-as="SIP服务IP" v-validate="'required|url'" @keydown.enter="$el.querySelector('#port').focus()">
  35. </div>
  36. </div>
  37. <div :class="{'form-group':true, 'has-error': errors.has('Port')}">
  38. <label for="port" class="col-sm-4 control-label">SIP服务端口
  39. <span class="text-red">*</span>
  40. </label>
  41. <div class="col-sm-7">
  42. <input type="text" class="form-control" id="port" name="Port" v-model.trim="form.Port" data-vv-as="SIP服务端口" v-validate="'required|numeric'" @keydown.enter="$el.querySelector('#local-serial').focus()">
  43. </div>
  44. </div>
  45. <div :class="{'form-group': true, 'has-error': errors.has('LocalSerial')}">
  46. <label for="local-serial" class="col-sm-4 control-label">设备国标编号
  47. <!-- <span class="text-red">*</span> -->
  48. </label>
  49. <div class="col-sm-7">
  50. <input type="text" class="form-control" id="local-serial" name="LocalSerial" v-model.trim="form.LocalSerial" data-vv-as="设备国标编号" v-validate="" placeholder="默认使用 livecms.ini > sip > serial" @keydown.enter="$el.querySelector('#local-host').focus()">
  51. </div>
  52. </div>
  53. <div :class="{'form-group': true, 'has-error': errors.has('LocalHost')}">
  54. <label for="local-host" class="col-sm-4 control-label">本地IP
  55. <!-- <span class="text-red">*</span> -->
  56. </label>
  57. <div class="col-sm-7">
  58. <input type="text" class="form-control" id="local-host" name="LocalHost" v-model.trim="form.LocalHost" data-vv-as="本地IP" v-validate="" placeholder="默认使用 livecms.ini > sip > host" @keydown.enter="$el.querySelector('#local-port').focus()">
  59. </div>
  60. </div>
  61. <div :class="{'form-group': true, 'has-error': errors.has('LocalPort')}">
  62. <label for="local-port" class="col-sm-4 control-label">本地端口
  63. <!-- <span class="text-red">*</span> -->
  64. </label>
  65. <div class="col-sm-7">
  66. <input type="text" class="form-control" id="local-port" name="LocalPort" v-model.trim="form.LocalPort" data-vv-as="本地端口" v-validate="'numeric'" placeholder="选填" @keydown.enter="$el.querySelector('#username').focus()">
  67. </div>
  68. </div>
  69. </div>
  70. <div class="col-md-6">
  71. <div :class="{'form-group': true, 'has-error': errors.has('Username')}">
  72. <label for="username" class="col-sm-4 control-label">SIP认证用户名
  73. <!-- <span class="text-red">*</span> -->
  74. </label>
  75. <div class="col-sm-7">
  76. <input type="text" class="form-control" id="username" name="Username" v-model.trim="form.Username" data-vv-as="SIP认证用户名" v-validate="" placeholder="默认使用 设备国标编号" @keydown.enter="$el.querySelector('#password').focus()">
  77. </div>
  78. </div>
  79. <div :class="{'form-group': true, 'has-error': errors.has('Password')}">
  80. <label for="password" class="col-sm-4 control-label">SIP认证密码
  81. <!-- <span class="text-red">*</span> -->
  82. </label>
  83. <div class="col-sm-7">
  84. <input type="text" class="form-control" id="password" name="Password" v-model.trim="form.Password" data-vv-as="SIP认证密码" v-validate="" @keydown.enter="$el.querySelector('#register-interval').focus()">
  85. </div>
  86. </div>
  87. <!-- <div :class="{'form-group': true, 'has-error': errors.has('RegisterTimeout')}">
  88. <label for="register-timeout" class="col-sm-4 control-label">注册有效期(秒)
  89. <span class="text-red">*</span>
  90. </label>
  91. <div class="col-sm-7">
  92. <input type="text" class="form-control" id="register-timeout" name="RegisterTimeout" v-model.trim="form.RegisterTimeout" data-vv-as="注册有效期" v-validate="'required|numeric'" @keydown.enter="$el.querySelector('#register-interval').focus()">
  93. </div>
  94. </div> -->
  95. <div :class="{'form-group': true, 'has-error': errors.has('RegisterInterval')}">
  96. <label for="register-interval" class="col-sm-4 control-label">注册周期(秒)
  97. <span class="text-red">*</span>
  98. </label>
  99. <div class="col-sm-7">
  100. <input type="text" class="form-control" id="register-interval" name="RegisterInterval" v-model.trim="form.RegisterInterval" data-vv-as="注册周期" v-validate="'required|numeric'" @keydown.enter="$el.querySelector('#keepalive-interval').focus()">
  101. </div>
  102. </div>
  103. <div :class="{'form-group': true, 'has-error': errors.has('KeepaliveInterval')}">
  104. <label for="keepalive-interval" class="col-sm-4 control-label">心跳周期(秒)
  105. <span class="text-red">*</span>
  106. </label>
  107. <div class="col-sm-7">
  108. <input type="text" class="form-control" id="keepalive-interval" name="KeepaliveInterval" v-model.trim="form.KeepaliveInterval" data-vv-as="心跳周期" v-validate="'required|numeric'" @keydown.enter="onSubmit">
  109. </div>
  110. </div>
  111. <div :class="{'form-group': true, 'has-error': errors.has('CatalogGroupSize')}">
  112. <label for="catalog-group-size" class="col-sm-4 control-label">目录分组大小
  113. <span class="text-red">*</span>
  114. </label>
  115. <div class="col-sm-7">
  116. <select class="form-control" id="catalog-group-size" name="CatalogGroupSize" v-model.trim="form.CatalogGroupSize" data-vv-as="目录分组大小" v-validate="">
  117. <option value="1">1</option>
  118. <option value="2">2</option>
  119. <option value="4">4</option>
  120. <option value="8">8</option>
  121. </select>
  122. </div>
  123. </div>
  124. <div :class="{'form-group': true, 'has-error': errors.has('CommandTransport')}">
  125. <label for="command-transport" class="col-sm-4 control-label">信令传输
  126. <span class="text-red">*</span>
  127. </label>
  128. <div class="col-sm-7">
  129. <select class="form-control" id="command-transport" name="CommandTransport" v-model.trim="form.CommandTransport" data-vv-as="信令传输" v-validate="">
  130. <option value="UDP">UDP</option>
  131. <option value="TCP">TCP</option>
  132. </select>
  133. </div>
  134. </div>
  135. <div :class="{'form-group': true, 'has-error': errors.has('Charset')}">
  136. <label for="charset" class="col-sm-4 control-label">字符集
  137. <span class="text-red">*</span>
  138. </label>
  139. <div class="col-sm-7">
  140. <select class="form-control" id="charset" name="Charset" v-model.trim="form.Charset" data-vv-as="字符集" v-validate="">
  141. <option value="GB2312">GB2312</option>
  142. <option value="UTF-8">UTF-8</option>
  143. </select>
  144. </div>
  145. </div>
  146. <div :class="{'form-group':true, 'has-error': errors.has('StreamKeepalive')}">
  147. <label class="col-sm-4 control-label">其它选项
  148. <!-- <span class="text-red">*</span> -->
  149. </label>
  150. <div class="col-sm-7 checkbox">
  151. <el-checkbox style="margin-left:-19px;margin-top:-5px;" size="small" v-model.trim="form.Enable" name="Enable">启用</el-checkbox>
  152. &nbsp;&nbsp;
  153. <el-checkbox style="margin-left:-19px;margin-top:-5px;" size="small" v-model.trim="form.AllowControl" name="AllowControl">允许云台控制</el-checkbox>
  154. &nbsp;&nbsp;
  155. <el-checkbox style="margin-left:-19px;margin-top:-5px;" size="small" v-model.trim="form.StreamKeepalive" name="StreamKeepalive" v-if="form.CommandTransport == 'UDP' || form.CommandTransport == 'udp'" title="开启RTCP流保活可防止产生野流">RTCP流保活</el-checkbox>
  156. </div>
  157. </div>
  158. </div>
  159. <div class="clearfix"></div>
  160. </FormDlg>
  161. </template>
  162. <script>
  163. import FormDlg from 'components/FormDlg.vue'
  164. import $ from 'jquery'
  165. export default {
  166. data() {
  167. return {
  168. form: this.defForm()
  169. }
  170. },
  171. components: {
  172. FormDlg
  173. },
  174. methods: {
  175. defForm() {
  176. return {
  177. ID: "",
  178. Enable: false,
  179. Name: "",
  180. Serial: "",
  181. Realm: "",
  182. Host: "",
  183. Port: 5060,
  184. LocalSerial: "",
  185. LocalHost: "",
  186. LocalPort: "",
  187. Username: "",
  188. Password: "",
  189. Online: false,
  190. Status: "",
  191. RegisterTimeout: 3600,
  192. KeepaliveInterval: 60,
  193. RegisterInterval: 300,
  194. StreamKeepalive: false,
  195. AllowControl: true,
  196. ShareAllChannel: false,
  197. CommandTransport: "UDP",
  198. Charset: "GB2312",
  199. CatalogGroupSize: 1,
  200. }
  201. },
  202. onHide() {
  203. this.form = this.defForm();
  204. },
  205. onShow() {
  206. this.errors.clear();
  207. },
  208. async onSubmit() {
  209. var ok = await this.$validator.validateAll();
  210. if(!ok) {
  211. var e = this.errors.items[0];
  212. this.$message({
  213. type: 'error',
  214. message: e.msg
  215. })
  216. $(`[name=${e.field}]`).focus();
  217. return;
  218. }
  219. $.get('/api/v1/cascade/save', this.form).then(data => {
  220. this.$refs['dlg'].hide();
  221. this.$emit("submit");
  222. })
  223. },
  224. show(data) {
  225. this.errors.clear();
  226. if(data) {
  227. Object.assign(this.form, data);
  228. }
  229. if(!this.form["LocalPort"]) {
  230. this.form["LocalPort"] = ""
  231. }
  232. this.$nextTick(() => {
  233. this.$refs['dlg'].show();
  234. })
  235. }
  236. }
  237. }
  238. </script>
  239. <style lang="less" scoped>
  240. .model-lg {
  241. width: 80% !important;
  242. }
  243. </style>