index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" @submit.native.prevent>
  4. <el-form-item label="名称" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="地址" prop="address">
  14. <el-input
  15. v-model="queryParams.address"
  16. placeholder="请输入地址"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="负责人" prop="principal">
  23. <el-input
  24. v-model="queryParams.principal"
  25. placeholder="请输入负责人"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  33. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  34. </el-form-item>
  35. </el-form>
  36. <el-row :gutter="10" class="mb8">
  37. <el-col :span="1.5">
  38. <el-button
  39. type="primary"
  40. plain
  41. icon="el-icon-plus"
  42. size="mini"
  43. @click="handleAdd"
  44. v-hasPermi="['firecontrol:fulltimestation:add']"
  45. >新增
  46. </el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button
  50. type="success"
  51. plain
  52. icon="el-icon-edit"
  53. size="mini"
  54. :disabled="single"
  55. @click="handleUpdate"
  56. v-hasPermi="['firecontrol:fulltimestation:edit']"
  57. >修改
  58. </el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="danger"
  63. plain
  64. icon="el-icon-delete"
  65. size="mini"
  66. :disabled="multiple"
  67. @click="handleDelete"
  68. v-hasPermi="['firecontrol:fulltimestation:remove']"
  69. >删除
  70. </el-button>
  71. </el-col>
  72. <el-col :span="1.5">
  73. <el-button
  74. type="warning"
  75. plain
  76. icon="el-icon-download"
  77. size="mini"
  78. @click="handleExport"
  79. v-hasPermi="['firecontrol:fulltimestation:export']"
  80. >导出
  81. </el-button>
  82. </el-col>
  83. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  84. </el-row>
  85. <el-table v-loading="loading" :data="fulltimestationList" @selection-change="handleSelectionChange">
  86. <el-table-column type="selection" width="55" align="center"/>
  87. <!--<el-table-column label="主键id" align="center" prop="id"/>-->
  88. <el-table-column label="名称" align="center" prop="name"/>
  89. <el-table-column label="地址" align="center" prop="address"/>
  90. <el-table-column label="负责人" align="center" prop="principal"/>
  91. <el-table-column label="联系电话" align="center" prop="contactsPhone"/>
  92. <el-table-column label="经度" align="center" prop="longitude"/>
  93. <el-table-column label="所属部门" align="center" prop="deptName"/>
  94. <el-table-column label="纬度" align="center" prop="latitude"/>
  95. <el-table-column label="创建人" align="center" prop="createName"/>
  96. <el-table-column label="创建时间" align="center" prop="createTime"/>
  97. <el-table-column label="修改人" align="center" prop="updateName"/>
  98. <el-table-column label="修改时间" align="center" prop="updateTime"/>
  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="['firecontrol:fulltimestation: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="['firecontrol:fulltimestation: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="900px" class="form-style">
  129. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  130. <el-row>
  131. <el-col :span="12">
  132. <el-form-item label="名称" prop="name">
  133. <el-input v-model="form.name" placeholder="请输入名称" maxlength="20"/>
  134. </el-form-item>
  135. <el-form-item label="负责人" prop="principal">
  136. <el-input v-model="form.principal" placeholder="请输入负责人" maxlength="20"/>
  137. </el-form-item>
  138. <el-form-item label="经度" prop="longitude" @dblclick.native="showMap">
  139. <el-input v-model="form.longitude" placeholder="鼠标双击此处以选择经纬度" maxlength="32"/>
  140. </el-form-item>
  141. <el-form-item label="所属部门" prop="deptId">
  142. <treeselect v-model="form.deptId" :options="deptOptions" multiple:false :show-count="true" :noResultsText="'空'" :noOptionsText="'空'"
  143. placeholder="请选择部门" @select="hx"/>
  144. </el-form-item>
  145. </el-col>
  146. <el-col :span="12">
  147. <el-form-item label="地址" prop="address">
  148. <el-input v-model="form.address" placeholder="请输入地址" maxlength="20"/>
  149. </el-form-item>
  150. <el-form-item label="联系电话" prop="contactsPhone">
  151. <el-input v-model="form.contactsPhone" placeholder="请输入联系电话" maxlength="20"/>
  152. </el-form-item>
  153. <el-form-item label="纬度" prop="latitude" @dblclick.native="showMap">
  154. <el-input v-model="form.latitude" placeholder="鼠标双击此处以选择经纬度" maxlength="32"/>
  155. </el-form-item>
  156. <!-- <el-form-item label="所属部门" prop="deptId">-->
  157. <!-- <Deptselector :setValue=setDataDeptId :dataDeptId="form.deptId"/>-->
  158. <!-- </el-form-item>-->
  159. </el-col>
  160. <el-col :span="24">
  161. <el-form-item label="绑定设备" prop="deviceList">
  162. <el-select v-model="form.deviceList" filterable placeholder="请选择设备" multiple :style='{"width":"100%"}'>
  163. <el-option
  164. v-for="dict in deviceList"
  165. :key="dict.id"
  166. :label="dict.cameraName"
  167. :value="dict.id"
  168. ></el-option>
  169. </el-select>
  170. </el-form-item>
  171. </el-col>
  172. <el-col :span="24">
  173. <el-form-item label="图片" prop="attachPaths">
  174. <DataImageUpload ref="ImageUpload" :fileType="['png', 'jpg', 'jpeg']" :value="form.attachPaths"
  175. @input="getUrl"></DataImageUpload>
  176. </el-form-item>
  177. </el-col>
  178. </el-row>
  179. </el-form>
  180. <div slot="footer" class="dialog-footer">
  181. <el-button type="primary" @click="submitForm">确 定</el-button>
  182. <el-button @click="cancel">取 消</el-button>
  183. </div>
  184. </el-dialog>
  185. <el-dialog :title="titleLongitude" :visible.sync="showLongitude" append-to-body>
  186. <el-input v-show="false" v-model="form.longitude" disabled></el-input>
  187. <el-input v-show="false" v-model="form.latitude" disabled></el-input>
  188. <Supermap style="width: 100%;height: 500px;" :mapDiv="'fulltimestationMap'" :mapSite="{doubleClickZoom:false}"
  189. :codes="['9fa5']" :isSideBySide="false" :showLatLng="showLatLng"/>
  190. <el-button type="primary" @click="showLongitude=false">确定</el-button>
  191. </el-dialog>
  192. <ISuperMap ref="ISuperMap" v-if="ISuperMapvisible" @send="send"/>
  193. </div>
  194. </template>
  195. <script>
  196. import {
  197. addFulltimestation,
  198. delFulltimestation,
  199. getFulltimestation,
  200. listFulltimestation,
  201. updateFulltimestation
  202. } from "@/api/data/digitalfirecontrol/fulltimestation";
  203. import Deptselector from '@/views/components/deptselector';
  204. import Supermap from '@/views/components/supermap';
  205. import {checkLat, checkLon, validPhoneMobile} from "@/api/rules/rules";
  206. import {format_date} from "@/views/data/common/dateExport";
  207. import {selectCenterMonitorlList} from "../../../../api/data/digitalforest/animal/animal";
  208. import ISuperMap from "@/views/data/common/ISuperMap";
  209. import {treeselect} from "@/api/system/dept";
  210. import Treeselect from "@riophae/vue-treeselect";
  211. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  212. import DataImageUpload from "@/components/ImageUpload/dataUpload.vue";
  213. export default {
  214. name: "Fulltimestation",
  215. components: {Deptselector, Supermap, Treeselect, ISuperMap, DataImageUpload},
  216. data() {
  217. return {
  218. deptOptions: undefined,
  219. dataDeptId: null,
  220. deptId: null,
  221. deptName: null,
  222. titleLongitude: '经纬度',
  223. // 遮罩层
  224. loading: true,
  225. ISuperMapvisible: false,
  226. sign: 1,
  227. // 选中数组
  228. ids: [],
  229. // 非单个禁用
  230. single: true,
  231. // 非多个禁用
  232. multiple: true,
  233. // 显示搜索条件
  234. showSearch: true,
  235. // 总条数
  236. total: 0,
  237. // 专职站管理表格数据
  238. fulltimestationList: [],
  239. deviceList: [],
  240. // 弹出层标题
  241. title: "",
  242. // 是否显示弹出层
  243. open: false,
  244. // 查询参数
  245. queryParams: {
  246. pageNum: 1,
  247. pageSize: 10,
  248. address: null,
  249. principal: null,
  250. contactsPhone: null,
  251. longitude: null,
  252. latitude: null,
  253. createName:null,
  254. createTime:null,
  255. updateName:null,
  256. updateTime:null,
  257. },
  258. // 表单参数
  259. form: {},
  260. // 表单校验
  261. rules: {
  262. name: [
  263. {required: true, message: '名称不能为空', trigger: 'blur'}
  264. ],
  265. address: [
  266. {required: true, message: '地址不能为空', trigger: 'blur'}
  267. ],
  268. principal: [
  269. {required: true, message: '负责人不能为空', trigger: 'blur'}
  270. ],
  271. contactsPhone: [
  272. {required: true, message: '联系电话不能为空', trigger: 'blur'},
  273. {validator: validPhoneMobile, trigger: 'blur'}
  274. ],
  275. longitude: [
  276. {required: true, message: "经度不能为空", trigger: ["blur","change"]},
  277. {validator: checkLon, trigger: 'blur'}
  278. ],
  279. latitude: [
  280. {required: true, message: "纬度不能为空", trigger: ["blur","change"]},
  281. {validator: checkLat, trigger: 'blur'}
  282. ],
  283. deptId: [
  284. {required: true, message: '所属部门不能为空', trigger: 'change'}
  285. ]
  286. },
  287. showLongitude: false
  288. };
  289. },
  290. created() {
  291. this.getList();
  292. this.getTreeselect();
  293. },
  294. methods: {
  295. getTreeselect() {
  296. treeselect().then(response => {
  297. this.deptOptions = response.data
  298. })
  299. },
  300. hx(node) {
  301. this.form.dataDeptId = node.id
  302. this.form.deptId = node.id
  303. this.form.deptName = node.label
  304. this.$refs.form.validateField('deptId');
  305. },
  306. getUrl(url) {
  307. this.form.attachPaths = url
  308. },
  309. // setDataDeptId(e) {
  310. // this.form.deptId = e.deptId;
  311. // this.form.deptName = e.deptName;
  312. // },
  313. showMap() {
  314. this.ISuperMapvisible = true;
  315. this.$nextTick(() => {
  316. this.$refs.ISuperMap.init(this.sign, {
  317. id: this.form.id,
  318. longitude: this.form.longitude,
  319. latitude: this.form.latitude,
  320. xiantude: this.form.longitude
  321. })
  322. })
  323. },
  324. send(val) {
  325. if (val===true){
  326. this.ISuperMapvisible = false;
  327. return;
  328. }
  329. if (this.sign === 1) {
  330. this.form.longitude = val.longitude;
  331. this.form.latitude = val.latitude;
  332. }
  333. if (this.sign === 2 || this.sign === 3) this.form.longitude = val.xiantude;
  334. this.ISuperMapvisible = false
  335. },
  336. showLatLng: function (lat, lng) {
  337. this.form.latitude = lat;
  338. this.form.longitude = lng;
  339. },
  340. /** 查询专职站管理列表 */
  341. getList() {
  342. this.loading = true;
  343. listFulltimestation(this.queryParams).then(response => {
  344. this.fulltimestationList = response.rows;
  345. this.total = response.total;
  346. this.loading = false;
  347. });
  348. },
  349. // 取消按钮
  350. cancel() {
  351. this.open = false;
  352. this.reset();
  353. },
  354. // 表单重置
  355. reset() {
  356. this.form = {
  357. id: null,
  358. address: null,
  359. principal: null,
  360. contactsPhone: null,
  361. longitude: null,
  362. latitude: null,
  363. deviceList: [],
  364. deptId: null,
  365. deptName: null
  366. };
  367. this.resetForm("form");
  368. },
  369. /** 搜索按钮操作 */
  370. handleQuery() {
  371. this.queryParams.pageNum = 1;
  372. this.getList();
  373. },
  374. /** 重置按钮操作 */
  375. resetQuery() {
  376. this.resetForm("queryForm");
  377. this.handleQuery();
  378. },
  379. getCenterMonitorlList() {
  380. selectCenterMonitorlList({pageNum: 1, pageSize: 10}).then(response => {
  381. this.deviceList = response.data;
  382. });
  383. },
  384. // 多选框选中数据
  385. handleSelectionChange(selection) {
  386. this.ids = selection.map(item => item.id)
  387. this.single = selection.length !== 1
  388. this.multiple = !selection.length
  389. },
  390. /** 新增按钮操作 */
  391. handleAdd() {
  392. this.reset();
  393. this.open = true;
  394. this.title = "添加专职站管理";
  395. this.getCenterMonitorlList()
  396. },
  397. /** 修改按钮操作 */
  398. handleUpdate(row) {
  399. this.reset();
  400. const id = row.id || this.ids
  401. getFulltimestation(id).then(response => {
  402. this.form = response.data;
  403. this.open = true;
  404. this.title = "修改专职站管理";
  405. });
  406. this.getCenterMonitorlList()
  407. },
  408. /** 提交按钮 */
  409. submitForm() {
  410. this.$refs["form"].validate(valid => {
  411. if (valid) {
  412. if (this.form.id != null) {
  413. updateFulltimestation(this.form).then(response => {
  414. this.$modal.msgSuccess("修改成功");
  415. this.open = false;
  416. this.getList();
  417. });
  418. } else {
  419. addFulltimestation(this.form).then(response => {
  420. this.$modal.msgSuccess("新增成功");
  421. this.open = false;
  422. this.getList();
  423. });
  424. }
  425. }
  426. });
  427. },
  428. /** 删除按钮操作 */
  429. handleDelete(row) {
  430. const ids = row.id || this.ids;
  431. this.$modal.confirm('是否确认删除选中的数据项?').then(function () {
  432. return delFulltimestation(ids);
  433. }).then(() => {
  434. this.getList();
  435. this.$modal.msgSuccess("删除成功");
  436. }).catch(() => {
  437. });
  438. },
  439. /** 导出按钮操作 */
  440. handleExport() {
  441. this.download('sooka-sponest-center-data/fulltimestation/export', {
  442. ...this.queryParams
  443. }, `专职站管理_${format_date(new Date())}.xlsx`)
  444. }
  445. }
  446. };
  447. </script>