platformEdit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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>
  41. </el-col>
  42. <el-col :span="12">
  43. <el-form ref="platform2" :rules="rules" :model="platform" label-width="160px">
  44. <el-form-item label="SIP认证用户名" prop="username">
  45. <el-input v-model="platform.username"></el-input>
  46. </el-form-item>
  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%" >
  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.shareAllLiveStream"></el-checkbox>
  101. <el-checkbox label="拉起离线推流" v-model="platform.startOfflinePush"></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. shareAllLiveStream: false,
  161. startOfflinePush: false,
  162. catalogGroup: 1,
  163. administrativeDivision: null,
  164. treeType: "BusinessGroup",
  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. that.platform.deviceGBId = res.data.username;
  198. that.platform.deviceIp = res.data.deviceIp;
  199. that.platform.devicePort = res.data.devicePort;
  200. that.platform.username = res.data.username;
  201. that.platform.password = res.data.password;
  202. that.platform.treeType = res.data.treeType;
  203. that.platform.administrativeDivision = res.data.username.substr(0, 6);
  204. }).catch(function (error) {
  205. console.log(error);
  206. });
  207. }else {
  208. this.platform.id = platform.id;
  209. this.platform.enable = platform.enable;
  210. this.platform.ptz = platform.ptz;
  211. this.platform.rtcp = platform.rtcp;
  212. this.platform.name = platform.name;
  213. this.platform.serverGBId = platform.serverGBId;
  214. this.platform.serverGBDomain = platform.serverGBDomain;
  215. this.platform.serverIP = platform.serverIP;
  216. this.platform.serverPort = platform.serverPort;
  217. this.platform.deviceGBId = platform.deviceGBId;
  218. this.platform.deviceIp = platform.deviceIp;
  219. this.platform.devicePort = platform.devicePort;
  220. this.platform.username = platform.username;
  221. this.platform.password = platform.password;
  222. this.platform.expires = platform.expires;
  223. this.platform.keepTimeout = platform.keepTimeout;
  224. this.platform.transport = platform.transport;
  225. this.platform.characterSet = platform.characterSet;
  226. this.platform.shareAllLiveStream = platform.shareAllLiveStream;
  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. if (this.onSubmit_text === "保存") {
  251. this.$confirm("修改目录结构会导致关联目录与通道数据被清空", '提示', {
  252. dangerouslyUseHTMLString: true,
  253. confirmButtonText: '确定',
  254. cancelButtonText: '取消',
  255. center: true,
  256. type: 'warning'
  257. }).then(() => {
  258. this.saveForm()
  259. }).catch(() => {
  260. });
  261. }else {
  262. this.saveForm()
  263. }
  264. },
  265. saveForm: function (){
  266. var that = this;
  267. that.$axios({
  268. method: 'post',
  269. url: this.saveUrl,
  270. data: that.platform
  271. }).then(function (res) {
  272. if (res.data.code === 0) {
  273. that.$message({
  274. showClose: true,
  275. message: "保存成功",
  276. type: "success",
  277. });
  278. that.showDialog = false;
  279. if (that.listChangeCallback != null) {
  280. that.listChangeCallback();
  281. }
  282. }else {
  283. that.$message({
  284. showClose: true,
  285. message: res.data.msg,
  286. type: "error",
  287. });
  288. }
  289. }).catch(function (error) {
  290. console.log(error);
  291. });
  292. },
  293. close: function () {
  294. this.showDialog = false;
  295. this.$refs.platform1.resetFields();
  296. this.$refs.platform2.resetFields();
  297. this.platform = {
  298. id: null,
  299. enable: true,
  300. ptz: true,
  301. rtcp: false,
  302. name: null,
  303. serverGBId: null,
  304. administrativeDivision: null,
  305. serverGBDomain: null,
  306. serverIP: null,
  307. serverPort: null,
  308. deviceGBId: null,
  309. deviceIp: null,
  310. devicePort: null,
  311. username: null,
  312. password: null,
  313. expires: 300,
  314. keepTimeout: 60,
  315. transport: "UDP",
  316. characterSet: "GB2312",
  317. treeType: "BusinessGroup",
  318. shareAllLiveStream: false,
  319. startOfflinePush: false,
  320. catalogGroup: 1,
  321. }
  322. },
  323. deviceGBIdExit: async function (deviceGbId) {
  324. var result = false;
  325. var that = this;
  326. await that.$axios({
  327. method: 'post',
  328. url:`/api/platform/exit/${deviceGbId}`})
  329. .then(function (res) {
  330. result = res.data;
  331. })
  332. .catch(function (error) {
  333. console.log(error);
  334. });
  335. return result;
  336. },
  337. checkExpires: function() {
  338. if (this.platform.enable && this.platform.expires == "0") {
  339. this.platform.expires = "300";
  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>