150a39e0719a03475d7512168ef8b89e2b3c1c91.svn-base 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <j-modal
  3. :title="title"
  4. :width="width"
  5. :visible="visible"
  6. switchFullscreen
  7. @ok="handleOk"
  8. :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
  9. @cancel="handleCancel"
  10. cancelText="关闭">
  11. <div class="attrPane">
  12. <rm-bulletin-board-form ref="realForm" :lng="this.lng" :lat="this.lat" @ok="submitCallback"
  13. :disabled="disableSubmit" @coordsChange="coordsChange"></rm-bulletin-board-form>
  14. </div>
  15. <div class="geomPane">
  16. <basic-map ref="locMap" height='775px' layersUrl='/resManager.catalog/rescatalog/resList'
  17. :model="{...model,layerName:'公告牌'}"></basic-map>
  18. </div>
  19. </j-modal>
  20. </template>
  21. <script>
  22. import RmBulletinBoardForm from './RmBulletinBoardForm'
  23. import BasicMap from "../../../../../components/BasicMap/BasicMap";
  24. import {transform} from "ol/proj";
  25. import proj4 from "proj4";
  26. import {register} from "ol/proj/proj4";
  27. export default {
  28. name: 'RmBulletinBoardModal',
  29. components: {
  30. BasicMap,
  31. RmBulletinBoardForm
  32. },
  33. data() {
  34. return {
  35. lng: 0,
  36. lat: 0,
  37. title: '',
  38. width: 1200,
  39. visible: false,
  40. disableSubmit: false,
  41. mapHeight: "775px",
  42. model: {}
  43. }
  44. },
  45. beforeCreate() {
  46. proj4.defs("EPSG:4548",
  47. "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs");
  48. proj4.defs("EPSG:4527",
  49. "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=39500000 +y_0=0 +ellps=GRS80 +units=m +no_defs");
  50. proj4.defs("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs");
  51. register(proj4);
  52. },
  53. methods: {
  54. add() {
  55. this.visible = true
  56. this.$nextTick(() => {
  57. this.$refs.realForm.add();
  58. })
  59. },
  60. edit(record) {
  61. this.model = record;
  62. let coord = [record.hzb, record.zzb];
  63. //测绘系统的坐标系与正常坐标系XY轴是反的,横坐标对应纬度
  64. if (record.hzb > 39000000 || record.zzb > 39000000) { //情况1:4527坐标,带带号投影坐标,坐标位数应为前8后7
  65. this.lng = record.hzb > record.zzb ? record.hzb : record.zzb;
  66. this.lat = record.hzb > record.zzb ? record.zzb : record.hzb;
  67. coord = transform([this.lng, this.lat], 'EPSG:4527', 'EPSG:4490');
  68. } else if (record.hzb > 180 || record.zzb > 180) { //情况2:4548坐标,无带号投影坐标,坐标位数应为前6后7
  69. this.lng = record.hzb < record.zzb ? record.hzb : record.zzb
  70. this.lat = record.hzb < record.zzb ? record.zzb : record.hzb
  71. coord = transform([this.lng, this.lat], 'EPSG:4548', 'EPSG:4490');
  72. } else { //情况3:4490坐标,经纬度坐标
  73. this.lng = record.hzb > record.zzb ? record.hzb : record.zzb
  74. this.lat = record.hzb > record.zzb ? record.zzb : record.hzb
  75. coord = [this.lng, this.lat ];
  76. }
  77. this.lng = parseFloat(coord[0].toFixed(6));
  78. this.lat = parseFloat(coord[1].toFixed(6));
  79. this.visible = true;
  80. this.$nextTick(() => {
  81. this.$refs.realForm.edit(record);
  82. })
  83. },
  84. close() {
  85. this.$emit('close');
  86. this.visible = false;
  87. },
  88. handleOk() {
  89. this.$refs.realForm.submitForm();
  90. },
  91. submitCallback() {
  92. this.$emit('ok');
  93. this.visible = false;
  94. },
  95. handleCancel() {
  96. this.close()
  97. },
  98. locateByCoords() {
  99. let loc_x = this.hzb;
  100. let loc_y = this.zzb;
  101. this.$nextTick(() => {
  102. this.$refs.locMap.locateByCoords(loc_x, loc_y);
  103. })
  104. },
  105. locMapReady() {
  106. this.locateByCoords();
  107. },
  108. coordsTranslated(coords) {
  109. this.lng = coords[0].toFixed(6);
  110. this.lat = coords[1].toFixed(6);
  111. },
  112. coordsChange(hzb, zzb) {
  113. let coord = [hzb, zzb];
  114. //测绘系统的坐标系与正常坐标系XY轴是反的,横坐标对应纬度
  115. if (hzb > 39000000 || zzb > 39000000) { //情况1:4527坐标,带带号投影坐标,坐标位数应为前8后7
  116. this.lng = hzb > zzb ? hzb : zzb;
  117. this.lat = hzb > zzb ? zzb : hzb;
  118. coord = transform([this.lng, this.lat], 'EPSG:4527', 'EPSG:4490');
  119. } else if (hzb > 180 || zzb > 180) { //情况2:4548坐标,无带号投影坐标,坐标位数应为前6后7
  120. this.lng = hzb < zzb ? hzb : zzb;
  121. this.lat = hzb < zzb ? zzb : hzb;
  122. coord = transform([this.lng, this.lat], 'EPSG:4548', 'EPSG:4490');
  123. } else { //情况3:4490坐标,经纬度坐标
  124. this.lng = hzb > zzb ? hzb : zzb;
  125. this.lat = hzb > zzb ? zzb : hzb;
  126. coord = [this.lng, this.lat ];u
  127. }
  128. this.lng = parseFloat(coord[0].toFixed(6));
  129. this.lat = parseFloat(coord[1].toFixed(6));
  130. this.$refs.locMap.locateByCoords({...this.model, lng: this.lng, lat: this.lat, geoinfo: ''});
  131. this.edit({...this.model, hzb: hzb, zzb: zzb});
  132. }
  133. }
  134. // beforeMount() {
  135. // if(!this.height){
  136. // let calcHeight = window.document.documentElement.clientHeight - 160;
  137. // let m_height = calcHeight.toString()+'px';
  138. // this.mapHeight = m_height;
  139. // }
  140. // }
  141. }
  142. </script>
  143. <style scoped>
  144. .attrPane {
  145. width: 33%;
  146. display: inline-block;
  147. overflow-y: auto;
  148. height: 775px;
  149. }
  150. .geomPane {
  151. width: 66%;
  152. display: inline-block;
  153. }
  154. </style>