VideoLook.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <div>
  3. <new-table
  4. :height="600"
  5. :title="title"
  6. :listData="videoLists"
  7. :tableItems="tableItems"
  8. :shows="tableShows"
  9. >
  10. <template #right>
  11. <el-button
  12. size="mini"
  13. type="primary"
  14. style="margin-right: 10px"
  15. @click="add"
  16. >添加监控</el-button>
  17. </template>
  18. <template #type="scope">
  19. <span>{{getType(scope.row.type)}}</span>
  20. </template>
  21. <template #handler="scope">
  22. <el-button
  23. size="mini"
  24. style="margin-right: 10px"
  25. @click="edit(scope.row)"
  26. >编辑</el-button
  27. >
  28. <el-popconfirm
  29. title=" 确定要删除这个区域吗?"
  30. @confirm="del(scope.row)"
  31. >
  32. <el-button
  33. type="danger"
  34. size="mini"
  35. slot="reference"
  36. >删除</el-button
  37. >
  38. </el-popconfirm>
  39. <el-button
  40. size="mini"
  41. type="primary"
  42. style="margin-left: 10px"
  43. @click="open(scope.row)"
  44. >查看摄像头</el-button
  45. >
  46. </template>
  47. </new-table>
  48. <!-- 新增编辑 -->
  49. <el-dialog
  50. :title="showType ? '编 辑' : '新 增'"
  51. :visible.sync="dialogVisible"
  52. width="30%"
  53. >
  54. <div>
  55. <el-form
  56. ref="form"
  57. :model="form"
  58. :rules="rules"
  59. label-width="120px"
  60. size="mini"
  61. >
  62. <el-form-item label="大屏所属位置" prop="type">
  63. <el-select v-model="form.type">
  64. <el-option v-for="item in typeList" :key="item.id" :value="item.id" :label="item.name"></el-option>
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item label="选择监控" prop="selectVideo">
  68. <el-cascader
  69. v-model="selectVideo"
  70. :options="options"
  71. size="mini"
  72. @change="handleChange"
  73. :props="{value: 'id', label: 'cameraName', children: 'cameraList', expandTrigger: 'hover', disabled: 'runStatus'}"
  74. :show-all-levels="false"></el-cascader>
  75. </el-form-item>
  76. </el-form>
  77. </div>
  78. <span slot="footer" class="dialog-footer">
  79. <el-button @click="reset">重 置</el-button>
  80. <el-button @click="dialogVisible = false">取 消</el-button>
  81. <el-button type="primary" @click="onSubmit('form')">{{
  82. showType ? "更 新" : "新 增"
  83. }}</el-button>
  84. </span>
  85. </el-dialog>
  86. <el-dialog :title="cameraTitle" :visible.sync="isVideo" width="50%">
  87. <div style="width: 100%; height: 560px; text-align: center;">
  88. <iframe
  89. v-if="isVideo"
  90. :src="
  91. 'static/jinm/index.html?' +
  92. '1' +
  93. ',' +
  94. cameraOne +
  95. ',' +
  96. cameraTwo +
  97. ',' +
  98. '100%' +
  99. ',' +
  100. '0'
  101. "
  102. style="width: 100%; height: 530px;"
  103. frameborder="0"
  104. allowfullscreen="true"
  105. ></iframe>
  106. </div>
  107. </el-dialog>
  108. </div>
  109. </template>
  110. <script>
  111. import NewTable from "../../components/newTable/NewTable";
  112. import {getVideoAll, baseVideoAdd, baseVideoList, baseVideoDel, baseVideoEdit, getVideo} from "../../utils/api";
  113. export default {
  114. name: "VideoLook",
  115. components: {
  116. NewTable
  117. },
  118. data() {
  119. return {
  120. title: '视频列表',
  121. tableItems: [
  122. {
  123. prop: "id",
  124. label: "ID",
  125. minWidth: "50",
  126. slotName: "id",
  127. },
  128. {
  129. prop: "videoName",
  130. label: "摄像头名称",
  131. minWidth: "100",
  132. slotName: "videoName",
  133. },
  134. {
  135. label: "所属大屏位置",
  136. minWidth: "100",
  137. slotName: "type",
  138. },
  139. {
  140. label: "操作",
  141. minWidth: "150",
  142. slotName: "handler",
  143. },
  144. ],
  145. tableShows: {
  146. showIndex: false,
  147. showSelect: false,
  148. },
  149. videoLists: [],
  150. typeList: [
  151. {
  152. id: 1,
  153. name: '门卫管控'
  154. },
  155. {
  156. id: 2,
  157. name: '环境监测'
  158. }
  159. ],
  160. showType: false,
  161. dialogVisible: false,
  162. form: {
  163. videoId: '',
  164. type: ''
  165. },
  166. options: [],
  167. selectVideo: [],
  168. rules: {
  169. type: [{ required: true, message: '请选择位置', trigger: 'change' }],
  170. },
  171. cameraTitle: '',
  172. isVideo: false,
  173. cameraOne: '',
  174. cameraTwo: '',
  175. }
  176. },
  177. methods: {
  178. init() {
  179. baseVideoList({}).then(res => {
  180. if(res.code === 10000) {
  181. this.videoLists = res.data;
  182. }
  183. })
  184. },
  185. initVideo() {
  186. getVideoAll({}).then(res => {
  187. if(res.code === 10000) {
  188. res.data.forEach(item => {
  189. item.cameraList.forEach(items => {
  190. items.runStatus = !items.runStatus
  191. })
  192. })
  193. this.options = res.data;
  194. }
  195. })
  196. },
  197. getType(val) {
  198. let str = '';
  199. this.typeList.forEach(item => {
  200. if(item.id === val) {
  201. str = item.name
  202. }
  203. })
  204. return str
  205. },
  206. add() {
  207. this.dialogVisible = true;
  208. this.showType = false;
  209. },
  210. edit(row) {
  211. this.dialogVisible = true;
  212. this.showType = true;
  213. this.form.id = row.id;
  214. this.form.type = row.type;
  215. this.form.videoId = row.videoId;
  216. let arr = row.selectVideo.split(',');
  217. this.selectVideo = arr.map(Number);
  218. },
  219. del(val) {
  220. let params = {
  221. id: val.id
  222. }
  223. baseVideoDel(params).then(res => {
  224. if(res.code === 10000) {
  225. this.init()
  226. this.$message.success(res.message);
  227. } else {
  228. this.$message.error(res.message);
  229. }
  230. })
  231. },
  232. open(row) {
  233. let params = {
  234. cameraIds: [row.videoId]
  235. }
  236. getVideo(params).then(res => {
  237. this.isVideo = true;
  238. this.cameraOne = res.data[0].wsUrl;
  239. this.cameraTwo = res.data[0].rtspUrl;
  240. })
  241. },
  242. handleChange(value) {
  243. this.form.videoId = value[value.length - 1];
  244. },
  245. onSubmit(formName) {
  246. this.$refs[formName].validate((valid) => {
  247. if (valid) {
  248. if (this.showType) {
  249. let params = {
  250. id: this.form.id,
  251. videoId: this.form.videoId,
  252. type: this.form.type,
  253. selectVideo: this.selectVideo.join(',')
  254. }
  255. baseVideoEdit(params).then(res => {
  256. if(res.code === 10000) {
  257. this.init()
  258. this.$message.success(res.message);
  259. } else {
  260. this.$message.error(res.message);
  261. }
  262. this.dialogVisible = false;
  263. })
  264. } else {
  265. let params = {
  266. videoId: this.form.videoId,
  267. type: this.form.type,
  268. selectVideo: this.selectVideo.join(',')
  269. }
  270. baseVideoAdd(params).then(res => {
  271. if(res.code === 10000) {
  272. this.init()
  273. this.$message.success(res.message);
  274. } else {
  275. this.$message.error(res.message);
  276. }
  277. this.dialogVisible = false;
  278. })
  279. }
  280. } else {
  281. console.log("error submit!!");
  282. return false;
  283. }
  284. });
  285. },
  286. },
  287. mounted() {
  288. this.initVideo();
  289. this.init();
  290. }
  291. }
  292. </script>
  293. <style scoped>
  294. </style>