addStreamTOGB.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <div id="addStreamProxy" v-loading="isLoging">
  3. <el-dialog
  4. title=" 加入"
  5. width="40%"
  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="margin-top: 1rem;margin-right: 100px;">
  13. <el-form ref="streamProxy" :rules="rules" :model="proxyParam" label-width="140px">
  14. <el-form-item label="名称" prop="name">
  15. <el-input v-model="proxyParam.name" clearable></el-input>
  16. </el-form-item>
  17. <el-form-item label="流应用名" prop="app">
  18. <el-input v-model="proxyParam.app" clearable :disabled="true"></el-input>
  19. </el-form-item>
  20. <el-form-item label="流ID" prop="stream">
  21. <el-input v-model="proxyParam.stream" clearable :disabled="true"></el-input>
  22. </el-form-item>
  23. <el-form-item label="国标编码" prop="gbId">
  24. <el-input v-model="proxyParam.gbId" placeholder="设置国标编码可推送到国标" clearable></el-input>
  25. </el-form-item>
  26. <el-form-item>
  27. <div style="float: right;">
  28. <el-button type="primary" @click="onSubmit">保存</el-button>
  29. <el-button @click="close">取消</el-button>
  30. </div>
  31. </el-form-item>
  32. </el-form>
  33. </div>
  34. </el-dialog>
  35. </div>
  36. </template>
  37. <script>
  38. export default {
  39. name: "streamProxyEdit",
  40. props: {},
  41. computed: {},
  42. created() {},
  43. data() {
  44. // var deviceGBIdRules = async (rule, value, callback) => {
  45. // console.log(value);
  46. // if (value === "") {
  47. // callback(new Error("请输入设备国标编号"));
  48. // } else {
  49. // var exit = await this.deviceGBIdExit(value);
  50. // console.log(exit);
  51. // console.log(exit == "true");
  52. // console.log(exit === "true");
  53. // if (exit) {
  54. // callback(new Error("设备国标编号已存在"));
  55. // } else {
  56. // callback();
  57. // }
  58. // }
  59. // };
  60. return {
  61. listChangeCallback: null,
  62. showDialog: false,
  63. isLoging: false,
  64. proxyParam: {
  65. name: null,
  66. app: null,
  67. stream: null,
  68. gbId: null,
  69. },
  70. rules: {
  71. name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  72. app: [{ required: true, message: "请输入应用名", trigger: "blur" }],
  73. stream: [{ required: true, message: "请输入流ID", trigger: "blur" }],
  74. gbId: [{ required: true, message: "请输入国标编码", trigger: "blur" }],
  75. },
  76. };
  77. },
  78. methods: {
  79. openDialog: function (proxyParam, callback) {
  80. this.showDialog = true;
  81. this.listChangeCallback = callback;
  82. if (proxyParam != null) {
  83. this.proxyParam = proxyParam;
  84. }
  85. },
  86. onSubmit: function () {
  87. console.log("onSubmit");
  88. var that = this;
  89. that.$axios({
  90. method:"post",
  91. url:`/api/push/save_to_gb`,
  92. data: that.proxyParam
  93. }).then(function (res) {
  94. if (res.data == "success") {
  95. that.$message({
  96. showClose: true,
  97. message: "保存成功",
  98. type: "success",
  99. });
  100. that.showDialog = false;
  101. if (that.listChangeCallback != null) {
  102. that.listChangeCallback();
  103. }
  104. }
  105. }).catch(function (error) {
  106. console.log(error);
  107. });
  108. },
  109. close: function () {
  110. console.log("关闭加入GB");
  111. this.showDialog = false;
  112. this.$refs.streamProxy.resetFields();
  113. },
  114. deviceGBIdExit: async function (deviceGbId) {
  115. var result = false;
  116. var that = this;
  117. await that.$axios({
  118. method:"post",
  119. url:`/api/platform/exit/${deviceGbId}`
  120. }).then(function (res) {
  121. result = res.data;
  122. }).catch(function (error) {
  123. console.log(error);
  124. });
  125. return result;
  126. },
  127. checkExpires: function() {
  128. if (this.platform.enable && this.platform.expires == "0") {
  129. this.platform.expires = "300";
  130. }
  131. }
  132. },
  133. };
  134. </script>