index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
  4. @submit.native.prevent>
  5. <el-form-item label="名称" prop="name">
  6. <el-input
  7. v-model="queryParams.name"
  8. placeholder="请输入名称"
  9. clearable
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="树种" prop="forestSpecies">
  14. <el-select v-model="queryParams.forestSpecies" placeholder="请选择树种" clearable size="small">
  15. <el-option
  16. v-for="dict in dict.type.dominant_tree_species"
  17. :key="dict.value"
  18. :label="dict.label"
  19. :value="dict.value"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item prop="deptId">
  24. <template slot="label">
  25. <span @click="changeQueryType" v-if="queryParams.deptName == 0">本级及下级</span>
  26. <span @click="changeQueryType" v-if="queryParams.deptName == 1">只查询本级</span>
  27. </template>
  28. <treeselect v-model="queryParams.deptId" :options="deptOptions" multiple:false :show-count="true"
  29. placeholder="请选择部门" @select="hx" :noResultsText="'空'" :noOptionsText="'空'" style="width: 240px"/>
  30. <el-input v-model="queryParams.deptName" v-if="false"/>
  31. </el-form-item>
  32. <el-form-item>
  33. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  34. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  35. </el-form-item>
  36. </el-form>
  37. <el-row :gutter="10" class="mb8">
  38. <el-col :span="1.5">
  39. <el-button
  40. type="primary"
  41. plain
  42. icon="el-icon-plus"
  43. size="mini"
  44. @click="handleAdd"
  45. v-hasPermi="['forest:keyFireproofPlots:add']"
  46. >新增
  47. </el-button>
  48. </el-col>
  49. <el-col :span="1.5">
  50. <el-button
  51. type="success"
  52. plain
  53. icon="el-icon-edit"
  54. size="mini"
  55. :disabled="single"
  56. @click="handleUpdate"
  57. v-hasPermi="['forest:keyFireproofPlots:edit']"
  58. >修改
  59. </el-button>
  60. </el-col>
  61. <el-col :span="1.5">
  62. <el-button
  63. type="danger"
  64. plain
  65. icon="el-icon-delete"
  66. size="mini"
  67. :disabled="multiple"
  68. @click="handleDelete"
  69. v-hasPermi="['forest:keyFireproofPlots:remove']"
  70. >删除
  71. </el-button>
  72. </el-col>
  73. <el-col :span="1.5">
  74. <el-button
  75. type="warning"
  76. plain
  77. icon="el-icon-download"
  78. size="mini"
  79. @click="handleExport"
  80. v-hasPermi="['forest:keyFireproofPlots:export']"
  81. >导出
  82. </el-button>
  83. </el-col>
  84. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  85. </el-row>
  86. <el-table v-loading="loading" :data="keyFireproofPlotsList" @selection-change="handleSelectionChange">
  87. <el-table-column type="selection" width="55" align="center"/>
  88. <el-table-column label="名称" align="center" prop="name"/>
  89. <el-table-column label="面积(公顷)" align="center" prop="plotsArea"/>
  90. <el-table-column label="经度" align="center" prop="longitude"/>
  91. <el-table-column label="纬度" align="center" prop="latitude"/>
  92. <el-table-column label="林班" align="center" prop="linBan"/>
  93. <el-table-column label="小班" align="center" prop="xiaoBan"/>
  94. <el-table-column label="林种" align="center" prop="forestSpecies ">
  95. <template slot-scope="scope">
  96. <dict-tag :options="dict.type.dominant_tree_species" :value="scope.row.forestSpecies"/>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="所属部门" align="center" prop="deptName"/>
  100. <el-table-column label="创建人" align="center" prop="createName"/>
  101. <el-table-column label="创建时间" align="center" prop="createTime"/>
  102. <el-table-column label="修改人" align="center" prop="updateName"/>
  103. <el-table-column label="修改时间" align="center" prop="updateTime"/>
  104. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  105. <template slot-scope="scope">
  106. <el-button
  107. size="mini"
  108. type="text"
  109. icon="el-icon-edit"
  110. @click="handleUpdate(scope.row)"
  111. v-hasPermi="['forest:keyFireproofPlots:edit']"
  112. >修改
  113. </el-button>
  114. <el-button
  115. size="mini"
  116. type="text"
  117. icon="el-icon-delete"
  118. @click="handleDelete(scope.row)"
  119. v-hasPermi="['forest:keyFireproofPlots:remove']"
  120. >删除
  121. </el-button>
  122. </template>
  123. </el-table-column>
  124. </el-table>
  125. <pagination
  126. v-show="total>0"
  127. :total="total"
  128. :page.sync="queryParams.pageNum"
  129. :limit.sync="queryParams.pageSize"
  130. @pagination="getList"
  131. />
  132. <!-- 添加或修改重点防火地块对话框 -->
  133. <el-dialog :title="title" :visible.sync="open" width="850px" class="form-style">
  134. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  135. <el-row :gutter="20">
  136. <el-col :span="12">
  137. <el-form-item label="名称" prop="name">
  138. <el-input v-model="form.name" placeholder="请输入名称" :disabled="disabled" maxlength="50"/>
  139. </el-form-item>
  140. </el-col>
  141. <el-col :span="12">
  142. <el-form-item label="面积(公顷)" prop="plotsArea">
  143. <el-input v-model="form.plotsArea" placeholder="请输入面积(公顷)" :disabled="disabled" maxlength="13"/>
  144. </el-form-item>
  145. </el-col>
  146. </el-row>
  147. <el-row>
  148. <el-col :span="12">
  149. <el-form-item label="经度" prop="longitude" @dblclick.native="showMap">
  150. <el-input v-model="form.longitude" placeholder="鼠标双击选择经纬度"/>
  151. </el-form-item>
  152. </el-col>
  153. <el-col :span="12">
  154. <el-form-item label="纬度" prop="latitude" @dblclick.native="showMap">
  155. <el-input v-model="form.latitude" placeholder="鼠标双击选择经纬度"/>
  156. </el-form-item>
  157. </el-col>
  158. </el-row>
  159. <el-row>
  160. <el-col :span="12">
  161. <el-form-item label="林班" prop="linBan">
  162. <el-input v-model="form.linBan" placeholder="请输入林班" :disabled="disabled" maxlength="50"/>
  163. </el-form-item>
  164. </el-col>
  165. <el-col :span="12">
  166. <el-form-item label="小班" prop="xiaoBan">
  167. <el-input v-model="form.xiaoBan" placeholder="请输入小班" :disabled="disabled" maxlength="50"/>
  168. </el-form-item>
  169. </el-col>
  170. </el-row>
  171. <el-row>
  172. <el-col :span="12">
  173. <el-form-item label="所属部门" prop="deptId">
  174. <treeselect v-model="form.deptId" :options="deptOptions" multiple:false :show-count="true"
  175. placeholder="请选择部门" @select="hx" :noResultsText="'空'" :noOptionsText="'空'"/>
  176. </el-form-item>
  177. </el-col>
  178. <el-col :span="12">
  179. <el-form-item label="林种" prop="forestSpecies">
  180. <el-select v-model="form.forestSpecies" placeholder="请选择林种" filterable>
  181. <el-option
  182. v-for="dict in dict.type.dominant_tree_species"
  183. :key="dict.value"
  184. :label="dict.label"
  185. :value="dict.value"
  186. ></el-option>
  187. </el-select>
  188. </el-form-item>
  189. </el-col>
  190. </el-row>
  191. <el-row>
  192. <el-col :span="24">
  193. <el-form-item label="绑定设备" prop="deviceList">
  194. <el-select v-model="form.deviceList" filterable placeholder="请选择设备" multiple>
  195. <el-option
  196. v-for="dict in cameraList"
  197. :key="dict.id"
  198. :label="dict.cameraName"
  199. :value="dict.id"
  200. ></el-option>
  201. </el-select>
  202. </el-form-item>
  203. </el-col>
  204. </el-row>
  205. <el-row>
  206. <el-col :span="24">
  207. <el-form-item label="图片" prop="attachPaths">
  208. <DataImageUpload ref="ImageUpload" :fileType="['png', 'jpg', 'jpeg']" :value="form.attachPaths"
  209. @input="getUrl"></DataImageUpload>
  210. </el-form-item>
  211. </el-col>
  212. </el-row>
  213. </el-form>
  214. <div slot="footer" class="dialog-footer">
  215. <el-button type="primary" @click="submitForm" v-show=!disabled>确 定</el-button>
  216. <el-button @click="cancel">取 消</el-button>
  217. </div>
  218. </el-dialog>
  219. <ISuperMap ref="ISuperMap" v-if="ISuperMapvisible" @send="send"/>
  220. </div>
  221. </template>
  222. <script>
  223. import {
  224. addKeyFireproofPlots,
  225. delKeyFireproofPlots,
  226. getKeyFireproofPlots,
  227. listKeyFireproofPlots,
  228. updateKeyFireproofPlots
  229. } from "@/api/data/digitalforest/keyFireproofPlots/keyFireproofPlots";
  230. import {getDept} from '@/api/system/deptparty'
  231. import Deptselector from '@/views/components/deptselector';
  232. import deptselector from '@/views/components/deptselector'
  233. import {treeselect} from "@/api/system/dept";
  234. import Treeselect from "@riophae/vue-treeselect";
  235. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  236. import {validPhoneMobile, checkPositiveInteger, checkLat, checkLon, checkPositiveDecimal} from "@/api/rules/rules";
  237. import {selectCenterMonitorlList} from "@/api/data/digitalforest/animal/animal";
  238. import ISuperMap from "@/views/data/common/ISuperMap.vue";
  239. import DataImageUpload from "@/components/ImageUpload/dataUpload.vue";
  240. export default {
  241. name: "KeyFireproofPlots",
  242. dicts: ['dominant_tree_species'],
  243. components: {deptselector, Treeselect,ISuperMap,Deptselector,DataImageUpload},
  244. data() {
  245. return {
  246. disabled:true,
  247. sign: 1,
  248. ISuperMapvisible: false,
  249. cameraList: [],//设备集合
  250. // 信息弹出层上的坐标弹层
  251. showLongitude: false,
  252. titleLongitude: '',
  253. // 遮罩层
  254. loading: true,
  255. // 选中数组
  256. ids: [],
  257. // 非单个禁用
  258. single: true,
  259. // 非多个禁用
  260. multiple: true,
  261. // 显示搜索条件
  262. showSearch: true,
  263. // 总条数
  264. total: 0,
  265. // 重点防火地块表格数据
  266. keyFireproofPlotsList: [],
  267. // 弹出层标题
  268. title: "",
  269. // 是否显示弹出层
  270. open: false,
  271. // 部门树选项
  272. deptOptions: [],
  273. // 查询参数
  274. queryParams: {
  275. pageNum: 1,
  276. pageSize: 10,
  277. deptId: null,
  278. deptName: 0,
  279. dataDeptId: null,
  280. name: null,
  281. latitude: null,
  282. longitude: null,
  283. linBan:null,
  284. xiaoBan:null,
  285. plotsArea:null,
  286. forestSpecies:null
  287. },
  288. // 表单参数
  289. form: {},
  290. // 表单校验
  291. rules: {
  292. name: [
  293. {required: true, message: '名称不能为空', trigger: 'blur'}
  294. ],
  295. longitude: [
  296. {required: true, message: '经度不能为空', trigger: ['change', 'blur']},
  297. {validator: checkLon, trigger: 'blur'}
  298. ],
  299. latitude: [
  300. {required: true, message: '纬度不能为空', trigger: ['change', 'blur']},
  301. {validator: checkLat, trigger: 'blur'}
  302. ],
  303. plotsArea: [
  304. {validator: checkPositiveDecimal, trigger: 'blur'}
  305. ],
  306. deptId: [
  307. {required: true, message: '所属部门不能为空', trigger: 'change'}
  308. ]
  309. }
  310. };
  311. },
  312. created() {
  313. this.getList();
  314. this.getTreeselect();
  315. selectCenterMonitorlList(this.queryParams).then(response => {
  316. this.cameraList = response.data;
  317. });
  318. },
  319. methods: {
  320. getUrl(url) {
  321. //获取图片全路径 例:http://{{ ip }}:{{ port }}/group1/M00/00/07/wKgKEGVxMCiAZbvVAAJE9SGvagw915.jpg
  322. this.form.attachPaths = url
  323. //获取图片路径 例:group1/M00/00/07/wKgKEGVxL6eACFv2AAJE9SGvagw622.jpg
  324. // this.form.attachPaths = this.$refs.ImageUpload.dialogName
  325. },
  326. hx(node) {
  327. this.form.dataDeptId = node.id
  328. this.form.deptId = node.id
  329. this.form.deptName = node.label
  330. this.$refs.form.validateField("deptId")
  331. },
  332. showMap() {
  333. this.ISuperMapvisible = true;
  334. this.$nextTick(() => {
  335. this.$refs.ISuperMap.init(this.sign, {
  336. id: this.form.id,
  337. longitude: this.form.longitude,
  338. latitude: this.form.latitude,
  339. xiantude: this.form.longitude//this.form.longitude换成每个页面对应线或者面对应的字段
  340. })
  341. })
  342. },
  343. send(val) {
  344. if (val === true) {
  345. this.ISuperMapvisible = false;
  346. return;
  347. }
  348. if (this.sign === 1) {
  349. this.form.longitude = val.longitude;
  350. this.form.latitude = val.latitude;
  351. }
  352. if (this.sign === 2 || this.sign === 3) this.form.longitude = val.xiantude;//this.form.longitude 换成对应的线或区域的字段
  353. this.ISuperMapvisible = false
  354. },
  355. setDataDeptId(e) {
  356. this.form.deptId = e.deptId
  357. this.form.deptName = e.deptName
  358. },
  359. /** 查询重点防火地块列表 */
  360. getList() {
  361. this.loading = true;
  362. listKeyFireproofPlots(this.queryParams).then(response => {
  363. this.keyFireproofPlotsList = response.rows;
  364. this.total = response.total;
  365. this.loading = false;
  366. });
  367. },
  368. showLatLng: function (lat, lng) {
  369. this.form.latitude = lat
  370. this.form.longitude = lng
  371. },
  372. /** 查询部门下拉树结构 */
  373. getTreeselect() {
  374. treeselect().then(response => {
  375. this.deptOptions = response.data;
  376. });
  377. },
  378. // 取消按钮
  379. cancel() {
  380. this.open = false;
  381. this.reset();
  382. },
  383. // 表单重置
  384. reset() {
  385. this.form = {
  386. createBy: null,
  387. createTime: null,
  388. updateBy: null,
  389. updateTime: null,
  390. createName:null,
  391. updateName:null,
  392. deptId: null,
  393. deptName: null,
  394. id: null,
  395. name: null,
  396. latitude: null,
  397. longitude: null,
  398. linBan:null,
  399. xiaoBan:null,
  400. plotsArea:null,
  401. forestSpecies:null
  402. };
  403. this.resetForm("form");
  404. },
  405. /** 搜索按钮操作 */
  406. handleQuery() {
  407. this.queryParams.pageNum = 1;
  408. this.getList();
  409. },
  410. /** 重置按钮操作 */
  411. resetQuery() {
  412. this.queryParams.deptName = 0;
  413. this.resetForm("queryForm");
  414. this.handleQuery();
  415. },
  416. // 多选框选中数据
  417. handleSelectionChange(selection) {
  418. this.ids = selection.map(item => item.id)
  419. this.single = selection.length !== 1
  420. this.multiple = !selection.length
  421. },
  422. /** 新增按钮操作 */
  423. handleAdd() {
  424. this.reset();
  425. this.open = true;
  426. this.title = "添加重点防火地块";
  427. this.disabled = false
  428. },
  429. /** 修改按钮操作 */
  430. handleUpdate(row) {
  431. this.reset();
  432. const id = row.id || this.ids
  433. getKeyFireproofPlots(id).then(response => {
  434. this.form = response.data;
  435. this.open = true;
  436. this.title = "修改重点防火地块";
  437. this.disabled = false
  438. });
  439. },
  440. /** 提交按钮 */
  441. submitForm() {
  442. this.$refs["form"].validate(valid => {
  443. if (valid) {
  444. if (this.form.id != null) {
  445. updateKeyFireproofPlots(this.form).then(response => {
  446. this.$modal.msgSuccess("修改成功");
  447. this.open = false;
  448. this.getList();
  449. });
  450. } else {
  451. addKeyFireproofPlots(this.form).then(response => {
  452. this.$modal.msgSuccess("新增成功");
  453. this.open = false;
  454. this.getList();
  455. });
  456. }
  457. }
  458. });
  459. },
  460. /** 删除按钮操作 */
  461. handleDelete(row) {
  462. const ids = row.id || this.ids;
  463. this.$modal.confirm('是否确认删除选中的数据项?').then(function () {
  464. return delKeyFireproofPlots(ids);
  465. }).then(() => {
  466. this.getList();
  467. this.$modal.msgSuccess("删除成功");
  468. }).catch(() => {
  469. });
  470. },
  471. /** 导出按钮操作 */
  472. handleExport() {
  473. this.download('sooka-sponest-center-data/keyFireproofPlots/export', {
  474. ...this.queryParams
  475. }, `重点防火地块_${new Date().getTime()}.xlsx`)
  476. },
  477. // 点击按钮修改是否只查询本级部门用户
  478. changeQueryType() {
  479. this.queryParams.deptName = this.queryParams.deptName == 0 ? 1 : 0;
  480. }
  481. }
  482. };
  483. </script>