Commit abe8327d9f60e1e25c68f253c328acbc12cfdd94

Authored by youxiw2000
1 parent fd211057

1

src/main/resources/static/pages/base/stationroute/js/stationroute-list-function.js
1   -/**
2   - * 函数
3   - *
4   - * - - - - - - - 》 getCurrSelNode : 获取选中树节点数据函数
5   - *
6   - * - - - - - - - 》 resjtreeDate : 刷新树函数函数
7   - *
8   - * - - - - - - - 》 setFormInputValue : 新增站点参数集合赋值函数
9   - *
10   - * - - - - - - - 》 editSetStationParmas : 编辑站点参数集合赋值函数
11   - *
12   - * - - - - - - - 》 editSeteditStationParmasValue:编辑站点范围图形参数集合赋值函数
13   - *
14   - * - - - - - - - 》 lineNameIsHaveInterval : 系统规划时修正线路名称
15   - *
16   - * - - - - - - - 》 systemLineStation:系统规划保存函数
17   - *
18   - * - - - - - - - 》 stationRevoke :撤销站点
19   - *
20   - * - - - - - - - 》 editLinePlan :编辑线路走向
21   - *
22   - * - - - - - - - 》 setFormValue :编辑站点设置表单元素值
23   - *
24   - * - - - - - - - 》 eachSectionList:路段折线百度坐标转WGS坐标
25   - */
26   -
27   -var PublicFunctions = function () {
28   - var PubFun = {
29   - /** 初始化线路标题与ID */
30   - setTiteText : function(lineId) {
31   - // 根据线路ID获取线路名称
32   - GetAjaxData.getIdLineName(lineId,function(data) {
33   - // 定义线路名称
34   - var lineNameV = data.name;
35   - $('.portlet-title .caption').text(lineNameV);
36   - });
37   - },
38   - /** @param direction 方向 @return array */
39   - getCurrSelNode : function(direction){
40   - // 定义Obj
41   - var array = [];
42   - try {
43   - // 上行
44   - if(direction=='0'){
45   - // 获取上行选中节点
46   - array = $.jstree.reference("#station_Up_tree").get_selected(true);
47   - // 下行
48   - }else if(direction=='1'){
49   - // 获取下行选中节点
50   - array = $.jstree.reference("#station_Down_tree").get_selected(true);
51   - }
52   - } catch (e) {
53   - console.log(e);
54   - }
55   - // 返回Obj
56   - return array;
57   - },
58   - /** @param id:线路ID ;directionData:方向 */
59   - resjtreeDate : function(id,directionData,version){
60   -
61   - if(!version){
62   - version = $("#versions").val();
63   - }
64   -
65   - // 获取树数据
66   - GetAjaxData.getStation(id,directionData,version,function(treeDateJson) {
67   - // 获取数据长度
68   - var len = treeDateJson[0].children[0].children.length;
69   - // 上行
70   - if(directionData==0){
71   - // 长度大于零
72   - if(len>0) {
73   - // 隐藏上行规划
74   - $('#upToolsMobal').hide();
75   - // 显示树
76   - $('#uptreeMobal').show();
77   - // 刷新树
78   - StationTreeData.upreloadeTree(treeDateJson);
79   - }else {
80   - if ($($("#versions").find("option:selected")[0]).attr("status") > 0) {
81   - // 显示上行规划
82   - $('#upToolsMobal').show();
83   - }else{
84   - $('#upToolsMobal').hide();
85   -
86   - }
87   - // 隐藏上行树
88   - $('#uptreeMobal').hide();
89   - }
90   -
91   - // 下行
92   - }else if(directionData==1){
93   - // 如果长度大于
94   - if(len>0) {
95   - // 隐藏下行规划
96   - $('#downToolsMobal').hide();
97   - // 显示下行树
98   - $('#DowntreeMobal').show();
99   - // 跟新树
100   - StationTreeData.dwonreloadeTree(treeDateJson);
101   - }else {
102   - if ($($("#versions").find("option:selected")[0]).attr("status") > 0) {
103   - // 显示下行规划
104   - $('#downToolsMobal').show();
105   - }else{
106   - $('#downToolsMobal').hide();
107   - }
108   - // 隐藏下行树
109   - $('#DowntreeMobal').hide();
110   - }
111   - }
112   -
113   - PublicFunctions.linePanlThree(id,treeDateJson,directionData,version,function (polyline_center) {
114   - var map = WorldsBMap.getmapBValue();
115   - map.panTo(polyline_center);
116   - });
117   - });
118   - },
119   -
120   - /** 修正线路名称 @param:<directionUpValue:方向(0:上行;1:下行)> */
121   - lineNameIsHaveInterval : function(directionData) {
122   - // 定义线路名称
123   - var lineNameV = $('.portlet-title .caption').text();
124   - // 线路名称是否为区间线路
125   - if(lineNameV.indexOf('区间')>0){
126   - // 截去区间
127   - var lineNameNew = lineNameV.replace('区间','');
128   - // 是否继续弹出层
129   - layer.confirm('系统无法生成该线路【'+lineNameV+'】的站点与路段!自动修改为如下线路名称【'+lineNameNew+'】生成', {
130   - btn : [ '确认提示并提交', '取消' ]
131   - }, function(index) {
132   - // 关闭弹出层
133   - layer.close(index);
134   - // 线路名称去掉区间
135   - lineNameV = lineNameNew;
136   - /** 保存 @param:<lineNameV:线路名称;directionData:方向(0:上行;1:下行)> */
137   - PublicFunctions.systemLineStation(lineNameV,directionData);
138   - },function(){
139   - // 关闭弹出层
140   - layer.closeAll();
141   - // 上行
142   - if(directionData==0){
143   - // 显示上行规划
144   - $('#upToolsMobal').show();
145   - // 下行
146   - }else if(directionData==1){
147   - // 显示下行规划
148   - $('#downToolsMobal').show();
149   - }
150   - });
151   -
152   - // 线路名称是否为定班线路
153   - }else if(lineNameV.indexOf('定班')>0){
154   - // 截去定班
155   - var lineNameNew = lineNameV.replace('定班','');
156   - // 是否继续弹出层
157   - layer.confirm('系统无法生成该线路【'+lineNameV+'】的站点与路段!自动修改为如下线路名称【'+lineNameNew+'】生成', {
158   - btn : [ '确认提示并提交', '取消' ]
159   - }, function(index) {
160   - // 关闭弹出层
161   - layer.close(index);
162   - // 线路名称去掉区间
163   - lineNameV = lineNameNew;
164   - /** 保存 @param:<lineNameV:线路名称;directionData:方向(0:上行;1:下行)> */
165   - PublicFunctions.systemLineStation(lineNameV,directionData);
166   - },function(){
167   - // 关闭弹出层
168   - layer.closeAll();
169   - // 上行
170   - if(directionData==0){
171   - // 显示上行规划
172   - $('#upToolsMobal').show();
173   - // 下行
174   - }else if(directionData==1){
175   - // 显示下行规划
176   - $('#downToolsMobal').show();
177   - }
178   - });
179   - }else {
180   - /** 直接保存 @param:<lineNameV:线路名称;directionData:方向(0:上行;1:下行)> */
181   - PublicFunctions.systemLineStation(lineNameV,directionData);
182   - }
183   -
184   - },
185   -
186   - /** 直接保存 @param:<lineNameV:线路名称;directionData:方向(0:上行;1:下行)> */
187   - systemLineStation : function(lineNameV,directionData) {
188   - /** 从百度地图获取线路信息 @param:<lineNameV:线路名称;directionData:方向(0:上行;1:下行);callback>*/
189   - WorldsBMap.lineInfoPanl(lineNameV,directionData,function(BusLine){
190   - // 如果线路信息不为空
191   - if(BusLine) {
192   - // 获取公交线几何对象, 仅当结果自动添加到地图上时有效
193   - var Polygon = BusLine.getPolyline();
194   - // 返回多边型的点数组(自1.2新增)
195   - var polyGonArray = Polygon.getPath();
196   - // 获取公交站点个数(自 1.2 新增)
197   - var stationNumber = BusLine.getNumBusStations();
198   - // 定义线路信息集合
199   - var stationInfo = [];
200   - // 遍历
201   - for(var k = 0 ; k < stationNumber; k++) {
202   - // 定义线路信息集合
203   - var tempM = {};
204   - // 添加站点名称
205   - tempM.name = BusLine.getBusStation(k).name;
206   - // 添加站点坐标
207   - tempM.potion = BusLine.getBusStation(k).position;
208   - tempM.wgs = {x:'',y:''};
209   - // 添加
210   - stationInfo.push(tempM);
211   - }
212   - // 获取站点之间的距离与时间
213   - WorldsBMap.getDistanceAndDuration(stationInfo,function(json) {
214   - // 设置第一个站的距离
215   - json[0].distance = '';
216   - // 设置第一个站的时间
217   - json[0].duration = '';
218   - // 定义站点信息JSON字符串
219   - var stationJSON = JSON.stringify(json);
220   - // 定义路段信息字符串
221   - var sectionJSON = JSON.stringify(polyGonArray);
222   - // 参数集合
223   - var params = {};
224   - // 站点信息JSON字符串
225   - params.stationJSON = stationJSON;
226   - var addLine = LineObj.getLineObj();
227   - // 线路ID
228   - params.lineId = addLine.id;
229   - // 方向
230   - params.directions = directionData;
231   - // 原始坐标类型
232   - params.dbType = 'b';
233   - // 圆形半径
234   - params.radius = '100';
235   - // 图形类型(r:圆形;p:多边形)
236   - params.shapesType = 'r';
237   - // destroy:是否撤销
238   - params.destroy = '0';
239   -
240   - // 路段信息JSON字符串
241   - params.sectionJSON = sectionJSON;
242   - // 限速
243   - params.speedLimit = '60';
244   - params.baseRes = 'No';
245   - // 获取版本号后提交添加
246   - $.get('/lineVersions/findByLineId',{'lineId':addLine.id},function(lineVersions){
247   - $.each(lineVersions,function(){
248   - if (this.status == 1) {
249   - // versions:版本号
250   - params.versions = this.versions;
251   - // 保存
252   - GetAjaxData.collectionSave(params,function(rd) {
253   - if(rd.status='SUCCESS') {
254   - // 关闭弹出层
255   - layer.closeAll();
256   - layer.msg('保存成功!');
257   - }else {
258   - // 保存失败
259   - layer.msg('保存失败!');
260   - }
261   - // 刷新树
262   - PublicFunctions.resjtreeDate(addLine.id,directionData,$("#versions").val());
263   - /** 查询上行路段信息 @param:<Line.id:线路Id;0:上行> @return:data:路段数据 */
264   -// GetAjaxData.getSectionRouteInfo(addLine.id,directionData,function(data) {
265   -// /** 在地图上画出线路走向 @param:<Line.id:线路Id;0:上行;data:路段数据> */
266   -// PublicFunctions.linePanlThree(addLine.id,data,directionData);
267   -// });
268   - });
269   - }
270   - })
271   - });
272   - });
273   - // 关闭弹出层
274   - layer.closeAll();
275   - // 上行
276   - if(directionData==0){
277   - $('#stationDown').removeClass('active');
278   - $('#stationDown').removeClass('in');
279   - $('#stationDown').addClass('fade');
280   - $('#stationUp').addClass('active in');
281   - $('#downLine').parent().removeClass('active');
282   - $('#upLine').parent().addClass('active');
283   - // 下行
284   - }else if(directionData==1){
285   - $('#stationUp').removeClass('active');
286   - $('#stationUp').removeClass('in');
287   - $('#stationUp').addClass('fade');
288   - $('#stationDown').addClass('active in');
289   - $('#upLine').parent().removeClass('active');
290   - $('#downLine').parent().addClass('active');
291   - }
292   - } else {
293   - layer.msg('百度地图中没有此线路,无法系统规划!');
294   - setTimeout(function() {
295   - // 关闭弹出层
296   - layer.closeAll();
297   - // 上行
298   - if(directionData==0){
299   - // 显示上行规划
300   - $('#upToolsMobal').show();
301   - // 下行
302   - }else if(directionData==1){
303   - // 显示下行规划
304   - $('#downToolsMobal').show();
305   - }
306   - }, 3000);
307   - }
308   - });
309   - },
310   -
311   - /** @param directionV_ :方向 */
312   - stationRevoke : function(directionV_) {
313   - // 获取树选中节点对象
314   - var obj = PublicFunctions.getCurrSelNode(directionV_);
315   - // 是否选中,选中节点是否为站点
316   - if(obj.length == 0 || obj[0].original.chaildredType !='station'){
317   - // 弹出提示层
318   - layer.msg('请先选择要删除的站点!');
319   - return;
320   - }
321   - // 弹出是否撤销提示框
322   - layer.confirm('你确定要撤销【'+obj[0].text+'】站点吗?', {btn : [ '确定撤销','返回' ],icon: 3, title:'提示' }, function(index){
323   -
324   - debugger;
325   - // 站点路由ID
326   - var stationRouteId = obj[0].original.stationRouteId;
327   -
328   - var Line = LineObj.getLineObj();
329   -
330   - clonsole.log(Line);
331   -
332   - // 撤销参数集合
333   - var params = {stationRouteId:stationRouteId,destroy:'1',status:Line.status};
334   - // 方向
335   - var stationRouteDirections = obj[0].original.stationRouteDirections;
336   - // 撤销
337   - GetAjaxData.stationRouteIsDestroy(params,function(result) {
338   - // 关闭弹出框
339   - layer.close(index);
340   - if(result.status=='SUCCESS'){
341   - layer.msg('撤销'+(directionV_==0?"上行":"下行")+'站点【'+obj[0].text+'】成功!');
342   - }else{
343   - layer.msg('撤销'+(directionV_==0?"上行":"下行")+'站点【'+obj[0].text+'】失败!');
344   - }
345   - WorldsBMap.clearMarkAndOverlays();
346   -
347   - var ver = $("#versions").val();
348   -
349   - // 刷行左边树
350   - PublicFunctions.resjtreeDate(Line.id,stationRouteDirections,ver);
351   - /** 查询上行路段信息 @param:<Line.id:线路Id;0:上行> @return:data:路段数据 */
352   -// GetAjaxData.getSectionRouteInfo(Line.id,stationRouteDirections,ver,function(data) {
353   -// /** 在地图上画出线路走向 @param:<Line.id:线路Id;0:上行;data:路段数据> */
354   -// PublicFunctions.linePanlThree(Line.id,data,stationRouteDirections);
355   -// });
356   - });
357   - });
358   - },
359   -
360   - /** @param direction_ :方向 */
361   - editLinePlan : function(direction_) {
362   - var sel = PublicFunctions.getCurrSelNode(direction_);
363   - if(sel.length==0 || sel[0].original.chaildredType !='section'){
364   - if(direction_=='0') {
365   - layer.msg('请先选中要编辑的上行路段!');
366   - }else if(direction_=='1') {
367   - layer.msg('请先选中要编辑的下行路段!');
368   - }
369   - return;
370   - }
371   - $('#downLine').addClass('btn disabled');
372   - $('.btn-circle').addClass('disabled');
373   - $('#upLine').addClass('btn disabled');
374   - var editSectionV = sel[0].original;
375   - EditSectionObj.setEitdSection(editSectionV);
376   - // 弹出添加失败提示消息,2秒关闭(如果不配置,默认是3秒)
377   - var yindex = layer.msg('编辑完线路走向后,请双击线路走向区域保存',{ offset: '126px',shift: 0,time: 10000});
378   - WorldsBMap.editPolyUpline();
379   - },
380   -
381   - setFormValue : function(editStationParmas) {
382   - // 站点ID
383   - $('#stationIdInput').val(editStationParmas.stationId);
384   - // 站点路由ID
385   - $('#stationRouteIdInput').val(editStationParmas.stationRouteId);
386   - // 站点路由线路Id
387   - $('#stationRouteLineInput').val(editStationParmas.stationRouteLine);
388   - // 线路编码
389   - $('#lineCodeInput').val(editStationParmas.stationRouteLIneCode);
390   - // 行业标准
391   - $('#industryCodeInput').val(editStationParmas.industryCode);
392   - // 百度坐标点图形集合
393   - $('#bPolygonGridInput').val(editStationParmas.stationBPolygonGrid);
394   - // 获取站点名称元素设值
395   - $('#zdmcInput').val(editStationParmas.stationStationName);
396   - // 获取站点路由名称元素设值
397   - $('#stationNameInput').val(editStationParmas.stationStationName);
398   - // 获取站点编码元素设值
399   - $('#stationCodInput').val(editStationParmas.stationCode);
400   - // 获取站点类型元素设值
401   - // $('#stationMarkSelect').val(editStationParmas.stationRouteStationMark);
402   - // 获取站点方向元素设值
403   - $('#stationdirSelect').val(editStationParmas.stationRoutedirections);
404   - // 获取站点道路编码元素设值
405   - $('#roadCodingCodInput').val(editStationParmas.stationRoadCoding);
406   - // 百度地图经纬度坐标中心点
407   - $('#bJwpointsInput').val(editStationParmas.stationJwpoints);
408   - if(editStationParmas.stationShapesType=='r') {
409   - // 获取图形类型元素,并添加值
410   - $('#shapesTypeSelect').val('圆形');
411   - }else if(editStationParmas.stationShapesType=='d'){
412   - $('#radiusGroup').hide();
413   - $('#shapesTypeSelect').val('多边形');
414   - }
415   - // 获取半径元素,并添加值
416   - $('#radiusInput').val(editStationParmas.stationRadius);
417   - // 是否撤销
418   - $('#destroySelect').val(editStationParmas.stationDestroy);
419   - // 到站时间
420   - $('#toTimeInput').val(editStationParmas.stationRouteToTime);
421   - // 到站距离
422   - $('#distancesInput').val(editStationParmas.stationRouteDistances);
423   - // 线路版本号
424   - $('#versionsInput').val(editStationParmas.stationRouteVersions);
425   - // 描述/说明
426   - $('#descriptionsTextarea').val(editStationParmas.sttationDescriptions);
427   - },
428   -
429   - setSectionFormValue : function(Section) {
430   - $('#isRoadeSpeedInput').val(Section.isRoadeSpeed);
431   - // 路段ID
432   - $('#sectionIdInput').val(Section.sectionId);
433   - // 路段路由ID
434   - $('#sectionRouteIdInput').val(Section.sectionrouteId);
435   - // 线路ID
436   - $('#sectionRouteLineInput').val(Section.sectionrouteLine);
437   - // 线路编码
438   - $('#lineCodeInput').val(Section.sectionrouteLineCode);
439   - // 折线坐标集合
440   - $('#bsectionVectorInput').val(Section.sectionBsectionVector);
441   - // 路段名称
442   - $('#sectionNameInput').val(Section.sectionName);
443   - // 路段编码
444   - $('#sectionCodeInput').val(Section.sectionCode);
445   - // 路段序号
446   - $('#sectionrouteCodeSelect').val(Section.sectionrouteCode);
447   - // 路段方向
448   - $('#directionsSection').val(Section.sectionrouteDirections);
449   - // 道路编码
450   - $('#roadCodingCodInput').val(Section.sectionRoadCoding);
451   - // 道路限速
452   - $('#speedLimitInput').val(Section.sectionSpeedLimet);
453   - // 路段长度
454   - $('#sectionDistanceInput').val(Section.sectionDistance);
455   - // 时长
456   - $('#sectionTimeInput').val(Section.sectionTime);
457   - // 版本号
458   - $('#versionsInput').val(Section.versions);
459   - },
460   -
461   - /** 在地图上画出线路走向 @param:<Line.id:线路Id;0:上行;data:路段数据> */
462   - linePanlThree : function(lineId,data,direction,version,callback) {
463   - /** 获取站点路由信息 @param:<Line.id:线路Id;0:上行> @return:<resultdata:站点路由数据> */
464   - var polyline_center;
465   - GetAjaxData.getStationRoutePoint(lineId,direction,version,function(resultdata) {
466   - WorldsBMap.clearMarkAndOverlays();
467   - // 如果站点路由数据不为空
468   - if(resultdata.length>0) {
469   -// var ceter_index = Math.round(resultdata.length / 2);
470   - var ceterPointsStr = resultdata[0].stationJwpoints;
471   - var ceterPointsArray = ceterPointsStr.split(' ');
472   - polyline_center = new BMap.Point(ceterPointsArray[0],ceterPointsArray[1]);
473   - // 遍历站点路由数据
474   - for(var s = 0 ; s<resultdata.length;s++) {
475   - WorldsBMap.drawingUpStationPoint(resultdata[s], s+1);
476   - }
477   - }
478   - data = data[0].children[1];
479   - // 路段数据长度
480   - var dataLen = data.children.length;
481   - // 如果大于零
482   - if(dataLen>0) {
483   - WorldsBMap.drawingUpline01(data.children);
484   - // WorldsBMap.drawingUpline01(polyline_center,data);
485   - }
486   - callback && callback(polyline_center);
487   - });
488   - },
489   - /** 加载树 @param:<lineId:线路ID;direction:方向(0:上行;1:下行)> */
490   - TreeUpOrDown : function(lineId,direction,version) {
491   -
492   - /** 获取树结果数据 @param:<lineId:线路ID;direction:方向;callback:回调函数> */
493   - GetAjaxData.getStation(lineId,direction,version,function(treeDateJson) {
494   - // 获取返回数据长度
495   - var len = treeDateJson[0].children[0].children.length;
496   - // 上行
497   - if(direction == 0) {
498   - /** 初始化上行树 @param:<treeDateJson:树数据结构> */
499   - StationTreeData.upInit(treeDateJson);
500   - if(len>0) {
501   - $('#upToolsMobal').hide();
502   - $('#uptreeMobal').show();
503   - }else {
504   - $('#upToolsMobal').show();
505   - $('#uptreeMobal').hide();
506   - }
507   -
508   - PublicFunctions.linePanlThree(lineId,treeDateJson,direction,version,function (polyline_center) {
509   - var map = WorldsBMap.getmapBValue();
510   - map.panTo(polyline_center);
511   - });
512   -
513   - // 下行
514   - }else if(direction ==1) {
515   - /** 出事画下行树 @param:<treeDateJson:树数据结构> */
516   - StationTreeData.downInit(treeDateJson);
517   - if(len>0) {
518   - $('#downToolsMobal').hide();
519   - $('#DowntreeMobal').show();
520   - }else {
521   - $('#downToolsMobal').show();
522   - $('#DowntreeMobal').hide();
523   - }
524   - }
525   - });
526   - },
527   - isHaveStationName : function(data) {
528   - if(data.length>0) {
529   - layer.confirm('系统已存在【'+ data[0].stationName +'】该站点位置名称,请选择【系统引用】或者更改站点名称进行新增!', {btn : [ '返回' ],icon: 3, title:'提示' }, function(index){
530   - layer.close(index);
531   - });
532   - return false;
533   - }else {
534   - return true;
535   - }
536   - },
537   - // 地图处于编辑状态
538   - editMapStatus : function (dir) {
539   - WorldsBMap.setMap_status(1);
540   - // 有方向就显示退出编辑模式按钮
541   - if(dir!=null && dir!='null'){
542   - WorldsBMap.setDir(dir);
543   - $('#esc_edit_div').show();
544   - }
545   - $('.protlet-box-layer').show();
546   - },
547   - // 地图处于编辑状态
548   - editMapStatusRemove : function () {
549   - WorldsBMap.setMap_status(0);
550   - $('.protlet-box-layer').hide();
551   - $('#esc_edit_div').hide();
552   - // 退出绘画模式
553   - WorldsBMap.exitDrawStatus();
554   - },
555   - // 选项鎖死解除
556   - editAChangeCssRemoveDisabled : function() {
557   - $('#downLine').removeClass('btn disabled');
558   - $('.btn-circle').removeClass('disabled');
559   - $('#upLine').removeClass('btn disabled');
560   - },
561   - // 方向代码转名称.
562   - dirdmToName : function(value){
563   - var srStr = '';
564   - if(value=='0')
565   - srStr = '上行';
566   - else if(value=='1')
567   - srStr = '下行';
568   - return srStr;
569   - },
570   - }
571   - return PubFun ;
  1 +/**
  2 + * 函数
  3 + *
  4 + * - - - - - - - 》 getCurrSelNode : 获取选中树节点数据函数
  5 + *
  6 + * - - - - - - - 》 resjtreeDate : 刷新树函数函数
  7 + *
  8 + * - - - - - - - 》 setFormInputValue : 新增站点参数集合赋值函数
  9 + *
  10 + * - - - - - - - 》 editSetStationParmas : 编辑站点参数集合赋值函数
  11 + *
  12 + * - - - - - - - 》 editSeteditStationParmasValue:编辑站点范围图形参数集合赋值函数
  13 + *
  14 + * - - - - - - - 》 lineNameIsHaveInterval : 系统规划时修正线路名称
  15 + *
  16 + * - - - - - - - 》 systemLineStation:系统规划保存函数
  17 + *
  18 + * - - - - - - - 》 stationRevoke :撤销站点
  19 + *
  20 + * - - - - - - - 》 editLinePlan :编辑线路走向
  21 + *
  22 + * - - - - - - - 》 setFormValue :编辑站点设置表单元素值
  23 + *
  24 + * - - - - - - - 》 eachSectionList:路段折线百度坐标转WGS坐标
  25 + */
  26 +
  27 +var PublicFunctions = function () {
  28 + var PubFun = {
  29 + /** 初始化线路标题与ID */
  30 + setTiteText : function(lineId) {
  31 + // 根据线路ID获取线路名称
  32 + GetAjaxData.getIdLineName(lineId,function(data) {
  33 + // 定义线路名称
  34 + var lineNameV = data.name;
  35 + $('.portlet-title .caption').text(lineNameV);
  36 + });
  37 + },
  38 + /** @param direction 方向 @return array */
  39 + getCurrSelNode : function(direction){
  40 + // 定义Obj
  41 + var array = [];
  42 + try {
  43 + // 上行
  44 + if(direction=='0'){
  45 + // 获取上行选中节点
  46 + array = $.jstree.reference("#station_Up_tree").get_selected(true);
  47 + // 下行
  48 + }else if(direction=='1'){
  49 + // 获取下行选中节点
  50 + array = $.jstree.reference("#station_Down_tree").get_selected(true);
  51 + }
  52 + } catch (e) {
  53 + console.log(e);
  54 + }
  55 + // 返回Obj
  56 + return array;
  57 + },
  58 + /** @param id:线路ID ;directionData:方向 */
  59 + resjtreeDate : function(id,directionData,version){
  60 +
  61 + if(!version){
  62 + version = $("#versions").val();
  63 + }
  64 +
  65 + // 获取树数据
  66 + GetAjaxData.getStation(id,directionData,version,function(treeDateJson) {
  67 + // 获取数据长度
  68 + var len = treeDateJson[0].children[0].children.length;
  69 + // 上行
  70 + if(directionData==0){
  71 + // 长度大于零
  72 + if(len>0) {
  73 + // 隐藏上行规划
  74 + $('#upToolsMobal').hide();
  75 + // 显示树
  76 + $('#uptreeMobal').show();
  77 + // 刷新树
  78 + StationTreeData.upreloadeTree(treeDateJson);
  79 + }else {
  80 + if ($($("#versions").find("option:selected")[0]).attr("status") > 0) {
  81 + // 显示上行规划
  82 + $('#upToolsMobal').show();
  83 + }else{
  84 + $('#upToolsMobal').hide();
  85 +
  86 + }
  87 + // 隐藏上行树
  88 + $('#uptreeMobal').hide();
  89 + }
  90 +
  91 + // 下行
  92 + }else if(directionData==1){
  93 + // 如果长度大于
  94 + if(len>0) {
  95 + // 隐藏下行规划
  96 + $('#downToolsMobal').hide();
  97 + // 显示下行树
  98 + $('#DowntreeMobal').show();
  99 + // 跟新树
  100 + StationTreeData.dwonreloadeTree(treeDateJson);
  101 + }else {
  102 + if ($($("#versions").find("option:selected")[0]).attr("status") > 0) {
  103 + // 显示下行规划
  104 + $('#downToolsMobal').show();
  105 + }else{
  106 + $('#downToolsMobal').hide();
  107 + }
  108 + // 隐藏下行树
  109 + $('#DowntreeMobal').hide();
  110 + }
  111 + }
  112 +
  113 + PublicFunctions.linePanlThree(id,treeDateJson,directionData,version,function (polyline_center) {
  114 + var map = WorldsBMap.getmapBValue();
  115 + map.panTo(polyline_center);
  116 + });
  117 + });
  118 + },
  119 +
  120 + /** 修正线路名称 @param:<directionUpValue:方向(0:上行;1:下行)> */
  121 + lineNameIsHaveInterval : function(directionData) {
  122 + // 定义线路名称
  123 + var lineNameV = $('.portlet-title .caption').text();
  124 + // 线路名称是否为区间线路
  125 + if(lineNameV.indexOf('区间')>0){
  126 + // 截去区间
  127 + var lineNameNew = lineNameV.replace('区间','');
  128 + // 是否继续弹出层
  129 + layer.confirm('系统无法生成该线路【'+lineNameV+'】的站点与路段!自动修改为如下线路名称【'+lineNameNew+'】生成', {
  130 + btn : [ '确认提示并提交', '取消' ]
  131 + }, function(index) {
  132 + // 关闭弹出层
  133 + layer.close(index);
  134 + // 线路名称去掉区间
  135 + lineNameV = lineNameNew;
  136 + /** 保存 @param:<lineNameV:线路名称;directionData:方向(0:上行;1:下行)> */
  137 + PublicFunctions.systemLineStation(lineNameV,directionData);
  138 + },function(){
  139 + // 关闭弹出层
  140 + layer.closeAll();
  141 + // 上行
  142 + if(directionData==0){
  143 + // 显示上行规划
  144 + $('#upToolsMobal').show();
  145 + // 下行
  146 + }else if(directionData==1){
  147 + // 显示下行规划
  148 + $('#downToolsMobal').show();
  149 + }
  150 + });
  151 +
  152 + // 线路名称是否为定班线路
  153 + }else if(lineNameV.indexOf('定班')>0){
  154 + // 截去定班
  155 + var lineNameNew = lineNameV.replace('定班','');
  156 + // 是否继续弹出层
  157 + layer.confirm('系统无法生成该线路【'+lineNameV+'】的站点与路段!自动修改为如下线路名称【'+lineNameNew+'】生成', {
  158 + btn : [ '确认提示并提交', '取消' ]
  159 + }, function(index) {
  160 + // 关闭弹出层
  161 + layer.close(index);
  162 + // 线路名称去掉区间
  163 + lineNameV = lineNameNew;
  164 + /** 保存 @param:<lineNameV:线路名称;directionData:方向(0:上行;1:下行)> */
  165 + PublicFunctions.systemLineStation(lineNameV,directionData);
  166 + },function(){
  167 + // 关闭弹出层
  168 + layer.closeAll();
  169 + // 上行
  170 + if(directionData==0){
  171 + // 显示上行规划
  172 + $('#upToolsMobal').show();
  173 + // 下行
  174 + }else if(directionData==1){
  175 + // 显示下行规划
  176 + $('#downToolsMobal').show();
  177 + }
  178 + });
  179 + }else {
  180 + /** 直接保存 @param:<lineNameV:线路名称;directionData:方向(0:上行;1:下行)> */
  181 + PublicFunctions.systemLineStation(lineNameV,directionData);
  182 + }
  183 +
  184 + },
  185 +
  186 + /** 直接保存 @param:<lineNameV:线路名称;directionData:方向(0:上行;1:下行)> */
  187 + systemLineStation : function(lineNameV,directionData) {
  188 + /** 从百度地图获取线路信息 @param:<lineNameV:线路名称;directionData:方向(0:上行;1:下行);callback>*/
  189 + WorldsBMap.lineInfoPanl(lineNameV,directionData,function(BusLine){
  190 + // 如果线路信息不为空
  191 + if(BusLine && Polygon) {
  192 + // 获取公交线几何对象, 仅当结果自动添加到地图上时有效
  193 + var Polygon = BusLine.getPolyline();
  194 + // 返回多边型的点数组(自1.2新增)
  195 + var polyGonArray = Polygon.getPath();
  196 + // 获取公交站点个数(自 1.2 新增)
  197 + var stationNumber = BusLine.getNumBusStations();
  198 + // 定义线路信息集合
  199 + var stationInfo = [];
  200 + // 遍历
  201 + for(var k = 0 ; k < stationNumber; k++) {
  202 + // 定义线路信息集合
  203 + var tempM = {};
  204 + // 添加站点名称
  205 + tempM.name = BusLine.getBusStation(k).name;
  206 + // 添加站点坐标
  207 + tempM.potion = BusLine.getBusStation(k).position;
  208 + tempM.wgs = {x:'',y:''};
  209 + // 添加
  210 + stationInfo.push(tempM);
  211 + }
  212 + // 获取站点之间的距离与时间
  213 + WorldsBMap.getDistanceAndDuration(stationInfo,function(json) {
  214 + // 设置第一个站的距离
  215 + json[0].distance = '';
  216 + // 设置第一个站的时间
  217 + json[0].duration = '';
  218 + // 定义站点信息JSON字符串
  219 + var stationJSON = JSON.stringify(json);
  220 + // 定义路段信息字符串
  221 + var sectionJSON = JSON.stringify(polyGonArray);
  222 + // 参数集合
  223 + var params = {};
  224 + // 站点信息JSON字符串
  225 + params.stationJSON = stationJSON;
  226 + var addLine = LineObj.getLineObj();
  227 + // 线路ID
  228 + params.lineId = addLine.id;
  229 + // 方向
  230 + params.directions = directionData;
  231 + // 原始坐标类型
  232 + params.dbType = 'b';
  233 + // 圆形半径
  234 + params.radius = '100';
  235 + // 图形类型(r:圆形;p:多边形)
  236 + params.shapesType = 'r';
  237 + // destroy:是否撤销
  238 + params.destroy = '0';
  239 +
  240 + // 路段信息JSON字符串
  241 + params.sectionJSON = sectionJSON;
  242 + // 限速
  243 + params.speedLimit = '60';
  244 + params.baseRes = 'No';
  245 + // 获取版本号后提交添加
  246 + $.get('/lineVersions/findByLineId',{'lineId':addLine.id},function(lineVersions){
  247 + $.each(lineVersions,function(){
  248 + if (this.status == 1) {
  249 + // versions:版本号
  250 + params.versions = this.versions;
  251 + // 保存
  252 + GetAjaxData.collectionSave(params,function(rd) {
  253 + if(rd.status='SUCCESS') {
  254 + // 关闭弹出层
  255 + layer.closeAll();
  256 + layer.msg('保存成功!');
  257 + }else {
  258 + // 保存失败
  259 + layer.msg('保存失败!');
  260 + }
  261 + // 刷新树
  262 + PublicFunctions.resjtreeDate(addLine.id,directionData,$("#versions").val());
  263 + /** 查询上行路段信息 @param:<Line.id:线路Id;0:上行> @return:data:路段数据 */
  264 +// GetAjaxData.getSectionRouteInfo(addLine.id,directionData,function(data) {
  265 +// /** 在地图上画出线路走向 @param:<Line.id:线路Id;0:上行;data:路段数据> */
  266 +// PublicFunctions.linePanlThree(addLine.id,data,directionData);
  267 +// });
  268 + });
  269 + }
  270 + })
  271 + });
  272 + });
  273 + // 关闭弹出层
  274 + layer.closeAll();
  275 + // 上行
  276 + if(directionData==0){
  277 + $('#stationDown').removeClass('active');
  278 + $('#stationDown').removeClass('in');
  279 + $('#stationDown').addClass('fade');
  280 + $('#stationUp').addClass('active in');
  281 + $('#downLine').parent().removeClass('active');
  282 + $('#upLine').parent().addClass('active');
  283 + // 下行
  284 + }else if(directionData==1){
  285 + $('#stationUp').removeClass('active');
  286 + $('#stationUp').removeClass('in');
  287 + $('#stationUp').addClass('fade');
  288 + $('#stationDown').addClass('active in');
  289 + $('#upLine').parent().removeClass('active');
  290 + $('#downLine').parent().addClass('active');
  291 + }
  292 + } else {
  293 + layer.msg('百度地图中没有此线路,无法系统规划!');
  294 + setTimeout(function() {
  295 + // 关闭弹出层
  296 + layer.closeAll();
  297 + // 上行
  298 + if(directionData==0){
  299 + // 显示上行规划
  300 + $('#upToolsMobal').show();
  301 + // 下行
  302 + }else if(directionData==1){
  303 + // 显示下行规划
  304 + $('#downToolsMobal').show();
  305 + }
  306 + }, 3000);
  307 + }
  308 + });
  309 + },
  310 +
  311 + /** @param directionV_ :方向 */
  312 + stationRevoke : function(directionV_) {
  313 + // 获取树选中节点对象
  314 + var obj = PublicFunctions.getCurrSelNode(directionV_);
  315 + // 是否选中,选中节点是否为站点
  316 + if(obj.length == 0 || obj[0].original.chaildredType !='station'){
  317 + // 弹出提示层
  318 + layer.msg('请先选择要删除的站点!');
  319 + return;
  320 + }
  321 + // 弹出是否撤销提示框
  322 + layer.confirm('你确定要撤销【'+obj[0].text+'】站点吗?', {btn : [ '确定撤销','返回' ],icon: 3, title:'提示' }, function(index){
  323 +
  324 + debugger;
  325 + // 站点路由ID
  326 + var stationRouteId = obj[0].original.stationRouteId;
  327 +
  328 + var Line = LineObj.getLineObj();
  329 +
  330 + clonsole.log(Line);
  331 +
  332 + // 撤销参数集合
  333 + var params = {stationRouteId:stationRouteId,destroy:'1',status:Line.status};
  334 + // 方向
  335 + var stationRouteDirections = obj[0].original.stationRouteDirections;
  336 + // 撤销
  337 + GetAjaxData.stationRouteIsDestroy(params,function(result) {
  338 + // 关闭弹出框
  339 + layer.close(index);
  340 + if(result.status=='SUCCESS'){
  341 + layer.msg('撤销'+(directionV_==0?"上行":"下行")+'站点【'+obj[0].text+'】成功!');
  342 + }else{
  343 + layer.msg('撤销'+(directionV_==0?"上行":"下行")+'站点【'+obj[0].text+'】失败!');
  344 + }
  345 + WorldsBMap.clearMarkAndOverlays();
  346 +
  347 + var ver = $("#versions").val();
  348 +
  349 + // 刷行左边树
  350 + PublicFunctions.resjtreeDate(Line.id,stationRouteDirections,ver);
  351 + /** 查询上行路段信息 @param:<Line.id:线路Id;0:上行> @return:data:路段数据 */
  352 +// GetAjaxData.getSectionRouteInfo(Line.id,stationRouteDirections,ver,function(data) {
  353 +// /** 在地图上画出线路走向 @param:<Line.id:线路Id;0:上行;data:路段数据> */
  354 +// PublicFunctions.linePanlThree(Line.id,data,stationRouteDirections);
  355 +// });
  356 + });
  357 + });
  358 + },
  359 +
  360 + /** @param direction_ :方向 */
  361 + editLinePlan : function(direction_) {
  362 + var sel = PublicFunctions.getCurrSelNode(direction_);
  363 + if(sel.length==0 || sel[0].original.chaildredType !='section'){
  364 + if(direction_=='0') {
  365 + layer.msg('请先选中要编辑的上行路段!');
  366 + }else if(direction_=='1') {
  367 + layer.msg('请先选中要编辑的下行路段!');
  368 + }
  369 + return;
  370 + }
  371 + $('#downLine').addClass('btn disabled');
  372 + $('.btn-circle').addClass('disabled');
  373 + $('#upLine').addClass('btn disabled');
  374 + var editSectionV = sel[0].original;
  375 + EditSectionObj.setEitdSection(editSectionV);
  376 + // 弹出添加失败提示消息,2秒关闭(如果不配置,默认是3秒)
  377 + var yindex = layer.msg('编辑完线路走向后,请双击线路走向区域保存',{ offset: '126px',shift: 0,time: 10000});
  378 + WorldsBMap.editPolyUpline();
  379 + },
  380 +
  381 + setFormValue : function(editStationParmas) {
  382 + // 站点ID
  383 + $('#stationIdInput').val(editStationParmas.stationId);
  384 + // 站点路由ID
  385 + $('#stationRouteIdInput').val(editStationParmas.stationRouteId);
  386 + // 站点路由线路Id
  387 + $('#stationRouteLineInput').val(editStationParmas.stationRouteLine);
  388 + // 线路编码
  389 + $('#lineCodeInput').val(editStationParmas.stationRouteLIneCode);
  390 + // 行业标准
  391 + $('#industryCodeInput').val(editStationParmas.industryCode);
  392 + // 百度坐标点图形集合
  393 + $('#bPolygonGridInput').val(editStationParmas.stationBPolygonGrid);
  394 + // 获取站点名称元素设值
  395 + $('#zdmcInput').val(editStationParmas.stationStationName);
  396 + // 获取站点路由名称元素设值
  397 + $('#stationNameInput').val(editStationParmas.stationStationName);
  398 + // 获取站点编码元素设值
  399 + $('#stationCodInput').val(editStationParmas.stationCode);
  400 + // 获取站点类型元素设值
  401 + // $('#stationMarkSelect').val(editStationParmas.stationRouteStationMark);
  402 + // 获取站点方向元素设值
  403 + $('#stationdirSelect').val(editStationParmas.stationRoutedirections);
  404 + // 获取站点道路编码元素设值
  405 + $('#roadCodingCodInput').val(editStationParmas.stationRoadCoding);
  406 + // 百度地图经纬度坐标中心点
  407 + $('#bJwpointsInput').val(editStationParmas.stationJwpoints);
  408 + if(editStationParmas.stationShapesType=='r') {
  409 + // 获取图形类型元素,并添加值
  410 + $('#shapesTypeSelect').val('圆形');
  411 + }else if(editStationParmas.stationShapesType=='d'){
  412 + $('#radiusGroup').hide();
  413 + $('#shapesTypeSelect').val('多边形');
  414 + }
  415 + // 获取半径元素,并添加值
  416 + $('#radiusInput').val(editStationParmas.stationRadius);
  417 + // 是否撤销
  418 + $('#destroySelect').val(editStationParmas.stationDestroy);
  419 + // 到站时间
  420 + $('#toTimeInput').val(editStationParmas.stationRouteToTime);
  421 + // 到站距离
  422 + $('#distancesInput').val(editStationParmas.stationRouteDistances);
  423 + // 线路版本号
  424 + $('#versionsInput').val(editStationParmas.stationRouteVersions);
  425 + // 描述/说明
  426 + $('#descriptionsTextarea').val(editStationParmas.sttationDescriptions);
  427 + },
  428 +
  429 + setSectionFormValue : function(Section) {
  430 + $('#isRoadeSpeedInput').val(Section.isRoadeSpeed);
  431 + // 路段ID
  432 + $('#sectionIdInput').val(Section.sectionId);
  433 + // 路段路由ID
  434 + $('#sectionRouteIdInput').val(Section.sectionrouteId);
  435 + // 线路ID
  436 + $('#sectionRouteLineInput').val(Section.sectionrouteLine);
  437 + // 线路编码
  438 + $('#lineCodeInput').val(Section.sectionrouteLineCode);
  439 + // 折线坐标集合
  440 + $('#bsectionVectorInput').val(Section.sectionBsectionVector);
  441 + // 路段名称
  442 + $('#sectionNameInput').val(Section.sectionName);
  443 + // 路段编码
  444 + $('#sectionCodeInput').val(Section.sectionCode);
  445 + // 路段序号
  446 + $('#sectionrouteCodeSelect').val(Section.sectionrouteCode);
  447 + // 路段方向
  448 + $('#directionsSection').val(Section.sectionrouteDirections);
  449 + // 道路编码
  450 + $('#roadCodingCodInput').val(Section.sectionRoadCoding);
  451 + // 道路限速
  452 + $('#speedLimitInput').val(Section.sectionSpeedLimet);
  453 + // 路段长度
  454 + $('#sectionDistanceInput').val(Section.sectionDistance);
  455 + // 时长
  456 + $('#sectionTimeInput').val(Section.sectionTime);
  457 + // 版本号
  458 + $('#versionsInput').val(Section.versions);
  459 + },
  460 +
  461 + /** 在地图上画出线路走向 @param:<Line.id:线路Id;0:上行;data:路段数据> */
  462 + linePanlThree : function(lineId,data,direction,version,callback) {
  463 + /** 获取站点路由信息 @param:<Line.id:线路Id;0:上行> @return:<resultdata:站点路由数据> */
  464 + var polyline_center;
  465 + GetAjaxData.getStationRoutePoint(lineId,direction,version,function(resultdata) {
  466 + WorldsBMap.clearMarkAndOverlays();
  467 + // 如果站点路由数据不为空
  468 + if(resultdata.length>0) {
  469 +// var ceter_index = Math.round(resultdata.length / 2);
  470 + var ceterPointsStr = resultdata[0].stationJwpoints;
  471 + var ceterPointsArray = ceterPointsStr.split(' ');
  472 + polyline_center = new BMap.Point(ceterPointsArray[0],ceterPointsArray[1]);
  473 + // 遍历站点路由数据
  474 + for(var s = 0 ; s<resultdata.length;s++) {
  475 + WorldsBMap.drawingUpStationPoint(resultdata[s], s+1);
  476 + }
  477 + }
  478 + data = data[0].children[1];
  479 + // 路段数据长度
  480 + var dataLen = data.children.length;
  481 + // 如果大于零
  482 + if(dataLen>0) {
  483 + WorldsBMap.drawingUpline01(data.children);
  484 + // WorldsBMap.drawingUpline01(polyline_center,data);
  485 + }
  486 + callback && callback(polyline_center);
  487 + });
  488 + },
  489 + /** 加载树 @param:<lineId:线路ID;direction:方向(0:上行;1:下行)> */
  490 + TreeUpOrDown : function(lineId,direction,version) {
  491 +
  492 + /** 获取树结果数据 @param:<lineId:线路ID;direction:方向;callback:回调函数> */
  493 + GetAjaxData.getStation(lineId,direction,version,function(treeDateJson) {
  494 + // 获取返回数据长度
  495 + var len = treeDateJson[0].children[0].children.length;
  496 + // 上行
  497 + if(direction == 0) {
  498 + /** 初始化上行树 @param:<treeDateJson:树数据结构> */
  499 + StationTreeData.upInit(treeDateJson);
  500 + if(len>0) {
  501 + $('#upToolsMobal').hide();
  502 + $('#uptreeMobal').show();
  503 + }else {
  504 + $('#upToolsMobal').show();
  505 + $('#uptreeMobal').hide();
  506 + }
  507 +
  508 + PublicFunctions.linePanlThree(lineId,treeDateJson,direction,version,function (polyline_center) {
  509 + var map = WorldsBMap.getmapBValue();
  510 + map.panTo(polyline_center);
  511 + });
  512 +
  513 + // 下行
  514 + }else if(direction ==1) {
  515 + /** 出事画下行树 @param:<treeDateJson:树数据结构> */
  516 + StationTreeData.downInit(treeDateJson);
  517 + if(len>0) {
  518 + $('#downToolsMobal').hide();
  519 + $('#DowntreeMobal').show();
  520 + }else {
  521 + $('#downToolsMobal').show();
  522 + $('#DowntreeMobal').hide();
  523 + }
  524 + }
  525 + });
  526 + },
  527 + isHaveStationName : function(data) {
  528 + if(data.length>0) {
  529 + layer.confirm('系统已存在【'+ data[0].stationName +'】该站点位置名称,请选择【系统引用】或者更改站点名称进行新增!', {btn : [ '返回' ],icon: 3, title:'提示' }, function(index){
  530 + layer.close(index);
  531 + });
  532 + return false;
  533 + }else {
  534 + return true;
  535 + }
  536 + },
  537 + // 地图处于编辑状态
  538 + editMapStatus : function (dir) {
  539 + WorldsBMap.setMap_status(1);
  540 + // 有方向就显示退出编辑模式按钮
  541 + if(dir!=null && dir!='null'){
  542 + WorldsBMap.setDir(dir);
  543 + $('#esc_edit_div').show();
  544 + }
  545 + $('.protlet-box-layer').show();
  546 + },
  547 + // 地图处于编辑状态
  548 + editMapStatusRemove : function () {
  549 + WorldsBMap.setMap_status(0);
  550 + $('.protlet-box-layer').hide();
  551 + $('#esc_edit_div').hide();
  552 + // 退出绘画模式
  553 + WorldsBMap.exitDrawStatus();
  554 + },
  555 + // 选项鎖死解除
  556 + editAChangeCssRemoveDisabled : function() {
  557 + $('#downLine').removeClass('btn disabled');
  558 + $('.btn-circle').removeClass('disabled');
  559 + $('#upLine').removeClass('btn disabled');
  560 + },
  561 + // 方向代码转名称.
  562 + dirdmToName : function(value){
  563 + var srStr = '';
  564 + if(value=='0')
  565 + srStr = '上行';
  566 + else if(value=='1')
  567 + srStr = '下行';
  568 + return srStr;
  569 + },
  570 + }
  571 + return PubFun ;
572 572 }();
573 573 \ No newline at end of file
... ...