RecordConfigDialog.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <confirm-dialog
  3. ref="configDialog"
  4. :title="title"
  5. @confirm="onSave"
  6. >
  7. <div class="c-grid-form auto u-align-self--center">
  8. <span class="c-grid-form__label">宽度</span>
  9. <el-input-number
  10. v-model="recordConfig.videoWidth"
  11. class="has-info"
  12. data-info="范围:240~7680"
  13. controls-position="right"
  14. :min="240"
  15. :max="7680"
  16. step-strictly
  17. />
  18. <span class="c-grid-form__label">高度</span>
  19. <el-input-number
  20. v-model="recordConfig.videoHeight"
  21. class="has-info"
  22. data-info="范围:240~7680"
  23. controls-position="right"
  24. :min="240"
  25. :max="7680"
  26. step-strictly
  27. />
  28. <span class="c-grid-form__label">码率</span>
  29. <div class="l-flex--row c-grid-form__option">
  30. <el-input-number
  31. v-model="recordConfig.videoBitRate"
  32. controls-position="right"
  33. :min="36"
  34. step-strictly
  35. />
  36. &nbsp;Kbps(最低36Kbps)
  37. </div>
  38. <span class="c-grid-form__label">帧率</span>
  39. <div class="l-flex--row c-grid-form__option">
  40. <el-input-number
  41. v-model="recordConfig.frameRate"
  42. class="has-info"
  43. data-info="范围:1~24"
  44. controls-position="right"
  45. :min="1"
  46. :max="24"
  47. step-strictly
  48. />
  49. &nbsp;1~24
  50. </div>
  51. </div>
  52. </confirm-dialog>
  53. </template>
  54. <script>
  55. import {
  56. getRecordConfig,
  57. addRecordConfig,
  58. updateRecordConfig
  59. } from '@/api/device'
  60. export default {
  61. name: 'RecordConfigDialog',
  62. data () {
  63. return {
  64. title: '',
  65. recordConfig: {}
  66. }
  67. },
  68. methods: {
  69. show ({ id, name }) {
  70. this.title = `${name}推流配置`
  71. const loading = this.$showLoading()
  72. getRecordConfig(id).then(({ data }) => {
  73. if (data) {
  74. this.$has = true
  75. const { videoWidth, videoHeight, videoBitRate, frameRate } = data
  76. this.recordConfig = {
  77. deviceId: id,
  78. videoWidth,
  79. videoHeight,
  80. videoBitRate: videoBitRate / 1024 | 0,
  81. frameRate
  82. }
  83. } else {
  84. this.$has = false
  85. this.recordConfig = {
  86. deviceId: id,
  87. videoWidth: 640,
  88. videoHeight: 360,
  89. videoBitRate: 36,
  90. frameRate: 1
  91. }
  92. }
  93. this.$refs.configDialog.show()
  94. }).finally(() => {
  95. this.$closeLoading(loading)
  96. })
  97. },
  98. onSave (done) {
  99. const { deviceId, videoWidth, videoHeight, videoBitRate, frameRate } = this.recordConfig
  100. ;(this.$has ? updateRecordConfig : addRecordConfig)({
  101. deviceId,
  102. videoWidth,
  103. videoHeight,
  104. videoBitRate: videoBitRate * 1024,
  105. frameRate
  106. }).then(() => {
  107. done()
  108. this.$message({
  109. type: 'success',
  110. message: '设置成功'
  111. })
  112. })
  113. }
  114. }
  115. }
  116. </script>