index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="摄像机名称" prop="cameraName">
  5. <el-input
  6. v-model="queryParams.cameraName"
  7. placeholder="请输入摄像机名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  14. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <el-row :gutter="10" class="mb8">
  18. <el-col :span="1.5">
  19. <el-button
  20. type="primary"
  21. plain
  22. icon="el-icon-plus"
  23. size="mini"
  24. @click="handleAdd"
  25. v-hasPermi="['bd:camera:add']"
  26. >新增</el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button
  30. type="success"
  31. plain
  32. icon="el-icon-edit"
  33. size="mini"
  34. :disabled="single"
  35. @click="handleUpdate"
  36. v-hasPermi="['bd:camera:edit']"
  37. >修改</el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button
  41. type="danger"
  42. plain
  43. icon="el-icon-delete"
  44. size="mini"
  45. :disabled="multiple"
  46. @click="handleDelete"
  47. v-hasPermi="['bd:camera:remove']"
  48. >删除</el-button>
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-button
  52. type="warning"
  53. plain
  54. icon="el-icon-download"
  55. size="mini"
  56. @click="handleExport"
  57. v-hasPermi="['bd:camera:export']"
  58. >导出</el-button>
  59. </el-col>
  60. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  61. </el-row>
  62. <el-table v-loading="loading" :data="cameraList" @selection-change="handleSelectionChange">
  63. <el-table-column type="selection" width="55" align="center" />
  64. <el-table-column label="编号" align="center" prop="id" />
  65. <el-table-column label="摄像机名称" align="center" prop="cameraName" />
  66. <el-table-column label="流地址" align="center" prop="cameraStream" />
  67. <el-table-column label="web直播流" align="center" prop="liveStream" />
  68. <el-table-column label="通道号" align="center" prop="channelCode" />
  69. <el-table-column label="创建时间" align="center" prop="updateTime" width="180">
  70. <template slot-scope="scope">
  71. <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="修改时间" align="center" prop="createTime" width="180">
  75. <template slot-scope="scope">
  76. <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  80. <template slot-scope="scope">
  81. <el-button
  82. size="mini"
  83. type="text"
  84. icon="el-icon-edit"
  85. @click="handleUpdate(scope.row)"
  86. v-hasPermi="['bd:camera:edit']"
  87. >修改</el-button>
  88. <el-button
  89. size="mini"
  90. type="text"
  91. icon="el-icon-delete"
  92. @click="handleDelete(scope.row)"
  93. v-hasPermi="['bd:camera:remove']"
  94. >删除</el-button>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. <pagination
  99. v-show="total>0"
  100. :total="total"
  101. :page.sync="queryParams.pageNum"
  102. :limit.sync="queryParams.pageSize"
  103. @pagination="getList"
  104. />
  105. <!-- 添加或修改视频设备对话框 -->
  106. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  107. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  108. <el-form-item label="摄像机名称" prop="cameraName">
  109. <el-input v-model="form.cameraName" placeholder="请输入摄像机名称" />
  110. </el-form-item>
  111. <el-form-item label="流地址" prop="cameraStream">
  112. <el-input v-model="form.cameraStream" placeholder="请输入流地址" />
  113. </el-form-item>
  114. <el-form-item label="web直播流" prop="liveStream">
  115. <el-input v-model="form.liveStream" placeholder="请输入web直播流" />
  116. </el-form-item>
  117. <el-form-item label="通道号" prop="channelCode">
  118. <el-input v-model="form.channelCode" placeholder="请输入通道号" />
  119. </el-form-item>
  120. </el-form>
  121. <div slot="footer" class="dialog-footer">
  122. <el-button type="primary" @click="submitForm">确 定</el-button>
  123. <el-button @click="cancel">取 消</el-button>
  124. </div>
  125. </el-dialog>
  126. </div>
  127. </template>
  128. <script>
  129. import { listCamera, getCamera, delCamera, addCamera, updateCamera } from "@/api/bd/camera";
  130. export default {
  131. name: "Camera",
  132. data() {
  133. return {
  134. // 遮罩层
  135. loading: true,
  136. // 选中数组
  137. ids: [],
  138. // 非单个禁用
  139. single: true,
  140. // 非多个禁用
  141. multiple: true,
  142. // 显示搜索条件
  143. showSearch: true,
  144. // 总条数
  145. total: 0,
  146. // 视频设备表格数据
  147. cameraList: [],
  148. // 弹出层标题
  149. title: "",
  150. // 是否显示弹出层
  151. open: false,
  152. // 查询参数
  153. queryParams: {
  154. pageNum: 1,
  155. pageSize: 10,
  156. cameraName: null,
  157. },
  158. // 表单参数
  159. form: {},
  160. // 表单校验
  161. rules: {
  162. }
  163. };
  164. },
  165. created() {
  166. this.getList();
  167. },
  168. methods: {
  169. /** 查询视频设备列表 */
  170. getList() {
  171. this.loading = true;
  172. listCamera(this.queryParams).then(response => {
  173. this.cameraList = response.rows;
  174. this.total = response.total;
  175. this.loading = false;
  176. });
  177. },
  178. // 取消按钮
  179. cancel() {
  180. this.open = false;
  181. this.reset();
  182. },
  183. // 表单重置
  184. reset() {
  185. this.form = {
  186. id: null,
  187. cameraName: null,
  188. cameraStream: null,
  189. liveStream: null,
  190. channelCode: null,
  191. updateTime: null,
  192. createTime: null,
  193. createBy: null,
  194. updateBy: null
  195. };
  196. this.resetForm("form");
  197. },
  198. /** 搜索按钮操作 */
  199. handleQuery() {
  200. this.queryParams.pageNum = 1;
  201. this.getList();
  202. },
  203. /** 重置按钮操作 */
  204. resetQuery() {
  205. this.resetForm("queryForm");
  206. this.handleQuery();
  207. },
  208. // 多选框选中数据
  209. handleSelectionChange(selection) {
  210. this.ids = selection.map(item => item.id)
  211. this.single = selection.length!==1
  212. this.multiple = !selection.length
  213. },
  214. /** 新增按钮操作 */
  215. handleAdd() {
  216. this.reset();
  217. this.open = true;
  218. this.title = "添加视频设备";
  219. },
  220. /** 修改按钮操作 */
  221. handleUpdate(row) {
  222. this.reset();
  223. const id = row.id || this.ids
  224. getCamera(id).then(response => {
  225. this.form = response.data;
  226. this.open = true;
  227. this.title = "修改视频设备";
  228. });
  229. },
  230. /** 提交按钮 */
  231. submitForm() {
  232. this.$refs["form"].validate(valid => {
  233. if (valid) {
  234. if (this.form.id != null) {
  235. updateCamera(this.form).then(response => {
  236. this.$modal.msgSuccess("修改成功");
  237. this.open = false;
  238. this.getList();
  239. });
  240. } else {
  241. addCamera(this.form).then(response => {
  242. this.$modal.msgSuccess("新增成功");
  243. this.open = false;
  244. this.getList();
  245. });
  246. }
  247. }
  248. });
  249. },
  250. /** 删除按钮操作 */
  251. handleDelete(row) {
  252. const ids = row.id || this.ids;
  253. this.$modal.confirm('是否确认删除视频设备编号为"' + ids + '"的数据项?').then(function() {
  254. return delCamera(ids);
  255. }).then(() => {
  256. this.getList();
  257. this.$modal.msgSuccess("删除成功");
  258. }).catch(() => {});
  259. },
  260. /** 导出按钮操作 */
  261. handleExport() {
  262. this.download('bd/camera/export', {
  263. ...this.queryParams
  264. }, `camera_${new Date().getTime()}.xlsx`)
  265. }
  266. }
  267. };
  268. </script>