网站
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

377 wiersze
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. homesteadLayer: '', // 宅基地图层
  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+'land_status', {}, 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. // module.data.useType = content;
  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. addHomesteadLayer(content);
  79. // $('#page_s1').html('共' + 10 + '页')
  80. var propertyData = template('propertyData', module.data);
  81. $("#propertyContent").html(propertyData);
  82. }
  83. }
  84. // 添加宅基地图层
  85. addHomesteadLayer = function (content) {
  86. if (module.data.homesteadLayer) {
  87. module.data.map.removeLayer(module.data.homesteadLayer);
  88. module.data.homesteadLayer = '';
  89. }
  90. let features = [];
  91. content.forEach(item => {
  92. if (item.theGeomJson != null && item.theGeomJson !== '') {
  93. const iconFeature = new ol.Feature({
  94. geometry: new ol.geom.MultiPolygon(JSON.parse(item.theGeomJson).coordinates),
  95. // name: item.centerName,
  96. // centerDeptId: item.deptId,
  97. level: 'homestead',
  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.homesteadLayer = new ol.layer.Vector({
  107. source: vectorSource,
  108. name: 'homesteadLayer',
  109. style: new ol.style.Style({
  110. fill: new ol.style.Fill({
  111. //矢量图层填充颜色,以及透明度
  112. color: "rgba(22, 233, 15, 0.3)",
  113. }),
  114. stroke: new ol.style.Stroke({
  115. //边界样式
  116. color: "#16E90F",
  117. width: 2,
  118. }),
  119. })
  120. });
  121. module.data.map.getLayers().insertAt(3, module.data.homesteadLayer);
  122. }
  123. openDialog = function(id){
  124. tools.doGet(zjdzdxxGet+id, {translate_dict: 1}, module.assetDetail , true);
  125. }
  126. closeDialog = function(id){
  127. $('#dialog').css('display','none');
  128. }
  129. module.assetDetail = function(data){
  130. if (data.code == 200) {
  131. var content = data.data;
  132. module.data.propertyDetail = content;
  133. tools.doGet(attachmentList, {
  134. tableId:content.id,
  135. tableName: 't_homestead_zjdzdxx',
  136. bizPath: 'home'
  137. }, module.attachmentDetail , true);
  138. // var propertyDetailData = template('propertyDetailData', module.data);
  139. // $("#propertyDetailContent").html(propertyDetailData);
  140. // $('#dialog').css('display','block');
  141. }
  142. }
  143. module.attachmentDetail = function(data){
  144. if (data.code == 200) {
  145. var content = data.rows;
  146. var attachmentList = [];
  147. content.map(res=>{
  148. if (res.fileName.indexOf('png')>-1||res.fileName.indexOf('jpg')>-1){
  149. attachmentList.push(res);
  150. }
  151. })
  152. module.data.attachment = attachmentList;
  153. var propertyDetailData = template('propertyDetailData', module.data);
  154. $("#propertyDetailContent").html(propertyDetailData);
  155. $('#dialog').css('display','block');
  156. }
  157. }
  158. module.treeselect = function(data){
  159. if (data.code == 200) {
  160. var content = data.data[0].children;
  161. content.map(res=>{
  162. module.data.treeselect.push(res)
  163. })
  164. module.data.treeselectA = data.data[0];
  165. // module.data.treeselect = content[0].children;
  166. var treeselectData = template('treeselectData', module.data);
  167. $("#treeselectContent").html(treeselectData);
  168. var treeselectSecondData = template('treeselectSecondData', module.data);
  169. $("#treeselectSecondContent").html(treeselectSecondData);
  170. initMap(data.data[0]);
  171. //资产列表
  172. tools.doGet(zjdzdxxList, {
  173. deptId: 100,
  174. translate_dict: 1,
  175. houseOwnership:1,
  176. pageNum: 1,
  177. pageSize: 10,
  178. }, module.assetList , true);
  179. tools.doGet(treeselectSecond+'100', {}, module.useContent, true);
  180. }
  181. }
  182. initMap = function (dept) {
  183. let mapCenterLocation;
  184. if (dept.lng && dept.lat) {
  185. mapCenterLocation = [dept.lng, dept.lat];
  186. } else {
  187. mapCenterLocation = [116.391461, 39.902359];
  188. }
  189. document.getElementById("container").innerHTML = "";
  190. // 定义地图投影
  191. let projection = new ol.proj.Projection({
  192. code: "EPSG:3857",
  193. units: "degrees",
  194. });
  195. // 定义地图图层
  196. let aerial = new ol.layer.Tile({
  197. source: new ol.source.XYZ({
  198. url: "http://t{0-7}.tianditu.com/img_w/wmts?" +
  199. "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
  200. "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=cc4aba6e967096098249efa069733067",
  201. }),
  202. isGroup: true,
  203. name: "卫星影像图",
  204. });
  205. let yingxzi = new ol.layer.Tile({
  206. source: new ol.source.XYZ({
  207. url: "http://t{0-7}.tianditu.com/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=cc4aba6e967096098249efa069733067",
  208. }),
  209. isGroup: true,
  210. name: "天地图文字标注--卫星影像图",
  211. });
  212. //加载地图
  213. module.data.map = new ol.Map({
  214. controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([]),
  215. layers: [aerial, yingxzi],
  216. projection: projection,
  217. target: "container",
  218. view: new ol.View({
  219. center: ol.proj.fromLonLat(mapCenterLocation), // 地图中心坐标
  220. zoom: 13,
  221. minZoom: 1, //地图缩小限制
  222. maxZoom: 18, //地图放大限制
  223. // extent: [13481224.75161,5667110.83528,13811063.06278,5880284.11416]
  224. }),
  225. /*interactions: ol.interaction.defaults({
  226. doubleClickZoom: false, // 双击放大地图
  227. // mouseWheelZoom: false, // 鼠标滚轮放大地图
  228. // shiftDragZoom: false, // shift + 鼠标左键拖拽 放大地图
  229. })*/
  230. });
  231. // 地图点击事件
  232. module.data.map.on("click", (evt) => {
  233. let feature = module.data.map.forEachFeatureAtPixel(
  234. evt.pixel,
  235. (feature) => feature
  236. );
  237. if (feature) {
  238. if (feature.get('level') === 'homestead') {
  239. openDialog(feature.get('id'));
  240. }
  241. }
  242. });
  243. // 鼠标指针移动到指定的feature上,改变鼠标指针的样式为 pointer(小手)
  244. module.data.map.on('pointermove', (evt) => {
  245. if (evt.dragging) {
  246. return ;
  247. }
  248. const pixel = module.data.map.getEventPixel(evt.originalEvent);
  249. // const hit = module.data.map.hasFeatureAtPixel(pixel);
  250. // let features = module.data.map.getFeaturesAtPixel(pixel);
  251. const hit = module.data.map.forEachFeatureAtPixel(pixel, function (feature) {
  252. if (feature && feature.get('level') === 'homestead') {
  253. return true;
  254. }
  255. });
  256. module.data.map.getTargetElement().style.cursor = hit ? 'pointer' : '';
  257. });
  258. }
  259. selectChange = function(){
  260. // tools.doGet(treeselectSecond+$('#treeselectContent').val(), {}, module.selectSecondChange , true);
  261. if ($('#treeselectContent').val() == 100){
  262. module.data.treeselectSecond = [{
  263. value:100,
  264. label:'全部'
  265. }];
  266. tools.doGet(treeselectSecond+'100', {}, module.useContent , true);
  267. }else{
  268. module.data.treeselectSecond = module.data.treeselect.filter(function (e) { return e.value == $('#treeselectContent').val(); })[0].children;
  269. tools.doGet(treeselectSecond+$('#treeselectContent').val(), {}, module.useContent , true);
  270. }
  271. var treeselectSecondData = template('treeselectSecondData', module.data);
  272. $("#treeselectSecondContent").html(treeselectSecondData);
  273. selectSecondChange();
  274. }
  275. selectSecondChange = function(){
  276. $('.page_s1').html('');
  277. module.data.propertyList = "";
  278. tools.doGet(zjdzdxxList, {
  279. deptId: $('#treeselectSecondContent').val(),
  280. translate_dict: 1,
  281. houseOwnership:1,
  282. pageNum: 1,
  283. pageSize: 10,
  284. }, module.assetList , true);
  285. tools.doGet(treeselectSecond+$('#treeselectSecondContent').val(), {}, module.useContent , true);
  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. }
  298. useTypeChange = function () {
  299. $('.page_s1').html('');
  300. module.data.propertyList = "";
  301. tools.doGet(zjdzdxxList, {
  302. deptId: $('#treeselectSecondContent').val() == null ? 100 : $('#treeselectSecondContent').val(),
  303. translate_dict: 1,
  304. houseOwnership:1,
  305. landStatus:$('#useTypeContent').val(),
  306. pageNum: 1,
  307. pageSize: 10,
  308. }, module.assetList , true);
  309. // $('#useTypeContent').val(),
  310. }
  311. turnThePage = function (pageNum) {
  312. tools.doGet(zjdzdxxList, {
  313. deptId: $('#treeselectSecondContent').val() == null ? 100 : $('#treeselectSecondContent').val(),
  314. translate_dict: 1,
  315. pageNum: pageNum,
  316. pageSize: 10,
  317. }, module.assetList , true);
  318. }
  319. openBig = function () {
  320. $("#open").css('display','none');
  321. $(".table_main").css('display','none');
  322. $(".pageNum").css('display','none');
  323. $("#close").css('display','block');
  324. $("#map_main").css({
  325. 'height': '59vh',
  326. 'position': 'absolute',
  327. 'top': '1vh',
  328. 'width': 'calc(100% - 2vh)',
  329. })
  330. $("#container").css('height','59vh')
  331. initMap(module.data.treeselectA);
  332. // 添加资源图层
  333. addHomesteadLayer(module.data.propertyList);
  334. }
  335. closeBig = function () {
  336. $("#open").css('display','block');
  337. $(".table_main").css('display','block');
  338. $(".pageNum").css('display','block');
  339. $("#close").css('display','none');
  340. $("#map_main").css({
  341. 'height': '16vh',
  342. 'position': 'relative',
  343. 'width': '100%',
  344. 'top': '0vh',
  345. })
  346. $("#container").css('height','16vh')
  347. initMap(module.data.treeselectA);
  348. // 添加资源图层
  349. addHomesteadLayer(module.data.propertyList);
  350. }
  351. return module;
  352. });