platformEdit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. <template>
  2. <div id="addlatform" v-loading="isLoging">
  3. <el-dialog
  4. title="添加平台"
  5. width="70%"
  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="text-align: right; margin-top: 1rem">
  13. <el-row :gutter="24">
  14. <el-col :span="11">
  15. <el-form ref="platform1" :rules="rules" :model="platform" label-width="160px">
  16. <el-form-item label="名称" prop="name">
  17. <el-input v-model="platform.name"></el-input>
  18. </el-form-item>
  19. <el-form-item label="SIP服务国标编码" prop="serverGBId">
  20. <el-input v-model="platform.serverGBId" clearable @input="serverGBIdChange"></el-input>
  21. </el-form-item>
  22. <el-form-item label="SIP服务国标域" prop="serverGBDomain">
  23. <el-input v-model="platform.serverGBDomain" clearable></el-input>
  24. </el-form-item>
  25. <el-form-item label="SIP服务IP" prop="serverIP">
  26. <el-input v-model="platform.serverIP" clearable></el-input>
  27. </el-form-item>
  28. <el-form-item label="SIP服务端口" prop="serverPort">
  29. <el-input v-model="platform.serverPort" clearable type="number"></el-input>
  30. </el-form-item>
  31. <el-form-item label="设备国标编号" prop="deviceGBId">
  32. <el-input v-model="platform.deviceGBId" clearable @input="deviceGBIdChange"></el-input>
  33. </el-form-item>
  34. <el-form-item label="本地IP" prop="deviceIp">
  35. <el-input v-model="platform.deviceIp" :disabled="true"></el-input>
  36. </el-form-item>
  37. <el-form-item label="本地端口" prop="devicePort">
  38. <el-input v-model="platform.devicePort" :disabled="true" type="number"></el-input>
  39. </el-form-item>
  40. <el-form-item label="SDP发流IP" prop="sendStreamIp">
  41. <el-input v-model="platform.sendStreamIp"></el-input>
  42. </el-form-item>
  43. </el-form>
  44. </el-col>
  45. <el-col :span="12">
  46. <el-form ref="platform2" :rules="rules" :model="platform" label-width="160px">
  47. <el-form-item label="行政区划" prop="administrativeDivision">
  48. <el-input v-model="platform.administrativeDivision" clearable></el-input>
  49. </el-form-item>
  50. <el-form-item label="SIP认证用户名" prop="username">
  51. <el-input v-model="platform.username"></el-input>
  52. </el-form-item>
  53. <el-form-item label="SIP认证密码" prop="password">
  54. <el-input v-model="platform.password" ></el-input>
  55. </el-form-item>
  56. <el-form-item label="注册周期(秒)" prop="expires">
  57. <el-input v-model="platform.expires"></el-input>
  58. </el-form-item>
  59. <el-form-item label="心跳周期(秒)" prop="keepTimeout">
  60. <el-input v-model="platform.keepTimeout"></el-input>
  61. </el-form-item>
  62. <el-form-item label="信令传输" prop="transport">
  63. <el-select
  64. v-model="platform.transport"
  65. style="width: 100%"
  66. placeholder="请选择信令传输方式"
  67. >
  68. <el-option label="UDP" value="UDP"></el-option>
  69. <el-option label="TCP" value="TCP"></el-option>
  70. </el-select>
  71. </el-form-item>
  72. <el-form-item label="目录分组" prop="catalogGroup">
  73. <el-select
  74. v-model="platform.catalogGroup"
  75. style="width: 100%"
  76. placeholder="请选择目录分组"
  77. >
  78. <el-option label="1" value="1"></el-option>
  79. <el-option label="2" value="2"></el-option>
  80. <el-option label="4" value="4"></el-option>
  81. <el-option label="8" value="8"></el-option>
  82. </el-select>
  83. </el-form-item>
  84. <el-form-item label="字符集" prop="characterSet">
  85. <el-select
  86. v-model="platform.characterSet"
  87. style="width: 100%"
  88. placeholder="请选择字符集"
  89. >
  90. <el-option label="GB2312" value="GB2312"></el-option>
  91. <el-option label="UTF-8" value="UTF-8"></el-option>
  92. </el-select>
  93. </el-form-item>
  94. <el-form-item label="其他选项">
  95. <el-checkbox label="启用" v-model="platform.enable" @change="checkExpires"></el-checkbox>
  96. <!-- <el-checkbox label="云台控制" v-model="platform.ptz"></el-checkbox>-->
  97. <el-checkbox label="拉起推流" v-model="platform.startOfflinePush"></el-checkbox>
  98. <el-checkbox label="RTCP保活" v-model="platform.rtcp" @change="rtcpCheckBoxChange"></el-checkbox>
  99. <el-checkbox label="消息通道" v-model="platform.asMessageChannel" ></el-checkbox>
  100. <el-checkbox label="推送通道" v-model="platform.autoPushChannel" ></el-checkbox>
  101. </el-form-item>
  102. <el-form-item>
  103. <el-button type="primary" @click="onSubmit">{{
  104. onSubmit_text
  105. }}</el-button>
  106. <el-button @click="close">取消</el-button>
  107. </el-form-item>
  108. </el-form>
  109. </el-col>
  110. </el-row>
  111. </div>
  112. </el-dialog>
  113. </div>
  114. </template>
  115. <script>
  116. export default {
  117. name: "platformEdit",
  118. props: {},
  119. computed: {},
  120. data() {
  121. var deviceGBIdRules = async (rule, value, callback) => {
  122. console.log(value);
  123. if (value === "") {
  124. callback(new Error("请输入设备国标编号"));
  125. } else {
  126. var exit = await this.deviceGBIdExit(value);
  127. if (exit) {
  128. callback(new Error("设备国标编号已存在"));
  129. } else {
  130. callback();
  131. }
  132. }
  133. };
  134. return {
  135. listChangeCallback: null,
  136. showDialog: false,
  137. isLoging: false,
  138. onSubmit_text: "立即创建",
  139. saveUrl: "/api/platform/save",
  140. platform: {
  141. id: null,
  142. enable: true,
  143. ptz: true,
  144. rtcp: false,
  145. asMessageChannel: false,
  146. autoPushChannel: false,
  147. name: null,
  148. serverGBId: null,
  149. serverGBDomain: null,
  150. serverIP: null,
  151. serverPort: null,
  152. deviceGBId: null,
  153. deviceIp: null,
  154. devicePort: null,
  155. username: null,
  156. password: null,
  157. expires: 3600,
  158. keepTimeout: 60,
  159. transport: "UDP",
  160. characterSet: "GB2312",
  161. startOfflinePush: false,
  162. catalogGroup: 1,
  163. administrativeDivision: "",
  164. sendStreamIp: null,
  165. },
  166. rules: {
  167. name: [{ required: true, message: "请输入平台名称", trigger: "blur" }],
  168. serverGBId: [
  169. { required: true, message: "请输入SIP服务国标编码", trigger: "blur" },
  170. ],
  171. serverGBDomain: [
  172. { required: true, message: "请输入SIP服务国标域", trigger: "blur" },
  173. ],
  174. serverIP: [{ required: true, message: "请输入SIP服务IP", trigger: "blur" }],
  175. serverPort: [{ required: true, message: "请输入SIP服务端口", trigger: "blur" }],
  176. deviceGBId: [{ validator: deviceGBIdRules, trigger: "blur" }],
  177. username: [{ required: false, message: "请输入SIP认证用户名", trigger: "blur" }],
  178. password: [{ required: false, message: "请输入SIP认证密码", trigger: "blur" }],
  179. expires: [{ required: true, message: "请输入注册周期", trigger: "blur" }],
  180. keepTimeout: [{ required: true, message: "请输入心跳周期", trigger: "blur" }],
  181. transport: [{ required: true, message: "请选择信令传输", trigger: "blur" }],
  182. characterSet: [{ required: true, message: "请选择编码字符集", trigger: "blur" }],
  183. },
  184. };
  185. },
  186. methods: {
  187. openDialog: function (platform, callback) {
  188. var that = this;
  189. if (platform == null) {
  190. this.onSubmit_text = "立即创建";
  191. this.saveUrl = "/api/platform/add";
  192. this.$axios({
  193. method: 'get',
  194. url:`/api/platform/server_config`
  195. }).then(function (res) {
  196. console.log(res);
  197. if (res.data.code === 0) {
  198. that.platform.deviceGBId = res.data.data.username;
  199. that.platform.deviceIp = res.data.data.deviceIp;
  200. that.platform.devicePort = res.data.data.devicePort;
  201. that.platform.username = res.data.data.username;
  202. that.platform.password = res.data.data.password;
  203. that.platform.sendStreamIp = res.data.data.sendStreamIp;
  204. that.platform.administrativeDivision = res.data.data.username.substr(0, 6);
  205. }
  206. }).catch(function (error) {
  207. console.log(error);
  208. });
  209. }else {
  210. this.platform.id = platform.id;
  211. this.platform.enable = platform.enable;
  212. this.platform.ptz = platform.ptz;
  213. this.platform.rtcp = platform.rtcp;
  214. this.platform.asMessageChannel = platform.asMessageChannel;
  215. this.platform.autoPushChannel = platform.autoPushChannel;
  216. this.platform.name = platform.name;
  217. this.platform.serverGBId = platform.serverGBId;
  218. this.platform.serverGBDomain = platform.serverGBDomain;
  219. this.platform.serverIP = platform.serverIP;
  220. this.platform.serverPort = platform.serverPort;
  221. this.platform.deviceGBId = platform.deviceGBId;
  222. this.platform.deviceIp = platform.deviceIp;
  223. this.platform.devicePort = platform.devicePort;
  224. this.platform.username = platform.username;
  225. this.platform.password = platform.password;
  226. this.platform.expires = platform.expires;
  227. this.platform.keepTimeout = platform.keepTimeout;
  228. this.platform.transport = platform.transport;
  229. this.platform.characterSet = platform.characterSet;
  230. this.platform.catalogId = platform.catalogId;
  231. this.platform.startOfflinePush = platform.startOfflinePush;
  232. this.platform.catalogGroup = platform.catalogGroup;
  233. this.platform.sendStreamIp = platform.sendStreamIp;
  234. this.platform.administrativeDivision = platform.administrativeDivision;
  235. this.onSubmit_text = "保存";
  236. this.saveUrl = "/api/platform/save";
  237. }
  238. this.showDialog = true;
  239. this.listChangeCallback = callback;
  240. },
  241. serverGBIdChange: function () {
  242. if (this.platform.serverGBId.length > 10) {
  243. this.platform.serverGBDomain = this.platform.serverGBId.substr(0, 10);
  244. }
  245. },
  246. deviceGBIdChange: function () {
  247. this.platform.username = this.platform.deviceGBId ;
  248. if (this.platform.administrativeDivision == null) {
  249. this.platform.administrativeDivision = this.platform.deviceGBId.substr(0, 6);
  250. }
  251. },
  252. onSubmit: function () {
  253. this.saveForm()
  254. },
  255. saveForm: function (){
  256. this.$axios({
  257. method: 'post',
  258. url: this.saveUrl,
  259. data: this.platform
  260. }).then((res) =>{
  261. if (res.data.code === 0) {
  262. this.$message({
  263. showClose: true,
  264. message: "保存成功",
  265. type: "success",
  266. });
  267. this.showDialog = false;
  268. if (this.listChangeCallback != null) {
  269. this.listChangeCallback();
  270. }
  271. }else {
  272. this.$message({
  273. showClose: true,
  274. message: res.data.msg,
  275. type: "error",
  276. });
  277. }
  278. }).catch((error)=> {
  279. console.log(error);
  280. });
  281. },
  282. close: function () {
  283. this.showDialog = false;
  284. this.$refs.platform1.resetFields();
  285. this.$refs.platform2.resetFields();
  286. this.platform = {
  287. id: null,
  288. enable: true,
  289. ptz: true,
  290. rtcp: false,
  291. asMessageChannel: false,
  292. autoPushChannel: false,
  293. name: null,
  294. serverGBId: null,
  295. administrativeDivision: null,
  296. serverGBDomain: null,
  297. serverIP: null,
  298. serverPort: null,
  299. deviceGBId: null,
  300. deviceIp: null,
  301. devicePort: null,
  302. username: null,
  303. password: null,
  304. expires: 3600,
  305. keepTimeout: 60,
  306. transport: "UDP",
  307. characterSet: "GB2312",
  308. startOfflinePush: false,
  309. catalogGroup: 1,
  310. }
  311. },
  312. deviceGBIdExit: async function (deviceGbId) {
  313. var result = false;
  314. var that = this;
  315. await that.$axios({
  316. method: 'get',
  317. url:`/api/platform/exit/${deviceGbId}`})
  318. .then(function (res) {
  319. if (res.data.code === 0) {
  320. result = res.data.data;
  321. }
  322. })
  323. .catch(function (error) {
  324. console.log(error);
  325. });
  326. return result;
  327. },
  328. checkExpires: function() {
  329. if (this.platform.enable && this.platform.expires === "0") {
  330. this.platform.expires = "3600";
  331. }
  332. },
  333. rtcpCheckBoxChange: function (result){
  334. if (result) {
  335. this.$message({
  336. showClose: true,
  337. message: "开启RTCP保活需要上级平台支持,可以避免无效推流",
  338. type: "warning",
  339. });
  340. }
  341. },
  342. },
  343. };
  344. </script>
  345. <style>
  346. /* 谷歌 */
  347. input::-webkit-outer-spin-button,
  348. input::-webkit-inner-spin-button {
  349. -webkit-appearance: none;
  350. appearance: none;
  351. margin: 0;
  352. }
  353. /* 火狐 */
  354. input{
  355. -moz-appearance:textfield;
  356. }
  357. .control-wrapper-not-used {
  358. position: relative;
  359. width: 6.25rem;
  360. height: 6.25rem;
  361. max-width: 6.25rem;
  362. max-height: 6.25rem;
  363. border-radius: 100%;
  364. margin-top: 2.5rem;
  365. margin-left: 0.5rem;
  366. float: left;
  367. }
  368. .control-panel {
  369. position: relative;
  370. top: 0;
  371. left: 5rem;
  372. height: 11rem;
  373. max-height: 11rem;
  374. }
  375. .control-btn {
  376. display: flex;
  377. justify-content: center;
  378. position: absolute;
  379. width: 44%;
  380. height: 44%;
  381. border-radius: 5px;
  382. border: 1px solid #78aee4;
  383. box-sizing: border-box;
  384. transition: all 0.3s linear;
  385. }
  386. .control-btn i {
  387. font-size: 20px;
  388. color: #78aee4;
  389. display: flex;
  390. justify-content: center;
  391. align-items: center;
  392. }
  393. .control-round {
  394. position: absolute;
  395. top: 21%;
  396. left: 21%;
  397. width: 58%;
  398. height: 58%;
  399. background: #fff;
  400. border-radius: 100%;
  401. }
  402. .control-round-inner {
  403. position: absolute;
  404. left: 13%;
  405. top: 13%;
  406. display: flex;
  407. justify-content: center;
  408. align-items: center;
  409. width: 70%;
  410. height: 70%;
  411. font-size: 40px;
  412. color: #78aee4;
  413. border: 1px solid #78aee4;
  414. border-radius: 100%;
  415. transition: all 0.3s linear;
  416. }
  417. .control-inner-btn {
  418. position: absolute;
  419. width: 60%;
  420. height: 60%;
  421. background: #fafafa;
  422. }
  423. .control-top {
  424. top: -8%;
  425. left: 27%;
  426. transform: rotate(-45deg);
  427. border-radius: 5px 100% 5px 0;
  428. }
  429. .control-top i {
  430. transform: rotate(45deg);
  431. border-radius: 5px 100% 5px 0;
  432. }
  433. .control-top .control-inner {
  434. left: -1px;
  435. bottom: 0;
  436. border-top: 1px solid #78aee4;
  437. border-right: 1px solid #78aee4;
  438. border-radius: 0 100% 0 0;
  439. }
  440. .control-top .fa {
  441. transform: rotate(45deg) translateY(-7px);
  442. }
  443. .control-left {
  444. top: 27%;
  445. left: -8%;
  446. transform: rotate(45deg);
  447. border-radius: 5px 0 5px 100%;
  448. }
  449. .control-left i {
  450. transform: rotate(-45deg);
  451. }
  452. .control-left .control-inner {
  453. right: -1px;
  454. top: -1px;
  455. border-bottom: 1px solid #78aee4;
  456. border-left: 1px solid #78aee4;
  457. border-radius: 0 0 0 100%;
  458. }
  459. .control-left .fa {
  460. transform: rotate(-45deg) translateX(-7px);
  461. }
  462. .control-right {
  463. top: 27%;
  464. right: -8%;
  465. transform: rotate(45deg);
  466. border-radius: 5px 100% 5px 0;
  467. }
  468. .control-right i {
  469. transform: rotate(-45deg);
  470. }
  471. .control-right .control-inner {
  472. left: -1px;
  473. bottom: -1px;
  474. border-top: 1px solid #78aee4;
  475. border-right: 1px solid #78aee4;
  476. border-radius: 0 100% 0 0;
  477. }
  478. .control-right .fa {
  479. transform: rotate(-45deg) translateX(7px);
  480. }
  481. .control-bottom {
  482. left: 27%;
  483. bottom: -8%;
  484. transform: rotate(45deg);
  485. border-radius: 0 5px 100% 5px;
  486. }
  487. .control-bottom i {
  488. transform: rotate(-45deg);
  489. }
  490. .control-bottom .control-inner {
  491. top: -1px;
  492. left: -1px;
  493. border-bottom: 1px solid #78aee4;
  494. border-right: 1px solid #78aee4;
  495. border-radius: 0 0 100% 0;
  496. }
  497. .control-bottom .fa {
  498. transform: rotate(-45deg) translateY(7px);
  499. }
  500. </style>