platformEdit.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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" type="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"></el-checkbox>
  78. <el-checkbox label="云台控制" v-model="platform.PTZEnable"></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. console.log(exit);
  108. console.log(exit == "true");
  109. console.log(exit === "true");
  110. if (exit) {
  111. callback(new Error("设备国标编号已存在"));
  112. } else {
  113. callback();
  114. }
  115. }
  116. };
  117. return {
  118. listChangeCallback: null,
  119. showDialog: false,
  120. isLoging: false,
  121. onSubmit_text: "立即创建",
  122. // platform: {
  123. // enable: false,
  124. // PTZEnable: true,
  125. // rtcp: false,
  126. // name: null,
  127. // serverGBId: null,
  128. // serverGBDomain: null,
  129. // serverIP: null,
  130. // serverPort: null,
  131. // deviceGBId: null,
  132. // deviceIp: null,
  133. // devicePort: null,
  134. // username: null,
  135. // password: null,
  136. // expires: 300,
  137. // keepTimeout: 60,
  138. // transport: "UDP",
  139. // characterSet: "GB2312",
  140. // },
  141. platform: {
  142. enable: true,
  143. PTZEnable: true,
  144. rtcp: false,
  145. name: "测试001",
  146. serverGBId: "34020000002000000001",
  147. serverGBDomain: "3402000000",
  148. serverIP: "192.168.1.141",
  149. serverPort: "5060",
  150. deviceGBId: "34020000001320001101",
  151. deviceIp: "192.168.1.20",
  152. devicePort: "5060",
  153. username: "34020000001320001101",
  154. password: "12345678",
  155. expires: 300,
  156. keepTimeout: 60,
  157. transport: "UDP",
  158. characterSet: "GB2312",
  159. },
  160. rules: {
  161. name: [{ required: true, message: "请输入平台名称", trigger: "blur" }],
  162. serverGBId: [
  163. { required: true, message: "请输入SIP服务国标编码", trigger: "blur" },
  164. ],
  165. serverGBDomain: [
  166. { required: true, message: "请输入SIP服务国标域", trigger: "blur" },
  167. ],
  168. serverIP: [{ required: true, message: "请输入SIP服务IP", trigger: "blur" }],
  169. serverPort: [{ required: true, message: "请输入SIP服务端口", trigger: "blur" }],
  170. deviceGBId: [{ validator: deviceGBIdRules, trigger: "blur" }],
  171. username: [{ required: false, message: "请输入SIP认证用户名", trigger: "blur" }],
  172. password: [{ required: false, message: "请输入SIP认证密码", trigger: "blur" }],
  173. expires: [{ required: true, message: "请输入注册周期", trigger: "blur" }],
  174. keepTimeout: [{ required: true, message: "请输入心跳周期", trigger: "blur" }],
  175. transport: [{ required: true, message: "请选择信令传输", trigger: "blur" }],
  176. characterSet: [{ required: true, message: "请选择编码字符集", trigger: "blur" }],
  177. },
  178. };
  179. },
  180. methods: {
  181. openDialog: function (platform, callback) {
  182. var that = this;
  183. this.$axios
  184. .get(`/api/platforms/serverconfig`)
  185. .then(function (res) {
  186. console.log(res);
  187. that.platform.deviceGBId = res.data.username;
  188. that.platform.deviceIp = res.data.deviceIp;
  189. that.platform.devicePort = res.data.devicePort;
  190. that.platform.username = res.data.username;
  191. that.platform.password = res.data.password;
  192. })
  193. .catch(function (error) {
  194. console.log(error);
  195. });
  196. this.showDialog = true;
  197. this.listChangeCallback = callback;
  198. if (platform != null) {
  199. this.platform = platform;
  200. this.onSubmit_text = "保存";
  201. } else {
  202. }
  203. },
  204. onSubmit: function () {
  205. console.log("onSubmit");
  206. var that = this;
  207. that.$axios
  208. .post(`/api/platforms/save`, that.platform)
  209. .then(function (res) {
  210. console.log(res);
  211. console.log(res.data == "success");
  212. if (res.data == "success") {
  213. that.$message({
  214. showClose: true,
  215. message: "保存成功",
  216. type: "success",
  217. });
  218. that.showDialog = false;
  219. if (that.listChangeCallback != null) {
  220. that.listChangeCallback();
  221. }
  222. }
  223. })
  224. .catch(function (error) {
  225. console.log(error);
  226. });
  227. },
  228. close: function () {
  229. console.log("关闭添加视频平台");
  230. this.showDialog = false;
  231. this.$refs.platform1.resetFields();
  232. this.$refs.platform2.resetFields();
  233. },
  234. deviceGBIdExit: async function (deviceGbId) {
  235. var result = false;
  236. var that = this;
  237. await that.$axios
  238. .post(`/api/platforms/exit/${deviceGbId}`)
  239. .then(function (res) {
  240. result = res.data;
  241. })
  242. .catch(function (error) {
  243. console.log(error);
  244. });
  245. return result;
  246. },
  247. },
  248. };
  249. </script>
  250. <style>
  251. .control-wrapper-not-used {
  252. position: relative;
  253. width: 6.25rem;
  254. height: 6.25rem;
  255. max-width: 6.25rem;
  256. max-height: 6.25rem;
  257. border-radius: 100%;
  258. margin-top: 2.5rem;
  259. margin-left: 0.5rem;
  260. float: left;
  261. }
  262. .control-panel {
  263. position: relative;
  264. top: 0;
  265. left: 5rem;
  266. height: 11rem;
  267. max-height: 11rem;
  268. }
  269. .control-btn {
  270. display: flex;
  271. justify-content: center;
  272. position: absolute;
  273. width: 44%;
  274. height: 44%;
  275. border-radius: 5px;
  276. border: 1px solid #78aee4;
  277. box-sizing: border-box;
  278. transition: all 0.3s linear;
  279. }
  280. .control-btn i {
  281. font-size: 20px;
  282. color: #78aee4;
  283. display: flex;
  284. justify-content: center;
  285. align-items: center;
  286. }
  287. .control-round {
  288. position: absolute;
  289. top: 21%;
  290. left: 21%;
  291. width: 58%;
  292. height: 58%;
  293. background: #fff;
  294. border-radius: 100%;
  295. }
  296. .control-round-inner {
  297. position: absolute;
  298. left: 13%;
  299. top: 13%;
  300. display: flex;
  301. justify-content: center;
  302. align-items: center;
  303. width: 70%;
  304. height: 70%;
  305. font-size: 40px;
  306. color: #78aee4;
  307. border: 1px solid #78aee4;
  308. border-radius: 100%;
  309. transition: all 0.3s linear;
  310. }
  311. .control-inner-btn {
  312. position: absolute;
  313. width: 60%;
  314. height: 60%;
  315. background: #fafafa;
  316. }
  317. .control-top {
  318. top: -8%;
  319. left: 27%;
  320. transform: rotate(-45deg);
  321. border-radius: 5px 100% 5px 0;
  322. }
  323. .control-top i {
  324. transform: rotate(45deg);
  325. border-radius: 5px 100% 5px 0;
  326. }
  327. .control-top .control-inner {
  328. left: -1px;
  329. bottom: 0;
  330. border-top: 1px solid #78aee4;
  331. border-right: 1px solid #78aee4;
  332. border-radius: 0 100% 0 0;
  333. }
  334. .control-top .fa {
  335. transform: rotate(45deg) translateY(-7px);
  336. }
  337. .control-left {
  338. top: 27%;
  339. left: -8%;
  340. transform: rotate(45deg);
  341. border-radius: 5px 0 5px 100%;
  342. }
  343. .control-left i {
  344. transform: rotate(-45deg);
  345. }
  346. .control-left .control-inner {
  347. right: -1px;
  348. top: -1px;
  349. border-bottom: 1px solid #78aee4;
  350. border-left: 1px solid #78aee4;
  351. border-radius: 0 0 0 100%;
  352. }
  353. .control-left .fa {
  354. transform: rotate(-45deg) translateX(-7px);
  355. }
  356. .control-right {
  357. top: 27%;
  358. right: -8%;
  359. transform: rotate(45deg);
  360. border-radius: 5px 100% 5px 0;
  361. }
  362. .control-right i {
  363. transform: rotate(-45deg);
  364. }
  365. .control-right .control-inner {
  366. left: -1px;
  367. bottom: -1px;
  368. border-top: 1px solid #78aee4;
  369. border-right: 1px solid #78aee4;
  370. border-radius: 0 100% 0 0;
  371. }
  372. .control-right .fa {
  373. transform: rotate(-45deg) translateX(7px);
  374. }
  375. .control-bottom {
  376. left: 27%;
  377. bottom: -8%;
  378. transform: rotate(45deg);
  379. border-radius: 0 5px 100% 5px;
  380. }
  381. .control-bottom i {
  382. transform: rotate(-45deg);
  383. }
  384. .control-bottom .control-inner {
  385. top: -1px;
  386. left: -1px;
  387. border-bottom: 1px solid #78aee4;
  388. border-right: 1px solid #78aee4;
  389. border-radius: 0 0 100% 0;
  390. }
  391. .control-bottom .fa {
  392. transform: rotate(-45deg) translateY(7px);
  393. }
  394. </style>