platformEdit.vue 12 KB

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