mapTest.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <div id="map_test">
  3. <div class="left">
  4. <el-table
  5. :data="menuListData"
  6. style="width: 100%;margin-bottom: 20px"
  7. :row-key="row => row.id"
  8. :expand-row-keys="keyList"
  9. border
  10. :max-height="maxHeight"
  11. header-cell-class-name = "table_header_class"
  12. :row-class-name="cellStyle"
  13. @row-click ="change"
  14. :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
  15. ref="dataTreeList"
  16. >
  17. <el-table-column
  18. prop="title"
  19. label="目录">
  20. </el-table-column>
  21. </el-table>
  22. </div>
  23. <div class="middle">
  24. <div class="input_part">
  25. <div class="name_part">
  26. <span class="input_name">功能入参:</span>
  27. </div>
  28. <textarea v-model="t_editor" placeholder="在此处输入代码" class="input_text" />
  29. <div class="run_part">
  30. <el-button class="run_method" @click="runMethod">运行</el-button>
  31. </div>
  32. </div>
  33. <div class="output_part">
  34. <div class="name_part">
  35. <span class="input_name">功能出参:</span>
  36. </div>
  37. <textarea v-model="t_result" placeholder="此处显示返回结果" class="input_text" />
  38. </div>
  39. </div>
  40. <div class="right">
  41. <iframe id="i_map" name="i_map" class="full_map" frameborder="0">
  42. </iframe>
  43. </div>
  44. </div>
  45. </template>
  46. <script>
  47. import CityGIS from "@/units/CityGis.Bridge";
  48. import menuList from "../config/basicTool.json";
  49. import {getToken} from "@/service/Token";
  50. export default {
  51. name: "mapTest",
  52. data(){
  53. return {
  54. bridge:"",
  55. t_editor:"",
  56. t_result:"",
  57. current_url:null,
  58. maxHeight:0,
  59. menuListData: [],
  60. mapMethod:'',
  61. keyList:[]
  62. }
  63. },
  64. mounted() {
  65. this.menuListData = menuList;
  66. if(this.$route.query.mapMethod){
  67. this.mapMethod = this.$route.query.mapMethod;
  68. this.autoChange(this.mapMethod)
  69. }
  70. this.$nextTick(() => {
  71. // window.innerHeight 浏览器窗口的可见高度,下面的 200 是除了table最大高度的剩余空间。
  72. this.maxHeight = window.innerHeight -20;
  73. })
  74. //加载地图插件
  75. this.bridge = new CityGIS.Bridge({
  76. id:"i_map",
  77. //url:'http://localhost:8081/#/jk_map?theme=light&type=3D',
  78. url:'https://cimnet.zjw.sh.gov.cn:2008/VUE-Map-Tool-Widget/#/jk_map?theme=light&type=3D',
  79. onReady:function (){
  80. // console.log("地图创建完成");
  81. }
  82. });
  83. this.bridge.addEventListener((arg) =>{
  84. switch (arg.action){
  85. case "MapIsReady":
  86. this.t_result = JSON.stringify(arg.data,null,4);
  87. break;
  88. case "LayerIsReady":
  89. this.t_result = JSON.stringify(arg.data,null,4);
  90. break;
  91. case "MapExtentChanged":
  92. this.t_result = JSON.stringify(arg.data, null, 4);
  93. break;
  94. case "MapClickResult":
  95. this.t_result = JSON.stringify(arg.data, null, 4);
  96. break;
  97. case "MapMoveResult":
  98. this.t_result = JSON.stringify(arg.data, null, 4);
  99. break;
  100. case "DrawComplete":
  101. this.t_result = JSON.stringify(arg.data, null, 4);
  102. break;
  103. case "Calculation":
  104. this.t_result = JSON.stringify(arg.data, null, 4);
  105. break;
  106. case "ReturnResult":
  107. this.t_result = JSON.stringify(arg.data, null, 4);
  108. break;
  109. case "PopupClickResult":
  110. this.t_result = JSON.stringify(arg.data, null, 4);
  111. break;
  112. }
  113. })
  114. },
  115. methods:{
  116. autoChange(id){
  117. for(let i=0;i<this.menuListData.length;i++){
  118. if(id==this.menuListData[i].id){
  119. this.change(this.menuListData[i])
  120. break;
  121. }else if(this.menuListData[i].children && this.menuListData[i].children.length >0){
  122. for(let j=0;j<this.menuListData[i].children.length;j++){
  123. if(id==this.menuListData[i].children[j].id){
  124. this.change(this.menuListData[i].children[j]);
  125. this.keyList.push(this.menuListData[i].id);
  126. break;
  127. }
  128. }
  129. }
  130. }
  131. },
  132. cellStyle(row){
  133. if(row.row.id.length == 4){ //一级目录
  134. if(row.row.chosen){
  135. return "row_bg_chosen"
  136. }else{
  137. return "row_bg"
  138. }
  139. }else{
  140. if(row.row.chosen){
  141. return "row_second_bg_chosen"
  142. }else{
  143. return "row_second_bg"
  144. }
  145. }
  146. },
  147. change(item){
  148. for(let i=0;i<this.menuListData.length;i++){
  149. if(this.menuListData[i].children){
  150. for(let j=0;j<this.menuListData[i].children.length;j++){
  151. if(item.id==this.menuListData[i].children[j].id){
  152. this.menuListData[i].children[j].chosen = true
  153. }else{
  154. this.menuListData[i].children[j].chosen = false
  155. }
  156. }
  157. }else{
  158. if(item.id==this.menuListData[i].id){
  159. this.menuListData[i].chosen = true
  160. }else{
  161. this.menuListData[i].chosen = false
  162. }
  163. }
  164. }
  165. let params = JSON.stringify(item.data, null, 4);
  166. params = JSON.parse(params);
  167. if(params.Parameters !== undefined && params.Parameters.url !== undefined){
  168. this.current_url = params.Parameters.url;
  169. params.Parameters.url = "***";
  170. }else{
  171. this.current_url = null;
  172. }
  173. params = JSON.stringify(params, null, 4);
  174. this.t_editor = params;
  175. },
  176. runMethod(){
  177. let params = JSON.parse(this.t_editor);
  178. if(this.current_url !== null){
  179. if(params.Parameters.url == "***"){
  180. params.Parameters.url =this.current_url;
  181. }
  182. }
  183. getToken().then(res =>{
  184. let token = res.msg[0].Rows[0].token;
  185. params.Parameters.token = token;
  186. this.bridge.Invoke(params);
  187. })
  188. // this.bridge.Invoke(params);
  189. }
  190. }
  191. }
  192. </script>
  193. <style scoped lang="scss">
  194. ::v-deep{
  195. .table_header_class{
  196. font-size: 18px ;
  197. font-family: Microsoft YaHei;
  198. font-weight: 400;
  199. color: #3F3F3F;
  200. height: 48px ;
  201. border-color:#BFDFFF;
  202. }
  203. .el-table .cell{
  204. line-height:23px ;
  205. }
  206. .el-table .el-table__cell{
  207. padding: 12px 1px;
  208. }
  209. .el-table .row_bg{
  210. font-family: Microsoft YaHei;
  211. font-weight: bold;
  212. font-size: 18px;
  213. color: #1388fc;
  214. height: 48px ;
  215. border-color:#BFDFFF;
  216. }
  217. .el-table .row_bg_chosen{
  218. font-family: Microsoft YaHei;
  219. font-weight: bold;
  220. font-size: 18px;
  221. color: #d0a528;
  222. height: 48px ;
  223. border-color:#BFDFFF;
  224. }
  225. .el-table .el-table__expand-icon{
  226. float: right;
  227. font-size: 18px ;
  228. font-weight: 400;
  229. color: #1388fc;
  230. }
  231. .el-table .row_second_bg{
  232. font-family: Microsoft YaHei;
  233. font-weight: bold;
  234. font-size: 16px ;
  235. color: #4184c7;
  236. height: 30px ;
  237. border-color:#BFDFFF;
  238. }
  239. .el-table .row_second_bg_chosen{
  240. font-family: Microsoft YaHei;
  241. font-weight: bold;
  242. font-size: 16px ;
  243. color: #d0a528;
  244. height: 30px ;
  245. border-color:#BFDFFF;
  246. }
  247. .el-button{
  248. padding: 12px 20px ;
  249. }
  250. // 滚动条的宽度
  251. .el-table__body-wrapper::-webkit-scrollbar {
  252. width: 16px; // 横向滚动条
  253. height: 16px; // 纵向滚动条 必写
  254. }
  255. // 滚动条的滑块
  256. .el-table__body-wrapper::-webkit-scrollbar-thumb {
  257. background-color: #BFDFFF;
  258. border-radius: 3px;
  259. }
  260. .el-table .el-table__body-wrapper::-webkit-scrollbar-track{
  261. background: #f5f1f1;
  262. }
  263. .el-table--border .el-table__cell, .el-table__body-wrapper .el-table--border.is-scrolling-left~.el-table__fixed{
  264. border-right: none;
  265. }
  266. }
  267. #map_test{
  268. width: 100%;
  269. height: 100%;
  270. display: flex;
  271. flex-direction: row;
  272. .left{
  273. width: 12%;
  274. height: 100%;
  275. border-right:1px solid #BFDFFF;
  276. }
  277. .middle{
  278. width: 22%;
  279. height: 100%;
  280. display: flex;
  281. flex-direction: column;
  282. justify-content: space-around;
  283. .input_part{
  284. width: 100%;
  285. height: 50%;
  286. display: flex;
  287. flex-direction: column;
  288. align-items: center;
  289. justify-content: space-evenly;
  290. .name_part{
  291. width: 100%;
  292. display: flex;
  293. .input_name{
  294. margin: 1% 2%;
  295. font-size: 16px ;
  296. font-family: Microsoft YaHei;
  297. font-weight: bold;
  298. color: #4C4C4C;
  299. }
  300. }
  301. .input_text{
  302. margin-left: 2%;
  303. margin-right: 2%;
  304. background: #F7FBFF;
  305. border: 1px solid #BFDFFF;
  306. width: 96%;
  307. height: 80%;
  308. font-size: 16px ;
  309. }
  310. .run_part{
  311. width: 100%;
  312. .run_method{
  313. float: right;
  314. margin:4px 10px;
  315. background: #4CA6FF;
  316. font-size: 16px ;
  317. font-family: Microsoft YaHei;
  318. font-weight: bold;
  319. color: #FFFFFF;
  320. }
  321. }
  322. }
  323. .output_part{
  324. width: 100%;
  325. height: 50%;
  326. display: flex;
  327. flex-direction: column;
  328. align-items: center;
  329. justify-content: space-evenly;
  330. .name_part{
  331. width: 100%;
  332. display: flex;
  333. .input_name{
  334. margin: 1% 2%;
  335. font-size: 16px ;
  336. font-family: Microsoft YaHei;
  337. font-weight: bold;
  338. color: #4C4C4C;
  339. }
  340. }
  341. .input_text{
  342. margin-left: 2%;
  343. margin-right: 2%;
  344. background: #F7FBFF;
  345. border: 1px solid #BFDFFF;
  346. width: 96%;
  347. height: 80%;
  348. font-size: 16px;
  349. }
  350. }
  351. }
  352. .right{
  353. width: 68%;
  354. height: 100%;
  355. .full_map{
  356. width: 100%;
  357. height: 100%;
  358. }
  359. }
  360. }
  361. </style>