ISuperMapAreaMarker.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template><div>
  2. <el-dialog title="经纬度" :visible.sync="showLongitude" append-to-body width="80%" @close='close'>
  3. <el-input v-show="false" v-model="obj.longitude"></el-input>
  4. <el-input v-show="false" v-model="obj.latitude"></el-input>
  5. <Supermap ref="Supermap" style="width: 100%;height: 75vh;" :mapDiv="uuid" :mapSite="{doubleClickZoom:false}"
  6. :codes="['9fa5']" :isSideBySide="false" :showLatLng="showLL"></Supermap>
  7. <el-button type="primary" @click="closeDialog">确定</el-button>
  8. </el-dialog>
  9. <el-dialog title="线坐标" :visible.sync="showLongitudex" append-to-body @close='close' width="80%">
  10. <Supermap ref="LineSupermap" style="width: 100%;height:75vh"
  11. :mapDiv="uuid" :mapSite="{doubleClickZoom:false}" :codes="['9fa5']" :isSideBySide="false"
  12. :showLineLatLng="showAreaLatLng"></Supermap>
  13. <el-button type="primary" @click="closeDialog">确定</el-button>
  14. </el-dialog>
  15. <el-dialog title="区域坐标" :visible.sync="showLongitudeq" @close='close' width="80%">
  16. <div style="width: 100%; display: flex;">
  17. <div style="width: 20%; float: left;">
  18. <el-table ref="table" v-loading="loading" :data="tableData" height="100%" v-if="sign===3" @selection-change="handleSelectionChange">
  19. <el-table-column type="selection" width="55" align="center"/>
  20. <el-table-column prop="name" label="区域名称" width="180"></el-table-column>
  21. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
  22. <template slot-scope="scope">
  23. <el-button
  24. size="mini"
  25. type="text"
  26. icon="el-icon-edit"
  27. @click="handleUpdate(scope.row)"
  28. v-hasPermi="['farm:farmland:edit']"
  29. >修改
  30. </el-button>
  31. <el-button
  32. size="mini"
  33. type="text"
  34. icon="el-icon-delete"
  35. @click="handleDelete(scope.row)"
  36. >删除
  37. </el-button>
  38. </template>
  39. </el-table-column>
  40. </el-table>
  41. </div>
  42. <div style="width: 80%; float: left;">
  43. <Supermap ref="areaSupermap" style="width: 100%;height:75vh"
  44. :mapDiv="uuid" :mapSite="{doubleClickZoom:false}" :codes="['9fa5']"
  45. :isSideBySide="false" :showAreaLatLng="showAreaLatLng"></Supermap>
  46. </div>
  47. </div>
  48. <el-button type="primary" @click="closeDialog">确定</el-button>
  49. <el-button @click="clearAway">清除</el-button>
  50. </el-dialog>
  51. <el-dialog :title="(sign===1?'经纬度':(sign===2?'线坐标':'区域坐标'))" :visible.sync="visible" append-to-body
  52. width="90%"
  53. height="60%"
  54. @close='close'>
  55. <div style="width: 100%; display: flex;">
  56. <div style="width: 20%; float: left;">
  57. <el-table ref="table" v-loading="loading" :data="tableData" height="100%" v-if="sign===3" @selection-change="handleSelectionChange">
  58. <el-table-column type="selection" width="55" align="center"/>
  59. <el-table-column prop="name" label="区域名称" width="180"></el-table-column>
  60. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
  61. <template slot-scope="scope">
  62. <el-button
  63. size="mini"
  64. type="text"
  65. icon="el-icon-edit"
  66. @click="handleUpdate(scope.row)"
  67. v-hasPermi="['farm:farmland:edit']"
  68. >修改
  69. </el-button>
  70. <el-button
  71. size="mini"
  72. type="text"
  73. icon="el-icon-delete"
  74. @click="handleDelete(scope.row)"
  75. >删除
  76. </el-button>
  77. </template>
  78. </el-table-column>
  79. </el-table>
  80. </div>
  81. <div style="width: 80%; float: left;">
  82. <supermap ref="supermap" style="width: 100%; height: 75vh;" :putSmUserID_layer="putSmUserID_layer" @showLatLng="showLatLng"></supermap>
  83. </div>
  84. </div>
  85. <el-button type="primary" @click="closeDialog">确定</el-button>
  86. <el-button @click="clearAway">清除</el-button>
  87. </el-dialog>
  88. <el-dialog :title="title" :visible.sync="visibleName" append-to-body width="400px">
  89. <el-form ref="obj" :model="obj" :rules="rules" label-width="100px">
  90. <el-form-item label="区域名称" prop="name">
  91. <el-input v-model="obj.name" placeholder="请输入区域名称" maxlength="20"/>
  92. </el-form-item>
  93. </el-form>
  94. <div slot="footer" class="dialog-footer">
  95. <el-button type="primary" @click="submitForm">确 定</el-button>
  96. <el-button @click="cancel">取 消</el-button>
  97. </div>
  98. </el-dialog>
  99. </div>
  100. </template>
  101. <script>
  102. import {getConfigKey} from "@/api/system/config";
  103. import {
  104. delRegionalFlagByFlagType,
  105. getRegionalFlag,
  106. updateInfo,
  107. updateRegionalFlag
  108. } from '@/api/data/digitalresources/info'
  109. import request from '@/utils/request'
  110. const uuidv4 = require("uuid/v4")
  111. import supermap from '@/views/components/supermap-2.5d';
  112. import Supermap from '@/views/components/supermap';
  113. import { delFarmland, getFarmland, updateFarmland } from '@/api/data/digitalresources/farmland'
  114. export default {
  115. //多区域的地图
  116. name: "ISuperMapArearAndCameras",
  117. components: {supermap, Supermap},
  118. // created() {
  119. //
  120. // },
  121. data() {
  122. return {
  123. // 遮罩层
  124. loading: true,
  125. eventId:null,
  126. visibleName:false,
  127. id:null,
  128. arr:[],
  129. tableData:[],
  130. cameraMarkersList:[],
  131. visuForestCloudCameraBOList:[],
  132. visuForestCloudCameraBOListSearch:[],
  133. uuid: '',
  134. sign: undefined,
  135. title: "",
  136. visible: false,
  137. showLongitude: false,
  138. showLongitudex: false,
  139. showLongitudeq: false,
  140. obj: {
  141. longitude: undefined,
  142. latitude: undefined,
  143. xiantude: undefined,
  144. name:undefined,
  145. },
  146. rules: {
  147. name: [
  148. {required: true, message: "区域名称不能为空", trigger: "change" }
  149. ],
  150. }
  151. };
  152. },
  153. created() {
  154. this.getRegionalFlag();
  155. },
  156. methods: {
  157. putSmUserID_layer: function (entity) {
  158. },
  159. showAreaLatLng: function (latlng) {
  160. this.obj.xiantude = JSON.stringify(latlng);
  161. },
  162. /** 区域标记按钮操作 */
  163. getRegionalFlag() {
  164. this.loading = true;
  165. getRegionalFlag(this.eventId).then(response => {
  166. this.tableData = response.data;
  167. this.loading = false;
  168. })
  169. },
  170. //删除
  171. handleDelete(row){
  172. this.$modal.confirm('是否确认删除选中的数据项?').then(function () {
  173. return delRegionalFlagByFlagType(row.eventId,row.flagType);
  174. }).then(() => {
  175. this.clearAway();
  176. this.getRegionalFlag();
  177. this.$modal.msgSuccess("删除成功");
  178. }).catch(() => {
  179. });
  180. },
  181. showLatLng: function (val) {
  182. if (this.sign === 1) {
  183. this.obj.longitude = val.longitude;
  184. this.obj.latitude = val.latitude;
  185. }
  186. if (this.sign === 2 || this.sign === 3) {
  187. this.obj.xiantude = JSON.stringify(val.markerList);
  188. }
  189. },
  190. showLL: function (lat, lng) {
  191. this.obj.latitude = lat;
  192. this.obj.longitude = lng;
  193. },
  194. clearAway(){
  195. this.$refs.table.clearSelection();
  196. if (this.showLongitudeq == true) this.$refs.areaSupermap.clearAll();
  197. if (this.visible == true)this.$refs.supermap.clearAllByQin(this.sign)
  198. this.obj.xiantude = null;
  199. },
  200. initP(sign, form,eventId) {
  201. getConfigKey('supermapKey').then(response => {
  202. let isN = response.msg;
  203. if (isN === 'true') this.visible = true;
  204. if (isN === 'false') sign === 2 ? this.showLongitudex = true : (sign === 1 ? this.showLongitude = true : this.showLongitudeq = true);
  205. this.sign = sign;
  206. this.eventId = eventId
  207. this.uuid = uuidv4();
  208. this.$nextTick(() => {
  209. //2d 点
  210. if (this.sign === 1 && this.showLongitude === true) {
  211. setTimeout(() => {
  212. this.$refs.Supermap.clearM(false);
  213. if (form.longitude!==null && form.longitude!=='' && form.longitude!==undefined) {
  214. this.$refs.Supermap.setMarkers([{lng: form.longitude, lat: form.latitude, icon: "marker"}])
  215. }
  216. }, 2000);
  217. }
  218. // //2.5d 点
  219. // if (this.sign === 1 && this.visible === true) {
  220. // setTimeout(() => {
  221. // this.$refs.supermap.superMapInfo(this.sign, {longitude: form.longitude, latitude: form.latitude});
  222. // }, 2000)
  223. // }
  224. //2.5d 点
  225. if (this.sign === 1 && this.visible === true) {
  226. setTimeout(() => {
  227. this.$refs.supermap.superMapInfo(this.sign, {longitude: form.longitude, latitude: form.latitude});
  228. }, 2000);
  229. setTimeout(() => {
  230. this.$refs.supermap.loadRoad()
  231. }, 7000);
  232. }
  233. //2.5d 线/区域
  234. if ((this.sign === 2 && this.visible === true) || (this.sign === 3 && this.visible === true)) {
  235. // const arr = JSON.parse(form.xiantude == undefined || form.xiantude == null ? "[]" : form.xiantude);
  236. // console.log(arr)
  237. this.getRegionalFlag();
  238. setTimeout(() => {
  239. this.$refs.supermap.superMapInfo(this.sign, {
  240. graphicsList: this.arr && this.arr.length > 0 ? this.arr : [],
  241. color: "rgba(250,4,4,0)",
  242. withAlpha: 0.8
  243. },null,undefined,1);
  244. }, 2000);
  245. }
  246. //2d 线
  247. if (this.sign === 2 && this.showLongitudex === true) {
  248. const arr = JSON.parse(form.xiantude);
  249. setTimeout(() => {
  250. this.$refs.LineSupermap.setConnectList(arr && arr.length > 0 ? arr : [], "#1a1919");
  251. }, 2000)
  252. }
  253. //2d 区域
  254. if (this.sign === 3 && this.showLongitudeq === true) {
  255. this.getRegionalFlag();
  256. // const arr = JSON.parse(form.xiantude);
  257. setTimeout(() => {
  258. this.$refs.areaSupermap.setGraphicsList(
  259. this.arr && this.arr.length > 0 ? this.arr : [],
  260. "#1a1919");
  261. }, 2000)
  262. }
  263. }
  264. )
  265. })
  266. },
  267. handleSelectionChange(selection) {
  268. if ((this.sign === 2 && this.visible === true) || (this.sign === 3 && this.visible === true)) {
  269. this.$refs.supermap.entityHandler(1);
  270. this.$refs.supermap.setGraphicsList2(selection, "rgba(250,4,4,0)", 0.8);
  271. }
  272. if (this.sign === 3 && this.showLongitudeq === true) {
  273. this.$refs.areaSupermap.clearAll();
  274. for (let i = 0; i < selection.length; i++) {
  275. let graphicsList = [];
  276. for (let j = 0; j < selection[i].latLng.length; j+=2) {
  277. graphicsList.push({lng:selection[i].latLng[j],lat:selection[i].latLng[j+1]});
  278. }
  279. this.$refs.areaSupermap.setGraphicsList(graphicsList, "#1a1919",selection[i].name);
  280. }
  281. // this.$refs.areaSupermap.setGraphicsList([{lat:"124",lng:"42"},{lat:"24",lng:"142"},{lat:"11",lng:"42"},{lat:"2",lng:"1"},{lat:"124",lng:"42"}], "#1a1919");
  282. // this.$refs.areaSupermap.setGraphicsList([{lat:"122.552490234375",lng:"45.78276229037425"},{lat:"131.275634765625",lng:"45.716885087220255"},{lat:"127.96875",lng:"42.53282026811079"},{lat:"122.67333984375",lng:"43.19159229965069"}], "#1a1919");
  283. }
  284. },
  285. submitForm(){
  286. this.$refs["obj"].validate(valid => {
  287. if (valid) {
  288. if (this.id) {
  289. updateRegionalFlag(this.obj).then(response => {
  290. this.$modal.msgSuccess("修改成功");
  291. this.getRegionalFlag();
  292. });
  293. } else {
  294. this.$emit('send', this.obj);
  295. }
  296. this.visibleName = false;
  297. this.clearAway();
  298. // this.visible = false;
  299. this.showLongitude = false;
  300. this.showLongitudex = false;
  301. // this.showLongitudeq = false;
  302. }
  303. });
  304. },
  305. cancel(){
  306. this.obj.name = null;
  307. this.visibleName = false;
  308. this.clearAway();
  309. },
  310. reset() {
  311. this.obj.name=null,
  312. this.resetForm("obj");
  313. },
  314. handleUpdate(row) {
  315. this.reset();
  316. this.obj.eventId = this.eventId
  317. this.obj.flagType = row.flagType
  318. this.id = 1;//修改表标识
  319. this.visibleName = true;
  320. this.title = "修改区域标记";
  321. },
  322. closeDialog() {
  323. this.reset();
  324. this.id = null;
  325. this.title = "添加区域标记";
  326. if (this.obj.longitude || (this.obj.xiantude && JSON.parse(this.obj.xiantude).length > 0))this.visibleName = true;
  327. },
  328. closeDialogsend() {
  329. this.$emit('send', 666);
  330. this.visible = false;
  331. this.showLongitude = false;
  332. this.showLongitudex = false;
  333. this.showLongitudeq = false;
  334. },
  335. close() {
  336. this.$emit('send', true);
  337. this.visible = false;
  338. this.showLongitude = false;
  339. this.showLongitudex = false;
  340. this.showLongitudeq = false;
  341. },
  342. }
  343. };
  344. </script>