platformEdit.vue 16 KB

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