index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="88px">
  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. >新增
  26. </el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button
  30. type="danger"
  31. plain
  32. icon="el-icon-delete"
  33. size="mini"
  34. :disabled="multiple"
  35. @click="handleDelete"
  36. >删除
  37. </el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button
  41. type="success"
  42. plain
  43. icon="el-icon-refresh"
  44. size="mini"
  45. @click="handleCamera"
  46. >同步摄像头
  47. </el-button>
  48. </el-col>
  49. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  50. </el-row>
  51. <el-table v-loading="loading" :data="cameraList" @selection-change="handleSelectionChange">
  52. <el-table-column type="selection" width="55" align="center"/>
  53. <el-table-column label="序号" align="center" type="index"/>
  54. <el-table-column label="监控点" align="center" prop="cameraIndexCode"/>
  55. <el-table-column label="摄像头名称" align="center" prop="cameraName"/>
  56. <el-table-column label="摄像头类型" align="center" prop="cameraTypeName"/>
  57. <el-table-column label="经度" align="center" prop="longitude"/>
  58. <el-table-column label="维度" align="center" prop="latitude"/>
  59. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  60. <template slot-scope="scope">
  61. <el-button
  62. size="mini"
  63. type="text"
  64. icon="el-icon-edit"
  65. @click="handleUpdate(scope.row)"
  66. >修改
  67. </el-button>
  68. <el-button
  69. size="mini"
  70. type="text"
  71. icon="el-icon-delete"
  72. @click="handleDelete(scope.row)"
  73. >删除
  74. </el-button>
  75. <el-button
  76. size="mini"
  77. type="text"
  78. icon="el-icon-s-custom"
  79. @click="handleDept(scope.row)"
  80. >部门管理
  81. </el-button>
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. <pagination
  86. v-show="total>0"
  87. :total="total"
  88. :page.sync="queryParams.pageNum"
  89. :limit.sync="queryParams.pageSize"
  90. @pagination="getList"
  91. />
  92. <!-- 添加或修改摄像头对话框 -->
  93. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  94. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  95. <el-form-item label="监控点" prop="cameraIndexCode">
  96. <el-input v-model="form.cameraIndexCode" placeholder="请输入监控点"/>
  97. </el-form-item>
  98. <el-form-item label="摄像头名称" prop="cameraName">
  99. <el-input v-model="form.cameraName" placeholder="请输入摄像头名称"/>
  100. </el-form-item>
  101. <el-form-item label="经度" prop="longitude">
  102. <el-input v-model="form.longitude" placeholder="请输入经度"/>
  103. </el-form-item>
  104. <el-form-item label="维度" prop="latitude">
  105. <el-input v-model="form.latitude" placeholder="请输入维度"/>
  106. </el-form-item>
  107. <el-form-item label="部门名称" prop="parentId">
  108. <treeselect v-model="form.parentId" :normalizer="normalizer" :options="deptOptions"
  109. placeholder="请选择部门名称"/>
  110. </el-form-item>
  111. </el-form>
  112. <div slot="footer" class="dialog-footer">
  113. <el-button type="primary" @click="submitForm">确 定</el-button>
  114. <el-button @click="cancel">取 消</el-button>
  115. </div>
  116. </el-dialog>
  117. </div>
  118. </template>
  119. <script>
  120. import {addCamera, delCamera, getCamera, getCameraList, listCamera, updateCamera} from "@/api/system/camera";
  121. import Treeselect from "@riophae/vue-treeselect";
  122. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  123. import {listDept} from "@/api/system/dept";
  124. export default {
  125. name: "Camera",
  126. components: {Treeselect},
  127. data() {
  128. return {
  129. // 遮罩层
  130. loading: true,
  131. // 选中数组
  132. ids: [],
  133. // 非单个禁用
  134. single: true,
  135. // 非多个禁用
  136. multiple: true,
  137. // 显示搜索条件
  138. showSearch: true,
  139. // 总条数
  140. total: 0,
  141. // 摄像头表格数据
  142. cameraList: [],
  143. // 弹出层标题
  144. title: "",
  145. // 是否显示弹出层
  146. open: false,
  147. // 查询参数
  148. queryParams: {
  149. pageNum: 1,
  150. pageSize: 10,
  151. cameraIndexCode: null,
  152. cameraName: null,
  153. cameraTypeName: null,
  154. longitude: null,
  155. latitude: null,
  156. deptId: null,
  157. },
  158. // 表单参数
  159. form: {},
  160. // 表单校验
  161. rules: {},
  162. // 表格树数据
  163. deptList: [],
  164. // 部门树选项
  165. deptOptions: [],
  166. };
  167. },
  168. created() {
  169. this.getList();
  170. },
  171. methods: {
  172. handleDept(){},
  173. /** 同步摄像头 */
  174. handleCamera(){
  175. getCameraList().then(res => {
  176. if(res.code == 200){
  177. this.$modal.msgSuccess("同步成功");
  178. }
  179. this.getList();
  180. })
  181. },
  182. /** 查询部门列表 */
  183. getDeptList() {
  184. this.loading = true;
  185. listDept({}).then(response => {
  186. this.deptList = this.handleTree(response.data, "deptId");
  187. this.loading = false;
  188. });
  189. console.log("deptList", this.deptList);
  190. },
  191. /** 转换部门数据结构 */
  192. normalizer(node) {
  193. if (node.children && !node.children.length) {
  194. delete node.children;
  195. }
  196. return {
  197. id: node.deptId,
  198. label: node.deptName,
  199. children: node.children
  200. };
  201. },
  202. /** 查询摄像头列表 */
  203. getList() {
  204. this.loading = true;
  205. listCamera(this.queryParams).then(response => {
  206. this.cameraList = response.rows;
  207. this.total = response.total;
  208. this.loading = false;
  209. });
  210. },
  211. // 取消按钮
  212. cancel() {
  213. this.open = false;
  214. this.reset();
  215. },
  216. // 表单重置
  217. reset() {
  218. this.form = {
  219. id: null,
  220. cameraIndexCode: null,
  221. cameraName: null,
  222. cameraTypeName: null,
  223. longitude: null,
  224. latitude: null,
  225. deptId: null,
  226. createBy: null,
  227. createTime: null,
  228. updateBy: null,
  229. updateTime: null
  230. };
  231. this.resetForm("form");
  232. },
  233. /** 搜索按钮操作 */
  234. handleQuery() {
  235. this.queryParams.pageNum = 1;
  236. this.getList();
  237. },
  238. /** 重置按钮操作 */
  239. resetQuery() {
  240. this.resetForm("queryForm");
  241. this.handleQuery();
  242. },
  243. // 多选框选中数据
  244. handleSelectionChange(selection) {
  245. this.ids = selection.map(item => item.id)
  246. this.single = selection.length !== 1
  247. this.multiple = !selection.length
  248. },
  249. /** 新增按钮操作 */
  250. handleAdd() {
  251. this.reset();
  252. this.getDeptList();
  253. this.open = true;
  254. this.title = "添加摄像头";
  255. },
  256. /** 修改按钮操作 */
  257. handleUpdate(row) {
  258. this.reset();
  259. const id = row.id || this.ids
  260. getCamera(id).then(response => {
  261. this.form = response.data;
  262. this.open = true;
  263. this.title = "修改摄像头";
  264. });
  265. },
  266. /** 提交按钮 */
  267. submitForm() {
  268. this.form.sort = this.value
  269. this.$refs["form"].validate(valid => {
  270. if (valid) {
  271. if (this.form.id != null) {
  272. updateCamera(this.form).then(response => {
  273. this.$modal.msgSuccess("修改成功");
  274. this.open = false;
  275. this.getList();
  276. });
  277. } else {
  278. addCamera(this.form).then(response => {
  279. this.$modal.msgSuccess("新增成功");
  280. this.open = false;
  281. this.getList();
  282. });
  283. }
  284. }
  285. });
  286. },
  287. /** 删除按钮操作 */
  288. handleDelete(row) {
  289. const ids = row.id || this.ids;
  290. this.$modal.confirm('是否确认删除数据项?').then(function () {
  291. return delCamera(ids);
  292. }).then(() => {
  293. this.getList();
  294. this.$modal.msgSuccess("删除成功");
  295. }).catch(() => {
  296. });
  297. }
  298. }
  299. };
  300. </script>