网站
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.

resource.js 14 KiB

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