StreamProxyEdit.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <div id="addStreamProxy" 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="streamProxy" :rules="rules" :model="proxyParam" label-width="140px" >
  14. <el-form-item label="类型" prop="type">
  15. <el-select
  16. v-model="proxyParam.type"
  17. style="width: 100%"
  18. placeholder="请选择代理类型"
  19. >
  20. <el-option label="默认" value="default"></el-option>
  21. <el-option label="FFmpeg" value="ffmpeg"></el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="名称" prop="name">
  25. <el-input v-model="proxyParam.name" clearable></el-input>
  26. </el-form-item>
  27. <el-form-item label="流应用名" prop="app">
  28. <el-input v-model="proxyParam.app" clearable></el-input>
  29. </el-form-item>
  30. <el-form-item label="流ID" prop="stream">
  31. <el-input v-model="proxyParam.stream" clearable></el-input>
  32. </el-form-item>
  33. <el-form-item label="拉流地址" prop="url" v-if="proxyParam.type=='default'">
  34. <el-input v-model="proxyParam.url" clearable></el-input>
  35. </el-form-item>
  36. <el-form-item label="拉流地址" prop="src_url" v-if="proxyParam.type=='ffmpeg'">
  37. <el-input v-model="proxyParam.src_url" clearable></el-input>
  38. </el-form-item>
  39. <el-form-item label="超时时间" prop="timeout_ms" v-if="proxyParam.type=='ffmpeg'">
  40. <el-input v-model="proxyParam.timeout_ms" clearable></el-input>
  41. </el-form-item>
  42. <el-form-item label="FFmpeg命令模板" prop="ffmpeg_cmd_key" v-if="proxyParam.type=='ffmpeg'">
  43. <el-input v-model="proxyParam.ffmpeg_cmd_key" clearable></el-input>
  44. </el-form-item>
  45. <el-form-item label="国标编码" prop="gbId">
  46. <el-input v-model="proxyParam.gbId" placeholder="设置国标编码可推送到国标" clearable></el-input>
  47. </el-form-item>
  48. <el-form-item label="拉流方式" prop="rtp_type" v-if="proxyParam.type=='default'">
  49. <el-select
  50. v-model="proxyParam.rtp_type"
  51. style="width: 100%"
  52. placeholder="请选择拉流方式"
  53. >
  54. <el-option label="TCP" value="0"></el-option>
  55. <el-option label="UDP" value="1"></el-option>
  56. <el-option label="组播" value="2"></el-option>
  57. </el-select>
  58. </el-form-item>
  59. <el-form-item label="国标平台">
  60. <el-select
  61. v-model="proxyParam.platformGbId"
  62. style="width: 100%"
  63. placeholder="请选择国标平台"
  64. >
  65. <el-option
  66. v-for="item in platformList"
  67. :key="item.name"
  68. :label="item.name"
  69. :value="item.serverGBId">
  70. <span style="float: left">{{ item.name }}</span>
  71. <span style="float: right; color: #8492a6; font-size: 13px">{{ item.serverGBId }}</span>
  72. </el-option>
  73. </el-select>
  74. </el-form-item>
  75. <el-form-item label="其他选项">
  76. <div style="float: left;">
  77. <el-checkbox label="启用" v-model="proxyParam.enable" ></el-checkbox>
  78. <el-checkbox label="转HLS" v-model="proxyParam.enable_hls" ></el-checkbox>
  79. <el-checkbox label="MP4录制" v-model="proxyParam.enable_mp4" ></el-checkbox>
  80. </div>
  81. </el-form-item>
  82. <el-form-item>
  83. <div style="float: right;">
  84. <el-button type="primary" @click="onSubmit" :loading="dialogLoading" >{{onSubmit_text}}</el-button>
  85. <el-button @click="close">取消</el-button>
  86. </div>
  87. </el-form-item>
  88. </el-form>
  89. </div>
  90. </el-dialog>
  91. </div>
  92. </template>
  93. <script>
  94. export default {
  95. name: "streamProxyEdit",
  96. props: {},
  97. computed: {},
  98. created() {},
  99. data() {
  100. // var deviceGBIdRules = async (rule, value, callback) => {
  101. // console.log(value);
  102. // if (value === "") {
  103. // callback(new Error("请输入设备国标编号"));
  104. // } else {
  105. // var exit = await this.deviceGBIdExit(value);
  106. // console.log(exit);
  107. // console.log(exit == "true");
  108. // console.log(exit === "true");
  109. // if (exit) {
  110. // callback(new Error("设备国标编号已存在"));
  111. // } else {
  112. // callback();
  113. // }
  114. // }
  115. // };
  116. return {
  117. listChangeCallback: null,
  118. showDialog: false,
  119. isLoging: false,
  120. dialogLoading: false,
  121. onSubmit_text: "立即创建",
  122. platformList: [{
  123. id: 1,
  124. enable: true,
  125. name: "141",
  126. serverGBId: "34020000002000000001",
  127. serverGBDomain: "3402000000",
  128. serverIP: "192.168.1.141",
  129. serverPort: 15060,
  130. deviceGBId: "34020000002000000001",
  131. deviceIp: "192.168.1.20",
  132. devicePort: "5060",
  133. username: "34020000002000000001",
  134. password: "12345678",
  135. expires: "300",
  136. keepTimeout: "60",
  137. transport: "UDP",
  138. characterSet: "GB2312",
  139. ptz: false,
  140. rtcp: false,
  141. status: true,
  142. }],
  143. proxyParam: {
  144. name: null,
  145. type: "default",
  146. app: null,
  147. stream: null,
  148. url: "rtmp://58.200.131.2/livetv/cctv5hd",
  149. src_url: null,
  150. timeout_ms: null,
  151. ffmpeg_cmd_key: null,
  152. gbId: null,
  153. rtp_type: null,
  154. enable: true,
  155. enable_hls: true,
  156. enable_mp4: false,
  157. platformGbId: null,
  158. },
  159. rules: {
  160. name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  161. app: [{ required: true, message: "请输入应用名", trigger: "blur" }],
  162. stream: [{ required: true, message: "请输入流ID", trigger: "blur" }],
  163. url: [{ required: true, message: "请输入要代理的流", trigger: "blur" }],
  164. src_url: [{ required: true, message: "请输入要代理的流", trigger: "blur" }],
  165. timeout_ms: [{ required: true, message: "请输入FFmpeg推流成功超时时间", trigger: "blur" }],
  166. ffmpeg_cmd_key: [{ required: false, message: "请输入FFmpeg命令参数模板(可选)", trigger: "blur" }],
  167. },
  168. };
  169. },
  170. methods: {
  171. openDialog: function (proxyParam, callback) {
  172. this.showDialog = true;
  173. this.listChangeCallback = callback;
  174. if (proxyParam != null) {
  175. this.proxyParam = proxyParam;
  176. }
  177. let that = this;
  178. this.$axios({
  179. method: 'get',
  180. url:`/api/platform/query/10000/0`
  181. }).then(function (res) {
  182. that.platformList = res.data.list;
  183. }).catch(function (error) {
  184. console.log(error);
  185. });
  186. },
  187. onSubmit: function () {
  188. console.log("onSubmit");
  189. this.dialogLoading = true;
  190. var that = this;
  191. that.$axios({
  192. method: 'post',
  193. url:`/api/proxy/save`,
  194. data: that.proxyParam
  195. }).then(function (res) {
  196. that.dialogLoading = false;
  197. if (typeof (res.data.code) != "undefined" && res.data.code === 0) {
  198. that.$message({
  199. showClose: true,
  200. message: res.data.msg,
  201. type: "success",
  202. });
  203. that.showDialog = false;
  204. if (that.listChangeCallback != null) {
  205. that.listChangeCallback();
  206. that.dialogLoading = false;
  207. }
  208. }
  209. }).catch(function (error) {
  210. console.log(error);
  211. this.dialogLoading = false;
  212. });
  213. },
  214. close: function () {
  215. console.log("关闭添加视频平台");
  216. this.showDialog = false;
  217. this.dialogLoading = false;
  218. this.$refs.streamProxy.resetFields();
  219. },
  220. deviceGBIdExit: async function (deviceGbId) {
  221. var result = false;
  222. var that = this;
  223. await that.$axios({
  224. method: 'post',
  225. url:`/api/platform/exit/${deviceGbId}`
  226. }).then(function (res) {
  227. result = res.data;
  228. }).catch(function (error) {
  229. console.log(error);
  230. });
  231. return result;
  232. },
  233. checkExpires: function() {
  234. if (this.platform.enable && this.platform.expires == "0") {
  235. this.platform.expires = "300";
  236. }
  237. }
  238. },
  239. };
  240. </script>