Commit 3cdc25c04fe5152e0a522dcbfcfa110f53047cf7

Authored by zlz
1 parent 9c22aadc

运管处路单上传BUG修改

src/main/resources/static/pages/trafficManage/js/lineStationUpload.js
... ... @@ -13,124 +13,46 @@
13 13 */
14 14  
15 15 (function(){
16   - /**
17   - * 取得编码-公司map
18   - * gsmap["5"] = 南汇公司
19   - * gsmap["5_3"] = 芦潮港分公司
20   - */
21   - function getBusMap(){
22   - // 取得公司信息,替换公司编码
23   - var gsmap = {};
24   - $get('/business/all', null, function(array){
25   - $.each(array, function(i, gs){
26   - var k = gs.upCode + '_' + gs.businessCode;
27   - if(gs.upCode === '88'){
28   - k = gs.businessCode;
29   - }
30   - gsmap[k] = gs.businessName;
31   - });
32   - });
33   - return gsmap;
34   - }
35   - // 填充公司下拉框选择值
36   - $get('/business/all', {upCode_eq: '88'}, function(array){
37   -
38   - // 公司下拉options属性值
39   - var options = '<option value="">请选择...</option>';
40   -
41   - // 遍历array
42   - $.each(array, function(i,d){
43   -
44   - options += '<option value="'+d.businessCode+'">'+d.businessName+'</option>';
45   -
46   - });
47   -
48   - // 填充公司下拉框options,并添加公司下拉框值改变事件setbrancheCompanySelectOptions
49   - $('#companySelect').html(options).on('change', setbrancheCompanySelectOptions);
50   -
51   - });
52   -
53   - // 填充分公司下拉框选择值
54   - function setbrancheCompanySelectOptions(){
55   -
56   - // 获取公司下拉框选择值
57   - var businessCode = $('#companySelect').val();
58   -
59   - // 分公司下拉框options属性值
60   - var options = '<option value="">请选择...</option>';
61   -
62   - // 如果公司选择为空则分公司为空 ; 否则查询出所属公司下的分公司名称和相应分公司代码
63   - if(businessCode == null || businessCode ==''){
64   -
65   - // 填充分公司下拉框options
66   - $('#brancheCompanySelect').html(options);
67   -
68   - } else {
69   -
70   - // 查询出所属公司下的分公司名称和相应分公司代码
71   - $get('/business/all', {upCode_eq: businessCode}, function(array){
72   -
73   - // 遍历array
74   - $.each(array, function(i,d){
75   -
76   - options += '<option value="'+d.businessCode+'">'+d.businessName+'</option>';
77   -
78   - // 填充分公司下拉框options
79   - $('#brancheCompanySelect').html(options);
80   -
81   - });
82   - });
83   -
84   - // 填充公司下拉框options,并添加公司下拉框值改变事件setbrancheCompanySelectOptions
85   - $('#brancheCompanySelect').html(options).on('change', setLineAutocompleteOptions);
86   - }
87   - }
88   -
89   - function setLineAutocompleteOptions(){
90   - // 搜索参数集合
91   - var params = {};
92   - // 搜索字段名称
93   - var name;
94   - var items = $("ul.breadcrumb select");
95   - // 遍历items集合
96   - for(var j = 0, item; item = items[j++];){
97   - // 获取字段名称
98   - name = $(item).attr('name');
99   - if(name){
100   - // 赋取相对应的值
101   - params[name] = $(item).val();
102   - }
103   - }
104   - var lines = new Array();
105   - var gsmap = getBusMap();
106   - // 取得所有线路
107   - $get('/line/all', params, function(allLine) {
108   - // 遍历数组
109   - $.each(allLine, function(i, e) {
110   - var companyCode = e.company;
111   - e.company = gsmap[e.company];
112   - e.brancheCompany = gsmap[companyCode+"_"+e.brancheCompany];
113   - var line = '{"hex":"'+e.company+'","label":"'+e.name+'"}';
114   - var obj = jQuery.parseJSON(line);
115   - lines[i]= obj;
116   - });
117   -
118   -
119   - });
120   - // 给输入框绑定autocomplete事件
121   - $("input[name='name_eq']").autocompleter({
122   - highlightMatches: true,
123   - source: lines,
124   - template: '{{ label }} <span>({{ hex }})</span>',
125   - hint: true,
126   - empty: false,
127   - limit: 5,
128   - });
129   - }
130   -
131   -
132   - // 设置autocompleter的宽度和输入框一样
133   - $(".autocompleter").css("width",$("input[name='name_eq']").css("width"))
  16 +
  17 + $('#line').select2({
  18 + ajax: {
  19 + url: '/realSchedule/findLine',
  20 + type: 'post',
  21 + dataType: 'json',
  22 + delay: 150,
  23 + data: function(params){
  24 + return{line: params.term};
  25 + },
  26 + processResults: function (data) {
  27 + return {
  28 + results: data
  29 + };
  30 + },
  31 + cache: true
  32 + },
  33 + templateResult: function(repo){
  34 + if (repo.loading) return repo.text;
  35 + var h = '<span>'+repo.text+'</span>';
  36 + return h;
  37 + },
  38 + escapeMarkup: function (markup) { return markup; },
  39 + minimumInputLength: 1,
  40 + templateSelection: function(repo){
  41 + return repo.text;
  42 + },
  43 + language: {
  44 + noResults: function(){
  45 + return '<span style="color:red;font-size: 12px;">没有搜索到线路!</span>';
  46 + },
  47 + inputTooShort : function(e) {
  48 + return '<span style="color:gray;font-size: 12px;"><i class="fa fa-search"></i> 输入线路搜索线路</span>';
  49 + },
  50 + searching : function() {
  51 + return '<span style="color:gray;font-size: 12px;"> 正在搜索线路...</span>';
  52 + }
  53 + }
  54 + });
  55 +
134 56 // 绑定查询事件
135 57 $("#search").click(searchM);
136 58 // 绑定上传事件
... ... @@ -149,7 +71,7 @@
149 71 $("#right_div table tbody").empty();
150 72 var params = {};
151 73 // 取得输入框的值
152   - var inputs = $("ul.breadcrumb input");
  74 + var inputs = $(".param input,select");
153 75 // 遍历数组
154 76 $.each(inputs, function(i, element) {
155 77 params[$(element).attr("name")] = $(element).val();
... ... @@ -168,17 +90,36 @@
168 90  
169 91 // 上传方法
170 92 function uploadM() {
171   - var params = {};
172   - // 取得输入框的值
173   - var trs = $("#right_div tbody tr");
174   - if (trs.length == 0) {
175   - alert("请选择模板");
176   - return;
177   - }
178   - // 遍历数组
179   - $.each(trs, function(i, element) {
180   - alert($(".ttInfoId", element).html());
181   - });
  93 + // 取得输入框的值
  94 + var trs = $("#right_div tbody tr input");
  95 + if (trs.length == 0) {
  96 + alert("请选择线路");
  97 + return;
  98 + }else if(trs.length > 1){
  99 + alert("一次只能上传一条线路");
  100 + return;
  101 + }
  102 + var ids ="0,";
  103 + // 遍历数组
  104 + $.each(trs, function(i, element) {
  105 + ids +=$(element).val()+",";
  106 + });
  107 + var params = {"ids":ids};
  108 + $.ajax({
  109 + type: 'get',url: '/trmg/setXL',
  110 + data: params ,dataType:'text',
  111 + success:function(data) {
  112 + if(data == 'success'){
  113 + alert("上传成功");
  114 + }else{
  115 + alert("上传失败");
  116 + }
  117 +
  118 + }, error : function() {
  119 + alert("操作失败");
  120 + }
  121 +
  122 + });
182 123 }
183 124  
184 125 // 表格行的单击事件
... ...