platformEdit.vue 16 KB

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