onvifEdit.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <div id="onvif搜索" v-loading="isLoging">
  3. <el-dialog
  4. title="onvif搜索"
  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="form" :rules="rules" :model="form" label-width="140px" >
  14. <el-form-item label="地址" prop="hostName" >
  15. <el-select v-model="form.hostName" style="float: left; width: 100%" >
  16. <el-option
  17. v-for="item in hostNames"
  18. :key="item"
  19. :label="item.replace('http://', '')"
  20. :value="item">
  21. </el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="用户名" prop="username">
  25. <el-input v-model="form.username" clearable></el-input>
  26. </el-form-item>
  27. <el-form-item label="密码" prop="password">
  28. <el-input v-model="form.password" clearable></el-input>
  29. </el-form-item>
  30. <el-form-item>
  31. <div style="float: right;">
  32. <el-button type="primary" @click="onSubmit" >确认</el-button>
  33. <el-button @click="close">取消</el-button>
  34. </div>
  35. </el-form-item>
  36. </el-form>
  37. </div>
  38. </el-dialog>
  39. </div>
  40. </template>
  41. <script>
  42. export default {
  43. name: "onvifEdit",
  44. props: {},
  45. computed: {},
  46. created() {},
  47. data() {
  48. return {
  49. listChangeCallback: null,
  50. showDialog: false,
  51. isLoging: false,
  52. hostNames:[],
  53. form: {
  54. hostName: null,
  55. username: "admin",
  56. password: "admin123",
  57. },
  58. rules: {
  59. hostName: [{ required: true, message: "请选择", trigger: "blur" }],
  60. username: [{ required: true, message: "请输入用户名", trigger: "blur" }],
  61. password: [{ required: true, message: "请输入密码", trigger: "blur" }],
  62. },
  63. };
  64. },
  65. methods: {
  66. openDialog: function (hostNamesParam, callback) {
  67. console.log(hostNamesParam)
  68. this.showDialog = true;
  69. this.listChangeCallback = callback;
  70. if (hostNamesParam != null) {
  71. this.hostNames = hostNamesParam;
  72. }
  73. },
  74. onSubmit: function () {
  75. console.log("onSubmit");
  76. console.log(this.form);
  77. this.$axios({
  78. method: 'get',
  79. url:`api/onvif/rtsp`,
  80. params: {
  81. hostname: this.form.hostName,
  82. timeout: 3000,
  83. username: this.form.username,
  84. password: this.form.password,
  85. }
  86. }).then((res) => {
  87. console.log(res.data)
  88. if (res.data.code == 0) {
  89. if (res.data.data != null) {
  90. this.listChangeCallback(res.data.data)
  91. }else {
  92. this.$message({
  93. showClose: true,
  94. message: res.data.msg,
  95. type: "error",
  96. });
  97. }
  98. }else {
  99. this.$message({
  100. showClose: true,
  101. message: res.data.msg,
  102. type: "error",
  103. });
  104. }
  105. }).catch(function (error) {
  106. console.log(error);
  107. });
  108. },
  109. close: function () {
  110. this.showDialog = false;
  111. this.$refs.form.resetFields();
  112. },
  113. },
  114. };
  115. </script>