platformEdit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  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="treeType" >
  82. <el-select v-model="platform.treeType" style="width: 100%" @change="treeTypeChange">
  83. <el-option key="WGS84" label="行政区划" value="CivilCode"></el-option>
  84. <el-option key="GCJ02" label="业务分组" value="BusinessGroup"></el-option>
  85. </el-select>
  86. </el-form-item>
  87. <el-form-item label="字符集" prop="characterSet">
  88. <el-select
  89. v-model="platform.characterSet"
  90. style="width: 100%"
  91. placeholder="请选择字符集"
  92. >
  93. <el-option label="GB2312" value="GB2312"></el-option>
  94. <el-option label="UTF-8" value="UTF-8"></el-option>
  95. </el-select>
  96. </el-form-item>
  97. <el-form-item label="其他选项">
  98. <el-checkbox label="启用" v-model="platform.enable" @change="checkExpires"></el-checkbox>
  99. <!-- <el-checkbox label="云台控制" v-model="platform.ptz"></el-checkbox>-->
  100. <el-checkbox label="拉起离线推流" v-model="platform.startOfflinePush"></el-checkbox>
  101. <el-checkbox label="RTCP保活" v-model="platform.rtcp" @change="rtcpCheckBoxChange"></el-checkbox>
  102. <el-checkbox label="作为消息通道" v-model="platform.asMessageChannel" ></el-checkbox>
  103. </el-form-item>
  104. <el-form-item>
  105. <el-button type="primary" @click="onSubmit">{{
  106. onSubmit_text
  107. }}</el-button>
  108. <el-button @click="close">取消</el-button>
  109. </el-form-item>
  110. </el-form>
  111. </el-col>
  112. </el-row>
  113. </div>
  114. </el-dialog>
  115. </div>
  116. </template>
  117. <script>
  118. export default {
  119. name: "platformEdit",
  120. props: {},
  121. computed: {},
  122. data() {
  123. var deviceGBIdRules = async (rule, value, callback) => {
  124. console.log(value);
  125. if (value === "") {
  126. callback(new Error("请输入设备国标编号"));
  127. } else {
  128. var exit = await this.deviceGBIdExit(value);
  129. if (exit) {
  130. callback(new Error("设备国标编号已存在"));
  131. } else {
  132. callback();
  133. }
  134. }
  135. };
  136. return {
  137. listChangeCallback: null,
  138. showDialog: false,
  139. isLoging: false,
  140. onSubmit_text: "立即创建",
  141. saveUrl: "/api/platform/save",
  142. platform: {
  143. id: null,
  144. enable: true,
  145. ptz: true,
  146. rtcp: false,
  147. asMessageChannel: false,
  148. name: null,
  149. serverGBId: null,
  150. serverGBDomain: null,
  151. serverIP: null,
  152. serverPort: null,
  153. deviceGBId: null,
  154. deviceIp: null,
  155. devicePort: null,
  156. username: null,
  157. password: null,
  158. expires: 3600,
  159. keepTimeout: 60,
  160. transport: "UDP",
  161. characterSet: "GB2312",
  162. startOfflinePush: false,
  163. catalogGroup: 1,
  164. administrativeDivision: null,
  165. treeType: "BusinessGroup",
  166. },
  167. rules: {
  168. name: [{ required: true, message: "请输入平台名称", trigger: "blur" }],
  169. serverGBId: [
  170. { required: true, message: "请输入SIP服务国标编码", trigger: "blur" },
  171. ],
  172. serverGBDomain: [
  173. { required: true, message: "请输入SIP服务国标域", trigger: "blur" },
  174. ],
  175. serverIP: [{ required: true, message: "请输入SIP服务IP", trigger: "blur" }],
  176. serverPort: [{ required: true, message: "请输入SIP服务端口", trigger: "blur" }],
  177. deviceGBId: [{ validator: deviceGBIdRules, trigger: "blur" }],
  178. username: [{ required: false, message: "请输入SIP认证用户名", trigger: "blur" }],
  179. password: [{ required: false, message: "请输入SIP认证密码", trigger: "blur" }],
  180. expires: [{ required: true, message: "请输入注册周期", trigger: "blur" }],
  181. keepTimeout: [{ required: true, message: "请输入心跳周期", trigger: "blur" }],
  182. transport: [{ required: true, message: "请选择信令传输", trigger: "blur" }],
  183. characterSet: [{ required: true, message: "请选择编码字符集", trigger: "blur" }],
  184. },
  185. };
  186. },
  187. methods: {
  188. openDialog: function (platform, callback) {
  189. var that = this;
  190. if (platform == null) {
  191. this.onSubmit_text = "立即创建";
  192. this.saveUrl = "/api/platform/add";
  193. this.$axios({
  194. method: 'get',
  195. url:`/api/platform/server_config`
  196. }).then(function (res) {
  197. console.log(res);
  198. if (res.data.code === 0) {
  199. that.platform.deviceGBId = res.data.data.username;
  200. that.platform.deviceIp = res.data.data.deviceIp;
  201. that.platform.devicePort = res.data.data.devicePort;
  202. that.platform.username = res.data.data.username;
  203. that.platform.password = res.data.data.password;
  204. that.platform.treeType = "BusinessGroup";
  205. that.platform.administrativeDivision = res.data.data.username.substr(0, 6);
  206. }
  207. }).catch(function (error) {
  208. console.log(error);
  209. });
  210. }else {
  211. this.platform.id = platform.id;
  212. this.platform.enable = platform.enable;
  213. this.platform.ptz = platform.ptz;
  214. this.platform.rtcp = platform.rtcp;
  215. this.platform.asMessageChannel = platform.asMessageChannel;
  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.administrativeDivision = platform.administrativeDivision;
  234. this.platform.treeType = platform.treeType;
  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. name: null,
  293. serverGBId: null,
  294. administrativeDivision: null,
  295. serverGBDomain: null,
  296. serverIP: null,
  297. serverPort: null,
  298. deviceGBId: null,
  299. deviceIp: null,
  300. devicePort: null,
  301. username: null,
  302. password: null,
  303. expires: 3600,
  304. keepTimeout: 60,
  305. transport: "UDP",
  306. characterSet: "GB2312",
  307. treeType: "BusinessGroup",
  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. treeTypeChange: function (){
  343. this.$message({
  344. showClose: true,
  345. message: "修改目录结构会导致关联目录与通道数据被清空,保存后生效",
  346. type: "warning",
  347. });
  348. }
  349. },
  350. };
  351. </script>
  352. <style>
  353. /* 谷歌 */
  354. input::-webkit-outer-spin-button,
  355. input::-webkit-inner-spin-button {
  356. -webkit-appearance: none;
  357. appearance: none;
  358. margin: 0;
  359. }
  360. /* 火狐 */
  361. input{
  362. -moz-appearance:textfield;
  363. }
  364. .control-wrapper-not-used {
  365. position: relative;
  366. width: 6.25rem;
  367. height: 6.25rem;
  368. max-width: 6.25rem;
  369. max-height: 6.25rem;
  370. border-radius: 100%;
  371. margin-top: 2.5rem;
  372. margin-left: 0.5rem;
  373. float: left;
  374. }
  375. .control-panel {
  376. position: relative;
  377. top: 0;
  378. left: 5rem;
  379. height: 11rem;
  380. max-height: 11rem;
  381. }
  382. .control-btn {
  383. display: flex;
  384. justify-content: center;
  385. position: absolute;
  386. width: 44%;
  387. height: 44%;
  388. border-radius: 5px;
  389. border: 1px solid #78aee4;
  390. box-sizing: border-box;
  391. transition: all 0.3s linear;
  392. }
  393. .control-btn i {
  394. font-size: 20px;
  395. color: #78aee4;
  396. display: flex;
  397. justify-content: center;
  398. align-items: center;
  399. }
  400. .control-round {
  401. position: absolute;
  402. top: 21%;
  403. left: 21%;
  404. width: 58%;
  405. height: 58%;
  406. background: #fff;
  407. border-radius: 100%;
  408. }
  409. .control-round-inner {
  410. position: absolute;
  411. left: 13%;
  412. top: 13%;
  413. display: flex;
  414. justify-content: center;
  415. align-items: center;
  416. width: 70%;
  417. height: 70%;
  418. font-size: 40px;
  419. color: #78aee4;
  420. border: 1px solid #78aee4;
  421. border-radius: 100%;
  422. transition: all 0.3s linear;
  423. }
  424. .control-inner-btn {
  425. position: absolute;
  426. width: 60%;
  427. height: 60%;
  428. background: #fafafa;
  429. }
  430. .control-top {
  431. top: -8%;
  432. left: 27%;
  433. transform: rotate(-45deg);
  434. border-radius: 5px 100% 5px 0;
  435. }
  436. .control-top i {
  437. transform: rotate(45deg);
  438. border-radius: 5px 100% 5px 0;
  439. }
  440. .control-top .control-inner {
  441. left: -1px;
  442. bottom: 0;
  443. border-top: 1px solid #78aee4;
  444. border-right: 1px solid #78aee4;
  445. border-radius: 0 100% 0 0;
  446. }
  447. .control-top .fa {
  448. transform: rotate(45deg) translateY(-7px);
  449. }
  450. .control-left {
  451. top: 27%;
  452. left: -8%;
  453. transform: rotate(45deg);
  454. border-radius: 5px 0 5px 100%;
  455. }
  456. .control-left i {
  457. transform: rotate(-45deg);
  458. }
  459. .control-left .control-inner {
  460. right: -1px;
  461. top: -1px;
  462. border-bottom: 1px solid #78aee4;
  463. border-left: 1px solid #78aee4;
  464. border-radius: 0 0 0 100%;
  465. }
  466. .control-left .fa {
  467. transform: rotate(-45deg) translateX(-7px);
  468. }
  469. .control-right {
  470. top: 27%;
  471. right: -8%;
  472. transform: rotate(45deg);
  473. border-radius: 5px 100% 5px 0;
  474. }
  475. .control-right i {
  476. transform: rotate(-45deg);
  477. }
  478. .control-right .control-inner {
  479. left: -1px;
  480. bottom: -1px;
  481. border-top: 1px solid #78aee4;
  482. border-right: 1px solid #78aee4;
  483. border-radius: 0 100% 0 0;
  484. }
  485. .control-right .fa {
  486. transform: rotate(-45deg) translateX(7px);
  487. }
  488. .control-bottom {
  489. left: 27%;
  490. bottom: -8%;
  491. transform: rotate(45deg);
  492. border-radius: 0 5px 100% 5px;
  493. }
  494. .control-bottom i {
  495. transform: rotate(-45deg);
  496. }
  497. .control-bottom .control-inner {
  498. top: -1px;
  499. left: -1px;
  500. border-bottom: 1px solid #78aee4;
  501. border-right: 1px solid #78aee4;
  502. border-radius: 0 0 100% 0;
  503. }
  504. .control-bottom .fa {
  505. transform: rotate(-45deg) translateY(7px);
  506. }
  507. </style>