Commit 087e805257ca9b8f463b497a14a3b332d50dc273

Authored by zlz
1 parent 0ff608ab

BUG修复(切换页面,线路输入框失效)

src/main/resources/static/pages/trafficManage/js/lineStationUploadRecord.js
... ... @@ -13,16 +13,59 @@
13 13 */
14 14  
15 15 (function(){
  16 + var page = 0, initPag, storage = window.localStorage;
16 17 // 关闭左侧栏
17 18 if (!$('body').hasClass('page-sidebar-closed'))
18 19 $('.menu-toggler.sidebar-toggler').click();
19   - // 日期控件
20   - $('#dateInput').datetimepicker({
21   - // 日期控件时间格式
22   - format : 'YYYY-MM-DD',
23   - // 语言
24   - locale: 'zh-cn'
25   - });
  20 +
  21 + $("#dateInput").datetimepicker({
  22 + format : 'YYYY-MM-DD',
  23 + locale : 'zh-cn'
  24 + });
  25 +
  26 + function getComp(cb) {
  27 + $.get('/user/companyData',null,function(rs) {
  28 + return cb && cb(rs);
  29 + });
  30 + }
  31 +
  32 + initLineSelect2();
  33 +
  34 + function initLineSelect2(compD) {debugger;
  35 + getComp(function(rs) {
  36 + var params = {};
  37 + if(rs.length>0) {
  38 + var compA = new Array();
  39 + for(var c = 0 ; c<rs.length;c++) {
  40 + var comC = rs[c].companyCode;
  41 + var child = rs[c].children;
  42 + if(child.length>0) {
  43 + for(var d = 0 ;d< child.length;d++) {
  44 + compA.push(comC + '_' + child[d].code);
  45 + }
  46 + }else {
  47 + compA.push(comC);
  48 + }
  49 + }
  50 + params.cgsbm_in = compA.toString();
  51 + }
  52 + // 填充线路拉框选择值
  53 + $get('/line/all', params, function(array){
  54 + var len_ = array.length,paramsD = new Array();
  55 + if(len_>0) {
  56 + $.each(array, function(i, g){
  57 + if(g.name!='' || g.name != null) {
  58 + paramsD.push({'id':g.name + '_' + g.id + '_' + g.lineCode ,'text':g.name});
  59 + }
  60 + });
  61 + initPinYinSelect2($('#line'),paramsD,function(selector) {
  62 + selector.select2("val", storage.xlName_AgursData);
  63 + });
  64 + }
  65 + });
  66 + });
  67 + }
  68 +
26 69 // 日期范围输入框限制,绑定按键和粘贴事件
27 70 $(".dateRange").keyup(function(){
28 71 var tmptxt=$(this).val();
... ... @@ -48,81 +91,91 @@
48 91 if(tmptxt < 0){
49 92 $(this).val(00);
50 93 }
51   - }).css("ime-mode", "disabled");
52   - /**
53   - * 取得编码-公司map
54   - * gsmap["5"] = 南汇公司
55   - * gsmap["5_3"] = 芦潮港分公司
56   - */
57   - function getBusMap(){
58   - // 取得公司信息,替换公司编码
59   - var gsmap = {};
60   - $get('/business/all', null, function(array){
61   - $.each(array, function(i, gs){
62   - var k = gs.upCode + '_' + gs.businessCode;
63   - if(gs.upCode === '88'){
64   - k = gs.businessCode;
65   - }
66   - gsmap[k] = gs.businessName;
67   - });
68   - });
69   - return gsmap;
70   - }
71   - /**
72   - * 设置公司自动完成
73   - */
74   - var lines = new Array();
75   - var gsmap = getBusMap();
76   - // 取得所有线路
77   - $get('/line/all', null, function(allLine) {
78   - // 遍历数组
79   - $.each(allLine, function(i, e) {
80   - var companyCode = e.company;
81   - e.company = gsmap[e.company];
82   - e.brancheCompany = gsmap[companyCode+"_"+e.brancheCompany];
83   - var line = '{"hex":"' + e.company + '","label":"' + e.name
84   - + '"}';
85   - var obj = jQuery.parseJSON(line);
86   - lines[i] = obj;
87   - });
88   - });
89   - // 给输入框绑定autocomplete事件
90   - $("input[name='xl.name_eq']").autocompleter({
91   - highlightMatches : true,
92   - source : lines,
93   - template : '{{ label }} <span>({{ hex }})</span>',
94   - hint : true,
95   - empty : false,
96   - limit : 5,
97   - });
98   - // 设置autocompleter的宽度和输入框一样
99   - $(".autocompleter").css("width",
100   - $("input[name='xl.name_eq']").css("width"));
101   -
102   - /**
103   - * 设置内部编码自动完成
104   - */
105   - var cars = new Array();
106   - // 取得所有车辆
107   - $get('/cars/all', null, function(allCars) {
108   - // 遍历数组
109   - $.each(allCars, function(i, e) {
110   - var car = '{"hex":"' + e.insideCode + '","label":"' + e.insideCode
111   - + '"}';
112   - var obj = jQuery.parseJSON(car);
113   - cars[i] = obj;
114   - });
115   - });
116   - // 给输入框绑定autocomplete事件
117   - $("input[name='xl.insideCode_eq']").autocompleter({
118   - highlightMatches : true,
119   - source : cars,
120   - template : '{{ label }}',
121   - hint : true,
122   - empty : false,
123   - limit : 5,
124   - });
125   - // 设置autocompleter的宽度和输入框一样
126   - $(".autocompleter").css("width",
127   - $("input[name='xl.insideCode_eq']").css("width"));
  94 + }).css("ime-mode", "disabled");
  95 +
  96 + // 绑定查询事件
  97 + $("#search").click(searchM);
  98 + // 查询方法
  99 + function searchM(pagination) {
  100 + if($("#dateInput").val() == ""){
  101 + alert("请选择时间");
  102 + return ;
  103 + }
  104 + if(pagination){
  105 + page = 0;
  106 + }
  107 + var params = {};
  108 + // 排序(按方向与序号)
  109 + params['order'] = 'reportDate';
  110 + // 排序方向.
  111 + params['direction'] = 'ASC';
  112 + // 记录当前页数
  113 + params['page'] = page;
  114 + // 弹出正在加载层
  115 + var i = layer.load(2);
  116 + // 取得输入框的值
  117 + var inputs = $(".form-inline input,select");
  118 + // 遍历数组
  119 + $.each(inputs, function(i, element) {
  120 + params[$(element).attr("name")] = $(element).val();
  121 + });
  122 + var startDate = params['startDate'] == "" ? "0" : params['startDate'];
  123 + var endDate = params['endDate'] == "" ? "23" : params['endDate'];
  124 + var reportDate = params['reportDate'];
  125 + params['reportDate_start'] = reportDate.replace(/-/g,'') + (startDate > 9 ? startDate : "0"+startDate);
  126 + params['reportDate_end'] = reportDate.replace(/-/g,'') + (endDate > 9 ? endDate : "0"+endDate);
  127 + $get('/vehicle_stop/getVehicleInoutStopByParam', params, function(data) {
  128 + var content = data.content;
  129 + _dateFormat(content);
  130 + var bodyHtm = template('lineStationUploadRecord_list_temp', {
  131 + list : content
  132 + });
  133 + $('#vehicle_stop tbody').html(bodyHtm);
  134 + if(pagination && data.content.length > 0){
  135 + //重新分页
  136 + initPag = true;
  137 + showPagination(data);
  138 + }
  139 + layer.close(i);
  140 + });
  141 + }
  142 +
  143 + /** 分页栏组件 */
  144 + function showPagination(data){
  145 + // 分页组件
  146 + $('#pagination').jqPaginator({
  147 + // 总页数
  148 + totalPages: data.totalPages,
  149 + // 中间显示页数
  150 + visiblePages: 6,
  151 + // 当前页
  152 + currentPage: page + 1,
  153 + first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
  154 + prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>',
  155 + next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>',
  156 + last: '<li class="last"><a href="javascript:void(0);">尾页<\/a><\/li>',
  157 + page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
  158 + onPageChange: function (num, type) {
  159 + if(initPag){
  160 + initPag = false;
  161 + return;
  162 + }
  163 + page = num - 1;
  164 + searchM(false);
  165 + }
  166 + });
  167 + }
  168 +
  169 + //转换时间格式
  170 + function _dateFormat(list) {
  171 + var fs = 'YYYY-MM-DD HH:mm:ss';
  172 + $.each(list, function(i, obj) {
  173 + obj['report_date'] = moment(obj['report_date']).format(fs);
  174 + });
  175 + }
  176 +
  177 + // 时间字符串转成时间戳
  178 + function str2datetime(stringTime){
  179 + return Date.parse(new Date(stringTime));
  180 + }
128 181 })();
129 182 \ No newline at end of file
... ...