platformEdit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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></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></el-input>
  30. </el-form-item>
  31. <el-form-item label="设备国标编号" prop="deviceGBId">
  32. <el-input v-model="platform.deviceGBId" clearable></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"></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="RTCP保活" v-model="platform.rtcp"></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. created() {},
  100. data() {
  101. var deviceGBIdRules = async (rule, value, callback) => {
  102. console.log(value);
  103. if (value === "") {
  104. callback(new Error("请输入设备国标编号"));
  105. } else {
  106. var exit = await this.deviceGBIdExit(value);
  107. if (exit) {
  108. callback(new Error("设备国标编号已存在"));
  109. } else {
  110. callback();
  111. }
  112. }
  113. };
  114. return {
  115. listChangeCallback: null,
  116. showDialog: false,
  117. isLoging: false,
  118. onSubmit_text: "立即创建",
  119. platform: {
  120. id: null,
  121. enable: true,
  122. ptz: true,
  123. rtcp: false,
  124. name: null,
  125. serverGBId: null,
  126. serverGBDomain: null,
  127. serverIP: null,
  128. serverPort: null,
  129. deviceGBId: null,
  130. deviceIp: null,
  131. devicePort: null,
  132. username: null,
  133. password: null,
  134. expires: 300,
  135. keepTimeout: 60,
  136. transport: "UDP",
  137. characterSet: "GB2312",
  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 = platform;
  179. this.onSubmit_text = "保存";
  180. }
  181. this.showDialog = true;
  182. this.listChangeCallback = callback;
  183. },
  184. onSubmit: function () {
  185. console.log("onSubmit");
  186. var that = this;
  187. that.$axios({
  188. method: 'post',
  189. url:`/api/platform/save`,
  190. data: that.platform
  191. }).then(function (res) {
  192. if (res.data == "success") {
  193. that.$message({
  194. showClose: true,
  195. message: "保存成功",
  196. type: "success",
  197. });
  198. that.showDialog = false;
  199. if (that.listChangeCallback != null) {
  200. that.listChangeCallback();
  201. }
  202. }
  203. }).catch(function (error) {
  204. console.log(error);
  205. });
  206. },
  207. close: function () {
  208. console.log("关闭添加视频平台");
  209. this.showDialog = false;
  210. this.$refs.platform1.resetFields();
  211. this.$refs.platform2.resetFields();
  212. },
  213. deviceGBIdExit: async function (deviceGbId) {
  214. var result = false;
  215. var that = this;
  216. await that.$axios({
  217. method: 'post',
  218. url:`/api/platform/exit/${deviceGbId}`})
  219. .then(function (res) {
  220. result = res.data;
  221. })
  222. .catch(function (error) {
  223. console.log(error);
  224. });
  225. return result;
  226. },
  227. checkExpires: function() {
  228. if (this.platform.enable && this.platform.expires == "0") {
  229. this.platform.expires = "300";
  230. }
  231. }
  232. },
  233. };
  234. </script>
  235. <style>
  236. .control-wrapper-not-used {
  237. position: relative;
  238. width: 6.25rem;
  239. height: 6.25rem;
  240. max-width: 6.25rem;
  241. max-height: 6.25rem;
  242. border-radius: 100%;
  243. margin-top: 2.5rem;
  244. margin-left: 0.5rem;
  245. float: left;
  246. }
  247. .control-panel {
  248. position: relative;
  249. top: 0;
  250. left: 5rem;
  251. height: 11rem;
  252. max-height: 11rem;
  253. }
  254. .control-btn {
  255. display: flex;
  256. justify-content: center;
  257. position: absolute;
  258. width: 44%;
  259. height: 44%;
  260. border-radius: 5px;
  261. border: 1px solid #78aee4;
  262. box-sizing: border-box;
  263. transition: all 0.3s linear;
  264. }
  265. .control-btn i {
  266. font-size: 20px;
  267. color: #78aee4;
  268. display: flex;
  269. justify-content: center;
  270. align-items: center;
  271. }
  272. .control-round {
  273. position: absolute;
  274. top: 21%;
  275. left: 21%;
  276. width: 58%;
  277. height: 58%;
  278. background: #fff;
  279. border-radius: 100%;
  280. }
  281. .control-round-inner {
  282. position: absolute;
  283. left: 13%;
  284. top: 13%;
  285. display: flex;
  286. justify-content: center;
  287. align-items: center;
  288. width: 70%;
  289. height: 70%;
  290. font-size: 40px;
  291. color: #78aee4;
  292. border: 1px solid #78aee4;
  293. border-radius: 100%;
  294. transition: all 0.3s linear;
  295. }
  296. .control-inner-btn {
  297. position: absolute;
  298. width: 60%;
  299. height: 60%;
  300. background: #fafafa;
  301. }
  302. .control-top {
  303. top: -8%;
  304. left: 27%;
  305. transform: rotate(-45deg);
  306. border-radius: 5px 100% 5px 0;
  307. }
  308. .control-top i {
  309. transform: rotate(45deg);
  310. border-radius: 5px 100% 5px 0;
  311. }
  312. .control-top .control-inner {
  313. left: -1px;
  314. bottom: 0;
  315. border-top: 1px solid #78aee4;
  316. border-right: 1px solid #78aee4;
  317. border-radius: 0 100% 0 0;
  318. }
  319. .control-top .fa {
  320. transform: rotate(45deg) translateY(-7px);
  321. }
  322. .control-left {
  323. top: 27%;
  324. left: -8%;
  325. transform: rotate(45deg);
  326. border-radius: 5px 0 5px 100%;
  327. }
  328. .control-left i {
  329. transform: rotate(-45deg);
  330. }
  331. .control-left .control-inner {
  332. right: -1px;
  333. top: -1px;
  334. border-bottom: 1px solid #78aee4;
  335. border-left: 1px solid #78aee4;
  336. border-radius: 0 0 0 100%;
  337. }
  338. .control-left .fa {
  339. transform: rotate(-45deg) translateX(-7px);
  340. }
  341. .control-right {
  342. top: 27%;
  343. right: -8%;
  344. transform: rotate(45deg);
  345. border-radius: 5px 100% 5px 0;
  346. }
  347. .control-right i {
  348. transform: rotate(-45deg);
  349. }
  350. .control-right .control-inner {
  351. left: -1px;
  352. bottom: -1px;
  353. border-top: 1px solid #78aee4;
  354. border-right: 1px solid #78aee4;
  355. border-radius: 0 100% 0 0;
  356. }
  357. .control-right .fa {
  358. transform: rotate(-45deg) translateX(7px);
  359. }
  360. .control-bottom {
  361. left: 27%;
  362. bottom: -8%;
  363. transform: rotate(45deg);
  364. border-radius: 0 5px 100% 5px;
  365. }
  366. .control-bottom i {
  367. transform: rotate(-45deg);
  368. }
  369. .control-bottom .control-inner {
  370. top: -1px;
  371. left: -1px;
  372. border-bottom: 1px solid #78aee4;
  373. border-right: 1px solid #78aee4;
  374. border-radius: 0 0 100% 0;
  375. }
  376. .control-bottom .fa {
  377. transform: rotate(-45deg) translateY(7px);
  378. }
  379. </style>