Commit 0631e6cfe773ce81a3ad4d70007be06dee45f0aa

Authored by 潘钊
2 parents 27a01ee5 57a5894f

Merge branch 'minhang' of http://222.66.0.204:8090/panzhaov5/bsth_control into minhang

src/main/java/com/bsth/controller/LineController.java
@@ -47,6 +47,16 @@ public class LineController extends BaseController<Line, Integer> { @@ -47,6 +47,16 @@ public class LineController extends BaseController<Line, Integer> {
47 } 47 }
48 48
49 /** 49 /**
  50 + * 验证线路编码是否存在
  51 + *
  52 + * @return Map < {valid: true }:是否通过验证>
  53 + */
  54 + @RequestMapping(value = "lineCodeVerification", method = RequestMethod.GET)
  55 + public String lineCodeVerification(@RequestParam(defaultValue = "lineCode") String lineCode) {
  56 + return service.lineCodeVerification(lineCode);
  57 + }
  58 +
  59 + /**
50 * 60 *
51 * 保存 61 * 保存
52 * 62 *
@@ -59,7 +69,7 @@ public class LineController extends BaseController&lt;Line, Integer&gt; { @@ -59,7 +69,7 @@ public class LineController extends BaseController&lt;Line, Integer&gt; {
59 t.setId(Integer.valueOf(t.getLineCode())); 69 t.setId(Integer.valueOf(t.getLineCode()));
60 70
61 } 71 }
62 - if( (t.getId().toString().length()) > 6) { 72 + if( (t.getId().toString().length()) > 6 || service.lineCodeVerification(t.getLineCode()).equals("false") ) {
63 73
64 map.put("status", ResponseCode.ERROR); 74 map.put("status", ResponseCode.ERROR);
65 return map; 75 return map;
src/main/java/com/bsth/service/LineService.java
1 package com.bsth.service; 1 package com.bsth.service;
2 2
  3 +import java.util.Map;
  4 +
3 import org.springframework.web.bind.annotation.RequestMapping; 5 import org.springframework.web.bind.annotation.RequestMapping;
4 import org.springframework.web.bind.annotation.RequestMethod; 6 import org.springframework.web.bind.annotation.RequestMethod;
5 7
@@ -32,4 +34,6 @@ public interface LineService extends BaseService&lt;Line, Integer&gt; { @@ -32,4 +34,6 @@ public interface LineService extends BaseService&lt;Line, Integer&gt; {
32 Line findByLineCode(String lineCode); 34 Line findByLineCode(String lineCode);
33 35
34 Line findById(Integer id); 36 Line findById(Integer id);
  37 +
  38 + String lineCodeVerification(String lineCode);
35 } 39 }
src/main/java/com/bsth/service/impl/BusIntervalServiceImpl.java
@@ -1645,73 +1645,79 @@ public class BusIntervalServiceImpl implements BusIntervalService { @@ -1645,73 +1645,79 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1645 } 1645 }
1646 for(String key : keyMap.keySet()){ 1646 for(String key : keyMap.keySet()){
1647 Map<String, Object> tempMap = new HashMap<String, Object>(); 1647 Map<String, Object> tempMap = new HashMap<String, Object>();
1648 - int jhbc = 0;  
1649 - int sjbc = 0;  
1650 - int jhlc = 0;  
1651 - int sjlc = 0;  
1652 - int lzbc = 0, lzlc = 0, dmbc = 0, dmlc = 0,  
1653 - gzbc = 0, gzlc = 0, jfbc = 0, jflc = 0,  
1654 - zsbc = 0, zslc = 0, qrbc = 0, qrlc = 0,  
1655 - qcbc = 0, qclc = 0, kxbc = 0, kxlc = 0,  
1656 - qhbc = 0, qhlc = 0, wybc = 0, wylc = 0;  
1657 - int qtbc = 0, qtlc = 0; 1648 + int jhbc = 0, sjbc = 0,
  1649 + lzbc = 0, dmbc = 0,
  1650 + gzbc = 0, jfbc = 0, zsbc = 0,
  1651 + qrbc = 0, qcbc = 0, kxbc = 0,
  1652 + qhbc = 0, wybc = 0, qtbc = 0;
  1653 + BigDecimal jhlc = new BigDecimal("0"), sjlc = new BigDecimal("0"),
  1654 + lzlc = new BigDecimal("0"), dmlc = new BigDecimal("0"),
  1655 + gzlc = new BigDecimal("0"), jflc = new BigDecimal("0"),
  1656 + zslc = new BigDecimal("0"), qrlc = new BigDecimal("0"),
  1657 + qclc = new BigDecimal("0"), kxlc = new BigDecimal("0"),
  1658 + qhlc = new BigDecimal("0"), wylc = new BigDecimal("0"),
  1659 + qtlc = new BigDecimal("0");
1658 String companyName = "", subCompanyName = ""; 1660 String companyName = "", subCompanyName = "";
1659 for(ScheduleRealInfo schedule : keyMap.get(key)){ 1661 for(ScheduleRealInfo schedule : keyMap.get(key)){
1660 if(schedule.getGsName() != null && companyName.length() == 0) 1662 if(schedule.getGsName() != null && companyName.length() == 0)
1661 companyName = schedule.getGsName(); 1663 companyName = schedule.getGsName();
1662 if(schedule.getFgsName() != null && subCompanyName.length() == 0) 1664 if(schedule.getFgsName() != null && subCompanyName.length() == 0)
1663 subCompanyName = schedule.getFgsName(); 1665 subCompanyName = schedule.getFgsName();
1664 - double lc = 0d; 1666 + BigDecimal lc = new BigDecimal("0");
1665 if(schedule.getJhlcOrig() != null && schedule.getJhlcOrig() > 0.1d){ 1667 if(schedule.getJhlcOrig() != null && schedule.getJhlcOrig() > 0.1d){
1666 - lc = schedule.getJhlcOrig(); 1668 + lc = new BigDecimal("0"+schedule.getJhlcOrig());
1667 } else { 1669 } else {
1668 - lc = schedule.getJhlc(); 1670 + lc = new BigDecimal("0"+schedule.getJhlc());
1669 } 1671 }
1670 1672
1671 if(!schedule.isSflj()){ 1673 if(!schedule.isSflj()){
1672 jhbc++; 1674 jhbc++;
1673 - jhlc += lc; 1675 + jhlc = jhlc.add(lc);
1674 } 1676 }
1675 if(schedule.getStatus() != -1){ 1677 if(schedule.getStatus() != -1){
1676 sjbc++; 1678 sjbc++;
1677 - sjlc += lc; 1679 + sjlc = sjlc.add(lc);
1678 } else if(schedule.getStatus() == -1){ 1680 } else if(schedule.getStatus() == -1){
1679 if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("路阻") != -1){ 1681 if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("路阻") != -1){
1680 lzbc++; 1682 lzbc++;
1681 - lzlc += lc; 1683 + lzlc = lzlc.add(lc);
1682 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("吊慢") != -1){ 1684 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("吊慢") != -1){
1683 dmbc++; 1685 dmbc++;
1684 - dmlc += lc; 1686 + dmlc = dmlc.add(lc);
1685 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("故障") != -1){ 1687 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("故障") != -1){
1686 gzbc++; 1688 gzbc++;
1687 - gzlc += lc; 1689 + gzlc = gzlc.add(lc);
1688 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("纠纷") != -1){ 1690 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("纠纷") != -1){
1689 jfbc++; 1691 jfbc++;
1690 - jflc += lc; 1692 + jflc = jflc.add(lc);
1691 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("肇事") != -1){ 1693 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("肇事") != -1){
1692 zsbc++; 1694 zsbc++;
1693 - zslc += lc; 1695 + zslc = zslc.add(lc);
1694 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("缺人") != -1){ 1696 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("缺人") != -1){
1695 qrbc++; 1697 qrbc++;
1696 - qrlc += lc; 1698 + qrlc = qrlc.add(lc);
1697 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("缺车") != -1){ 1699 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("缺车") != -1){
1698 qcbc++; 1700 qcbc++;
1699 - qclc += lc; 1701 + qclc = qclc.add(lc);
1700 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("客稀") != -1){ 1702 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("客稀") != -1){
1701 kxbc++; 1703 kxbc++;
1702 - kxlc += lc; 1704 + kxlc = kxlc.add(lc);
1703 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("气候") != -1){ 1705 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("气候") != -1){
1704 qhbc++; 1706 qhbc++;
1705 - qhlc += lc; 1707 + qhlc = qhlc.add(lc);
1706 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("外援") != -1){ 1708 }else if(schedule.getAdjustExps() != null && schedule.getAdjustExps().indexOf("外援") != -1){
1707 wybc++; 1709 wybc++;
1708 - wylc += lc; 1710 + wylc = wylc.add(lc);
1709 } else { 1711 } else {
1710 qtbc++; 1712 qtbc++;
1711 - qtlc += lc; 1713 + qtlc = qtlc.add(lc);
1712 } 1714 }
1713 } 1715 }
1714 } 1716 }
  1717 + boolean flag = true;
  1718 + if(jhlc.toString().equals("0")){
  1719 + flag = false;
  1720 + }
1715 tempMap.put("date", Date); 1721 tempMap.put("date", Date);
1716 tempMap.put("company", companyName); 1722 tempMap.put("company", companyName);
1717 tempMap.put("subCompany", subCompanyName); 1723 tempMap.put("subCompany", subCompanyName);
@@ -1720,42 +1726,43 @@ public class BusIntervalServiceImpl implements BusIntervalService { @@ -1720,42 +1726,43 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1720 tempMap.put("jhbc", jhbc); 1726 tempMap.put("jhbc", jhbc);
1721 tempMap.put("sjbc", sjbc); 1727 tempMap.put("sjbc", sjbc);
1722 tempMap.put("bcbfb", df.format(jhbc>0?(double)sjbc/jhbc*100:0)+"%"); 1728 tempMap.put("bcbfb", df.format(jhbc>0?(double)sjbc/jhbc*100:0)+"%");
1723 - tempMap.put("jhlc", jhlc);  
1724 - tempMap.put("sjlc", sjlc);  
1725 - tempMap.put("lcbfb", df.format(jhlc>0?(double)sjlc/jhlc*100:0)+"%"); 1729 + tempMap.put("jhlc", jhlc.doubleValue());
  1730 + tempMap.put("sjlc", sjlc.doubleValue());
  1731 +// tempMap.put("lcbfb", df.format(flag?(double)sjlc/jhlc*100:0)+"%");
  1732 + tempMap.put("lcbfb", df.format(flag?sjlc.divide(jhlc, 4, BigDecimal.ROUND_HALF_UP).doubleValue()*100:0)+"%");
1726 tempMap.put("lzbc", lzbc); 1733 tempMap.put("lzbc", lzbc);
1727 - tempMap.put("lzlc", lzlc);  
1728 - tempMap.put("lzbfb", df.format(jhlc>0?(double)lzbc/jhbc*100:0)+"%"); 1734 + tempMap.put("lzlc", lzlc.doubleValue());
  1735 + tempMap.put("lzbfb", df.format(flag?(double)lzbc/jhbc*100:0)+"%");
1729 tempMap.put("dmbc", dmbc); 1736 tempMap.put("dmbc", dmbc);
1730 - tempMap.put("dmlc", dmlc);  
1731 - tempMap.put("dmbfb", df.format(jhlc>0?(double)dmbc/jhbc*100:0)+"%"); 1737 + tempMap.put("dmlc", dmlc.doubleValue());
  1738 + tempMap.put("dmbfb", df.format(flag?(double)dmbc/jhbc*100:0)+"%");
1732 tempMap.put("gzbc", gzbc); 1739 tempMap.put("gzbc", gzbc);
1733 - tempMap.put("gzlc", gzlc);  
1734 - tempMap.put("gzbfb", df.format(jhlc>0?(double)gzbc/jhbc*100:0)+"%"); 1740 + tempMap.put("gzlc", gzlc.doubleValue());
  1741 + tempMap.put("gzbfb", df.format(flag?(double)gzbc/jhbc*100:0)+"%");
1735 tempMap.put("jfbc", jfbc); 1742 tempMap.put("jfbc", jfbc);
1736 - tempMap.put("jflc", jflc);  
1737 - tempMap.put("jfbfb", df.format(jhlc>0?(double)jfbc/jhbc*100:0)+"%"); 1743 + tempMap.put("jflc", jflc.doubleValue());
  1744 + tempMap.put("jfbfb", df.format(flag?(double)jfbc/jhbc*100:0)+"%");
1738 tempMap.put("zsbc", zsbc); 1745 tempMap.put("zsbc", zsbc);
1739 - tempMap.put("zslc", zslc);  
1740 - tempMap.put("zsbfb", df.format(jhlc>0?(double)zsbc/jhbc*100:0)+"%"); 1746 + tempMap.put("zslc", zslc.doubleValue());
  1747 + tempMap.put("zsbfb", df.format(flag?(double)zsbc/jhbc*100:0)+"%");
1741 tempMap.put("qrbc", qrbc); 1748 tempMap.put("qrbc", qrbc);
1742 - tempMap.put("qrlc", qrlc);  
1743 - tempMap.put("qrbfb", df.format(jhlc>0?(double)qrbc/jhbc*100:0)+"%"); 1749 + tempMap.put("qrlc", qrlc.doubleValue());
  1750 + tempMap.put("qrbfb", df.format(flag?(double)qrbc/jhbc*100:0)+"%");
1744 tempMap.put("qcbc", qcbc); 1751 tempMap.put("qcbc", qcbc);
1745 - tempMap.put("qclc", qclc);  
1746 - tempMap.put("qcbfb", df.format(jhlc>0?(double)qcbc/jhbc*100:0)+"%"); 1752 + tempMap.put("qclc", qclc.doubleValue());
  1753 + tempMap.put("qcbfb", df.format(flag?(double)qcbc/jhbc*100:0)+"%");
1747 tempMap.put("kxbc", kxbc); 1754 tempMap.put("kxbc", kxbc);
1748 - tempMap.put("kxlc", kxlc);  
1749 - tempMap.put("kxbfb", df.format(jhlc>0?(double)kxbc/jhbc*100:0)+"%"); 1755 + tempMap.put("kxlc", kxlc.doubleValue());
  1756 + tempMap.put("kxbfb", df.format(flag?(double)kxbc/jhbc*100:0)+"%");
1750 tempMap.put("qhbc", qhbc); 1757 tempMap.put("qhbc", qhbc);
1751 - tempMap.put("qhlc", qhlc);  
1752 - tempMap.put("qhbfb", df.format(jhlc>0?(double)qhbc/jhbc*100:0)+"%"); 1758 + tempMap.put("qhlc", qhlc.doubleValue());
  1759 + tempMap.put("qhbfb", df.format(flag?(double)qhbc/jhbc*100:0)+"%");
1753 tempMap.put("wybc", wybc); 1760 tempMap.put("wybc", wybc);
1754 - tempMap.put("wylc", wylc);  
1755 - tempMap.put("wybfb", df.format(jhlc>0?(double)wybc/jhbc*100:0)+"%"); 1761 + tempMap.put("wylc", wylc.doubleValue());
  1762 + tempMap.put("wybfb", df.format(flag?(double)wybc/jhbc*100:0)+"%");
1756 tempMap.put("qtbc", qtbc); 1763 tempMap.put("qtbc", qtbc);
1757 - tempMap.put("qtlc", qtlc);  
1758 - tempMap.put("qtbfb", df.format(jhlc>0?(double)qtbc/jhbc*100:0)+"%"); 1764 + tempMap.put("qtlc", qtlc.doubleValue());
  1765 + tempMap.put("qtbfb", df.format(flag?(double)qtbc/jhbc*100:0)+"%");
1759 1766
1760 resList.add(tempMap); 1767 resList.add(tempMap);
1761 } 1768 }
@@ -1777,6 +1784,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { @@ -1777,6 +1784,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1777 e.printStackTrace(); 1784 e.printStackTrace();
1778 } 1785 }
1779 } 1786 }
  1787 + System.out.println(map);
1780 1788
1781 return resList; 1789 return resList;
1782 } 1790 }
src/main/java/com/bsth/service/impl/LineServiceImpl.java
1 package com.bsth.service.impl; 1 package com.bsth.service.impl;
2 2
  3 +import java.util.HashMap;
  4 +import java.util.Map;
  5 +
3 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.beans.factory.annotation.Autowired;
4 import org.springframework.stereotype.Service; 7 import org.springframework.stereotype.Service;
5 8
@@ -50,4 +53,14 @@ public class LineServiceImpl extends BaseServiceImpl&lt;Line, Integer&gt; implements L @@ -50,4 +53,14 @@ public class LineServiceImpl extends BaseServiceImpl&lt;Line, Integer&gt; implements L
50 return repository.findOne(id); 53 return repository.findOne(id);
51 } 54 }
52 55
  56 + @Override
  57 + public String lineCodeVerification(String lineCode) {
  58 + String state = "true";
  59 + Line line = repository.findByLineCode(lineCode);
  60 + if(line != null){
  61 + state = "false";
  62 + }
  63 + return state;
  64 + }
  65 +
53 } 66 }
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
@@ -2968,6 +2968,14 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2968,6 +2968,14 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2968 bCompany=scheduleRealInfo.getFgsBm(); 2968 bCompany=scheduleRealInfo.getFgsBm();
2969 fage = false; 2969 fage = false;
2970 } 2970 }
  2971 + Set<ChildTaskPlan> cts = scheduleRealInfo.getcTasks();
  2972 + if(cts != null && cts.size() > 0){
  2973 + listS.add(scheduleRealInfo);
  2974 + }else{
  2975 + if(scheduleRealInfo.getZdsjActual()!=null){
  2976 + listS.add(scheduleRealInfo);
  2977 + }
  2978 + }
2971 listS.add(scheduleRealInfo); 2979 listS.add(scheduleRealInfo);
2972 } 2980 }
2973 } 2981 }
src/main/resources/static/pages/base/line/js/line-add-form.js
@@ -94,7 +94,13 @@ $(function(){ @@ -94,7 +94,13 @@ $(function(){
94 // 需要验证的表单元素 94 // 需要验证的表单元素
95 rules : { 95 rules : {
96 'name' : {required : true,maxlength: 30},// 线路名称 必填项、 最大长度. 96 'name' : {required : true,maxlength: 30},// 线路名称 必填项、 最大长度.
97 - 'lineCode' : {required : true,maxlength: 6},// 线路编码 必填项、最大长度. 97 + 'lineCode' : {required : true,maxlength: 6,digits:true ,remote:{type: 'GET',
  98 + url: '/line/lineCodeVerification',
  99 + data:{'lineCode':function(){ return $("#lineCodeInput").val();}},
  100 + dataFilter: function (data,type) {
  101 + return data; //要返回data 否则会影响到后续验证 并且阻碍提交【即使验证通过】,也不会提交
  102 + },
  103 + delay: 2000}},// 线路编码 必填项、最大长度.
98 'company' : {required : true,maxlength: 30},// 所属公司 必填项、最大长度. 104 'company' : {required : true,maxlength: 30},// 所属公司 必填项、最大长度.
99 'brancheCompany' : {required : true,maxlength: 30},// 所属分公司 必填项、最大长度. 105 'brancheCompany' : {required : true,maxlength: 30},// 所属分公司 必填项、最大长度.
100 'level' : {required : true,maxlength: 30},// 线路等级 必填项、最大长度. 106 'level' : {required : true,maxlength: 30},// 线路等级 必填项、最大长度.
@@ -119,7 +125,11 @@ $(function(){ @@ -119,7 +125,11 @@ $(function(){
119 'history' : {maxlength: 200},// 线路沿革 输入长度最多是 200 的字符串(汉字算一个字符)。 125 'history' : {maxlength: 200},// 线路沿革 输入长度最多是 200 的字符串(汉字算一个字符)。
120 'descriptions' : {maxlength: 200}// 描述/说明 输入长度最多是 200 的字符串(汉字算一个字符)。 126 'descriptions' : {maxlength: 200}// 描述/说明 输入长度最多是 200 的字符串(汉字算一个字符)。
121 }, 127 },
122 - 128 + messages:{
  129 + 'lineCode':{
  130 + remote: '此线路编码已存在!'
  131 + }
  132 + },
123 /** 133 /**
124 * 类型:Callback。当未通过验证的表单提交时,可以在该回调函数中处理一些事情。 134 * 类型:Callback。当未通过验证的表单提交时,可以在该回调函数中处理一些事情。
125 * 135 *
@@ -183,12 +193,12 @@ $(function(){ @@ -183,12 +193,12 @@ $(function(){
183 193
184 // 隐藏错误提示 194 // 隐藏错误提示
185 error.hide(); 195 error.hide();
186 -  
187 // 表单序列化 196 // 表单序列化
188 var params = form.serializeJSON(); 197 var params = form.serializeJSON();
  198 + submit();
189 199
190 // 查询线路编码的顺延号 200 // 查询线路编码的顺延号
191 - $get('/line/all', {lineCode_prefixLike: params.lineCode},function(lineCode){ 201 + /*$get('/line/all', {lineCode_eq: params.lineCode},function(lineCode){
192 202
193 // 定义返回值的长度 203 // 定义返回值的长度
194 var len = lineCode.length; 204 var len = lineCode.length;
@@ -196,7 +206,7 @@ $(function(){ @@ -196,7 +206,7 @@ $(function(){
196 // 如果大于零,则已存在录入的线路编码;否则不存在 206 // 如果大于零,则已存在录入的线路编码;否则不存在
197 if(len > 0) { 207 if(len > 0) {
198 208
199 - /*// 定义已有的线路编码 209 + // 定义已有的线路编码
200 var oldCode = params.lineCode; 210 var oldCode = params.lineCode;
201 211
202 // 自动获取线路编码 212 // 自动获取线路编码
@@ -210,7 +220,7 @@ $(function(){ @@ -210,7 +220,7 @@ $(function(){
210 btn : [ '确认提示并提交', '取消' ] 220 btn : [ '确认提示并提交', '取消' ]
211 }, submit); 221 }, submit);
212 222
213 - });*/ 223 + });
214 layer.open({ 224 layer.open({
215 title: '消息提示' 225 title: '消息提示'
216 ,content: '线路编码【'+params.lineCode+'】已存在,请重新输入编码!' 226 ,content: '线路编码【'+params.lineCode+'】已存在,请重新输入编码!'
@@ -221,7 +231,7 @@ $(function(){ @@ -221,7 +231,7 @@ $(function(){
221 submit(); 231 submit();
222 232
223 } 233 }
224 - }); 234 + });*/
225 235
226 236
227 // 提交 237 // 提交
@@ -229,7 +239,6 @@ $(function(){ @@ -229,7 +239,6 @@ $(function(){
229 239
230 // 添加数据 240 // 添加数据
231 $post('/line', params, function(result) { 241 $post('/line', params, function(result) {
232 -  
233 // 如果返回结果不为空 242 // 如果返回结果不为空
234 if(result){ 243 if(result){
235 244
src/main/resources/static/pages/oil/list_ph.html
@@ -199,7 +199,7 @@ @@ -199,7 +199,7 @@
199 <table 199 <table
200 class="table table-striped table-bordered table-hover table-checkable" 200 class="table table-striped table-bordered table-hover table-checkable"
201 id="datatable_ylb_body" 201 id="datatable_ylb_body"
202 - style="table-layout: fixed; overflow: auto; height: calc(100% - 80px);"> 202 + style="table-layout: fixed; overflow: auto; ">
203 <tbody></tbody> 203 <tbody></tbody>
204 </table> 204 </table>
205 </div> 205 </div>
src/main/resources/static/pages/report/inoutstation/inoutstation.html
@@ -70,14 +70,14 @@ @@ -70,14 +70,14 @@
70 </div> 70 </div>
71 <div style="display: inline-block; margin-left: 5px;"> 71 <div style="display: inline-block; margin-left: 5px;">
72 <input class="btn btn-default" type="button" id="query" value="查询" /> 72 <input class="btn btn-default" type="button" id="query" value="查询" />
73 - <input class="btn btn-default" type="button" id="export" value="导出" /> 73 + <a class="btn btn-default" data-type="xls" href="javascript:;" id="export" >导出</a>
74 </div> 74 </div>
75 </div> 75 </div>
76 76
77 </form> 77 </form>
78 </div> 78 </div>
79 <div class="portlet-body" > 79 <div class="portlet-body" >
80 - <div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 506px;height: 400px"> 80 + <div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 506px;">
81 <table class="table table-bordered table-hover table-checkable" id="forms"> 81 <table class="table table-bordered table-hover table-checkable" id="forms">
82 <tbody class="ludan_ll_1"> 82 <tbody class="ludan_ll_1">
83 83
@@ -169,18 +169,17 @@ @@ -169,18 +169,17 @@
169 169
170 170
171 171
172 - $("#export").on("click",function(){  
173 - var curTbl = document.getElementById("forms");  
174 - var oXL = new ActiveXObject("Excel.Application");  
175 - var oWB = oXL.Workbooks.Add();  
176 - var oSheet = oWB.ActiveSheet;  
177 - var sel = document.body.createTextRange();  
178 - sel.moveToElementText(curTbl);  
179 - sel.select();  
180 - sel.execCommand("Copy");  
181 - oSheet.Paste();  
182 - oXL.Visible = true;  
183 - }); 172 +
  173 + var $exportLink = document.getElementById('export');
  174 + $exportLink.addEventListener('click', function(e){
  175 + e.preventDefault();
  176 + if(e.target.nodeName === "A"){
  177 + tableExport('forms', '班次到离站', e.target.getAttribute('data-type'));
  178 + }
  179 +
  180 +
  181 +
  182 + }, false);
184 183
185 }); 184 });
186 185
@@ -205,10 +204,10 @@ @@ -205,10 +204,10 @@
205 {{else}} 204 {{else}}
206 <td {{if obj[o.stationCode] =='y'}}style="color: red"{{/if}}> 205 <td {{if obj[o.stationCode] =='y'}}style="color: red"{{/if}}>
207 {{if obj[(o.stationCode)+'in']!=''}} 206 {{if obj[(o.stationCode)+'in']!=''}}
208 - <label> I {{obj[(o.stationCode)+'in']}}</label> 207 + <label> I {{obj[(o.stationCode)+'in']}}</label>
209 {{/if}}<br/> 208 {{/if}}<br/>
210 {{if obj[(o.stationCode)+'out']!=''}} 209 {{if obj[(o.stationCode)+'out']!=''}}
211 - <label> O{{obj[(o.stationCode)+'out']}}</label> 210 + <label> O {{obj[(o.stationCode)+'out']}}</label>
212 {{/if}} 211 {{/if}}
213 </td> 212 </td>
214 {{/if}} 213 {{/if}}
@@ -221,3 +220,8 @@ @@ -221,3 +220,8 @@
221 </tr> 220 </tr>
222 {{/if}} 221 {{/if}}
223 </script> 222 </script>
  223 +
  224 +<script src="/pages/report/inoutstation/js/Blob.js" ></script>
  225 +<script src="/pages/report/inoutstation/js/FileSaver.js" ></script>
  226 +<script src="/pages/report/inoutstation/js/tableExport.js" ></script>
  227 +
src/main/resources/static/pages/report/inoutstation/js/Blob.js 0 → 100644
  1 +/* Blob.js
  2 + * A Blob implementation.
  3 + * 2014-07-24
  4 + *
  5 + * By Eli Grey, http://eligrey.com
  6 + * By Devin Samarin, https://github.com/dsamarin
  7 + * License: X11/MIT
  8 + * See https://github.com/eligrey/Blob.js/blob/master/LICENSE.md
  9 + */
  10 +
  11 +/*global self, unescape */
  12 +/*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
  13 + plusplus: true */
  14 +
  15 +/*! @source http://purl.eligrey.com/github/Blob.js/blob/master/Blob.js */
  16 +
  17 +(function (view) {
  18 + "use strict";
  19 +
  20 + view.URL = view.URL || view.webkitURL;
  21 +
  22 + if (view.Blob && view.URL) {
  23 + try {
  24 + new Blob;
  25 + return;
  26 + } catch (e) {}
  27 + }
  28 +
  29 + // Internally we use a BlobBuilder implementation to base Blob off of
  30 + // in order to support older browsers that only have BlobBuilder
  31 + var BlobBuilder = view.BlobBuilder || view.WebKitBlobBuilder || view.MozBlobBuilder || (function(view) {
  32 + var
  33 + get_class = function(object) {
  34 + return Object.prototype.toString.call(object).match(/^\[object\s(.*)\]$/)[1];
  35 + }
  36 + , FakeBlobBuilder = function BlobBuilder() {
  37 + this.data = [];
  38 + }
  39 + , FakeBlob = function Blob(data, type, encoding) {
  40 + this.data = data;
  41 + this.size = data.length;
  42 + this.type = type;
  43 + this.encoding = encoding;
  44 + }
  45 + , FBB_proto = FakeBlobBuilder.prototype
  46 + , FB_proto = FakeBlob.prototype
  47 + , FileReaderSync = view.FileReaderSync
  48 + , FileException = function(type) {
  49 + this.code = this[this.name = type];
  50 + }
  51 + , file_ex_codes = (
  52 + "NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR "
  53 + + "NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR"
  54 + ).split(" ")
  55 + , file_ex_code = file_ex_codes.length
  56 + , real_URL = view.URL || view.webkitURL || view
  57 + , real_create_object_URL = real_URL.createObjectURL
  58 + , real_revoke_object_URL = real_URL.revokeObjectURL
  59 + , URL = real_URL
  60 + , btoa = view.btoa
  61 + , atob = view.atob
  62 +
  63 + , ArrayBuffer = view.ArrayBuffer
  64 + , Uint8Array = view.Uint8Array
  65 +
  66 + , origin = /^[\w-]+:\/*\[?[\w\.:-]+\]?(?::[0-9]+)?/
  67 + ;
  68 + FakeBlob.fake = FB_proto.fake = true;
  69 + while (file_ex_code--) {
  70 + FileException.prototype[file_ex_codes[file_ex_code]] = file_ex_code + 1;
  71 + }
  72 + // Polyfill URL
  73 + if (!real_URL.createObjectURL) {
  74 + URL = view.URL = function(uri) {
  75 + var
  76 + uri_info = document.createElementNS("http://www.w3.org/1999/xhtml", "a")
  77 + , uri_origin
  78 + ;
  79 + uri_info.href = uri;
  80 + if (!("origin" in uri_info)) {
  81 + if (uri_info.protocol.toLowerCase() === "data:") {
  82 + uri_info.origin = null;
  83 + } else {
  84 + uri_origin = uri.match(origin);
  85 + uri_info.origin = uri_origin && uri_origin[1];
  86 + }
  87 + }
  88 + return uri_info;
  89 + };
  90 + }
  91 + URL.createObjectURL = function(blob) {
  92 + var
  93 + type = blob.type
  94 + , data_URI_header
  95 + ;
  96 + if (type === null) {
  97 + type = "application/octet-stream";
  98 + }
  99 + if (blob instanceof FakeBlob) {
  100 + data_URI_header = "data:" + type;
  101 + if (blob.encoding === "base64") {
  102 + return data_URI_header + ";base64," + blob.data;
  103 + } else if (blob.encoding === "URI") {
  104 + return data_URI_header + "," + decodeURIComponent(blob.data);
  105 + } if (btoa) {
  106 + return data_URI_header + ";base64," + btoa(blob.data);
  107 + } else {
  108 + return data_URI_header + "," + encodeURIComponent(blob.data);
  109 + }
  110 + } else if (real_create_object_URL) {
  111 + return real_create_object_URL.call(real_URL, blob);
  112 + }
  113 + };
  114 + URL.revokeObjectURL = function(object_URL) {
  115 + if (object_URL.substring(0, 5) !== "data:" && real_revoke_object_URL) {
  116 + real_revoke_object_URL.call(real_URL, object_URL);
  117 + }
  118 + };
  119 + FBB_proto.append = function(data/*, endings*/) {
  120 + var bb = this.data;
  121 + // decode data to a binary string
  122 + if (Uint8Array && (data instanceof ArrayBuffer || data instanceof Uint8Array)) {
  123 + var
  124 + str = ""
  125 + , buf = new Uint8Array(data)
  126 + , i = 0
  127 + , buf_len = buf.length
  128 + ;
  129 + for (; i < buf_len; i++) {
  130 + str += String.fromCharCode(buf[i]);
  131 + }
  132 + bb.push(str);
  133 + } else if (get_class(data) === "Blob" || get_class(data) === "File") {
  134 + if (FileReaderSync) {
  135 + var fr = new FileReaderSync;
  136 + bb.push(fr.readAsBinaryString(data));
  137 + } else {
  138 + // async FileReader won't work as BlobBuilder is sync
  139 + throw new FileException("NOT_READABLE_ERR");
  140 + }
  141 + } else if (data instanceof FakeBlob) {
  142 + if (data.encoding === "base64" && atob) {
  143 + bb.push(atob(data.data));
  144 + } else if (data.encoding === "URI") {
  145 + bb.push(decodeURIComponent(data.data));
  146 + } else if (data.encoding === "raw") {
  147 + bb.push(data.data);
  148 + }
  149 + } else {
  150 + if (typeof data !== "string") {
  151 + data += ""; // convert unsupported types to strings
  152 + }
  153 + // decode UTF-16 to binary string
  154 + bb.push(unescape(encodeURIComponent(data)));
  155 + }
  156 + };
  157 + FBB_proto.getBlob = function(type) {
  158 + if (!arguments.length) {
  159 + type = null;
  160 + }
  161 + return new FakeBlob(this.data.join(""), type, "raw");
  162 + };
  163 + FBB_proto.toString = function() {
  164 + return "[object BlobBuilder]";
  165 + };
  166 + FB_proto.slice = function(start, end, type) {
  167 + var args = arguments.length;
  168 + if (args < 3) {
  169 + type = null;
  170 + }
  171 + return new FakeBlob(
  172 + this.data.slice(start, args > 1 ? end : this.data.length)
  173 + , type
  174 + , this.encoding
  175 + );
  176 + };
  177 + FB_proto.toString = function() {
  178 + return "[object Blob]";
  179 + };
  180 + FB_proto.close = function() {
  181 + this.size = 0;
  182 + delete this.data;
  183 + };
  184 + return FakeBlobBuilder;
  185 + }(view));
  186 +
  187 + view.Blob = function(blobParts, options) {
  188 + var type = options ? (options.type || "") : "";
  189 + var builder = new BlobBuilder();
  190 + if (blobParts) {
  191 + for (var i = 0, len = blobParts.length; i < len; i++) {
  192 + builder.append(blobParts[i]);
  193 + }
  194 + }
  195 + return builder.getBlob(type);
  196 + };
  197 +}(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this.content || this));
src/main/resources/static/pages/report/inoutstation/js/FileSaver.js 0 → 100644
  1 +/* FileSaver.js
  2 + * A saveAs() FileSaver implementation.
  3 + * 2014-08-29
  4 + *
  5 + * By Eli Grey, http://eligrey.com
  6 + * License: X11/MIT
  7 + * See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md
  8 + */
  9 +
  10 +/*global self */
  11 +/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
  12 +
  13 +/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
  14 +
  15 +var saveAs = saveAs
  16 + // IE 10+ (native saveAs)
  17 + || (typeof navigator !== "undefined" &&
  18 + navigator.msSaveOrOpenBlob && navigator.msSaveOrOpenBlob.bind(navigator))
  19 + // Everyone else
  20 + || (function(view) {
  21 + "use strict";
  22 + // IE <10 is explicitly unsupported
  23 + if (typeof navigator !== "undefined" &&
  24 + /MSIE [1-9]\./.test(navigator.userAgent)) {
  25 + return;
  26 + }
  27 + var
  28 + doc = view.document
  29 + // only get URL when necessary in case Blob.js hasn't overridden it yet
  30 + , get_URL = function() {
  31 + return view.URL || view.webkitURL || view;
  32 + }
  33 + , save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
  34 + , can_use_save_link = "download" in save_link
  35 + , click = function(node) {
  36 + var event = doc.createEvent("MouseEvents");
  37 + event.initMouseEvent(
  38 + "click", true, false, view, 0, 0, 0, 0, 0
  39 + , false, false, false, false, 0, null
  40 + );
  41 + node.dispatchEvent(event);
  42 + }
  43 + , webkit_req_fs = view.webkitRequestFileSystem
  44 + , req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem
  45 + , throw_outside = function(ex) {
  46 + (view.setImmediate || view.setTimeout)(function() {
  47 + throw ex;
  48 + }, 0);
  49 + }
  50 + , force_saveable_type = "application/octet-stream"
  51 + , fs_min_size = 0
  52 + // See https://code.google.com/p/chromium/issues/detail?id=375297#c7 for
  53 + // the reasoning behind the timeout and revocation flow
  54 + , arbitrary_revoke_timeout = 10
  55 + , revoke = function(file) {
  56 + var revoker = function() {
  57 + if (typeof file === "string") { // file is an object URL
  58 + get_URL().revokeObjectURL(file);
  59 + } else { // file is a File
  60 + file.remove();
  61 + }
  62 + };
  63 + if (view.chrome) {
  64 + revoker();
  65 + } else {
  66 + setTimeout(revoker, arbitrary_revoke_timeout);
  67 + }
  68 + }
  69 + , dispatch = function(filesaver, event_types, event) {
  70 + event_types = [].concat(event_types);
  71 + var i = event_types.length;
  72 + while (i--) {
  73 + var listener = filesaver["on" + event_types[i]];
  74 + if (typeof listener === "function") {
  75 + try {
  76 + listener.call(filesaver, event || filesaver);
  77 + } catch (ex) {
  78 + throw_outside(ex);
  79 + }
  80 + }
  81 + }
  82 + }
  83 + , FileSaver = function(blob, name) {
  84 + // First try a.download, then web filesystem, then object URLs
  85 + var
  86 + filesaver = this
  87 + , type = blob.type
  88 + , blob_changed = false
  89 + , object_url
  90 + , target_view
  91 + , dispatch_all = function() {
  92 + dispatch(filesaver, "writestart progress write writeend".split(" "));
  93 + }
  94 + // on any filesys errors revert to saving with object URLs
  95 + , fs_error = function() {
  96 + // don't create more object URLs than needed
  97 + if (blob_changed || !object_url) {
  98 + object_url = get_URL().createObjectURL(blob);
  99 + }
  100 + if (target_view) {
  101 + target_view.location.href = object_url;
  102 + } else {
  103 + var new_tab = view.open(object_url, "_blank");
  104 + if (new_tab == undefined && typeof safari !== "undefined") {
  105 + //Apple do not allow window.open, see http://bit.ly/1kZffRI
  106 + view.location.href = object_url
  107 + }
  108 + }
  109 + filesaver.readyState = filesaver.DONE;
  110 + dispatch_all();
  111 + revoke(object_url);
  112 + }
  113 + , abortable = function(func) {
  114 + return function() {
  115 + if (filesaver.readyState !== filesaver.DONE) {
  116 + return func.apply(this, arguments);
  117 + }
  118 + };
  119 + }
  120 + , create_if_not_found = {create: true, exclusive: false}
  121 + , slice
  122 + ;
  123 + filesaver.readyState = filesaver.INIT;
  124 + if (!name) {
  125 + name = "download";
  126 + }
  127 + if (can_use_save_link) {
  128 + object_url = get_URL().createObjectURL(blob);
  129 + save_link.href = object_url;
  130 + save_link.download = name;
  131 + click(save_link);
  132 + filesaver.readyState = filesaver.DONE;
  133 + dispatch_all();
  134 + revoke(object_url);
  135 + return;
  136 + }
  137 + // Object and web filesystem URLs have a problem saving in Google Chrome when
  138 + // viewed in a tab, so I force save with application/octet-stream
  139 + // http://code.google.com/p/chromium/issues/detail?id=91158
  140 + // Update: Google errantly closed 91158, I submitted it again:
  141 + // https://code.google.com/p/chromium/issues/detail?id=389642
  142 + if (view.chrome && type && type !== force_saveable_type) {
  143 + slice = blob.slice || blob.webkitSlice;
  144 + blob = slice.call(blob, 0, blob.size, force_saveable_type);
  145 + blob_changed = true;
  146 + }
  147 + // Since I can't be sure that the guessed media type will trigger a download
  148 + // in WebKit, I append .download to the filename.
  149 + // https://bugs.webkit.org/show_bug.cgi?id=65440
  150 + if (webkit_req_fs && name !== "download") {
  151 + name += ".download";
  152 + }
  153 + if (type === force_saveable_type || webkit_req_fs) {
  154 + target_view = view;
  155 + }
  156 + if (!req_fs) {
  157 + fs_error();
  158 + return;
  159 + }
  160 + fs_min_size += blob.size;
  161 + req_fs(view.TEMPORARY, fs_min_size, abortable(function(fs) {
  162 + fs.root.getDirectory("saved", create_if_not_found, abortable(function(dir) {
  163 + var save = function() {
  164 + dir.getFile(name, create_if_not_found, abortable(function(file) {
  165 + file.createWriter(abortable(function(writer) {
  166 + writer.onwriteend = function(event) {
  167 + target_view.location.href = file.toURL();
  168 + filesaver.readyState = filesaver.DONE;
  169 + dispatch(filesaver, "writeend", event);
  170 + revoke(file);
  171 + };
  172 + writer.onerror = function() {
  173 + var error = writer.error;
  174 + if (error.code !== error.ABORT_ERR) {
  175 + fs_error();
  176 + }
  177 + };
  178 + "writestart progress write abort".split(" ").forEach(function(event) {
  179 + writer["on" + event] = filesaver["on" + event];
  180 + });
  181 + writer.write(blob);
  182 + filesaver.abort = function() {
  183 + writer.abort();
  184 + filesaver.readyState = filesaver.DONE;
  185 + };
  186 + filesaver.readyState = filesaver.WRITING;
  187 + }), fs_error);
  188 + }), fs_error);
  189 + };
  190 + dir.getFile(name, {create: false}, abortable(function(file) {
  191 + // delete file if it already exists
  192 + file.remove();
  193 + save();
  194 + }), abortable(function(ex) {
  195 + if (ex.code === ex.NOT_FOUND_ERR) {
  196 + save();
  197 + } else {
  198 + fs_error();
  199 + }
  200 + }));
  201 + }), fs_error);
  202 + }), fs_error);
  203 + }
  204 + , FS_proto = FileSaver.prototype
  205 + , saveAs = function(blob, name) {
  206 + return new FileSaver(blob, name);
  207 + }
  208 + ;
  209 + FS_proto.abort = function() {
  210 + var filesaver = this;
  211 + filesaver.readyState = filesaver.DONE;
  212 + dispatch(filesaver, "abort");
  213 + };
  214 + FS_proto.readyState = FS_proto.INIT = 0;
  215 + FS_proto.WRITING = 1;
  216 + FS_proto.DONE = 2;
  217 +
  218 + FS_proto.error =
  219 + FS_proto.onwritestart =
  220 + FS_proto.onprogress =
  221 + FS_proto.onwrite =
  222 + FS_proto.onabort =
  223 + FS_proto.onerror =
  224 + FS_proto.onwriteend =
  225 + null;
  226 +
  227 + return saveAs;
  228 +}(
  229 + typeof self !== "undefined" && self
  230 + || typeof window !== "undefined" && window
  231 + || this.content
  232 +));
  233 +// `self` is undefined in Firefox for Android content script context
  234 +// while `this` is nsIContentFrameMessageManager
  235 +// with an attribute `content` that corresponds to the window
  236 +
  237 +if (typeof module !== "undefined" && module !== null) {
  238 + module.exports = saveAs;
  239 +} else if ((typeof define !== "undefined" && define !== null) && (define.amd != null)) {
  240 + define([], function() {
  241 + return saveAs;
  242 + });
  243 +}
src/main/resources/static/pages/report/inoutstation/js/tableExport.js 0 → 100644
  1 +
  2 +
  3 +(function(view){
  4 + "use strict";
  5 + var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  6 + var fromCharCode = String.fromCharCode;
  7 + var INVALID_CHARACTER_ERR = ( function() {
  8 + // fabricate a suitable error object
  9 + try {
  10 + document.createElement('$');
  11 + } catch (error) {
  12 + return error;
  13 + }
  14 + }());
  15 +
  16 + // encoder
  17 + var btoa = function(string) {
  18 + var a, b, b1, b2, b3, b4, c, i = 0, len = string.length, max = Math.max, result = '';
  19 +
  20 + while (i < len) {
  21 + a = string.charCodeAt(i++) || 0;
  22 + b = string.charCodeAt(i++) || 0;
  23 + c = string.charCodeAt(i++) || 0;
  24 +
  25 + if (max(a, b, c) > 0xFF) {
  26 + throw INVALID_CHARACTER_ERR;
  27 + }
  28 +
  29 + b1 = (a >> 2) & 0x3F;
  30 + b2 = ((a & 0x3) << 4) | ((b >> 4) & 0xF);
  31 + b3 = ((b & 0xF) << 2) | ((c >> 6) & 0x3);
  32 + b4 = c & 0x3F;
  33 +
  34 + if (!b) {
  35 + b3 = b4 = 64;
  36 + } else if (!c) {
  37 + b4 = 64;
  38 + }
  39 + result += characters.charAt(b1) + characters.charAt(b2) + characters.charAt(b3) + characters.charAt(b4);
  40 + }
  41 + return result;
  42 + };
  43 +
  44 + //获取dom文本
  45 + var getText = function( el ){
  46 + var s = el.textContent || el.innerText;
  47 + return s == null ? "" : s.replace( /^\s*(.*?)\s+$/, "$1");
  48 + };
  49 + view.tableExport = function(tableId, filename, type){
  50 + var doc = view.document,
  51 + table = doc.getElementById(tableId),
  52 + charSet = doc.characterSet
  53 +
  54 + var uri = {
  55 + json: 'application/json;charset='+charSet,
  56 + txt: 'csv/txt;charset='+charSet,
  57 + csv: 'csv/txt;charset='+charSet,
  58 + doc: 'application/vnd.ms-doc',
  59 + excel: 'application/vnd.ms-excel'
  60 + };
  61 +
  62 + var base64 = function(s) {
  63 + return btoa(unescape(encodeURIComponent(s)));
  64 + };
  65 + var template = function(s, c) {
  66 + return s.replace(/{(\w+)}/g, function(m, p) {
  67 + return c[p];
  68 + });
  69 + };
  70 +
  71 + var get_blob = function() {
  72 + return view.Blob;
  73 + }
  74 +
  75 + var fixCSVField = function(value) {
  76 + var fixedValue = value;
  77 + var addQuotes = (value.indexOf(',') !== -1) || (value.indexOf('\r') !== -1) || (value.indexOf('\n') !== -1);
  78 + var replaceDoubleQuotes = (value.indexOf('"') !== -1);
  79 +
  80 + if (replaceDoubleQuotes) {
  81 + fixedValue = fixedValue.replace(/"/g, '""');
  82 + }
  83 + if (addQuotes || replaceDoubleQuotes) {
  84 + fixedValue = '"' + fixedValue + '"';
  85 + }
  86 + return fixedValue;
  87 + };
  88 +
  89 + var saveData = function(data){
  90 + var BB = get_blob();
  91 + saveAs(new BB([data], {type: uri[type]}), filename + "."+type);
  92 + };
  93 +
  94 + var toCSV = function(){
  95 + var data = "\ufeff";
  96 + for (var i = 0, row; row = table.rows[i]; i++) {
  97 + for (var j = 0, col; col = row.cells[j]; j++) {
  98 + data = data + (j ? ',' : '') + fixCSVField(getText(col));
  99 + }
  100 + data = data + "\r\n";
  101 + }
  102 + saveData(data);
  103 + };
  104 +
  105 + var toJson = function(){
  106 + var jsonHeaderArray = [];
  107 +
  108 + if(table.tHead){
  109 + for(var i =0,col; col = table.tHead.rows[0].cells[i]; i++){
  110 + jsonHeaderArray.push(getText(col));
  111 + }
  112 + }
  113 +
  114 + var jsonArray = [];
  115 + if(table.tBodies){
  116 + for(var j=0,tbody; tbody = table.tBodies[j]; j++){
  117 + for(var k =0, rowb; rowb= tbody.rows[k]; k++){
  118 + var len = jsonArray.length;
  119 + jsonArray[len] = [];
  120 + for (var g = 0, colb; colb = rowb.cells[g]; g++) {
  121 + jsonArray[len].push(getText(colb));
  122 + }
  123 + }
  124 + }
  125 + }
  126 +
  127 + var jsonExportArray = {
  128 + header: jsonHeaderArray,
  129 + data: jsonArray
  130 + };
  131 + saveData(JSON.stringify(jsonExportArray));
  132 + };
  133 +
  134 + var toOffice = function(){
  135 + var tmpl = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:'+type+'" xmlns="http://www.w3.org/TR/REC-html40">';
  136 + tmpl += '<head><meta charset="'+charSet+'" /><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>';
  137 + tmpl += '{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->';
  138 + tmpl += '</head><body><table>{table}</table></body></html>';
  139 + var office = '',
  140 + maph = [['<thead><tr>', '</tr></thead>'], ['<tbody><tr>', '</tr></tbody>'], ['<tr>', '</tr>']],
  141 + mapb = [['<th>', '</th>'],['<td>', '</td>']],
  142 + flag = +!table.tHead,
  143 + com = 1 - flag;
  144 +
  145 + for(var i=0, row; row = table.rows[i]; i++){
  146 + flag = i > com ? 2 : flag;
  147 + office += maph[flag][0];
  148 + for(var j =0, col; col = row.cells[j]; j++){
  149 + office += mapb[+!!flag][0]+ getText(col) +mapb[+!!flag][1];
  150 + }
  151 + office += maph[flag][1];
  152 + flag++;
  153 + }
  154 + saveData(template(tmpl, {worksheet: 'Worksheet', table: office}));
  155 + };
  156 +
  157 + var typeMap = {
  158 + json : toJson,
  159 + txt: toCSV,
  160 + csv: toCSV,
  161 + doc: toOffice,
  162 + docx: toOffice,
  163 + xls: toOffice,
  164 + xlsx: toOffice
  165 + };
  166 +
  167 + typeMap[type]();
  168 + };
  169 +
  170 +})(window);
0 \ No newline at end of file 171 \ No newline at end of file
src/main/resources/static/pages/summary/fast_and_slow/data.html
1 -<div class="ct_data_body_wrap">  
2 - <div class="uk-card uk-card-default uk-card-body ct_rq_left">  
3 - <ul uk-scrollspy-nav="closest: li; scroll: true; offset: 100"  
4 - class="uk-nav uk-nav-default tm-nav uk-nav-parent-icon">  
5 - <li class="uk-active"><a href="#table_20171010">2017-10-10</a></li>  
6 - <li><a href="#table_20171011">2017-10-11</a></li>  
7 - <li><a href="#table_20171012">2017-10-12</a></li>  
8 - <li><a href="#table_20171013">2017-10-13</a></li>  
9 - <li><a href="#table_20171014">2017-10-14</a></li>  
10 - <li><a href="#table_20171015">2017-10-15</a></li>  
11 - <li><a href="#table_20171016">2017-10-16</a></li>  
12 - </ul>  
13 - </div>  
14 -  
15 - <div class="uk-card uk-card-default uk-card-body ct_right_tables">  
16 - <div id="table_20171010">  
17 - <table>  
18 -  
19 - </table>  
20 - </div>  
21 - </div>  
22 -  
23 - <script>  
24 - (function () {  
25 - var wrap = '.ct_data_body_wrap';  
26 -  
27 - $(wrap).on('init', function (e, data) {  
28 - e.stopPropagation();  
29 - console.log('data init');  
30 -  
31 - });  
32 - })();  
33 - </script> 1 +<div class="ct_data_body_wrap">
  2 + <div class="uk-card uk-card-default uk-card-body ct_rq_left">
  3 + <ul uk-scrollspy-nav="closest: li; scroll: true; offset: 100"
  4 + class="uk-nav uk-nav-default tm-nav uk-nav-parent-icon">
  5 + <li class="uk-active"><a href="#table_20171010">2017-10-10</a></li>
  6 + <li><a href="#table_20171011">2017-10-11</a></li>
  7 + <li><a href="#table_20171012">2017-10-12</a></li>
  8 + <li><a href="#table_20171013">2017-10-13</a></li>
  9 + <li><a href="#table_20171014">2017-10-14</a></li>
  10 + <li><a href="#table_20171015">2017-10-15</a></li>
  11 + <li><a href="#table_20171016">2017-10-16</a></li>
  12 + </ul>
  13 + </div>
  14 +
  15 + <div class="uk-card uk-card-default uk-card-body ct_right_tables">
  16 + <div id="table_20171010">
  17 + <table>
  18 +
  19 + </table>
  20 + </div>
  21 + </div>
  22 +
  23 + <script>
  24 + (function () {
  25 + var wrap = '.ct_data_body_wrap';
  26 +
  27 + $(wrap).on('init', function (e, data) {
  28 + e.stopPropagation();
  29 + console.log('data init');
  30 +
  31 + });
  32 + })();
  33 + </script>
34 </div> 34 </div>
35 \ No newline at end of file 35 \ No newline at end of file
src/main/resources/static/pages/summary/fast_and_slow/f_a_s_wrap.html
1 -<!-- 快慢误点统计 --> 1 +<!-- 快慢误点统计 -->
2 <iframe src="/pages/summary/fast_and_slow/main.html?origin=real_control_iframe" frameborder="0" style="height: 100%;width: 100%;"></iframe> 2 <iframe src="/pages/summary/fast_and_slow/main.html?origin=real_control_iframe" frameborder="0" style="height: 100%;width: 100%;"></iframe>
3 \ No newline at end of file 3 \ No newline at end of file
src/main/resources/static/pages/summary/fast_and_slow/main.html
1 -<!DOCTYPE html>  
2 -<html lang="zh-cn">  
3 -  
4 -<head>  
5 - <meta charset="UTF-8">  
6 - <link rel="stylesheet" href="/assets/plugins/uk3.0/uikit.min.css"/>  
7 - <link rel="stylesheet" href="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.css" />  
8 - <!-- flatpickr -->  
9 - <link rel="stylesheet" href="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.css">  
10 - <style>  
11 - html,body{  
12 - height: 100%;  
13 - }  
14 - .ct_page{  
15 - padding: 25px 15px;  
16 - height: 100%;  
17 - height: calc(100% - 50px);  
18 - }  
19 -  
20 - .ct_cont{  
21 - height: calc(100% - 35px);  
22 - }  
23 -  
24 - .ct_cont>div>div.uk-card{  
25 - height: 99%;  
26 - }  
27 -  
28 - .loading{  
29 - height: 100%;  
30 - text-align: center;  
31 - }  
32 - .loading .uk-spinner{  
33 - margin-top: 200px;  
34 - }  
35 - .loading circle{  
36 - stroke: red;  
37 - }  
38 -  
39 - .ps-container > .ps-scrollbar-x-rail, .ps-container > .ps-scrollbar-y-rail{  
40 - opacity: 0.6 !important;  
41 - padding: 0 !important;  
42 - }  
43 -  
44 - .ct_search_form_wrap{  
45 - border-bottom: 1px solid #e5e5e5;  
46 - padding: 10px 0 25px 10px;  
47 - }  
48 - .ct_search_form_wrap .ct_field{  
49 - display: inline-block;  
50 - margin: 0 5px;  
51 - }  
52 -  
53 - .ct_search_form_wrap .ct_field label{  
54 - font-size: 14px;  
55 - }  
56 -  
57 - .ct_search_form_wrap .ct_field input[type=text]{  
58 - width: 110px;  
59 - }  
60 -  
61 - .ct_search_form_wrap .ct_field select{  
62 - width: auto;  
63 - min-width: 100px;  
64 - }  
65 -  
66 - .ct_search_form_wrap .uk-button{  
67 - padding: 0 14px;  
68 - }  
69 -  
70 - .ct_search_form_wrap .uk-button i{  
71 - vertical-align: middle;  
72 - margin-top: -2px;  
73 - margin-right: 7px;  
74 - }  
75 -  
76 - .ct_field.ct_field_bottom{  
77 - vertical-align: bottom;  
78 - font-size: 12px;  
79 - margin-left: 0;  
80 - }  
81 -  
82 - .ct_cont_body{  
83 - height: calc(100% - 88px);  
84 - width: 100%;  
85 - padding-top: 12px;  
86 - }  
87 -  
88 - .ct_data_body_wrap{  
89 - height: 100%;  
90 - width: 100%;  
91 - }  
92 -  
93 - .ct_rq_left{  
94 - width: 200px;  
95 - display: inline-block;  
96 - vertical-align: top;  
97 - height: 99%;  
98 - height: calc(100% - 5px);  
99 - }  
100 -  
101 - .ct_right_tables{  
102 - width: calc(100% - 220px);  
103 - display: inline-block;  
104 - margin-left: 12px;  
105 - height: 99%;  
106 - height: calc(100% - 5px);  
107 - }  
108 -  
109 - .tm-nav>li a{  
110 - position: relative;  
111 - font-size: 15px;  
112 - }  
113 - .tm-nav>li.uk-active>a:before {  
114 - content: "";  
115 - position: absolute;  
116 - width: 15px;  
117 - border-top: 1px solid #1e87f0;  
118 - z-index: 9;  
119 - right: 60px;  
120 - top: 15px;  
121 - }  
122 - .uk-nav-default>li.uk-active>a {  
123 - color: #222;  
124 - }  
125 - </style>  
126 -</head>  
127 -  
128 -<body>  
129 -<div class="loading">  
130 - <div uk-spinner></div>  
131 -</div>  
132 -<div class="ct_page" style="display: none;">  
133 - <h3 class="uk-heading-line uk-heading-bullet"><span>快慢误点统计</span></h3>  
134 - <div class="ct_cont" >  
135 - <div class="ct_search_form_wrap">  
136 - <form>  
137 - <div class="ct_field">  
138 - <label>公司:  
139 - <select class="uk-select" name="companyId_eq">  
140 - </select>  
141 - </label>  
142 - </div>  
143 - <div class="ct_field">  
144 - <label>分公司:  
145 - <select class="uk-select" name="subCompanyId_eq">  
146 - </select>  
147 - </label>  
148 - </div>  
149 - <div class="ct_field">  
150 - <label>线路:  
151 - <select class="uk-select" name="lineCode_eq">  
152 - </select>  
153 - </label>  
154 - </div>  
155 - <div class="ct_field">  
156 - <label>日期范围:  
157 - <input class="uk-input" name="rq" style="width: 200px;">  
158 - </label>  
159 - </div>  
160 - <div class="ct_field">  
161 - <label><input class="uk-radio" type="radio" name="type" checked> 全部</label>&nbsp;  
162 - <label><input class="uk-radio" type="radio" name="type"> 快误</label>&nbsp;  
163 - <label><input class="uk-radio" type="radio" name="type"> 慢误</label>  
164 - </div>  
165 - <div class="ct_field">  
166 - <button class="uk-button uk-button-primary search"><i uk-icon="icon: search"></i>搜索</button>  
167 - </div>  
168 - <div class="ct_field ct_field_bottom">  
169 - <button class="uk-button uk-button-text" style="padding: 0 5px;">导出数据</button>  
170 - </div>  
171 - <div class="ct_field ct_field_bottom">  
172 - <span uk-icon="icon: question" title="统计 “正常”、“区间”、“放站” 班次" uk-tooltip="pos: bottom"></span>  
173 - </div>  
174 - </form>  
175 - </div>  
176 -  
177 - <div class="ct_cont_body">  
178 - </div>  
179 - </div>  
180 -</div>  
181 -  
182 -<script src="/metronic_v4.5.4/plugins/jquery.min.js"></script>  
183 -<script src="/assets/plugins/uk3.0/uikit.min.js"></script>  
184 -<script src="/assets/plugins/uk3.0/uikit-icons.min.js"></script>  
185 -<script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js" ></script>  
186 -<!-- EventProxy -->  
187 -<script src="/assets/js/eventproxy.js"></script>  
188 -<!-- art-template 模版引擎 -->  
189 -<script src="/assets/plugins/template.js"></script>  
190 -<script src="/real_control_v2/assets/plugins/moment/moment.min.js"></script>  
191 -<!-- jquery.serializejson JSON序列化插件 -->  
192 -<script src="/assets/plugins/jquery.serializejson.js" merge="plugins"></script>  
193 -<!-- flatpickr -->  
194 -<script src="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.js" ></script>  
195 -<script src="/real_control_v2/assets/plugins/flatpickr/l10n/zh.js" ></script>  
196 -<script>  
197 -  
198 -(function () {  
199 - //var data_dom;  
200 - var f = $('form', '');  
201 - var ep = EventProxy.create('query_comps', 'query_lines', function () {  
202 - $('[name=companyId_eq]', f).trigger('change');//公司change  
203 - //query();  
204 -  
205 - $('.loading').remove();  
206 - $('.ct_page').show();  
207 - });  
208 -  
209 - $.get('/pages/summary/fast_and_slow/data.html', function (rs) {  
210 - $('.ct_cont_body').html(rs);  
211 - });  
212 -  
213 - //点击搜索按钮  
214 - $('.search', f).on('click', function () {  
215 - $('.ct_data_body_wrap').trigger('init');  
216 - });  
217 -  
218 - //日期选择框  
219 - var fs='YYYY-MM-DD'  
220 - , ets=moment().format(fs)  
221 - , sts=moment().subtract(7, 'days').format(fs);  
222 - flatpickr('.ct_search_form_wrap [name=rq]', {  
223 - mode: "range", dateFormat: "Y-m-d","locale": "zh", defaultDate: [sts, ets]  
224 - });  
225 - var comps;  
226 - //构建公司级联下拉框  
227 - $.get('/user/companyData', function (rs) {  
228 - comps = rs;  
229 - var opts = '';  
230 - for(var i=0,obj;obj=comps[i++];){  
231 - opts += '<option value="'+obj.companyCode+'">'+obj.companyName+'</option>';  
232 - }  
233 - $('[name=companyId_eq]', f).html(opts);  
234 - ep.emit('query_comps');  
235 - });  
236 - var lineMapps;  
237 - //加载线路信息  
238 - $.get('/line/all', {'destroy_eq': 0}, function (rs) {  
239 - rs.sort(function (a, b) {  
240 - return a.name.localeCompare(b.name);  
241 - });  
242 - lineMapps={};  
243 - var k;  
244 - $.each(rs, function () {  
245 - k = this.company+'_'+this.brancheCompany;  
246 - if(!lineMapps[k])  
247 - lineMapps[k]=[];  
248 - lineMapps[k].push(this);  
249 - });  
250 -  
251 - ep.emit('query_lines');  
252 - });  
253 -  
254 - $('[name=companyId_eq]', f).on('change', function () {  
255 - var code = $(this).val(), subs=[];  
256 - $.each(comps, function () {  
257 - if(this.companyCode==code)  
258 - subs=this.children;  
259 - });  
260 -  
261 - var opts='';  
262 - $.each(subs, function () {  
263 - opts += '<option value="'+this.code+'">'+this.name+'</option>';  
264 - });  
265 - $('[name=subCompanyId_eq]', f).html(opts).trigger('change');  
266 - });  
267 -  
268 - $('[name=subCompanyId_eq]', f).on('change', function () {  
269 - var k = $('[name=companyId_eq]', f).val() + '_' + $(this).val();  
270 - var array = lineMapps[k];  
271 - var opts = '';  
272 - if(array){  
273 - $.each(array, function () {  
274 - opts += '<option value="'+this.lineCode+'">'+this.name+'</option>';  
275 - });  
276 - }  
277 - $('[name=lineCode_eq]', f).html(opts);  
278 - });  
279 -})();  
280 -</script>  
281 -</body> 1 +<!DOCTYPE html>
  2 +<html lang="zh-cn">
  3 +
  4 +<head>
  5 + <meta charset="UTF-8">
  6 + <link rel="stylesheet" href="/assets/plugins/uk3.0/uikit.min.css"/>
  7 + <link rel="stylesheet" href="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.css" />
  8 + <!-- flatpickr -->
  9 + <link rel="stylesheet" href="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.css">
  10 + <style>
  11 + html,body{
  12 + height: 100%;
  13 + }
  14 + .ct_page{
  15 + padding: 25px 15px;
  16 + height: 100%;
  17 + height: calc(100% - 50px);
  18 + }
  19 +
  20 + .ct_cont{
  21 + height: calc(100% - 35px);
  22 + }
  23 +
  24 + .ct_cont>div>div.uk-card{
  25 + height: 99%;
  26 + }
  27 +
  28 + .loading{
  29 + height: 100%;
  30 + text-align: center;
  31 + }
  32 + .loading .uk-spinner{
  33 + margin-top: 200px;
  34 + }
  35 + .loading circle{
  36 + stroke: red;
  37 + }
  38 +
  39 + .ps-container > .ps-scrollbar-x-rail, .ps-container > .ps-scrollbar-y-rail{
  40 + opacity: 0.6 !important;
  41 + padding: 0 !important;
  42 + }
  43 +
  44 + .ct_search_form_wrap{
  45 + border-bottom: 1px solid #e5e5e5;
  46 + padding: 10px 0 25px 10px;
  47 + }
  48 + .ct_search_form_wrap .ct_field{
  49 + display: inline-block;
  50 + margin: 0 5px;
  51 + }
  52 +
  53 + .ct_search_form_wrap .ct_field label{
  54 + font-size: 14px;
  55 + }
  56 +
  57 + .ct_search_form_wrap .ct_field input[type=text]{
  58 + width: 110px;
  59 + }
  60 +
  61 + .ct_search_form_wrap .ct_field select{
  62 + width: auto;
  63 + min-width: 100px;
  64 + }
  65 +
  66 + .ct_search_form_wrap .uk-button{
  67 + padding: 0 14px;
  68 + }
  69 +
  70 + .ct_search_form_wrap .uk-button i{
  71 + vertical-align: middle;
  72 + margin-top: -2px;
  73 + margin-right: 7px;
  74 + }
  75 +
  76 + .ct_field.ct_field_bottom{
  77 + vertical-align: bottom;
  78 + font-size: 12px;
  79 + margin-left: 0;
  80 + }
  81 +
  82 + .ct_cont_body{
  83 + height: calc(100% - 88px);
  84 + width: 100%;
  85 + padding-top: 12px;
  86 + }
  87 +
  88 + .ct_data_body_wrap{
  89 + height: 100%;
  90 + width: 100%;
  91 + }
  92 +
  93 + .ct_rq_left{
  94 + width: 200px;
  95 + display: inline-block;
  96 + vertical-align: top;
  97 + height: 99%;
  98 + height: calc(100% - 5px);
  99 + }
  100 +
  101 + .ct_right_tables{
  102 + width: calc(100% - 220px);
  103 + display: inline-block;
  104 + margin-left: 12px;
  105 + height: 99%;
  106 + height: calc(100% - 5px);
  107 + }
  108 +
  109 + .tm-nav>li a{
  110 + position: relative;
  111 + font-size: 15px;
  112 + }
  113 + .tm-nav>li.uk-active>a:before {
  114 + content: "";
  115 + position: absolute;
  116 + width: 15px;
  117 + border-top: 1px solid #1e87f0;
  118 + z-index: 9;
  119 + right: 60px;
  120 + top: 15px;
  121 + }
  122 + .uk-nav-default>li.uk-active>a {
  123 + color: #222;
  124 + }
  125 + </style>
  126 +</head>
  127 +
  128 +<body>
  129 +<div class="loading">
  130 + <div uk-spinner></div>
  131 +</div>
  132 +<div class="ct_page" style="display: none;">
  133 + <h3 class="uk-heading-line uk-heading-bullet"><span>快慢误点统计</span></h3>
  134 + <div class="ct_cont" >
  135 + <div class="ct_search_form_wrap">
  136 + <form>
  137 + <div class="ct_field">
  138 + <label>公司:
  139 + <select class="uk-select" name="companyId_eq">
  140 + </select>
  141 + </label>
  142 + </div>
  143 + <div class="ct_field">
  144 + <label>分公司:
  145 + <select class="uk-select" name="subCompanyId_eq">
  146 + </select>
  147 + </label>
  148 + </div>
  149 + <div class="ct_field">
  150 + <label>线路:
  151 + <select class="uk-select" name="lineCode_eq">
  152 + </select>
  153 + </label>
  154 + </div>
  155 + <div class="ct_field">
  156 + <label>日期范围:
  157 + <input class="uk-input" name="rq" style="width: 200px;">
  158 + </label>
  159 + </div>
  160 + <div class="ct_field">
  161 + <label><input class="uk-radio" type="radio" name="type" checked> 全部</label>&nbsp;
  162 + <label><input class="uk-radio" type="radio" name="type"> 快误</label>&nbsp;
  163 + <label><input class="uk-radio" type="radio" name="type"> 慢误</label>
  164 + </div>
  165 + <div class="ct_field">
  166 + <button class="uk-button uk-button-primary search"><i uk-icon="icon: search"></i>搜索</button>
  167 + </div>
  168 + <div class="ct_field ct_field_bottom">
  169 + <button class="uk-button uk-button-text" style="padding: 0 5px;">导出数据</button>
  170 + </div>
  171 + <div class="ct_field ct_field_bottom">
  172 + <span uk-icon="icon: question" title="统计 “正常”、“区间”、“放站” 班次" uk-tooltip="pos: bottom"></span>
  173 + </div>
  174 + </form>
  175 + </div>
  176 +
  177 + <div class="ct_cont_body">
  178 + </div>
  179 + </div>
  180 +</div>
  181 +
  182 +<script src="/metronic_v4.5.4/plugins/jquery.min.js"></script>
  183 +<script src="/assets/plugins/uk3.0/uikit.min.js"></script>
  184 +<script src="/assets/plugins/uk3.0/uikit-icons.min.js"></script>
  185 +<script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js" ></script>
  186 +<!-- EventProxy -->
  187 +<script src="/assets/js/eventproxy.js"></script>
  188 +<!-- art-template 模版引擎 -->
  189 +<script src="/assets/plugins/template.js"></script>
  190 +<script src="/real_control_v2/assets/plugins/moment/moment.min.js"></script>
  191 +<!-- jquery.serializejson JSON序列化插件 -->
  192 +<script src="/assets/plugins/jquery.serializejson.js" merge="plugins"></script>
  193 +<!-- flatpickr -->
  194 +<script src="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.js" ></script>
  195 +<script src="/real_control_v2/assets/plugins/flatpickr/l10n/zh.js" ></script>
  196 +<script>
  197 +
  198 +(function () {
  199 + //var data_dom;
  200 + var f = $('form', '');
  201 + var ep = EventProxy.create('query_comps', 'query_lines', function () {
  202 + $('[name=companyId_eq]', f).trigger('change');//公司change
  203 + //query();
  204 +
  205 + $('.loading').remove();
  206 + $('.ct_page').show();
  207 + });
  208 +
  209 + $.get('/pages/summary/fast_and_slow/data.html', function (rs) {
  210 + $('.ct_cont_body').html(rs);
  211 + });
  212 +
  213 + //点击搜索按钮
  214 + $('.search', f).on('click', function () {
  215 + $('.ct_data_body_wrap').trigger('init');
  216 + });
  217 +
  218 + //日期选择框
  219 + var fs='YYYY-MM-DD'
  220 + , ets=moment().format(fs)
  221 + , sts=moment().subtract(7, 'days').format(fs);
  222 + flatpickr('.ct_search_form_wrap [name=rq]', {
  223 + mode: "range", dateFormat: "Y-m-d","locale": "zh", defaultDate: [sts, ets]
  224 + });
  225 + var comps;
  226 + //构建公司级联下拉框
  227 + $.get('/user/companyData', function (rs) {
  228 + comps = rs;
  229 + var opts = '';
  230 + for(var i=0,obj;obj=comps[i++];){
  231 + opts += '<option value="'+obj.companyCode+'">'+obj.companyName+'</option>';
  232 + }
  233 + $('[name=companyId_eq]', f).html(opts);
  234 + ep.emit('query_comps');
  235 + });
  236 + var lineMapps;
  237 + //加载线路信息
  238 + $.get('/line/all', {'destroy_eq': 0}, function (rs) {
  239 + rs.sort(function (a, b) {
  240 + return a.name.localeCompare(b.name);
  241 + });
  242 + lineMapps={};
  243 + var k;
  244 + $.each(rs, function () {
  245 + k = this.company+'_'+this.brancheCompany;
  246 + if(!lineMapps[k])
  247 + lineMapps[k]=[];
  248 + lineMapps[k].push(this);
  249 + });
  250 +
  251 + ep.emit('query_lines');
  252 + });
  253 +
  254 + $('[name=companyId_eq]', f).on('change', function () {
  255 + var code = $(this).val(), subs=[];
  256 + $.each(comps, function () {
  257 + if(this.companyCode==code)
  258 + subs=this.children;
  259 + });
  260 +
  261 + var opts='';
  262 + $.each(subs, function () {
  263 + opts += '<option value="'+this.code+'">'+this.name+'</option>';
  264 + });
  265 + $('[name=subCompanyId_eq]', f).html(opts).trigger('change');
  266 + });
  267 +
  268 + $('[name=subCompanyId_eq]', f).on('change', function () {
  269 + var k = $('[name=companyId_eq]', f).val() + '_' + $(this).val();
  270 + var array = lineMapps[k];
  271 + var opts = '';
  272 + if(array){
  273 + $.each(array, function () {
  274 + opts += '<option value="'+this.lineCode+'">'+this.name+'</option>';
  275 + });
  276 + }
  277 + $('[name=lineCode_eq]', f).html(opts);
  278 + });
  279 +})();
  280 +</script>
  281 +</body>
282 </html> 282 </html>
283 \ No newline at end of file 283 \ No newline at end of file