Commit 7a91bb5780b51c41b6239f293dfa24487ff5b822

Authored by 潘钊
1 parent a492e608

update

src/main/java/com/bsth/controller/directive/DirectiveController.java
... ... @@ -62,7 +62,7 @@ public class DirectiveController {
62 62 * @param @param lineId 新线路编码
63 63 * @throws
64 64 */
65   - @RequestMapping(value = "/lineChnage", method = RequestMethod.POST)
  65 + @RequestMapping(value = "/lineChnage", method = RequestMethod.GET)
66 66 public int lineChange(@RequestParam String nbbm, @RequestParam Integer lineId){
67 67 SysUser user = SecurityUtils.getCurrentUser();
68 68 return directiveService.lineChange(nbbm, lineId, user.getUserName());
... ...
src/main/java/com/bsth/controller/forecast/SampleController.java
1 1 package com.bsth.controller.forecast;
2 2  
  3 +import java.io.UnsupportedEncodingException;
  4 +import java.net.URLDecoder;
  5 +
3 6 import org.springframework.beans.factory.annotation.Autowired;
4 7 import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RequestParam;
5 9 import org.springframework.web.bind.annotation.RestController;
6 10  
  11 +import com.alibaba.fastjson.JSON;
  12 +import com.alibaba.fastjson.JSONObject;
7 13 import com.bsth.controller.BaseController;
  14 +import com.bsth.controller.forecast.dto.CreateSampleParam;
8 15 import com.bsth.entity.forecast.Sample;
9 16 import com.bsth.service.forecast.SampleService;
10 17  
... ... @@ -16,7 +23,15 @@ public class SampleController extends BaseController<Sample, Long>{
16 23 SampleService sampleService;
17 24  
18 25 @RequestMapping("/create/gps")
19   - public int createDataByGps(String lineCode, Integer updown){
20   - return sampleService.createDataByGps(lineCode, updown);
  26 + public int createDataByGps(@RequestParam String data){
  27 +
  28 + try {
  29 + data = URLDecoder.decode(data, "utf-8");
  30 + CreateSampleParam param = JSONObject.toJavaObject(JSON.parseObject(data), CreateSampleParam.class);
  31 + System.out.println(param);
  32 + } catch (UnsupportedEncodingException e) {
  33 + e.printStackTrace();
  34 + }
  35 + return 0;
21 36 }
22 37 }
... ...
src/main/java/com/bsth/controller/forecast/dto/CreateSampleParam.java 0 → 100644
  1 +package com.bsth.controller.forecast.dto;
  2 +
  3 +import java.util.Set;
  4 +
  5 +public class CreateSampleParam {
  6 +
  7 + private String lineCode;
  8 +
  9 + private String startDate;
  10 +
  11 + private String endDate;
  12 +
  13 + private Integer updown;
  14 +
  15 + private Set<TimeRange> timeRange;
  16 +
  17 + public static class TimeRange{
  18 + private String s;
  19 + private String e;
  20 + private String tag;
  21 + public String getS() {
  22 + return s;
  23 + }
  24 + public void setS(String s) {
  25 + this.s = s;
  26 + }
  27 + public String getE() {
  28 + return e;
  29 + }
  30 + public void setE(String e) {
  31 + this.e = e;
  32 + }
  33 + public String getTag() {
  34 + return tag;
  35 + }
  36 + public void setTag(String tag) {
  37 + this.tag = tag;
  38 + }
  39 + }
  40 +
  41 + public String getLineCode() {
  42 + return lineCode;
  43 + }
  44 +
  45 + public void setLineCode(String lineCode) {
  46 + this.lineCode = lineCode;
  47 + }
  48 +
  49 + public String getStartDate() {
  50 + return startDate;
  51 + }
  52 +
  53 + public void setStartDate(String startDate) {
  54 + this.startDate = startDate;
  55 + }
  56 +
  57 + public String getEndDate() {
  58 + return endDate;
  59 + }
  60 +
  61 + public void setEndDate(String endDate) {
  62 + this.endDate = endDate;
  63 + }
  64 +
  65 + public Integer getUpdown() {
  66 + return updown;
  67 + }
  68 +
  69 + public void setUpdown(Integer updown) {
  70 + this.updown = updown;
  71 + }
  72 +
  73 + public Set<TimeRange> getTimeRange() {
  74 + return timeRange;
  75 + }
  76 +
  77 + public void setTimeRange(Set<TimeRange> timeRange) {
  78 + this.timeRange = timeRange;
  79 + }
  80 +}
... ...
src/main/java/com/bsth/data/arrival/ArrivalData_GPS.java
... ... @@ -50,7 +50,7 @@ public class ArrivalData_GPS implements CommandLineRunner{
50 50  
51 51 @Override
52 52 public void run(String... arg0) throws Exception {
53   - Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 30, 15, TimeUnit.SECONDS);
  53 + Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 30, 12, TimeUnit.SECONDS);
54 54 }
55 55  
56 56 @Component
... ...
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
... ... @@ -9,6 +9,7 @@ import java.util.Map;
9 9 import java.util.NavigableSet;
10 10 import java.util.concurrent.TimeUnit;
11 11  
  12 +import org.apache.commons.lang3.StringUtils;
12 13 import org.apache.http.HttpEntity;
13 14 import org.apache.http.client.methods.CloseableHttpResponse;
14 15 import org.apache.http.client.methods.HttpGet;
... ... @@ -146,9 +147,14 @@ public class GpsRealData implements CommandLineRunner{
146 147 if (jsonObj != null)
147 148 list = JSON.parseArray(jsonObj.getString("data"), GpsEntity.class);
148 149  
  150 + String nbbm;
149 151 //附加车辆内部编码
150 152 for(GpsEntity gps : list){
151   - gps.setNbbm(BasicData.deviceId2NbbmMap.get(gps.getDeviceId()));
  153 + nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId());
  154 + if(StringUtils.isBlank(nbbm))
  155 + continue;
  156 +
  157 + gps.setNbbm(nbbm);
152 158 gps.setStationName(BasicData.stationCode2NameMap.get(gps.getStopNo()));
153 159 add(gps);
154 160 }
... ...
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
... ... @@ -579,12 +579,12 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
579 579 File textFile = clientUtils.GetFtpFile(url, port, username, password, remotePath, textFileName);
580 580  
581 581 /*File[] sources = new File[] {textFile};*/
582   - File[] sources = new File[] {textFile};
  582 + //File[] sources = new File[] {textFile};
583 583  
584 584 File target = new File(odlGzFileName);
585 585  
586 586 // 将txt文件打包
587   - File targetFile = packTarGZUtils.pack(sources, target);
  587 + File targetFile = PackTarGZUtils.compress(textFile, target);
588 588  
589 589 /*clientUtils.testUpLoadFromDisk(targetFile,targetFile.getName());*/
590 590  
... ...
src/main/java/com/bsth/util/FTPClientUtils.java
... ... @@ -66,12 +66,10 @@ public class FTPClientUtils {
66 66 }
67 67  
68 68 ftp.changeWorkingDirectory(path);
69   -
  69 + ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
70 70 ftp.enterLocalPassiveMode();
71   -
72 71 success = ftp.storeFile(new String(filename.getBytes("gbk"),"gbk"), input);
73 72 /*success = ftp.storeFile(filename, input); */
74   -
75 73 input.close();
76 74  
77 75 ftp.logout();
... ... @@ -322,6 +320,7 @@ public class FTPClientUtils {
322 320  
323 321 }
324 322  
  323 + out.flush();
325 324 ftp.logout();
326 325  
327 326 } catch (IOException e){
... ...
src/main/java/com/bsth/util/PackTarGZUtils.java
... ... @@ -95,9 +95,9 @@ public class PackTarGZUtils {
95 95 * @throws
96 96 *
97 97 */
98   - public static File compress(File source) {
  98 + public static File compress(File source, File target) {
99 99  
100   - File target = new File(source.getName() + ".gz");
  100 + //File target = new File(source.getName() + ".gz");
101 101  
102 102 FileInputStream in = null;
103 103  
... ... @@ -117,6 +117,9 @@ public class PackTarGZUtils {
117 117  
118 118 out.write(array, 0, number);
119 119 }
  120 +
  121 + out.finish();
  122 + out.flush();
120 123 } catch (FileNotFoundException e) {
121 124  
122 125 e.printStackTrace();
... ... @@ -164,4 +167,9 @@ public class PackTarGZUtils {
164 167 return target;
165 168  
166 169 }
  170 +
  171 + public static void main(String[] args) {
  172 + File f = compress(new File("C:\\Users\\panzhao\\Desktop\\111\\1025.txt"), new File("C:\\Users\\panzhao\\Desktop\\111\\333\\1025.txt.gz"));
  173 +
  174 + }
167 175 }
... ...
src/main/resources/ftp.properties
1   -ftp.url=222.66.0.205
  1 +ftp.url=116.236.238.212
2 2 ftp.port=21
3 3 ftp.username=transport
4 4 ftp.password=transport123
... ...
src/main/resources/ms-jdbc.properties
1 1 ms.mysql.driver= com.mysql.jdbc.Driver
2   -ms.mysql.url= jdbc:mysql://192.168.168.201:3306/ms?useUnicode=true&characterEncoding=utf-8
  2 +ms.mysql.url= jdbc:mysql://127.0.0.1:3306/ms?useUnicode=true&characterEncoding=utf-8
3 3 ms.mysql.username= root
4   -ms.mysql.password= 123456
  4 +ms.mysql.password= panzhao
5 5  
6 6 #ms.mysql.driver= com.mysql.jdbc.Driver
7 7 #ms.mysql.url= jdbc:mysql://192.168.168.171:3306/ms?useUnicode=true&characterEncoding=utf-8
... ...
src/main/resources/static/login.html
... ... @@ -153,6 +153,11 @@ img.captcha-img{
153 153 text-align: center;
154 154 color: #a6a6a6;
155 155 }
  156 +
  157 +h3.logo-text{
  158 + font-family: 华文楷体,华文细黑;
  159 + font-size: 28px;
  160 +}
156 161 </style>
157 162 </head>
158 163  
... ... @@ -160,7 +165,7 @@ img.captcha-img{
160 165 <div class="wrapper ng-scope">
161 166 <div id="loginPanel" class="dialog dialog-shadow">
162 167 <br>
163   - <h3>闵行公交调度系统 </h3>
  168 + <h3 class="logo-text">闵行公交调度系统 </h3>
164 169 <hr>
165 170 <form style="padding: 0px 35px;">
166 171 <div class="form-group" style="margin-bottom: 0">
... ... @@ -182,7 +187,7 @@ img.captcha-img{
182 187 <div class="form-group" id="captchaWrap">
183 188 <label></label>
184 189 <div class="input-icon">
185   - <input type="password" name="captcha" style="width: 153px !important;"
  190 + <input type="text" name="captcha" style="width: 153px !important;"
186 191 class="form-control input-inline input-medium" placeholder="输入验证码" >
187 192  
188 193 <span class="help-inline"> <img alt="验证码" class="captcha-img" title="点击刷新验证码"> </span>
... ...
src/main/resources/static/pages/control/line/index.html
... ... @@ -228,8 +228,8 @@ function countDown(name){
228 228  
229 229 <script>
230 230 var updateLog = {
231   - text: '<div class="updete_log"><p>1、...</p></div>'
232   - ,title: '2016年8月28号更新日志'
  231 + text: '<div class="updete_log"><p>1、过滤掉未加入调度配置的GPS信号。</p></div>'
  232 + ,title: '2016年9月13号更新日志'
233 233 }
234 234  
235 235 var lineCodes = '' //全部线路编码字符串,由data.js初始化
... ...
src/main/resources/static/pages/control/line/js/home.js
... ... @@ -85,18 +85,18 @@ var _home = (function() {
85 85 $('menu.menu').show();
86 86 }, 400);
87 87  
88   - /*setTimeout(function() {
  88 + setTimeout(function() {
89 89 // 提示文本
90   - var promptFlag = storage.getItem('promptFlag_0828');
  90 + var promptFlag = storage.getItem('promptFlag_0913');
91 91 if (!promptFlag) {
92 92 layer.alert(updateLog.text, {
93 93 title: updateLog.title,
94 94 area: ['410px', '250px'],
95 95 shift : 5
96 96 });
97   - storage.setItem('promptFlag_0828', 1);
  97 + storage.setItem('promptFlag_0913', 1);
98 98 }
99   - }, 1500);*/
  99 + }, 1500);
100 100 }
101 101 }
102 102  
... ...
src/main/resources/static/pages/forecast/sample/css/main.css
... ... @@ -225,32 +225,90 @@ rect.f_rect{
225 225  
226 226  
227 227 #forecastSamplePanel .tab-content::-webkit-scrollbar,
228   -#forecastSamplePanel #trafficChart::-webkit-scrollbar {
  228 +#forecastSamplePanel #trafficChart::-webkit-scrollbar,
  229 +#sptItems::-webkit-scrollbar{
229 230 width: 15px;
230 231 height: 16px;
231 232 }
232 233 #forecastSamplePanel .tab-content::-webkit-scrollbar-track,
233 234 #forecastSamplePanel .tab-content::-webkit-scrollbar-thumb,
234 235 #forecastSamplePanel #trafficChart::-webkit-scrollbar-track,
235   -#forecastSamplePanel #trafficChart::-webkit-scrollbar-thumb {
  236 +#forecastSamplePanel #trafficChart::-webkit-scrollbar-thumb,
  237 +#sptItems::-webkit-scrollbar-track,
  238 +#sptItems::-webkit-scrollbar-thumb {
236 239 border-radius: 999px;
237 240 border: 5px solid transparent;
238 241 }
239 242 #forecastSamplePanel .tab-content::-webkit-scrollbar-thumb,
240   -#forecastSamplePanel #trafficChart::-webkit-scrollbar-thumb {
  243 +#forecastSamplePanel #trafficChart::-webkit-scrollbar-thumb,
  244 +#sptItems::-webkit-scrollbar-thumb {
241 245 min-height: 20px;
242 246 background-clip: content-box;
243 247 box-shadow: 0 0 0 5px rgba(0,0,0,.2) inset;
244 248 }
245 249 #forecastSamplePanel .tab-content::-webkit-scrollbar-corner,
246   -#forecastSamplePanel #trafficChart::-webkit-scrollbar-corner {
  250 +#forecastSamplePanel #trafficChart::-webkit-scrollbar-corner,
  251 +#sptItems::-webkit-scrollbar-corner {
247 252 background: transparent;
248 253 }
249 254  
250 255 #forecastPopForm.form-horizontal .form-group{
251   - margin: 15px 7px;
  256 + margin: 15px 7px 0;
252 257 }
253 258  
254 259 #forecastPopForm.form-horizontal{
255 260 margin: 15px;
  261 +}
  262 +
  263 +#forecastPopForm.form-horizontal h6{
  264 + border-bottom: 1px solid #eeeeee;padding: 8px 0 10px;color: gray;
  265 +}
  266 +
  267 +.forecast-spt-item{
  268 + margin: 8px 0;
  269 + padding: 8px 0;
  270 + /* border-bottom: 1px solid #c2cad8; */
  271 + position: relative;
  272 +}
  273 +
  274 +.forecast-spt-item>div{
  275 + padding: 0 0 0 15px;
  276 +}
  277 +
  278 +.forecast-spt-item>div.e-date{
  279 + padding: 0 15px 0 0;
  280 +}
  281 +
  282 +#forecastPopForm .form-actions{
  283 + border-top: 1px solid #eeeeee;
  284 + margin-top: 12px;
  285 + padding-top: 13px;
  286 + text-align: center;
  287 +}
  288 +
  289 +.forecast-item-close{
  290 + position: absolute;
  291 + z-index: 9;
  292 + left: 15px;
  293 + top: 13px;
  294 + width: 10px;
  295 + height: 10px;
  296 + background: #fff;
  297 + padding: 0 5px !important;
  298 + font-size: 18px;
  299 + cursor: pointer;
  300 + font-weight: 600;
  301 + color: #ea8d8d;
  302 +}
  303 +
  304 +.forecast-item-close:HOVER {
  305 + color: red;
  306 +}
  307 +
  308 +#sptItems{
  309 + height: 304px;
  310 + overflow-y: auto;
  311 + overflow-x: hidden;
  312 + padding-right: 15px;
  313 + margin: 15px 0px;
256 314 }
257 315 \ No newline at end of file
... ...
src/main/resources/static/pages/forecast/sample/main.html
... ... @@ -62,45 +62,68 @@
62 62 <div class="form-group">
63 63 <label class="col-md-3 control-label">线路</label>
64 64 <div class="col-md-9">
65   - <input type="text" class="form-control" value="闵行11路" readonly>
  65 + <input type="hidden" name="lineCode" value="{{line.code}}">
  66 + <input type="text" class="form-control" value="{{line.name}}" style="width: 180px;" readonly>
66 67 </div>
67 68 </div>
68 69 <div class="form-group">
69 70 <label class="col-md-3 control-label">走向</label>
70 71 <div class="col-md-9">
71   - <select class="form-control input-inline input-medium" readonly>
72   - <option value="0">上行</option>
73   - </select>
  72 + <input type="hidden" name="updown" value={{updown}}>
  73 + <input type="text" class="form-control" value='{{updown == 0?"上行":"下行"}}' style="width: 180px;" readonly>
74 74 </div>
75 75 </div>
76 76  
77   - <h6 style="margin: 20px 0;border-bottom: 1px solid #eeeeee;padding: 15px 0 10px;color: gray;">1、 告诉我应该使用哪些GPS数据</h6>
  77 + <h6><i class="fa fa-question-circle"></i> 使用哪些天的GPS数据</h6>
78 78 <div class="form-group">
79   - <label class="col-md-3 control-label">gps起始时间</label>
  79 + <label class="col-md-3 control-label">起始日期</label>
80 80 <div class="col-md-9">
81   - <input type="date" class="form-control" >
  81 + <input type="date" class="form-control" style="width: 180px;" name="startDate" value="{{sdate}}" required>
82 82 </div>
83 83 </div>
84 84 <div class="form-group">
85   - <label class="col-md-3 control-label">gps截止时间</label>
  85 + <label class="col-md-3 control-label">截止日期</label>
86 86 <div class="col-md-9">
87   - <input type="date" class="form-control" >
  87 + <input type="date" class="form-control" style="width: 180px;" name="endDate" value="{{cdate}}" required>
88 88 </div>
89 89 </div>
90 90  
91 91  
92   - <h6 style="margin: 20px 0;border-bottom: 1px solid #eeeeee;padding: 15px 0 10px;color: gray;">2、 你想怎么划分时区</h6>
93   - <div class="form-group">
94   - <label class="col-md-3 control-label">...</label>
95   - <div class="col-md-9">
96   - <input type="date" class="form-control" >
97   - </div>
98   - </div>
  92 + <h6><i class="fa fa-question-circle"></i> 你想怎么划分时区</h6>
  93 + <div class="form-group" id="sptItems">
  94 + {{each drs as dr i }}
  95 + <div class="forecast-spt-item row">
  96 + <div class="forecast-item-close"><i class="fa fa-times-circle" ></i></div>
  97 + <div class="col-md-offset-1 col-md-4">
  98 + <input type="text" class="form-control" name="dr_name[]" placeholder="时区名称" value="{{dr.name}}" required>
  99 + </div>
  100 + <div class="col-md-3 s-date">
  101 + <input type="time" class="form-control" name="dr_stime[]" placeholder="开始时间" value="{{dr.s}}" required>
  102 + </div>
  103 + <div class="col-md-1" style="padding-top: 10px;">至</div>
  104 + <div class="col-md-3 e-date">
  105 + <input type="time" class="form-control" name="dr_etime[]" placeholder="结束时间" value="{{dr.e}}" required>
  106 + </div>
  107 + </div>
  108 + {{/each}}
  109 + </div>
  110 +
  111 + <div class="footer">
  112 + <a href="javascript:;" style="text-indent: 28px;" class="add-item"><i class="fa fa-plus"></i> 添加项</a>
  113 + </div>
  114 +
  115 + <div class="form-actions">
  116 + <div class="row">
  117 + <div class="col-md-12" style="">
  118 + <button type="submit" class="btn green">开始生成数据</button>
  119 + <button type="button" class="btn default">取消</button>
  120 + </div>
  121 + </div>
  122 + </div>
99 123 </div>
100 124 </form>
101 125 </script>
102 126  
103   -
104 127 <script src="/pages/forecast/sample/js/svg.js"></script>
105 128 <script>
106 129 !function(){
... ... @@ -183,6 +206,10 @@
183 206 return $('.line_config_tree li.selected').data('code');
184 207 }
185 208  
  209 + function getLineName(){
  210 + return $.trim($('.line_config_tree li.selected').text());
  211 + }
  212 +
186 213 function drawSvg(){
187 214 //绘制svg
188 215 var rts = [], updown = getUpdown();
... ... @@ -199,32 +226,87 @@
199 226  
200 227  
201 228 $('#gpsCreateDataLink').on('click', function(){
202   - /* var lineName = $('.line_config_tree ul li.selected button').text();
203   - var updownText = $('.left_station_route ul li.active a').text();
204   -
205   - layer.confirm('使用GPS轨迹生成【'+lineName+' -'+updownText+'】站点间耗时数据? 该操作将会清除原有数据。', {
206   - btn: ['我确定','算了吧'],
207   - icon: 3
208   - }, function(){
209   -
210   - }); */
  229 + var drs = [{name: '早低谷', s: '00:00', e: '07:00'},{name: '早高峰', s: '07:01', e: '09:00'},{name: '平峰', s: '09:01', e: '16:00'},{name: '晚高峰', s: '16:01', e: '20:00'},{name: '晚低谷', s: '20:01', e: '23:59'}];
  230 + var line = {code: getLineCode(), name: getLineName()};
211 231  
  232 + var cdate = moment().format('YYYY-MM-DD')
  233 + ,sdate = moment().subtract(14, 'days').format('YYYY-MM-DD');
212 234 layer.open({
213 235 type: 1,
214   - area: '530px',
215   - maxmin: true,
216   - content: template('forecast_gps_create_temp', {}),
  236 + area: '580px',
  237 + // maxmin: true,
  238 + content: template('forecast_gps_create_temp', {updown: getUpdown(), line: line, drs: drs, cdate: cdate, sdate: sdate}),
217 239 shift: 5,
218   - title: 'GPS生成数据',
219   - success: function(){
220   - /* dictionaryUtils.transformDom($('#childTaskDiv .nt-dictionary'));
221   - $('#childTaskDiv').trigger('init', {
222   - selected: schedul,
223   - _data: _data,
224   - _alone: _alone
225   - }); */
  240 + title: '根据历史轨迹生成数据',
  241 + success: function(layero){
  242 + var f = $('#forecastPopForm');
  243 +
  244 + f.on('click', '.forecast-item-close' , function(){
  245 + $(this).parent('.forecast-spt-item').remove();
  246 + });
  247 + $('.add-item', f).on('click', function(){
  248 + var item = '<div class="forecast-spt-item row"><div class="forecast-item-close"><i class="fa fa-times-circle" ></i></div><div class="col-md-offset-1 col-md-4"><input type="text" class="form-control" name="dr_name[]" placeholder="时区名称" required></div><div class="col-md-3 s-date"><input type="time" class="form-control" name="dr_stime[]" placeholder="开始时间" required> </div><div class="col-md-1" style="padding-top: 10px;">至</div><div class="col-md-3 e-date"><input type="time" class="form-control" name="dr_etime[]" placeholder="结束时间" required></div></div>';
  249 + $('#sptItems').append(item);
  250 + $('#sptItems').scrollTop( $('#sptItems')[0].scrollHeight );
  251 + });
  252 +
  253 + f.on('submit', function(){
  254 + try{
  255 + if(customFormValidate(f)){
  256 + var param = f.serializeJSON()
  257 + ,timeRange = []
  258 + ,size = param.dr_name.length;
  259 + for(var i = 0; i < size; i ++)
  260 + timeRange.push({tag: param.dr_name[i], s: param.dr_stime[i], e: param.dr_etime[i]});
  261 +
  262 + delete param.dr_name;
  263 + delete param.dr_stime;
  264 + delete param.dr_etime;
  265 + param.timeRange = timeRange;
  266 +
  267 + $.post('/sample/create/gps', {data: encodeURI(JSON.stringify(param))}, function(rs){
  268 + console.log(rs);
  269 + });
  270 + }
  271 + }catch (e){
  272 + console.log(e);
  273 + }
  274 +
  275 + return false;
  276 + });
226 277 }
227 278 });
228 279 });
  280 +
  281 +
  282 + /**
  283 + * 自定义表单校验
  284 + */
  285 + function customFormValidate(f){
  286 + var rs = true;
  287 + //所有可见的项
  288 + var es = $('input,select', f);
  289 +
  290 + for(var i = 0, e; e = es[i++];){
  291 + if($(e).attr('required') && ( $(e).val() == null || $(e).val() == '')){
  292 + if($(e).hasClass('select2-hidden-accessible'))
  293 + $(e).next().find('.select2-selection').addClass('custom-val-error');
  294 + else
  295 + $(e).addClass('custom-val-error');
  296 + rs = false;
  297 + }
  298 + else{
  299 + if($(e).hasClass('select2-hidden-accessible'))
  300 + $(e).next().find('.select2-selection').removeClass('custom-val-error');
  301 + else
  302 + $(e).removeClass('custom-val-error');
  303 + }
  304 + }
  305 +
  306 + if(!rs){
  307 + layer.alert('数据完整性校验失败,请检查输入项', {icon: 2, title: '操作失败', shift: 5});
  308 + }
  309 + return rs;
  310 + }
229 311 }();
230 312 </script>
231 313 \ No newline at end of file
... ...