网站
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

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