VideoAdmin.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <template>
  2. <div class="videoAdmin">
  3. <!-- 查询 -->
  4. <query-conditions :formItems="searchList" @getQueryParams="handleQuery"></query-conditions>
  5. <!-- 表格 -->
  6. <new-table :height="600" :title="title" :listData="videoLists" :tableItems="tableItems" :shows="tableShows" @selectionChange="selectionChange">
  7. <template #right>
  8. <el-button size="mini" type="primary" v-if="hasPerm('video:add')" style="margin-right: 10px" @click="add">添加监控</el-button>
  9. <el-button size="mini" type="danger" v-if="hasPerm('video:del')" @click="delAll">批量删除</el-button>
  10. </template>
  11. <template #start="scope">
  12. <el-switch v-model="scope.row.runStatus" @change="onSwitch(scope.row)"></el-switch>
  13. </template>
  14. <template #handler="scope">
  15. <el-button size="mini" style="margin-right: 10px" v-if="hasPerm('video:edit')" @click="edit(scope.row)">编辑</el-button>
  16. <el-popconfirm
  17. title=" 确定要删除这个区域吗?"
  18. @confirm="del(scope.row)"
  19. >
  20. <el-button type="danger" v-if="hasPerm('video:del')" size="mini" slot="reference">删除</el-button>
  21. </el-popconfirm>
  22. <el-button size="mini" type="primary" style="margin-left: 10px" @click="open(scope.row)">查看摄像头</el-button>
  23. </template>
  24. </new-table>
  25. <table-footer
  26. :totals="total"
  27. :size="pageSize"
  28. @sizeChange="sizeChange"
  29. @pageChange="pageChange"></table-footer>
  30. <!-- 新增编辑 -->
  31. <el-dialog
  32. :title="showType ? '编 辑' : '新 增'"
  33. :visible.sync="dialogVisible"
  34. width="30%">
  35. <div>
  36. <el-form ref="form" :model="form" :rules="rules" label-width="100px" size="mini">
  37. <el-form-item label="摄像头名称" prop="cameraName">
  38. <el-input v-model="form.cameraName"></el-input>
  39. </el-form-item>
  40. <el-form-item label="所属区域" prop="areaId">
  41. <el-select v-model="form.areaId">
  42. <el-option v-for="item in searchList[0].options" :key="item.value" :label="item.label" :value="item.value"></el-option>
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item label="所属品牌" prop="brandId">
  46. <el-select v-model="form.brandId">
  47. <el-option v-for="item in searchList[1].options" :key="item.value" :label="item.label" :value="item.value"></el-option>
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item label="ip地址" prop="cameraIp">
  51. <el-input v-model="form.cameraIp"></el-input>
  52. </el-form-item>
  53. <el-form-item label="用户名" prop="account">
  54. <el-input v-model="form.account"></el-input>
  55. </el-form-item>
  56. <el-form-item label="密码" prop="password">
  57. <el-input v-model="form.password"></el-input>
  58. </el-form-item>
  59. <el-form-item label="斯高德房间id">
  60. <el-input v-model="form.roomId"></el-input>
  61. </el-form-item>
  62. <!-- <el-form-item label="排序" prop="sort">-->
  63. <!-- <el-input v-model="form.sort"></el-input>-->
  64. <!-- </el-form-item>-->
  65. </el-form>
  66. </div>
  67. <span slot="footer" class="dialog-footer">
  68. <el-button @click="reset">重 置</el-button>
  69. <el-button @click="dialogVisible = false">取 消</el-button>
  70. <el-button type="primary" @click="onSubmit('form')">{{showType ? '更 新' : '新 增'}}</el-button>
  71. </span>
  72. </el-dialog>
  73. <el-dialog
  74. :title="cameraTitle"
  75. :visible.sync="isVideo"
  76. width="50%">
  77. <div style="width: 100%; height: 560px; text-align: center;">
  78. <iframe v-if="isVideo" :src="'static/jinm/index.html?'+'1'+','+ cameraOne +','+ cameraTwo + ',' +'100%' + ',' + '0'" style="width: 100%; height: 530px;" frameborder="0" allowfullscreen="true"></iframe>
  79. <div>
  80. <el-button :disabled="last === null" size="small" @click="getNext(last)">上一个</el-button>
  81. <el-button :disabled="next === null" size="small" @click="getNext(next)">下一个</el-button>
  82. </div>
  83. </div>
  84. </el-dialog>
  85. </div>
  86. </template>
  87. <script>
  88. import QueryConditions from "@/components/bioSafety/QueryConditions";
  89. import NewTable from "@/components/newTable/NewTable";
  90. import TableFooter from "@/components/TableFooter";
  91. import {areaList, brandList, videoList, videoSwitch, delVideo, addVideo, editVideo, getVideo} from '../../utils/api'
  92. import {arrToIds} from "@/utils";
  93. export default {
  94. name: "VideoAdmin",
  95. components: {
  96. QueryConditions,
  97. NewTable,
  98. TableFooter,
  99. },
  100. data() {
  101. return {
  102. searchList: [
  103. {
  104. type: 'select',
  105. label: '区域搜索:',
  106. placeholder: '请选择区域',
  107. field: 'areaId',
  108. options: []
  109. },
  110. {
  111. type: 'select',
  112. label: '摄像头品牌:',
  113. placeholder: '请选择品牌',
  114. field: 'brandId',
  115. options: []
  116. },
  117. // {
  118. // type: 'select',
  119. // label: '摄像头排序:',
  120. // placeholder: '请选择排序',
  121. // field: 'sort',
  122. // options: [
  123. // {
  124. // label: '正序',
  125. // value: 0,
  126. // },
  127. // {
  128. // label: '倒序',
  129. // value: 1
  130. // }
  131. // ]
  132. // },
  133. {
  134. type: 'input',
  135. label: '名称搜索:',
  136. placeholder: '请输入摄像头名称',
  137. field: 'keyWord'
  138. },
  139. ],
  140. keyWord: '',
  141. areaId: '',
  142. brandId: '',
  143. sort: '',
  144. pageNum: 1,
  145. pageSize: 20,
  146. total: 0,
  147. videoLists: [],
  148. title: '监控列表',
  149. tableItems: [
  150. {
  151. prop: 'id',
  152. label: 'ID',
  153. minWidth: '50',
  154. slotName: 'id'
  155. },
  156. {
  157. prop: 'cameraName',
  158. label: '摄像头名称',
  159. minWidth: '100',
  160. slotName: 'cameraName'
  161. },
  162. {
  163. prop: 'areaName',
  164. label: '所属区域',
  165. minWidth: '100',
  166. slotName: 'areaName'
  167. },
  168. {
  169. prop: 'brandName',
  170. label: '所属品牌',
  171. minWidth: '100',
  172. slotName: 'brandName'
  173. },
  174. {
  175. prop: 'cameraIp',
  176. label: 'ip地址',
  177. minWidth: '100',
  178. slotName: 'cameraIp'
  179. },
  180. {
  181. prop: 'account',
  182. label: '用户名',
  183. minWidth: '100',
  184. slotName: 'account'
  185. },
  186. {
  187. prop: 'password',
  188. label: '密码',
  189. minWidth: '100',
  190. slotName: 'password'
  191. },
  192. // {
  193. // prop: 'sort',
  194. // label: '排序',
  195. // minWidth: '50',
  196. // slotName: 'sort'
  197. // },
  198. {
  199. label: '是否启用',
  200. minWidth: '80',
  201. slotName: 'start'
  202. },
  203. {
  204. label: '操作',
  205. minWidth: '150',
  206. slotName: 'handler'
  207. }
  208. ],
  209. tableShows: {
  210. showIndex: false,
  211. showSelect: true
  212. },
  213. dialogVisible: false,
  214. showType: false,
  215. form: {
  216. cameraName: '',
  217. areaId: '',
  218. brandId: '',
  219. cameraIp: '',
  220. account: '',
  221. password: '',
  222. sort: '',
  223. roomId: '',
  224. },
  225. rules: {
  226. cameraName: [ { required: true, message: '摄像头名称不能为空', trigger: 'blur' } ],
  227. areaId: [ { required: true, message: '区域不能为空', trigger: 'change' } ],
  228. brandId: [ { required: true, message: '品牌不能为空', trigger: 'change' } ],
  229. cameraIp: [ { required: true, message: 'ip地址不能为空', trigger: 'blur' } ],
  230. account: [ { required: true, message: '用户名不能为空', trigger: 'blur' } ],
  231. password: [ { required: true, message: '密码不能为空', trigger: 'blur' } ],
  232. sort: [ { required: true, message: '请输入排序', trigger: 'blur' } ],
  233. },
  234. selectList: [],
  235. cameraOne: '',
  236. cameraTwo: '',
  237. cameraTitle: '',
  238. isVideo: false,
  239. last: '',
  240. next: '',
  241. }
  242. },
  243. methods: {
  244. // 修改size
  245. sizeChange(val) {
  246. this.pageSize = val;
  247. this.init();
  248. },
  249. // 修改页数
  250. pageChange(val) {
  251. this.pageNum= val;
  252. this.init();
  253. },
  254. init() {
  255. let params = {
  256. current: this.pageNum,
  257. size: this.pageSize,
  258. areaId: this.areaId,
  259. brandId: this.brandId,
  260. strchStr: this.keyWord,
  261. // sort: this.sort
  262. }
  263. videoList(params).then(res => {
  264. if(res.code === 10000) {
  265. this.videoLists = res.data.records;
  266. this.total = res.data.total;
  267. }
  268. })
  269. },
  270. handleQuery(data) {
  271. this.areaId = data.areaId ? data.areaId : '';
  272. this.keyWord = data.keyWord ? data.keyWord : '';
  273. this.brandId = data.brandId ? data.brandId : '';
  274. this.sort = data.sort;
  275. this.pageNum = 1;
  276. this.init();
  277. },
  278. // 获取区域,摄像头品牌
  279. getArea() {
  280. let params = {
  281. current: 1,
  282. size: 100,
  283. areaName: ''
  284. }
  285. areaList(params).then(res => {
  286. if(res.code === 10000) {
  287. res.data.records.forEach(item => {
  288. this.searchList[0].options.push({label: item.areaName, value: item.id})
  289. })
  290. }
  291. })
  292. let params1 = {
  293. current: 1,
  294. size: 100,
  295. brandName: ''
  296. }
  297. brandList(params1).then(res => {
  298. if(res.code === 10000) {
  299. res.data.records.forEach(item => {
  300. this.searchList[1].options.push({label: item.brandName, value: item.id})
  301. })
  302. }
  303. })
  304. },
  305. // 是否启用
  306. onSwitch(row) {
  307. let params = {
  308. id: row.id
  309. }
  310. videoSwitch(params).then(res => {
  311. if(res.code === 10000) {
  312. this.$message.success(res.message);
  313. } else {
  314. this.$message.error('失败');
  315. }
  316. })
  317. },
  318. // 批量选择
  319. selectionChange(rows) {
  320. this.selectList = rows;
  321. },
  322. add() {
  323. this.showType = false;
  324. this.dialogVisible = true;
  325. },
  326. // 编辑
  327. edit(row) {
  328. this.showType = true;
  329. this.dialogVisible = true;
  330. this.form.id = row.id;
  331. this.form.cameraName = row.cameraName;
  332. this.form.areaId = row.areaId;
  333. this.form.brandId = row.brandId;
  334. this.form.cameraIp = row.cameraIp;
  335. this.form.account = row.account;
  336. this.form.password = row.password;
  337. this.form.roomId = row.roomId;
  338. // this.form.sort = row.sort;
  339. },
  340. // 单个删除
  341. del(row) {
  342. let params = {
  343. ids: row.id
  344. }
  345. delVideo(params).then(res => {
  346. if(res.code === 10000) {
  347. this.init()
  348. this.$message.success(res.message)
  349. } else {
  350. this.$message('删除失败')
  351. }
  352. })
  353. },
  354. // 批量删除
  355. delAll() {
  356. if(this.selectList.length > 0) {
  357. this.$confirm('此操作将永久删除这些品牌,是否继续?', '提示', {
  358. confirmButtonText: '确定',
  359. cancelButtonText: '取消',
  360. type: 'warning'
  361. }).then(() => {
  362. let ids = arrToIds(this.selectList);
  363. let params = {
  364. ids: ids
  365. }
  366. delVideo(params).then(res => {
  367. if(res.code === 10000) {
  368. this.init();
  369. this.$message.success(res.message)
  370. } else {
  371. this.$message.error('删除失败')
  372. }
  373. })
  374. }).catch(() => {
  375. this.$message({
  376. type: 'info',
  377. message: '已取消删除'
  378. });
  379. })
  380. // delArea()
  381. } else {
  382. this.$message.error('请勾选需要删除的区域');
  383. return;
  384. }
  385. },
  386. // 查看摄像头
  387. open(row) {
  388. if(row.runStatus) {
  389. let params = {
  390. cameraIds: [row.id],
  391. strchStr: this.keyWord,
  392. areaId: this.areaId,
  393. brandId: this.brandId,
  394. // sort: this.sort
  395. }
  396. getVideo(params).then(res => {
  397. if(res.code === 10000) {
  398. this.isVideo = true;
  399. // this.cameraTitle = res.data[0].cameraName;
  400. this.cameraOne = res.data[0].wsUrl;
  401. this.cameraTwo = res.data[0].rtspUrl;
  402. this.last = res.data[0].lastId;
  403. this.next = res.data[0].nextId;
  404. } else {
  405. this.$message.error(res.message);
  406. }
  407. })
  408. } else {
  409. this.$message.error('该摄像头未启用');
  410. }
  411. },
  412. // 新增、编辑
  413. onSubmit(formName) {
  414. this.$refs[formName].validate((valid) => {
  415. if (valid) {
  416. if (this.showType) {
  417. // // 编辑
  418. let params = {
  419. id: this.form.id,
  420. cameraName: this.form.cameraName,
  421. areaId: this.form.areaId,
  422. brandId: this.form.brandId,
  423. cameraIp: this.form.cameraIp,
  424. account: this.form.account,
  425. password: this.form.password,
  426. roomId: this.form.roomId,
  427. // sort: this.form.sort
  428. }
  429. editVideo(params).then(res => {
  430. this.dialogVisible = false;
  431. if(res.code === 10000) {
  432. this.init();
  433. this.$message.success(res.message)
  434. } else {
  435. this.$message.error(res.message)
  436. }
  437. })
  438. } else {
  439. // 新增
  440. let params = {
  441. cameraName: this.form.cameraName,
  442. areaId: this.form.areaId,
  443. brandId: this.form.brandId,
  444. cameraIp: this.form.cameraIp,
  445. account: this.form.account,
  446. password: this.form.password,
  447. roomId: this.form.roomId,
  448. // sort: this.form.sort
  449. }
  450. addVideo(params).then(res => {
  451. this.dialogVisible = false;
  452. if(res.code === 10000) {
  453. this.init();
  454. this.$message.success(res.message);
  455. } else {
  456. this.$message.error(res.message)
  457. }
  458. })
  459. }
  460. } else {
  461. console.log('error submit!!');
  462. return false;
  463. }
  464. })
  465. },
  466. // 重置
  467. reset() {
  468. this.form = {
  469. cameraName: '',
  470. areaId: '',
  471. brandId: '',
  472. cameraIp: '',
  473. account: '',
  474. password: '',
  475. roomId: '',
  476. }
  477. },
  478. // 上一个下一个
  479. getNext(id) {
  480. let params = {
  481. cameraIds: [id],
  482. strchStr: this.keyWord,
  483. areaId: this.areaId,
  484. brandId: this.brandId,
  485. sort: this.sort
  486. }
  487. getVideo(params).then(res => {
  488. if(res.code === 10000) {
  489. this.isVideo = true;
  490. this.cameraTitle = res.data[0].cameraName;
  491. this.cameraOne = res.data[0].wsUrl;
  492. this.cameraTwo = res.data[0].rtspUrl;
  493. this.last = res.data[0].lastId;
  494. this.next = res.data[0].nextId;
  495. } else {
  496. this.$message.error(res.message);
  497. }
  498. })
  499. }
  500. },
  501. mounted() {
  502. this.getArea()
  503. this.init()
  504. }
  505. }
  506. </script>
  507. <style scoped>
  508. .videoAdmin {
  509. width: 100%;
  510. height: 100%;
  511. box-sizing: border-box;
  512. padding: 20px;
  513. }
  514. </style>