platformEdit.vue 16 KB

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