DiskCam.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <div>
  3. <el-row style="padding: 5px">
  4. <el-col :md="16" style="padding: 5px">
  5. <el-card v-if="camVideo !== null" class="box-card">
  6. <div slot="header" class="clearfix">
  7. <span>{{ camVideo.recordTime }}</span>
  8. </div>
  9. <div class="text item">
  10. <video
  11. :src="camVideo.videoUrl"
  12. controls
  13. autoplay
  14. class="video"
  15. width="100%"
  16. />
  17. </div>
  18. </el-card>
  19. </el-col>
  20. <el-col :md="8" style="padding: 5px">
  21. <el-card class="box-card">
  22. <div slot="header" class="clearfix">
  23. <el-select
  24. v-model="selectedOption"
  25. style="margin: 5px;"
  26. clearable
  27. placeholder="选择摄像头"
  28. @change="onSelectChange"
  29. >
  30. <el-option v-for="item in selectOptions" :key="item.value" :label="item.label" :value="item.label" />
  31. </el-select>
  32. <el-button type="plain" icon="el-icon-date" style="margin: 5px" @click="onSelectDate">选择日期</el-button>
  33. <el-button type="plain" icon="el-icon-magic-stick" style="margin: 5px" @click="onButtonSubmit">提交</el-button>
  34. </div>
  35. <div class="text item">
  36. <span style="color: red">
  37. {{ getYearMonthDay(calendarDate) }} 的监控列表
  38. </span>
  39. <el-divider />
  40. <el-table
  41. :data="dataList"
  42. :show-header="true"
  43. style="width: 100%"
  44. >
  45. <el-table-column
  46. prop="createAt"
  47. label="名字"
  48. />
  49. <el-table-column label="操作">
  50. <template slot-scope="scope">
  51. <el-button
  52. size="mini"
  53. @click="handlePlay(scope.$index, scope.row)"
  54. >播放</el-button>
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. </div>
  59. </el-card>
  60. </el-col>
  61. </el-row>
  62. <el-dialog
  63. title="日历"
  64. append-to-body
  65. :visible.sync="showCalenderDialog"
  66. width="50%"
  67. center
  68. >
  69. <div style="padding: 5px; text-align: center">
  70. <span style="color: green">绿色标记的日期表示当天有监控录像</span>
  71. <el-calendar v-model="calendarDate">
  72. <div
  73. slot="dateCell"
  74. slot-scope="{ date, data }"
  75. @click="handleCellClick(date, data)"
  76. >
  77. <p>{{ data.day.split("-").slice(2).join() }}</p>
  78. <p v-if="dealMyDate(data.day)" class="blue budge" />
  79. </div>
  80. </el-calendar>
  81. </div>
  82. </el-dialog>
  83. </div>
  84. </template>
  85. <script>
  86. import { getCamDetail, getCamKeyValue, getRecordByMonth } from '@/api/disk'
  87. export default {
  88. name: 'DiskCam',
  89. data() {
  90. return {
  91. selectOptions: [],
  92. selectedOption: '',
  93. currentCamId: '',
  94. calendarDate: new Date(),
  95. dateMap: new Map(),
  96. query: {
  97. camId: this.currentCamId,
  98. yearMonth: '',
  99. yearMonthDay: ''
  100. },
  101. dataList: [],
  102. showCalenderDialog: false,
  103. camVideo: null
  104. }
  105. },
  106. watch: {
  107. $route() {
  108. this.$router.go()
  109. },
  110. calendarDate: {
  111. handler(newValue, oldValue) {
  112. const oldMonth = this.getYearMonth(oldValue)
  113. const newMonth = this.getYearMonth(newValue)
  114. if (oldMonth !== newMonth) {
  115. this.showCalender = false
  116. this.query.camId = this.currentCamId
  117. this.query.yearMonth = this.getYearMonth(newValue)
  118. this.getCamRecordByMonth().then(resp => {
  119. if (resp.code === 0) {
  120. this.dateMap.clear()
  121. for (const item of resp.data) {
  122. const date1 = new Date(item)
  123. const dayStr = this.getYearMonthDay(date1)
  124. this.dateMap.set(dayStr, date1)
  125. }
  126. }
  127. this.showCalender = true
  128. }).catch(error => {
  129. this.$message.error(error.message)
  130. })
  131. }
  132. }
  133. }
  134. },
  135. created() {
  136. document.title = '监控'
  137. this.getData()
  138. getCamKeyValue().then(resp => {
  139. if (resp.code === 0) {
  140. this.selectOptions = resp.data
  141. }
  142. })
  143. },
  144. methods: {
  145. getData() {
  146. getCamDetail(this.query).then(resp => {
  147. if (resp.code === 0) {
  148. const respData = resp.data
  149. console.log(respData)
  150. }
  151. })
  152. },
  153. onSelectChange() {
  154. this.$message.info('select -> ' + this.selectedOption)
  155. },
  156. handleCellClick(date, data) {
  157. this.query.yearMonthDay = this.getYearMonthDay(date)
  158. },
  159. dealMyDate(val) {
  160. let res = ''
  161. if (this.dateMap.get(val) != null) {
  162. res = true
  163. }
  164. return res
  165. },
  166. getYearMonth(date) {
  167. const year = date.getFullYear().toString().padStart(4, '0')
  168. const month = (date.getMonth() + 1).toString().padStart(2, '0')
  169. // const day = date.getDate().toString().padStart(2, '0')
  170. // const hour = date.getHours().toString().padStart(2, '0')
  171. // const minute = date.getMinutes().toString().padStart(2, '0')
  172. // const second = date.getSeconds().toString().padStart(2, '0')
  173. // 2023-02-16 08:25:05
  174. // console.log(`${year}-${month}-${day} ${hour}:${minute}:${second}`)
  175. return year + '-' + month
  176. },
  177. getYearMonthDay(date) {
  178. const year = date.getFullYear().toString().padStart(4, '0')
  179. const month = (date.getMonth() + 1).toString().padStart(2, '0')
  180. const day = date.getDate().toString().padStart(2, '0')
  181. return year + '-' + month + '-' + day
  182. },
  183. getCamRecordByMonth(val) {
  184. const query = {
  185. camId: 1,
  186. yearMonth: ''
  187. }
  188. getRecordByMonth(query).then(resp => {
  189. if (resp.code === 0) {
  190. console.log(resp.data)
  191. }
  192. })
  193. },
  194. handlePlay(index, row) {
  195. this.$message.info('play cam video')
  196. },
  197. onSelectDate() {
  198. this.showCalenderDialog = true
  199. },
  200. onButtonSubmit() {
  201. this.$confirm('确认提交?', '提示', {
  202. confirmButtonText: '确定',
  203. cancelButtonText: '取消',
  204. type: 'warning'
  205. }).then(() => {
  206. this.$message({
  207. type: 'success',
  208. message: '已提交'
  209. })
  210. }).catch(() => {
  211. this.$message({
  212. type: 'info',
  213. message: '已取消'
  214. })
  215. })
  216. }
  217. }
  218. }
  219. </script>
  220. <style>
  221. .clearfix:before,
  222. .clearfix:after {
  223. display: table;
  224. content: "";
  225. }
  226. .clearfix:after {
  227. clear: both;
  228. }
  229. .is-selected {
  230. color: #1989FA;
  231. }
  232. ::v-deep.el-calendar{
  233. height: calc(100% - 35px);
  234. }
  235. ::v-deep.el-calendar .el-calendar__body{
  236. padding-bottom: 16px;
  237. height: calc(100% - 80px);
  238. }
  239. ::v-deep.el-calendar .el-calendar-table{
  240. height: 100%;
  241. }
  242. .el-backtop, ::v-deep.el-calendar .el-calendar-table td.is-today .date{
  243. background: #DCE9FF;
  244. color: rgba(0,0,0,0.45);
  245. }
  246. .el-backtop, ::v-deep.el-calendar .el-calendar-table .date:hover{
  247. background: #DCE9FF;
  248. color: rgba(0,0,0,0.45);
  249. }
  250. ::v-deep.el-calendar .el-calendar-table .el-calendar-day:hover{
  251. background: none;
  252. }
  253. ::v-deep.el-calendar .el-calendar-table td.is-selected{
  254. background: none;
  255. }
  256. ::v-deep.el-calendar .el-calendar-table td.is-selected .date{
  257. background: #5E97F9;
  258. box-shadow: 0px 4px 7px 0px rgba(113,208,255,0.5);
  259. color: #fff;
  260. }
  261. ::v-deep.el-calendar .el-calendar__button-group{
  262. display: none;
  263. }
  264. ::v-deep.el-calendar .el-calendar__title{
  265. margin: 0 auto;
  266. }
  267. ::v-deep.el-calendar .el-calendar-table .el-calendar-day{
  268. position: relative;
  269. }
  270. </style>