index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <div class="video">
  3. <div class="videoTop">
  4. <div class="videoTopLeft">
  5. 选择站点:
  6. <el-select
  7. filterable
  8. v-model="store.state.siteId"
  9. placeholder="请选择"
  10. style="width: 250px; margin-right: 20px"
  11. >
  12. <el-option
  13. v-for="site in store.state.siteList"
  14. :key="site"
  15. :label="site.siteName"
  16. :value="site.id"
  17. ></el-option>
  18. </el-select>
  19. <el-input
  20. placeholder="搜索设备名"
  21. v-model="filterText"
  22. class="videoTopLeftInput"
  23. >
  24. <!-- <template #suffix>
  25. <i class="el-icon-search el-input__icon"></i>
  26. </template> -->
  27. </el-input>
  28. <el-button
  29. type="primary"
  30. icon="el-icon-search"
  31. class="search-button"
  32. @click="searchData()"
  33. >
  34. 搜索
  35. </el-button>
  36. <!-- <el-button
  37. class="search-button"
  38. icon="el-icon-plus"
  39. type="success"
  40. @click="Insert()"
  41. >
  42. 新增
  43. </el-button> -->
  44. </div>
  45. <!-- <div class="videoRight">
  46. <el-button type="primary">导入</el-button>
  47. <el-button type="primary">导出</el-button>
  48. </div> -->
  49. </div>
  50. <div class="videoContent">
  51. <el-table
  52. :data="tableData"
  53. border
  54. stripe
  55. :header-cell-style="headClass"
  56. :height="Height"
  57. v-loading="loadingStatus"
  58. element-loading-text="摄像头打开中...."
  59. element-loading-background="rgba(255, 255, 255, 0.6)"
  60. >
  61. <el-table-column
  62. prop="stationStatus"
  63. label="状态"
  64. align="center"
  65. width="50"
  66. >
  67. <template #default="scope">
  68. <el-avatar
  69. class="status"
  70. :style="
  71. scope.row.ALIVEVALUE == 3
  72. ? 'background-color:#04F21C'
  73. : 'background-color:red'
  74. "
  75. ></el-avatar>
  76. </template>
  77. </el-table-column>
  78. <el-table-column
  79. prop="deviceName"
  80. label="名称"
  81. align="center"
  82. ></el-table-column>
  83. <el-table-column
  84. prop="deviceCode"
  85. label="编号"
  86. align="center"
  87. width=""
  88. ></el-table-column>
  89. <el-table-column
  90. prop="floor"
  91. label="楼层"
  92. align="center"
  93. width="60"
  94. ></el-table-column>
  95. <el-table-column
  96. prop="deviceAddress"
  97. label="设备安装位置"
  98. align="center"
  99. width=""
  100. ></el-table-column>
  101. <el-table-column prop="deviceType" label="设备类型" align="center">
  102. <template #default="scope">
  103. {{ scope.row.deviceType == '2' ? '视频监控设备' : '其他' }}
  104. </template>
  105. </el-table-column>
  106. <el-table-column
  107. prop="installTime"
  108. label="安装时间"
  109. align="center"
  110. width="200"
  111. ></el-table-column>
  112. <el-table-column
  113. prop="creator"
  114. label="创建人"
  115. align="center"
  116. ></el-table-column>
  117. <el-table-column
  118. prop="sim"
  119. label="sim卡号"
  120. align="center"
  121. ></el-table-column>
  122. <el-table-column label="视频画面" align="center" width="150">
  123. <template #default="scope" style="text-align: center">
  124. <a v-if="scope.row.ALIVEVALUE == 3" @click="open_video(scope.row)">
  125. 查看
  126. </a>
  127. <span v-else style="color: #aaa">--</span>
  128. </template>
  129. </el-table-column>
  130. </el-table>
  131. <div class="listPagination">
  132. <el-pagination
  133. v-model:currentPage="currentPage"
  134. :page-sizes="[15, 20, 25, 30]"
  135. :page-size="15"
  136. layout="total, sizes, prev, pager, next, jumper"
  137. :total="tableData.length"
  138. @size-change="handleSizeChange"
  139. @current-change="handleCurrentChange"
  140. background
  141. ></el-pagination>
  142. </div>
  143. <!--视频弹框组件开始-----------------------start-->
  144. <check-video
  145. :dialogTitle="dialogTitle"
  146. @closeDialog="closeDialog"
  147. :flag="showDialog"
  148. ></check-video>
  149. <!--视频弹框组件结束-----------------------end-->
  150. </div>
  151. <div></div>
  152. </div>
  153. </template>
  154. <script>
  155. import { useStore } from 'vuex'
  156. import { defineComponent, ref, onMounted,watch } from 'vue'
  157. import { ElMessage } from 'element-plus'
  158. import * as api from '@/api/deviceManage/videoEquip.js'
  159. import checkVideo from './checkVideo'
  160. import axios from 'axios'
  161. export default defineComponent({
  162. name: 'powerEquip',
  163. components: { checkVideo },
  164. props: {
  165. Height: String,
  166. activeName: String,
  167. },
  168. setup(props) {
  169. const store = useStore()
  170. const dialogTitle = ref('')
  171. const showDialog = ref(false)
  172. const total = ref(0)
  173. const pageSize = ref(15)
  174. const currentPage = ref(1)
  175. const filterText = ref('')
  176. // const activeName = 'powerEquip'
  177. const tableData = ref([])
  178. const onLineVideoList = ref([])
  179. const openId = ref('')
  180. const reCount = ref(0)
  181. const count = ref(0)
  182. const loadingStatus = ref(false)
  183. const timer = ref('')
  184. const deviceCode = ref('')
  185. //查看视频画面
  186. const LookUp = (ind, row) => {
  187. // alert(2)
  188. console.log(ind, row)
  189. dialogTitle.value = '查看视频'
  190. showDialog.value = true
  191. }
  192. const handleSizeChange = (val) => {
  193. pageSize.value = val
  194. videoMonitoringDeviceList()
  195. }
  196. const handleCurrentChange = (val) => {
  197. currentPage.value = val
  198. videoMonitoringDeviceList()
  199. }
  200. // 表头样式设置
  201. const headClass = () => {
  202. return 'background:#FAFAFA !important;color: black;'
  203. }
  204. // 关闭操作
  205. const closeDialog = () => {
  206. showDialog.value = false
  207. // videoMonitoringDeviceList()
  208. }
  209. function searchData(){
  210. videoMonitoringDeviceList()
  211. chk_video()
  212. }
  213. //视频列表
  214. function videoMonitoringDeviceList() {
  215. api
  216. .videoMonitoringDeviceList({
  217. siteId: store.state.siteId,
  218. size: pageSize.value,
  219. current: currentPage.value,
  220. deviceType: 2,
  221. deviceName: filterText.value,
  222. })
  223. .then((requset) => {
  224. if (requset.status === 'SUCCESS') {
  225. tableData.value = requset.data.records
  226. total.value = requset.data.total
  227. } else {
  228. ElMessage.error(requset.msg)
  229. }
  230. })
  231. }
  232. //请求视频cgi数据
  233. const chk_video = () => {
  234. axios
  235. .post(
  236. 'https://fire.usky.cn:8443/YtIoT/cgi-bin/demo2.cgi',
  237. 'queryJson:' +
  238. JSON.stringify({
  239. CMD: 1,
  240. }),
  241. {
  242. headers: {
  243. 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  244. },
  245. }
  246. )
  247. .then((response) => {
  248. console.log('response cgi')
  249. console.log(response.data.RESULT.LIST)
  250. console.log(openId.value)
  251. onLineVideoList.value = response.data.RESULT.LIST
  252. if (openId.value.length > 0) {
  253. // start
  254. console.log('doododododododo')
  255. for (var n = 0; n < onLineVideoList.value.length; n++) {
  256. if (openId.value == onLineVideoList.value[n].DEVICE) {
  257. console.log('再次打开摄像头')
  258. console.log(openId.value)
  259. console.log(onLineVideoList.value[n].DEVICE)
  260. console.log(onLineVideoList.value[n].ONAIR)
  261. reCount.value++
  262. console.log(reCount.value)
  263. if (onLineVideoList.value[n].ONAIR) {
  264. if (++count.value > 2) {
  265. loadingStatus.value = false
  266. dialogTitle.value = '查看视频'
  267. showDialog.value = true
  268. } else {
  269. store.state.siteCameraTimer = setTimeout(chk_video, 5000)
  270. }
  271. } else {
  272. if (reCount.value > 7) {
  273. loadingStatus.value = false
  274. alert('远程摄像头链接超时,请稍后再试')
  275. break
  276. }
  277. store.state.siteCameraTimer = setTimeout(chk_video, 5000)
  278. }
  279. }
  280. }
  281. // end
  282. } else {
  283. for (var i = 0; i < onLineVideoList.value.length; i++) {
  284. for (var j = 0; j < tableData.value.length; j++) {
  285. if (
  286. onLineVideoList.value[i].DEVICE ==
  287. tableData.value[j].deviceCode
  288. ) {
  289. // alert(1)
  290. tableData.value[j].ALIVEVALUE =
  291. onLineVideoList.value[i].ALIVEVALUE
  292. }
  293. }
  294. }
  295. console.log('处理后的,tableData.value')
  296. console.log(tableData.value)
  297. }
  298. })
  299. .catch((error) => {
  300. console.log(error)
  301. })
  302. }
  303. // 查看视频
  304. const open_video = (item) => {
  305. deviceCode.value = item.deviceCode
  306. if (openId.value != item.deviceCode) {
  307. openId.value = item.deviceCode
  308. }
  309. for (var n = 0; n < onLineVideoList.value.length; n++) {
  310. if (onLineVideoList.value[n].DEVICE == openId.value) {
  311. console.log('第一次打开时设备及其状态')
  312. console.log(onLineVideoList.value[n].DEVICE)
  313. console.log(openId.value)
  314. console.log(onLineVideoList.value[n].ONAIR)
  315. if (onLineVideoList.value[n].ONAIR) {
  316. dialogTitle.value = '查看视频'
  317. showDialog.value = true
  318. return
  319. }
  320. }
  321. }
  322. count.value = 0
  323. reCount.value = 0
  324. loadingStatus.value = true
  325. axios
  326. .post(
  327. 'https://fire.usky.cn:8443/YtIoT/cgi-bin/demo2.cgi',
  328. 'queryJson:' +
  329. JSON.stringify({
  330. CMD: 3,
  331. BODY: {
  332. DEVICE: item.deviceCode,
  333. ACTION: 1,
  334. IDX: 7,
  335. },
  336. }),
  337. {
  338. headers: {
  339. 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  340. },
  341. }
  342. )
  343. .then((response) => {
  344. response
  345. store.state.siteCameraTimer = window.setTimeout(function () {
  346. chk_video()
  347. }, 5000)
  348. })
  349. // end
  350. }
  351. watch(
  352. () => props.activeName,
  353. (newVal) => {
  354. // alert(newVal)
  355. if (newVal == 'videoEquip') {
  356. // clearTimeOut(timer.value)
  357. // window.clearTimeOut() //关闭定时器// alert('关闭定时器?')
  358. reCount.value = 0
  359. openId.value = ''
  360. loadingStatus.value = false
  361. videoMonitoringDeviceList()
  362. chk_video()
  363. }
  364. }
  365. )
  366. onMounted(() => {})
  367. return {
  368. headClass,
  369. LookUp,
  370. handleSizeChange,
  371. handleCurrentChange,
  372. searchData,
  373. videoMonitoringDeviceList,
  374. filterText,
  375. tableData,
  376. // activeName,
  377. currentPage,
  378. closeDialog,
  379. dialogTitle,
  380. showDialog,
  381. store,
  382. chk_video,
  383. openId,
  384. onLineVideoList,
  385. reCount,
  386. count,
  387. loadingStatus,
  388. open_video,
  389. timer,
  390. deviceCode,
  391. }
  392. },
  393. })
  394. </script>
  395. <style lang="scss" scoped>
  396. //first样式
  397. .video {
  398. margin: 15px;
  399. //顶部左侧样式
  400. .videoTop {
  401. display: flex;
  402. height: 32px;
  403. line-height: 32px;
  404. .videoTopLeft {
  405. width: 70%;
  406. .goBack {
  407. margin-right: 15px;
  408. }
  409. .videoTopLeftTitle {
  410. font-size: 14px;
  411. margin-right: 10px;
  412. }
  413. .videoTopLeftInput {
  414. width: 15rem;
  415. }
  416. .el-input__icon {
  417. color: #409eff;
  418. }
  419. .el-input__inner:hover {
  420. border-color: #409eff;
  421. }
  422. .el-input__inner:focus {
  423. border-color: #409eff;
  424. }
  425. .search-button {
  426. margin-left: 1rem;
  427. }
  428. }
  429. //顶部右侧样式
  430. .videoRight {
  431. width: 30%;
  432. button {
  433. margin-left: 1rem;
  434. float: right;
  435. }
  436. }
  437. }
  438. .videoContent {
  439. margin-top: 15px;
  440. }
  441. }
  442. .listPagination {
  443. margin-top: 15px;
  444. float: right;
  445. }
  446. </style>