index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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 label="经度" prop="longitude">
  13. <el-input
  14. v-model="queryParams.longitude"
  15. placeholder="请输入经度"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="纬度" prop="latitude">
  21. <el-input
  22. v-model="queryParams.latitude"
  23. placeholder="请输入纬度"
  24. clearable
  25. @keyup.enter.native="handleQuery"
  26. />
  27. </el-form-item>
  28. <el-form-item>
  29. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  30. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  31. </el-form-item>
  32. </el-form>
  33. <el-row :gutter="10" class="mb8">
  34. <el-col :span="1.5">
  35. <el-button
  36. type="primary"
  37. plain
  38. icon="el-icon-plus"
  39. size="mini"
  40. @click="handleAdd"
  41. v-hasPermi="['system:camera:add']"
  42. >新增
  43. </el-button>
  44. </el-col>
  45. <el-col :span="1.5">
  46. <el-button
  47. type="success"
  48. plain
  49. icon="el-icon-edit"
  50. size="mini"
  51. :disabled="single"
  52. @click="handleUpdate"
  53. v-hasPermi="['system:camera:edit']"
  54. >修改
  55. </el-button>
  56. </el-col>
  57. <el-col :span="1.5">
  58. <el-button
  59. type="danger"
  60. plain
  61. icon="el-icon-delete"
  62. size="mini"
  63. :disabled="multiple"
  64. @click="handleDelete"
  65. v-hasPermi="['system:camera:remove']"
  66. >删除
  67. </el-button>
  68. </el-col>
  69. <el-col :span="1.5">
  70. <el-button
  71. type="warning"
  72. plain
  73. icon="el-icon-download"
  74. size="mini"
  75. @click="handleExport"
  76. v-hasPermi="['system:camera:export']"
  77. >导出
  78. </el-button>
  79. </el-col>
  80. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  81. </el-row>
  82. <el-table v-loading="loading" :data="cameraList" @selection-change="handleSelectionChange">
  83. <el-table-column type="selection" width="55" align="center"/>
  84. <el-table-column label="名称" align="center" prop="cameraName"/>
  85. <el-table-column label="归属派出所" align="center" prop="policeName"/>
  86. <el-table-column label="点位具体位置" align="center" prop="address"/>
  87. <el-table-column label="经度" align="center" prop="longitude"/>
  88. <el-table-column label="纬度" align="center" prop="latitude"/>
  89. <el-table-column label="摄像头状态" prop="cameraStatus" width="100">
  90. <template slot-scope="scope">
  91. <dict-tag :options="dict.type.camera_status" :value="scope.row.cameraStatus"/>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="类型" prop="buildType" width="100">
  95. <template slot-scope="scope">
  96. <dict-tag :options="dict.type.build_type" :value="scope.row.buildType"/>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  100. <template slot-scope="scope">
  101. <el-button
  102. size="mini"
  103. type="text"
  104. icon="el-icon-edit"
  105. @click="handleUpdate(scope.row)"
  106. v-hasPermi="['system:camera:edit']"
  107. >修改
  108. </el-button>
  109. <el-button
  110. size="mini"
  111. type="text"
  112. icon="el-icon-delete"
  113. @click="handleDelete(scope.row)"
  114. v-hasPermi="['system:camera:remove']"
  115. >删除
  116. </el-button>
  117. </template>
  118. </el-table-column>
  119. </el-table>
  120. <pagination
  121. v-show="total>0"
  122. :total="total"
  123. :page.sync="queryParams.pageNum"
  124. :limit.sync="queryParams.pageSize"
  125. @pagination="getList"
  126. />
  127. <!-- 添加或修改摄像头对话框 -->
  128. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
  129. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  130. <el-form-item label="摄像头名称" prop="cameraName">
  131. <el-input v-model="form.cameraName" placeholder="请输入摄像头名称" maxlength="20"/>
  132. </el-form-item>
  133. <el-form-item label="归属派出所" prop="policeName">
  134. <el-select v-model="form.policeName" filterable placeholder="请选择项目名称" @change="onChange">
  135. <el-option
  136. v-for="item in projectData"
  137. :key="item.id"
  138. :label="item.policeName"
  139. :value="item.id">
  140. </el-option>
  141. </el-select>
  142. </el-form-item>
  143. <el-form-item label="点位具体位置" prop="address">
  144. <el-input v-model="form.address" placeholder="请输入点位具体位置" maxlength="20"/>
  145. </el-form-item>
  146. <el-form-item label="经度" prop="longitude">
  147. <el-input v-model="form.longitude" placeholder="请输入经度"/>
  148. </el-form-item>
  149. <el-form-item label="纬度" prop="latitude">
  150. <el-input v-model="form.latitude" placeholder="请输入纬度"/>
  151. </el-form-item>
  152. <el-form-item label="摄像头状态">
  153. <el-select v-model="form.cameraStatus" placeholder="请选择摄像头状态">
  154. <el-option
  155. v-for="dict in dict.type.camera_status"
  156. :key="dict.value"
  157. :label="dict.label"
  158. :value="dict.value"
  159. ></el-option>
  160. </el-select>
  161. </el-form-item>
  162. <el-form-item label="类型">
  163. <el-select v-model="form.buildType" placeholder="请选择类型">
  164. <el-option
  165. v-for="dict in dict.type.build_type"
  166. :key="dict.value"
  167. :label="dict.label"
  168. :value="dict.value"
  169. ></el-option>
  170. </el-select>
  171. </el-form-item>
  172. </el-form>
  173. <div slot="footer" class="dialog-footer">
  174. <el-button type="primary" @click="submitForm">确 定</el-button>
  175. <el-button @click="cancel">取 消</el-button>
  176. </div>
  177. </el-dialog>
  178. </div>
  179. </template>
  180. <script>
  181. import {getCamera, listCamera,addCamera, delCamera, updateCamera} from "@/api/system/camera";
  182. import {listAllPolice} from "@/api/system/station";
  183. import {checkLat, checkLon} from "@/api/system/rules";
  184. export default {
  185. name: "Camera",
  186. dicts: ['build_type',"camera_status"],
  187. data() {
  188. return {
  189. // 遮罩层
  190. loading: true,
  191. // 选中数组
  192. ids: [],
  193. // 非单个禁用
  194. single: true,
  195. // 非多个禁用
  196. multiple: true,
  197. // 显示搜索条件
  198. showSearch: true,
  199. // 总条数
  200. total: 0,
  201. // 摄像头表格数据
  202. cameraList: [],
  203. // 弹出层标题
  204. title: "",
  205. // 是否显示弹出层
  206. open: false,
  207. // 查询参数
  208. queryParams: {
  209. pageNum: 1,
  210. pageSize: 10,
  211. cameraName: null,
  212. address: null,
  213. longitude: null,
  214. latitude: null,
  215. buildType: null
  216. },
  217. projectData: [],
  218. // 表单参数
  219. form: {},
  220. // 表单校验
  221. rules: {
  222. longitude: [
  223. { required: true, message: "经度不能为空", trigger: "change" },
  224. {validator: checkLon, trigger: 'blur'}
  225. ],
  226. cameraName: [
  227. { required: true, message: "摄像头名称不能为空", trigger: "change" },
  228. ],
  229. latitude: [
  230. { required: true, message: "纬度不能为空", trigger: "change" },
  231. {validator: checkLat, trigger: 'blur'}
  232. ],
  233. }
  234. };
  235. },
  236. created() {
  237. this.getList();
  238. this.getProjectList();
  239. },
  240. methods: {
  241. /** 查询摄像头列表 */
  242. getList() {
  243. this.loading = true;
  244. listCamera(this.queryParams).then(response => {
  245. this.cameraList = response.rows;
  246. this.total = response.total;
  247. this.loading = false;
  248. });
  249. },
  250. /** 查询派出所管理列表 */
  251. getProjectList() {
  252. this.loading = true;
  253. listAllPolice().then(response => {
  254. this.projectData = response.data;
  255. });
  256. },
  257. // 取消按钮
  258. cancel() {
  259. this.open = false;
  260. this.reset();
  261. },
  262. // 表单重置
  263. reset() {
  264. this.form = {
  265. id: null,
  266. projectName: null,
  267. address: null,
  268. longitude: null,
  269. latitude: null,
  270. buildType: null
  271. };
  272. this.resetForm("form");
  273. },
  274. /** 搜索按钮操作 */
  275. handleQuery() {
  276. this.queryParams.pageNum = 1;
  277. this.getList();
  278. this.getProjectList();
  279. },
  280. /** 重置按钮操作 */
  281. resetQuery() {
  282. this.resetForm("queryForm");
  283. this.handleQuery();
  284. },
  285. // 多选框选中数据
  286. handleSelectionChange(selection) {
  287. this.ids = selection.map(item => item.id)
  288. this.single = selection.length !== 1
  289. this.multiple = !selection.length
  290. },
  291. /** 新增按钮操作 */
  292. handleAdd() {
  293. this.reset();
  294. this.open = true;
  295. this.title = "添加摄像头";
  296. },
  297. /** 修改按钮操作 */
  298. handleUpdate(row) {
  299. this.reset();
  300. const id = row.id || this.ids
  301. getCamera(id).then(response => {
  302. this.form = response.data;
  303. this.open = true;
  304. this.title = "修改摄像头";
  305. });
  306. },
  307. onChange(e) {
  308. this.form.policeId = e
  309. this.form.policeName = this.projectData.find(item => item.id == e).policeName
  310. },
  311. /** 提交按钮 */
  312. submitForm() {
  313. this.$refs["form"].validate(valid => {
  314. if (valid) {
  315. if (this.form.id != null) {
  316. updateCamera(this.form).then(response => {
  317. this.$modal.msgSuccess("修改成功");
  318. this.open = false;
  319. this.getList();
  320. this.getProjectList();
  321. });
  322. } else {
  323. addCamera(this.form).then(response => {
  324. this.$modal.msgSuccess("新增成功");
  325. this.open = false;
  326. this.getList();
  327. this.getProjectList();
  328. });
  329. }
  330. }
  331. });
  332. },
  333. /** 删除按钮操作 */
  334. handleDelete(row) {
  335. const ids = row.id || this.ids;
  336. this.$modal.confirm('是否确认删除摄像头编号为"' + ids + '"的数据项?').then(function () {
  337. return delCamera(ids);
  338. }).then(() => {
  339. this.getList();
  340. this.getProjectList();
  341. this.$modal.msgSuccess("删除成功");
  342. }).catch(() => {
  343. });
  344. },
  345. /** 导出按钮操作 */
  346. handleExport() {
  347. this.download('system/camera/export', {
  348. ...this.queryParams
  349. }, `camera_${new Date().getTime()}.xlsx`)
  350. }
  351. }
  352. }
  353. ;
  354. </script>