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

308 lines
11 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. 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.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.rows;
  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. addResourceLayer(content);
  79. // $('#page_s1').html('共' + 10 + '页')
  80. var propertyData = template('propertyData', module.data);
  81. $("#propertyContent").html(propertyData);
  82. }
  83. }
  84. // 添加资源图层
  85. addResourceLayer = function (content) {
  86. if (module.data.resourceLayer) {
  87. module.data.map.removeLayer(module.data.resourceLayer);
  88. module.data.resourceLayer = '';
  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: 'resource',
  98. });
  99. features.push(iconFeature);
  100. }
  101. });
  102. const vectorSource = new ol.source.Vector({
  103. features: features,
  104. });
  105. module.data.resourceLayer = new ol.layer.Vector({
  106. source: vectorSource,
  107. name: 'resourceLayer',
  108. style: new ol.style.Style({
  109. fill: new ol.style.Fill({
  110. //矢量图层填充颜色,以及透明度
  111. color: "rgba(255, 255, 0, 0.3)",
  112. }),
  113. stroke: new ol.style.Stroke({
  114. //边界样式
  115. color: "#ffff00",
  116. width: 2,
  117. }),
  118. })
  119. });
  120. module.data.map.getLayers().insertAt(3, module.data.resourceLayer);
  121. }
  122. openDialog = function(id){
  123. tools.doGet(resourceGet+id, {translate_dict: 1}, module.assetDetail , true);
  124. }
  125. closeDialog = function(id){
  126. $('#dialog').css('display','none');
  127. }
  128. module.assetDetail = function(data){
  129. if (data.code == 200) {
  130. var content = data.data;
  131. module.data.propertyDetail = content;
  132. tools.doGet(attachmentList, {
  133. tableId:content.id,
  134. tableName: 't_asset_resource',
  135. bizPath: 'asset'
  136. }, module.attachmentDetail , true);
  137. // var propertyDetailData = template('propertyDetailData', module.data);
  138. // $("#propertyDetailContent").html(propertyDetailData);
  139. // $('#dialog').css('display','block');
  140. }
  141. }
  142. module.attachmentDetail = function(data){
  143. if (data.code == 200) {
  144. var content = data.rows;
  145. var attachmentList = [];
  146. content.map(res=>{
  147. if (res.fileName.indexOf('png')>-1||res.fileName.indexOf('jpg')>-1){
  148. attachmentList.push(res);
  149. }
  150. })
  151. module.data.attachment = attachmentList;
  152. var propertyDetailData = template('propertyDetailData', module.data);
  153. $("#propertyDetailContent").html(propertyDetailData);
  154. $('#dialog').css('display','block');
  155. }
  156. }
  157. module.treeselect = function(data){
  158. if (data.code == 200) {
  159. var content = data.data[0].children;
  160. content.map(res=>{
  161. module.data.treeselect.push(res)
  162. })
  163. // module.data.treeselect = content[0].children;
  164. var treeselectData = template('treeselectData', module.data);
  165. $("#treeselectContent").html(treeselectData);
  166. var treeselectSecondData = template('treeselectSecondData', module.data);
  167. $("#treeselectSecondContent").html(treeselectSecondData);
  168. initMap(data.data[0]);
  169. //资产列表
  170. tools.doGet(resourceList, {
  171. deptId: 100,
  172. translate_dict: 1,
  173. pageNum: 1,
  174. pageSize: 10,
  175. }, module.assetList , true);
  176. tools.doGet(treeselectSecond+'100', {}, module.useContent, true);
  177. }
  178. }
  179. initMap = function (dept) {
  180. let mapCenterLocation;
  181. if (dept.lng && dept.lat) {
  182. mapCenterLocation = [dept.lng, dept.lat];
  183. } else {
  184. mapCenterLocation = [116.391461, 39.902359];
  185. }
  186. document.getElementById("container").innerHTML = "";
  187. // 定义地图投影
  188. let projection = new ol.proj.Projection({
  189. code: "EPSG:3857",
  190. units: "degrees",
  191. });
  192. // 定义地图图层
  193. let aerial = new ol.layer.Tile({
  194. source: new ol.source.XYZ({
  195. url: "http://t{0-7}.tianditu.com/img_w/wmts?" +
  196. "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
  197. "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=cc4aba6e967096098249efa069733067",
  198. }),
  199. isGroup: true,
  200. name: "卫星影像图",
  201. });
  202. let yingxzi = new ol.layer.Tile({
  203. source: new ol.source.XYZ({
  204. url: "http://t{0-7}.tianditu.com/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=cc4aba6e967096098249efa069733067",
  205. }),
  206. isGroup: true,
  207. name: "天地图文字标注--卫星影像图",
  208. });
  209. //加载地图
  210. module.data.map = new ol.Map({
  211. controls: ol.control.defaults({attribution: false, zoom: false, rotate: false}).extend([new ol.control.FullScreen()]),
  212. layers: [aerial, yingxzi],
  213. projection: projection,
  214. target: "container",
  215. view: new ol.View({
  216. center: ol.proj.fromLonLat(mapCenterLocation), // 地图中心坐标
  217. zoom: 13,
  218. minZoom: 1, //地图缩小限制
  219. maxZoom: 18, //地图放大限制
  220. // extent: [13481224.75161,5667110.83528,13811063.06278,5880284.11416]
  221. }),
  222. /*interactions: ol.interaction.defaults({
  223. doubleClickZoom: false, // 双击放大地图
  224. // mouseWheelZoom: false, // 鼠标滚轮放大地图
  225. // shiftDragZoom: false, // shift + 鼠标左键拖拽 放大地图
  226. })*/
  227. });
  228. }
  229. selectChange = function(){
  230. // tools.doGet(treeselectSecond+$('#treeselectContent').val(), {}, module.selectSecondChange , true);
  231. if ($('#treeselectContent').val() == 100){
  232. module.data.treeselectSecond = [{
  233. value:100,
  234. label:'全部'
  235. }]
  236. tools.doGet(treeselectSecond+'100', {}, module.useContent , true);
  237. }else{
  238. module.data.treeselectSecond = module.data.treeselect.filter(function (e) { return e.value == $('#treeselectContent').val(); })[0].children;
  239. tools.doGet(treeselectSecond+$('#treeselectContent').val(), {}, module.useContent , true);
  240. }
  241. var treeselectSecondData = template('treeselectSecondData', module.data);
  242. $("#treeselectSecondContent").html(treeselectSecondData);
  243. selectSecondChange();
  244. }
  245. selectSecondChange = function(){
  246. $('.page_s1').html('');
  247. module.data.propertyList = "";
  248. tools.doGet(resourceList, {
  249. deptId: $('#treeselectSecondContent').val(),
  250. translate_dict: 1,
  251. pageNum: 1,
  252. pageSize: 10,
  253. }, module.assetList , true);
  254. tools.doGet(treeselectSecond+$('#treeselectSecondContent').val(), {}, module.useContent , true);
  255. //资产列表
  256. // tools.doGet(assetList, {
  257. // deptId: $('#treeselectSecondContent').val(),
  258. // useType: $('#useTypeContent').val() == null ? 1 : $('#useTypeContent').val(),
  259. // operationType: 1,
  260. // translate_dict: 1,
  261. // pageNum: 1,
  262. // pageSize: 10,
  263. // orderByColumn: 'code',
  264. // isAsc: 'asc',
  265. // }, module.assetList , true);
  266. }
  267. useTypeChange = function () {
  268. $('.page_s1').html('');
  269. module.data.propertyList = "";
  270. tools.doGet(resourceList, {
  271. deptId: $('#treeselectSecondContent').val() == null ? 100 : $('#treeselectSecondContent').val(),
  272. dkzt:$('#useTypeContent').val(),
  273. translate_dict: 1,
  274. pageNum: 1,
  275. pageSize: 10,
  276. }, module.assetList , true);
  277. }
  278. turnThePage = function (pageNum) {
  279. tools.doGet(resourceList, {
  280. deptId: 187,
  281. translate_dict: 1,
  282. pageNum: pageNum,
  283. pageSize: 10,
  284. }, module.assetList , true);
  285. }
  286. return module;
  287. });