Commit 39e5b0936d354b5666046ca75c521a7e46fb7155

Authored by zlz
1 parent 952eab02

运管处路单上传BUG修改

src/main/resources/static/pages/trafficManage/js/timeTempletUploadRecord.js
... ... @@ -13,6 +13,7 @@
13 13 */
14 14  
15 15 (function(){
  16 + var page = 0, initPagination;
16 17 // 关闭左侧栏
17 18 if (!$('body').hasClass('page-sidebar-closed'))
18 19 $('.menu-toggler.sidebar-toggler').click();
... ... @@ -69,6 +70,49 @@
69 70 $('#brancheCompanySelect').html(options).on('change', setLineAutocompleteOptions);
70 71 }
71 72 }
  73 +
  74 + function setLineAutocompleteOptions(){
  75 + // 搜索参数集合
  76 + var params = {};
  77 + // 搜索字段名称
  78 + var name;
  79 + var items = $("ul.breadcrumb select");
  80 + // 遍历items集合
  81 + for(var j = 0, item; item = items[j++];){
  82 + // 获取字段名称
  83 + name = $(item).attr('name');
  84 + if(name){
  85 + // 赋取相对应的值
  86 + params[name] = $(item).val();
  87 + }
  88 + }
  89 + var lines = new Array();
  90 + var gsmap = getBusMap();
  91 + // 取得所有线路
  92 + $get('/line/all', params, function(allLine) {
  93 + // 遍历数组
  94 + $.each(allLine, function(i, e) {
  95 + var companyCode = e.company;
  96 + e.company = gsmap[e.company];
  97 + e.brancheCompany = gsmap[companyCode+"_"+e.brancheCompany];
  98 + var line = '{"hex":"'+e.company+'","label":"'+e.name+'"}';
  99 + var obj = jQuery.parseJSON(line);
  100 + lines[i]= obj;
  101 + });
  102 +
  103 +
  104 + });
  105 + // 给输入框绑定autocomplete事件
  106 + $("#line_name").autocompleter({
  107 + highlightMatches: true,
  108 + source: lines,
  109 + template: '{{ label }} <span>({{ hex }})</span>',
  110 + hint: true,
  111 + empty: false,
  112 + limit: 5,
  113 + });
  114 + }
  115 +
72 116 // 日期控件
73 117 $('#dateInput').datetimepicker({
74 118 // 日期控件时间格式
... ... @@ -140,7 +184,7 @@
140 184 });
141 185 });
142 186 // 给输入框绑定autocomplete事件
143   - $("input[name='xl.name_eq']").autocompleter({
  187 + $("#line_name").autocompleter({
144 188 highlightMatches : true,
145 189 source : lines,
146 190 template : '{{ label }} <span>({{ hex }})</span>',
... ... @@ -150,5 +194,66 @@
150 194 });
151 195 // 设置autocompleter的宽度和输入框一样
152 196 $(".autocompleter").css("width",
153   - $("input[name='xl.name_eq']").css("width"));
  197 + $("#line_name").css("width"));
  198 +
  199 + searchM(null, true);
  200 + // 绑定查询事件
  201 + $("#search").click(searchM);
  202 + // 查询方法
  203 + function searchM(p, pagination) {
  204 + var params = {};
  205 + // 取得输入框的值
  206 + var inputs = $(".breadcrumb input,select");
  207 + // 遍历数组
  208 + $.each(inputs, function(i, element) {
  209 + params[$(element).attr("name")] = $(element).val();
  210 + });
  211 + var i = layer.load(2);
  212 + $get('/skb_log', params, function(data) {
  213 + var content = data.content;
  214 + _dateFormat(content);
  215 + var bodyHtm = template('timeTempletUploadRecord_list_temp', {
  216 + list : content
  217 + });
  218 + $('#datatable_logger tbody').html(bodyHtm);
  219 + if(pagination && data.content.length > 0){
  220 + //重新分页
  221 + initPagination = true;
  222 + showPagination(data);
  223 + }
  224 + layer.close(i);
  225 + });
  226 + }
  227 +
  228 + //转换时间格式
  229 + function _dateFormat(list) {
  230 + var fs = 'YYYY-MM-DD HH:mm';
  231 + $.each(list, function(i, obj) {
  232 + obj.createDate = moment(obj.createDate).format(fs);
  233 + });
  234 + }
  235 +
  236 + function showPagination(data){
  237 + //分页
  238 + $('#pagination').jqPaginator({
  239 + totalPages: data.totalPages,
  240 + visiblePages: 6,
  241 + currentPage: page + 1,
  242 + first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
  243 + prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>',
  244 + next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>',
  245 + last: '<li class="last"><a href="javascript:void(0);">尾页<\/a><\/li>',
  246 + page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
  247 + onPageChange: function (num, type) {
  248 + if(initPagination){
  249 + initPagination = false;
  250 + return;
  251 + }
  252 +
  253 +
  254 + page = num - 1;
  255 + searchM(null, false);
  256 + }
  257 + });
  258 + }
154 259 })();
155 260 \ No newline at end of file
... ...