网站
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

resource.js 11 KiB

hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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. //资产列表
  29. tools.doGet(resourceList, {
  30. deptId: 187,
  31. translate_dict: 1,
  32. pageNum: 1,
  33. pageSize: 10,
  34. }, module.assetList , true);
  35. tools.doGet(treeselectSecond+'100', {}, module.useContent, true);
  36. tools.doGet(treeselect, {}, module.treeselect , true);
  37. tools.doGet(webList, {}, module.webList , true);
  38. // tools.doGet(webDeptType+'use_code', {}, module.webDeptType , true);
  39. };
  40. module.useContent = function (data) {
  41. if (data.code == 200) {
  42. module.data.phone = data.data.phone;
  43. module.data.leader = data.data.leader;
  44. var propertyDetailData = template('propertyDetailData', module.data);
  45. $("#propertyDetailContent").html(propertyDetailData);
  46. module.data.map.getView().setCenter(ol.proj.fromLonLat([data.data.lng, data.data.lat]));
  47. module.data.map.getView().setZoom(13);
  48. }
  49. }
  50. module.webDeptType = function (data) {
  51. if (data.code == 200) {
  52. var content = data.data;
  53. content.map(res=>{
  54. module.data.useType.push(res)
  55. })
  56. // module.data.useType = content;
  57. var useTypeData = template('useTypeData', module.data);
  58. $("#useTypeContent").html(useTypeData);
  59. }
  60. }
  61. module.webList = function (data) {
  62. if (data.code == 200) {
  63. var content = data.rows;
  64. module.data.webList = content;
  65. var webData = template('webData', module.data);
  66. $("#webContent").html(webData);
  67. var titData = template('titData', module.data);
  68. $("#titContent").html(titData);
  69. }
  70. }
  71. module.assetList = function (data) {
  72. if (data.code == 200) {
  73. var content = data.rows;
  74. if (module.data.propertyList == '') {
  75. var page_s1 = createPage('.page_s1');
  76. //设置分页
  77. setPage(page_s1, {
  78. pageTotal: data.total, // 数据总条数
  79. pageSize: 10, // 每页显示条数
  80. pageCurrent: 1, // 当前页
  81. maxBtnNum: 5, // 最多按钮个数 (最少5个)
  82. })
  83. }
  84. module.data.propertyList = content;
  85. // 添加资产图层
  86. addResourceLayer(content);
  87. // $('#page_s1').html('共' + 10 + '页')
  88. var propertyData = template('propertyData', module.data);
  89. $("#propertyContent").html(propertyData);
  90. }
  91. }
  92. // 添加资产图层
  93. addResourceLayer = function (content) {
  94. if (module.data.resourceLayer) {
  95. module.data.map.removeLayer(module.data.resourceLayer);
  96. module.data.resourceLayer = '';
  97. }
  98. let features = [];
  99. content.forEach(item => {
  100. if (item.theGeom != null && item.theGeom !== '') {
  101. const iconFeature = new ol.Feature({
  102. geometry: new ol.geom.MultiPolygon(JSON.parse(item.theGeomJson).coordinates),
  103. // name: item.centerName,
  104. // centerDeptId: item.deptId,
  105. level: 'resource',
  106. });
  107. features.push(iconFeature);
  108. }
  109. });
  110. const vectorSource = new ol.source.Vector({
  111. features: features,
  112. });
  113. module.data.resourceLayer = new ol.layer.Vector({
  114. source: vectorSource,
  115. name: 'resourceLayer',
  116. style: new ol.style.Style({
  117. fill: new ol.style.Fill({
  118. //矢量图层填充颜色,以及透明度
  119. color: "rgba(255, 255, 0, 0.3)",
  120. }),
  121. stroke: new ol.style.Stroke({
  122. //边界样式
  123. color: "#ffff00",
  124. width: 2,
  125. }),
  126. })
  127. });
  128. module.data.map.getLayers().insertAt(3, module.data.resourceLayer);
  129. }
  130. openDialog = function(id){
  131. tools.doGet(resourceGet+id, {translate_dict: 1}, module.assetDetail , true);
  132. }
  133. closeDialog = function(id){
  134. $('#dialog').css('display','none');
  135. }
  136. module.assetDetail = function(data){
  137. if (data.code == 200) {
  138. var content = data.data;
  139. module.data.propertyDetail = content;
  140. tools.doGet(attachmentList, {
  141. tableId:content.id,
  142. tableName: 't_asset_resource',
  143. bizPath: 'asset'
  144. }, module.attachmentDetail , true);
  145. // var propertyDetailData = template('propertyDetailData', module.data);
  146. // $("#propertyDetailContent").html(propertyDetailData);
  147. // $('#dialog').css('display','block');
  148. }
  149. }
  150. module.attachmentDetail = function(data){
  151. if (data.code == 200) {
  152. var content = data.rows;
  153. var attachmentList = [];
  154. content.map(res=>{
  155. if (res.fileName.indexOf('png')>-1||res.fileName.indexOf('jpg')>-1){
  156. attachmentList.push(res);
  157. }
  158. })
  159. module.data.attachment = attachmentList;
  160. var propertyDetailData = template('propertyDetailData', module.data);
  161. $("#propertyDetailContent").html(propertyDetailData);
  162. $('#dialog').css('display','block');
  163. }
  164. }
  165. module.treeselect = function(data){
  166. if (data.code == 200) {
  167. var content = data.data[0].children;
  168. content.map(res=>{
  169. module.data.treeselect.push(res)
  170. })
  171. // module.data.treeselect = content[0].children;
  172. var treeselectData = template('treeselectData', module.data);
  173. $("#treeselectContent").html(treeselectData);
  174. var treeselectSecondData = template('treeselectSecondData', module.data);
  175. $("#treeselectSecondContent").html(treeselectSecondData);
  176. initMap(data.data[0]);
  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. });