网站
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

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