index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <div class="app-container">
  3. <el-dialog :visible.sync="showLongitude" append-to-body>
  4. 经度
  5. <el-input v-model="form.longitude"></el-input>
  6. 纬度
  7. <el-input v-model="form.latitude"></el-input>
  8. <supermap ref="enterprisemap" :visible.sync="showLongitude"
  9. style="width: 100%;height: 500px;" :setLatLng="setLatLng"></supermap>
  10. <el-button type="primary" @click="showLongitude=false">确定</el-button>
  11. </el-dialog>
  12. <el-form :model="queryParams" class="formclass" ref="queryForm" size="large" :inline="true" v-show="showSearch"
  13. label-width="100px">
  14. <el-form-item label="巡更点名称" prop="busPatrolstationName">
  15. <el-input
  16. v-model="queryParams.busPatrolstationName"
  17. placeholder="请输入巡更点名称"
  18. clearable
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="编码" prop="busPatrolstationCode">
  23. <el-input
  24. v-model="queryParams.busPatrolstationCode"
  25. placeholder="请输入编码"
  26. clearable
  27. @keyup.enter.native="handleQuery"
  28. />
  29. </el-form-item>
  30. <!--<el-form-item label="所属企业id" prop="busEnterpriseId">-->
  31. <!--<el-input-->
  32. <!--v-model="queryParams.busEnterpriseId"-->
  33. <!--placeholder="请输入所属企业id"-->
  34. <!--clearable-->
  35. <!--@keyup.enter.native="handleQuery"-->
  36. <!--/>-->
  37. <!--</el-form-item>-->
  38. <!--<el-form-item label="所属企业名称" prop="busEnterpriseName">-->
  39. <!--<el-input-->
  40. <!--v-model="queryParams.busEnterpriseName"-->
  41. <!--placeholder="请输入所属企业名称"-->
  42. <!--clearable-->
  43. <!--@keyup.enter.native="handleQuery"-->
  44. <!--/>-->
  45. <!--</el-form-item>-->
  46. <!--<el-form-item label="经度" prop="longitude">-->
  47. <!--<el-input-->
  48. <!--v-model="queryParams.longitude"-->
  49. <!--placeholder="请输入经度"-->
  50. <!--clearable-->
  51. <!--@keyup.enter.native="handleQuery"-->
  52. <!--/>-->
  53. <!--</el-form-item>-->
  54. <!--<el-form-item label="纬度" prop="latitude">-->
  55. <!--<el-input-->
  56. <!--v-model="queryParams.latitude"-->
  57. <!--placeholder="请输入纬度"-->
  58. <!--clearable-->
  59. <!--@keyup.enter.native="handleQuery"-->
  60. <!--/>-->
  61. <!--</el-form-item>-->
  62. <!--<el-form-item label="备注" prop="remarks">-->
  63. <!--<el-input-->
  64. <!--v-model="queryParams.remarks"-->
  65. <!--placeholder="请输入备注"-->
  66. <!--clearable-->
  67. <!--@keyup.enter.native="handleQuery"-->
  68. <!--/>-->
  69. <!--</el-form-item>-->
  70. <el-form-item>
  71. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  72. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  73. </el-form-item>
  74. </el-form>
  75. <el-row :gutter="10" class="mb8">
  76. <el-col :span="1.5">
  77. <el-button
  78. type="primary"
  79. plain
  80. icon="el-icon-plus"
  81. size="mini"
  82. @click="handleAdd"
  83. v-hasPermi="['system:patrolstation:add']"
  84. >新增
  85. </el-button>
  86. </el-col>
  87. <el-col :span="1.5">
  88. <el-button
  89. type="success"
  90. plain
  91. icon="el-icon-edit"
  92. size="mini"
  93. :disabled="single"
  94. @click="handleUpdate"
  95. v-hasPermi="['system:patrolstation:edit']"
  96. >修改
  97. </el-button>
  98. </el-col>
  99. <el-col :span="1.5">
  100. <el-button
  101. type="danger"
  102. plain
  103. icon="el-icon-delete"
  104. size="mini"
  105. :disabled="multiple"
  106. @click="handleDelete"
  107. v-hasPermi="['system:patrolstation:remove']"
  108. >删除
  109. </el-button>
  110. </el-col>
  111. <el-col :span="1.5">
  112. <el-button
  113. type="warning"
  114. plain
  115. icon="el-icon-download"
  116. size="mini"
  117. @click="handleExport"
  118. v-hasPermi="['system:patrolstation:export']"
  119. >导出
  120. </el-button>
  121. </el-col>
  122. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  123. </el-row>
  124. <el-table v-loading="loading" :data="patrolstationList" @selection-change="handleSelectionChange">
  125. <el-table-column type="selection" width="55" align="center"/>
  126. <!--<el-table-column label="id" align="center" prop="busPatrolstationId" />-->
  127. <el-table-column label="巡更点名称" align="center" prop="busPatrolstationName"/>
  128. <el-table-column label="编码" align="center" prop="busPatrolstationCode"/>
  129. <!--<el-table-column label="所属企业id" align="center" prop="busEnterpriseId" />-->
  130. <el-table-column label="所属企业名称" align="center" prop="busEnterpriseName"/>
  131. <el-table-column label="经度" align="center" prop="longitude"/>
  132. <el-table-column label="纬度" align="center" prop="latitude"/>
  133. <el-table-column label="备注" align="center" prop="remarks"/>
  134. <el-table-column label="状态" align="center" prop="delFlag"/>
  135. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  136. <template slot-scope="scope">
  137. <el-button
  138. size="mini"
  139. type="text"
  140. icon="el-icon-edit"
  141. @click="handleUpdate(scope.row)"
  142. v-hasPermi="['system:patrolstation:edit']"
  143. >修改
  144. </el-button>
  145. <el-button
  146. size="mini"
  147. type="text"
  148. icon="el-icon-delete"
  149. @click="handleDelete(scope.row)"
  150. v-hasPermi="['system:patrolstation:remove']"
  151. >废弃
  152. </el-button>
  153. </template>
  154. </el-table-column>
  155. </el-table>
  156. <pagination
  157. v-show="total>0"
  158. :total="total"
  159. :page.sync="queryParams.pageNum"
  160. :limit.sync="queryParams.pageSize"
  161. @pagination="getList"
  162. />
  163. <!-- 添加或修改巡更点对话框 -->
  164. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  165. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  166. <el-form-item label="名称" prop="busPatrolstationName">
  167. <el-input v-model="form.busPatrolstationName" placeholder="请输入巡更点名称"/>
  168. </el-form-item>
  169. <el-form-item label="编码" prop="busPatrolstationCode">
  170. <el-input v-model="form.busPatrolstationCode" placeholder="请输入编码"/>
  171. </el-form-item>
  172. <!--<el-form-item label="所属企业id" prop="busEnterpriseId">-->
  173. <!--<el-input v-model="form.busEnterpriseId" placeholder="请输入所属企业id" />-->
  174. <!--</el-form-item>-->
  175. <!--<el-form-item label="所属企业名称" prop="busEnterpriseName">-->
  176. <!--<el-input v-model="form.busEnterpriseName" placeholder="请输入所属企业名称" />-->
  177. <!--</el-form-item>-->
  178. <el-form-item label="经度" prop="longitude" @dblclick.native="showMap">
  179. <el-input v-model="form.longitude" placeholder="请输入经度"/>
  180. </el-form-item>
  181. <el-form-item label="纬度" prop="latitude" @dblclick.native="showMap">
  182. <el-input v-model="form.latitude" placeholder="请输入纬度"/>
  183. </el-form-item>
  184. <el-form-item label="备注" prop="remarks">
  185. <el-input v-model="form.remarks" placeholder="请输入备注"/>
  186. </el-form-item>
  187. </el-form>
  188. <div slot="footer" class="dialog-footer">
  189. <el-button type="primary" @click="submitForm">确 定</el-button>
  190. <el-button @click="cancel">取 消</el-button>
  191. </div>
  192. </el-dialog>
  193. </div>
  194. </template>
  195. <script>
  196. import {
  197. listPatrolstation,
  198. getPatrolstation,
  199. delPatrolstation,
  200. addPatrolstation,
  201. updatePatrolstation
  202. } from "@/api/centerdata_emergency1/patrolstation";
  203. import supermap from './supermap'
  204. export default {
  205. name: "Patrolstation",
  206. components: {
  207. supermap
  208. },
  209. data() {
  210. return {
  211. showLongitude: false,
  212. // 遮罩层
  213. loading: true,
  214. // 选中数组
  215. ids: [],
  216. // 非单个禁用
  217. single: true,
  218. // 非多个禁用
  219. multiple: true,
  220. // 显示搜索条件
  221. showSearch: true,
  222. // 总条数
  223. total: 0,
  224. // 巡更点表格数据
  225. patrolstationList: [],
  226. // 弹出层标题
  227. title: "",
  228. // 是否显示弹出层
  229. open: false,
  230. // 查询参数
  231. queryParams: {
  232. pageNum: 1,
  233. pageSize: 10,
  234. busPatrolstationName: null,
  235. busPatrolstationCode: null,
  236. busEnterpriseId: null,
  237. busEnterpriseName: null,
  238. longitude: null,
  239. latitude: null,
  240. remarks: null
  241. },
  242. // 表单参数
  243. form: {},
  244. // 表单校验
  245. rules: {
  246. busPatrolstationCode: [
  247. {required: true, message: "巡更点编码不能为空", trigger: "blur"}
  248. ],
  249. busPatrolstationName: [
  250. {required: true, message: "巡更点名称不能为空", trigger: "blur"}
  251. ],
  252. }
  253. };
  254. },
  255. watch: {
  256. '$route.query.busEnterpriseId': {
  257. handler: function (newValue, oldValue) {
  258. if (newValue != undefined) {
  259. this.queryParams.busEnterpriseId = newValue
  260. }
  261. if (oldValue != undefined) {
  262. this.queryParams.busEnterpriseId = oldValue
  263. }
  264. this.getList();
  265. },
  266. }
  267. },
  268. created() {
  269. this.queryParams.busEnterpriseId = this.$route.query.busEnterpriseId
  270. this.form.busEnterpriseId = this.$route.query.busEnterpriseId
  271. this.form.busEnterpriseName = this.$route.query.busEnterpriseName
  272. this.getList();
  273. },
  274. methods: {
  275. showMap() {
  276. this.showLongitude = true
  277. this.$nextTick(() => {
  278. if (this.form.latitude != null && this.form.latitude != undefined && this.form.longitude != null && this.form.longitude != undefined) {
  279. this.$refs.enterprisemap.setMarker(this.form.latitude, this.form.longitude)
  280. }
  281. })
  282. },
  283. setLatLng: function (lat, lng) {
  284. this.form.latitude = lat
  285. this.form.longitude = lng
  286. },
  287. /** 查询巡更点列表 */
  288. getList() {
  289. this.loading = true;
  290. listPatrolstation(this.queryParams).then(response => {
  291. this.patrolstationList = response.rows;
  292. this.total = response.total;
  293. this.loading = false;
  294. });
  295. },
  296. // 取消按钮
  297. cancel() {
  298. this.open = false;
  299. this.reset();
  300. },
  301. // 表单重置
  302. reset() {
  303. this.form = {
  304. busPatrolstationId: null,
  305. busPatrolstationName: null,
  306. busPatrolstationCode: null,
  307. busEnterpriseId: this.form.busEnterpriseId,
  308. busEnterpriseName: this.form.busEnterpriseName,
  309. longitude: null,
  310. latitude: null,
  311. remarks: null
  312. };
  313. this.resetForm("form");
  314. },
  315. /** 搜索按钮操作 */
  316. handleQuery() {
  317. this.queryParams.pageNum = 1;
  318. this.getList();
  319. },
  320. /** 重置按钮操作 */
  321. resetQuery() {
  322. this.resetForm("queryForm");
  323. this.handleQuery();
  324. },
  325. // 多选框选中数据
  326. handleSelectionChange(selection) {
  327. this.ids = selection.map(item => item.busPatrolstationId)
  328. this.single = selection.length !== 1
  329. this.multiple = !selection.length
  330. },
  331. /** 新增按钮操作 */
  332. handleAdd() {
  333. this.reset();
  334. this.open = true;
  335. this.title = "添加巡更点";
  336. },
  337. /** 修改按钮操作 */
  338. handleUpdate(row) {
  339. this.reset();
  340. const busPatrolstationId = row.busPatrolstationId || this.ids
  341. getPatrolstation(busPatrolstationId).then(response => {
  342. this.form = response.data;
  343. this.open = true;
  344. this.title = "修改巡更点";
  345. });
  346. },
  347. /** 提交按钮 */
  348. submitForm() {
  349. this.$refs["form"].validate(valid => {
  350. if (valid) {
  351. if (this.form.busPatrolstationId != null) {
  352. updatePatrolstation(this.form).then(response => {
  353. this.$modal.msgSuccess("修改成功");
  354. this.open = false;
  355. this.getList();
  356. });
  357. } else {
  358. addPatrolstation(this.form).then(response => {
  359. this.$modal.msgSuccess("新增成功");
  360. this.open = false;
  361. this.getList();
  362. });
  363. }
  364. }
  365. });
  366. },
  367. /** 删除按钮操作 */
  368. handleDelete(row) {
  369. const busPatrolstationIds = row.busPatrolstationId || this.ids;
  370. this.$modal.confirm('是否确认废弃巡更点编号为"' + busPatrolstationIds + '"的数据项?').then(function () {
  371. return delPatrolstation(busPatrolstationIds);
  372. }).then(() => {
  373. this.getList();
  374. this.$modal.msgSuccess("废弃成功");
  375. }).catch(() => {
  376. });
  377. },
  378. /** 导出按钮操作 */
  379. handleExport() {
  380. this.download('system/patrolstation/export', {
  381. ...this.queryParams
  382. }, `patrolstation_${new Date().getTime()}.xlsx`)
  383. }
  384. }
  385. };
  386. </script>