Commit 4eb90db480908763850602436acf08598017940c

Authored by yiming
1 parent 8ed54c91

bf

bsthLineProfiles/src/main/java/com/ruoyi/project/system/line/controller/BsthTLineAddController.java
... ... @@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
18 18 import org.springframework.stereotype.Controller;
19 19 import org.springframework.ui.ModelMap;
20 20 import org.springframework.web.bind.annotation.*;
  21 +import org.springframework.web.servlet.ModelAndView;
21 22  
22 23 import java.io.File;
23 24 import java.lang.reflect.Field;
... ... @@ -49,12 +50,16 @@ public class BsthTLineAddController extends BaseController
49 50  
50 51 @Autowired
51 52 private IUserService userService;
52   -
  53 +
53 54 @RequiresPermissions("system:line:view")
54 55 @GetMapping()
55   - public String line()
  56 + public ModelAndView line()
56 57 {
57   - return prefix + "/line";
  58 +
  59 + ModelAndView mv=new ModelAndView(prefix + "/line");
  60 + List<Map> companyList=bsthTLineService.selectCompany();
  61 + mv.addObject("companyList",companyList);
  62 + return mv;
58 63 }
59 64  
60 65 @GetMapping("/map")
... ...
bsthLineProfiles/src/main/java/com/ruoyi/project/system/line/controller/BsthTLineExamineController.java
... ... @@ -15,9 +15,11 @@ import org.springframework.beans.factory.annotation.Autowired;
15 15 import org.springframework.stereotype.Controller;
16 16 import org.springframework.ui.ModelMap;
17 17 import org.springframework.web.bind.annotation.*;
  18 +import org.springframework.web.servlet.ModelAndView;
18 19  
19 20  
20 21 import java.util.List;
  22 +import java.util.Map;
21 23  
22 24  
23 25 /**
... ... @@ -41,14 +43,16 @@ public class BsthTLineExamineController extends BaseController
41 43  
42 44  
43 45  
44   -
45 46 @RequiresPermissions("system:line:view")
46 47 @GetMapping()
47   - public String line()
  48 + public ModelAndView line()
48 49 {
49   - return prefix + "/line";
50   - }
51 50  
  51 + ModelAndView mv=new ModelAndView(prefix + "/line");
  52 + List<Map> companyList=bsthTLineService.selectCompany();
  53 + mv.addObject("companyList",companyList);
  54 + return mv;
  55 + }
52 56  
53 57 @GetMapping("/map")
54 58 public String map()
... ...
bsthLineProfiles/src/main/java/com/ruoyi/project/system/line/controller/BsthTLineHistoryController.java
... ... @@ -30,6 +30,7 @@ import com.ruoyi.common.utils.ServletUtils;
30 30 import com.ruoyi.common.utils.poi.ExcelUtil;
31 31 import com.ruoyi.common.utils.security.ShiroUtils;
32 32 import com.ruoyi.framework.web.page.TableDataInfo;
  33 +import org.springframework.web.servlet.ModelAndView;
33 34  
34 35 /**
35 36 * 【请填写功能名称】Controller
... ... @@ -53,13 +54,17 @@ public class BsthTLineHistoryController extends BaseController
53 54 @Autowired
54 55 private IUserService userService;
55 56  
  57 +
56 58 @RequiresPermissions("system:lineHistory:view")
57 59 @GetMapping()
58   - public String line()
  60 + public ModelAndView line()
59 61 {
60   - return prefix + "/line";
61   - }
62 62  
  63 + ModelAndView mv=new ModelAndView(prefix + "/line");
  64 + List<Map> companyList=bsthTLineService.selectCompany();
  65 + mv.addObject("companyList",companyList);
  66 + return mv;
  67 + }
63 68  
64 69 /**
65 70 * 变更分页
... ...
bsthLineProfiles/src/main/java/com/ruoyi/project/system/user/controller/LoginController.java
1 1 package com.ruoyi.project.system.user.controller;
2 2  
  3 +import java.util.ArrayList;
3 4 import java.util.Date;
  5 +import java.util.HashMap;
4 6 import java.util.List;
  7 +import java.util.Map;
5 8  
6   -import javax.servlet.http.Cookie;
7 9 import javax.servlet.http.HttpServletRequest;
8 10 import javax.servlet.http.HttpServletResponse;
9 11  
  12 +import org.apache.http.HttpResponse;
  13 +import org.apache.http.client.HttpClient;
  14 +import org.apache.http.client.methods.HttpPost;
  15 +import org.apache.http.entity.StringEntity;
  16 +import org.apache.http.impl.client.DefaultHttpClient;
  17 +import org.apache.http.impl.client.HttpClientBuilder;
  18 +import org.apache.http.util.EntityUtils;
10 19 import org.apache.shiro.SecurityUtils;
11 20 import org.apache.shiro.authc.AuthenticationException;
12 21 import org.apache.shiro.authc.UsernamePasswordToken;
... ... @@ -18,6 +27,9 @@ import org.springframework.web.bind.annotation.GetMapping;
18 27 import org.springframework.web.bind.annotation.PostMapping;
19 28 import org.springframework.web.bind.annotation.ResponseBody;
20 29  
  30 +import com.alibaba.fastjson.JSON;
  31 +import com.alibaba.fastjson.JSONArray;
  32 +import com.alibaba.fastjson.JSONObject;
21 33 import com.ruoyi.common.utils.DateUtils;
22 34 import com.ruoyi.common.utils.ServletUtils;
23 35 import com.ruoyi.common.utils.StringUtils;
... ... @@ -26,13 +38,15 @@ import com.ruoyi.framework.config.RuoYiConfig;
26 38 import com.ruoyi.framework.shiro.service.PasswordService;
27 39 import com.ruoyi.framework.web.controller.BaseController;
28 40 import com.ruoyi.framework.web.domain.AjaxResult;
  41 +import com.ruoyi.framework.web.service.PermissionService;
29 42 import com.ruoyi.framework.web.service.TokenService;
30 43 import com.ruoyi.project.system.config.service.IConfigService;
31 44 import com.ruoyi.project.system.menu.domain.Menu;
32 45 import com.ruoyi.project.system.menu.service.IMenuService;
33   -import com.ruoyi.project.system.menu.service.MenuServiceImpl;
34 46 import com.ruoyi.project.system.user.domain.User;
35 47  
  48 +import io.jsonwebtoken.lang.Assert;
  49 +
36 50 /**
37 51 * 登录验证
38 52 *
... ... @@ -56,6 +70,7 @@ public class LoginController extends BaseController
56 70 @Autowired
57 71 private RuoYiConfig ruoYiConfig;
58 72  
  73 +
59 74 @GetMapping("/login")
60 75 public String login(HttpServletRequest request, HttpServletResponse response)
61 76 {
... ... @@ -74,44 +89,72 @@ public class LoginController extends BaseController
74 89  
75 90 if(token != null) {
76 91  
77   - login("admin","admin123",false);
78   -
79   - // 取身份信息
80   - User user = getSysUser();
81   - // 根据用户id取出菜单
82   - List<Menu> menus = menuService.selectMenusByUser(user);
83   - mmap.put("menus", menus);
84   - mmap.put("user", user);
85   - mmap.put("sideTheme", "theme-dark");
86   - mmap.put("skinName", "skin-blue");
87   - mmap.put("ignoreFooter", configService.selectConfigByKey("sys.index.ignoreFooter"));
88   - mmap.put("copyrightYear", ruoYiConfig.getCopyrightYear());
89   - mmap.put("demoEnabled", ruoYiConfig.isDemoEnabled());
90   - mmap.put("isDefaultModifyPwd", initPasswordIsModify(user.getPwdUpdateDate()));
91   - mmap.put("isPasswordExpired", passwordIsExpiration(user.getPwdUpdateDate()));
92   -
93   - // 菜单导航显示风格
94   - String menuStyle = configService.selectConfigByKey("sys.index.menuStyle");
95   - // 移动端,默认使左侧导航菜单,否则取默认配置
96   - String indexStyle = ServletUtils.checkAgentIsMobile(ServletUtils.getRequest().getHeader("User-Agent")) ? "index" : menuStyle;
97   -
98   - // 优先Cookie配置导航菜单
99   - Cookie[] cookies = ServletUtils.getRequest().getCookies();
100   - for (Cookie cookie : cookies)
101   - {
102   - if (StringUtils.isNotEmpty(cookie.getName()) && "nav-style".equalsIgnoreCase(cookie.getName()))
103   - {
104   - indexStyle = cookie.getValue();
105   - break;
  92 + User user = tokenService.getUser(token);
  93 + if (user == null && token != null) {
  94 +
  95 + String dataJsonStr = sendPost("http://180.169.154.251:18080/information/authenticate/loginAuthentication",token);
  96 +
  97 +
  98 + JSONObject jsonObject = JSON.parseObject(dataJsonStr);
  99 +
  100 +
  101 + JSONObject dataJson = jsonObject.getJSONObject("data");
  102 +
  103 + Assert.notNull(dataJson, "获取用户信息异常");
  104 +
  105 +
  106 + JSONArray jsonMenu = dataJson.getJSONArray("userAuthList").getJSONObject(0).getJSONArray("roleList").getJSONObject(0).getJSONArray("resourceList");
  107 +
  108 +
  109 + Map<Long,Menu> menuMap = new HashMap<Long,Menu>();
  110 +
  111 + String ids = "";
  112 +
  113 + for(Object json:jsonMenu) {
  114 + ids += ((JSONObject)json).getLongValue("menuId") + ",";
106 115 }
107   - }
108 116  
109   - return "index";
  117 + ids.substring(0,ids.length() -1);
110 118  
111   - }else {
112   - return "login";
113   - }
  119 + List<Menu> allMenus = menuService.selectMenuNormalByMenuIds(ids.split(","));
114 120  
  121 +
  122 +
  123 + login("admin","admin123",false);
  124 + user = getSysUser();
  125 + user.setToken(token);
  126 +// user.setPermissions(permissionService.getMenuPermission());
  127 + tokenService.createToken(user);
  128 +
  129 +
  130 + //String username = dataJson.getString("account");
  131 +// String username = "admin";
  132 +// AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
  133 +// SysUser sysUser = sysUserService.selectUserByUserName(username);
  134 +
  135 +// user.setPermissions(permissionService.getMenuPermission(sysUser));
  136 +// user.setUser(sysUser);
  137 +
  138 +
  139 + mmap.put("menus", allMenus);
  140 + mmap.put("user", user);
  141 + mmap.put("ignoreFooter", configService.selectConfigByKey("sys.index.ignoreFooter"));
  142 + mmap.put("copyrightYear", ruoYiConfig.getCopyrightYear());
  143 + mmap.put("demoEnabled", ruoYiConfig.isDemoEnabled());
  144 + mmap.put("isDefaultModifyPwd", initPasswordIsModify(user.getPwdUpdateDate()));
  145 + mmap.put("isPasswordExpired", passwordIsExpiration(user.getPwdUpdateDate()));
  146 +
  147 + // 菜单导航显示风格
  148 + String menuStyle = configService.selectConfigByKey("sys.index.menuStyle");
  149 + // 移动端,默认使左侧导航菜单,否则取默认配置
  150 + String indexStyle = ServletUtils.checkAgentIsMobile(ServletUtils.getRequest().getHeader("User-Agent")) ? "index" : menuStyle;
  151 +
  152 +
  153 + return "index";
  154 +
  155 + }
  156 +
  157 + }
115 158 // User loginUser = tokenService.getUser(ServletUtils.getRequest());
116 159  
117 160  
... ... @@ -121,7 +164,32 @@ public class LoginController extends BaseController
121 164 // subject.login(token);
122 165 // return success();
123 166  
  167 + return "index";
  168 + }
  169 +
  170 + public String sendPost(String url,String token) {
  171 + String strresponse = null;
  172 + try{
  173 + HttpClient hc = HttpClientBuilder.create().build();//获取DefaultHttpClient请求
  174 + HttpPost hp = new HttpPost(url);
  175 + JSONObject jsonParam = new JSONObject();
124 176  
  177 + jsonParam.put("token", token);
  178 + jsonParam.put("systemCode", "SYS0015");
  179 + //设置数据为utf-8编码
  180 + StringEntity entity = new StringEntity(jsonParam.toString(),"utf-8");
  181 + //设置请求编码
  182 + entity.setContentEncoding("utf-8");
  183 + //设置请求类型
  184 + entity.setContentType("application/json");
  185 + hp.setEntity(entity);
  186 + //请求并得到结果
  187 + HttpResponse result = hc.execute(hp);
  188 + strresponse = EntityUtils.toString(result.getEntity(),"utf-8").trim();
  189 + }catch(Exception e){
  190 + e.printStackTrace();
  191 + }
  192 + return strresponse;
125 193  
126 194 }
127 195  
... ... @@ -194,4 +262,4 @@ public class LoginController extends BaseController
194 262 {
195 263 return "error/unauth";
196 264 }
197   -}
198 265 \ No newline at end of file
  266 +}
... ...
bsthLineProfiles/src/main/resources/application-druid.yml
... ... @@ -5,18 +5,22 @@ spring:
5 5 driverClassName: com.mysql.cj.jdbc.Driver
6 6 druid:
7 7 # 主库数据源
  8 +# master:
  9 +# url: jdbc:mysql://localhost:3306/linedata?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
  10 +# username: root
  11 +# password: Aa123456
  12 + # 主库数据源
8 13 master:
9 14 url: jdbc:mysql://localhost:3306/bsth_line_profiles?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
10 15 username: root
11 16 password: 1995627a
12   - #password: Aa123456
13 17 # 从库数据源
14 18 slave:
15 19 # 从数据源开关/默认关闭
16 20 enabled: false
17   - url:
18   - username:
19   - password:
  21 + url:
  22 + username:
  23 + password:
20 24 # 初始连接数
21 25 initialSize: 5
22 26 # 最小连接池数量
... ... @@ -36,7 +40,7 @@ spring:
36 40 testWhileIdle: true
37 41 testOnBorrow: false
38 42 testOnReturn: false
39   - webStatFilter:
  43 + webStatFilter:
40 44 enabled: true
41 45 statViewServlet:
42 46 enabled: true
... ... @@ -44,8 +48,8 @@ spring:
44 48 allow:
45 49 url-pattern: /druid/*
46 50 # 控制台管理用户名和密码
47   - login-username:
48   - login-password:
  51 + login-username:
  52 + login-password:
49 53 filter:
50 54 stat:
51 55 enabled: true
... ...
bsthLineProfiles/src/main/resources/application.yml
... ... @@ -28,7 +28,7 @@ server:
28 28 max-threads: 800
29 29 # Tomcat启动初始化的线程数,默认值25
30 30 min-spare-threads: 30
31   -
  31 +
32 32 # 日志配置
33 33 logging:
34 34 level:
... ... @@ -56,7 +56,7 @@ spring:
56 56 jackson:
57 57 time-zone: GMT+8
58 58 date-format: yyyy-MM-dd HH:mm:ss
59   - profiles:
  59 + profiles:
60 60 active: druid
61 61 # 文件上传
62 62 servlet:
... ... @@ -93,7 +93,7 @@ spring:
93 93 max-active: 8
94 94 # #连接池最大阻塞等待时间(使用负值表示没有限制)
95 95 max-wait: -1ms
96   -
  96 +
97 97 token:
98 98 # 令牌自定义标识
99 99 header: Authorization
... ... @@ -112,11 +112,11 @@ mybatis:
112 112 configLocation: classpath:mybatis/mybatis-config.xml
113 113  
114 114 # PageHelper分页插件
115   -pagehelper:
  115 +pagehelper:
116 116 helperDialect: mysql
117 117 reasonable: true
118 118 supportMethodsArguments: true
119   - params: count=countSql
  119 + params: count=countSql
120 120  
121 121 # Shiro
122 122 shiro:
... ... @@ -128,12 +128,12 @@ shiro:
128 128 # 首页地址
129 129 indexUrl: /index
130 130 # 验证码开关
131   - captchaEnabled: false
  131 + captchaEnabled: true
132 132 # 验证码类型 math 数组计算 char 字符
133 133 captchaType: math
134 134 cookie:
135 135 # 设置Cookie的域名 默认空,即当前访问的域名
136   - domain:
  136 + domain:
137 137 # 设置cookie的有效访问路径
138 138 path: /
139 139 # 设置HttpOnly属性
... ... @@ -155,7 +155,7 @@ shiro:
155 155 kickoutAfter: false
156 156  
157 157 # 防止XSS攻击
158   -xss:
  158 +xss:
159 159 # 过滤开关
160 160 enabled: true
161 161 # 排除链接(多个用逗号分隔)
... ... @@ -169,7 +169,7 @@ swagger:
169 169 enabled: true
170 170  
171 171 # 代码生成
172   -gen:
  172 +gen:
173 173 # 作者
174 174 author: ruoyi
175 175 # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
... ...
bsthLineProfiles/src/main/resources/templates/system/line/line.html
... ... @@ -257,9 +257,9 @@
257 257 }
258 258 companies=Array.from(new Set(companies));
259 259 companySelect();
260   - fCompanySelect(false);
  260 + fCompanySelect();
261 261 $('#company').on('change.select2', function (e) {
262   - fCompanySelect(true)
  262 + fCompanySelect()
263 263 });
264 264 });
265 265  
... ... @@ -285,7 +285,7 @@
285 285 }
286 286  
287 287  
288   - function fCompanySelect(flag){
  288 + function fCompanySelect(){
289 289 $('#fCompany').empty();
290 290 var company=$('#company').select2('val');
291 291 var arr = new Array();
... ...
bsthLineProfiles/src/main/resources/templates/system/lineAdd/line.html
... ... @@ -3,6 +3,7 @@
3 3 xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
4 4 <head>
5 5 <th:block th:include="include :: header('线路档案信息')" />
  6 +<th:block th:include="include :: select2-css" />
6 7 </head>
7 8 <body class="gray-bg">
8 9 <div class="container-div" id="context">
... ... @@ -11,9 +12,13 @@
11 12 <form id="formId">
12 13 <div class="select-list">
13 14 <ul>
14   - <li><label>公司:</label> <input type="text" name="company" />
  15 + <li><label>公司:</label>
  16 + <select id='company' >
  17 + </select>
15 18 </li>
16   - <li><label>分公司:</label> <input type="text" name="fCompany" />
  19 + <li><label>分公司:</label>
  20 + <select id='fCompany' >
  21 + </select>
17 22 </li>
18 23 <li><label>线路名称:</label> <input type="text" name="lineName" />
19 24 </li>
... ... @@ -39,6 +44,7 @@
39 44 </div>
40 45 </div>
41 46 <th:block th:include="include :: footer" />
  47 + <th:block th:include="include :: select2-js" />
42 48 <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
43 49 aria-labelledby="myModalLabel" aria-hidden="true">
44 50 <div class="modal-dialog">
... ... @@ -67,22 +73,83 @@
67 73  
68 74 <script th:inline="javascript">
69 75  
  76 + var companyList=[[${companyList}]];
  77 + var companies=new Array();
  78 + var fCompanies=new Array();
70 79 $(function() {
71   - stations=data.stations;
  80 + for(let i in companyList){
  81 + companies[i]=companyList[i].company;
  82 + fCompanies[i]=companyList[i].fCompany;
  83 + }
  84 + companies=Array.from(new Set(companies));
  85 + companySelect();
  86 + fCompanySelect();
  87 + $('#company').on('change.select2', function (e) {
  88 + fCompanySelect()
  89 + });
  90 + });
  91 +
  92 + function companySelect(){
72 93 var arr = new Array();
73   - for (var i = 0; i < stations.length; i++) {
74   - var station=new Object();
75   - station.id=stations[i];
76   - station.text=stations[i];
77   - station.value=stations[i];
78   - arr.push(station);
  94 + var company=new Object();
  95 + company.id='';
  96 + company.text='';
  97 + company.value='';
  98 + arr.push(company)
  99 + for (var i = 0; i < companies.length; i++) {
  100 + company=new Object();
  101 + company.id=companies[i];
  102 + company.text=companies[i];
  103 + company.value=companies[i];
  104 + arr.push(company);
79 105 }
80 106 $("#company").select2({
81 107 data: arr,
82 108 placeholder:'请选择',
83 109 allowClear:true
84 110 })
85   - });
  111 + }
  112 +
  113 +
  114 + function fCompanySelect(){
  115 + $('#fCompany').empty();
  116 + var company=$('#company').select2('val');
  117 + var arr = new Array();
  118 + var fCompany=new Object();
  119 + fCompany.id='';
  120 + fCompany.text='';
  121 + fCompany.value='';
  122 + arr.push(fCompany)
  123 + if(company==''){
  124 + for(let i in companyList){
  125 + var companyName=companyList[i].company;
  126 + var fCompanyName=companyList[i].fCompany;
  127 + fCompany=new Object();
  128 + fCompany.id=fCompanyName;
  129 + fCompany.text=fCompanyName;
  130 + fCompany.value=fCompanyName;
  131 + arr.push(fCompany);
  132 + }
  133 + }else {
  134 + for(let i in companyList){
  135 + var companyName=companyList[i].company;
  136 + var fCompanyName=companyList[i].fCompany;
  137 + if(companyName==company){
  138 + fCompany=new Object();
  139 + fCompany.id=fCompanyName;
  140 + fCompany.text=fCompanyName;
  141 + fCompany.value=fCompanyName;
  142 + arr.push(fCompany);
  143 + }
  144 + }
  145 + }
  146 +
  147 + $("#fCompany").select2({
  148 + data: arr,
  149 + placeholder:'请选择',
  150 + allowClear:true
  151 + });
  152 + }
86 153  
87 154 function add(obj){
88 155 if($(obj)[0].className.indexOf("disabled") == -1)
... ... @@ -199,7 +266,12 @@
199 266 }
200 267 }
201 268 }
202   -
  269 + function queryParams(params) {
  270 + var search = $.table.queryParams(params);
  271 + search.company=$('#company').select2('val');
  272 + search.fCompany=$('#fCompany').select2('val');
  273 + return search;
  274 + }
203 275  
204 276 var editFlag = [[${@permission.hasPermi('system:lineReport:edit')}]];
205 277 var removeFlag = [[${@permission.hasPermi('system:lineReport:remove')}]];
... ...
bsthLineProfiles/src/main/resources/templates/system/lineExamine/line.html
... ... @@ -4,6 +4,7 @@
4 4 <head>
5 5 <th:block th:include="include :: header('线路档案信息')" />
6 6 <th:block th:include="include :: datetimepicker-css" />
  7 +<th:block th:include="include :: select2-css" />
7 8 </head>
8 9 <body class="gray-bg">
9 10 <div class="container-div" id="context">
... ... @@ -12,9 +13,13 @@
12 13 <form id="formId">
13 14 <div class="select-list">
14 15 <ul>
15   - <li><label>公司:</label> <input type="text" name="company" />
  16 + <li><label>公司:</label>
  17 + <select id='company' >
  18 + </select>
16 19 </li>
17   - <li><label>分公司:</label> <input type="text" name="fCompany" />
  20 + <li><label>分公司:</label>
  21 + <select id='fCompany' >
  22 + </select>
18 23 </li>
19 24 <li><label>线路名称:</label> <input type="text" name="lineName" />
20 25 </li>
... ... @@ -44,6 +49,7 @@
44 49 </div>
45 50 <th:block th:include="include :: footer" />
46 51 <th:block th:include="include :: datetimepicker-js" />
  52 + <th:block th:include="include :: select2-js" />
47 53 <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
48 54 aria-labelledby="myModalLabel" aria-hidden="true">
49 55 <div class="modal-dialog">
... ... @@ -71,7 +77,83 @@
71 77  
72 78  
73 79 <script th:inline="javascript">
  80 + var companyList=[[${companyList}]];
  81 + var companies=new Array();
  82 + var fCompanies=new Array();
  83 + $(function() {
  84 + for(let i in companyList){
  85 + companies[i]=companyList[i].company;
  86 + fCompanies[i]=companyList[i].fCompany;
  87 + }
  88 + companies=Array.from(new Set(companies));
  89 + companySelect();
  90 + fCompanySelect();
  91 + $('#company').on('change.select2', function (e) {
  92 + fCompanySelect()
  93 + });
  94 + });
  95 +
  96 + function companySelect(){
  97 + var arr = new Array();
  98 + var company=new Object();
  99 + company.id='';
  100 + company.text='';
  101 + company.value='';
  102 + arr.push(company)
  103 + for (var i = 0; i < companies.length; i++) {
  104 + company=new Object();
  105 + company.id=companies[i];
  106 + company.text=companies[i];
  107 + company.value=companies[i];
  108 + arr.push(company);
  109 + }
  110 + $("#company").select2({
  111 + data: arr,
  112 + placeholder:'请选择',
  113 + allowClear:true
  114 + })
  115 + }
  116 +
74 117  
  118 + function fCompanySelect(){
  119 + $('#fCompany').empty();
  120 + var company=$('#company').select2('val');
  121 + var arr = new Array();
  122 + var fCompany=new Object();
  123 + fCompany.id='';
  124 + fCompany.text='';
  125 + fCompany.value='';
  126 + arr.push(fCompany)
  127 + if(company==''){
  128 + for(let i in companyList){
  129 + var companyName=companyList[i].company;
  130 + var fCompanyName=companyList[i].fCompany;
  131 + fCompany=new Object();
  132 + fCompany.id=fCompanyName;
  133 + fCompany.text=fCompanyName;
  134 + fCompany.value=fCompanyName;
  135 + arr.push(fCompany);
  136 + }
  137 + }else {
  138 + for(let i in companyList){
  139 + var companyName=companyList[i].company;
  140 + var fCompanyName=companyList[i].fCompany;
  141 + if(companyName==company){
  142 + fCompany=new Object();
  143 + fCompany.id=fCompanyName;
  144 + fCompany.text=fCompanyName;
  145 + fCompany.value=fCompanyName;
  146 + arr.push(fCompany);
  147 + }
  148 + }
  149 + }
  150 +
  151 + $("#fCompany").select2({
  152 + data: arr,
  153 + placeholder:'请选择',
  154 + allowClear:true
  155 + });
  156 + }
75 157  
76 158 new Vue({
77 159 el: '#context',
... ... @@ -88,6 +170,8 @@
88 170 var createTimeEnd=$('#createTimeEnd').val();
89 171 search.createTimeStr=createTimeStr;
90 172 search.createTimeEnd=createTimeEnd;
  173 + search.company=$('#company').select2('val');
  174 + search.fCompany=$('#fCompany').select2('val');
91 175 return search;
92 176 }
93 177  
... ...
bsthLineProfiles/src/main/resources/templates/system/lineHistory/line.html
... ... @@ -3,6 +3,7 @@
3 3 xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
4 4 <head>
5 5 <th:block th:include="include :: header('线路档案信息')" />
  6 +<th:block th:include="include :: select2-css" />
6 7 </head>
7 8 <body class="gray-bg">
8 9 <div class="container-div" id="context">
... ... @@ -11,9 +12,13 @@
11 12 <form id="formId">
12 13 <div class="select-list">
13 14 <ul>
14   - <li><label>公司:</label> <input type="text" name="company" />
  15 + <li><label>公司:</label>
  16 + <select id='company' >
  17 + </select>
15 18 </li>
16   - <li><label>分公司:</label> <input type="text" name="fCompany" />
  19 + <li><label>分公司:</label>
  20 + <select id='fCompany' >
  21 + </select>
17 22 </li>
18 23 <li><label>线路名称:</label> <input type="text" name="lineName" />
19 24 </li>
... ... @@ -34,6 +39,7 @@
34 39 </div>
35 40 </div>
36 41 <th:block th:include="include :: footer" />
  42 + <th:block th:include="include :: select2-js" />
37 43 <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
38 44 aria-labelledby="myModalLabel" aria-hidden="true">
39 45 <div class="modal-dialog">
... ... @@ -61,7 +67,83 @@
61 67  
62 68  
63 69 <script th:inline="javascript">
  70 + var companyList=[[${companyList}]];
  71 + var companies=new Array();
  72 + var fCompanies=new Array();
  73 + $(function() {
  74 + for(let i in companyList){
  75 + companies[i]=companyList[i].company;
  76 + fCompanies[i]=companyList[i].fCompany;
  77 + }
  78 + companies=Array.from(new Set(companies));
  79 + companySelect();
  80 + fCompanySelect();
  81 + $('#company').on('change.select2', function (e) {
  82 + fCompanySelect()
  83 + });
  84 + });
  85 +
  86 + function companySelect(){
  87 + var arr = new Array();
  88 + var company=new Object();
  89 + company.id='';
  90 + company.text='';
  91 + company.value='';
  92 + arr.push(company)
  93 + for (var i = 0; i < companies.length; i++) {
  94 + company=new Object();
  95 + company.id=companies[i];
  96 + company.text=companies[i];
  97 + company.value=companies[i];
  98 + arr.push(company);
  99 + }
  100 + $("#company").select2({
  101 + data: arr,
  102 + placeholder:'请选择',
  103 + allowClear:true
  104 + })
  105 + }
  106 +
64 107  
  108 + function fCompanySelect(){
  109 + $('#fCompany').empty();
  110 + var company=$('#company').select2('val');
  111 + var arr = new Array();
  112 + var fCompany=new Object();
  113 + fCompany.id='';
  114 + fCompany.text='';
  115 + fCompany.value='';
  116 + arr.push(fCompany)
  117 + if(company==''){
  118 + for(let i in companyList){
  119 + var companyName=companyList[i].company;
  120 + var fCompanyName=companyList[i].fCompany;
  121 + fCompany=new Object();
  122 + fCompany.id=fCompanyName;
  123 + fCompany.text=fCompanyName;
  124 + fCompany.value=fCompanyName;
  125 + arr.push(fCompany);
  126 + }
  127 + }else {
  128 + for(let i in companyList){
  129 + var companyName=companyList[i].company;
  130 + var fCompanyName=companyList[i].fCompany;
  131 + if(companyName==company){
  132 + fCompany=new Object();
  133 + fCompany.id=fCompanyName;
  134 + fCompany.text=fCompanyName;
  135 + fCompany.value=fCompanyName;
  136 + arr.push(fCompany);
  137 + }
  138 + }
  139 + }
  140 +
  141 + $("#fCompany").select2({
  142 + data: arr,
  143 + placeholder:'请选择',
  144 + allowClear:true
  145 + });
  146 + }
65 147  
66 148 new Vue({
67 149 el: '#context',
... ... @@ -75,6 +157,8 @@
75 157 var search = $.table.queryParams(params);
76 158 search.examineStatus ='true';
77 159 search.examineType='0';
  160 + search.company=$('#company').select2('val');
  161 + search.fCompany=$('#fCompany').select2('val');
78 162 return search;
79 163 }
80 164  
... ...