Commit 980c6efcf63999668c17cc80c59c5834d3b1d488
1 parent
2eac7f71
fixed bug!
Showing
1 changed file
with
448 additions
and
450 deletions
src/main/resources/static/pages/base/line/js/line-list-table.js
| 1 | -/** | |
| 2 | - * | |
| 3 | - * @JSName : line-list-table.js(线路信息list.html页面js) | |
| 4 | - * | |
| 5 | - * @Author : bsth@lq | |
| 6 | - * | |
| 7 | - * @Description : TOOD(线路信息list.html页面js) | |
| 8 | - * | |
| 9 | - * @Data : 2016年4月28日 上午9:21:17 | |
| 10 | - * | |
| 11 | - * @Version 公交调度系统BS版 0.1 | |
| 12 | - * | |
| 13 | - */ | |
| 14 | - | |
| 15 | -(function(){ | |
| 16 | - // 关闭左侧栏 | |
| 17 | - if (!$('body').hasClass('page-sidebar-closed')) {$('.menu-toggler.sidebar-toggler').click();} | |
| 18 | - // 初始化是否撤销值. | |
| 19 | - $('#destroy').val(0); | |
| 20 | - // 定义 page : 当前页;initPag ; icheckOptions:选择框 | |
| 21 | - var page = 0, | |
| 22 | - initPag, | |
| 23 | - icheckOptions = {checkboxClass: 'icheckbox_flat-blue',increaseArea: '20%'}, | |
| 24 | - storage = window.localStorage; | |
| 25 | - if(storage.xlName_AgursData!=null && storage.xlName_AgursData !='') { | |
| 26 | - $('.tipso-animation').children().remove(); | |
| 27 | - // 延迟加载 | |
| 28 | - setTimeout(function(){ | |
| 29 | - $('.tipso-animation').tipso({ | |
| 30 | - speed : 400, | |
| 31 | - background : '#0ed0e8', | |
| 32 | - color : '#ffffff', | |
| 33 | - position :'bottom', | |
| 34 | - width : 400, | |
| 35 | - delay : 100, | |
| 36 | - animationIn : 'fadeInDownBig', | |
| 37 | - animationOut : 'fadeOut', | |
| 38 | - offsetX : -50, | |
| 39 | - offsetY : -195, | |
| 40 | - content :'您可以通过点击重置按钮来清除对线路名称的记忆哦!', | |
| 41 | - | |
| 42 | - }); | |
| 43 | - $('.tipso-animation').tipso('show'); | |
| 44 | - setTimeout(function(){$('.tipso-animation').tipso('hide');},4000); | |
| 45 | - },200); | |
| 46 | - } | |
| 47 | - // 营运公司Map[key(businessCode)] = 名字 | |
| 48 | - var companyMap = new Map(); | |
| 49 | - // 分公司Map[key(upCode+_+businessCode)] = 名字 | |
| 50 | - var branchMap = new Map(); | |
| 51 | - initCompanySelect2(function(array) { | |
| 52 | - $.each(array, function() { | |
| 53 | - companyMap[this.businessCode] = this.businessName; | |
| 54 | - // companyMap.put(this.businessCode.toString(), this.businessName); | |
| 55 | - if(this.businessCode != null || this.businessCode !=''){ | |
| 56 | - /** 查询出所属公司下的分公司名称和相应分公司代码 @param:<upCode_eq:公司代码> */ | |
| 57 | - $get('/business/all', {upCode_eq: this.businessCode}, function(array){ | |
| 58 | - // 遍历array | |
| 59 | - $.each(array, function(i,d){ | |
| 60 | - branchMap[this.upCode+"_"+this.businessCode] = this.businessName; | |
| 61 | - // branchMap.put(this.upCode+"_"+this.businessCode, this.businessName); | |
| 62 | - }); | |
| 63 | - }); | |
| 64 | - } | |
| 65 | - }); | |
| 66 | - // 公司下拉options属性值 | |
| 67 | - var options = '<option value="">请选择...</option>'; | |
| 68 | - // 遍历array | |
| 69 | - $.each(array, function(i,d){ | |
| 70 | - options += '<option value="'+d.businessCode+'">'+d.businessName+'</option>'; | |
| 71 | - }); | |
| 72 | - // 初始化公司下拉框并监听值改变事件. | |
| 73 | - $('#companySelect').html(options).on('change', setBrancheCompanySelectOptions); | |
| 74 | - // 初始化分公司下拉框. | |
| 75 | - setBrancheCompanySelectOptions(); | |
| 76 | - initLineSelect2(array); | |
| 77 | - /** 表格数据分页加载 @param:<null:搜索参数;true:是否重新分页> */ | |
| 78 | - loadTableDate({'destroy_eq':0,'name_like':splitxlName(storage.xlName_AgursData)},true); | |
| 79 | - }); | |
| 80 | - | |
| 81 | - function initLineSelect2(compD) { | |
| 82 | - getComp(function(rs) { | |
| 83 | - var params = {}; | |
| 84 | - if(rs.length>0) { | |
| 85 | - var compA = new Array(); | |
| 86 | - for(var c = 0 ; c<rs.length;c++) { | |
| 87 | - var comC = rs[c].companyCode; | |
| 88 | - var child = rs[c].children; | |
| 89 | - if(child.length>0) { | |
| 90 | - for(var d = 0 ;d< child.length;d++) { | |
| 91 | - compA.push(comC + '_' + child[d].code); | |
| 92 | - } | |
| 93 | - }else { | |
| 94 | - compA.push(comC); | |
| 95 | - } | |
| 96 | - } | |
| 97 | - params.cgsbm_in = compA.toString(); | |
| 98 | - } | |
| 99 | - // 填充线路拉框选择值 | |
| 100 | - $get('/line/all', params, function(array){ | |
| 101 | - var len_ = array.length,paramsD = new Array(); | |
| 102 | - if(len_>0) { | |
| 103 | - $.each(array, function(i, g){ | |
| 104 | - if(g.remove != 1 && (g.name!='' || g.name != null)) { | |
| 105 | - paramsD.push({'id':g.name + '_' + g.id + '_' + g.lineCode ,'text':g.name + gsdmTogsName(compD,g.company)}); | |
| 106 | - } | |
| 107 | - }); | |
| 108 | - if($('span').hasClass('select2-selection')) | |
| 109 | - $('span .select2-selection').remove(); | |
| 110 | - initPinYinSelect2($('#lineSelect'),paramsD,function(selector) { | |
| 111 | - selector.select2("val", storage.xlName_AgursData); | |
| 112 | - }); | |
| 113 | - } | |
| 114 | - }); | |
| 115 | - }); | |
| 116 | - } | |
| 117 | - // 选择线路,填充线路编码搜索框 | |
| 118 | - $("#lineSelect").on("change",function(){ | |
| 119 | - var text = $('#lineSelect').val(); | |
| 120 | - if(text){ | |
| 121 | - var linecode = text.split("_"); | |
| 122 | - $("#lineCodeInput").val(linecode[2]); | |
| 123 | - } | |
| 124 | - }); | |
| 125 | - | |
| 126 | - function gsdmTogsName(gsD,code) { | |
| 127 | - var rsStr = ''; | |
| 128 | - for(var s = 0 ; s < gsD.length; s++) { | |
| 129 | - if(gsD[s].businessCode == code) { | |
| 130 | - rsStr = rsStr + '(' + gsD[s].businessName.replace('公司','') + ')'; | |
| 131 | - break; | |
| 132 | - } | |
| 133 | - } | |
| 134 | - return rsStr; | |
| 135 | - } | |
| 136 | - | |
| 137 | - function initCompanySelect2(cb) { | |
| 138 | - // get请求获取公司 | |
| 139 | - $get('/business/all', {upCode_eq: '88'}, function(gs_d){ | |
| 140 | - return cb && cb(gs_d); | |
| 141 | - }); | |
| 142 | - } | |
| 143 | - function getComp(cb) { | |
| 144 | - $.get('/user/companyData',null,function(rs) { | |
| 145 | - return cb && cb(rs); | |
| 146 | - }); | |
| 147 | - } | |
| 148 | - function getParams() { | |
| 149 | - // cells 集合返回表格中所有(列)单元格的一个数组 | |
| 150 | - var cells = $('tr.filter')[0].cells; | |
| 151 | - // 搜索参数集合 | |
| 152 | - var params = {}; | |
| 153 | - // 搜索字段名称 | |
| 154 | - var name; | |
| 155 | - // 遍历cells数组 | |
| 156 | - $.each(cells, function(i, cell){ | |
| 157 | - // 获取第i列的input或者select集合 | |
| 158 | - var items = $('input,select', cell); | |
| 159 | - // 遍历items集合 | |
| 160 | - for(var j = 0, item; item = items[j++];){ | |
| 161 | - // 获取字段名称 | |
| 162 | - name = $(item).attr('name'); | |
| 163 | - if(name){ | |
| 164 | - // 赋取相对应的值 | |
| 165 | - params[name] = $(item).val(); | |
| 166 | - } | |
| 167 | - } | |
| 168 | - }); | |
| 169 | - return params; | |
| 170 | - } | |
| 171 | - | |
| 172 | - /** 表格数据分页加载事件 @param:<param : 查询参数;isPon : 是否重新分页> */ | |
| 173 | - function loadTableDate(param,isPon){ | |
| 174 | - // 搜索参数 | |
| 175 | - var params = {}; | |
| 176 | - if(param) { | |
| 177 | - params = param; | |
| 178 | - } | |
| 179 | - // 排序(按更新时间) | |
| 180 | - params['order'] = 'id'; | |
| 181 | - // 记录当前页数 | |
| 182 | - params['page'] = page; | |
| 183 | - params['remove_ne'] = 1; | |
| 184 | - // 弹出正在加载层 | |
| 185 | - var i = layer.load(2); | |
| 186 | - getComp(function(rs) { | |
| 187 | - if(rs.length>0) { | |
| 188 | - var compA = new Array(); | |
| 189 | - for(var c = 0 ; c<rs.length;c++) { | |
| 190 | - var comC = rs[c].companyCode; | |
| 191 | - var child = rs[c].children; | |
| 192 | - if(child.length>0) { | |
| 193 | - for(var d = 0 ;d< child.length;d++) { | |
| 194 | - compA.push(comC + '_' + child[d].code); | |
| 195 | - } | |
| 196 | - }else { | |
| 197 | - compA.push(comC); | |
| 198 | - } | |
| 199 | - } | |
| 200 | - params.cgsbm_in = compA.toString(); | |
| 201 | - } | |
| 202 | - // 异步请求获取表格数据 | |
| 203 | - $.get('/line',params,function(result){ | |
| 204 | - // 添加序号 | |
| 205 | - result.content.page = page; | |
| 206 | - $.each(result.content, function(i, data) { | |
| 207 | - result.content[i].gsmc = companyMap[data.company]; | |
| 208 | - result.content[i].fgsmc = branchMap[data.cgsbm]; | |
| 209 | - }); | |
| 210 | - // 把数据填充到模版中 | |
| 211 | - var tbodyHtml = template('line_list_temp',{list:result.content}); | |
| 212 | - // 把渲染好的模版html文本追加到表格中 | |
| 213 | - $('#datatable_line tbody').html(tbodyHtml); | |
| 214 | - // 制定复选框 | |
| 215 | - $('#datatable_line tbody').find('.icheck').iCheck(icheckOptions); | |
| 216 | - // 复选框改变事件 | |
| 217 | - $('#datatable_line tbody').find('.icheck').on('ifChanged', iCheckChange); | |
| 218 | - // 是重新分页且返回数据长度大于0 | |
| 219 | - if(isPon && result.content.length > 0){ | |
| 220 | - // 重新分页 | |
| 221 | - initPag = true; | |
| 222 | - // 分页栏 | |
| 223 | - showPagination(result); | |
| 224 | - } | |
| 225 | - // 关闭弹出加载层 | |
| 226 | - layer.close(i); | |
| 227 | - }); | |
| 228 | - }); | |
| 229 | - } | |
| 230 | - | |
| 231 | - /** 复选框组件 */ | |
| 232 | - function iCheckChange(){ | |
| 233 | - // 获取当前的父节点tr | |
| 234 | - var tr = $(this).parents('tr'); | |
| 235 | - // 判断当前是否选中 | |
| 236 | - if(this.checked) { | |
| 237 | - // 选中,则增添父节点tr的样式 | |
| 238 | - tr.addClass('row-active'); | |
| 239 | - }else { | |
| 240 | - // 未选中,则删除父节点tr的样式 | |
| 241 | - tr.removeClass('row-active'); | |
| 242 | - } | |
| 243 | - } | |
| 244 | - | |
| 245 | - /** 分页栏组件 */ | |
| 246 | - function showPagination(data){ | |
| 247 | - // 分页组件 | |
| 248 | - $('#pagination').jqPaginator({ | |
| 249 | - // 总页数 | |
| 250 | - totalPages: data.totalPages, | |
| 251 | - // 中间显示页数 | |
| 252 | - visiblePages: 6, | |
| 253 | - // 当前页 | |
| 254 | - currentPage: page + 1, | |
| 255 | - first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>', | |
| 256 | - prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>', | |
| 257 | - next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>', | |
| 258 | - last: '<li class="last"><a href="javascript:void(0);">尾页<\/a><\/li>', | |
| 259 | - page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>', | |
| 260 | - onPageChange: function (num, type) { | |
| 261 | - if(initPag){ | |
| 262 | - initPag = false; | |
| 263 | - return; | |
| 264 | - } | |
| 265 | - var pData = getParams(); | |
| 266 | - pData.name_like = splitxlName(pData.name_like); | |
| 267 | - page = num - 1; | |
| 268 | - loadTableDate(pData, false); | |
| 269 | - } | |
| 270 | - }); | |
| 271 | - } | |
| 272 | - /** 填充分公司下拉框选择值 */ | |
| 273 | - function setBrancheCompanySelectOptions(){ | |
| 274 | - // 获取公司下拉框选择值 | |
| 275 | - var businessCode = $('#companySelect').val(); | |
| 276 | - // 分公司下拉框options属性值 | |
| 277 | - var options = '<option value="">请选择...</option>'; | |
| 278 | - // 如果公司选择为空则分公司为空 ; 否则查询出所属公司下的分公司名称和相应分公司代码 | |
| 279 | - if(businessCode == null || businessCode ==''){ | |
| 280 | - // 填充分公司下拉框options | |
| 281 | - $('#brancheCompanySelect').html(options); | |
| 282 | - } else { | |
| 283 | - /** 查询出所属公司下的分公司名称和相应分公司代码 @param:<upCode_eq:公司代码> */ | |
| 284 | - $get('/business/all', {upCode_eq: businessCode}, function(array){ | |
| 285 | - // 遍历array | |
| 286 | - $.each(array, function(i,d){ | |
| 287 | - options += '<option value="'+d.businessCode+'">'+d.businessName+'</option>'; | |
| 288 | - // 填充分公司下拉框options | |
| 289 | - $('#brancheCompanySelect').html(options); | |
| 290 | - }); | |
| 291 | - }); | |
| 292 | - } | |
| 293 | - } | |
| 294 | - | |
| 295 | - /** 重置按钮事件 */ | |
| 296 | - $('tr.filter .filter-cancel').on('click',function() { | |
| 297 | - // 清空搜索框值 | |
| 298 | - $('tr.filter input,select').val('').change(); | |
| 299 | - $('.tipso-animation').tipso('hide'); | |
| 300 | - storage.setItem('xlName_AgursData',''); | |
| 301 | - /** 表格数据分页加载 @param:<null:搜索参数;true:是否重新分页> */ | |
| 302 | - loadTableDate(null,true); | |
| 303 | - }); | |
| 304 | - | |
| 305 | - function splitxlName(str) { | |
| 306 | - var rsStr = ''; | |
| 307 | - if(str) { | |
| 308 | - var strArray = str.split('_'); | |
| 309 | - rsStr = strArray[0]; | |
| 310 | - } | |
| 311 | - return rsStr; | |
| 312 | - } | |
| 313 | - | |
| 314 | - /** 搜索按钮事件 */ | |
| 315 | - $('tr.filter .filter-submit').on('click',function(){ | |
| 316 | - var params = getParams(); | |
| 317 | - if(params.name_like!='' && params.name_like != null) { | |
| 318 | - storage.setItem('xlName_AgursData',params.name_like); | |
| 319 | - } | |
| 320 | - params.name_like = splitxlName(params.name_like); | |
| 321 | - page = 0; | |
| 322 | - /** 表格数据分页加载 @param:<params:搜索参数;true:是否重新分页> */ | |
| 323 | - loadTableDate(params,true); | |
| 324 | - }); | |
| 325 | - /** 生成行单,这里暂时只做了单选生成。 */ | |
| 326 | - $('#datatable_ajax_tools #createUsingSingle').on('click', function() { | |
| 327 | - // 获取选中行. | |
| 328 | - var arrChk = $("input[type='checkbox']:checked"); | |
| 329 | - var len = arrChk.length; | |
| 330 | - // 选中行ID与线路名称 | |
| 331 | - var id = '', lineName = ''; | |
| 332 | - if(len>1) { | |
| 333 | - // 弹出添加成功提示消息 | |
| 334 | - layer.msg('存在多选,请只选中一行!'); | |
| 335 | - return ; | |
| 336 | - }else if(len==0) { | |
| 337 | - // 弹出添加成功提示消息 | |
| 338 | - layer.msg('请选中一条线路!'); | |
| 339 | - return ; | |
| 340 | - }else { | |
| 341 | - layer.open({ | |
| 342 | - id:1, | |
| 343 | - type: 1, | |
| 344 | - title: "线路文件版本号", | |
| 345 | - // skin:'layui-layer-rim', | |
| 346 | - area:['450px', 'auto'], | |
| 347 | - | |
| 348 | - content: '<div class="col-sm-12">' | |
| 349 | - +'<div class="input-group">' | |
| 350 | - +'<span class="input-group-addon"> 线路文件版本号 :</span>' | |
| 351 | - +'<input id="fileVersionsInput" type="text" class="form-control" placeholder="没有填写默认为2">' | |
| 352 | - +'</div>' | |
| 353 | - +'</div>', | |
| 354 | - btn:['确定','取消'], | |
| 355 | - btn1: function (index,layero) { | |
| 356 | - var fileVersions = $('#fileVersionsInput').val(); | |
| 357 | - id = arrChk.data('id'); | |
| 358 | - lineName = arrChk.val(); | |
| 359 | - // 请求参数 | |
| 360 | - var params = {lineId:id, fileVersions:fileVersions}; | |
| 361 | - // 关闭弹出框 | |
| 362 | - layer.close(index); | |
| 363 | - // 弹出正在加载层 | |
| 364 | - var index2 = layer.load(0); | |
| 365 | - /** 生成线路行单 @pararm:<params:请求参数> */ | |
| 366 | - $post('/stationroute/usingSingle',params,function(data) { | |
| 367 | - // 关闭弹出框 | |
| 368 | - layer.close(index2); | |
| 369 | - if(data.status=='SUCCESS') { | |
| 370 | - // 弹出添加成功提示消息 | |
| 371 | - layer.msg('生成线路【'+ lineName +'】线路文件成功!'); | |
| 372 | - }else if(data.status=='ERROR'){ | |
| 373 | - // 弹出添加成功提示消息 | |
| 374 | - layer.msg('生成线路【'+ lineName +'】线路文件失败!'); | |
| 375 | - }else if(data.status=='NOTDATA') { | |
| 376 | - // 弹出添加成功提示消息 | |
| 377 | - layer.msg('系统无线路【'+ lineName +'】的站点与路段信息!'); | |
| 378 | - }else if(data.status=='NOLinePlayType') { | |
| 379 | - // 弹出添加成功提示消息 | |
| 380 | - layer.msg('无法识别【'+ lineName +'】的线路规划类型,请设置为双向/环线!'); | |
| 381 | - } | |
| 382 | - }); | |
| 383 | - }, | |
| 384 | - btn2:function (index,layero) { | |
| 385 | - layer.close(index); | |
| 386 | - } | |
| 387 | - | |
| 388 | - }); | |
| 389 | - } | |
| 390 | - }); | |
| 391 | - /** 生成路线(路段和站点) */ | |
| 392 | - $('#datatable_ajax_tools #editRoute').on('click', function() { | |
| 393 | - // 获取选中行. | |
| 394 | - var arrChk = $("input[type='checkbox']:checked"); | |
| 395 | - var len = arrChk.length; | |
| 396 | - // 选中行ID与线路名称 | |
| 397 | - var id = ''; | |
| 398 | - if(len>1) { | |
| 399 | - // 弹出添加成功提示消息 | |
| 400 | - layer.msg('存在多选,请只选中一行!'); | |
| 401 | - return ; | |
| 402 | - }else if(len==0) { | |
| 403 | - // 弹出添加成功提示消息 | |
| 404 | - layer.msg('请选中一条线路!'); | |
| 405 | - return ; | |
| 406 | - }else { | |
| 407 | - id = arrChk.data('id'); | |
| 408 | - $.get('/lineVersions/findByLineId',{'lineId':id},function(lineVersions){ | |
| 409 | - if(lineVersions != null && lineVersions != "") { | |
| 410 | - window.location.href = "/pages/base/line/map.html?no="+id; | |
| 411 | - } else { | |
| 412 | - layer.msg('此线路没有线路版本,请先到线路版本信息页面添加改线路版本!'); | |
| 413 | - return ; | |
| 414 | - } | |
| 415 | - }); | |
| 416 | - } | |
| 417 | - }); | |
| 418 | - | |
| 419 | - // 导出线路站点 | |
| 420 | - $('#datatable_ajax_tools #exportStation').on('click', function() { | |
| 421 | - // 获取选中行. | |
| 422 | - var arrChk = $("input[type='checkbox']:checked"); | |
| 423 | - var len = arrChk.length; | |
| 424 | - // 选中行ID与线路名称 | |
| 425 | - var id = ''; | |
| 426 | - if(len>1) { | |
| 427 | - // 弹出添加成功提示消息 | |
| 428 | - layer.msg('存在多选,请只选中一行!'); | |
| 429 | - return ; | |
| 430 | - }else if(len==0) { | |
| 431 | - // 弹出添加成功提示消息 | |
| 432 | - layer.msg('请选中一条线路!'); | |
| 433 | - return ; | |
| 434 | - }else { | |
| 435 | - id = arrChk.data('id'); | |
| 436 | - var param = {}; | |
| 437 | - param.id = id; | |
| 438 | - window.open('/stationroute/export?id='+id); | |
| 439 | - | |
| 440 | - /*$.get("/stationroute/export",param,function(result) { | |
| 441 | - if(result.status == "ERROR") { | |
| 442 | - layer.msg("导出文件失败!"); | |
| 443 | - } else if(result.status == "ERROR") { | |
| 444 | - layer.msg("导出文件成功!"); | |
| 445 | - } else { | |
| 446 | - layer.msg("未知异常!"); | |
| 447 | - } | |
| 448 | - });*/ | |
| 449 | - } | |
| 450 | - }); | |
| 1 | +/** | |
| 2 | + * | |
| 3 | + * @JSName : line-list-table.js(线路信息list.html页面js) | |
| 4 | + * | |
| 5 | + * @Author : bsth@lq | |
| 6 | + * | |
| 7 | + * @Description : TOOD(线路信息list.html页面js) | |
| 8 | + * | |
| 9 | + * @Data : 2016年4月28日 上午9:21:17 | |
| 10 | + * | |
| 11 | + * @Version 公交调度系统BS版 0.1 | |
| 12 | + * | |
| 13 | + */ | |
| 14 | + | |
| 15 | +(function(){ | |
| 16 | + // 关闭左侧栏 | |
| 17 | + if (!$('body').hasClass('page-sidebar-closed')) {$('.menu-toggler.sidebar-toggler').click();} | |
| 18 | + // 初始化是否撤销值. | |
| 19 | + $('#destroy').val(0); | |
| 20 | + // 定义 page : 当前页;initPag ; icheckOptions:选择框 | |
| 21 | + var page = 0, | |
| 22 | + initPag, | |
| 23 | + icheckOptions = {checkboxClass: 'icheckbox_flat-blue',increaseArea: '20%'}, | |
| 24 | + storage = window.localStorage; | |
| 25 | + if(storage.xlName_AgursData!=null && storage.xlName_AgursData !='') { | |
| 26 | + $('.tipso-animation').children().remove(); | |
| 27 | + // 延迟加载 | |
| 28 | + setTimeout(function(){ | |
| 29 | + $('.tipso-animation').tipso({ | |
| 30 | + speed : 400, | |
| 31 | + background : '#0ed0e8', | |
| 32 | + color : '#ffffff', | |
| 33 | + position :'bottom', | |
| 34 | + width : 400, | |
| 35 | + delay : 100, | |
| 36 | + animationIn : 'fadeInDownBig', | |
| 37 | + animationOut : 'fadeOut', | |
| 38 | + offsetX : -50, | |
| 39 | + offsetY : -195, | |
| 40 | + content :'您可以通过点击重置按钮来清除对线路名称的记忆哦!', | |
| 41 | + | |
| 42 | + }); | |
| 43 | + $('.tipso-animation').tipso('show'); | |
| 44 | + setTimeout(function(){$('.tipso-animation').tipso('hide');},4000); | |
| 45 | + },200); | |
| 46 | + } | |
| 47 | + // 营运公司Map[key(businessCode)] = 名字 | |
| 48 | + var companyMap = new Map(); | |
| 49 | + // 分公司Map[key(upCode+_+businessCode)] = 名字 | |
| 50 | + var branchMap = new Map(); | |
| 51 | + initCompanySelect2(function(array) { | |
| 52 | + $.each(array, function() { | |
| 53 | + companyMap[this.businessCode] = this.businessName; | |
| 54 | + // companyMap.put(this.businessCode.toString(), this.businessName); | |
| 55 | + if(this.businessCode != null || this.businessCode !=''){ | |
| 56 | + /** 查询出所属公司下的分公司名称和相应分公司代码 @param:<upCode_eq:公司代码> */ | |
| 57 | + $get('/business/all', {upCode_eq: this.businessCode}, function(array){ | |
| 58 | + // 遍历array | |
| 59 | + $.each(array, function(i,d){ | |
| 60 | + branchMap[this.upCode+"_"+this.businessCode] = this.businessName; | |
| 61 | + // branchMap.put(this.upCode+"_"+this.businessCode, this.businessName); | |
| 62 | + }); | |
| 63 | + }); | |
| 64 | + } | |
| 65 | + }); | |
| 66 | + // 公司下拉options属性值 | |
| 67 | + var options = '<option value="">请选择...</option>'; | |
| 68 | + // 遍历array | |
| 69 | + $.each(array, function(i,d){ | |
| 70 | + options += '<option value="'+d.businessCode+'">'+d.businessName+'</option>'; | |
| 71 | + }); | |
| 72 | + // 初始化公司下拉框并监听值改变事件. | |
| 73 | + $('#companySelect').html(options).on('change', setBrancheCompanySelectOptions); | |
| 74 | + // 初始化分公司下拉框. | |
| 75 | + setBrancheCompanySelectOptions(); | |
| 76 | + initLineSelect2(array); | |
| 77 | + /** 表格数据分页加载 @param:<null:搜索参数;true:是否重新分页> */ | |
| 78 | + loadTableDate({'destroy_eq':0,'name_like':splitxlName(storage.xlName_AgursData)},true); | |
| 79 | + }); | |
| 80 | + | |
| 81 | + function initLineSelect2(compD) { | |
| 82 | + getComp(function(rs) { | |
| 83 | + var params = {}; | |
| 84 | + if(rs.length>0) { | |
| 85 | + var compA = new Array(); | |
| 86 | + for(var c = 0 ; c<rs.length;c++) { | |
| 87 | + var comC = rs[c].companyCode; | |
| 88 | + var child = rs[c].children; | |
| 89 | + if(child.length>0) { | |
| 90 | + for(var d = 0 ;d< child.length;d++) { | |
| 91 | + compA.push(comC + '_' + child[d].code); | |
| 92 | + } | |
| 93 | + }else { | |
| 94 | + compA.push(comC); | |
| 95 | + } | |
| 96 | + } | |
| 97 | + params.cgsbm_in = compA.toString(); | |
| 98 | + } | |
| 99 | + // 填充线路拉框选择值 | |
| 100 | + $get('/line/all', params, function(array){ | |
| 101 | + var len_ = array.length,paramsD = new Array(); | |
| 102 | + if(len_>0) { | |
| 103 | + $.each(array, function(i, g){ | |
| 104 | + if(g.remove != 1 && (g.name!='' || g.name != null)) { | |
| 105 | + paramsD.push({'id':g.name + '_' + g.id + '_' + g.lineCode ,'text':g.name + gsdmTogsName(compD,g.company)}); | |
| 106 | + } | |
| 107 | + }); | |
| 108 | + if($('span').hasClass('select2-selection')) | |
| 109 | + $('span .select2-selection').remove(); | |
| 110 | + initPinYinSelect2($('#lineSelect'),paramsD,function(selector) { | |
| 111 | + selector.select2("val", storage.xlName_AgursData); | |
| 112 | + }); | |
| 113 | + } | |
| 114 | + }); | |
| 115 | + }); | |
| 116 | + } | |
| 117 | + // 选择线路,填充线路编码搜索框 | |
| 118 | + $("#lineSelect").on("change",function(){ | |
| 119 | + var text = $('#lineSelect').val(); | |
| 120 | + if(text){ | |
| 121 | + var linecode = text.split("_"); | |
| 122 | + $("#lineCodeInput").val(linecode[2]); | |
| 123 | + } | |
| 124 | + }); | |
| 125 | + | |
| 126 | + function gsdmTogsName(gsD,code) { | |
| 127 | + var rsStr = ''; | |
| 128 | + for(var s = 0 ; s < gsD.length; s++) { | |
| 129 | + if(gsD[s].businessCode == code) { | |
| 130 | + rsStr = rsStr + '(' + gsD[s].businessName.replace('公司','') + ')'; | |
| 131 | + break; | |
| 132 | + } | |
| 133 | + } | |
| 134 | + return rsStr; | |
| 135 | + } | |
| 136 | + | |
| 137 | + function initCompanySelect2(cb) { | |
| 138 | + // get请求获取公司 | |
| 139 | + $get('/business/all', {upCode_eq: '88'}, function(gs_d){ | |
| 140 | + return cb && cb(gs_d); | |
| 141 | + }); | |
| 142 | + } | |
| 143 | + function getComp(cb) { | |
| 144 | + $.get('/user/companyData',null,function(rs) { | |
| 145 | + return cb && cb(rs); | |
| 146 | + }); | |
| 147 | + } | |
| 148 | + function getParams() { | |
| 149 | + // cells 集合返回表格中所有(列)单元格的一个数组 | |
| 150 | + var cells = $('tr.filter')[0].cells; | |
| 151 | + // 搜索参数集合 | |
| 152 | + var params = {}; | |
| 153 | + // 搜索字段名称 | |
| 154 | + var name; | |
| 155 | + // 遍历cells数组 | |
| 156 | + $.each(cells, function(i, cell){ | |
| 157 | + // 获取第i列的input或者select集合 | |
| 158 | + var items = $('input,select', cell); | |
| 159 | + // 遍历items集合 | |
| 160 | + for(var j = 0, item; item = items[j++];){ | |
| 161 | + // 获取字段名称 | |
| 162 | + name = $(item).attr('name'); | |
| 163 | + if(name){ | |
| 164 | + // 赋取相对应的值 | |
| 165 | + params[name] = $(item).val(); | |
| 166 | + } | |
| 167 | + } | |
| 168 | + }); | |
| 169 | + return params; | |
| 170 | + } | |
| 171 | + | |
| 172 | + /** 表格数据分页加载事件 @param:<param : 查询参数;isPon : 是否重新分页> */ | |
| 173 | + function loadTableDate(param,isPon){ | |
| 174 | + // 搜索参数 | |
| 175 | + var params = {}; | |
| 176 | + if(param) { | |
| 177 | + params = param; | |
| 178 | + } | |
| 179 | + // 排序(按更新时间) | |
| 180 | + params['order'] = 'id'; | |
| 181 | + // 记录当前页数 | |
| 182 | + params['page'] = page; | |
| 183 | + params['remove_ne'] = 1; | |
| 184 | + // 弹出正在加载层 | |
| 185 | + var i = layer.load(2); | |
| 186 | + getComp(function(rs) { | |
| 187 | + if(rs.length>0) { | |
| 188 | + var compA = new Array(); | |
| 189 | + for(var c = 0 ; c<rs.length;c++) { | |
| 190 | + var comC = rs[c].companyCode; | |
| 191 | + var child = rs[c].children; | |
| 192 | + if(child.length>0) { | |
| 193 | + for(var d = 0 ;d< child.length;d++) { | |
| 194 | + compA.push(comC + '_' + child[d].code); | |
| 195 | + } | |
| 196 | + }else { | |
| 197 | + compA.push(comC); | |
| 198 | + } | |
| 199 | + } | |
| 200 | + params.cgsbm_in = compA.toString(); | |
| 201 | + } | |
| 202 | + // 异步请求获取表格数据 | |
| 203 | + $.get('/line',params,function(result){ | |
| 204 | + // 添加序号 | |
| 205 | + result.content.page = page; | |
| 206 | + $.each(result.content, function(i, data) { | |
| 207 | + result.content[i].gsmc = companyMap[data.company]; | |
| 208 | + result.content[i].fgsmc = branchMap[data.cgsbm]; | |
| 209 | + }); | |
| 210 | + // 把数据填充到模版中 | |
| 211 | + var tbodyHtml = template('line_list_temp',{list:result.content}); | |
| 212 | + // 把渲染好的模版html文本追加到表格中 | |
| 213 | + $('#datatable_line tbody').html(tbodyHtml); | |
| 214 | + // 制定复选框 | |
| 215 | + $('#datatable_line tbody').find('.icheck').iCheck(icheckOptions); | |
| 216 | + // 复选框改变事件 | |
| 217 | + $('#datatable_line tbody').find('.icheck').on('ifChanged', iCheckChange); | |
| 218 | + // 是重新分页且返回数据长度大于0 | |
| 219 | + if(isPon && result.content.length > 0){ | |
| 220 | + // 重新分页 | |
| 221 | + initPag = true; | |
| 222 | + // 分页栏 | |
| 223 | + showPagination(result); | |
| 224 | + } | |
| 225 | + // 关闭弹出加载层 | |
| 226 | + layer.close(i); | |
| 227 | + }); | |
| 228 | + }); | |
| 229 | + } | |
| 230 | + | |
| 231 | + /** 复选框组件 */ | |
| 232 | + function iCheckChange(){ | |
| 233 | + // 获取当前的父节点tr | |
| 234 | + var tr = $(this).parents('tr'); | |
| 235 | + // 判断当前是否选中 | |
| 236 | + if(this.checked) { | |
| 237 | + // 选中,则增添父节点tr的样式 | |
| 238 | + tr.addClass('row-active'); | |
| 239 | + }else { | |
| 240 | + // 未选中,则删除父节点tr的样式 | |
| 241 | + tr.removeClass('row-active'); | |
| 242 | + } | |
| 243 | + } | |
| 244 | + | |
| 245 | + /** 分页栏组件 */ | |
| 246 | + function showPagination(data){ | |
| 247 | + // 分页组件 | |
| 248 | + $('#pagination').jqPaginator({ | |
| 249 | + // 总页数 | |
| 250 | + totalPages: data.totalPages, | |
| 251 | + // 中间显示页数 | |
| 252 | + visiblePages: 6, | |
| 253 | + // 当前页 | |
| 254 | + currentPage: page + 1, | |
| 255 | + first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>', | |
| 256 | + prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>', | |
| 257 | + next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>', | |
| 258 | + last: '<li class="last"><a href="javascript:void(0);">尾页<\/a><\/li>', | |
| 259 | + page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>', | |
| 260 | + onPageChange: function (num, type) { | |
| 261 | + if(initPag){ | |
| 262 | + initPag = false; | |
| 263 | + return; | |
| 264 | + } | |
| 265 | + var pData = getParams(); | |
| 266 | + pData.name_like = splitxlName(pData.name_like); | |
| 267 | + page = num - 1; | |
| 268 | + loadTableDate(pData, false); | |
| 269 | + } | |
| 270 | + }); | |
| 271 | + } | |
| 272 | + /** 填充分公司下拉框选择值 */ | |
| 273 | + function setBrancheCompanySelectOptions(){ | |
| 274 | + // 获取公司下拉框选择值 | |
| 275 | + var businessCode = $('#companySelect').val(); | |
| 276 | + // 分公司下拉框options属性值 | |
| 277 | + var options = '<option value="">请选择...</option>'; | |
| 278 | + // 如果公司选择为空则分公司为空 ; 否则查询出所属公司下的分公司名称和相应分公司代码 | |
| 279 | + if(businessCode == null || businessCode ==''){ | |
| 280 | + // 填充分公司下拉框options | |
| 281 | + $('#brancheCompanySelect').html(options); | |
| 282 | + } else { | |
| 283 | + /** 查询出所属公司下的分公司名称和相应分公司代码 @param:<upCode_eq:公司代码> */ | |
| 284 | + $get('/business/all', {upCode_eq: businessCode}, function(array){ | |
| 285 | + // 遍历array | |
| 286 | + $.each(array, function(i,d){ | |
| 287 | + options += '<option value="'+d.businessCode+'">'+d.businessName+'</option>'; | |
| 288 | + // 填充分公司下拉框options | |
| 289 | + $('#brancheCompanySelect').html(options); | |
| 290 | + }); | |
| 291 | + }); | |
| 292 | + } | |
| 293 | + } | |
| 294 | + | |
| 295 | + /** 重置按钮事件 */ | |
| 296 | + $('tr.filter .filter-cancel').on('click',function() { | |
| 297 | + // 清空搜索框值 | |
| 298 | + $('tr.filter input,select').val('').change(); | |
| 299 | + $('.tipso-animation').tipso('hide'); | |
| 300 | + storage.setItem('xlName_AgursData',''); | |
| 301 | + /** 表格数据分页加载 @param:<null:搜索参数;true:是否重新分页> */ | |
| 302 | + loadTableDate(null,true); | |
| 303 | + }); | |
| 304 | + | |
| 305 | + function splitxlName(str) { | |
| 306 | + var rsStr = ''; | |
| 307 | + if(str) { | |
| 308 | + var strArray = str.split('_'); | |
| 309 | + rsStr = strArray[0]; | |
| 310 | + } | |
| 311 | + return rsStr; | |
| 312 | + } | |
| 313 | + | |
| 314 | + /** 搜索按钮事件 */ | |
| 315 | + $('tr.filter .filter-submit').on('click',function(){ | |
| 316 | + var params = getParams(); | |
| 317 | + if(params.name_like!='' && params.name_like != null) { | |
| 318 | + storage.setItem('xlName_AgursData',params.name_like); | |
| 319 | + } | |
| 320 | + params.name_like = splitxlName(params.name_like); | |
| 321 | + page = 0; | |
| 322 | + /** 表格数据分页加载 @param:<params:搜索参数;true:是否重新分页> */ | |
| 323 | + loadTableDate(params,true); | |
| 324 | + }); | |
| 325 | + /** 生成行单,这里暂时只做了单选生成。 */ | |
| 326 | + $('#datatable_ajax_tools #createUsingSingle').on('click', function() { | |
| 327 | + // 获取选中行. | |
| 328 | + var arrChk = $("input[type='checkbox']:checked"); | |
| 329 | + var len = arrChk.length; | |
| 330 | + // 选中行ID与线路名称 | |
| 331 | + var id = '', lineName = ''; | |
| 332 | + if(len>1) { | |
| 333 | + // 弹出添加成功提示消息 | |
| 334 | + layer.msg('存在多选,请只选中一行!'); | |
| 335 | + return ; | |
| 336 | + }else if(len==0) { | |
| 337 | + // 弹出添加成功提示消息 | |
| 338 | + layer.msg('请选中一条线路!'); | |
| 339 | + return ; | |
| 340 | + }else { | |
| 341 | + layer.open({ | |
| 342 | + title: "线路文件版本号", | |
| 343 | + // skin:'layui-layer-rim', | |
| 344 | + area:['450px', 'auto'], | |
| 345 | + | |
| 346 | + content: '<div class="col-sm-12">' | |
| 347 | + +'<div class="input-group">' | |
| 348 | + +'<span class="input-group-addon"> 线路文件版本号 :</span>' | |
| 349 | + +'<input id="fileVersionsInput" type="text" class="form-control" placeholder="没有填写默认为2">' | |
| 350 | + +'</div>' | |
| 351 | + +'</div>', | |
| 352 | + btn:['确定','取消'], | |
| 353 | + btn1: function (index,layero) { | |
| 354 | + var fileVersions = $('#fileVersionsInput').val(); | |
| 355 | + id = arrChk.data('id'); | |
| 356 | + lineName = arrChk.val(); | |
| 357 | + // 请求参数 | |
| 358 | + var params = {lineId:id, fileVersions:fileVersions}; | |
| 359 | + // 关闭弹出框 | |
| 360 | + layer.close(index); | |
| 361 | + // 弹出正在加载层 | |
| 362 | + var index2 = layer.load(0); | |
| 363 | + /** 生成线路行单 @pararm:<params:请求参数> */ | |
| 364 | + $post('/stationroute/usingSingle',params,function(data) { | |
| 365 | + // 关闭弹出框 | |
| 366 | + layer.close(index2); | |
| 367 | + if(data.status=='SUCCESS') { | |
| 368 | + // 弹出添加成功提示消息 | |
| 369 | + layer.msg('生成线路【'+ lineName +'】线路文件成功!'); | |
| 370 | + }else if(data.status=='ERROR'){ | |
| 371 | + // 弹出添加成功提示消息 | |
| 372 | + layer.msg('生成线路【'+ lineName +'】线路文件失败!'); | |
| 373 | + }else if(data.status=='NOTDATA') { | |
| 374 | + // 弹出添加成功提示消息 | |
| 375 | + layer.msg('系统无线路【'+ lineName +'】的站点与路段信息!'); | |
| 376 | + }else if(data.status=='NOLinePlayType') { | |
| 377 | + // 弹出添加成功提示消息 | |
| 378 | + layer.msg('无法识别【'+ lineName +'】的线路规划类型,请设置为双向/环线!'); | |
| 379 | + } | |
| 380 | + }); | |
| 381 | + }, | |
| 382 | + btn2:function (index,layero) { | |
| 383 | + layer.close(index); | |
| 384 | + } | |
| 385 | + | |
| 386 | + }); | |
| 387 | + } | |
| 388 | + }); | |
| 389 | + /** 生成路线(路段和站点) */ | |
| 390 | + $('#datatable_ajax_tools #editRoute').on('click', function() { | |
| 391 | + // 获取选中行. | |
| 392 | + var arrChk = $("input[type='checkbox']:checked"); | |
| 393 | + var len = arrChk.length; | |
| 394 | + // 选中行ID与线路名称 | |
| 395 | + var id = ''; | |
| 396 | + if(len>1) { | |
| 397 | + // 弹出添加成功提示消息 | |
| 398 | + layer.msg('存在多选,请只选中一行!'); | |
| 399 | + return ; | |
| 400 | + }else if(len==0) { | |
| 401 | + // 弹出添加成功提示消息 | |
| 402 | + layer.msg('请选中一条线路!'); | |
| 403 | + return ; | |
| 404 | + }else { | |
| 405 | + id = arrChk.data('id'); | |
| 406 | + $.get('/lineVersions/findByLineId',{'lineId':id},function(lineVersions){ | |
| 407 | + if(lineVersions != null && lineVersions != "") { | |
| 408 | + window.location.href = "/pages/base/line/map.html?no="+id; | |
| 409 | + } else { | |
| 410 | + layer.msg('此线路没有线路版本,请先到线路版本信息页面添加改线路版本!'); | |
| 411 | + return ; | |
| 412 | + } | |
| 413 | + }); | |
| 414 | + } | |
| 415 | + }); | |
| 416 | + | |
| 417 | + // 导出线路站点 | |
| 418 | + $('#datatable_ajax_tools #exportStation').on('click', function() { | |
| 419 | + // 获取选中行. | |
| 420 | + var arrChk = $("input[type='checkbox']:checked"); | |
| 421 | + var len = arrChk.length; | |
| 422 | + // 选中行ID与线路名称 | |
| 423 | + var id = ''; | |
| 424 | + if(len>1) { | |
| 425 | + // 弹出添加成功提示消息 | |
| 426 | + layer.msg('存在多选,请只选中一行!'); | |
| 427 | + return ; | |
| 428 | + }else if(len==0) { | |
| 429 | + // 弹出添加成功提示消息 | |
| 430 | + layer.msg('请选中一条线路!'); | |
| 431 | + return ; | |
| 432 | + }else { | |
| 433 | + id = arrChk.data('id'); | |
| 434 | + var param = {}; | |
| 435 | + param.id = id; | |
| 436 | + window.open('/stationroute/export?id='+id); | |
| 437 | + | |
| 438 | + /*$.get("/stationroute/export",param,function(result) { | |
| 439 | + if(result.status == "ERROR") { | |
| 440 | + layer.msg("导出文件失败!"); | |
| 441 | + } else if(result.status == "ERROR") { | |
| 442 | + layer.msg("导出文件成功!"); | |
| 443 | + } else { | |
| 444 | + layer.msg("未知异常!"); | |
| 445 | + } | |
| 446 | + });*/ | |
| 447 | + } | |
| 448 | + }); | |
| 451 | 449 | })(); |
| 452 | 450 | \ No newline at end of file | ... | ... |