platformEdit.vue 13 KB

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