管理系统PC端
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

map.vue 34 KiB

1週間前
1週間前
1週間前
1週間前
6日前
6日前
6日前
1週間前
1週間前
6日前
6日前
1週間前
1週間前
6日前
6日前
6日前
6日前
1週間前
6日前
1週間前
1週間前
6日前
1週間前
6日前
1週間前
6日前
1週間前
6日前
6日前
6日前
1週間前
6日前
1週間前
6日前
1週間前
6日前
1週間前
1週間前
6日前
1週間前
6日前
6日前
1週間前
6日前
1週間前
6日前
1週間前
6日前
1週間前
6日前
1週間前
6日前
1週間前
6日前
1週間前
6日前
1週間前
6日前
1週間前
6日前
1週間前
6日前
1週間前
6日前
1週間前
6日前
1週間前
6日前
1週間前
1週間前
6日前
1週間前
1週間前
1週間前
6日前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
1週間前
6日前
1週間前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966
  1. <template>
  2. <div class="app-container">
  3. <van-nav-bar
  4. title="土地列表管理"
  5. left-arrow
  6. placeholder
  7. safe-area-inset-top
  8. @click-left="onClickLeft"
  9. />
  10. <div class="search_box">
  11. <div class="left">
  12. <van-field v-model="value" left-icon="search" placeholder="请输入用户名" />
  13. </div>
  14. <van-button type="primary" round >搜索</van-button>
  15. </div>
  16. <div class="location" :id="locationMap">
  17. <img src="../../assets/images/app/location.png" alt="">
  18. </div>
  19. <div id="full-screen-acceptance" style="width: 100%;height:100vh;">
  20. <!--<div id="landMapDiv"></div>-->
  21. <div id="landMapBox"></div>
  22. <!-- <div id='land-btn-wrap'>-->
  23. <!-- <el-row>-->
  24. <!-- <input id="drawPolygon" class="ant-btn ant-btn-red" type="button" value="画图"/>&nbsp;&nbsp;-->
  25. <!-- &lt;!&ndash; <input id="drawRemove" type="button" class="ant-btn ant-btn-red" value="取消画图"/>&nbsp;&nbsp; &ndash;&gt;-->
  26. <!-- <input id="drawReset" type="button" class="ant-btn ant-btn-red" value="还原"/>-->
  27. <!-- </el-row>-->
  28. <!-- </div>-->
  29. </div>
  30. <van-popup v-model="open" position="bottom" round >
  31. <div class="landPopup">
  32. <p class="landPopup_title">属性数据 <img @click="$router.push({name:'appAttributeEdit',query:{fid:form.fid}})" src="../../assets/images/app/edit.png" width="25" alt=""></p>
  33. <van-field readonly v-model="form.deptName" label="区域位置名称" placeholder="请输入" input-align="right" label-width="auto" />
  34. <van-field readonly v-model="form.bsm" label="标识码" placeholder="请输入" input-align="right" label-width="auto" />
  35. <van-field readonly v-model="form.ysdm" label="要素代码" placeholder="请输入" input-align="right" label-width="auto" />
  36. <van-field readonly v-model="form.dkbm" label="地块代码" placeholder="请输入" input-align="right" label-width="auto" />
  37. <van-field readonly v-model="form.dkmc" label="地块名称" placeholder="请输入" input-align="right" label-width="auto" />
  38. <van-field readonly v-model="form.syqxz" label="所有权性质" placeholder="请输入" input-align="right" label-width="auto" />
  39. <van-field readonly v-model="form.dklb" label="地块类别" placeholder="请输入" input-align="right" label-width="auto" />
  40. <van-field readonly v-model="form.tdlylx" label="土地利用类型" placeholder="请输入" input-align="right" label-width="auto" />
  41. <van-field readonly v-model="form.dldj" label="地力等级" placeholder="请输入" input-align="right" label-width="auto" />
  42. <van-field readonly v-model="form.tdyt" label="土地用途" placeholder="请输入" input-align="right" label-width="auto" />
  43. <van-field readonly v-model="form.sfjbnt" label="是否基本农田" placeholder="请输入" input-align="right" label-width="auto" />
  44. <van-field readonly v-model="form.dkdz" label="地块东至" placeholder="请输入" input-align="right" label-width="auto" />
  45. <van-field readonly v-model="form.dkxz" label="地块西至" placeholder="请输入" input-align="right" label-width="auto" />
  46. <van-field readonly v-model="form.dknz" label="地块南至" placeholder="请输入" input-align="right" label-width="auto" />
  47. <van-field readonly v-model="form.dkbz" label="地块北至" placeholder="请输入" input-align="right" label-width="auto" />
  48. <van-field readonly v-model="form.dkbzxx" label="备注信息" placeholder="请输入" input-align="right" label-width="auto" />
  49. <van-field readonly v-model="form.zjrxm" label="指界人姓名" placeholder="请输入" input-align="right" label-width="auto" />
  50. <van-field readonly v-model="form.txmj" label="图显面积" placeholder="请输入" input-align="right" label-width="auto" />
  51. <van-field readonly v-model="form.scmjm" label="实测面积" placeholder="请输入" input-align="right" label-width="auto" />
  52. <van-field readonly v-model="form.sfzwd" label="是否账外地" placeholder="请输入" input-align="right" label-width="auto" />
  53. <p class="landPopup_title">经营数据 <img @click="$router.push({name:'appOperateEdit',query:{dkbm:form.dkbm}})" src="../../assets/images/app/edit.png" width="25" alt=""></p>
  54. <van-field readonly v-model="form.jymj" label="经营面积(亩)" placeholder="请输入" input-align="right" label-width="auto" />
  55. <van-field readonly v-model="form.jyfs" label="经营方式" placeholder="请输入" input-align="right" label-width="auto" />
  56. <van-field readonly v-model="form.jydxmc" label="经营对象名称" placeholder="请输入" input-align="right" label-width="auto" />
  57. <van-field readonly v-model="form.jykssj" label="经营开始时间" placeholder="请输入" input-align="right" label-width="auto" />
  58. <van-field readonly v-model="form.jyjssj" label="经营结束时间" placeholder="请输入" input-align="right" label-width="auto" />
  59. <van-field readonly v-model="form.cbje" label="承包金额(元)" placeholder="请输入" input-align="right" label-width="auto" />
  60. <van-field readonly v-model="form.surveyStatus" label="调查状态" placeholder="请输入" input-align="right" label-width="auto" />
  61. <van-field readonly v-model="form.bzxx" label="备注信息" placeholder="请输入" input-align="right" label-width="auto" />
  62. <van-field readonly label="实物图" placeholder="" input-align="right" label-width="auto" />
  63. <div v-if="!!form.dkImg">
  64. <el-tooltip effect="light" :content="item" placement="bottom" v-for="(item, index) in form.dkImg.split(',')" :key="index">
  65. <el-image style="height: 64px; width: 64px; margin: 2px; display: inline-block;" fit="scale-down" :src="baseRoutingUrll + item" :preview-src-list="form.dkImg.split(',').map((x) => baseRoutingUrll + x)"/>
  66. </el-tooltip>
  67. </div>
  68. <div class="footer_main">
  69. <van-button type="danger" @click="open = false" hairline size="large">关闭弹窗</van-button>
  70. </div>
  71. </div>
  72. </van-popup>
  73. </div>
  74. </template>
  75. <script>
  76. import { listLand, listLandQuery,getLand, getLandDetail, getLandDetailByDkbm, delLand, addLand, updateLand, printLand } from "@/api/resource/land"
  77. import { getOperationDetailByDkbm } from "@/api/resource/operation"
  78. import { areaSavePri, cleanSavePri } from "@/api/gis/map"
  79. import { getToken } from "@/utils/auth"
  80. import Treeselect from "@riophae/vue-treeselect";
  81. import { Splitpanes, Pane } from "splitpanes"
  82. import "@riophae/vue-treeselect/dist/vue-treeselect.css"
  83. import "splitpanes/dist/splitpanes.css"
  84. import { deptTreeSelect } from "@/api/system/user"
  85. import {getConfigKey} from "@/api/system/config";
  86. import {getDept,getInfoByImportCode} from "@/api/system/dept";
  87. import MapField from "@/components/house/MapField";
  88. import {Toast} from "vant";
  89. import $ from "jquery";
  90. export default {
  91. name: "contractedVillageContractor",
  92. components: { Treeselect, Splitpanes, Pane,MapField },
  93. data() {
  94. return {
  95. baseRoutingUrll:'/api',
  96. form: {}, // 地块信息表单参数
  97. map: "", // 地图
  98. mapGeoServerUrl: "", // geoserver地址
  99. mapCenterLocation: [], // 地图中心坐标
  100. landLayerName: "", // 地块图层名称
  101. landLayer: "", // 地块图层
  102. mapBorder: "", // 地图边界
  103. villageBorderLayerName: "", // 乡镇边界图层名称
  104. vectorLayer: "", // 绘制的矢量图层
  105. title: "", // 弹出层标题
  106. open: false, // 是否显示地块弹出层
  107. syqxzOptions: [], // 所有权性质字典
  108. syqxzText: null, // 所有权性质标签名
  109. showOwnership: false, // 控制所有权性质字典弹出层的显示和隐藏
  110. dklbOptions: [], // 地块类别字典
  111. dklbText: null, // 地块类别标签名
  112. showLandCategory: false, // 控制的地块类别字典弹出层的显示和隐藏
  113. dldjOptions: [], // 地力等级字典
  114. dldjText: null, // 地力等级标签名
  115. showLandGrade: false, // 控制地力等级字典弹出层的显示和隐藏
  116. tdytOptions: [], // 土地用途字典
  117. tdytText: null, // 土地用途标签名
  118. showLandPurpose: false, // 控制土地用途字典弹出层的显示和隐藏
  119. tdlylxOptions: [], // 土地利用类型
  120. tdlylxText: null, // 土地利用类型标签名
  121. showLandType: false, // 控制土地利用类型字典弹出层的显示和隐藏
  122. sfjbntOptions: [], // 是否基本农田字典
  123. showSaveBtn: false, // 控制保存按钮的显示隐藏
  124. showDeleteBtn: false, // 控制删除按钮的显示隐藏
  125. // isDisabled: false, // 是否禁用
  126. taskStatus: null, // 调查任务的完成状态:1表示已完成,2表示未完成
  127. landCategory: ['10'], // 地块类别
  128. showLegend:true,
  129. value:'',
  130. deptId:100,
  131. importCode:'',
  132. locationMap: this.guidProduct(),
  133. };
  134. },
  135. computed: {
  136. isAndroid() {
  137. return !!window._Native_object;
  138. },
  139. hasSelectLocationMode() {
  140. return this.isAndroid && typeof(window._Native_object.SelectLocationMode) === 'function';
  141. },
  142. hasGetLocationTimeout() {
  143. return this.isAndroid && typeof(window._Native_object.GetLocationTimeout) === 'function';
  144. },
  145. hasGetLocationMode() {
  146. return this.isAndroid && typeof(window._Native_object.GetLocationMode) === 'function';
  147. },
  148. },
  149. created() {
  150. console.log(this.$store.getters.user.user.dept.deptId)
  151. this.deptId = this.$store.getters.user.user.dept.deptId;
  152. this.importCode = this.$store.getters.user.user.dept.importCode;
  153. // 获取geoserver的地址
  154. this.getGeoServerUrl();
  155. // 获取地块图层名称
  156. this.getLandLayerName();
  157. // 获取村边界的图层名称
  158. this.getVillageBorderLayerName();
  159. },
  160. mounted() {
  161. // 初始化地图
  162. listLandQuery().then(response => {
  163. setTimeout(() => {
  164. this.initMap(response.rows);
  165. }, 500);
  166. });
  167. },
  168. methods: {
  169. onClickLeft(){
  170. history.back(-1);
  171. },
  172. // 获取geoserver的地址
  173. getGeoServerUrl() {
  174. getConfigKey("system.geoServer.url").then(response => {
  175. this.mapGeoServerUrl = response.msg;
  176. });
  177. },
  178. // 获取地块图层名称
  179. getLandLayerName() {
  180. getConfigKey("geoserver.layer.resourceLand").then(response => {
  181. this.landLayerName = response.msg;
  182. });
  183. },
  184. // 获取村边界的图层名称
  185. getVillageBorderLayerName() {
  186. getConfigKey("geoserver.layer.villageBorder").then(response => {
  187. this.villageBorderLayerName = response.msg;
  188. });
  189. },
  190. guidProduct(){
  191. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  192. var r = Math.random() * 16 | 0,
  193. v = c == 'x' ? r : (r & 0x3 | 0x8);
  194. return v.toString(16);
  195. });
  196. },
  197. // 初始化地图
  198. initMap(resourceList) {
  199. getDept(this.deptId).then(response => {
  200. let dept = response.data;
  201. if (dept.longitude && dept.latitude) {
  202. this.mapCenterLocation = [dept.longitude, dept.latitude];
  203. } else {
  204. this.mapCenterLocation = [116.391458, 39.902377];
  205. }
  206. document.getElementById("landMapBox").innerHTML = "";
  207. // 定义地图投影
  208. let projection = new ol.proj.Projection({
  209. code: "EPSG:3857",
  210. units: "degrees",
  211. });
  212. // 定义地图图层
  213. let aerial = new ol.layer.Tile({
  214. source: new ol.source.XYZ({
  215. url: "http://t{0-7}.tianditu.com/img_w/wmts?" +
  216. "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
  217. "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=cc4aba6e967096098249efa069733067",
  218. }),
  219. isGroup: true,
  220. name: "卫星影像图",
  221. });
  222. let yingxzi = new ol.layer.Tile({
  223. source: new ol.source.XYZ({
  224. url: "http://t{0-7}.tianditu.com/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=cc4aba6e967096098249efa069733067",
  225. }),
  226. isGroup: true,
  227. name: "天地图文字标注--卫星影像图",
  228. });
  229. //加载地图
  230. this.map = new ol.Map({
  231. controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]),
  232. layers: [aerial, yingxzi],
  233. projection: projection,
  234. target: "landMapBox",
  235. view: new ol.View({
  236. center: ol.proj.fromLonLat(this.mapCenterLocation), // 地图中心坐标
  237. zoom: 15.5,
  238. minZoom: 1, //地图缩小限制
  239. maxZoom: 18, //地图放大限制
  240. // extent: [13481224.75161,5667110.83528,13811063.06278,5880284.11416]
  241. }),
  242. });
  243. // // 添加村边界
  244. this.addVillageBorder();
  245. // 添加地块图层
  246. this.addLandLayer();
  247. // 绘制地块
  248. $("#drawLandPolygon").click(() => {
  249. // 创建矢量数据源
  250. let vectorSource = new ol.source.Vector({
  251. wrapX: false,
  252. });
  253. // 创建矢量图层
  254. this.vectorLayer = new ol.layer.Vector({
  255. source: vectorSource,
  256. });
  257. // 添加图层
  258. this.map.addLayer(this.vectorLayer);
  259. // 地图交互-绘制图形
  260. let drawInteraction = new ol.interaction.Draw({
  261. source: vectorSource,
  262. type: "Polygon",
  263. });
  264. // 添加交互
  265. this.map.addInteraction(drawInteraction);
  266. drawInteraction.on('drawend', (evt) => {
  267. // 移除交互
  268. this.map.removeInteraction(drawInteraction);
  269. let coordinates = evt.feature.getGeometry().getCoordinates();
  270. this.reset();
  271. this.form.theGeom = JSON.stringify(coordinates);
  272. this.title = "添加地块信息";
  273. this.showSaveBtn = true;
  274. this.showDeleteBtn = false;
  275. // this.isDisabled = false;
  276. setTimeout(() => {
  277. this.open = true;
  278. }, 10);
  279. });
  280. });
  281. var mark_layer = null;
  282. function addMark(lng, lat) {
  283. if(!mark_layer)
  284. {
  285. mark_layer = new ol.layer.Vector({
  286. source: new ol.source.Vector(),
  287. });
  288. that.map.addLayer(mark_layer);
  289. }
  290. else
  291. mark_layer.getSource().clear();
  292. let newFeature = new ol.Feature({
  293. geometry: new ol.geom.Point(ol.proj.fromLonLat([lng, lat])), //几何信息
  294. //name: "标注点",
  295. });
  296. newFeature.setStyle(new ol.style.Style({
  297. image: new ol.style.Icon({
  298. //设置图标偏移
  299. anchor: [0.5, 0.5],
  300. //标注样式的起点位置
  301. anchorOrigin: "top-right",
  302. //X方向单位:分数
  303. anchorXUnits: "fraction",
  304. //Y方向单位:像素
  305. anchorYUnits: "fraction",
  306. //偏移起点位置的方向
  307. offsetOrigin: "top-right",
  308. //透明度
  309. opacity: 0.9,
  310. //图片路径
  311. src: require('../../assets/images/app/mark.png'),
  312. }),
  313. zIndex: 9999,
  314. }));
  315. mark_layer.getSource().addFeature(newFeature);
  316. }
  317. var that = this;
  318. var Zb;
  319. $("#" + this.locationMap).click(function () {
  320. that.getCurrentLocation(res => {
  321. if (res.code == 200) {
  322. let lat = res.data.lat;
  323. let lng = res.data.lng;
  324. if(lat && lng){
  325. Zb = [lng,lat];
  326. }else {
  327. Zb =[115.452752, 31.789033];
  328. }
  329. addMark(lng,lat);
  330. that.map.getView().animate({
  331. // 只设置需要的属性即可
  332. center: ol.proj.fromLonLat(Zb), // 中心点
  333. zoom: 18, // 缩放级别
  334. rotation: undefined, // 缩放完成view视图旋转弧度
  335. duration: 1000, // 缩放持续时间,默认不需要设置
  336. });
  337. }
  338. });
  339. });
  340. // 地图点击事件
  341. this.map.on("click", (evt) => {
  342. // 点击宅基地查看详情
  343. console.log(this.landLayer)
  344. if (this.landLayer) {
  345. const viewResolution = this.map.getView().getResolution();
  346. const url = this.landLayer.getSource()
  347. .getFeatureInfoUrl(evt.coordinate, viewResolution, 'EPSG:3857', {'INFO_FORMAT': 'application/json'});
  348. console.log(url)
  349. if (url) {
  350. fetch(url)
  351. .then(response => response.json())
  352. .then(data => {
  353. if (data.features.length > 0) {
  354. let id = data.features[0].properties.DKBM;
  355. getLandDetailByDkbm(id).then(response => {
  356. this.form = response.data;
  357. setTimeout(() => {
  358. this.open = true;
  359. }, 500);
  360. });
  361. // getLandDetail(id).then(response => {
  362. // // this.form = response.data;
  363. // getLandDetailByDkbm(response.data.dkbm).then(res => {
  364. // res.data.txmj = response.data.txmj;
  365. // this.form = res.data;
  366. // });
  367. // // getOperationDetailByDkbm(response.data.dkbm).then(response => {
  368. // // this.form = response.data
  369. // // })
  370. // setTimeout(() => {
  371. // this.open = true;
  372. // }, 500);
  373. // });
  374. }
  375. });
  376. }
  377. }
  378. });
  379. });
  380. },
  381. filterLandLayer() {
  382. if (this.landLayer) {
  383. this.map.removeLayer(this.landLayer);
  384. this.landLayer = "";
  385. }
  386. this.addLandLayer();
  387. },
  388. getLocationMode() {
  389. let mode = '';
  390. if(this.hasGetLocationMode)
  391. {
  392. mode = window._Native_object.GetLocationMode();
  393. }
  394. console.log('当前选择定位模式: ' + mode);
  395. return mode;
  396. },
  397. getLocationTimeout() {
  398. let timeout = 10000;
  399. if(this.hasGetLocationMode)
  400. {
  401. let to = window._Native_object.GetLocationTimeout();
  402. if(to <= 0)
  403. to = 30000;
  404. timeout = to;
  405. }
  406. console.log('当前选择定位超时: ' + timeout);
  407. return timeout;
  408. },
  409. getDeptLocation(callback) {
  410. getQueryLand().then((response) => {
  411. if (response.code == 200) {
  412. let InsertCode = response.data;
  413. if (InsertCode != null) {
  414. var lat = InsertCode.lat;
  415. var lng = InsertCode.lng;
  416. if(lat !=null && lng !=null && lat !="" && lng !=""){
  417. callback(response);
  418. return;
  419. }
  420. }
  421. }
  422. this.getCurrentLocation(callback);
  423. });
  424. },
  425. getCurrentLocation(callback) {
  426. // 1. 首先尝试Android宿主端
  427. if(this.isAndroid) // Android层注入全局对象
  428. {
  429. let mode = this.getLocationMode();
  430. if(mode !== 'h5')
  431. {
  432. console.log('使用Native获取定位');
  433. let coord = window._Native_object.GetLocation(null);
  434. console.log('Native坐标: ' + coord);
  435. if(coord)
  436. {
  437. let arr = coord.split(',');
  438. let res = {
  439. code: 200,
  440. data: {
  441. lng: arr[0],
  442. lat: arr[1],
  443. },
  444. };
  445. callback(res);
  446. return;
  447. }
  448. }
  449. }
  450. // 2. 再尝试浏览器
  451. if (navigator.geolocation) {
  452. console.log('使用浏览器获取定位');
  453. const loading = Toast.loading({
  454. message: '定位中...',
  455. duration: 0,
  456. });
  457. let timeout = this.getLocationTimeout();
  458. navigator.geolocation.getCurrentPosition(
  459. (position) => {
  460. const { latitude, longitude } = position.coords;
  461. console.log('浏览器定位结果: 经纬度=' + longitude + ', ' + latitude);
  462. let res = {
  463. code: 200,
  464. data: {
  465. lng: longitude,
  466. lat: latitude,
  467. },
  468. };
  469. loading.clear();
  470. callback(res);
  471. },
  472. (error) => {
  473. loading.clear();
  474. console.log('定位失败: ' + error.message);
  475. getQueryLand().then(callback);
  476. },
  477. { enableHighAccuracy: true, timeout: timeout }
  478. );
  479. return;
  480. }
  481. // 最后使用地区坐标
  482. console.log('使用地区坐标定位');
  483. getQueryLand().then(callback);
  484. },
  485. // 添加地块图层
  486. addLandLayer() {
  487. this.landLayer = new ol.layer.Image({
  488. source: new ol.source.ImageWMS({
  489. url: this.mapGeoServerUrl + '/wms',
  490. params: {
  491. LAYERS: this.landLayerName,
  492. cql_filter: "import_code = '" + this.importCode + "'",
  493. SRID: 3857,
  494. abc: Math.random() // 无效参数,保证每次发送的请求都不一样
  495. }
  496. }),
  497. name: 'landLayer'
  498. });
  499. this.map.getLayers().insertAt(3, this.landLayer);
  500. // this.map.addLayer(this.landLayer);
  501. },
  502. // 添加村边界
  503. addVillageBorder() {
  504. this.mapBorder = new ol.layer.Image({
  505. source: new ol.source.ImageWMS({
  506. url: this.mapGeoServerUrl + '/wms',
  507. params: {
  508. LAYERS: this.villageBorderLayerName,
  509. cql_filter: "import_code = '" + this.importCode + "'",
  510. SRID: 3857,
  511. },
  512. }),
  513. name: 'villageBorderLayer'
  514. });
  515. this.map.getLayers().insertAt(2, this.mapBorder);
  516. },
  517. saveLand() {
  518. this.$refs.landForm.validate().then(() => {
  519. if (this.form.id) {
  520. this.showSaveBtn = false;
  521. updateDk(this.form).then(response => {
  522. if (response.code == 200) {
  523. this.$toast({
  524. icon: 'success',
  525. message: '保存成功',
  526. duration:"1000",
  527. onClose: () => {
  528. this.open = false;
  529. this.showSaveBtn = true;
  530. }
  531. });
  532. }
  533. });
  534. } else {
  535. this.form.deptId = this.deptId;
  536. this.showSaveBtn = false;
  537. addDk(this.form).then(response => {
  538. if (response.code == 200) {
  539. this.$toast({
  540. icon: 'success',
  541. message: '保存成功',
  542. duration:"1000",
  543. onClose: () => {
  544. this.open = false;
  545. this.showSaveBtn = true;
  546. // 移除矢量图层
  547. this.map.removeLayer(this.vectorLayer);
  548. this.vectorLayer = "";
  549. // 移除地块图层重新加载
  550. this.map.removeLayer(this.landLayer);
  551. this.landLayer = "";
  552. this.addLandLayer();
  553. }
  554. });
  555. }
  556. });
  557. }
  558. }).catch(() => {
  559. this.$notify({ type: 'danger', message: '请填写完整的表单项' });
  560. });
  561. },
  562. deleteLand(id) {
  563. this.$dialog.confirm({
  564. message: '是否确认删除此地块?',
  565. }).then(() => {
  566. // on confirm
  567. this.showDeleteBtn = false;
  568. deleteDk(id).then(res => {
  569. if (res.code == 200) {
  570. this.$toast({
  571. icon: 'success',
  572. message: '删除成功',
  573. duration: "1000",
  574. onClose: () => {
  575. this.open = false;
  576. this.showDeleteBtn = true;
  577. // 移除地块图层重新加载
  578. this.map.removeLayer(this.landLayer);
  579. this.landLayer = "";
  580. this.addLandLayer();
  581. }
  582. });
  583. }
  584. });
  585. }).catch(() => {
  586. // on cancel
  587. });
  588. },
  589. onConfirmOwnershipOptions(value){
  590. this.form.syqxz = value.dictValue;
  591. this.syqxzText = value.dictLabel;
  592. this.showOwnership = false;
  593. },
  594. onConfirmLandCategoryOptions(value){
  595. this.form.dklb = value.dictValue;
  596. this.dklbText = value.dictLabel;
  597. this.showLandCategory = false;
  598. },
  599. onConfirmLandTypeOptions(value) {
  600. this.form.tdlylx = value.dictValue;
  601. this.tdlylxText = value.dictLabel;
  602. this.showLandType = false;
  603. },
  604. onConfirmLandGradeOptions(value) {
  605. this.form.dldj = value.dictValue
  606. this.dldjText = value.dictLabel;
  607. this.showLandGrade = false;
  608. },
  609. onConfirmLandPurposeOptions(value){
  610. this.form.tdyt = value.dictValue;
  611. this.tdytText = value.dictLabel;
  612. this.showLandPurpose = false;
  613. },
  614. generateCode() {
  615. generateLandCode({deptId: this.deptId}).then(response => {
  616. this.$set(this.form, 'dkbm', response.data);
  617. });
  618. },
  619. closePopup() {
  620. // 移除矢量图层
  621. if (this.vectorLayer) {
  622. this.map.removeLayer(this.vectorLayer);
  623. this.vectorLayer = "";
  624. }
  625. this.open = false;
  626. this.reset();
  627. },
  628. reset() {
  629. this.form = {
  630. deptId: null,
  631. dkbm: null,
  632. dkmc: null,
  633. syqxz: '30',
  634. dklb: '99',
  635. tdlylx: '01',
  636. dldj: '01',
  637. tdyt: '1',
  638. sfjbnt: '1',
  639. scmjm: null,
  640. zjrxm: null,
  641. dkdz: null,
  642. dkxz: null,
  643. dknz: null,
  644. dkbz: null,
  645. dkbzxx: null,
  646. theGeom: null
  647. };
  648. this.syqxzText = '集体土地所有权';
  649. this.dklbText = '其他集体土地';
  650. this.tdlylxText = '【1】耕地';
  651. this.dldjText = '一等地';
  652. this.tdytText = '种植业';
  653. },
  654. openLandCategoryPopup() {
  655. // 修改时 && 地块类别为承包地块 不允许打开地块类别弹出层
  656. if (this.form.id && this.form.dklb === '10') {
  657. this.$toast({
  658. icon: 'fail',
  659. message: '当前地块为承包地块,不能更改地块类别',
  660. duration: '2000'
  661. })
  662. return ;
  663. }
  664. this.showLandCategory = true;
  665. }
  666. },
  667. };
  668. </script>
  669. <style scoped lang="scss">
  670. ::v-deep .van-nav-bar{
  671. background: linear-gradient( 173deg, #91E2D3 0%, #CDFCF0 100%);
  672. ::v-deep.van-icon{
  673. color: #000000;
  674. }
  675. }
  676. .location{
  677. display: flex;
  678. align-items: center;
  679. justify-content: center;
  680. width: 50px;
  681. height: 50px;
  682. margin: 2vh;
  683. position: absolute;
  684. top: 12vh;
  685. right: 0vw;
  686. z-index: 9;
  687. background-color: rgba(0,0,0,0.5);
  688. border-radius: 10px;
  689. img{
  690. width: 30px;
  691. height: 30px;
  692. border: 1px dashed #ffffff;
  693. }
  694. }
  695. .van-popup{
  696. background: linear-gradient( 180deg, #E5FFF4 0%, #ffffff 100%);
  697. .landPopup{
  698. width: 94%;
  699. margin: 0 auto;
  700. .landPopup_title{
  701. color: #29D2AF;
  702. font-size: 20px;
  703. display: flex;
  704. align-items: center;
  705. justify-content: space-between;
  706. }
  707. }
  708. }
  709. .app-container{
  710. /*background: #fff url("../../../../../static/images/contracted/contracted_index_bg.png") no-repeat center;*/
  711. background-size: 100% 100%;
  712. height: 100vh;
  713. padding: 0;
  714. overflow: hidden;
  715. }
  716. ::v-deep .van-hairline--bottom::after{
  717. border: none;
  718. }
  719. ::v-deep .van-field--disabled .van-field__label {
  720. color: #646566;
  721. }
  722. ::v-deep .landPopup .van-dialog {
  723. width: 90%;
  724. height: 85%;
  725. overflow-y: auto;
  726. }
  727. ::v-deep .landPopup .van-field__label {
  728. width: 7em;
  729. }
  730. .head{
  731. padding: 0 4vw;
  732. }
  733. .tap_block{
  734. width: 100%;
  735. display: flex;
  736. justify-content: space-between;
  737. background: #ebfaf2;
  738. padding: 2PX 4PX;
  739. border-radius: 10PX;
  740. margin-top: 1vh;
  741. .active{
  742. background-image: linear-gradient(to right,#c6fe8b,#48e5a2);
  743. box-shadow: 0 0 10PX #cccccc;
  744. color: #333333;
  745. }
  746. p{
  747. width: 25%;
  748. text-align: center;
  749. padding: 5PX 0;
  750. border-radius: 10PX;
  751. color: #666666;
  752. }
  753. }
  754. .legend_main{
  755. position: absolute;
  756. top: 2vh;
  757. right: 2vw;
  758. }
  759. .openLegend{
  760. position: absolute;
  761. top: 2vh;
  762. right: 0vw;
  763. background-color: rgba(255,255,255,.5);
  764. width: 20PX;
  765. height: 70PX;
  766. display: flex;
  767. align-items: center;
  768. justify-content: center;
  769. border-top-left-radius: 10PX;
  770. border-bottom-left-radius: 10PX;
  771. .sanjiao-left {
  772. display: inline-block;
  773. border-right: 8PX solid #999999;
  774. border-right-color: initial;
  775. border-top: 5PX solid transparent;
  776. border-bottom: 5PX solid transparent;
  777. }
  778. }
  779. .legend_second{
  780. background: rgba(255,255,255,.5);
  781. padding: 2vh;
  782. border-radius: 10PX;
  783. margin-top: 2vh;
  784. }
  785. .legend_tt{
  786. font-size: 16PX;
  787. display: flex;
  788. align-items: center;
  789. justify-content: space-between;
  790. img{
  791. width: 20PX;
  792. }
  793. }
  794. .legend{
  795. background: rgba(255,255,255,.5);
  796. padding: 2vh;
  797. border-radius: 10PX;
  798. .van-checkbox{
  799. margin-top: 2vh;
  800. &:nth-child(1){
  801. ::v-deep .van-checkbox__icon .van-icon{
  802. /*border-color: rgba(22,233,15,1);*/
  803. border: 4px solid #16E90F;
  804. }
  805. }
  806. &:nth-child(2){
  807. ::v-deep .van-checkbox__icon .van-icon{
  808. /*border-color: rgba(1,198,222,1);*/
  809. border: 4px solid #01C6DE;
  810. }
  811. }
  812. &:nth-child(3){
  813. ::v-deep .van-checkbox__icon .van-icon{
  814. /*border-color: rgba(238,238,0,1);*/
  815. border: 4px solid #EEEE00;
  816. }
  817. }
  818. &:nth-child(4){
  819. ::v-deep .van-checkbox__icon .van-icon{
  820. /*border-color: rgba(238,60,60,1);*/
  821. border: 4px solid #EE3C3C;
  822. }
  823. }
  824. &:nth-child(5){
  825. ::v-deep .van-checkbox__icon .van-icon{
  826. /*border-color: rgba(235,134,0,1);*/
  827. border: 4px solid #EB8600;
  828. }
  829. }
  830. }
  831. .van-checkbox-group {
  832. .van-checkbox__label{
  833. i{
  834. display: block;
  835. width: 15PX;
  836. height: 15PX;
  837. border: 1px solid;
  838. border-radius: 3PX;
  839. margin-left: 10PX;
  840. }
  841. .i1{
  842. background: rgba(22,233,15,.7);
  843. border-color: rgba(22,233,15,1);
  844. }
  845. .i2{
  846. background: rgba(1,198,222,.7);
  847. border-color: rgba(1,198,222,1);
  848. }
  849. .i3{
  850. background: rgba(238,238,0,.7);
  851. border-color: rgba(238,238,0,1);
  852. }
  853. .i4{
  854. background: rgba(238,60,60,.7);
  855. border-color: rgba(238,60,60,1);
  856. }
  857. .i5{
  858. background: rgba(235,134,0,.7);
  859. border-color: rgba(235,134,0,1);
  860. }
  861. div{
  862. display: flex;
  863. align-items: center;
  864. }
  865. }
  866. }
  867. }
  868. .mapBox{
  869. height: 100vh;
  870. width: 100%;
  871. }
  872. .footer_main {
  873. flex: 0 0 120px;
  874. background: #ccc;
  875. display: flex;
  876. justify-content: center; /* 相对父元素水平居中 */
  877. align-items: center; /* 子元素相对父元素垂直居中 */
  878. }
  879. .search_box{
  880. display: flex;
  881. align-items: center;
  882. justify-content: space-between;
  883. width: 94%;
  884. margin: 2vh auto;
  885. position: absolute;
  886. left: 3vw;
  887. z-index: 9;
  888. .left{
  889. display: flex;
  890. align-items: center;
  891. flex: 1;
  892. background-color: #ffffff;
  893. border-radius: 50vh;
  894. overflow: hidden;
  895. margin-right: 3vw;
  896. }
  897. p{
  898. flex-shrink: 0;
  899. }
  900. button{
  901. flex-shrink: 0;
  902. background: linear-gradient( 271deg, #53E4A5 0%, #24DBDB 100%);
  903. border: none;
  904. width: 20vw;
  905. }
  906. }
  907. #land-btn-wrap {
  908. position: relative;
  909. width: 40%;
  910. left: 60%;
  911. bottom: 95%;
  912. z-index: 2000;
  913. }
  914. #landMapBox {
  915. width: 100%;
  916. height: 100%;
  917. }
  918. .ant-btn-red {
  919. position: relative;
  920. display: inline-block;
  921. background: #D0EEFF;
  922. border: 1px solid #99D3F5;
  923. border-radius: 4px;
  924. padding: 4px 12px;
  925. overflow: hidden;
  926. color: #1E88C7;
  927. text-decoration: none;
  928. text-indent: 0;
  929. line-height: 20px;
  930. right: -36%;
  931. }
  932. </style>