网站
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

resource.js 14 KiB

2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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. resourceLayer: '', // 资源图层
  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_code', {}, 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. // module.data.useType = content;
  50. var useTypeData = template('useTypeData', module.data);
  51. $("#useTypeContent").html(useTypeData);
  52. }
  53. }
  54. module.webList = function (data) {
  55. if (data.code == 200) {
  56. var content = data.data;
  57. module.data.webList = content;
  58. var webData = template('webData', module.data);
  59. $("#webContent").html(webData);
  60. var titData = template('titData', module.data);
  61. $("#titContent").html(titData);
  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. addResourceLayer(content);
  80. // $('#page_s1').html('共' + 10 + '页')
  81. var propertyData = template('propertyData', module.data);
  82. $("#propertyContent").html(propertyData);
  83. }
  84. }
  85. // 添加资源图层
  86. addResourceLayer = function (content) {
  87. if (module.data.resourceLayer) {
  88. module.data.map.removeLayer(module.data.resourceLayer);
  89. module.data.resourceLayer = '';
  90. }
  91. let features = [];
  92. content.forEach(item => {
  93. if (item.theGeomJson != null && item.theGeomJson !== '') {
  94. const iconFeature = new ol.Feature({
  95. geometry: new ol.geom.MultiPolygon(JSON.parse(item.theGeomJson).coordinates),
  96. // name: item.centerName,
  97. // centerDeptId: item.deptId,
  98. level: 'resource',
  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.resourceLayer = new ol.layer.Vector({
  108. source: vectorSource,
  109. name: 'resourceLayer',
  110. style: new ol.style.Style({
  111. fill: new ol.style.Fill({
  112. //矢量图层填充颜色,以及透明度
  113. color: "rgba(255, 255, 0, 0.3)",
  114. }),
  115. stroke: new ol.style.Stroke({
  116. //边界样式
  117. color: "#ffff00",
  118. width: 2,
  119. }),
  120. })
  121. });
  122. module.data.map.getLayers().insertAt(3, module.data.resourceLayer);
  123. }
  124. openDialog = function(id){
  125. tools.doGet(resourceGet+id, {translate_dict: 1}, module.assetDetail , true);
  126. }
  127. closeDialog = function(id){
  128. $('#dialog').css('display','none');
  129. }
  130. module.assetDetail = function(data){
  131. if (data.code == 200) {
  132. var content = data.data;
  133. module.data.propertyDetail = content;
  134. tools.doGet(attachmentList, {
  135. tableId:content.id,
  136. tableName: 't_asset_resource',
  137. bizPath: 'asset'
  138. }, module.attachmentDetail , true);
  139. // var propertyDetailData = template('propertyDetailData', module.data);
  140. // $("#propertyDetailContent").html(propertyDetailData);
  141. // $('#dialog').css('display','block');
  142. }
  143. }
  144. module.attachmentDetail = function(data){
  145. if (data.code == 200) {
  146. var content = data.rows;
  147. var attachmentList = [];
  148. content.map(res=>{
  149. if (res.fileName.indexOf('png')>-1||res.fileName.indexOf('jpg')>-1){
  150. attachmentList.push(res);
  151. }
  152. })
  153. module.data.attachment = attachmentList;
  154. var propertyDetailData = template('propertyDetailData', module.data);
  155. $("#propertyDetailContent").html(propertyDetailData);
  156. $('#dialog').css('display','block');
  157. }
  158. }
  159. module.treeselect = function(data){
  160. if (data.code == 200) {
  161. var content = data.data[0].children;
  162. content.map(res=>{
  163. module.data.treeselect.push(res)
  164. })
  165. // module.data.treeselect = content[0].children;
  166. // module.data.treeselectA = data.data[0];
  167. var treeselectData = template('treeselectData', module.data);
  168. $("#treeselectContent").html(treeselectData);
  169. var treeselectSecondData = template('treeselectSecondData', module.data);
  170. $("#treeselectSecondContent").html(treeselectSecondData);
  171. initMap(data.data[0]);
  172. //资产列表
  173. tools.doGet(resourceList, {
  174. deptId: 100,
  175. translate_dict: 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') === 'resource') {
  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') === 'resource') {
  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(resourceList, {
  279. deptId: $('#treeselectSecondContent').val(),
  280. translate_dict: 1,
  281. pageNum: 1,
  282. pageSize: 10,
  283. }, module.assetList , true);
  284. tools.doGet(treeselectSecond+$('#treeselectSecondContent').val(), {}, module.useContent , true);
  285. //资产列表
  286. // tools.doGet(assetList, {
  287. // deptId: $('#treeselectSecondContent').val(),
  288. // useType: $('#useTypeContent').val() == null ? 1 : $('#useTypeContent').val(),
  289. // operationType: 1,
  290. // translate_dict: 1,
  291. // pageNum: 1,
  292. // pageSize: 10,
  293. // orderByColumn: 'code',
  294. // isAsc: 'asc',
  295. // }, module.assetList , true);
  296. }
  297. useTypeChange = function () {
  298. $('.page_s1').html('');
  299. module.data.propertyList = "";
  300. tools.doGet(resourceList, {
  301. deptId: $('#treeselectSecondContent').val() == null ? 100 : $('#treeselectSecondContent').val(),
  302. dkzt:$('#useTypeContent').val(),
  303. translate_dict: 1,
  304. pageNum: 1,
  305. pageSize: 10,
  306. }, module.assetList , true);
  307. }
  308. turnThePage = function (pageNum) {
  309. tools.doGet(resourceList, {
  310. deptId: $('#treeselectSecondContent').val() == null ? 100 : $('#treeselectSecondContent').val(),
  311. translate_dict: 1,
  312. pageNum: pageNum,
  313. pageSize: 10,
  314. }, module.assetList , true);
  315. }
  316. openBig = function () {
  317. $("#open").css('display','none');
  318. $(".table_main").css('display','none');
  319. $(".pageNum").css('display','none');
  320. $("#close").css('display','block');
  321. $("#map_main").css({
  322. 'height': '59vh',
  323. 'position': 'absolute',
  324. 'top': '1vh',
  325. 'width': 'calc(100% - 2vh)',
  326. })
  327. $("#container").css('height','59vh')
  328. initMap(module.data.treeselectA);
  329. // 添加资源图层
  330. addResourceLayer(module.data.propertyList);
  331. }
  332. closeBig = function () {
  333. $("#open").css('display','block');
  334. $(".table_main").css('display','block');
  335. $(".pageNum").css('display','block');
  336. $("#close").css('display','none');
  337. $("#map_main").css({
  338. 'height': '16vh',
  339. 'position': 'relative',
  340. 'width': '100%',
  341. 'top': '0vh',
  342. })
  343. $("#container").css('height','16vh')
  344. initMap(module.data.treeselectA);
  345. // 添加资源图层
  346. addResourceLayer(module.data.propertyList);
  347. }
  348. return module;
  349. });