VideoControl.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <div class="videoControl-container">
  3. <div class="comm-open">
  4. {{ commOpenning ? "允许操作" : "禁止操作" }}
  5. <el-switch
  6. style="display: block; margin: 4px"
  7. v-model="commOpenning"
  8. active-color="#13ce66"
  9. inactive-color="#ff4949"
  10. >
  11. </el-switch>
  12. </div>
  13. <div class="comm-panel">
  14. <div
  15. class="btn-box"
  16. v-for="item of commandConfig.direction"
  17. :key="item.type"
  18. >
  19. <el-button
  20. type="primary"
  21. :icon="`el-icon-${item.type}`"
  22. size="mini"
  23. @mousedown.native="changePtzCommParam(item.command, false)"
  24. @mouseup.native="changePtzCommParam(item.command, true)"
  25. ></el-button>
  26. </div>
  27. </div>
  28. <div class="zoom-panel">
  29. <div class="btn-box" v-for="item of commandConfig.zoom" :key="item.type">
  30. <el-button
  31. type="primary"
  32. :icon="`el-icon-${item.type}`"
  33. size="mini"
  34. @mousedown.native="changePtzCommParam(item.command, false)"
  35. @mouseup.native="changePtzCommParam(item.command, true)"
  36. ></el-button>
  37. </div>
  38. </div>
  39. <div class="form_box">
  40. <el-form label-width="70px" size="small">
  41. <el-form-item label="速度" prop="speed" class="form_info">
  42. <el-select
  43. class="myInput"
  44. size="mini"
  45. v-model="speed"
  46. placeholder="请选择速度"
  47. style="width: 100%"
  48. >
  49. <el-option
  50. v-for="item in Array.from(
  51. { length: 10 },
  52. (item, index) => index + 1
  53. )"
  54. :key="item"
  55. :label="item"
  56. :value="item"
  57. ></el-option>
  58. </el-select>
  59. </el-form-item>
  60. <el-form-item label="预置点" prop="presetIndex" class="form_info">
  61. <el-select
  62. class="myInput"
  63. size="mini"
  64. v-model="presetIndex"
  65. placeholder="请选择预置点"
  66. style="width: 100%"
  67. >
  68. <el-option
  69. v-for="item in Array.from(
  70. { length: 255 },
  71. (item, index) => index + 1
  72. )"
  73. :key="item"
  74. :label="item"
  75. :value="item"
  76. ></el-option>
  77. </el-select>
  78. </el-form-item>
  79. <div class="btn_box">
  80. <el-button type="primary" size="mini" @click="changePtzPresetParam(8)"
  81. >设置</el-button
  82. >
  83. <el-button
  84. type="primary"
  85. size="mini"
  86. @click="changePtzPresetParam(39)"
  87. >转到</el-button
  88. >
  89. </div>
  90. <!-- <el-form-item label="时间" prop="startTime">
  91. <el-date-picker class="myInput" size="mini" v-model="startTime" type="datetime" placeholder="选择日期时间" style="width: 100%"></el-date-picker>
  92. </el-form-item>
  93. <div class="btn_box">
  94. <el-button type="primary" size="mini" @click="changePlayTypeParam(true)" :disabled="!startTime">回放</el-button>
  95. <el-button type="primary" size="mini" @click="changePlayTypeParam(false)" :disabled="!startTime">实时</el-button>
  96. </div> -->
  97. </el-form>
  98. </div>
  99. </div>
  100. </template>
  101. <script>
  102. import Dayjs from "dayjs";
  103. export default {
  104. name: "VideoControl",
  105. props: {
  106. curVideoData: {
  107. type: Object,
  108. require: true,
  109. default: () => ({}),
  110. },
  111. },
  112. data() {
  113. return {
  114. // 视频控制相关 start
  115. commandConfig: {
  116. //视频控制开关配置
  117. direction: [
  118. //方向
  119. { type: "top-left", name: "左上", command: 25 },
  120. { type: "top", name: "上", command: 21 },
  121. { type: "top-right", name: "右上", command: 26 },
  122. { type: "back", name: "左", command: 23 },
  123. { type: "rank", name: "中", command: 0 },
  124. { type: "right", name: "右", command: 24 },
  125. { type: "bottom-left", name: "左下", command: 27 },
  126. { type: "bottom", name: "下", command: 22 },
  127. { type: "bottom-right", name: "右下", command: 28 },
  128. ],
  129. zoom: [
  130. //放大缩小
  131. { type: "zoom-in", name: "放大", command: 11 },
  132. { type: "zoom-out", name: "缩小", command: 12 },
  133. ],
  134. },
  135. startTime: null,
  136. speed: 5,
  137. presetIndex: 1,
  138. // 视频控制 end
  139. commOpenning: false,
  140. };
  141. },
  142. mounted() {},
  143. methods: {
  144. changePtzCommParam(comm, stop) {
  145. if (!this.commOpenning) {
  146. stop && this.$message.warning("请先开启操作许可!");
  147. return;
  148. }
  149. if (!comm) return;
  150. if (!this.curVideoData.id) {
  151. stop && this.$message.warning("请先选择视频窗口!");
  152. return;
  153. }
  154. let param = {
  155. id: this.curVideoData.id,
  156. ptzCommand: comm,
  157. ptzStop: stop,
  158. ptzSpeed: this.speed,
  159. canControl: this.curVideoData.ptzEnable,
  160. };
  161. this.$EventBus.$emit("updateSendParam", param);
  162. },
  163. changePtzPresetParam(comm) {
  164. if (!this.commOpenning) {
  165. stop && this.$message.warning("请先开启操作许可!");
  166. return;
  167. }
  168. if (!comm) return;
  169. if (!this.curVideoData.id) {
  170. this.$message.warning("请先选择视频窗口!");
  171. return;
  172. }
  173. let param = {
  174. id: this.curVideoData.id,
  175. ptzPreset: comm,
  176. ptzPresetIndex: this.presetIndex,
  177. canControl: this.curVideoData.ptzEnable,
  178. };
  179. this.$EventBus.$emit("updateSendParam", param);
  180. },
  181. /**
  182. * state true代表回放模式
  183. */
  184. changePlayTypeParam(state) {
  185. if (!this.commOpenning) {
  186. stop && this.$message.warning("请先开启操作许可!");
  187. return;
  188. }
  189. let param = { id: this.curVideoData.id };
  190. if (!this.curVideoData.id) {
  191. this.$message.warning("请先选择视频窗口!");
  192. return;
  193. }
  194. if (state) {
  195. if (!this.startTime) {
  196. this.$message.warning("请选择回放开始时间!");
  197. return;
  198. }
  199. param["startTime"] = Dayjs(this.startTime).format(
  200. "YYYY-MM-DD HH:mm:ss"
  201. );
  202. }
  203. this.$EventBus.$emit("updateSendParam", param, true);
  204. },
  205. },
  206. };
  207. </script>
  208. <style lang="less" scoped>
  209. .videoControl-container {
  210. width: 100%;
  211. .comm-open {
  212. padding: 6px 6px 6px 16px;
  213. text-align: left;
  214. font-size: 0.083333rem /* 16/192 */;
  215. line-height: 30px /* 50/192 */;
  216. color: #fff;
  217. display: flex;
  218. height: 43px;
  219. }
  220. .comm-panel {
  221. width: 184px;
  222. margin: 0 auto;
  223. display: flex;
  224. flex-wrap: wrap;
  225. .el-button {
  226. background: #007ccc;
  227. border-color: #007ccc;
  228. }
  229. }
  230. .zoom-panel {
  231. width: 122px;
  232. margin: 0 auto;
  233. display: flex;
  234. .el-button {
  235. background: #007ccc;
  236. border-color: #007ccc;
  237. }
  238. }
  239. .btn-box {
  240. flex-shrink: 0;
  241. width: 60px;
  242. height: 40px;
  243. display: flex;
  244. justify-content: center;
  245. align-items: center;
  246. }
  247. .form_box {
  248. width: 100%;
  249. padding: 10px 0;
  250. ::v-deep .form_info .el-form-item__label {
  251. color: rgb(255, 255, 255);
  252. }
  253. ::v-deep .el-form {
  254. width: 100%;
  255. .myInput {
  256. .el-input__inner {
  257. // width: 110px;
  258. height: 30px;
  259. border-radius: 0;
  260. background: rgba(0, 20, 23, 0.2);
  261. border: 0.5px solid #5bd6ff;
  262. color: #5bd6ff;
  263. // padding-right: 35px;
  264. }
  265. .el-input__inner:focus {
  266. border: 0.5px solid #5bd6ff !important;
  267. }
  268. .el-input.is-focus .el-input__inner {
  269. border: 0.5px solid #5bd6ff !important;
  270. }
  271. .el-input__suffix {
  272. right: 5px;
  273. }
  274. .el-input__icon {
  275. line-height: 30px;
  276. }
  277. }
  278. .btn_box {
  279. width: 100%;
  280. display: flex;
  281. justify-content: center;
  282. align-items: center;
  283. margin-bottom: 12px;
  284. }
  285. }
  286. }
  287. }
  288. </style>