网站
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

377 satır
14 KiB

  1. /**
  2. * Created by Administrator on 2021/4/5.
  3. */
  4. define(['jquery', "template", "Tools", "paging", 'dateTime', 'swiper'], function ($, template, Tools) {
  5. //数据存储
  6. var module = {
  7. data: {
  8. propertyList:'',
  9. treeselect:[{
  10. value:100,
  11. label:'全部'
  12. }],
  13. treeselectSecond:[{
  14. value:100,
  15. label:'全部'
  16. }],
  17. useType:[{
  18. dictValue:'',
  19. dictLabel:'全部'
  20. }],
  21. propertyDetail:{},
  22. map: '', // 地图图层
  23. permanentLayer: '', // 资产图层
  24. },
  25. };
  26. var tools = new Tools();
  27. module.init = function (page) {
  28. tools.doGet(treeselect, {}, module.treeselect , true);
  29. tools.doGet(webList, {}, module.webList , true);
  30. // tools.doGet(webDeptType+'use_type', {}, module.webDeptType , true);
  31. };
  32. module.useContent = function (data) {
  33. if (data.code == 200) {
  34. module.data.phone = data.data.phone;
  35. module.data.leader = data.data.leader;
  36. var propertyDetailData = template('propertyDetailData', module.data);
  37. $("#propertyDetailContent").html(propertyDetailData);
  38. module.data.map.getView().setCenter(ol.proj.fromLonLat([data.data.lng, data.data.lat]));
  39. module.data.map.getView().setZoom(13);
  40. }
  41. }
  42. module.webDeptType = function (data) {
  43. if (data.code == 200) {
  44. var content = data.data;
  45. content.map(res=>{
  46. module.data.useType.push(res)
  47. })
  48. var useTypeData = template('useTypeData', module.data);
  49. $("#useTypeContent").html(useTypeData);
  50. }
  51. }
  52. module.webList = function (data) {
  53. if (data.code == 200) {
  54. var content = data.data;
  55. module.data.webList = content;
  56. var webData = template('webData', module.data);
  57. $("#webContent").html(webData);
  58. var titData = template('titData', module.data);
  59. $("#titContent").html(titData);
  60. }
  61. }
  62. module.assetList = function (data) {
  63. if (data.code == 200) {
  64. var content = data.rows;
  65. if (module.data.propertyList == '') {
  66. var page_s1 = createPage('.page_s1');
  67. //设置分页
  68. setPage(page_s1, {
  69. pageTotal: data.total, // 数据总条数
  70. pageSize: 10, // 每页显示条数
  71. pageCurrent: 1, // 当前页
  72. maxBtnNum: 5, // 最多按钮个数 (最少5个)
  73. })
  74. }
  75. module.data.propertyList = content;
  76. // 添加资产图层
  77. addPermanentLayer(content);
  78. // $('#page_s1').html('共' + 10 + '页')
  79. var propertyData = template('propertyData', module.data);
  80. $("#propertyContent").html(propertyData);
  81. }
  82. }
  83. // 添加资产图层
  84. addPermanentLayer = function (content) {
  85. if (module.data.permanentLayer) {
  86. module.data.map.removeLayer(module.data.permanentLayer);
  87. module.data.permanentLayer = '';
  88. }
  89. let features = [];
  90. content.forEach(item => {
  91. if (item.theGeom != null && item.theGeom !== '') {
  92. const iconFeature = new ol.Feature({
  93. geometry: new ol.geom.Point(JSON.parse(item.theGeom).coordinates),
  94. // name: item.centerName,
  95. // centerDeptId: item.deptId,
  96. level: 'permanent',
  97. id: item.id
  98. });
  99. features.push(iconFeature);
  100. }
  101. });
  102. const vectorSource = new ol.source.Vector({
  103. features: features,
  104. });
  105. module.data.permanentLayer = new ol.layer.Vector({
  106. source: vectorSource,
  107. name: 'permanentLayer',
  108. style: new ol.style.Style({
  109. image: new ol.style.Icon({
  110. //设置图标偏移
  111. anchor: [0.5, 1],
  112. //标注样式的起点位置
  113. anchorOrigin: "top-right",
  114. //X方向单位:分数
  115. anchorXUnits: "fraction",
  116. //Y方向单位:像素
  117. anchorYUnits: "pixels",
  118. //偏移起点位置的方向
  119. offsetOrigin: "top-right",
  120. //透明度
  121. opacity: 0.9,
  122. //图片路径
  123. src: '/infoport/static/images/zc_icon.png',
  124. }),
  125. })
  126. });
  127. module.data.map.getLayers().insertAt(3, module.data.permanentLayer);
  128. }
  129. openDialog = function(id){
  130. tools.doGet(assetGet+id, {translate_dict: 1}, module.assetDetail , true);
  131. }
  132. closeDialog = function(id){
  133. $('#dialog').css('display','none');
  134. }
  135. module.assetDetail = function(data){
  136. if (data.code == 200) {
  137. var content = data.data;
  138. module.data.propertyDetail = content;
  139. tools.doGet(attachmentList, {
  140. tableId:content.id,
  141. tableName: 't_asset_permanent',
  142. bizPath: 'asset'
  143. }, module.attachmentDetail , true);
  144. // var propertyDetailData = template('propertyDetailData', module.data);
  145. // $("#propertyDetailContent").html(propertyDetailData);
  146. // $('#dialog').css('display','block');
  147. }
  148. }
  149. module.attachmentDetail = function(data){
  150. if (data.code == 200) {
  151. var content = data.rows;
  152. var attachmentList = [];
  153. content.map(res=>{
  154. if (res.fileName.indexOf('png')>-1||res.fileName.indexOf('jpg')>-1){
  155. attachmentList.push(res);
  156. }
  157. })
  158. module.data.attachment = attachmentList;
  159. var propertyDetailData = template('propertyDetailData', module.data);
  160. $("#propertyDetailContent").html(propertyDetailData);
  161. $('#dialog').css('display','block');
  162. }
  163. }
  164. module.treeselect = function(data){
  165. if (data.code == 200) {
  166. var content = data.data[0].children;
  167. content.map(res=>{
  168. module.data.treeselect.push(res)
  169. })
  170. module.data.treeselectA = data.data[0];
  171. var treeselectData = template('treeselectData', module.data);
  172. $("#treeselectContent").html(treeselectData);
  173. var treeselectSecondData = template('treeselectSecondData', module.data);
  174. $("#treeselectSecondContent").html(treeselectSecondData);
  175. initMap(data.data[0]);
  176. //资产列表
  177. tools.doGet(assetList, {
  178. deptId: 100,
  179. useType: '',
  180. operationType: 1,
  181. translate_dict: 1,
  182. pageNum: 1,
  183. pageSize: 10,
  184. orderByColumn: 'code',
  185. isAsc: 'asc',
  186. }, module.assetList , true);
  187. tools.doGet(treeselectSecond+'100', {}, module.useContent , true);
  188. }
  189. }
  190. initMap = function (dept) {
  191. let mapCenterLocation;
  192. if (dept.lng && dept.lat) {
  193. mapCenterLocation = [dept.lng, dept.lat];
  194. } else {
  195. mapCenterLocation = [116.391461, 39.902359];
  196. }
  197. document.getElementById("container").innerHTML = "";
  198. // 定义地图投影
  199. let projection = new ol.proj.Projection({
  200. code: "EPSG:3857",
  201. units: "degrees",
  202. });
  203. // 定义地图图层
  204. let aerial = new ol.layer.Tile({
  205. source: new ol.source.XYZ({
  206. url: "http://t{0-7}.tianditu.com/img_w/wmts?" +
  207. "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
  208. "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=cc4aba6e967096098249efa069733067",
  209. }),
  210. isGroup: true,
  211. name: "卫星影像图",
  212. });
  213. let yingxzi = new ol.layer.Tile({
  214. source: new ol.source.XYZ({
  215. url: "http://t{0-7}.tianditu.com/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=cc4aba6e967096098249efa069733067",
  216. }),
  217. isGroup: true,
  218. name: "天地图文字标注--卫星影像图",
  219. });
  220. //加载地图
  221. module.data.map = new ol.Map({
  222. controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]),
  223. layers: [aerial, yingxzi],
  224. projection: projection,
  225. target: "container",
  226. view: new ol.View({
  227. center: ol.proj.fromLonLat(mapCenterLocation), // 地图中心坐标
  228. zoom: 13,
  229. minZoom: 1, //地图缩小限制
  230. maxZoom: 18, //地图放大限制
  231. // extent: [13481224.75161,5667110.83528,13811063.06278,5880284.11416]
  232. }),
  233. /*interactions: ol.interaction.defaults({
  234. doubleClickZoom: false, // 双击放大地图
  235. // mouseWheelZoom: false, // 鼠标滚轮放大地图
  236. // shiftDragZoom: false, // shift + 鼠标左键拖拽 放大地图
  237. })*/
  238. });
  239. // 地图点击事件
  240. module.data.map.on("click", (evt) => {
  241. let feature = module.data.map.forEachFeatureAtPixel(
  242. evt.pixel,
  243. (feature) => feature
  244. );
  245. if (feature) {
  246. if (feature.get('level') === 'permanent') {
  247. openDialog(feature.get('id'));
  248. }
  249. }
  250. });
  251. // 鼠标指针移动到指定的feature上,改变鼠标指针的样式为 pointer(小手)
  252. module.data.map.on('pointermove', (evt) => {
  253. if (evt.dragging) {
  254. return ;
  255. }
  256. const pixel = module.data.map.getEventPixel(evt.originalEvent);
  257. // const hit = module.data.map.hasFeatureAtPixel(pixel);
  258. // let features = module.data.map.getFeaturesAtPixel(pixel);
  259. const hit = module.data.map.forEachFeatureAtPixel(pixel, function (feature) {
  260. if (feature && feature.get('level') === 'permanent') {
  261. return true;
  262. }
  263. });
  264. module.data.map.getTargetElement().style.cursor = hit ? 'pointer' : '';
  265. });
  266. }
  267. selectChange = function(){
  268. // tools.doGet(treeselectSecond+$('#treeselectContent').val(), {}, module.selectSecondChange , true);
  269. if ($('#treeselectContent').val() == 100){
  270. module.data.treeselectSecond = [{
  271. value:100,
  272. label:'全部'
  273. }]
  274. tools.doGet(treeselectSecond+'100', {}, module.useContent , true);
  275. }else{
  276. module.data.treeselectSecond = module.data.treeselect.filter(function (e) { return e.value == $('#treeselectContent').val(); })[0].children;
  277. tools.doGet(treeselectSecond+$('#treeselectContent').val(), {}, module.useContent , true);
  278. }
  279. var treeselectSecondData = template('treeselectSecondData', module.data);
  280. $("#treeselectSecondContent").html(treeselectSecondData);
  281. selectSecondChange();
  282. }
  283. selectSecondChange = function(){
  284. $('.page_s1').html('');
  285. module.data.propertyList = "";
  286. //资产列表
  287. tools.doGet(assetList, {
  288. deptId: $('#treeselectSecondContent').val(),
  289. useType: $('#useTypeContent').val() == null ? 1 : $('#useTypeContent').val(),
  290. operationType: 1,
  291. translate_dict: 1,
  292. pageNum: 1,
  293. pageSize: 10,
  294. orderByColumn: 'code',
  295. isAsc: 'asc',
  296. }, module.assetList , true);
  297. tools.doGet(treeselectSecond+$('#treeselectSecondContent').val(), {}, module.useContent , true);
  298. }
  299. useTypeChange = function () {
  300. $('.page_s1').html('');
  301. module.data.propertyList = "";
  302. tools.doGet(assetList, {
  303. deptId: $('#treeselectSecondContent').val() == null ? 100 : $('#treeselectSecondContent').val(),
  304. useType: $('#useTypeContent').val(),
  305. operationType: 1,
  306. translate_dict: 1,
  307. pageNum: 1,
  308. pageSize: 10,
  309. }, module.assetList , true);
  310. }
  311. turnThePage = function (pageNum) {
  312. tools.doGet(assetList, {
  313. deptId: $('#treeselectSecondContent').val() == null ? 100 : $('#treeselectSecondContent').val(),
  314. useType: $('#useTypeContent').val() == null ? 1 : $('#useTypeContent').val(),
  315. operationType: 1,
  316. translate_dict: 1,
  317. pageNum: pageNum,
  318. pageSize: 10,
  319. }, module.assetList , true);
  320. }
  321. openBig = function (pageNum) {
  322. $("#open").css('display','none');
  323. $(".table_main").css('display','none');
  324. $(".pageNum").css('display','none');
  325. $("#close").css('display','block');
  326. $("#map_main").css({
  327. 'height': '59vh',
  328. 'position': 'absolute',
  329. 'top': '1vh',
  330. 'width': 'calc(100% - 2vh)',
  331. })
  332. $("#container").css('height','59vh')
  333. initMap(module.data.treeselectA);
  334. // 添加资产图层
  335. addPermanentLayer(module.data.propertyList);
  336. }
  337. closeBig = function (pageNum) {
  338. $("#open").css('display','block');
  339. $(".table_main").css('display','block');
  340. $(".pageNum").css('display','block');
  341. $("#close").css('display','none');
  342. $("#map_main").css({
  343. 'height': '16vh',
  344. 'position': 'relative',
  345. 'width': '100%',
  346. 'top': '0vh',
  347. })
  348. $("#container").css('height','16vh')
  349. initMap(module.data.treeselectA);
  350. // 添加资产图层
  351. addPermanentLayer(module.data.propertyList);
  352. }
  353. return module;
  354. });