index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <div id="mapApp">
  3. <div class="btn" v-if="nowObj.qsx">
  4. <!-- <el-button @click="drawer = true">打开抽屉</el-button> -->
  5. <span class="sx qsx">前时相:{{ nowObj.qsx }}</span>
  6. <span class="sx hsx">后时相:{{ nowObj.hsx }}</span>
  7. </div>
  8. <MapView :maptype="maptype" ref="MapView" />
  9. <el-drawer
  10. :visible.sync="drawer"
  11. :with-header="false"
  12. :modal="false"
  13. :wrapperClosable="false"
  14. modal-class="mask-layer"
  15. >
  16. <div class="jctbCon">
  17. <div class="tbTitle">
  18. <span>检测图斑{{ newObj.name }}</span>
  19. <el-input
  20. placeholder="请输入监测编号查询"
  21. prefix-icon="el-icon-search"
  22. v-model="queryParams.jcbh"
  23. >
  24. </el-input>
  25. <el-button>下载</el-button>
  26. </div>
  27. <div class="numCard">
  28. <div class="cardItem">
  29. <span>检测图斑个数(个):</span>
  30. <span>{{ newObj.spotsnumber }}</span>
  31. </div>
  32. <div class="cardItem jc">
  33. <span>监测面积(亩):</span>
  34. <span>{{ newObj.spotsarea }}</span>
  35. </div>
  36. </div>
  37. <el-table :data="tableData" border style="width: 100%">
  38. <!-- @cell-click="tableClick" -->
  39. <el-table-column prop="jcbh" label="监测编号" width="220">
  40. <template slot-scope="scope">
  41. <span style="cursor: pointer" @click="tableClick(scope.row)">{{
  42. scope.row.jcbh
  43. }}</span>
  44. </template>
  45. </el-table-column>
  46. <el-table-column prop="xmc" label="区县名称" show-overflow-tooltip>
  47. </el-table-column>
  48. <el-table-column
  49. prop="jcmj"
  50. label="监测面积(亩)"
  51. show-overflow-tooltip
  52. >
  53. </el-table-column>
  54. <el-table-column label="操作" align="center">
  55. <template slot-scope="scope">
  56. <el-button
  57. size="mini"
  58. type="text"
  59. @click.stop="handleDetails(scope.row)"
  60. >详情</el-button
  61. >
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. <pagination
  66. v-show="total > 0"
  67. :total="total"
  68. :page.sync="queryParams.pageNum"
  69. :limit.sync="queryParams.pageSize"
  70. @pagination="getList"
  71. />
  72. </div>
  73. </el-drawer>
  74. <el-dialog
  75. title="详细信息"
  76. :visible.sync="dialogVisible"
  77. width="30%"
  78. :before-close="handleClose"
  79. >
  80. <CustomDetails :model="infoObj" :config="detailInfos"></CustomDetails>
  81. </el-dialog>
  82. </div>
  83. </template>
  84. <script>
  85. import MapView from "../MapView.vue";
  86. import CustomDetails from "@/components/custom-detailsInfo.vue";
  87. import parse from "wellknown";
  88. import { getPcsj, listPcsjXQList, getPcsjXQ } from "@/api/supervise/pcsj";
  89. import { detailInfos } from "./config";
  90. import "ol/ol.css";
  91. // import { get as getProjection, transform } from "ol/proj.js";
  92. import Map from "ol/Map";
  93. import View from "ol/View";
  94. import TileLayer from "ol/layer/Tile";
  95. import VectorSource from "ol/source/Vector";
  96. import VectorLayer from "ol/layer/Vector";
  97. import Feature from "ol/Feature";
  98. import LineString from "ol/geom/LineString";
  99. import Stroke from "ol/style/Stroke";
  100. import Fill from "ol/style/Fill";
  101. import { Vector as LayerVec } from "ol/layer";
  102. import { Style, Icon } from "ol/style";
  103. import { Point } from "ol/geom";
  104. import { Vector as SourceVec, XYZ } from "ol/source";
  105. import Tile from "ol/layer/Tile";
  106. import { OSM } from "ol/source";
  107. import * as control from "ol/control";
  108. import * as coordinate from "ol/coordinate";
  109. import ImageLayer from "ol/layer/Image";
  110. import ImageStatic from "ol/source/ImageStatic";
  111. import Draw from "ol/interaction/Draw";
  112. import GeoJSON from "ol/format/GeoJSON";
  113. import { transform } from "@/utils/transformUtils";
  114. import { removeWebGLTile, addTiff } from "@/utils/help";
  115. export default {
  116. components: {
  117. MapView,
  118. CustomDetails,
  119. },
  120. data() {
  121. return {
  122. maptype: "normal",
  123. total: 0,
  124. queryParams: {
  125. jcbh: "", //监测编号
  126. pageNum: 1,
  127. pageSize: 10,
  128. pcsjid: this.$route.query.id,
  129. },
  130. drawer: true,
  131. direction: "rtl",
  132. tableData: [],
  133. newObj: {
  134. name: "f52d8b03a7214d9098ca44a7ea641d9b",
  135. spotsnumber: 0,
  136. spotsarea: 0,
  137. },
  138. curPageResultLayer: {},
  139. vectorLayer: {},
  140. nowObj: {},
  141. itemObj: {}, //用于存储分屏高亮的实体
  142. dialogVisible: false,
  143. infoObj: {},
  144. detailInfos: detailInfos,
  145. };
  146. },
  147. mounted() {
  148. console.log(this.$route.query);
  149. // 绑定事件,编写回调函数
  150. this.$nextTick(() => {
  151. getPcsj(this.$route.query.id).then((response) => {
  152. this.newObj = response.data;
  153. });
  154. this.getList();
  155. });
  156. },
  157. methods: {
  158. tableClick(row) {
  159. removeWebGLTile("mapCon1");
  160. removeWebGLTile("mapCon2");
  161. let urlQsx = this.newObj.proxypath + row.qsxtif;
  162. let urlHsx = this.newObj.proxypath + row.hsxtif;
  163. if (this.nowObj.id != row.id) {
  164. this.maptype = "split";
  165. this.nowObj = row;
  166. addTiff("mapCon1", urlQsx);
  167. addTiff("mapCon2", urlHsx);
  168. this.test(row);
  169. } else {
  170. this.maptype = "normal";
  171. this.nowObj = {};
  172. }
  173. },
  174. getList() {
  175. listPcsjXQList(this.queryParams).then((response) => {
  176. this.tableData = response.rows;
  177. this.total = response.total;
  178. // this.open = true;
  179. // this.title = "修改监管批次数据";
  180. this.initVectorLayer("mapDiv");
  181. this.initVectorLayer("mapCon1");
  182. this.initVectorLayer("mapCon2");
  183. this.addGeoJson("mapDiv");
  184. this.addGeoJson("mapCon1");
  185. this.addGeoJson("mapCon2");
  186. });
  187. },
  188. handleDetails(row) {
  189. getPcsjXQ(row.id).then((res) => {
  190. this.infoObj = res.data;
  191. this.dialogVisible = true;
  192. });
  193. },
  194. handleClose() {
  195. this.drawer = false;
  196. },
  197. test(item) {
  198. window.map["mapCon1"].removeLayer(this.itemObj);
  199. window.map["mapCon2"].removeLayer(this.itemObj);
  200. if (item.geom && item.geom != "") {
  201. if (typeof item.geom === "string") {
  202. let geom = this.tableData[i].geom;
  203. item.geom = parse(geom);
  204. }
  205. let features = new GeoJSON().readFeatures(item.geom);
  206. this.itemObj = new VectorLayer({
  207. source: new VectorSource({
  208. features: features,
  209. }),
  210. style: function (feature) {
  211. return new Style({
  212. fill: new Fill({
  213. //矢量图层填充颜色,以及透明度
  214. color: "#f006",
  215. }),
  216. stroke: new Stroke({
  217. //边界样式
  218. color: "rgba(255, 0, 0, 1)",
  219. width: 2,
  220. }),
  221. });
  222. },
  223. zIndex: 9999,
  224. });
  225. let fullExtent = this.itemObj.getSource().getExtent();
  226. window.map["mapCon1"].getView().fit(fullExtent, {
  227. duration: 3, //动画的持续时间,
  228. callback: null,
  229. });
  230. window.map["mapCon1"].addLayer(this.itemObj);
  231. window.map["mapCon2"].addLayer(this.itemObj);
  232. }
  233. },
  234. addGeoJson(name) {
  235. this.tableData.forEach((titem, i) => {
  236. if (titem.geom && titem.geom != "") {
  237. if (typeof titem.geom === "string") {
  238. // let geom = transform(this.tableData[i].geom);
  239. let geom = this.tableData[i].geom;
  240. titem.geom = parse(geom);
  241. }
  242. let features = new GeoJSON().readFeatures(titem.geom);
  243. this.curPageResultLayer[name].getSource().addFeatures(features);
  244. }
  245. });
  246. let fullExtent = this.curPageResultLayer[name].getSource().getExtent();
  247. window.map[name].getView().fit(fullExtent, {
  248. duration: 3, //动画的持续时间,
  249. callback: null,
  250. });
  251. },
  252. /**
  253. * 初始化地图矢量图层
  254. */
  255. initVectorLayer(name) {
  256. if (!this.vectorLayer[name]) {
  257. let vectorSource = new VectorSource({
  258. // projection: "EPSG:3857",
  259. });
  260. this.vectorLayer[name] = new VectorLayer({
  261. source: vectorSource,
  262. style: new Style({
  263. stroke: new Stroke({
  264. color: "#f00",
  265. width: 2,
  266. }),
  267. }),
  268. });
  269. window.map[name].addLayer(this.vectorLayer[name]);
  270. }
  271. if (!this.curPageResultLayer[name]) {
  272. let vectorSource = new VectorSource();
  273. this.curPageResultLayer[name] = new VectorLayer({
  274. source: vectorSource,
  275. zIndex: 999,
  276. style: new Style({
  277. stroke: new Stroke({
  278. color: "#1f1cd3",
  279. width: 2,
  280. }),
  281. }),
  282. });
  283. window.map[name].addLayer(this.curPageResultLayer[name]);
  284. }
  285. },
  286. },
  287. };
  288. </script>
  289. <style lang="scss" scoped>
  290. .btn {
  291. // position: absolute;
  292. // top: 0;
  293. // left: 60px;
  294. // z-index: 40;
  295. .sx {
  296. background: rgb(151, 250, 222);
  297. padding: 5px 10px;
  298. border: 1px solid #4949492b;
  299. border-radius: 5px;
  300. position: absolute;
  301. top: 20px;
  302. left: calc(50% - 420px);
  303. z-index: 40;
  304. }
  305. .hsx {
  306. left: calc(50% - 220px);
  307. }
  308. }
  309. // .mask-layer{
  310. // width: 264px !important;
  311. // }
  312. ::v-deep .el-drawer__wrapper {
  313. position: static !important;
  314. }
  315. ::v-deep .el-drawer__container {
  316. position: static !important;
  317. }
  318. .jctbCon {
  319. .tbTitle {
  320. display: flex;
  321. justify-content: space-around;
  322. ::v-deep .el-input {
  323. width: 40%;
  324. }
  325. }
  326. .numCard {
  327. width: 100%;
  328. height: 120px;
  329. display: flex;
  330. // background-color: rgba(255, 192, 203, 0.272);
  331. flex-direction: row;
  332. align-items: center;
  333. justify-content: space-between;
  334. .cardItem {
  335. width: 230px;
  336. height: 85px;
  337. background: linear-gradient(
  338. 180deg,
  339. rgba(30, 198, 149, 1) 0%,
  340. rgba(30, 198, 149, 1) 0%,
  341. rgba(51, 204, 204, 1) 100%,
  342. rgba(51, 204, 204, 1) 100%
  343. );
  344. border: none;
  345. border-radius: 4px;
  346. -moz-box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.349019607843137);
  347. -webkit-box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.349019607843137);
  348. box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.349019607843137);
  349. font-family: "Arial Negreta", "Arial Normal", "Arial";
  350. font-weight: 700;
  351. font-style: normal;
  352. font-size: 14px;
  353. color: #ffffff;
  354. display: flex;
  355. flex-direction: column;
  356. justify-content: center;
  357. span {
  358. display: inline-block;
  359. width: 100%;
  360. height: 39%;
  361. // background: #faebd78c;
  362. text-align: center;
  363. }
  364. }
  365. .jc {
  366. background: linear-gradient(
  367. 90deg,
  368. rgba(244, 174, 149, 1) 0%,
  369. rgba(244, 174, 149, 1) 0%,
  370. rgba(226, 113, 140, 1) 100%,
  371. rgba(226, 113, 140, 1) 100%
  372. );
  373. }
  374. }
  375. }
  376. </style>
  377. <style scoped>
  378. html,
  379. body {
  380. padding: 0;
  381. margin: 0;
  382. height: 100%;
  383. }
  384. #mapApp {
  385. width: 100%;
  386. height: 100%;
  387. }
  388. </style>