pushStreamEdit.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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="edit"></el-input>
  19. </el-form-item>
  20. <el-form-item label="流ID" prop="stream">
  21. <el-input v-model="proxyParam.stream" clearable :disabled="edit"></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 label="经度" prop="longitude" v-if="proxyParam.gbId">
  27. <el-input v-model="proxyParam.longitude" placeholder="经度" clearable></el-input>
  28. </el-form-item>
  29. <el-form-item label="纬度" prop="latitude" v-if="proxyParam.gbId">
  30. <el-input v-model="proxyParam.latitude" placeholder="经度" clearable></el-input>
  31. </el-form-item>
  32. <el-form-item>
  33. <div style="float: right;">
  34. <el-button type="primary" @click="onSubmit">保存</el-button>
  35. <el-button @click="close">取消</el-button>
  36. </div>
  37. </el-form-item>
  38. </el-form>
  39. </div>
  40. </el-dialog>
  41. </div>
  42. </template>
  43. <script>
  44. export default {
  45. name: "pushStreamEdit",
  46. props: {},
  47. computed: {},
  48. created() {},
  49. data() {
  50. // var deviceGBIdRules = async (rule, value, callback) => {
  51. // console.log(value);
  52. // if (value === "") {
  53. // callback(new Error("请输入设备国标编号"));
  54. // } else {
  55. // var exit = await this.deviceGBIdExit(value);
  56. // console.log(exit);
  57. // console.log(exit == "true");
  58. // console.log(exit === "true");
  59. // if (exit) {
  60. // callback(new Error("设备国标编号已存在"));
  61. // } else {
  62. // callback();
  63. // }
  64. // }
  65. // };
  66. return {
  67. listChangeCallback: null,
  68. showDialog: false,
  69. isLoging: false,
  70. edit: false,
  71. proxyParam: {
  72. name: null,
  73. app: null,
  74. stream: null,
  75. gbId: null,
  76. longitude: null,
  77. latitude: null,
  78. },
  79. rules: {
  80. name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  81. app: [{ required: true, message: "请输入应用名", trigger: "blur" }],
  82. stream: [{ required: true, message: "请输入流ID", trigger: "blur" }],
  83. gbId: [{ required: true, message: "请输入国标编码", trigger: "blur" }],
  84. },
  85. };
  86. },
  87. methods: {
  88. openDialog: function (proxyParam, callback) {
  89. this.showDialog = true;
  90. this.listChangeCallback = callback;
  91. if (proxyParam != null) {
  92. this.proxyParam = proxyParam;
  93. this.edit = true
  94. }else{
  95. this.proxyParam= {
  96. name: null,
  97. app: null,
  98. stream: null,
  99. gbId: null,
  100. longitude: null,
  101. latitude: null,
  102. }
  103. this.edit = false
  104. }
  105. },
  106. onSubmit: function () {
  107. console.log("onSubmit");
  108. if (this.edit) {
  109. this.$axios({
  110. method:"post",
  111. url:`/api/push/save_to_gb`,
  112. data: this.proxyParam
  113. }).then( (res) => {
  114. if (res.data.code === 0) {
  115. this.$message({
  116. showClose: true,
  117. message: "保存成功",
  118. type: "success",
  119. });
  120. this.showDialog = false;
  121. if (this.listChangeCallback != null) {
  122. this.listChangeCallback();
  123. }
  124. }
  125. }).catch((error)=> {
  126. console.log(error);
  127. });
  128. }else {
  129. this.$axios({
  130. method:"post",
  131. url:`/api/push/add`,
  132. data: this.proxyParam
  133. }).then( (res) => {
  134. if (res.data.code === 0) {
  135. this.$message({
  136. showClose: true,
  137. message: "保存成功",
  138. type: "success",
  139. });
  140. this.showDialog = false;
  141. if (this.listChangeCallback != null) {
  142. this.listChangeCallback();
  143. }
  144. }
  145. }).catch((error)=> {
  146. console.log(error);
  147. });
  148. }
  149. },
  150. close: function () {
  151. console.log("关闭加入GB");
  152. this.showDialog = false;
  153. this.$refs.streamProxy.resetFields();
  154. },
  155. deviceGBIdExit: async function (deviceGbId) {
  156. var result = false;
  157. var that = this;
  158. await that.$axios({
  159. method:"get",
  160. url:`/api/platform/exit/${deviceGbId}`
  161. }).then(function (res) {
  162. result = res.data;
  163. }).catch(function (error) {
  164. console.log(error);
  165. });
  166. return result;
  167. },
  168. checkExpires: function() {
  169. if (this.platform.enable && this.platform.expires == "0") {
  170. this.platform.expires = "300";
  171. }
  172. },
  173. handleNodeClick: function (node){
  174. }
  175. },
  176. };
  177. </script>