Commit 12008f995463664d2b41cbc3ad5db7a5402e0342
Merge branch 'develop' of http://172.16.29.40:8010/wms/wms2 into develop
Showing
106 changed files
with
3694 additions
and
1961 deletions
Too many changes to show.
To preserve performance only 56 of 106 files are displayed.
.idea/compiler.xml
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | <project version="4"> |
3 | 3 | <component name="CompilerConfiguration"> |
4 | 4 | <annotationProcessing> |
5 | + <profile default="true" name="Default" enabled="true" /> | |
5 | 6 | <profile name="Maven default annotation processors profile" enabled="true"> |
6 | 7 | <sourceOutputDir name="target/generated-sources/annotations" /> |
7 | 8 | <sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> |
... | ... |
pom.xml
... | ... | @@ -45,14 +45,6 @@ |
45 | 45 | <dependency> |
46 | 46 | <groupId>org.springframework.boot</groupId> |
47 | 47 | <artifactId>spring-boot-starter</artifactId> |
48 | - <!-- | |
49 | - <exclusions> | |
50 | - <exclusion> | |
51 | - <artifactId>spring-boot-starter-tomcat</artifactId> | |
52 | - <groupId>org.springframework.boot</groupId> | |
53 | - </exclusion> | |
54 | - </exclusions> | |
55 | - --> | |
56 | 48 | </dependency> |
57 | 49 | |
58 | 50 | <!-- 下面的配置将使用undertow来做web容器而不是tomcat --> |
... | ... | @@ -73,12 +65,6 @@ |
73 | 65 | <artifactId>spring-boot-starter-undertow</artifactId> |
74 | 66 | </dependency> |
75 | 67 | |
76 | - <!-- SpringBoot tomcat Web容器 --> | |
77 | - <!--<dependency> | |
78 | - <groupId>org.springframework.boot</groupId> | |
79 | - <artifactId>spring-boot-starter-web</artifactId> | |
80 | - </dependency>--> | |
81 | - | |
82 | 68 | <!-- SpringBoot 测试 --> |
83 | 69 | <dependency> |
84 | 70 | <groupId>org.springframework.boot</groupId> |
... | ... | @@ -105,12 +91,30 @@ |
105 | 91 | <optional>true</optional> <!-- 表示依赖不会传递 --> |
106 | 92 | </dependency> |
107 | 93 | |
94 | + <!-- redis 缓存操作 --> | |
95 | + <dependency> | |
96 | + <groupId>org.springframework.boot</groupId> | |
97 | + <artifactId>spring-boot-starter-data-redis</artifactId> | |
98 | + </dependency> | |
99 | + | |
100 | + <!-- pool 对象池 --> | |
101 | + <dependency> | |
102 | + <groupId>org.apache.commons</groupId> | |
103 | + <artifactId>commons-pool2</artifactId> | |
104 | + </dependency> | |
105 | + | |
108 | 106 | <!-- thymeleaf网页解析 --> |
109 | 107 | <dependency> |
110 | 108 | <groupId>net.sourceforge.nekohtml</groupId> |
111 | 109 | <artifactId>nekohtml</artifactId> |
112 | 110 | </dependency> |
113 | 111 | |
112 | + <dependency> | |
113 | + <groupId>io.jsonwebtoken</groupId> | |
114 | + <artifactId>jjwt</artifactId> | |
115 | + <version>0.9.1</version> | |
116 | + </dependency> | |
117 | + | |
114 | 118 | <!-- Mysql8驱动包 --> |
115 | 119 | <dependency> |
116 | 120 | <groupId>mysql</groupId> |
... | ... | @@ -220,19 +224,6 @@ |
220 | 224 | <version>${velocity.version}</version> |
221 | 225 | </dependency> |
222 | 226 | |
223 | - <!--验证码 --> | |
224 | - <dependency> | |
225 | - <groupId>com.github.penggle</groupId> | |
226 | - <artifactId>kaptcha</artifactId> | |
227 | - <version>${kaptcha.version}</version> | |
228 | - <exclusions> | |
229 | - <exclusion> | |
230 | - <artifactId>javax.servlet-api</artifactId> | |
231 | - <groupId>javax.servlet</groupId> | |
232 | - </exclusion> | |
233 | - </exclusions> | |
234 | - </dependency> | |
235 | - | |
236 | 227 | <!-- swagger2--> |
237 | 228 | <dependency> |
238 | 229 | <groupId>io.springfox</groupId> |
... | ... | @@ -333,21 +324,16 @@ |
333 | 324 | </dependency> |
334 | 325 | |
335 | 326 | <dependency> |
336 | - <groupId>org.junit.jupiter</groupId> | |
337 | - <artifactId>junit-jupiter-api</artifactId> | |
338 | - </dependency> | |
339 | - <dependency> | |
340 | - <groupId>org.testng</groupId> | |
341 | - <artifactId>testng</artifactId> | |
342 | - <version>RELEASE</version> | |
343 | - <scope>compile</scope> | |
344 | - </dependency> | |
345 | - <dependency> | |
346 | 327 | <groupId>junit</groupId> |
347 | 328 | <artifactId>junit</artifactId> |
348 | 329 | <version>4.12</version> |
349 | 330 | </dependency> |
350 | 331 | |
332 | + <dependency> | |
333 | + <groupId>org.springframework.boot</groupId> | |
334 | + <artifactId>spring-boot-starter-amqp</artifactId> | |
335 | + </dependency> | |
336 | + | |
351 | 337 | <!-- echarts 图标插件 --> |
352 | 338 | <!--<dependency>--> |
353 | 339 | <!--<groupId>com.github.abel533</groupId>--> |
... | ... |
src/main/java/com/huaheng/api/general/controller/BasicDataApi.java
... | ... | @@ -31,10 +31,10 @@ public class BasicDataApi extends BaseController { |
31 | 31 | * 同步物料 |
32 | 32 | */ |
33 | 33 | @Log(title = "物料添加", action = BusinessType.INSERT) |
34 | - @PostMapping("/material") | |
34 | + @PostMapping("/addMaterial") | |
35 | 35 | @ApiOperation("物料添加公共接口") |
36 | 36 | @ResponseBody |
37 | - public AjaxResult MaterialApi(@RequestBody Material material) | |
37 | + public AjaxResult AddMaterialApi(@RequestBody Material material) | |
38 | 38 | { |
39 | 39 | AjaxResult ajaxResult = basicDataApiService.material(material); |
40 | 40 | return ajaxResult; |
... | ... | @@ -42,7 +42,7 @@ public class BasicDataApi extends BaseController { |
42 | 42 | |
43 | 43 | |
44 | 44 | @Log(title = "物料查询", action = BusinessType.INSERT) |
45 | - @PostMapping("/queryMaterialApi") | |
45 | + @PostMapping("/queryMaterial") | |
46 | 46 | @ApiOperation("物料查询公共接口") |
47 | 47 | @ResponseBody |
48 | 48 | public AjaxResult QueryMaterialApi(@RequestBody Material material) |
... | ... | @@ -65,12 +65,11 @@ public class BasicDataApi extends BaseController { |
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | - | |
69 | 68 | /** |
70 | 69 | * 同步仓库和货主 |
71 | 70 | */ |
72 | 71 | @Log(title = "仓库添加", action = BusinessType.INSERT) |
73 | - @PostMapping("/warehouse") | |
72 | + @PostMapping("/addWarehouse") | |
74 | 73 | @ApiOperation("仓库添加公共接口") |
75 | 74 | @ResponseBody |
76 | 75 | public AjaxResult WarehouseApi(@RequestBody Warehouse warehouse) |
... | ... |
src/main/java/com/huaheng/api/general/controller/ReceiptApi.java
src/main/java/com/huaheng/api/general/service/ReceiptApiService.java
... | ... | @@ -237,7 +237,7 @@ public class ReceiptApiService { |
237 | 237 | |
238 | 238 | |
239 | 239 | @Transactional |
240 | - public AjaxResult add(Integer[] ids){ | |
240 | + public AjaxResult remove(Integer[] ids){ | |
241 | 241 | List<Integer> idList = Arrays.asList(ids); |
242 | 242 | for (Integer id : idList) { |
243 | 243 | ReceiptHeader receiptHeader = receiptHeaderService.getById(id); |
... | ... |
src/main/java/com/huaheng/common/constant/Constants.java
src/main/java/com/huaheng/framework/config/CaptchaConfig.java deleted
1 | -package com.huaheng.framework.config; | |
2 | - | |
3 | -import java.util.Properties; | |
4 | -import org.springframework.context.annotation.Bean; | |
5 | -import org.springframework.context.annotation.Configuration; | |
6 | -import com.google.code.kaptcha.impl.DefaultKaptcha; | |
7 | -import com.google.code.kaptcha.util.Config; | |
8 | - | |
9 | -/** | |
10 | - * 验证码配置 | |
11 | - * | |
12 | - * @author huaheng | |
13 | - */ | |
14 | -@Configuration | |
15 | -public class CaptchaConfig | |
16 | -{ | |
17 | - @Bean(name = "captchaProducer") | |
18 | - public DefaultKaptcha getKaptchaBean() | |
19 | - { | |
20 | - DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); | |
21 | - Properties properties = new Properties(); | |
22 | - properties.setProperty("kaptcha.border", "yes"); | |
23 | - properties.setProperty("kaptcha.border.color", "105,179,90"); | |
24 | - properties.setProperty("kaptcha.textproducer.font.color", "blue"); | |
25 | - properties.setProperty("kaptcha.image.width", "160"); | |
26 | - properties.setProperty("kaptcha.image.height", "60"); | |
27 | - properties.setProperty("kaptcha.textproducer.font.size", "28"); | |
28 | - properties.setProperty("kaptcha.session.key", "kaptchaCode"); | |
29 | - properties.setProperty("kaptcha.textproducer.char.spac", "35"); | |
30 | - properties.setProperty("kaptcha.textproducer.char.length", "5"); | |
31 | - properties.setProperty("kaptcha.textproducer.font.names", "Arial,Courier"); | |
32 | - properties.setProperty("kaptcha.noise.color", "white"); | |
33 | - Config config = new Config(properties); | |
34 | - defaultKaptcha.setConfig(config); | |
35 | - return defaultKaptcha; | |
36 | - } | |
37 | - | |
38 | - @Bean(name = "captchaProducerMath") | |
39 | - public DefaultKaptcha getKaptchaBeanMath() | |
40 | - { | |
41 | - DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); | |
42 | - Properties properties = new Properties(); | |
43 | - properties.setProperty("kaptcha.border", "yes"); | |
44 | - properties.setProperty("kaptcha.border.color", "105,179,90"); | |
45 | - properties.setProperty("kaptcha.textproducer.font.color", "blue"); | |
46 | - properties.setProperty("kaptcha.image.width", "160"); | |
47 | - properties.setProperty("kaptcha.image.height", "60"); | |
48 | - properties.setProperty("kaptcha.textproducer.font.size", "38"); | |
49 | - properties.setProperty("kaptcha.session.key", "kaptchaCodeMath"); | |
50 | - properties.setProperty("kaptcha.textproducer.impl", "com.huaheng.framework.config.KaptchaTextCreator"); | |
51 | - properties.setProperty("kaptcha.textproducer.char.spac", "5"); | |
52 | - properties.setProperty("kaptcha.textproducer.char.length", "6"); | |
53 | - properties.setProperty("kaptcha.textproducer.font.names", "Arial,Courier"); | |
54 | - properties.setProperty("kaptcha.noise.color", "white"); | |
55 | - properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.NoNoise"); | |
56 | - properties.setProperty("kaptcha.obscurificator.impl", "com.google.code.kaptcha.impl.ShadowGimpy"); | |
57 | - Config config = new Config(properties); | |
58 | - defaultKaptcha.setConfig(config); | |
59 | - return defaultKaptcha; | |
60 | - } | |
61 | -} |
src/main/java/com/huaheng/framework/config/KaptchaTextCreator.java deleted
1 | -package com.huaheng.framework.config; | |
2 | - | |
3 | -import java.util.Random; | |
4 | -import com.google.code.kaptcha.text.impl.DefaultTextCreator; | |
5 | - | |
6 | -/** | |
7 | - * 验证码文本生成器 | |
8 | - * | |
9 | - * @author huaheng | |
10 | - */ | |
11 | -public class KaptchaTextCreator extends DefaultTextCreator | |
12 | -{ | |
13 | - | |
14 | - private static final String[] CNUMBERS = "0,1,2,3,4,5,6,7,8,9,10".split(","); | |
15 | - | |
16 | - @Override | |
17 | - public String getText() | |
18 | - { | |
19 | - Integer result = 0; | |
20 | - Random random = new Random(); | |
21 | - int x = random.nextInt(10); | |
22 | - int y = random.nextInt(10); | |
23 | - StringBuilder suChinese = new StringBuilder(); | |
24 | - int randomoperands = (int) Math.round(Math.random() * 2); | |
25 | - if (randomoperands == 0) | |
26 | - { | |
27 | - result = x * y; | |
28 | - suChinese.append(CNUMBERS[x]); | |
29 | - suChinese.append("*"); | |
30 | - suChinese.append(CNUMBERS[y]); | |
31 | - } | |
32 | - else if (randomoperands == 1) | |
33 | - { | |
34 | - if (!(x == 0) && y % x == 0) | |
35 | - { | |
36 | - result = y / x; | |
37 | - suChinese.append(CNUMBERS[y]); | |
38 | - suChinese.append("/"); | |
39 | - suChinese.append(CNUMBERS[x]); | |
40 | - } | |
41 | - else | |
42 | - { | |
43 | - result = x + y; | |
44 | - suChinese.append(CNUMBERS[x]); | |
45 | - suChinese.append("+"); | |
46 | - suChinese.append(CNUMBERS[y]); | |
47 | - } | |
48 | - } | |
49 | - else if (randomoperands == 2) | |
50 | - { | |
51 | - if (x >= y) | |
52 | - { | |
53 | - result = x - y; | |
54 | - suChinese.append(CNUMBERS[x]); | |
55 | - suChinese.append("-"); | |
56 | - suChinese.append(CNUMBERS[y]); | |
57 | - } | |
58 | - else | |
59 | - { | |
60 | - result = y - x; | |
61 | - suChinese.append(CNUMBERS[y]); | |
62 | - suChinese.append("-"); | |
63 | - suChinese.append(CNUMBERS[x]); | |
64 | - } | |
65 | - } | |
66 | - else | |
67 | - { | |
68 | - result = x + y; | |
69 | - suChinese.append(CNUMBERS[x]); | |
70 | - suChinese.append("+"); | |
71 | - suChinese.append(CNUMBERS[y]); | |
72 | - } | |
73 | - suChinese.append("=?@" + result); | |
74 | - return suChinese.toString(); | |
75 | - } | |
76 | - | |
77 | -} |
src/main/java/com/huaheng/framework/config/ShiroConfig.java
... | ... | @@ -3,6 +3,7 @@ package com.huaheng.framework.config; |
3 | 3 | import java.util.LinkedHashMap; |
4 | 4 | import java.util.Map; |
5 | 5 | import javax.servlet.Filter; |
6 | + | |
6 | 7 | import org.apache.shiro.cache.ehcache.EhCacheManager; |
7 | 8 | import org.apache.shiro.codec.Base64; |
8 | 9 | import org.apache.shiro.mgt.SecurityManager; |
... | ... | @@ -20,7 +21,6 @@ import com.huaheng.framework.shiro.realm.UserRealm; |
20 | 21 | import com.huaheng.framework.shiro.session.OnlineSessionDAO; |
21 | 22 | import com.huaheng.framework.shiro.session.OnlineSessionFactory; |
22 | 23 | import com.huaheng.framework.shiro.web.filter.LogoutFilter; |
23 | -import com.huaheng.framework.shiro.web.filter.captcha.CaptchaValidateFilter; | |
24 | 24 | import com.huaheng.framework.shiro.web.filter.online.OnlineSessionFilter; |
25 | 25 | import com.huaheng.framework.shiro.web.filter.sync.SyncOnlineSessionFilter; |
26 | 26 | import com.huaheng.framework.shiro.web.session.OnlineWebSessionManager; |
... | ... | @@ -29,12 +29,11 @@ import at.pollux.thymeleaf.shiro.dialect.ShiroDialect; |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * 权限配置加载 |
32 | - * | |
32 | + * | |
33 | 33 | * @author huaheng |
34 | 34 | */ |
35 | 35 | @Configuration |
36 | -public class ShiroConfig | |
37 | -{ | |
36 | +public class ShiroConfig { | |
38 | 37 | public static final String PREMISSION_STRING = "perms[\"{0}\"]"; |
39 | 38 | |
40 | 39 | // Session超时时间,单位为毫秒(默认30分钟) |
... | ... | @@ -85,17 +84,13 @@ public class ShiroConfig |
85 | 84 | * 缓存管理器 使用Ehcache实现 |
86 | 85 | */ |
87 | 86 | @Bean |
88 | - public EhCacheManager getEhCacheManager() | |
89 | - { | |
87 | + public EhCacheManager getEhCacheManager() { | |
90 | 88 | net.sf.ehcache.CacheManager cacheManager = net.sf.ehcache.CacheManager.getCacheManager("huaheng"); |
91 | 89 | EhCacheManager em = new EhCacheManager(); |
92 | - if (StringUtils.isNull(cacheManager)) | |
93 | - { | |
90 | + if (StringUtils.isNull(cacheManager)) { | |
94 | 91 | em.setCacheManagerConfigFile("classpath:ehcache/ehcache-shiro.xml"); |
95 | 92 | return em; |
96 | - } | |
97 | - else | |
98 | - { | |
93 | + } else { | |
99 | 94 | em.setCacheManager(cacheManager); |
100 | 95 | return em; |
101 | 96 | } |
... | ... | @@ -105,8 +100,7 @@ public class ShiroConfig |
105 | 100 | * 自定义Realm |
106 | 101 | */ |
107 | 102 | @Bean |
108 | - public UserRealm userRealm(EhCacheManager cacheManager) | |
109 | - { | |
103 | + public UserRealm userRealm(EhCacheManager cacheManager) { | |
110 | 104 | UserRealm userRealm = new UserRealm(); |
111 | 105 | userRealm.setCacheManager(cacheManager); |
112 | 106 | return userRealm; |
... | ... | @@ -116,8 +110,7 @@ public class ShiroConfig |
116 | 110 | * 自定义sessionDAO会话 |
117 | 111 | */ |
118 | 112 | @Bean |
119 | - public OnlineSessionDAO sessionDAO() | |
120 | - { | |
113 | + public OnlineSessionDAO sessionDAO() { | |
121 | 114 | OnlineSessionDAO sessionDAO = new OnlineSessionDAO(); |
122 | 115 | return sessionDAO; |
123 | 116 | } |
... | ... | @@ -126,8 +119,7 @@ public class ShiroConfig |
126 | 119 | * 自定义sessionFactory会话 |
127 | 120 | */ |
128 | 121 | @Bean |
129 | - public OnlineSessionFactory sessionFactory() | |
130 | - { | |
122 | + public OnlineSessionFactory sessionFactory() { | |
131 | 123 | OnlineSessionFactory sessionFactory = new OnlineSessionFactory(); |
132 | 124 | return sessionFactory; |
133 | 125 | } |
... | ... | @@ -136,8 +128,7 @@ public class ShiroConfig |
136 | 128 | * 自定义sessionFactory调度器 |
137 | 129 | */ |
138 | 130 | @Bean |
139 | - public SpringSessionValidationScheduler sessionValidationScheduler() | |
140 | - { | |
131 | + public SpringSessionValidationScheduler sessionValidationScheduler() { | |
141 | 132 | SpringSessionValidationScheduler sessionValidationScheduler = new SpringSessionValidationScheduler(); |
142 | 133 | // 相隔多久检查一次session的有效性,单位毫秒,默认就是10分钟 |
143 | 134 | sessionValidationScheduler.setSessionValidationInterval(validationInterval * 60 * 1000); |
... | ... | @@ -150,8 +141,7 @@ public class ShiroConfig |
150 | 141 | * 会话管理器 |
151 | 142 | */ |
152 | 143 | @Bean |
153 | - public OnlineWebSessionManager sessionValidationManager() | |
154 | - { | |
144 | + public OnlineWebSessionManager sessionValidationManager() { | |
155 | 145 | OnlineWebSessionManager manager = new OnlineWebSessionManager(); |
156 | 146 | // 加入缓存管理器 |
157 | 147 | manager.setCacheManager(getEhCacheManager()); |
... | ... | @@ -174,8 +164,7 @@ public class ShiroConfig |
174 | 164 | * 会话管理器 |
175 | 165 | */ |
176 | 166 | @Bean |
177 | - public OnlineWebSessionManager sessionManager() | |
178 | - { | |
167 | + public OnlineWebSessionManager sessionManager() { | |
179 | 168 | OnlineWebSessionManager manager = new OnlineWebSessionManager(); |
180 | 169 | // 加入缓存管理器 |
181 | 170 | manager.setCacheManager(getEhCacheManager()); |
... | ... | @@ -200,8 +189,7 @@ public class ShiroConfig |
200 | 189 | * 安全管理器 |
201 | 190 | */ |
202 | 191 | @Bean |
203 | - public SecurityManager securityManager(UserRealm userRealm) | |
204 | - { | |
192 | + public SecurityManager securityManager(UserRealm userRealm) { | |
205 | 193 | DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); |
206 | 194 | // 设置realm. |
207 | 195 | securityManager.setRealm(userRealm); |
... | ... | @@ -217,15 +205,13 @@ public class ShiroConfig |
217 | 205 | /** |
218 | 206 | * 退出过滤器 |
219 | 207 | */ |
220 | - public LogoutFilter logoutFilter() | |
221 | - { | |
208 | + public LogoutFilter logoutFilter() { | |
222 | 209 | LogoutFilter logoutFilter = new LogoutFilter(); |
223 | 210 | logoutFilter.setLoginUrl(loginUrl); |
224 | 211 | return logoutFilter; |
225 | 212 | } |
226 | 213 | |
227 | - public LogoutFilter logoutFilters() | |
228 | - { | |
214 | + public LogoutFilter logoutFilters() { | |
229 | 215 | LogoutFilter logoutFilter = new LogoutFilter(); |
230 | 216 | logoutFilter.setLoginUrl(loginUrls); |
231 | 217 | return logoutFilter; |
... | ... | @@ -235,8 +221,7 @@ public class ShiroConfig |
235 | 221 | * Shiro过滤器配置 |
236 | 222 | */ |
237 | 223 | @Bean |
238 | - public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) | |
239 | - { | |
224 | + public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) { | |
240 | 225 | ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); |
241 | 226 | // Shiro的核心安全接口,这个属性是必须的 |
242 | 227 | shiroFilterFactoryBean.setSecurityManager(securityManager); |
... | ... | @@ -264,20 +249,20 @@ public class ShiroConfig |
264 | 249 | filterChainDefinitionMap.put("/admin/logout", "adminlogout"); |
265 | 250 | // 不需要拦截的访问 |
266 | 251 | // filterChainDefinitionMap.put("/admin/home", "anon,captchaValidate"); |
267 | - filterChainDefinitionMap.put("/mobile/download/*", "anon,captchaValidate"); | |
268 | - filterChainDefinitionMap.put("/admin/login", "anon,captchaValidate"); | |
269 | - filterChainDefinitionMap.put("/login", "anon,captchaValidate"); | |
270 | - filterChainDefinitionMap.put("/api/login", "anon,captchaValidate"); | |
271 | - filterChainDefinitionMap.put("/mobile/login", "anon,captchaValidate"); | |
272 | - filterChainDefinitionMap.put("/getWarehouseByUserCode", "anon,captchaValidate"); | |
273 | - filterChainDefinitionMap.put("/API/WMS/v2/login", "anon,captchaValidate"); | |
252 | + filterChainDefinitionMap.put("/mobile/download/*", "anon"); | |
253 | + filterChainDefinitionMap.put("/admin/login", "anon"); | |
254 | + filterChainDefinitionMap.put("/login", "anon"); | |
255 | + filterChainDefinitionMap.put("/api/login", "anon"); | |
256 | + filterChainDefinitionMap.put("/mobile/login", "anon"); | |
257 | + filterChainDefinitionMap.put("/getWarehouseByUserCode", "anon"); | |
258 | + filterChainDefinitionMap.put("/API/WMS/v2/login", "anon"); | |
259 | + filterChainDefinitionMap.put("/api/**", "anon"); | |
274 | 260 | // 系统权限列表 |
275 | 261 | // filterChainDefinitionMap.putAll(SpringUtils.getBean(IMenuService.class).selectPermsAll()); |
276 | 262 | |
277 | 263 | Map<String, Filter> filters = new LinkedHashMap<>(); |
278 | 264 | filters.put("onlineSession", onlineSessionFilter()); |
279 | 265 | filters.put("syncOnlineSession", syncOnlineSessionFilter()); |
280 | - filters.put("captchaValidate", captchaValidateFilter()); | |
281 | 266 | // 注销成功,则跳转到指定页面 |
282 | 267 | filters.put("logout", logoutFilter()); |
283 | 268 | filters.put("adminlogout", logoutFilters()); |
... | ... | @@ -294,8 +279,7 @@ public class ShiroConfig |
294 | 279 | * 自定义在线用户处理过滤器 |
295 | 280 | */ |
296 | 281 | @Bean |
297 | - public OnlineSessionFilter onlineSessionFilter() | |
298 | - { | |
282 | + public OnlineSessionFilter onlineSessionFilter() { | |
299 | 283 | OnlineSessionFilter onlineSessionFilter = new OnlineSessionFilter(); |
300 | 284 | onlineSessionFilter.setLoginUrl(loginUrl); |
301 | 285 | return onlineSessionFilter; |
... | ... | @@ -305,29 +289,15 @@ public class ShiroConfig |
305 | 289 | * 自定义在线用户同步过滤器 |
306 | 290 | */ |
307 | 291 | @Bean |
308 | - public SyncOnlineSessionFilter syncOnlineSessionFilter() | |
309 | - { | |
292 | + public SyncOnlineSessionFilter syncOnlineSessionFilter() { | |
310 | 293 | SyncOnlineSessionFilter syncOnlineSessionFilter = new SyncOnlineSessionFilter(); |
311 | 294 | return syncOnlineSessionFilter; |
312 | 295 | } |
313 | 296 | |
314 | 297 | /** |
315 | - * 自定义验证码过滤器 | |
316 | - */ | |
317 | - @Bean | |
318 | - public CaptchaValidateFilter captchaValidateFilter() | |
319 | - { | |
320 | - CaptchaValidateFilter captchaValidateFilter = new CaptchaValidateFilter(); | |
321 | - captchaValidateFilter.setCaptchaEnabled(captchaEnabled); | |
322 | - captchaValidateFilter.setCaptchaType(captchaType); | |
323 | - return captchaValidateFilter; | |
324 | - } | |
325 | - | |
326 | - /** | |
327 | 298 | * cookie 属性设置 |
328 | 299 | */ |
329 | - public SimpleCookie rememberMeCookie() | |
330 | - { | |
300 | + public SimpleCookie rememberMeCookie() { | |
331 | 301 | SimpleCookie cookie = new SimpleCookie("rememberMe"); |
332 | 302 | cookie.setDomain(domain); |
333 | 303 | cookie.setPath(path); |
... | ... | @@ -339,8 +309,7 @@ public class ShiroConfig |
339 | 309 | /** |
340 | 310 | * 记住我 |
341 | 311 | */ |
342 | - public CookieRememberMeManager rememberMeManager() | |
343 | - { | |
312 | + public CookieRememberMeManager rememberMeManager() { | |
344 | 313 | CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager(); |
345 | 314 | cookieRememberMeManager.setCookie(rememberMeCookie()); |
346 | 315 | cookieRememberMeManager.setCipherKey(Base64.decode("fCq+/xW488hMTCD+cmJ3aQ==")); |
... | ... | @@ -351,8 +320,7 @@ public class ShiroConfig |
351 | 320 | * thymeleaf模板引擎和shiro框架的整合 |
352 | 321 | */ |
353 | 322 | @Bean |
354 | - public ShiroDialect shiroDialect() | |
355 | - { | |
323 | + public ShiroDialect shiroDialect() { | |
356 | 324 | return new ShiroDialect(); |
357 | 325 | } |
358 | 326 | |
... | ... | @@ -361,8 +329,7 @@ public class ShiroConfig |
361 | 329 | */ |
362 | 330 | @Bean |
363 | 331 | public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor( |
364 | - @Qualifier("securityManager") SecurityManager securityManager) | |
365 | - { | |
332 | + @Qualifier("securityManager") SecurityManager securityManager) { | |
366 | 333 | AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor(); |
367 | 334 | authorizationAttributeSourceAdvisor.setSecurityManager(securityManager); |
368 | 335 | return authorizationAttributeSourceAdvisor; |
... | ... |
src/main/java/com/huaheng/framework/redis/RedisCache.java
0 → 100644
1 | +package com.huaheng.framework.redis; | |
2 | + | |
3 | +import org.springframework.beans.factory.annotation.Autowired; | |
4 | +import org.springframework.data.redis.core.*; | |
5 | +import org.springframework.stereotype.Component; | |
6 | + | |
7 | +import java.util.*; | |
8 | +import java.util.concurrent.TimeUnit; | |
9 | + | |
10 | +/** | |
11 | + * spring redis 工具类 | |
12 | + * | |
13 | + * @author ruoyi | |
14 | + **/ | |
15 | +@SuppressWarnings(value = {"unchecked", "rawtypes"}) | |
16 | +@Component | |
17 | +public class RedisCache { | |
18 | + | |
19 | + @Autowired | |
20 | + public RedisTemplate redisTemplate; | |
21 | + | |
22 | + /** | |
23 | + * 缓存基本的对象,Integer、String、实体类等 | |
24 | + * | |
25 | + * @param key 缓存的键值 | |
26 | + * @param value 缓存的值 | |
27 | + * @return 缓存的对象 | |
28 | + */ | |
29 | + public <T> ValueOperations<String, T> setCacheObject(String key, T value) { | |
30 | + ValueOperations<String, T> operation = redisTemplate.opsForValue(); | |
31 | + operation.set(key, value); | |
32 | + return operation; | |
33 | + } | |
34 | + | |
35 | + /** | |
36 | + * 缓存基本的对象,Integer、String、实体类等 | |
37 | + * | |
38 | + * @param key 缓存的键值 | |
39 | + * @param value 缓存的值 | |
40 | + * @param timeout 时间 | |
41 | + * @param timeUnit 时间颗粒度 | |
42 | + * @return 缓存的对象 | |
43 | + */ | |
44 | + public <T> ValueOperations<String, T> setCacheObject(String key, T value, Integer timeout, TimeUnit timeUnit) { | |
45 | + ValueOperations<String, T> operation = redisTemplate.opsForValue(); | |
46 | + operation.set(key, value, timeout, timeUnit); | |
47 | + return operation; | |
48 | + } | |
49 | + | |
50 | + /** | |
51 | + * 获得缓存的基本对象。 | |
52 | + * | |
53 | + * @param key 缓存键值 | |
54 | + * @return 缓存键值对应的数据 | |
55 | + */ | |
56 | + public <T> T getCacheObject(String key) { | |
57 | + ValueOperations<String, T> operation = redisTemplate.opsForValue(); | |
58 | + return operation.get(key); | |
59 | + } | |
60 | + | |
61 | + /** | |
62 | + * 删除单个对象 | |
63 | + * | |
64 | + * @param key | |
65 | + */ | |
66 | + public void deleteObject(String key) { | |
67 | + redisTemplate.delete(key); | |
68 | + } | |
69 | + | |
70 | + /** | |
71 | + * 删除集合对象 | |
72 | + * | |
73 | + * @param collection | |
74 | + */ | |
75 | + public void deleteObject(Collection collection) { | |
76 | + redisTemplate.delete(collection); | |
77 | + } | |
78 | + | |
79 | + /** | |
80 | + * 缓存List数据 | |
81 | + * | |
82 | + * @param key 缓存的键值 | |
83 | + * @param dataList 待缓存的List数据 | |
84 | + * @return 缓存的对象 | |
85 | + */ | |
86 | + public <T> ListOperations<String, T> setCacheList(String key, List<T> dataList) { | |
87 | + ListOperations listOperation = redisTemplate.opsForList(); | |
88 | + if (null != dataList) { | |
89 | + int size = dataList.size(); | |
90 | + for (int i = 0; i < size; i++) { | |
91 | + listOperation.leftPush(key, dataList.get(i)); | |
92 | + } | |
93 | + } | |
94 | + return listOperation; | |
95 | + } | |
96 | + | |
97 | + /** | |
98 | + * 获得缓存的list对象 | |
99 | + * | |
100 | + * @param key 缓存的键值 | |
101 | + * @return 缓存键值对应的数据 | |
102 | + */ | |
103 | + public <T> List<T> getCacheList(String key) { | |
104 | + List<T> dataList = new ArrayList<T>(); | |
105 | + ListOperations<String, T> listOperation = redisTemplate.opsForList(); | |
106 | + Long size = listOperation.size(key); | |
107 | + | |
108 | + for (int i = 0; i < size; i++) { | |
109 | + dataList.add(listOperation.index(key, i)); | |
110 | + } | |
111 | + return dataList; | |
112 | + } | |
113 | + | |
114 | + /** | |
115 | + * 缓存Set | |
116 | + * | |
117 | + * @param key 缓存键值 | |
118 | + * @param dataSet 缓存的数据 | |
119 | + * @return 缓存数据的对象 | |
120 | + */ | |
121 | + public <T> BoundSetOperations<String, T> setCacheSet(String key, Set<T> dataSet) { | |
122 | + BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key); | |
123 | + Iterator<T> it = dataSet.iterator(); | |
124 | + while (it.hasNext()) { | |
125 | + setOperation.add(it.next()); | |
126 | + } | |
127 | + return setOperation; | |
128 | + } | |
129 | + | |
130 | + /** | |
131 | + * 获得缓存的set | |
132 | + * | |
133 | + * @param key | |
134 | + * @return | |
135 | + */ | |
136 | + public <T> Set<T> getCacheSet(String key) { | |
137 | + Set<T> dataSet = new HashSet<T>(); | |
138 | + BoundSetOperations<String, T> operation = redisTemplate.boundSetOps(key); | |
139 | + dataSet = operation.members(); | |
140 | + return dataSet; | |
141 | + } | |
142 | + | |
143 | + /** | |
144 | + * 缓存Map | |
145 | + * | |
146 | + * @param key | |
147 | + * @param dataMap | |
148 | + * @return | |
149 | + */ | |
150 | + public <T> HashOperations<String, String, T> setCacheMap(String key, Map<String, T> dataMap) { | |
151 | + HashOperations hashOperations = redisTemplate.opsForHash(); | |
152 | + if (null != dataMap) { | |
153 | + for (Map.Entry<String, T> entry : dataMap.entrySet()) { | |
154 | + hashOperations.put(key, entry.getKey(), entry.getValue()); | |
155 | + } | |
156 | + } | |
157 | + return hashOperations; | |
158 | + } | |
159 | + | |
160 | + /** | |
161 | + * 获得缓存的Map | |
162 | + * | |
163 | + * @param key | |
164 | + * @return | |
165 | + */ | |
166 | + public <T> Map<String, T> getCacheMap(String key) { | |
167 | + Map<String, T> map = redisTemplate.opsForHash().entries(key); | |
168 | + return map; | |
169 | + } | |
170 | + | |
171 | + /** | |
172 | + * 获得缓存的基本对象列表 | |
173 | + * | |
174 | + * @param pattern 字符串前缀 | |
175 | + * @return 对象列表 | |
176 | + */ | |
177 | + public Collection<String> keys(String pattern) { | |
178 | + return redisTemplate.keys(pattern); | |
179 | + } | |
180 | +} | |
... | ... |
src/main/java/com/huaheng/framework/shiro/web/filter/captcha/CaptchaValidateFilter.java deleted
1 | -package com.huaheng.framework.shiro.web.filter.captcha; | |
2 | - | |
3 | -import javax.servlet.ServletRequest; | |
4 | -import javax.servlet.ServletResponse; | |
5 | -import javax.servlet.http.HttpServletRequest; | |
6 | -import org.apache.shiro.web.filter.AccessControlFilter; | |
7 | -import com.google.code.kaptcha.Constants; | |
8 | -import com.huaheng.common.constant.ShiroConstants; | |
9 | -import com.huaheng.common.utils.StringUtils; | |
10 | -import com.huaheng.common.utils.security.ShiroUtils; | |
11 | - | |
12 | -/** | |
13 | - * 验证码过滤器 | |
14 | - * | |
15 | - * @author huaheng | |
16 | - */ | |
17 | -public class CaptchaValidateFilter extends AccessControlFilter | |
18 | -{ | |
19 | - | |
20 | - /** | |
21 | - * 是否开启验证码 | |
22 | - */ | |
23 | - private boolean captchaEnabled = true; | |
24 | - | |
25 | - /** | |
26 | - * 验证码类型 | |
27 | - */ | |
28 | - private String captchaType = "math"; | |
29 | - | |
30 | - public void setCaptchaEnabled(boolean captchaEnabled) | |
31 | - { | |
32 | - this.captchaEnabled = captchaEnabled; | |
33 | - } | |
34 | - | |
35 | - public void setCaptchaType(String captchaType) | |
36 | - { | |
37 | - this.captchaType = captchaType; | |
38 | - } | |
39 | - | |
40 | - @Override | |
41 | - public boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception | |
42 | - { | |
43 | - request.setAttribute(ShiroConstants.CURRENT_ENABLED, captchaEnabled); | |
44 | - request.setAttribute(ShiroConstants.CURRENT_TYPE, captchaType); | |
45 | - return super.onPreHandle(request, response, mappedValue); | |
46 | - } | |
47 | - | |
48 | - @Override | |
49 | - protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) | |
50 | - throws Exception | |
51 | - { | |
52 | - HttpServletRequest httpServletRequest = (HttpServletRequest) request; | |
53 | - // 验证码禁用 或不是表单提交 允许访问 | |
54 | - if (captchaEnabled == false || !"post".equals(httpServletRequest.getMethod().toLowerCase())) | |
55 | - { | |
56 | - return true; | |
57 | - } | |
58 | - return validateResponse(httpServletRequest, httpServletRequest.getParameter(ShiroConstants.CURRENT_VALIDATECODE)); | |
59 | - } | |
60 | - | |
61 | - public boolean validateResponse(HttpServletRequest request, String validateCode) | |
62 | - { | |
63 | - Object obj = ShiroUtils.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY); | |
64 | - String code = String.valueOf(obj != null ? obj : ""); | |
65 | - if (StringUtils.isEmpty(validateCode) || !validateCode.equalsIgnoreCase(code)) | |
66 | - { | |
67 | - return false; | |
68 | - } | |
69 | - return true; | |
70 | - } | |
71 | - | |
72 | - @Override | |
73 | - protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception | |
74 | - { | |
75 | - request.setAttribute(ShiroConstants.CURRENT_CAPTCHA, ShiroConstants.CAPTCHA_ERROR); | |
76 | - return true; | |
77 | - } | |
78 | -} |
src/main/java/com/huaheng/framework/token/ApiInterceptor.java
0 → 100644
1 | +package com.huaheng.framework.token; | |
2 | + | |
3 | +import com.alibaba.fastjson.JSONObject; | |
4 | +import com.huaheng.common.utils.ServletUtils; | |
5 | +import com.huaheng.common.utils.StringUtils; | |
6 | +import com.huaheng.framework.redis.RedisCache; | |
7 | +import org.springframework.web.servlet.HandlerInterceptor; | |
8 | + | |
9 | +import javax.annotation.Resource; | |
10 | +import javax.servlet.http.HttpServletRequest; | |
11 | +import javax.servlet.http.HttpServletResponse; | |
12 | +import java.security.SignatureException; | |
13 | + | |
14 | +/** | |
15 | + * Created by Enzo Cotter on 2020/6/11. | |
16 | + */ | |
17 | +public class ApiInterceptor implements HandlerInterceptor { | |
18 | + | |
19 | + @Resource | |
20 | + private RedisCache redisCache; | |
21 | + /** | |
22 | + * 可以在这里设置各种规则,取到token后解析,来验证token有效性,有效期等等。这里仅仅验证了是不是token为空。 | |
23 | + */ | |
24 | + @Override | |
25 | + public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception { | |
26 | + //这个就是从http头中取约定好的token的key。 | |
27 | + String token = httpServletRequest.getHeader("Authorization"); | |
28 | + try { | |
29 | + if (token == null || token.trim().equals("")) { | |
30 | + throw new SignatureException("token is null"); | |
31 | + } else { | |
32 | + token = token.substring(7); | |
33 | + String user = redisCache.getCacheObject(token); | |
34 | + if (StringUtils.isEmpty(user)) { | |
35 | + JSONObject jsonObject = new JSONObject(); | |
36 | + jsonObject.put("msg", "token不正确或过期"); | |
37 | + jsonObject.put("code", 401); | |
38 | + ServletUtils.renderString(httpServletResponse, jsonObject.toString()); | |
39 | + return false; | |
40 | + } | |
41 | + } | |
42 | + } catch (SignatureException e) { | |
43 | + JSONObject jsonObject = new JSONObject(); | |
44 | + jsonObject.put("msg", "请求参数中找不到Token"); | |
45 | + jsonObject.put("code", 401); | |
46 | + ServletUtils.renderString(httpServletResponse, jsonObject.toString()); | |
47 | + return false; | |
48 | + } | |
49 | + | |
50 | + return true; | |
51 | + } | |
52 | +} | |
... | ... |
src/main/java/com/huaheng/framework/token/TokenController.java
0 → 100644
1 | +package com.huaheng.framework.token; | |
2 | + | |
3 | +import com.huaheng.common.utils.StringUtils; | |
4 | +import com.huaheng.framework.shiro.service.PasswordService; | |
5 | +import com.huaheng.framework.web.controller.BaseController; | |
6 | +import com.huaheng.framework.web.domain.Result; | |
7 | +import com.huaheng.pc.system.user.domain.User; | |
8 | +import com.huaheng.pc.system.user.service.IUserService; | |
9 | +import org.springframework.web.bind.annotation.PostMapping; | |
10 | +import org.springframework.web.bind.annotation.RequestMapping; | |
11 | +import org.springframework.web.bind.annotation.ResponseBody; | |
12 | +import org.springframework.web.bind.annotation.RestController; | |
13 | + | |
14 | +import javax.annotation.Resource; | |
15 | +import java.util.Calendar; | |
16 | + | |
17 | +/** | |
18 | + * Created by Enzo Cotter on 2020/6/11. | |
19 | + */ | |
20 | +@RestController | |
21 | +@RequestMapping("/api") | |
22 | +public class TokenController extends BaseController { | |
23 | + | |
24 | + @Resource | |
25 | + private TokenService tokenService; | |
26 | + @Resource | |
27 | + private IUserService userService; | |
28 | + @Resource | |
29 | + private PasswordService passwordService; | |
30 | + | |
31 | + @PostMapping("/getToken") | |
32 | + @ResponseBody | |
33 | + public Result getToken(String username, String password, String warehouseCode) { | |
34 | + if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) { | |
35 | + return Result.error("用户名和密码不能为空"); | |
36 | + } | |
37 | + if (StringUtils.isEmpty(warehouseCode)) { | |
38 | + return Result.error("请选择仓库"); | |
39 | + } | |
40 | + User user = userService.selectUserByLoginName(username); | |
41 | + | |
42 | + if (!userService.checkWarehouseCodeAndUserName(warehouseCode, username)) { | |
43 | + return Result.error("用户没有该仓库操作权限"); | |
44 | + } | |
45 | + if (user.getPassword().equals(passwordService.encryptPassword(user.getLoginName(), password, user.getSalt()))) { | |
46 | + String token = tokenService.createToken(user); | |
47 | + Result ajaxResult = Result.success("成功"); | |
48 | + ajaxResult.put("token", token); | |
49 | + ajaxResult.put("expireTime", Calendar.getInstance().getTime()); | |
50 | + return ajaxResult; | |
51 | + } else { | |
52 | + return Result.error("密码错误"); | |
53 | + } | |
54 | + | |
55 | + } | |
56 | +} | |
... | ... |
src/main/java/com/huaheng/framework/token/TokenService.java
0 → 100644
1 | +package com.huaheng.framework.token; | |
2 | + | |
3 | +import com.alibaba.fastjson.JSONArray; | |
4 | +import com.alibaba.fastjson.JSONObject; | |
5 | +import com.fasterxml.jackson.annotation.JsonFormat; | |
6 | +import com.google.gson.JsonObject; | |
7 | +import com.huaheng.common.exception.service.ServiceException; | |
8 | +import com.huaheng.framework.redis.RedisCache; | |
9 | +import com.huaheng.pc.system.user.domain.User; | |
10 | +import io.jsonwebtoken.Claims; | |
11 | +import io.jsonwebtoken.Jws; | |
12 | +import io.jsonwebtoken.Jwts; | |
13 | +import io.jsonwebtoken.SignatureAlgorithm; | |
14 | +import jdk.nashorn.internal.parser.JSONParser; | |
15 | +import org.springframework.boot.autoconfigure.cache.CacheProperties; | |
16 | +import org.springframework.stereotype.Service; | |
17 | + | |
18 | +import javax.annotation.Resource; | |
19 | +import java.util.Calendar; | |
20 | +import java.util.Date; | |
21 | +import java.util.Map; | |
22 | +import java.util.concurrent.TimeUnit; | |
23 | + | |
24 | +/** | |
25 | + * token生成与解析 | |
26 | + * @author Enzo Cotter | |
27 | + * @date 2020/6/11 | |
28 | + */ | |
29 | +@Service | |
30 | +public class TokenService { | |
31 | + | |
32 | + @Resource | |
33 | + private RedisCache redisCache; | |
34 | + | |
35 | + /** | |
36 | + * 有效期7天 | |
37 | + */ | |
38 | + private static final int EXPIRE_TIME = 7; | |
39 | + | |
40 | + /** | |
41 | + * 盐 | |
42 | + */ | |
43 | + private static final String signingKey = "secret"; | |
44 | + | |
45 | + /** | |
46 | + * 创建token | |
47 | + * @param user 用户 | |
48 | + * @return | |
49 | + */ | |
50 | + public String createToken(User user){ | |
51 | + //签发时间 | |
52 | + Date iatTime = new Date(); | |
53 | + //expire time | |
54 | + Calendar nowTime = Calendar.getInstance(); | |
55 | + nowTime.add(Calendar.DATE, EXPIRE_TIME); | |
56 | + Date expireTime = nowTime.getTime(); | |
57 | + | |
58 | + Claims claims = Jwts.claims(); | |
59 | + claims.put("user", user); | |
60 | + claims.setIssuedAt(iatTime); | |
61 | + String token = Jwts.builder().setClaims(claims) | |
62 | + .signWith(SignatureAlgorithm.HS512,signingKey).compact(); | |
63 | + if (redisCache.setCacheObject(token, user.toString(), EXPIRE_TIME, TimeUnit.DAYS) == null) { | |
64 | + throw new ServiceException("redis异常"); | |
65 | + } | |
66 | + return token; | |
67 | + } | |
68 | + | |
69 | + /** | |
70 | + * 解析token | |
71 | + * @param token | |
72 | + */ | |
73 | + public void parseToken(String token){ | |
74 | + Jws<Claims> jws = Jwts.parser().setSigningKey(signingKey).parseClaimsJws(token); | |
75 | + Claims claims = jws.getBody(); | |
76 | + Map<String,String> header = jws.getHeader(); | |
77 | + System.out.println("parse"); | |
78 | + } | |
79 | +} | |
... | ... |
src/main/java/com/huaheng/framework/token/WebAppConfigurer.java
0 → 100644
1 | +package com.huaheng.framework.token; | |
2 | + | |
3 | +import org.springframework.context.annotation.Bean; | |
4 | +import org.springframework.context.annotation.Configuration; | |
5 | +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | |
6 | +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | |
7 | + | |
8 | +/** | |
9 | + * Created by Enzo Cotter on 2020/6/11. | |
10 | + */ | |
11 | +@Configuration | |
12 | +public class WebAppConfigurer implements WebMvcConfigurer { | |
13 | + | |
14 | + @Bean | |
15 | + ApiInterceptor apiInterceptor(){return new ApiInterceptor();} | |
16 | + | |
17 | + @Override | |
18 | + public void addInterceptors(InterceptorRegistry interceptorRegistry) { | |
19 | + interceptorRegistry.addInterceptor(apiInterceptor()) | |
20 | + .addPathPatterns("/api/**") | |
21 | + .excludePathPatterns("/api/getToken"); | |
22 | + } | |
23 | +} | |
... | ... |
src/main/java/com/huaheng/framework/web/domain/Result.java
0 → 100644
1 | +package com.huaheng.framework.web.domain; | |
2 | + | |
3 | +import com.huaheng.common.utils.StringUtils; | |
4 | + | |
5 | +import java.util.HashMap; | |
6 | + | |
7 | +/** | |
8 | + * 操作消息提醒 | |
9 | + * @author Enzo Cotter | |
10 | + * @date 2020/6/11 | |
11 | + */ | |
12 | +public class Result extends HashMap<String, Object> { | |
13 | + private static final long serialVersionUID = 1L; | |
14 | + | |
15 | + /** | |
16 | + * 状态码 | |
17 | + */ | |
18 | + public static final String CODE_TAG = "code"; | |
19 | + | |
20 | + /** | |
21 | + * 返回内容 | |
22 | + */ | |
23 | + public static final String MSG_TAG = "msg"; | |
24 | + | |
25 | + /** | |
26 | + * 数据对象 | |
27 | + */ | |
28 | + public static final String DATA_TAG = "data"; | |
29 | + | |
30 | + /** | |
31 | + * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。 | |
32 | + */ | |
33 | + public Result() { | |
34 | + } | |
35 | + | |
36 | + /** | |
37 | + * 初始化一个新创建的 AjaxResult 对象 | |
38 | + * | |
39 | + * @param code 状态码 | |
40 | + * @param msg 返回内容 | |
41 | + */ | |
42 | + public Result(int code, String msg) { | |
43 | + super.put(CODE_TAG, code); | |
44 | + super.put(MSG_TAG, msg); | |
45 | + } | |
46 | + | |
47 | + /** | |
48 | + * 初始化一个新创建的 AjaxResult 对象 | |
49 | + * | |
50 | + * @param code 状态码 | |
51 | + * @param msg 返回内容 | |
52 | + * @param data 数据对象 | |
53 | + */ | |
54 | + public Result(int code, String msg, Object data) { | |
55 | + super.put(CODE_TAG, code); | |
56 | + super.put(MSG_TAG, msg); | |
57 | + if (StringUtils.isNotNull(data)) { | |
58 | + super.put(DATA_TAG, data); | |
59 | + } | |
60 | + } | |
61 | + | |
62 | + /** | |
63 | + * 返回成功消息 | |
64 | + * | |
65 | + * @return 成功消息 | |
66 | + */ | |
67 | + public static Result success() { | |
68 | + return Result.success("操作成功"); | |
69 | + } | |
70 | + | |
71 | + /** | |
72 | + * 返回成功数据 | |
73 | + * | |
74 | + * @return 成功消息 | |
75 | + */ | |
76 | + public static Result success(Object data) { | |
77 | + return Result.success("操作成功", data); | |
78 | + } | |
79 | + | |
80 | + /** | |
81 | + * 返回成功消息 | |
82 | + * | |
83 | + * @param msg 返回内容 | |
84 | + * @return 成功消息 | |
85 | + */ | |
86 | + public static Result success(String msg) { | |
87 | + return Result.success(msg, null); | |
88 | + } | |
89 | + | |
90 | + /** | |
91 | + * 返回成功消息 | |
92 | + * | |
93 | + * @param msg 返回内容 | |
94 | + * @param data 数据对象 | |
95 | + * @return 成功消息 | |
96 | + */ | |
97 | + public static Result success(String msg, Object data) { | |
98 | + return new Result(200, msg, data); | |
99 | + } | |
100 | + | |
101 | + /** | |
102 | + * 返回错误消息 | |
103 | + * | |
104 | + * @return | |
105 | + */ | |
106 | + public static Result error() { | |
107 | + return Result.error("操作失败"); | |
108 | + } | |
109 | + | |
110 | + /** | |
111 | + * 返回错误消息 | |
112 | + * | |
113 | + * @param msg 返回内容 | |
114 | + * @return 警告消息 | |
115 | + */ | |
116 | + public static Result error(String msg) { | |
117 | + return Result.error(msg, null); | |
118 | + } | |
119 | + | |
120 | + /** | |
121 | + * 返回错误消息 | |
122 | + * | |
123 | + * @param msg 返回内容 | |
124 | + * @param data 数据对象 | |
125 | + * @return 警告消息 | |
126 | + */ | |
127 | + public static Result error(String msg, Object data) { | |
128 | + return new Result(400, msg, data); | |
129 | + } | |
130 | + | |
131 | + /** | |
132 | + * 返回错误消息 | |
133 | + * | |
134 | + * @param code 状态码 | |
135 | + * @param msg 返回内容 | |
136 | + * @return 警告消息 | |
137 | + */ | |
138 | + public static Result error(int code, String msg) { | |
139 | + return new Result(code, msg, null); | |
140 | + } | |
141 | + | |
142 | +} | |
... | ... |
src/main/java/com/huaheng/mobile/invenory/MobileInventoryController.java
... | ... | @@ -20,6 +20,8 @@ import com.huaheng.pc.inventory.cycleCountDetail.service.CycleCountDetailService |
20 | 20 | import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail; |
21 | 21 | import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService; |
22 | 22 | import com.huaheng.pc.inventory.inventoryHeader.service.InventoryHeaderService; |
23 | +import com.huaheng.pc.inventory.inventoryTransaction.domain.InventoryTransaction; | |
24 | +import com.huaheng.pc.inventory.inventoryTransaction.service.InventoryTransactionService; | |
23 | 25 | import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader; |
24 | 26 | import com.huaheng.pc.report.excelReport.mapper.ExcelReportMapper; |
25 | 27 | import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail; |
... | ... | @@ -52,6 +54,8 @@ public class MobileInventoryController { |
52 | 54 | @Resource |
53 | 55 | private InventoryDetailService inventoryDetailService; |
54 | 56 | @Resource |
57 | + private InventoryTransactionService inventoryTransactionService; | |
58 | + @Resource | |
55 | 59 | private TaskHeaderService taskService; |
56 | 60 | @Resource |
57 | 61 | private LocationService locationService; |
... | ... | @@ -487,4 +491,31 @@ public class MobileInventoryController { |
487 | 491 | } |
488 | 492 | return AjaxResult.success(inventoryDetail); |
489 | 493 | } |
494 | + | |
495 | + @PostMapping("/searchInventoryTransactionInCondition") | |
496 | + @ApiOperation("移动端查询库存交易记录") | |
497 | + @Log(title = "移动端查询库存交易记录", action = BusinessType.OTHER) | |
498 | + public AjaxResult searchInventoryTransactionInCondition(@RequestBody @ApiParam(value = "物料号") Map<String, String> param){ | |
499 | + String companyCode = param.get("companyCode"); | |
500 | + String transactionType = param.get("transactionType"); | |
501 | + String containerCode = param.get("containerCode"); | |
502 | + String materialCode = param.get("materialCode"); | |
503 | + String materialName = param.get("materialName"); | |
504 | + String materialSpec = param.get("materialSpec"); | |
505 | + String startTime = param.get("startTime"); | |
506 | + String endTime = param.get("endTime"); | |
507 | + LambdaQueryWrapper<InventoryTransaction> inventoryTransactionLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
508 | + inventoryTransactionLambdaQueryWrapper.eq(InventoryTransaction::getCompanyCode, companyCode) | |
509 | + .eq(InventoryTransaction::getWarehouseCode, ShiroUtils.getWarehouseCode()) | |
510 | + .eq(StringUtils.isNotEmpty(transactionType), InventoryTransaction::getTransactionType, transactionType) | |
511 | + .eq(StringUtils.isNotEmpty(containerCode), InventoryTransaction::getContainerCode, containerCode) | |
512 | + .like(StringUtils.isNotEmpty(materialCode), InventoryTransaction::getMaterialCode, materialCode) | |
513 | + .like(StringUtils.isNotEmpty(materialName), InventoryTransaction::getMaterialName, materialName) | |
514 | + .like(StringUtils.isNotEmpty(materialSpec), InventoryTransaction::getMaterialSpec, materialSpec) | |
515 | + .gt(StringUtils.isNotEmpty(startTime), InventoryTransaction::getCreated, startTime) | |
516 | + .le(StringUtils.isNotEmpty(endTime), InventoryTransaction::getCreated, endTime) | |
517 | + .orderByDesc(InventoryTransaction::getCreated); | |
518 | + List<InventoryTransaction> inventoryDetailList = inventoryTransactionService.list(inventoryTransactionLambdaQueryWrapper); | |
519 | + return AjaxResult.success(inventoryDetailList); | |
520 | + } | |
490 | 521 | } |
... | ... |
src/main/java/com/huaheng/mobile/receipt/MobileOneByOneReceiptController.java
... | ... | @@ -34,8 +34,8 @@ public class MobileOneByOneReceiptController { |
34 | 34 | @Log(title = "移动端逐件收货保存", action = BusinessType.OTHER) |
35 | 35 | public AjaxResult save(@RequestBody @ApiParam(value="容器号") ReceiptContainerView record) throws Exception { |
36 | 36 | record.setQty(new BigDecimal("1")); |
37 | - AjaxResult retResult = receiptContainerHeaderService.saveContainer(record.getReceiptCode(), record.getReceiptContainerCode(), | |
38 | - record.getReceiptDetailId(), record.getLocationCode(), record.getQty().intValue(), null); | |
37 | + AjaxResult retResult = receiptContainerHeaderService.saveCountain(record.getReceiptCode(), record.getReceiptContainerCode(), | |
38 | + record.getReceiptDetailId(), record.getLocationCode(), record.getQty(), null); | |
39 | 39 | return retResult; |
40 | 40 | } |
41 | 41 | } |
... | ... |
src/main/java/com/huaheng/pc/config/material/service/MaterialServiceImpl.java
... | ... | @@ -70,7 +70,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i |
70 | 70 | |
71 | 71 | Map<String, Object> map = receiptDetailService.getMap(lambda); |
72 | 72 | if (map != null) { |
73 | - return AjaxResult.error("存货编码(" + material.getCode() +")存在入库单,不能删除!"); | |
73 | + return AjaxResult.error("物料编码(" + material.getCode() +")存在入库单,不能删除!"); | |
74 | 74 | } |
75 | 75 | material.setDeleted(true); |
76 | 76 | material.setLastUpdatedBy(ShiroUtils.getLoginName()); |
... | ... |
src/main/java/com/huaheng/pc/config/station/controller/stationController.java
... | ... | @@ -52,7 +52,7 @@ public class stationController extends BaseController { |
52 | 52 | @Log(title = "配置-站台",operating = "站台列表", action = BusinessType.GRANT) |
53 | 53 | @PostMapping("/list") |
54 | 54 | @ResponseBody |
55 | - public TableDataInfo list(@ApiParam(name="shipmentType",value="编码、类型") Station station, | |
55 | + public TableDataInfo list(@ApiParam(name="station",value="编码、名称") Station station, | |
56 | 56 | @ApiParam(name = "createdBegin", value = "起止时间") String createdBegin, |
57 | 57 | @ApiParam(name = "createdEnd", value = "结束时间") String createdEnd) { |
58 | 58 | LambdaQueryWrapper<Station> lambdaQueryWrapper = Wrappers.lambdaQuery(); |
... | ... | @@ -62,6 +62,7 @@ public class stationController extends BaseController { |
62 | 62 | lambdaQueryWrapper.gt(StringUtils.isNotEmpty(createdBegin), Station::getCreated, createdBegin) |
63 | 63 | .lt(StringUtils.isNotEmpty(createdEnd), Station::getCreated, createdEnd) |
64 | 64 | .eq(StringUtils.isNotEmpty(station.getCode()), Station::getCode, station.getCode()) |
65 | + .like(StringUtils.isNotEmpty(station.getName()), Station::getName, station.getName()) | |
65 | 66 | .eq(StringUtils.isNotEmpty(station.getType()), Station::getType, station.getType()) |
66 | 67 | .eq(Station::getWarehouseCode, ShiroUtils.getWarehouseCode()); |
67 | 68 | |
... | ... |
src/main/java/com/huaheng/pc/config/station/domain/Station.java
... | ... | @@ -23,6 +23,13 @@ public class Station implements Serializable { |
23 | 23 | private Integer id; |
24 | 24 | |
25 | 25 | /** |
26 | + * 名称 | |
27 | + */ | |
28 | + @TableField(value = "name") | |
29 | + @ApiModelProperty(value="名称") | |
30 | + private String name; | |
31 | + | |
32 | + /** | |
26 | 33 | * 编码 |
27 | 34 | */ |
28 | 35 | @TableField(value = "code") |
... | ... |
src/main/java/com/huaheng/pc/monitor/job/task/RyTask.java
1 | 1 | package com.huaheng.pc.monitor.job.task; |
2 | 2 | |
3 | 3 | |
4 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
5 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
6 | +import com.huaheng.common.utils.security.ShiroUtils; | |
4 | 7 | import com.huaheng.pc.config.company.service.CompanyService; |
8 | +import com.huaheng.pc.config.container.domain.Container; | |
9 | +import com.huaheng.pc.config.container.service.ContainerService; | |
10 | +import com.huaheng.pc.config.location.domain.Location; | |
11 | +import com.huaheng.pc.config.location.service.LocationService; | |
5 | 12 | import com.huaheng.pc.config.wcsscanbarcode.service.WcsscanbarcodeService; |
6 | 13 | import com.huaheng.pc.monitor.job.service.IJobLogService; |
7 | 14 | import com.huaheng.pc.monitor.operlog.service.IOperLogService; |
15 | +import com.huaheng.pc.task.taskHeader.domain.TaskHeader; | |
16 | +import com.huaheng.pc.task.taskHeader.service.TaskHeaderService; | |
17 | +import org.jfree.data.gantt.TaskSeries; | |
8 | 18 | import org.springframework.beans.factory.annotation.Autowired; |
9 | 19 | import org.springframework.stereotype.Component; |
10 | 20 | |
11 | 21 | import javax.annotation.Resource; |
12 | 22 | import java.util.Date; |
23 | +import java.util.List; | |
24 | +import java.util.Random; | |
13 | 25 | |
14 | 26 | /** |
15 | 27 | * 定时任务调度测试 |
... | ... | @@ -23,6 +35,12 @@ public class RyTask { |
23 | 35 | private IJobLogService jobLogService; |
24 | 36 | @Autowired |
25 | 37 | private IOperLogService operLogService; |
38 | + @Autowired | |
39 | + private TaskHeaderService taskHeaderService; | |
40 | + @Autowired | |
41 | + private ContainerService containerService; | |
42 | + @Autowired | |
43 | + private LocationService locationService; | |
26 | 44 | @Resource |
27 | 45 | private WcsscanbarcodeService wcsscanbarcodeService; |
28 | 46 | @Resource |
... | ... | @@ -41,4 +59,31 @@ public class RyTask { |
41 | 59 | System.out.println("开始同步物料"); |
42 | 60 | } |
43 | 61 | |
62 | + | |
63 | + public void autoTest() { | |
64 | + LambdaQueryWrapper<TaskHeader> taskHeaderQueryWrapper = Wrappers.lambdaQuery(); | |
65 | + taskHeaderQueryWrapper.eq(TaskHeader::getWarehouseCode, ShiroUtils.getWarehouseCode()) | |
66 | + .le(TaskHeader::getStatus, 100); | |
67 | + List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderQueryWrapper); | |
68 | + int size = taskHeaderList.size(); | |
69 | + if(size > 1) { | |
70 | + return; | |
71 | + } | |
72 | + Random random = new Random(); | |
73 | + int choose = random.nextInt(100); | |
74 | + List<Location> list = containerService.getEmptyContainerInLocation(null,null,ShiroUtils.getWarehouseCode()); | |
75 | + Location location = list.get(random.nextInt(list.size())); | |
76 | + String containerCode = location.getContainerCode(); | |
77 | + String locationCode = location.getCode(); | |
78 | + if(choose % 2 == 1) { | |
79 | + LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
80 | + locationLambdaQueryWrapper.eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode()) | |
81 | + .eq(Location::getCode, "").eq(Location::getStatus, "empty"); | |
82 | + List<Location> locations = locationService.list(locationLambdaQueryWrapper); | |
83 | + Location freeLocation = locations.get(random.nextInt(locations.size())); | |
84 | + taskHeaderService.createTransferTask(locationCode, freeLocation.getCode()); | |
85 | + } else { | |
86 | + | |
87 | + } | |
88 | + } | |
44 | 89 | } |
... | ... |
src/main/java/com/huaheng/pc/monitor/message/controller/MessageController.java
0 → 100644
1 | +package com.huaheng.pc.monitor.message.controller; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
4 | +import com.baomidou.mybatisplus.core.metadata.IPage; | |
5 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
6 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |
7 | +import com.huaheng.common.support.Convert; | |
8 | +import com.huaheng.common.utils.StringUtils; | |
9 | +import com.huaheng.framework.aspectj.lang.annotation.Log; | |
10 | +import com.huaheng.framework.aspectj.lang.constant.BusinessType; | |
11 | +import com.huaheng.framework.web.controller.BaseController; | |
12 | +import com.huaheng.framework.web.domain.AjaxResult; | |
13 | +import com.huaheng.framework.web.page.PageDomain; | |
14 | +import com.huaheng.framework.web.page.TableDataInfo; | |
15 | +import com.huaheng.framework.web.page.TableSupport; | |
16 | +import com.huaheng.pc.monitor.message.domain.Messages; | |
17 | +import com.huaheng.pc.monitor.message.service.MessagesService; | |
18 | +import org.apache.shiro.authz.annotation.RequiresPermissions; | |
19 | +import org.springframework.stereotype.Controller; | |
20 | +import org.springframework.ui.ModelMap; | |
21 | +import org.springframework.web.bind.annotation.*; | |
22 | + | |
23 | +import javax.annotation.Resource; | |
24 | +import java.util.Arrays; | |
25 | +import java.util.List; | |
26 | + | |
27 | +/** | |
28 | + * Created by Enzo Cotter on 2020/4/16. | |
29 | + */ | |
30 | +@Controller | |
31 | +@RequestMapping("/monitor/messages") | |
32 | +public class MessageController extends BaseController { | |
33 | + | |
34 | + @Resource | |
35 | + private MessagesService messagesService; | |
36 | + | |
37 | + private String prefix = "monitor/messages"; | |
38 | + | |
39 | + @GetMapping() | |
40 | + public String messages(){ | |
41 | + return prefix+"/messages"; | |
42 | + } | |
43 | + | |
44 | + @RequiresPermissions("monitor:messages:list") | |
45 | + @Log(title = "管理-消息", operating = "查看消息", action = BusinessType.OTHER) | |
46 | + @PostMapping("/list") | |
47 | + @ResponseBody | |
48 | + public TableDataInfo list(Messages messages) { | |
49 | + LambdaQueryWrapper<Messages> lambdaQueryWrapper = Wrappers.lambdaQuery(); | |
50 | + PageDomain pageDomain = TableSupport.buildPageRequest(); | |
51 | + Integer pageNum = pageDomain.getPageNum(); | |
52 | + Integer pageSize = pageDomain.getPageSize(); | |
53 | + lambdaQueryWrapper | |
54 | + .eq(StringUtils.isNotEmpty(messages.getMsgTo()), Messages::getMsgTo, messages.getMsgTo()) | |
55 | + .eq(StringUtils.isNotEmpty(messages.getMsgFrom()), Messages::getMsgFrom, messages.getMsgFrom()) | |
56 | + .eq(StringUtils.isNotEmpty(messages.getMsgType()), Messages::getMsgType, messages.getMsgType()) | |
57 | + .eq(StringUtils.isNotEmpty(messages.getMsgSubType()), Messages::getMsgSubType, messages.getMsgSubType()) | |
58 | + .eq(StringUtils.isNotNull(messages.getEnable()), Messages::getEnable, messages.getEnable()) | |
59 | + .eq(StringUtils.isNotNull(messages.getTryCount()), Messages::getTryCount, messages.getTryCount()); | |
60 | + | |
61 | + if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)){ | |
62 | + /*使用分页查询*/ | |
63 | + Page<Messages> page = new Page<>(pageNum, pageSize); | |
64 | + IPage<Messages> iPage = messagesService.page(page, lambdaQueryWrapper); | |
65 | + return getMpDataTable(iPage.getRecords(), iPage.getTotal()); | |
66 | + } else { | |
67 | + List<Messages> list = messagesService.list(lambdaQueryWrapper); | |
68 | + return getDataTable(list); | |
69 | + } | |
70 | + } | |
71 | + | |
72 | + /** | |
73 | + * 修改消息 | |
74 | + */ | |
75 | + @GetMapping("/edit/{id}") | |
76 | + public String edit(@PathVariable("id") Integer id, ModelMap mmap) { | |
77 | + mmap.put("messages", messagesService.getById(id)); | |
78 | + return prefix + "/edit"; | |
79 | + } | |
80 | + | |
81 | + /** | |
82 | + * 修改保存消息地址 | |
83 | + */ | |
84 | + @RequiresPermissions("monitor:messages:edit") | |
85 | + @Log(title = "管理-消息", operating = "修改消息", action = BusinessType.UPDATE) | |
86 | + @PostMapping("/edit") | |
87 | + @ResponseBody | |
88 | + public AjaxResult editSave(Messages messages) { | |
89 | + return toAjax(messagesService.updateById(messages)); | |
90 | + } | |
91 | + | |
92 | + /** | |
93 | + * 删除消息 | |
94 | + */ | |
95 | + @RequiresPermissions("monitor:messages:remove") | |
96 | + @Log(title = "管理-消息", operating = "删除消息", action = BusinessType.DELETE) | |
97 | + @PostMapping( "/remove") | |
98 | + @ResponseBody | |
99 | + public AjaxResult remove(String ids) { | |
100 | + if (StringUtils.isEmpty(ids)){ | |
101 | + return AjaxResult.error("id不能为空"); | |
102 | + } | |
103 | + return toAjax(messagesService.removeByIds(Arrays.asList(Convert.toIntArray(ids)))); | |
104 | + } | |
105 | +} | |
... | ... |
src/main/java/com/huaheng/pc/monitor/message/domain/Messages.java
0 → 100644
1 | +package com.huaheng.pc.monitor.message.domain; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.annotation.IdType; | |
4 | +import com.baomidou.mybatisplus.annotation.TableField; | |
5 | +import com.baomidou.mybatisplus.annotation.TableId; | |
6 | +import com.baomidou.mybatisplus.annotation.TableName; | |
7 | +import java.io.Serializable; | |
8 | +import java.util.Date; | |
9 | +import lombok.Data; | |
10 | + | |
11 | +/** | |
12 | + * Created by Enzo Cotter on 2020/4/16. | |
13 | + */ | |
14 | + | |
15 | +/** | |
16 | + * 消息表 | |
17 | + */ | |
18 | +@Data | |
19 | +@TableName(value = "messages") | |
20 | +public class Messages implements Serializable { | |
21 | + /** | |
22 | + * 消息ID | |
23 | + */ | |
24 | + @TableId(value = "id", type = IdType.ID_WORKER) | |
25 | + private Long id; | |
26 | + | |
27 | + /** | |
28 | + * 消息类型 | |
29 | + */ | |
30 | + @TableField(value = "msgType") | |
31 | + private String msgType; | |
32 | + | |
33 | + /** | |
34 | + * 子类型 | |
35 | + */ | |
36 | + @TableField(value = "msgSubType") | |
37 | + private String msgSubType; | |
38 | + | |
39 | + /** | |
40 | + * 来源节点 | |
41 | + */ | |
42 | + @TableField(value = "msgFrom") | |
43 | + private String msgFrom; | |
44 | + | |
45 | + /** | |
46 | + * 目标节点 | |
47 | + */ | |
48 | + @TableField(value = "msgTo") | |
49 | + private String msgTo; | |
50 | + | |
51 | + /** | |
52 | + * 自定义字段1 | |
53 | + */ | |
54 | + @TableField(value = "msgSubject") | |
55 | + private String msgSubject; | |
56 | + | |
57 | + /** | |
58 | + * 消息主体内容 | |
59 | + */ | |
60 | + @TableField(value = "msgBody") | |
61 | + private String msgBody; | |
62 | + | |
63 | + /** | |
64 | + * 状态 | |
65 | + */ | |
66 | + @TableField(value = "enable") | |
67 | + private Integer enable; | |
68 | + | |
69 | + /** | |
70 | + * 重试次数 | |
71 | + */ | |
72 | + @TableField(value = "tryCount") | |
73 | + private Integer tryCount; | |
74 | + | |
75 | + /** | |
76 | + * 创建时间 | |
77 | + */ | |
78 | + @TableField(value = "created") | |
79 | + private Date created; | |
80 | + | |
81 | + /** | |
82 | + * 创建用户 | |
83 | + */ | |
84 | + @TableField(value = "createdBy") | |
85 | + private String createdBy; | |
86 | + | |
87 | + /** | |
88 | + * 自定义字段2 | |
89 | + */ | |
90 | + @TableField(value = "sess") | |
91 | + private String sess; | |
92 | + | |
93 | + /** | |
94 | + * 自定义字段3 | |
95 | + */ | |
96 | + @TableField(value = "params") | |
97 | + private String params; | |
98 | + | |
99 | + /** | |
100 | + * 自定义字段4 | |
101 | + */ | |
102 | + @TableField(value = "errorCode") | |
103 | + private String errorCode; | |
104 | + | |
105 | + @TableField(value = "queue") | |
106 | + private String queue; | |
107 | + | |
108 | + @TableField(value = "routingKey") | |
109 | + private String routingKey; | |
110 | + | |
111 | + @TableField(value = "nextRetry") | |
112 | + private Date nextRetry; | |
113 | + | |
114 | + @TableField(value = "updateTime") | |
115 | + private Date updateTime; | |
116 | + | |
117 | + private static final long serialVersionUID = 1L; | |
118 | +} | |
0 | 119 | \ No newline at end of file |
... | ... |
src/main/java/com/huaheng/pc/monitor/message/mapper/MessagesMapper.java
0 → 100644
1 | +package com.huaheng.pc.monitor.message.mapper; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |
4 | +import com.huaheng.pc.monitor.message.domain.Messages; | |
5 | + | |
6 | +/** | |
7 | + * Created by Enzo Cotter on 2020/4/16. | |
8 | + */ | |
9 | + | |
10 | +public interface MessagesMapper extends BaseMapper<Messages> { | |
11 | +} | |
0 | 12 | \ No newline at end of file |
... | ... |
src/main/java/com/huaheng/pc/monitor/message/service/BrokerMessageLogService.java
0 → 100644
1 | +package com.huaheng.pc.monitor.message.service; | |
2 | + | |
3 | +import com.huaheng.pc.monitor.message.domain.Messages; | |
4 | + | |
5 | +import java.util.Date; | |
6 | +import java.util.List; | |
7 | + | |
8 | +/** | |
9 | + * Created by Enzo Cotter on 2020/4/16. | |
10 | + */ | |
11 | +public interface BrokerMessageLogService { | |
12 | + | |
13 | + /** | |
14 | + * 查询消息状态为0(发送中) 且已经超时的消息集合 | |
15 | + * @return | |
16 | + */ | |
17 | + List<Messages> queryStatusAndTimeoutMessage(); | |
18 | + | |
19 | + /** | |
20 | + * 重新发送统计count发送次数 +1 | |
21 | + * @param messageId | |
22 | + * @param updateTime | |
23 | + */ | |
24 | + void update4ReSend(Long messageId, Date updateTime); | |
25 | + /** | |
26 | + * 更新最终消息发送结果 成功 or 失败 | |
27 | + * @param messageId | |
28 | + * @param status | |
29 | + * @param updateTime | |
30 | + */ | |
31 | + void changeBrokerMessageLogStatus(String messageId, Integer status, Date updateTime); | |
32 | +} | |
... | ... |
src/main/java/com/huaheng/pc/monitor/message/service/MessagesService.java
0 → 100644
1 | +package com.huaheng.pc.monitor.message.service; | |
2 | + | |
3 | +import com.huaheng.pc.monitor.message.domain.Messages; | |
4 | +import com.baomidou.mybatisplus.extension.service.IService; | |
5 | + /** | |
6 | + * Created by Enzo Cotter on 2020/4/16. | |
7 | + */ | |
8 | + | |
9 | +public interface MessagesService extends IService<Messages>{ | |
10 | + | |
11 | + | |
12 | +} | |
... | ... |
src/main/java/com/huaheng/pc/monitor/message/service/impl/BrokerMessageLogServiceImpl.java
0 → 100644
1 | +package com.huaheng.pc.monitor.message.service.impl; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
4 | +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |
5 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
6 | +import com.huaheng.pc.monitor.message.domain.Messages; | |
7 | +import com.huaheng.pc.monitor.message.service.BrokerMessageLogService; | |
8 | +import com.huaheng.pc.monitor.message.service.MessagesService; | |
9 | +import org.springframework.stereotype.Service; | |
10 | + | |
11 | +import javax.annotation.Resource; | |
12 | +import java.util.Date; | |
13 | +import java.util.List; | |
14 | + | |
15 | +/** | |
16 | + * Created by Enzo Cotter on 2020/4/16. | |
17 | + */ | |
18 | +@Service | |
19 | +public class BrokerMessageLogServiceImpl implements BrokerMessageLogService { | |
20 | + | |
21 | + @Resource | |
22 | + private MessagesService messagesService; | |
23 | + | |
24 | + /** | |
25 | + * 查询消息状态为0(发送中) 且已经超时的消息集合 | |
26 | + * | |
27 | + * @return | |
28 | + */ | |
29 | + @Override | |
30 | + public List<Messages> queryStatusAndTimeoutMessage() { | |
31 | + LambdaQueryWrapper<Messages> queryWrapper = Wrappers.lambdaQuery(); | |
32 | + queryWrapper.eq(Messages::getEnable, 0).le(Messages::getNextRetry, new Date()); | |
33 | + return messagesService.list(queryWrapper); | |
34 | + } | |
35 | + | |
36 | + /** | |
37 | + * 重新发送统计count发送次数 +1 | |
38 | + * | |
39 | + * @param messageId | |
40 | + * @param updateTime | |
41 | + */ | |
42 | + @Override | |
43 | + public void update4ReSend(Long messageId, Date updateTime) { | |
44 | + LambdaQueryWrapper<Messages> queryWrapper = Wrappers.lambdaQuery(); | |
45 | + queryWrapper.eq(Messages::getId, messageId); | |
46 | + Messages messages = new Messages(); | |
47 | + messages.setUpdateTime(updateTime); | |
48 | + messagesService.update(messages, queryWrapper); | |
49 | + } | |
50 | + | |
51 | + /** | |
52 | + * 更新最终消息发送结果 成功 or 失败 | |
53 | + * | |
54 | + * @param messageId | |
55 | + * @param status | |
56 | + * @param updateTime | |
57 | + */ | |
58 | + @Override | |
59 | + public void changeBrokerMessageLogStatus(String messageId, Integer status, Date updateTime) { | |
60 | + LambdaQueryWrapper<Messages> queryWrapper = Wrappers.lambdaQuery(); | |
61 | + queryWrapper.eq(Messages::getId, messageId); | |
62 | + Messages messages = new Messages(); | |
63 | + messages.setEnable(status); | |
64 | + messages.setUpdateTime(updateTime); | |
65 | + messagesService.update(messages, queryWrapper); | |
66 | + } | |
67 | +} | |
... | ... |
src/main/java/com/huaheng/pc/monitor/message/service/impl/MessagesServiceImpl.java
0 → 100644
1 | +package com.huaheng.pc.monitor.message.service.impl; | |
2 | + | |
3 | +import org.springframework.stereotype.Service; | |
4 | +import javax.annotation.Resource; | |
5 | +import java.util.List; | |
6 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
7 | +import com.huaheng.pc.monitor.message.domain.Messages; | |
8 | +import com.huaheng.pc.monitor.message.mapper.MessagesMapper; | |
9 | +import com.huaheng.pc.monitor.message.service.MessagesService; | |
10 | +/** | |
11 | + * Created by Enzo Cotter on 2020/4/16. | |
12 | + */ | |
13 | + | |
14 | +@Service | |
15 | +public class MessagesServiceImpl extends ServiceImpl<MessagesMapper, Messages> implements MessagesService{ | |
16 | + | |
17 | +} | |
... | ... |
src/main/java/com/huaheng/pc/receipt/receiptContainerHeader/service/ReceiptContainerHeaderService.java
... | ... | @@ -6,6 +6,7 @@ import com.huaheng.pc.receipt.receiptContainerHeader.domain.ReceiptContainerHead |
6 | 6 | import com.baomidou.mybatisplus.extension.service.IService; |
7 | 7 | import com.huaheng.pc.receipt.receiptContainerHeader.domain.ReceiptContainerView; |
8 | 8 | |
9 | +import java.math.BigDecimal; | |
9 | 10 | import java.util.List; |
10 | 11 | |
11 | 12 | public interface ReceiptContainerHeaderService extends IService<ReceiptContainerHeader>{ |
... | ... | @@ -20,8 +21,8 @@ public interface ReceiptContainerHeaderService extends IService<ReceiptContainer |
20 | 21 | * @param locatingRule 定位规则 |
21 | 22 | * @return 是否保存成功 |
22 | 23 | */ |
23 | - AjaxResult saveContainer(String receiptCode, String containerCode, Integer receiptDetailId, | |
24 | - String locationCode, Integer qty, String locatingRule); | |
24 | + AjaxResult saveCountain(String receiptCode, String containerCode, Integer receiptDetailId, | |
25 | + String locationCode, BigDecimal qty, String locatingRule); | |
25 | 26 | |
26 | 27 | /** |
27 | 28 | * 取消组盘 |
... | ... |
src/main/java/com/huaheng/pc/receipt/receiptContainerHeader/service/ReceiptContainerHeaderServiceImpl.java
... | ... | @@ -10,11 +10,13 @@ import com.huaheng.common.utils.security.ShiroUtils; |
10 | 10 | import com.huaheng.framework.web.domain.AjaxResult; |
11 | 11 | import com.huaheng.mobile.receipt.ReceiptBill; |
12 | 12 | import com.huaheng.pc.config.container.domain.Container; |
13 | +import com.huaheng.pc.config.container.domain.ContainerStatus; | |
13 | 14 | import com.huaheng.pc.config.container.service.ContainerService; |
14 | 15 | import com.huaheng.pc.config.location.domain.Location; |
15 | 16 | import com.huaheng.pc.config.location.service.LocationService; |
16 | 17 | import com.huaheng.pc.config.material.domain.Material; |
17 | 18 | import com.huaheng.pc.config.material.service.MaterialService; |
19 | +import com.huaheng.pc.config.warehouse.domain.Warehouse; | |
18 | 20 | import com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail; |
19 | 21 | import com.huaheng.pc.receipt.receiptContainerDetail.service.ReceiptContainerDetailService; |
20 | 22 | import com.huaheng.pc.receipt.receiptContainerHeader.domain.ReceiptContainerHeader; |
... | ... | @@ -26,10 +28,12 @@ import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader; |
26 | 28 | import com.huaheng.pc.receipt.receiptHeader.service.ReceiptHeaderService; |
27 | 29 | import com.huaheng.pc.task.taskHeader.domain.TaskHeader; |
28 | 30 | import com.huaheng.pc.task.taskHeader.service.TaskHeaderService; |
31 | +import io.swagger.models.auth.In; | |
29 | 32 | import org.springframework.stereotype.Service; |
30 | 33 | import org.springframework.transaction.annotation.Transactional; |
31 | 34 | |
32 | 35 | import javax.annotation.Resource; |
36 | +import java.io.PushbackInputStream; | |
33 | 37 | import java.math.BigDecimal; |
34 | 38 | import java.text.MessageFormat; |
35 | 39 | import java.util.Calendar; |
... | ... | @@ -65,8 +69,8 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
65 | 69 | */ |
66 | 70 | @Override |
67 | 71 | @Transactional |
68 | - public AjaxResult saveContainer(String receiptCode, String containerCode, Integer receiptDetailId, | |
69 | - String locationCode, Integer qty, String locatingRule) { | |
72 | + public AjaxResult saveCountain(String receiptCode, String containerCode, Integer receiptDetailId, | |
73 | + String locationCode, BigDecimal qty, String locatingRule) { | |
70 | 74 | ReceiptDetail detail = receiptDetailService.getById(receiptDetailId); |
71 | 75 | //检查容器编码合法性 |
72 | 76 | Integer taskType = checkContainer(containerCode, detail.getMaterialCode()); |
... | ... | @@ -77,9 +81,17 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
77 | 81 | }else { |
78 | 82 | if (taskType == 0){ throw new ServiceException("容器状态未知"); } |
79 | 83 | } |
84 | + LambdaQueryWrapper<Container> lambdaContainer = Wrappers.lambdaQuery(); | |
85 | + lambdaContainer.eq(Container::getCode, containerCode); | |
86 | + Container container = containerService.getOne(lambdaContainer); | |
87 | + if(container != null && StringUtils.isNotEmpty(container.getLocationCode())) { | |
88 | + locationCode = container.getLocationCode(); | |
89 | + } | |
80 | 90 | //检查库位编码合法性 |
81 | - if (checkLocationCode(locationCode, containerCode, taskType)) { | |
82 | - locationService.updateStatus(locationCode, "lock"); | |
91 | + if (StringUtils.isNotEmpty(locationCode)) { | |
92 | + if (checkLocationCode(locationCode, containerCode, taskType)) { | |
93 | + locationService.updateStatus(locationCode, "lock"); | |
94 | + } | |
83 | 95 | } |
84 | 96 | |
85 | 97 | /* 新建保存组盘头表记录*/ |
... | ... | @@ -97,10 +109,10 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
97 | 109 | receiptContainerHeader.setWarehouseCode(ShiroUtils.getWarehouseCode()); |
98 | 110 | receiptContainerHeader.setCompanyCode(receiptDetail.getCompanyCode()); |
99 | 111 | receiptContainerHeader.setContainerCode(containerCode); |
100 | - Container condition = new Container(); | |
101 | - condition.setCode(containerCode); | |
102 | - LambdaQueryWrapper<Container> containerHeaderQueryWrapper = Wrappers.lambdaQuery(condition); | |
103 | - Container container = containerService.getOne(containerHeaderQueryWrapper); | |
112 | +// Container condition = new Container(); | |
113 | +// condition.setCode(containerCode); | |
114 | +// LambdaQueryWrapper<Container> containerHeaderQueryWrapper = Wrappers.lambdaQuery(condition); | |
115 | +// Container container = containerService.getOne(containerHeaderQueryWrapper); | |
104 | 116 | receiptContainerHeader.setContainerType(container.getContainerType()); |
105 | 117 | receiptContainerHeader.setTaskType(String.valueOf(taskType)); |
106 | 118 | if (taskType.equals(QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT)) { |
... | ... | @@ -125,7 +137,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
125 | 137 | //根据入库单详情id查询入库详情 |
126 | 138 | ReceiptDetail receiptDetail = receiptDetailService.getById(receiptDetailId); |
127 | 139 | receiptDetail.setId(receiptDetailId); |
128 | - receiptDetail.setOpenQty(new BigDecimal(qty).add(receiptDetail.getOpenQty())); | |
140 | + receiptDetail.setOpenQty(qty.add(receiptDetail.getOpenQty())); | |
129 | 141 | //更新入库单详情的收货数量 |
130 | 142 | if (!receiptDetailService.updateById(receiptDetail)){ |
131 | 143 | throw new ServiceException("更新入库单详情失败"); |
... | ... | @@ -241,8 +253,8 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
241 | 253 | // } |
242 | 254 | AjaxResult ajaxResult = null; |
243 | 255 | for (ReceiptContainerView receiptContainerView : list) { |
244 | - ajaxResult = saveContainer(receiptContainerView.getReceiptCode(), receiptContainerView.getReceiptContainerCode(), | |
245 | - receiptContainerView.getReceiptDetailId(), receiptContainerView.getLocationCode(), receiptContainerView.getQty().intValue(), null); | |
256 | + ajaxResult = saveCountain(receiptContainerView.getReceiptCode(), receiptContainerView.getReceiptContainerCode(), | |
257 | + receiptContainerView.getReceiptDetailId(), receiptContainerView.getLocationCode(), receiptContainerView.getQty(), null); | |
246 | 258 | } |
247 | 259 | return ajaxResult; |
248 | 260 | } |
... | ... | @@ -294,9 +306,9 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
294 | 306 | if (taskHeaderService.count(lambdaQueryWrapper) > 0){ |
295 | 307 | throw new ServiceException("容器已经存在任务,请更换容器"); |
296 | 308 | } |
297 | - if ("empty".equals(container.getStatus())){ | |
309 | + if ("empty".equals(container.getStatus()) && StringUtils.isEmpty(container.getLocationCode())){ | |
298 | 310 | return QuantityConstant.TASK_TYPE_WHOLERECEIPT; |
299 | - }else if ("some".equals(container.getStatus())) { | |
311 | + }else if ("some".equals(container.getStatus()) || StringUtils.isNotEmpty(container.getLocationCode())) { | |
300 | 312 | return QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT; |
301 | 313 | } else if ("full".equals(container.getStatus())) { |
302 | 314 | throw new ServiceException("该容器已满,请更换容器"); |
... | ... | @@ -315,8 +327,10 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
315 | 327 | Boolean checkLocationCode(String locationCode, String containerCode, Integer taskType) { |
316 | 328 | //如果选了库位,就要校验库位和已经组盘的库位是否一致,避免重入库 |
317 | 329 | if (StringUtils.isEmpty(locationCode)) { |
318 | - if (QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT.equals(taskType)) { | |
330 | + if (QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT.equals(locationCode)) { | |
319 | 331 | throw new ServiceException("补充入库,必须填写库位"); |
332 | + } else { | |
333 | + return true; | |
320 | 334 | } |
321 | 335 | } |
322 | 336 | |
... | ... | @@ -383,7 +397,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
383 | 397 | * @param containerCode 容器编码 |
384 | 398 | */ |
385 | 399 | @Transactional |
386 | - public void receiptContainerDetailAdd(Integer receiptContainerHeaderId, ReceiptDetail receiptDetail, Integer qty, String containerCode, String locationCode){ | |
400 | + public void receiptContainerDetailAdd(Integer receiptContainerHeaderId, ReceiptDetail receiptDetail, BigDecimal qty, String containerCode, String locationCode){ | |
387 | 401 | LambdaQueryWrapper<ReceiptContainerDetail> lambda = Wrappers.lambdaQuery(); |
388 | 402 | lambda.eq(ReceiptContainerDetail::getReceiptContainerId, receiptContainerHeaderId) |
389 | 403 | .eq(ReceiptContainerDetail::getReceiptId, receiptDetail.getReceiptId()) |
... | ... | @@ -418,7 +432,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
418 | 432 | receiptContainerDetail.setMaterialName(receiptDetail.getMaterialName()); |
419 | 433 | receiptContainerDetail.setMaterialSpec(receiptDetail.getMaterialSpec()); |
420 | 434 | receiptContainerDetail.setMaterialUnit(receiptDetail.getMaterialUnit()); |
421 | - receiptContainerDetail.setQty(new BigDecimal(qty)); | |
435 | + receiptContainerDetail.setQty(qty); | |
422 | 436 | receiptContainerDetail.setSupplierCode(receiptDetail.getSupplierCode()); |
423 | 437 | receiptContainerDetail.setBatch(receiptDetail.getBatch()); |
424 | 438 | receiptContainerDetail.setLot(receiptDetail.getLot()); |
... | ... | @@ -433,7 +447,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
433 | 447 | throw new ServiceException("保存入库组盘详情失败"); |
434 | 448 | } |
435 | 449 | } else { |
436 | - receiptContainerDetail.setQty(receiptContainerDetail.getQty().add(BigDecimal.valueOf(qty))); | |
450 | + receiptContainerDetail.setQty(receiptContainerDetail.getQty().add(qty)); | |
437 | 451 | if (!receiptContainerDetailService.updateById(receiptContainerDetail)){ |
438 | 452 | throw new ServiceException("更新入库组盘详情失败"); |
439 | 453 | } |
... | ... | @@ -480,7 +494,6 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
480 | 494 | recorder.setTaskType(String.valueOf(QuantityConstant.TASK_TYPE_WHOLERECEIPT)); |
481 | 495 | recorder.setStatus((short) 0); |
482 | 496 | recorder.setCreatedBy(ShiroUtils.getLoginName()); |
483 | - recorder.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
484 | 497 | |
485 | 498 | LambdaQueryWrapper<ReceiptContainerHeader> receiptContainerHeaderLambada = Wrappers.lambdaQuery(); |
486 | 499 | receiptContainerHeaderLambada.eq(ReceiptContainerHeader::getContainerCode, receiptContainerCode) |
... | ... |
src/main/java/com/huaheng/pc/receipt/receiptDetail/controller/ReceiptDetailController.java
... | ... | @@ -149,21 +149,21 @@ public class ReceiptDetailController extends BaseController { |
149 | 149 | /** |
150 | 150 | * 删除入库单 |
151 | 151 | */ |
152 | - //@ApiOperation(value="删除入库单 ", notes="删除入库单 ", httpMethod = "POST") | |
153 | - //@RequiresPermissions("receipt:receiptDetail:add") | |
154 | - //@Log(title = "入库-入库单 ",operating = "修改入库单 ", action = BusinessType.INSERT) | |
155 | - //@PostMapping("/edit") | |
156 | - //@ResponseBody | |
157 | - //public AjaxResult remove(String ids) { | |
158 | - // if (StringUtils.isEmpty(ids)){ | |
159 | - // return AjaxResult.error("id为空"); | |
160 | - // } | |
161 | - // List<Integer> list = new ArrayList<>(); | |
162 | - // for (Integer id : Convert.toIntArray(ids)){ | |
163 | - // list.add(id); | |
164 | - // } | |
165 | - // return toAjax(receiptDetailService.removeByIds(list)); | |
166 | - //} | |
152 | + @ApiOperation(value="删除入库单 ", notes="删除入库单 ", httpMethod = "POST") | |
153 | + @RequiresPermissions("receipt:receiptDetail:remove") | |
154 | + @Log(title = "入库-入库单 ",operating = "修改入库单 ", action = BusinessType.INSERT) | |
155 | + @PostMapping("/remove") | |
156 | + @ResponseBody | |
157 | + public AjaxResult remove(String ids) { | |
158 | + if (StringUtils.isEmpty(ids)){ | |
159 | + return AjaxResult.error("id为空"); | |
160 | + } | |
161 | + List<Integer> list = new ArrayList<>(); | |
162 | + for (Integer id : Convert.toIntArray(ids)){ | |
163 | + list.add(id); | |
164 | + } | |
165 | + return toAjax(receiptDetailService.removeByIds(list)); | |
166 | + } | |
167 | 167 | |
168 | 168 | /** |
169 | 169 | * 审核入库单 |
... | ... | @@ -230,30 +230,29 @@ public class ReceiptDetailController extends BaseController { |
230 | 230 | @RequiresPermissions("shipment:bill:report") |
231 | 231 | @Log(title = "入库-入库单", operating = "打印入库单明细报表", action = BusinessType.OTHER) |
232 | 232 | @GetMapping("/report/{ids}") |
233 | - public String report(@PathVariable("ids") Integer[] ids, ModelMap mmap) | |
234 | - { | |
235 | - List<ReceiptDetail> list=new ArrayList<ReceiptDetail>(); | |
236 | - for(Integer id:ids){ | |
237 | - if(id!=null) { | |
233 | + public String report(@PathVariable("ids") Integer[] ids, ModelMap mmap) { | |
234 | + List<ReceiptDetail> list = new ArrayList<ReceiptDetail>(); | |
235 | + for (Integer id : ids) { | |
236 | + if (id != null) { | |
238 | 237 | ReceiptDetail receiptDetail = receiptDetailService.getById(id); |
239 | 238 | |
240 | 239 | //获得物料信息 |
241 | 240 | LambdaQueryWrapper<Material> materialLambd = Wrappers.lambdaQuery(); |
242 | - materialLambd.eq(Material::getCode,receiptDetail.getMaterialCode()) | |
243 | - .eq(Material::getWarehouseCode,ShiroUtils.getWarehouseCode()); | |
244 | - Material material =materialService.getOne(materialLambd); | |
245 | - if(material == null){ | |
246 | - throw new ServiceException("系统没有此物料编码"+receiptDetail.getMaterialCode()); | |
241 | + materialLambd.eq(Material::getCode, receiptDetail.getMaterialCode()) | |
242 | + .eq(Material::getWarehouseCode, ShiroUtils.getWarehouseCode()); | |
243 | + Material material = materialService.getOne(materialLambd); | |
244 | + if (material == null) { | |
245 | + throw new ServiceException("系统没有此物料编码" + receiptDetail.getMaterialCode()); | |
247 | 246 | } |
248 | 247 | receiptDetail.setMaterialSpec(material.getSpec()); |
249 | 248 | receiptDetail.setMaterialName(material.getName()); |
250 | 249 | NumberFormat nf = NumberFormat.getInstance(); |
251 | 250 | receiptDetail.setTotalQty(new BigDecimal(nf.format(receiptDetail.getTotalQty()))); |
252 | - LambdaQueryWrapper<Company> companyLambda =Wrappers.lambdaQuery(); | |
253 | - companyLambda.eq(Company::getCode,receiptDetail.getCompanyCode()); | |
254 | - Company company= companyService.getOne(companyLambda); | |
255 | - if(company == null){ | |
256 | - throw new ServiceException("系统没有此货主编码"+receiptDetail.getCompanyCode()); | |
251 | + LambdaQueryWrapper<Company> companyLambda = Wrappers.lambdaQuery(); | |
252 | + companyLambda.eq(Company::getCode, receiptDetail.getCompanyCode()); | |
253 | + Company company = companyService.getOne(companyLambda); | |
254 | + if (company == null) { | |
255 | + throw new ServiceException("系统没有此货主编码" + receiptDetail.getCompanyCode()); | |
257 | 256 | } |
258 | 257 | receiptDetail.setCompanyName(company.getName()); |
259 | 258 | list.add(receiptDetail); |
... | ... |
src/main/java/com/huaheng/pc/receipt/receiptDetail/service/ReceiptDetailServiceImpl.java
... | ... | @@ -448,7 +448,7 @@ public class ReceiptDetailServiceImpl extends ServiceImpl<ReceiptDetailMapper, R |
448 | 448 | ReceiptDetail receiptDetail = new ReceiptDetail(); |
449 | 449 | receiptDetail.setId(null); |
450 | 450 | receiptDetail.setWarehouseCode(ShiroUtils.getWarehouseCode()); |
451 | - receiptDetail.setCompanyCode(companyCode); | |
451 | + receiptDetail.setCompanyCode(companyCode); | |
452 | 452 | receiptDetail.setReceiptId(receiptHeader.getId()); |
453 | 453 | receiptDetail.setReceiptCode(receiptHeader.getCode()); |
454 | 454 | receiptDetail.setMaterialCode(receiptBill.getMaterialCode()); |
... | ... | @@ -461,7 +461,6 @@ public class ReceiptDetailServiceImpl extends ServiceImpl<ReceiptDetailMapper, R |
461 | 461 | receiptDetail.setLastUpdatedBy(ShiroUtils.getLoginName()); |
462 | 462 | receiptDetail.setDeleted(false); |
463 | 463 | receiptDetail.setBatch(receiptBill.getBatch()); |
464 | - receiptDetail.setCompanyCode(companyCode); | |
465 | 464 | save(receiptDetail); |
466 | 465 | mReceiptDetailIds.add(receiptDetail.getId()); |
467 | 466 | } |
... | ... |
src/main/java/com/huaheng/pc/receipt/receiptHeader/service/ReceiptHeaderService.java
... | ... | @@ -295,7 +295,7 @@ public class ReceiptHeaderService extends ServiceImpl<ReceiptHeaderMapper, Recei |
295 | 295 | throw new ServiceException("更新入库明细状态失败"); |
296 | 296 | } |
297 | 297 | } else { |
298 | - throw new ServiceException("已有入库明细进入订单池"); | |
298 | + receiptDetailService.updateReceiptHeaderLastStatus(receiptDetail.getReceiptId()); | |
299 | 299 | } |
300 | 300 | } |
301 | 301 | } |
... | ... |
src/main/java/com/huaheng/pc/receipt/receiving/controller/ReceivingController.java
... | ... | @@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping; |
17 | 17 | import org.springframework.web.bind.annotation.ResponseBody; |
18 | 18 | |
19 | 19 | import javax.annotation.Resource; |
20 | +import java.math.BigDecimal; | |
20 | 21 | |
21 | 22 | /** |
22 | 23 | * @author mahua |
... | ... | @@ -87,7 +88,7 @@ public class ReceivingController extends BaseController { |
87 | 88 | @ApiParam(name="containerCode",value="容器编码")String containerCode, |
88 | 89 | @ApiParam(name="receiptDetailId",value="入库单详情id")Integer receiptDetailId, |
89 | 90 | @ApiParam(name="locationCode",value="库位编码", required = false)String locationCode, |
90 | - @ApiParam(name="qty",value="收货数量")Integer qty, | |
91 | + @ApiParam(name="qty",value="收货数量") BigDecimal qty, | |
91 | 92 | @ApiParam(name="localtionRule",value="定位规则", required = false)String locatingRule){ |
92 | 93 | // LambdaQueryWrapper<TaskHeader> lambdaQueryWrapper = Wrappers.lambdaQuery(); |
93 | 94 | // lambdaQueryWrapper.eq(TaskHeader::getTaskType, 900) |
... | ... | @@ -97,7 +98,7 @@ public class ReceivingController extends BaseController { |
97 | 98 | // if (count > 0) { |
98 | 99 | // return AjaxResult.error("仓库有“出库查看”任务没有完成,请先完成任务"); |
99 | 100 | // } |
100 | - AjaxResult result = receiptContainerHeaderService.saveContainer(receiptCode, containerCode, receiptDetailId, | |
101 | + AjaxResult result = receiptContainerHeaderService.saveCountain(receiptCode, containerCode, receiptDetailId, | |
101 | 102 | locationCode, qty, locatingRule); |
102 | 103 | return result; |
103 | 104 | } |
... | ... |
src/main/java/com/huaheng/pc/shipment/shipmentContainerHeader/service/ShipmentContainerHeaderServiceImpl.java
... | ... | @@ -492,7 +492,7 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentCont |
492 | 492 | if (shipmentQty.compareTo(BigDecimal.ZERO) <= 0) { |
493 | 493 | continue; |
494 | 494 | } |
495 | - // 根据 仓库编码、货主编码、存货编码,物料状态,项目号来查找可以出库的物料 | |
495 | + // 根据 仓库编码、货主编码、物料编码,物料状态,项目号来查找可以出库的物料 | |
496 | 496 | // ShippingSearch search = new ShippingSearch(); |
497 | 497 | // search.setWarehouseCode(ShiroUtils.getWarehouseCode()); |
498 | 498 | // search.setCompanyCode(item.getCompanyCode()); |
... | ... |
src/main/java/com/huaheng/pc/system/dict/controller/DictTypeController.java
... | ... | @@ -24,13 +24,12 @@ import com.huaheng.pc.system.dict.service.IDictTypeService; |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * 数据字典信息 |
27 | - * | |
27 | + * | |
28 | 28 | * @author huaheng |
29 | 29 | */ |
30 | 30 | @Controller |
31 | 31 | @RequestMapping("/system/dict") |
32 | -public class DictTypeController extends BaseController | |
33 | -{ | |
32 | +public class DictTypeController extends BaseController { | |
34 | 33 | private String prefix = "system/dict/type"; |
35 | 34 | |
36 | 35 | @Autowired |
... | ... | @@ -38,8 +37,7 @@ public class DictTypeController extends BaseController |
38 | 37 | |
39 | 38 | @RequiresPermissions("system:dict:view") |
40 | 39 | @GetMapping() |
41 | - public String dictType() | |
42 | - { | |
40 | + public String dictType() { | |
43 | 41 | return prefix + "/type"; |
44 | 42 | } |
45 | 43 | |
... | ... | @@ -47,8 +45,7 @@ public class DictTypeController extends BaseController |
47 | 45 | @RequiresPermissions("system:dict:list") |
48 | 46 | @Log(title = "系统管理-字典类型", operating = "查看字典类型", action = BusinessType.GRANT) |
49 | 47 | @ResponseBody |
50 | - public TableDataInfo list(DictType dictType) | |
51 | - { | |
48 | + public TableDataInfo list(DictType dictType) { | |
52 | 49 | startPage(); |
53 | 50 | List<DictType> list = dictTypeService.selectDictTypeList(dictType); |
54 | 51 | return getDataTable(list); |
... | ... | @@ -58,16 +55,12 @@ public class DictTypeController extends BaseController |
58 | 55 | @RequiresPermissions("system:dict:export") |
59 | 56 | @PostMapping("/export") |
60 | 57 | @ResponseBody |
61 | - public AjaxResult export(DictType dictType) throws Exception | |
62 | - { | |
63 | - try | |
64 | - { | |
58 | + public AjaxResult export(DictType dictType) throws Exception { | |
59 | + try { | |
65 | 60 | List<DictType> list = dictTypeService.selectDictTypeList(dictType); |
66 | 61 | ExcelUtil<DictType> util = new ExcelUtil<DictType>(DictType.class); |
67 | 62 | return util.exportExcel(list, "dictType"); |
68 | - } | |
69 | - catch (Exception e) | |
70 | - { | |
63 | + } catch (Exception e) { | |
71 | 64 | return error("导出Excel失败,请联系网站管理员!"); |
72 | 65 | } |
73 | 66 | } |
... | ... | @@ -76,8 +69,7 @@ public class DictTypeController extends BaseController |
76 | 69 | * 新增字典类型 |
77 | 70 | */ |
78 | 71 | @GetMapping("/add") |
79 | - public String add() | |
80 | - { | |
72 | + public String add() { | |
81 | 73 | return prefix + "/add"; |
82 | 74 | } |
83 | 75 | |
... | ... | @@ -88,8 +80,7 @@ public class DictTypeController extends BaseController |
88 | 80 | @RequiresPermissions("system:dict:add") |
89 | 81 | @PostMapping("/add") |
90 | 82 | @ResponseBody |
91 | - public AjaxResult addSave(DictType dict) | |
92 | - { | |
83 | + public AjaxResult addSave(DictType dict) { | |
93 | 84 | Integer result = dictTypeService.insertDictType(dict); |
94 | 85 | DictService.dictDataList = null; |
95 | 86 | return toAjax(result); |
... | ... | @@ -99,8 +90,7 @@ public class DictTypeController extends BaseController |
99 | 90 | * 修改字典类型 |
100 | 91 | */ |
101 | 92 | @GetMapping("/edit/{id}") |
102 | - public String edit(@PathVariable("id") Integer id, ModelMap mmap) | |
103 | - { | |
93 | + public String edit(@PathVariable("id") Integer id, ModelMap mmap) { | |
104 | 94 | mmap.put("dict", dictTypeService.selectDictTypeById(id)); |
105 | 95 | return prefix + "/edit"; |
106 | 96 | } |
... | ... | @@ -112,8 +102,7 @@ public class DictTypeController extends BaseController |
112 | 102 | @RequiresPermissions("system:dict:edit") |
113 | 103 | @PostMapping("/edit") |
114 | 104 | @ResponseBody |
115 | - public AjaxResult editSave(DictType dict) | |
116 | - { | |
105 | + public AjaxResult editSave(DictType dict) { | |
117 | 106 | return toAjax(dictTypeService.updateDictType(dict)); |
118 | 107 | } |
119 | 108 | |
... | ... | @@ -121,14 +110,10 @@ public class DictTypeController extends BaseController |
121 | 110 | @RequiresPermissions("system:dict:remove") |
122 | 111 | @PostMapping("/remove") |
123 | 112 | @ResponseBody |
124 | - public AjaxResult remove(String ids) | |
125 | - { | |
126 | - try | |
127 | - { | |
113 | + public AjaxResult remove(String ids) { | |
114 | + try { | |
128 | 115 | return toAjax(dictTypeService.deleteDictTypeByIds(ids)); |
129 | - } | |
130 | - catch (Exception e) | |
131 | - { | |
116 | + } catch (Exception e) { | |
132 | 117 | return error(e.getMessage()); |
133 | 118 | } |
134 | 119 | } |
... | ... | @@ -139,8 +124,7 @@ public class DictTypeController extends BaseController |
139 | 124 | @RequiresPermissions("system:dict:list") |
140 | 125 | @Log(title = "系统管理-字典类型", operating = "查看字典类型详细数据", action = BusinessType.GRANT) |
141 | 126 | @GetMapping("/detail/{id}") |
142 | - public String detail(@PathVariable("id") Integer id, ModelMap mmap) | |
143 | - { | |
127 | + public String detail(@PathVariable("id") Integer id, ModelMap mmap) { | |
144 | 128 | mmap.put("dict", dictTypeService.selectDictTypeById(id)); |
145 | 129 | mmap.put("dictList", dictTypeService.selectDictTypeAll()); |
146 | 130 | return "system/dict/data/data"; |
... | ... | @@ -151,13 +135,11 @@ public class DictTypeController extends BaseController |
151 | 135 | */ |
152 | 136 | @PostMapping("/checkDictTypeUnique") |
153 | 137 | @ResponseBody |
154 | - public String checkDictTypeUnique(DictType dictType) | |
155 | - { | |
138 | + public Integer checkDictTypeUnique(DictType dictType) { | |
156 | 139 | String uniqueFlag = "0"; |
157 | - if (StringUtils.isNotNull(dictType)) | |
158 | - { | |
140 | + if (StringUtils.isNotNull(dictType)) { | |
159 | 141 | uniqueFlag = dictTypeService.checkDictTypeUnique(dictType); |
160 | 142 | } |
161 | - return uniqueFlag; | |
143 | + return Integer.valueOf(uniqueFlag); | |
162 | 144 | } |
163 | 145 | } |
... | ... |
src/main/java/com/huaheng/pc/system/user/controller/CaptchaController.java deleted
1 | -package com.huaheng.pc.system.user.controller; | |
2 | - | |
3 | -import java.awt.image.BufferedImage; | |
4 | -import java.io.IOException; | |
5 | -import javax.annotation.Resource; | |
6 | -import javax.imageio.ImageIO; | |
7 | -import javax.servlet.ServletOutputStream; | |
8 | -import javax.servlet.http.HttpServletRequest; | |
9 | -import javax.servlet.http.HttpServletResponse; | |
10 | -import javax.servlet.http.HttpSession; | |
11 | -import org.springframework.stereotype.Controller; | |
12 | -import org.springframework.web.bind.annotation.GetMapping; | |
13 | -import org.springframework.web.bind.annotation.RequestMapping; | |
14 | -import org.springframework.web.servlet.ModelAndView; | |
15 | -import com.google.code.kaptcha.Constants; | |
16 | -import com.google.code.kaptcha.Producer; | |
17 | -import com.huaheng.framework.web.controller.BaseController; | |
18 | - | |
19 | -/** | |
20 | - * 图片验证码(支持算术形式) | |
21 | - * | |
22 | - * @author huaheng | |
23 | - */ | |
24 | -@Controller | |
25 | -@RequestMapping("/captcha") | |
26 | -public class CaptchaController extends BaseController | |
27 | -{ | |
28 | - | |
29 | - @Resource(name = "captchaProducer") | |
30 | - private Producer captchaProducer; | |
31 | - | |
32 | - @Resource(name = "captchaProducerMath") | |
33 | - private Producer captchaProducerMath; | |
34 | - | |
35 | - /** | |
36 | - * 验证码生成 | |
37 | - */ | |
38 | - @GetMapping(value = "/captchaImage") | |
39 | - public ModelAndView getKaptchaImage(HttpServletRequest request, HttpServletResponse response) | |
40 | - { | |
41 | - ServletOutputStream out = null; | |
42 | - try | |
43 | - { | |
44 | - HttpSession session = request.getSession(); | |
45 | - response.setDateHeader("Expires", 0); | |
46 | - response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); | |
47 | - response.addHeader("Cache-Control", "post-check=0, pre-check=0"); | |
48 | - response.setHeader("Pragma", "no-cache"); | |
49 | - response.setContentType("image/jpeg"); | |
50 | - | |
51 | - String type = request.getParameter("type"); | |
52 | - String capStr = null; | |
53 | - String code = null; | |
54 | - BufferedImage bi = null; | |
55 | - if ("math".equals(type)) | |
56 | - { | |
57 | - String capText = captchaProducerMath.createText(); | |
58 | - capStr = capText.substring(0, capText.lastIndexOf("@")); | |
59 | - code = capText.substring(capText.lastIndexOf("@") + 1); | |
60 | - bi = captchaProducerMath.createImage(capStr); | |
61 | - } | |
62 | - else if ("char".equals(type)) | |
63 | - { | |
64 | - capStr = code = captchaProducer.createText(); | |
65 | - bi = captchaProducer.createImage(capStr); | |
66 | - } | |
67 | - session.setAttribute(Constants.KAPTCHA_SESSION_KEY, code); | |
68 | - out = response.getOutputStream(); | |
69 | - ImageIO.write(bi, "jpg", out); | |
70 | - out.flush(); | |
71 | - | |
72 | - } | |
73 | - catch (Exception e) | |
74 | - { | |
75 | - e.printStackTrace(); | |
76 | - } | |
77 | - finally | |
78 | - { | |
79 | - try | |
80 | - { | |
81 | - if (out != null) | |
82 | - { | |
83 | - out.close(); | |
84 | - } | |
85 | - } | |
86 | - catch (IOException e) | |
87 | - { | |
88 | - e.printStackTrace(); | |
89 | - } | |
90 | - } | |
91 | - return null; | |
92 | - } | |
93 | -} | |
94 | 0 | \ No newline at end of file |
src/main/java/com/huaheng/pc/system/user/mapper/UserMapper.java
... | ... | @@ -119,6 +119,14 @@ public interface UserMapper |
119 | 119 | public User checkEmailUnique(String email); |
120 | 120 | |
121 | 121 | /** |
122 | + * 检查用户是否拥有该仓库权限 | |
123 | + * @param warehouseCode 仓库code | |
124 | + * @param username 登录名 | |
125 | + * @return | |
126 | + */ | |
127 | + List<Map<String, Object>> checkWarehouseCodeAndUserName(@Param("warehouseCode") String warehouseCode, @Param("loginName") String username); | |
128 | + | |
129 | + /** | |
122 | 130 | * 根据用户id查询该用户所有仓库 |
123 | 131 | * @param userId |
124 | 132 | * @return |
... | ... |
src/main/java/com/huaheng/pc/system/user/service/IUserService.java
... | ... | @@ -200,6 +200,8 @@ public interface IUserService |
200 | 200 | public User selectmen(String loginName); |
201 | 201 | |
202 | 202 | public int batchUserWarehouse(@Param("userWarehouseList") List<SysUserWarehouse> userWarehouseList); |
203 | + | |
204 | + boolean checkWarehouseCodeAndUserName(String warehouseCode, String username); | |
203 | 205 | } |
204 | 206 | |
205 | 207 | |
... | ... |
src/main/java/com/huaheng/pc/system/user/service/UserServiceImpl.java
... | ... | @@ -594,4 +594,9 @@ public class UserServiceImpl implements IUserService |
594 | 594 | return sysUserWarehouseMapper.batchUserWarehouse(userWarehouseList); |
595 | 595 | } |
596 | 596 | |
597 | + @Override | |
598 | + public boolean checkWarehouseCodeAndUserName(String warehouseCode, String username) { | |
599 | + return !userMapper.checkWarehouseCodeAndUserName(warehouseCode, username).isEmpty(); | |
600 | + } | |
601 | + | |
597 | 602 | } |
... | ... |
src/main/java/com/huaheng/pc/task/taskHeader/controller/TaskHeaderController.java
... | ... | @@ -163,4 +163,14 @@ public class TaskHeaderController extends BaseController { |
163 | 163 | return taskHeaderService.setLocationCode(taskId, high); |
164 | 164 | } |
165 | 165 | |
166 | + @Log(title = "库位监控-出库查看", operating = "出库查看", action = BusinessType.GRANT) | |
167 | + @PostMapping("/checkLocationCode") | |
168 | + @ResponseBody | |
169 | + public AjaxResult checkLocationCode (String locationCode){ | |
170 | + if(StringUtils.isEmpty(locationCode)){ | |
171 | + return AjaxResult.error("库位不能为空!"); | |
172 | + } | |
173 | + return taskHeaderService.checkLocationCode(locationCode); | |
174 | + } | |
175 | + | |
166 | 176 | } |
... | ... |
src/main/java/com/huaheng/pc/task/taskHeader/service/CreateTaskMessage.java
0 → 100644
1 | +package com.huaheng.pc.task.taskHeader.service; | |
2 | + | |
3 | +import com.alibaba.fastjson.JSON; | |
4 | +import com.fasterxml.jackson.annotation.JsonFormat; | |
5 | +import com.huaheng.common.constant.Constants; | |
6 | +import com.huaheng.common.exception.BusinessException; | |
7 | +import com.huaheng.common.exception.service.ServiceException; | |
8 | +import com.huaheng.common.utils.DateUtils; | |
9 | +import com.huaheng.pc.monitor.message.domain.Messages; | |
10 | +import com.huaheng.pc.monitor.message.service.MessagesService; | |
11 | +import com.huaheng.pc.task.taskHeader.domain.TaskHeader; | |
12 | +import org.springframework.stereotype.Service; | |
13 | + | |
14 | +import javax.annotation.Resource; | |
15 | +import java.util.Date; | |
16 | + | |
17 | +/** | |
18 | + * Created by Enzo Cotter on 2020/4/20. | |
19 | + */ | |
20 | +@Service | |
21 | +public class CreateTaskMessage { | |
22 | + | |
23 | + @Resource | |
24 | + private MessagesService messagesService; | |
25 | + @Resource | |
26 | + private RabbitTaskSender rabbitTaskSender; | |
27 | + | |
28 | + public void createTask(TaskHeader taskHeader) throws Exception { | |
29 | + Messages messages = new Messages(); | |
30 | + messages.setMsgType("任务"); | |
31 | + messages.setMsgSubType(String.valueOf(taskHeader.getTaskType())); | |
32 | + messages.setMsgFrom("WMS"); | |
33 | + messages.setMsgTo("WCS"); | |
34 | + messages.setMsgSubject(""); | |
35 | + messages.setMsgBody(JSON.toJSONString(taskHeader)); | |
36 | + messages.setEnable(Constants.SEND_SUCCESS); | |
37 | + messages.setTryCount(0); | |
38 | + messages.setCreated(new Date()); | |
39 | + messages.setCreatedBy(taskHeader.getCreatedBy());; | |
40 | + messages.setQueue("task"); | |
41 | + messages.setRoutingKey("task.Issued"); | |
42 | + messages.setNextRetry(DateUtils.addMinutes(messages.getCreated(), Constants.ORDER_TIMEOUT)); | |
43 | + messages.setUpdateTime(new Date()); | |
44 | + if (messagesService.save(messages)) { | |
45 | + rabbitTaskSender.sendTask(messages); | |
46 | + } else { | |
47 | + throw new ServiceException("消息发送失败"); | |
48 | + } | |
49 | + } | |
50 | +} | |
... | ... |
src/main/java/com/huaheng/pc/task/taskHeader/service/RabbitTaskSender.java
0 → 100644
1 | +package com.huaheng.pc.task.taskHeader.service; | |
2 | + | |
3 | +import com.huaheng.common.constant.Constants; | |
4 | +import com.huaheng.pc.monitor.message.domain.Messages; | |
5 | +import com.huaheng.pc.monitor.message.service.BrokerMessageLogService; | |
6 | +import com.huaheng.pc.task.taskHeader.domain.TaskHeader; | |
7 | +import org.springframework.amqp.rabbit.connection.CorrelationData; | |
8 | +import org.springframework.amqp.rabbit.core.RabbitTemplate; | |
9 | +import org.springframework.stereotype.Component; | |
10 | +import org.springframework.amqp.rabbit.core.RabbitTemplate.ConfirmCallback; | |
11 | +import javax.annotation.Resource; | |
12 | +import java.util.Date; | |
13 | + | |
14 | +/** | |
15 | + * Created by Enzo Cotter on 2020/4/16. | |
16 | + */ | |
17 | +@Component | |
18 | +public class RabbitTaskSender { | |
19 | + | |
20 | + //自动注入RabbitTemplate模板类 | |
21 | + @Resource | |
22 | + private RabbitTemplate rabbitTemplate; | |
23 | + | |
24 | + @Resource | |
25 | + private BrokerMessageLogService brokerMessageLogService; | |
26 | + | |
27 | + //回调函数: confirm确认 | |
28 | + final ConfirmCallback confirmCallback = new RabbitTemplate.ConfirmCallback() { | |
29 | + @Override | |
30 | + public void confirm(CorrelationData correlationData, boolean ack, String cause) { | |
31 | + System.err.println("correlationData: " + correlationData); | |
32 | + String messageId = correlationData.getId(); | |
33 | + if(ack){ | |
34 | + //如果confirm返回成功 则进行更新 | |
35 | + brokerMessageLogService.changeBrokerMessageLogStatus(messageId, Constants.SEND_SUCCESS, new Date()); | |
36 | + } else { | |
37 | + //失败则进行具体的后续操作:重试 或者补偿等手段 | |
38 | + System.err.println("异常处理..."); | |
39 | + } | |
40 | + } | |
41 | + }; | |
42 | + | |
43 | + //发送消息方法调用: 构建自定义对象消息 | |
44 | + public void sendTask(Messages messages) { | |
45 | + rabbitTemplate.setConfirmCallback(confirmCallback); | |
46 | + //消息唯一ID | |
47 | + CorrelationData correlationData = new CorrelationData(String.valueOf(messages.getId())); | |
48 | + rabbitTemplate.convertAndSend("wms_exchange", "task.Issued", messages.getMsgBody(), correlationData); | |
49 | + } | |
50 | +} | |
... | ... |
src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderService.java
src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderServiceImpl.java
... | ... | @@ -32,6 +32,7 @@ import com.huaheng.pc.inventory.inventoryHeader.domain.InventoryHeader; |
32 | 32 | import com.huaheng.pc.inventory.inventoryHeader.service.InventoryHeaderService; |
33 | 33 | import com.huaheng.pc.inventory.inventoryTransaction.domain.InventoryTransaction; |
34 | 34 | import com.huaheng.pc.inventory.inventoryTransaction.service.InventoryTransactionService; |
35 | +import com.huaheng.pc.monitor.message.service.BrokerMessageLogService; | |
35 | 36 | import com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail; |
36 | 37 | import com.huaheng.pc.receipt.receiptContainerDetail.service.ReceiptContainerDetailService; |
37 | 38 | import com.huaheng.pc.receipt.receiptContainerHeader.domain.ReceiptContainerHeader; |
... | ... | @@ -112,12 +113,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
112 | 113 | @Resource |
113 | 114 | private ConfigWarningService configWarningService; |
114 | 115 | @Resource |
115 | - private MailService mailService; | |
116 | - @Resource | |
117 | - private SendMailService sendMailService; | |
118 | - @Resource | |
119 | 116 | private ReceivingService receivingService; |
120 | 117 | |
118 | + @Resource | |
119 | + private CreateTaskMessage createTaskMessage; | |
120 | + | |
121 | 121 | /** |
122 | 122 | * 盘点任务首选项 |
123 | 123 | * |
... | ... | @@ -317,6 +317,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
317 | 317 | //更新托盘、库位状态 |
318 | 318 | locationService.updateStatus(taskHeader.getToLocation(), "empty"); |
319 | 319 | } |
320 | + Container container = new Container(); | |
321 | + container.setStatus("empty"); | |
322 | + LambdaUpdateWrapper<Container> containerUpdateWrapper = Wrappers.lambdaUpdate(); | |
323 | + containerUpdateWrapper.eq(Container::getCode, taskHeader.getContainerCode()); | |
324 | + containerService.update(container, containerUpdateWrapper); | |
320 | 325 | } |
321 | 326 | // if(task.getType()==900){ |
322 | 327 | // //出库查看任务没有关联的货箱,不做处理 |
... | ... | @@ -546,7 +551,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
546 | 551 | return AjaxResult.error("任务" + taskId + "已经下发,请不要重复下发,操作中止"); |
547 | 552 | } |
548 | 553 | // 给wcs传递任务 |
549 | - taskAssignService.wcsTaskAssign(task); | |
554 | + try { | |
555 | + createTaskMessage.createTask(task); | |
556 | + } catch (Exception e) { | |
557 | + e.printStackTrace(); | |
558 | + } | |
550 | 559 | |
551 | 560 | //修改任务头表 |
552 | 561 | task.setId(taskId); |
... | ... | @@ -713,7 +722,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
713 | 722 | LambdaQueryWrapper<InventoryDetail> inventory = Wrappers.lambdaQuery(); |
714 | 723 | inventory.eq(InventoryDetail::getWarehouseCode, ShiroUtils.getWarehouseCode()) |
715 | 724 | .eq(InventoryDetail::getLocationCode, task.getFromLocation()) |
716 | - .eq(InventoryDetail::getReceiptDetailId, DataUtils.getString(map.get("receiptDetailId"))) | |
725 | +// .eq(InventoryDetail::getReceiptDetailId, DataUtils.getString(map.get("receiptDetailId"))) | |
717 | 726 | .eq(InventoryDetail::getContainerCode, DataUtils.getString(map.get("containerCode"))); |
718 | 727 | InventoryDetail detail = inventoryDetailService.getOne(inventory); |
719 | 728 | if (detail == null) { |
... | ... | @@ -1204,6 +1213,52 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1204 | 1213 | return AjaxResult.success("出库查看任务生成成功!"); |
1205 | 1214 | } |
1206 | 1215 | |
1216 | + /**库存监控出库查看*/ | |
1217 | + @Override | |
1218 | + @Transactional | |
1219 | + public AjaxResult checkLocationCode(String locationCode){ | |
1220 | + | |
1221 | + Location location = new Location(); | |
1222 | + location.setCode(locationCode); | |
1223 | + location.setWarehouseCode(ShiroUtils.getWarehouseCode()); | |
1224 | + location.setDeleted(false); | |
1225 | + LambdaQueryWrapper<Location> lambdaQueryWrapper = Wrappers.lambdaQuery(location); | |
1226 | + Location loc = locationService.getOne(lambdaQueryWrapper); | |
1227 | + if(!loc.getStatus().equals("empty")){ | |
1228 | + return AjaxResult.error(locationCode+"状态非空闲,操作失败"); | |
1229 | + } | |
1230 | + if(StringUtils.isEmpty(loc.getContainerCode())){ | |
1231 | + return AjaxResult.error(locationCode+"没有托盘,操作失败"); | |
1232 | + } | |
1233 | + //生成出库查看任务 | |
1234 | + TaskHeader task = new TaskHeader(); | |
1235 | + task.setWarehouseCode(ShiroUtils.getWarehouseCode()); | |
1236 | + task.setCompanyCode(ShiroUtils.getCompanyCodeList().get(0)); | |
1237 | + //这里默认一个0 | |
1238 | + task.setTaskType(900); | |
1239 | +// task.setStation(1); | |
1240 | +// task.setPort(1003); | |
1241 | +// if(loc.getType().equals("L")){ | |
1242 | +// task.setZoneCode("LK"); | |
1243 | +// } | |
1244 | +// task.setRoadway(loc.getRoadway()); | |
1245 | +// task.setContainerCode(loc.getContainerCode()); | |
1246 | +// task.setFirstStatus((short)1); | |
1247 | +// task.setLastStatus((short)1); | |
1248 | +// task.setSourceLocation(loc.getCode()); | |
1249 | +// task.setDestinationLocation(loc.getCode()); | |
1250 | +// task.setCreated(new Date()); | |
1251 | +// task.setCreatedBy(ShiroUtils.getLoginName()); | |
1252 | +// task.setBeginTime(new Date()); | |
1253 | +// insert(task); | |
1254 | +// //出库时先锁库位状态 | |
1255 | +// loc.setStatus("lock"); | |
1256 | +// locationService.updateByModel(loc); | |
1257 | + | |
1258 | + return AjaxResult.success(task.getId()); | |
1259 | + | |
1260 | + } | |
1261 | + | |
1207 | 1262 | /** |
1208 | 1263 | * 完成 |
1209 | 1264 | * 出库查看 |
... | ... |
src/main/resources/application-druid.properties
1 | -#数据源配置 | |
1 | +#锟斤拷锟斤拷源锟斤拷锟斤拷 | |
2 | 2 | spring.datasource.type=com.alibaba.druid.pool.DruidDataSource |
3 | 3 | spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver |
4 | -# 主库 | |
5 | -spring.datasource.druid.master.url=jdbc:mysql://172.16.29.45:3306/wms_v2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2b8 | |
6 | -#spring.datasource.druid.master.url=jdbc:mysql://39.100.243.49:3306/huahengExample?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false | |
7 | -#spring.datasource.druid.master.url=jdbc:mysql://localhost:3306/wms2.0?characterEncoding=utf8&serverTimezone=GMT%2b8 | |
4 | +# 锟斤拷锟斤拷 | |
5 | +#spring.datasource.druid.master.url=jdbc:mysql://172.16.29.45:3306/wms_v2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2b8 | |
6 | +#spring.datasource.druid.master.url=jdbc:mysql://172.16.29.45:3306/huahengExample?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false | |
7 | +spring.datasource.druid.master.url=jdbc:mysql://localhost:3306/wms_v2?characterEncoding=utf8&serverTimezone=GMT%2b8 | |
8 | 8 | |
9 | -spring.datasource.druid.master.username=softhuaheng | |
10 | -spring.datasource.druid.master.password=HHrobot123. | |
11 | -#spring.datasource.druid.master.username=user | |
12 | -#spring.datasource.druid.master.password=R6c3#rYyQ@e% | |
13 | -# 从库 | |
14 | -spring.datasource.druid.slave.open = true | |
9 | +#spring.datasource.druid.master.username=softhuaheng | |
10 | +#spring.datasource.druid.master.password=HHrobot123. | |
11 | +spring.datasource.druid.master.username=root | |
12 | +spring.datasource.druid.master.password=123456 | |
13 | +# 锟接匡拷 | |
14 | +spring.datasource.druid.slave.open = false | |
15 | 15 | spring.datasource.druid.slave.url=jdbc:mysql://199.19.109.117:3306/wms_v2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false |
16 | 16 | #spring.datasource.druid.master.username=softhuaheng |
17 | 17 | #spring.datasource.druid.master.password=HHrobot123. |
18 | -# 初始连接数 | |
18 | +# 锟斤拷始锟斤拷锟斤拷锟斤拷 | |
19 | 19 | spring.datasource.druid.initial-size=4 |
20 | -# 最大连接池数量 | |
20 | +# 锟斤拷锟斤拷锟斤拷映锟斤拷锟斤拷锟 | |
21 | 21 | spring.datasource.druid.max-active=10 |
22 | -# 最小连接池数量 | |
22 | +# 锟斤拷小锟斤拷锟接筹拷锟斤拷锟斤拷 | |
23 | 23 | spring.datasource.druid.min-idle=4 |
24 | -# 配置获取连接等待超时的时间 | |
24 | +# 锟斤拷锟矫伙拷取锟斤拷锟接等达拷锟斤拷时锟斤拷时锟斤拷 | |
25 | 25 | spring.datasource.druid.max-wait=60000 |
26 | -# 打开PSCache,并且指定每个连接上PSCache的大小 | |
26 | +# 锟斤拷PSCache锟斤拷锟斤拷锟斤拷指锟斤拷每锟斤拷锟斤拷锟斤拷锟斤拷PSCache锟侥达拷小 | |
27 | 27 | spring.datasource.druid.pool-prepared-statements=true |
28 | 28 | spring.datasource.druid.max-pool-prepared-statement-per-connection-size=20 |
29 | -# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 | |
29 | +# 锟斤拷锟矫硷拷锟斤拷锟矫才斤拷锟斤拷一锟轿硷拷猓拷锟斤拷锟斤拷要锟截闭的匡拷锟斤拷锟斤拷锟接o拷锟斤拷位锟角猴拷锟斤拷 | |
30 | 30 | spring.datasource.druid.timeBetweenEvictionRunsMillis=60000 |
31 | -# 配置一个连接在池中最小生存的时间,单位是毫秒 | |
31 | +# 锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟节筹拷锟斤拷锟斤拷小锟斤拷锟斤拷锟绞憋拷洌拷锟轿伙拷呛锟斤拷锟 | |
32 | 32 | spring.datasource.druid.min-evictable-idle-time-millis=300000 |
33 | 33 | spring.datasource.druid.validation-query=SELECT 1 FROM DUAL |
34 | 34 | spring.datasource.druid.test-while-idle=true |
... | ... | @@ -42,10 +42,10 @@ spring.datasource.druid.filter.stat.merge-sql=false |
42 | 42 | spring.datasource.druid.filter.wall.config.multi-statement-allow=true |
43 | 43 | |
44 | 44 | |
45 | -#日志配置 | |
45 | +#锟斤拷志锟斤拷锟斤拷 | |
46 | 46 | logging.level.com.huaheng=debug |
47 | 47 | logging.level.org.springframework=warn |
48 | 48 | logging.level.spring.springboot.dao=DEBUG |
49 | 49 | |
50 | -#测试服务端口、测试项目contextPath | |
50 | +#锟斤拷锟皆凤拷锟斤拷丝凇锟斤拷锟斤拷锟斤拷锟侥縞ontextPath | |
51 | 51 | |
... | ... |
src/main/resources/application-prd.yml
... | ... | @@ -6,7 +6,7 @@ spring: |
6 | 6 | druid: |
7 | 7 | # 主库 |
8 | 8 | master: |
9 | - url: jdbc:mysql://localhost:3306/wms_v2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2b8&allowPublicKeyRetrieval=true | |
9 | + url: jdbc:mysql://localhost:3306/xinyi_wms?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2b8&allowPublicKeyRetrieval=true | |
10 | 10 | username: root |
11 | 11 | password: 123456 |
12 | 12 | # 从库 |
... | ... | @@ -55,7 +55,23 @@ spring: |
55 | 55 | wall: |
56 | 56 | config: |
57 | 57 | multi-statement-allow: true |
58 | - | |
58 | + rabbitmq: | |
59 | + #地址 | |
60 | + addresses: 172.16.29.47:5672 | |
61 | + #用户名 | |
62 | + username: huaheng | |
63 | + #密码 | |
64 | + password: huahengsoft | |
65 | + #虚拟主机 | |
66 | + virtual-host: / | |
67 | + #连接超时时间 | |
68 | + connection-timeout: 15000 | |
69 | + #消息发送确认 | |
70 | + publisher-confirms: true | |
71 | + publisher-returns: true | |
72 | + template: | |
73 | + #启用强制信息 | |
74 | + mandatory: true | |
59 | 75 | #日志配置 |
60 | 76 | logging: |
61 | 77 | level: |
... | ... |
src/main/resources/application.yml
1 | 1 | spring: |
2 | 2 | profiles: |
3 | - active: dev | |
3 | + active: druid | |
4 | 4 | --- |
5 | 5 | #项目相关配置 |
6 | 6 | #名称 |
... | ... | @@ -84,6 +84,26 @@ spring: |
84 | 84 | password: owobzjvlgsxrbdfe |
85 | 85 | # 编码类型 |
86 | 86 | default-encoding: utf-8 |
87 | + # redis 配置 | |
88 | + redis: | |
89 | + # 地址 | |
90 | + host: localhost | |
91 | + # 端口,默认为6379 | |
92 | + port: 6379 | |
93 | + # 密码 | |
94 | + password: | |
95 | + # 连接超时时间 | |
96 | + timeout: 10s | |
97 | + lettuce: | |
98 | + pool: | |
99 | + # 连接池中的最小空闲连接 | |
100 | + min-idle: 0 | |
101 | + # 连接池中的最大空闲连接 | |
102 | + max-idle: 8 | |
103 | + # 连接池的最大数据库连接数 | |
104 | + max-active: 8 | |
105 | + # #连接池最大阻塞等待时间(使用负值表示没有限制) | |
106 | + max-wait: -1ms | |
87 | 107 | |
88 | 108 | mybatis-plus: |
89 | 109 | mapper-locations: classpath:mybatis/**/*.xml |
... | ... |
src/main/resources/mybatis/config/StationMapper.xml
... | ... | @@ -5,6 +5,7 @@ |
5 | 5 | <!--@mbg.generated--> |
6 | 6 | <!--@Table station--> |
7 | 7 | <id column="id" jdbcType="INTEGER" property="id" /> |
8 | + <result column="name" jdbcType="VARCHAR" property="name" /> | |
8 | 9 | <result column="code" jdbcType="VARCHAR" property="code" /> |
9 | 10 | <result column="status" jdbcType="INTEGER" property="status" /> |
10 | 11 | <result column="code" jdbcType="VARCHAR" property="code" /> |
... | ... | @@ -16,6 +17,6 @@ |
16 | 17 | </resultMap> |
17 | 18 | <sql id="Base_Column_List"> |
18 | 19 | <!--@mbg.generated--> |
19 | - id, code, `status`, type, warehouseCode, created, createdBy, lastUpdated, lastUpdatedBy | |
20 | + id, `name`, code, `status`, type, warehouseCode, created, createdBy, lastUpdated, lastUpdatedBy | |
20 | 21 | </sql> |
21 | 22 | </mapper> |
22 | 23 | \ No newline at end of file |
... | ... |
src/main/resources/mybatis/monitor/MessagesMapper.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
3 | +<mapper namespace="com.huaheng.pc.monitor.message.mapper.MessagesMapper"> | |
4 | + <resultMap id="BaseResultMap" type="com.huaheng.pc.monitor.message.domain.Messages"> | |
5 | + <!--@mbg.generated--> | |
6 | + <!--@Table messages--> | |
7 | + <id column="id" jdbcType="BIGINT" property="id" /> | |
8 | + <result column="msgType" jdbcType="VARCHAR" property="msgType" /> | |
9 | + <result column="msgSubType" jdbcType="VARCHAR" property="msgSubType" /> | |
10 | + <result column="msgFrom" jdbcType="VARCHAR" property="msgFrom" /> | |
11 | + <result column="msgTo" jdbcType="VARCHAR" property="msgTo" /> | |
12 | + <result column="msgSubject" jdbcType="VARCHAR" property="msgSubject" /> | |
13 | + <result column="msgBody" jdbcType="LONGVARCHAR" property="msgBody" /> | |
14 | + <result column="enable" jdbcType="INTEGER" property="enable" /> | |
15 | + <result column="tryCount" jdbcType="INTEGER" property="tryCount" /> | |
16 | + <result column="created" jdbcType="TIMESTAMP" property="created" /> | |
17 | + <result column="createdBy" jdbcType="VARCHAR" property="createdBy" /> | |
18 | + <result column="sess" jdbcType="VARCHAR" property="sess" /> | |
19 | + <result column="params" jdbcType="VARCHAR" property="params" /> | |
20 | + <result column="errorCode" jdbcType="VARCHAR" property="errorCode" /> | |
21 | + <result column="queue" jdbcType="VARCHAR" property="queue" /> | |
22 | + <result column="routingKey" jdbcType="VARCHAR" property="routingKey" /> | |
23 | + </resultMap> | |
24 | + <sql id="Base_Column_List"> | |
25 | + <!--@mbg.generated--> | |
26 | + id, msgType, msgSubType, msgFrom, msgTo, msgSubject, msgBody, `enable`, tryCount, | |
27 | + created, createdBy, sess, params, errorCode, queue, routingKey | |
28 | + </sql> | |
29 | +</mapper> | |
0 | 30 | \ No newline at end of file |
... | ... |
src/main/resources/mybatis/shipment/ShipmentDetailMapper.xml
... | ... | @@ -57,7 +57,7 @@ |
57 | 57 | |
58 | 58 | |
59 | 59 | <select id="SelectFirstStatus" resultType="java.util.Map"> |
60 | - SELECT h.id, h.firstStatus, h.status | |
60 | + SELECT h.id, h.firstStatus, h.lastStatus | |
61 | 61 | FROM shipment_header h |
62 | 62 | INNER JOIN shipment_detail d ON h.id = d.shipmentId AND d.id IN (#{ids}) |
63 | 63 | GROUP BY h.id,h.firstStatus |
... | ... |
src/main/resources/mybatis/system/UserMapper.xml
... | ... | @@ -203,5 +203,12 @@ |
203 | 203 | <update id="insertupdateTime" > |
204 | 204 | update sys_user set updateTime = #{date} where loginName = #{cPersonCode} |
205 | 205 | </update> |
206 | + <select id="checkWarehouseCodeAndUserName" resultType="java.util.Map"> | |
207 | + SELECT r.`name`, r.code | |
208 | + FROM sys_user u | |
209 | + LEFT JOIN sys_user_warehouse ur ON u.id = ur.userId | |
210 | + LEFT JOIN warehouse r ON ur.warehouseCode = r.code | |
211 | + WHERE u.loginName=#{loginName,jdbcType=VARCHAR} AND r.`code` =#{warehouseCode,jdbcType=VARCHAR} | |
212 | + </select> | |
206 | 213 | |
207 | 214 | </mapper> |
208 | 215 | \ No newline at end of file |
... | ... |
src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.css
1 | -.fixed-table-container .bs-checkbox, .fixed-table-container .no-records-found { | |
2 | - text-align: center; | |
3 | -} | |
4 | - | |
5 | -.fixed-table-body thead th .th-inner, .table td, .table th { | |
6 | - box-sizing: border-box | |
7 | -} | |
8 | - | |
9 | -.bootstrap-table .table { | |
10 | - margin-bottom: 0 !important; | |
11 | - border-bottom: 1px solid #ddd; | |
12 | - border-collapse: collapse !important; | |
13 | - border-radius: 1px | |
14 | -} | |
15 | - | |
16 | -.bootstrap-table .table:not(.table-condensed), .bootstrap-table .table:not(.table-condensed) > tbody > tr > td, .bootstrap-table .table:not(.table-condensed) > tbody > tr > th, .bootstrap-table .table:not(.table-condensed) > tfoot > tr > td, .bootstrap-table .table:not(.table-condensed) > tfoot > tr > th, .bootstrap-table .table:not(.table-condensed) > thead > tr > td { | |
17 | - padding: 8px | |
18 | -} | |
19 | - | |
20 | -.bootstrap-table .table.table-no-bordered > tbody > tr > td, .bootstrap-table .table.table-no-bordered > thead > tr > th { | |
21 | - border-right: 2px solid transparent | |
22 | -} | |
23 | - | |
24 | -.bootstrap-table .table.table-no-bordered > tbody > tr > td:last-child { | |
25 | - border-right: none | |
26 | -} | |
27 | - | |
28 | -.fixed-table-container { | |
29 | - position: relative; | |
30 | - clear: both; | |
31 | - border: 1px solid #ddd; | |
32 | - border-radius: 4px; | |
33 | - white-space: nowrap; | |
34 | - -webkit-border-radius: 4px; | |
35 | - -moz-border-radius: 4px | |
36 | -} | |
37 | - | |
38 | -.fixed-table-container.table-no-bordered { | |
39 | - border: 1px solid transparent | |
40 | -} | |
41 | - | |
42 | -.fixed-table-footer, .fixed-table-header { | |
43 | - overflow: hidden | |
44 | -} | |
45 | - | |
46 | -.fixed-table-footer { | |
47 | - border-top: 1px solid #ddd | |
48 | -} | |
49 | - | |
50 | -.fixed-table-body { | |
51 | - overflow-x: auto; | |
52 | - overflow-y: auto; | |
53 | - height: 100% | |
54 | -} | |
55 | - | |
56 | -.fixed-table-container table { | |
57 | - width: 100% | |
58 | -} | |
59 | - | |
60 | -.fixed-table-container thead th { | |
61 | - height: 0; | |
62 | - padding: 0; | |
63 | - margin: 0; | |
64 | - border-left: 1px solid #ddd | |
65 | -} | |
66 | - | |
67 | -.fixed-table-container thead th:focus { | |
68 | - outline: transparent solid 0 | |
69 | -} | |
70 | - | |
71 | -.fixed-table-container thead th:first-child { | |
72 | - border-left: none; | |
73 | - border-top-left-radius: 4px; | |
74 | - -webkit-border-top-left-radius: 4px; | |
75 | - -moz-border-radius-topleft: 4px | |
76 | -} | |
77 | - | |
78 | -.fixed-table-container tbody td .th-inner, .fixed-table-container thead th .th-inner { | |
79 | - padding: 8px; | |
80 | - line-height: 24px; | |
81 | - vertical-align: top; | |
82 | - overflow: hidden; | |
83 | - text-overflow: ellipsis; | |
84 | - white-space: nowrap | |
85 | -} | |
86 | - | |
87 | -.fixed-table-container thead th .sortable { | |
88 | - cursor: pointer; | |
89 | - background-position: right; | |
90 | - background-repeat: no-repeat; | |
91 | - padding-right: 30px | |
92 | -} | |
93 | - | |
94 | -.fixed-table-container thead th .both { | |
95 | - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAkElEQVQoz7X QMQ5AQBCF4dWQSJxC5wwax1Cq1e7BAdxD5SL+Tq/QCM1oNiJidwox0355mXnG/DrEtIQ6azioNZQxI0ykPhTQIwhCR+BmBYtlK7kLJYwWCcJA9M4qdrZrd8pPjZWPtOqdRQy320YSV17OatFC4euts6z39GYMKRPCTKY9UnPQ6P+GtMRfGtPnBCiqhAeJPmkqAAAAAElFTkSuQmCC') | |
96 | -} | |
97 | - | |
98 | -.fixed-table-container thead th .asc { | |
99 | - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg==) | |
100 | -} | |
101 | - | |
102 | -.fixed-table-container thead th .desc { | |
103 | - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZUlEQVQ4y2NgGAWjYBSggaqGu5FA/BOIv2PBIPFEUgxjB+IdQPwfC94HxLykus4GiD+hGfQOiB3J8SojEE9EM2wuSJzcsFMG4ttQgx4DsRalkZENxL+AuJQaMcsGxBOAmGvopk8AVz1sLZgg0bsAAAAASUVORK5CYII=) | |
104 | -} | |
105 | - | |
106 | -.fixed-table-container th.detail { | |
107 | - width: 30px | |
108 | -} | |
109 | - | |
110 | -.fixed-table-container tbody td { | |
111 | - border-left: 1px solid #ddd | |
112 | -} | |
113 | - | |
114 | -.fixed-table-container tbody tr:first-child td { | |
115 | - border-top: none | |
116 | -} | |
117 | - | |
118 | -.fixed-table-container tbody td:first-child { | |
119 | - border-left: none | |
120 | -} | |
121 | - | |
122 | -.fixed-table-container tbody .selected td { | |
123 | - background-color: #f5f5f5 | |
124 | -} | |
125 | - | |
126 | -.fixed-table-container .bs-checkbox .th-inner { | |
127 | - padding: 8px 0 | |
128 | -} | |
129 | - | |
130 | -.fixed-table-container input[type=radio], .fixed-table-container input[type=checkbox] { | |
131 | - margin: 0 auto !important | |
132 | -} | |
133 | - | |
134 | -.fixed-table-pagination .pagination-detail, .fixed-table-pagination div.pagination { | |
135 | - margin-top: 10px; | |
136 | - margin-bottom: 10px | |
137 | -} | |
138 | - | |
139 | -.fixed-table-pagination div.pagination .pagination { | |
140 | - margin: 0 | |
141 | -} | |
142 | - | |
143 | -.fixed-table-pagination .pagination a { | |
144 | - padding: 6px 12px; | |
145 | - line-height: 1.428571429 | |
146 | -} | |
147 | - | |
148 | -.fixed-table-pagination .pagination-info { | |
149 | - line-height: 34px; | |
150 | - margin-right: 5px | |
151 | -} | |
152 | - | |
153 | -.fixed-table-pagination .btn-group { | |
154 | - position: relative; | |
155 | - display: inline-block; | |
156 | - vertical-align: middle | |
157 | -} | |
158 | - | |
159 | -.fixed-table-pagination .dropup .dropdown-menu { | |
160 | - margin-bottom: 0 | |
161 | -} | |
162 | - | |
163 | -.fixed-table-pagination .page-list { | |
164 | - display: inline-block | |
165 | -} | |
166 | - | |
167 | -.fixed-table-toolbar .columns-left { | |
168 | - margin-right: 5px | |
169 | -} | |
170 | - | |
171 | -.fixed-table-toolbar .columns-right { | |
172 | - margin-left: 5px | |
173 | -} | |
174 | - | |
175 | -.fixed-table-toolbar .columns label { | |
176 | - display: block; | |
177 | - padding: 3px 20px; | |
178 | - clear: both; | |
179 | - font-weight: 400; | |
180 | - line-height: 1.428571429 | |
181 | -} | |
182 | - | |
183 | -.fixed-table-toolbar .bs-bars, .fixed-table-toolbar .columns, .fixed-table-toolbar .search { | |
184 | - position: relative; | |
185 | - margin-top: 10px; | |
186 | - margin-bottom: 10px; | |
187 | - line-height: 34px | |
188 | -} | |
189 | - | |
190 | -.fixed-table-pagination li.disabled a { | |
191 | - pointer-events: none; | |
192 | - cursor: default | |
193 | -} | |
194 | - | |
195 | -.fixed-table-loading { | |
196 | - display: none; | |
197 | - position: absolute; | |
198 | - top: 42px; | |
199 | - right: 0; | |
200 | - bottom: 0; | |
201 | - left: 0; | |
202 | - z-index: 99; | |
203 | - background-color: #fff; | |
204 | - text-align: center | |
205 | -} | |
206 | - | |
207 | -.fixed-table-body .card-view .title { | |
208 | - font-weight: 700; | |
209 | - display: inline-block; | |
210 | - min-width: 30%; | |
211 | - text-align: left !important | |
212 | -} | |
213 | - | |
214 | -.table td, .table th { | |
215 | - vertical-align: middle | |
216 | -} | |
217 | - | |
218 | -.fixed-table-toolbar .dropdown-menu { | |
219 | - text-align: left; | |
220 | - max-height: 300px; | |
221 | - overflow: auto | |
222 | -} | |
223 | - | |
224 | -.fixed-table-toolbar .btn-group > .btn-group { | |
225 | - display: inline-block; | |
226 | - margin-left: -1px !important | |
227 | -} | |
228 | - | |
229 | -.fixed-table-toolbar .btn-group > .btn-group > .btn { | |
230 | - border-radius: 0 | |
231 | -} | |
232 | - | |
233 | -.fixed-table-toolbar .btn-group > .btn-group:first-child > .btn { | |
234 | - border-top-left-radius: 4px; | |
235 | - border-bottom-left-radius: 4px | |
236 | -} | |
237 | - | |
238 | -.fixed-table-toolbar .btn-group > .btn-group:last-child > .btn { | |
239 | - border-top-right-radius: 4px; | |
240 | - border-bottom-right-radius: 4px | |
241 | -} | |
242 | - | |
243 | -.bootstrap-table .table > thead > tr > th { | |
244 | - vertical-align: bottom; | |
245 | - border-bottom: 1px solid #ddd | |
246 | -} | |
247 | - | |
248 | -.bootstrap-table .table thead > tr > th { | |
249 | - padding: 0; | |
250 | - margin: 0 | |
251 | -} | |
252 | - | |
253 | -.bootstrap-table .fixed-table-footer tbody > tr > td { | |
254 | - padding: 0 !important | |
255 | -} | |
256 | - | |
257 | -.bootstrap-table .fixed-table-footer .table { | |
258 | - border-bottom: none; | |
259 | - border-radius: 0; | |
260 | - padding: 0 !important | |
261 | -} | |
262 | - | |
263 | -.pull-right .dropdown-menu { | |
264 | - right: 0; | |
265 | - left: auto | |
266 | -} | |
267 | - | |
268 | -p.fixed-table-scroll-inner { | |
269 | - width: 100%; | |
270 | - height: 200px | |
271 | -} | |
272 | - | |
273 | -div.fixed-table-scroll-outer { | |
274 | - top: 0; | |
275 | - left: 0; | |
276 | - visibility: hidden; | |
277 | - width: 200px; | |
278 | - height: 150px; | |
279 | - overflow: hidden | |
280 | -} | |
281 | 1 | \ No newline at end of file |
2 | +.fixed-table-container .bs-checkbox,.fixed-table-container .no-records-found{text-align:center}.fixed-table-body thead th .th-inner,.table td,.table th{box-sizing:border-box}.bootstrap-table .table{margin-bottom:0!important;border-bottom:1px solid #ddd;border-collapse:collapse!important;border-radius:1px}.bootstrap-table .table:not(.table-condensed),.bootstrap-table .table:not(.table-condensed)>tbody>tr>td,.bootstrap-table .table:not(.table-condensed)>tbody>tr>th,.bootstrap-table .table:not(.table-condensed)>tfoot>tr>td,.bootstrap-table .table:not(.table-condensed)>tfoot>tr>th,.bootstrap-table .table:not(.table-condensed)>thead>tr>td{padding:8px}.bootstrap-table .table.table-no-bordered>tbody>tr>td,.bootstrap-table .table.table-no-bordered>thead>tr>th{border-right:2px solid transparent}.bootstrap-table .table.table-no-bordered>tbody>tr>td:last-child{border-right:none}.fixed-table-container{position:relative;clear:both;border:1px solid #ddd;border-radius:4px;-webkit-border-radius:4px;-moz-border-radius:4px}.fixed-table-container.table-no-bordered{border:1px solid transparent}.fixed-table-footer,.fixed-table-header{overflow:hidden}.fixed-table-footer{border-top:1px solid #ddd}.fixed-table-body{overflow-x:auto;overflow-y:auto;height:100%}.fixed-table-container table{width:100%}.fixed-table-container thead th{height:0;padding:0;margin:0;border-left:1px solid #ddd}.fixed-table-container thead th:focus{outline:transparent solid 0}.fixed-table-container thead th:first-child{border-left:none;border-top-left-radius:4px;-webkit-border-top-left-radius:4px;-moz-border-radius-topleft:4px}.fixed-table-container tbody td .th-inner,.fixed-table-container thead th .th-inner{padding:8px;line-height:24px;vertical-align:top;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.fixed-table-container thead th .sortable{cursor:pointer;background-position:right;background-repeat:no-repeat;padding-right:30px}.fixed-table-container thead th .both{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAkElEQVQoz7X QMQ5AQBCF4dWQSJxC5wwax1Cq1e7BAdxD5SL+Tq/QCM1oNiJidwox0355mXnG/DrEtIQ6azioNZQxI0ykPhTQIwhCR+BmBYtlK7kLJYwWCcJA9M4qdrZrd8pPjZWPtOqdRQy320YSV17OatFC4euts6z39GYMKRPCTKY9UnPQ6P+GtMRfGtPnBCiqhAeJPmkqAAAAAElFTkSuQmCC')}.fixed-table-container thead th .asc{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg==)}.fixed-table-container thead th .desc{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZUlEQVQ4y2NgGAWjYBSggaqGu5FA/BOIv2PBIPFEUgxjB+IdQPwfC94HxLykus4GiD+hGfQOiB3J8SojEE9EM2wuSJzcsFMG4ttQgx4DsRalkZENxL+AuJQaMcsGxBOAmGvopk8AVz1sLZgg0bsAAAAASUVORK5CYII=)}.fixed-table-container th.detail{width:30px}.fixed-table-container tbody td{border-left:1px solid #ddd}.fixed-table-container tbody tr:first-child td{border-top:none}.fixed-table-container tbody td:first-child{border-left:none}.fixed-table-container tbody .selected td{background-color:#f5f5f5}.fixed-table-container .bs-checkbox .th-inner{padding:8px 0}.fixed-table-container input[type=radio],.fixed-table-container input[type=checkbox]{margin:0 auto!important}.fixed-table-pagination .pagination-detail,.fixed-table-pagination div.pagination{margin-top:10px;margin-bottom:10px}.fixed-table-pagination div.pagination .pagination{margin:0}.fixed-table-pagination .pagination a{padding:6px 12px;line-height:1.428571429}.fixed-table-pagination .pagination-info{line-height:34px;margin-right:5px}.fixed-table-pagination .btn-group{position:relative;display:inline-block;vertical-align:middle}.fixed-table-pagination .dropup .dropdown-menu{margin-bottom:0}.fixed-table-pagination .page-list{display:inline-block}.fixed-table-toolbar .columns-left{margin-right:5px}.fixed-table-toolbar .columns-right{margin-left:5px}.fixed-table-toolbar .columns label{display:block;padding:3px 20px;clear:both;font-weight:400;line-height:1.428571429}.fixed-table-toolbar .bs-bars,.fixed-table-toolbar .columns,.fixed-table-toolbar .search{position:relative;margin-top:10px;margin-bottom:10px;line-height:34px}.fixed-table-pagination li.disabled a{pointer-events:none;cursor:default}.fixed-table-loading{display:none;position:absolute;top:42px;right:0;bottom:0;left:0;z-index:99;background-color:#fff;text-align:center}.fixed-table-body .card-view .title{font-weight:700;display:inline-block;min-width:30%;text-align:left!important}.table td,.table th{vertical-align:middle}.fixed-table-toolbar .dropdown-menu{text-align:left;max-height:300px;overflow:auto}.fixed-table-toolbar .btn-group>.btn-group{display:inline-block;margin-left:-1px!important}.fixed-table-toolbar .btn-group>.btn-group>.btn{border-radius:0}.fixed-table-toolbar .btn-group>.btn-group:first-child>.btn{border-top-left-radius:4px;border-bottom-left-radius:4px}.fixed-table-toolbar .btn-group>.btn-group:last-child>.btn{border-top-right-radius:4px;border-bottom-right-radius:4px}.bootstrap-table .table>thead>tr>th{vertical-align:bottom;border-bottom:1px solid #ddd}.bootstrap-table .table thead>tr>th{padding:0;margin:0}.bootstrap-table .fixed-table-footer tbody>tr>td{padding:0!important}.bootstrap-table .fixed-table-footer .table{border-bottom:none;border-radius:0;padding:0!important}.pull-right .dropdown-menu{right:0;left:auto}p.fixed-table-scroll-inner{width:100%;height:200px}div.fixed-table-scroll-outer{top:0;left:0;visibility:hidden;width:200px;height:150px;overflow:hidden} | |
282 | 3 | \ No newline at end of file |
... | ... |
src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.js
1 | -/* | |
2 | -* bootstrap-table - v1.11.0 - 2016-07-02 | |
3 | -* https://github.com/wenzhixin/bootstrap-table | |
4 | -* Copyright (c) 2016 zhixin wen | |
5 | -* Licensed MIT License | |
6 | -*/ | |
7 | -!function (a) { | |
8 | - "use strict"; | |
9 | - var b = null, c = function (a) { | |
10 | - var b = arguments, c = !0, d = 1; | |
11 | - return a = a.replace(/%s/g, function () { | |
12 | - var a = b[d++]; | |
13 | - return "undefined" == typeof a ? (c = !1, "") : a | |
14 | - }), c ? a : "" | |
15 | - }, d = function (b, c, d, e) { | |
16 | - var f = ""; | |
17 | - return a.each(b, function (a, b) { | |
18 | - return b[c] === e ? (f = b[d], !1) : !0 | |
19 | - }), f | |
20 | - }, e = function (b, c) { | |
21 | - var d = -1; | |
22 | - return a.each(b, function (a, b) { | |
23 | - return b.field === c ? (d = a, !1) : !0 | |
24 | - }), d | |
25 | - }, f = function (b) { | |
26 | - var c, d, e, f = 0, g = []; | |
27 | - for (c = 0; c < b[0].length; c++) f += b[0][c].colspan || 1; | |
28 | - for (c = 0; c < b.length; c++) for (g[c] = [], d = 0; f > d; d++) g[c][d] = !1; | |
29 | - for (c = 0; c < b.length; c++) for (d = 0; d < b[c].length; d++) { | |
30 | - var h = b[c][d], i = h.rowspan || 1, j = h.colspan || 1, k = a.inArray(!1, g[c]); | |
31 | - for (1 === j && (h.fieldIndex = k, "undefined" == typeof h.field && (h.field = k)), e = 0; i > e; e++) g[c + e][k] = !0; | |
32 | - for (e = 0; j > e; e++) g[c][k + e] = !0 | |
33 | - } | |
34 | - }, g = function () { | |
35 | - if (null === b) { | |
36 | - var c, d, e = a("<p/>").addClass("fixed-table-scroll-inner"), | |
37 | - f = a("<div/>").addClass("fixed-table-scroll-outer"); | |
38 | - f.append(e), a("body").append(f), c = e[0].offsetWidth, f.css("overflow", "scroll"), d = e[0].offsetWidth, c === d && (d = f[0].clientWidth), f.remove(), b = c - d | |
39 | - } | |
40 | - return b | |
41 | - }, h = function (b, d, e, f) { | |
42 | - var g = d; | |
43 | - if ("string" == typeof d) { | |
44 | - var h = d.split("."); | |
45 | - h.length > 1 ? (g = window, a.each(h, function (a, b) { | |
46 | - g = g[b] | |
47 | - })) : g = window[d] | |
48 | - } | |
49 | - return "object" == typeof g ? g : "function" == typeof g ? g.apply(b, e) : !g && "string" == typeof d && c.apply(this, [d].concat(e)) ? c.apply(this, [d].concat(e)) : f | |
50 | - }, i = function (b, c, d) { | |
51 | - var e = Object.getOwnPropertyNames(b), f = Object.getOwnPropertyNames(c), g = ""; | |
52 | - if (d && e.length !== f.length) return !1; | |
53 | - for (var h = 0; h < e.length; h++) if (g = e[h], a.inArray(g, f) > -1 && b[g] !== c[g]) return !1; | |
54 | - return !0 | |
55 | - }, j = function (a) { | |
56 | - return "string" == typeof a ? a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'").replace(/`/g, "`") : a | |
57 | - }, k = function (b) { | |
58 | - var c = 0; | |
59 | - return b.children().each(function () { | |
60 | - c < a(this).outerHeight(!0) && (c = a(this).outerHeight(!0)) | |
61 | - }), c | |
62 | - }, l = function (a) { | |
63 | - for (var b in a) { | |
64 | - var c = b.split(/(?=[A-Z])/).join("-").toLowerCase(); | |
65 | - c !== b && (a[c] = a[b], delete a[b]) | |
66 | - } | |
67 | - return a | |
68 | - }, m = function (a, b, c) { | |
69 | - var d = a; | |
70 | - if ("string" != typeof b || a.hasOwnProperty(b)) return c ? j(a[b]) : a[b]; | |
71 | - var e = b.split("."); | |
72 | - for (var f in e) d = d && d[e[f]]; | |
73 | - return c ? j(d) : d | |
74 | - }, n = function () { | |
75 | - return !!(navigator.userAgent.indexOf("MSIE ") > 0 || navigator.userAgent.match(/Trident.*rv\:11\./)) | |
76 | - }, o = function () { | |
77 | - Object.keys || (Object.keys = function () { | |
78 | - var a = Object.prototype.hasOwnProperty, b = !{toString: null}.propertyIsEnumerable("toString"), | |
79 | - c = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"], | |
80 | - d = c.length; | |
81 | - return function (e) { | |
82 | - if ("object" != typeof e && ("function" != typeof e || null === e)) throw new TypeError("Object.keys called on non-object"); | |
83 | - var f, g, h = []; | |
84 | - for (f in e) a.call(e, f) && h.push(f); | |
85 | - if (b) for (g = 0; d > g; g++) a.call(e, c[g]) && h.push(c[g]); | |
86 | - return h | |
87 | - } | |
88 | - }()) | |
89 | - }, p = function (b, c) { | |
90 | - this.options = c, this.$el = a(b), this.$el_ = this.$el.clone(), this.timeoutId_ = 0, this.timeoutFooter_ = 0, this.init() | |
91 | - }; | |
92 | - p.DEFAULTS = { | |
93 | - classes: "table table-hover", | |
94 | - locale: void 0, | |
95 | - height: void 0, | |
96 | - undefinedText: "-", | |
97 | - sortName: void 0, | |
98 | - sortOrder: "asc", | |
99 | - sortStable: !1, | |
100 | - striped: !1, | |
101 | - columns: [[]], | |
102 | - data: [], | |
103 | - dataField: "rows", | |
104 | - method: "get", | |
105 | - url: void 0, | |
106 | - ajax: void 0, | |
107 | - cache: !0, | |
108 | - contentType: "application/json", | |
109 | - dataType: "json", | |
110 | - ajaxOptions: {}, | |
111 | - queryParams: function (a) { | |
112 | - return a | |
113 | - }, | |
114 | - queryParamsType: "limit", | |
115 | - responseHandler: function (a) { | |
116 | - return a | |
117 | - }, | |
118 | - pagination: !1, | |
119 | - onlyInfoPagination: !1, | |
120 | - sidePagination: "client", | |
121 | - totalRows: 0, | |
122 | - pageNumber: 1, | |
123 | - pageSize: 10, | |
124 | - pageList: [10, 25, 50, 100], | |
125 | - paginationHAlign: "right", | |
126 | - paginationVAlign: "bottom", | |
127 | - paginationDetailHAlign: "left", | |
128 | - paginationPreText: "‹", | |
129 | - paginationNextText: "›", | |
130 | - search: !1, | |
131 | - searchOnEnterKey: !1, | |
132 | - strictSearch: !1, | |
133 | - searchAlign: "right", | |
134 | - selectItemName: "btSelectItem", | |
135 | - showHeader: !0, | |
136 | - showFooter: !1, | |
137 | - showColumns: !1, | |
138 | - showPaginationSwitch: !1, | |
139 | - showRefresh: !1, | |
140 | - showToggle: !1, | |
141 | - buttonsAlign: "right", | |
142 | - smartDisplay: !0, | |
143 | - escape: !1, | |
144 | - minimumCountColumns: 1, | |
145 | - idField: void 0, | |
146 | - uniqueId: void 0, | |
147 | - cardView: !1, | |
148 | - detailView: !1, | |
149 | - detailFormatter: function () { | |
150 | - return "" | |
151 | - }, | |
152 | - trimOnSearch: !0, | |
153 | - clickToSelect: !1, | |
154 | - singleSelect: !1, | |
155 | - toolbar: void 0, | |
156 | - toolbarAlign: "left", | |
157 | - checkboxHeader: !0, | |
158 | - sortable: !0, | |
159 | - silentSort: !0, | |
160 | - maintainSelected: !1, | |
161 | - searchTimeOut: 500, | |
162 | - searchText: "", | |
163 | - iconSize: void 0, | |
164 | - buttonsClass: "default", | |
165 | - iconsPrefix: "glyphicon", | |
166 | - icons: { | |
167 | - paginationSwitchDown: "glyphicon-collapse-down icon-chevron-down", | |
168 | - paginationSwitchUp: "glyphicon-collapse-up icon-chevron-up", | |
169 | - refresh: "glyphicon-refresh icon-refresh", | |
170 | - toggle: "glyphicon-list-alt icon-list-alt", | |
171 | - columns: "glyphicon-th icon-th", | |
172 | - detailOpen: "glyphicon-plus icon-plus", | |
173 | - detailClose: "glyphicon-minus icon-minus" | |
174 | - }, | |
175 | - customSearch: a.noop, | |
176 | - customSort: a.noop, | |
177 | - rowStyle: function () { | |
178 | - return {} | |
179 | - }, | |
180 | - rowAttributes: function () { | |
181 | - return {} | |
182 | - }, | |
183 | - footerStyle: function () { | |
184 | - return {} | |
185 | - }, | |
186 | - onAll: function () { | |
187 | - return !1 | |
188 | - }, | |
189 | - onClickCell: function () { | |
190 | - return !1 | |
191 | - }, | |
192 | - onDblClickCell: function () { | |
193 | - return !1 | |
194 | - }, | |
195 | - onClickRow: function () { | |
196 | - return !1 | |
197 | - }, | |
198 | - onDblClickRow: function () { | |
199 | - return !1 | |
200 | - }, | |
201 | - onSort: function () { | |
202 | - return !1 | |
203 | - }, | |
204 | - onCheck: function () { | |
205 | - return !1 | |
206 | - }, | |
207 | - onUncheck: function () { | |
208 | - return !1 | |
209 | - }, | |
210 | - onCheckAll: function () { | |
211 | - return !1 | |
212 | - }, | |
213 | - onUncheckAll: function () { | |
214 | - return !1 | |
215 | - }, | |
216 | - onCheckSome: function () { | |
217 | - return !1 | |
218 | - }, | |
219 | - onUncheckSome: function () { | |
220 | - return !1 | |
221 | - }, | |
222 | - onLoadSuccess: function () { | |
223 | - return !1 | |
224 | - }, | |
225 | - onLoadError: function () { | |
226 | - return !1 | |
227 | - }, | |
228 | - onColumnSwitch: function () { | |
229 | - return !1 | |
230 | - }, | |
231 | - onPageChange: function () { | |
232 | - return !1 | |
233 | - }, | |
234 | - onSearch: function () { | |
235 | - return !1 | |
236 | - }, | |
237 | - onToggle: function () { | |
238 | - return !1 | |
239 | - }, | |
240 | - onPreBody: function () { | |
241 | - return !1 | |
242 | - }, | |
243 | - onPostBody: function () { | |
244 | - return !1 | |
245 | - }, | |
246 | - onPostHeader: function () { | |
247 | - return !1 | |
248 | - }, | |
249 | - onExpandRow: function () { | |
250 | - return !1 | |
251 | - }, | |
252 | - onCollapseRow: function () { | |
253 | - return !1 | |
254 | - }, | |
255 | - onRefreshOptions: function () { | |
256 | - return !1 | |
257 | - }, | |
258 | - onRefresh: function () { | |
259 | - return !1 | |
260 | - }, | |
261 | - onResetView: function () { | |
262 | - return !1 | |
263 | - } | |
264 | - }, p.LOCALES = {}, p.LOCALES["en-US"] = p.LOCALES.en = { | |
265 | - formatLoadingMessage: function () { | |
266 | - return "Loading, please wait..." | |
267 | - }, formatRecordsPerPage: function (a) { | |
268 | - return c("%s rows per page", a) | |
269 | - }, formatShowingRows: function (a, b, d) { | |
270 | - return c("Showing %s to %s of %s rows", a, b, d) | |
271 | - }, formatDetailPagination: function (a) { | |
272 | - return c("Showing %s rows", a) | |
273 | - }, formatSearch: function () { | |
274 | - return "Search" | |
275 | - }, formatNoMatches: function () { | |
276 | - return "No matching records found" | |
277 | - }, formatPaginationSwitch: function () { | |
278 | - return "Hide/Show pagination" | |
279 | - }, formatRefresh: function () { | |
280 | - return "Refresh" | |
281 | - }, formatToggle: function () { | |
282 | - return "Toggle" | |
283 | - }, formatColumns: function () { | |
284 | - return "Columns" | |
285 | - }, formatAllRows: function () { | |
286 | - return "All" | |
287 | - } | |
288 | - }, a.extend(p.DEFAULTS, p.LOCALES["en-US"]), p.COLUMN_DEFAULTS = { | |
289 | - radio: !1, | |
290 | - checkbox: !1, | |
291 | - checkboxEnabled: !0, | |
292 | - field: void 0, | |
293 | - title: void 0, | |
294 | - titleTooltip: void 0, | |
295 | - "class": void 0, | |
296 | - align: void 0, | |
297 | - halign: void 0, | |
298 | - falign: void 0, | |
299 | - valign: void 0, | |
300 | - width: void 0, | |
301 | - sortable: !1, | |
302 | - order: "asc", | |
303 | - visible: !0, | |
304 | - switchable: !0, | |
305 | - clickToSelect: !0, | |
306 | - formatter: void 0, | |
307 | - footerFormatter: void 0, | |
308 | - events: void 0, | |
309 | - sorter: void 0, | |
310 | - sortName: void 0, | |
311 | - cellStyle: void 0, | |
312 | - searchable: !0, | |
313 | - searchFormatter: !0, | |
314 | - cardVisible: !0 | |
315 | - }, p.EVENTS = { | |
316 | - "all.bs.table": "onAll", | |
317 | - "click-cell.bs.table": "onClickCell", | |
318 | - "dbl-click-cell.bs.table": "onDblClickCell", | |
319 | - "click-row.bs.table": "onClickRow", | |
320 | - "dbl-click-row.bs.table": "onDblClickRow", | |
321 | - "sort.bs.table": "onSort", | |
322 | - "check.bs.table": "onCheck", | |
323 | - "uncheck.bs.table": "onUncheck", | |
324 | - "check-all.bs.table": "onCheckAll", | |
325 | - "uncheck-all.bs.table": "onUncheckAll", | |
326 | - "check-some.bs.table": "onCheckSome", | |
327 | - "uncheck-some.bs.table": "onUncheckSome", | |
328 | - "load-success.bs.table": "onLoadSuccess", | |
329 | - "load-error.bs.table": "onLoadError", | |
330 | - "column-switch.bs.table": "onColumnSwitch", | |
331 | - "page-change.bs.table": "onPageChange", | |
332 | - "search.bs.table": "onSearch", | |
333 | - "toggle.bs.table": "onToggle", | |
334 | - "pre-body.bs.table": "onPreBody", | |
335 | - "post-body.bs.table": "onPostBody", | |
336 | - "post-header.bs.table": "onPostHeader", | |
337 | - "expand-row.bs.table": "onExpandRow", | |
338 | - "collapse-row.bs.table": "onCollapseRow", | |
339 | - "refresh-options.bs.table": "onRefreshOptions", | |
340 | - "reset-view.bs.table": "onResetView", | |
341 | - "refresh.bs.table": "onRefresh" | |
342 | - }, p.prototype.init = function () { | |
343 | - this.initLocale(), this.initContainer(), this.initTable(), this.initHeader(), this.initData(), this.initFooter(), this.initToolbar(), this.initPagination(), this.initBody(), this.initSearchText(), this.initServer() | |
344 | - }, p.prototype.initLocale = function () { | |
345 | - if (this.options.locale) { | |
346 | - var b = this.options.locale.split(/-|_/); | |
347 | - b[0].toLowerCase(), b[1] && b[1].toUpperCase(), a.fn.bootstrapTable.locales[this.options.locale] ? a.extend(this.options, a.fn.bootstrapTable.locales[this.options.locale]) : a.fn.bootstrapTable.locales[b.join("-")] ? a.extend(this.options, a.fn.bootstrapTable.locales[b.join("-")]) : a.fn.bootstrapTable.locales[b[0]] && a.extend(this.options, a.fn.bootstrapTable.locales[b[0]]) | |
348 | - } | |
349 | - }, p.prototype.initContainer = function () { | |
350 | - this.$container = a(['<div class="bootstrap-table">', '<div class="fixed-table-toolbar"></div>', "top" === this.options.paginationVAlign || "both" === this.options.paginationVAlign ? '<div class="fixed-table-pagination" style="clear: both;"></div>' : "", '<div class="fixed-table-container">', '<div class="fixed-table-header"><table></table></div>', '<div class="fixed-table-body">', '<div class="fixed-table-loading">', this.options.formatLoadingMessage(), "</div>", "</div>", '<div class="fixed-table-footer"><table><tr></tr></table></div>', "bottom" === this.options.paginationVAlign || "both" === this.options.paginationVAlign ? '<div class="fixed-table-pagination"></div>' : "", "</div>", "</div>"].join("")), this.$container.insertAfter(this.$el), this.$tableContainer = this.$container.find(".fixed-table-container"), this.$tableHeader = this.$container.find(".fixed-table-header"), this.$tableBody = this.$container.find(".fixed-table-body"), this.$tableLoading = this.$container.find(".fixed-table-loading"), this.$tableFooter = this.$container.find(".fixed-table-footer"), this.$toolbar = this.$container.find(".fixed-table-toolbar"), this.$pagination = this.$container.find(".fixed-table-pagination"), this.$tableBody.append(this.$el), this.$container.after('<div class="clearfix"></div>'), this.$el.addClass(this.options.classes), this.options.striped && this.$el.addClass("table-striped"), -1 !== a.inArray("table-no-bordered", this.options.classes.split(" ")) && this.$tableContainer.addClass("table-no-bordered") | |
351 | - }, p.prototype.initTable = function () { | |
352 | - var b = this, c = [], d = []; | |
353 | - if (this.$header = this.$el.find(">thead"), this.$header.length || (this.$header = a("<thead></thead>").appendTo(this.$el)), this.$header.find("tr").each(function () { | |
354 | - var b = []; | |
355 | - a(this).find("th").each(function () { | |
356 | - "undefined" != typeof a(this).data("field") && a(this).data("field", a(this).data("field") + ""), b.push(a.extend({}, { | |
357 | - title: a(this).html(), | |
358 | - "class": a(this).attr("class"), | |
359 | - titleTooltip: a(this).attr("title"), | |
360 | - rowspan: a(this).attr("rowspan") ? +a(this).attr("rowspan") : void 0, | |
361 | - colspan: a(this).attr("colspan") ? +a(this).attr("colspan") : void 0 | |
362 | - }, a(this).data())) | |
363 | - }), c.push(b) | |
364 | - }), a.isArray(this.options.columns[0]) || (this.options.columns = [this.options.columns]), this.options.columns = a.extend(!0, [], c, this.options.columns), this.columns = [], f(this.options.columns), a.each(this.options.columns, function (c, d) { | |
365 | - a.each(d, function (d, e) { | |
366 | - e = a.extend({}, p.COLUMN_DEFAULTS, e), "undefined" != typeof e.fieldIndex && (b.columns[e.fieldIndex] = e), b.options.columns[c][d] = e | |
367 | - }) | |
368 | - }), !this.options.data.length) { | |
369 | - var e = []; | |
370 | - this.$el.find(">tbody>tr").each(function (c) { | |
371 | - var f = {}; | |
372 | - f._id = a(this).attr("id"), f._class = a(this).attr("class"), f._data = l(a(this).data()), a(this).find(">td").each(function (d) { | |
373 | - for (var g, h, i = a(this), j = +i.attr("colspan") || 1, k = +i.attr("rowspan") || 1; e[c] && e[c][d]; d++) ; | |
374 | - for (g = d; d + j > g; g++) for (h = c; c + k > h; h++) e[h] || (e[h] = []), e[h][g] = !0; | |
375 | - var m = b.columns[d].field; | |
376 | - f[m] = a(this).html(), f["_" + m + "_id"] = a(this).attr("id"), f["_" + m + "_class"] = a(this).attr("class"), f["_" + m + "_rowspan"] = a(this).attr("rowspan"), f["_" + m + "_colspan"] = a(this).attr("colspan"), f["_" + m + "_title"] = a(this).attr("title"), f["_" + m + "_data"] = l(a(this).data()) | |
377 | - }), d.push(f) | |
378 | - }), this.options.data = d, d.length && (this.fromHtml = !0) | |
379 | - } | |
380 | - }, p.prototype.initHeader = function () { | |
381 | - var b = this, d = {}, e = []; | |
382 | - this.header = { | |
383 | - fields: [], | |
384 | - styles: [], | |
385 | - classes: [], | |
386 | - formatters: [], | |
387 | - events: [], | |
388 | - sorters: [], | |
389 | - sortNames: [], | |
390 | - cellStyles: [], | |
391 | - searchables: [] | |
392 | - }, a.each(this.options.columns, function (f, g) { | |
393 | - e.push("<tr>"), 0 === f && !b.options.cardView && b.options.detailView && e.push(c('<th class="detail" rowspan="%s"><div class="fht-cell"></div></th>', b.options.columns.length)), a.each(g, function (a, f) { | |
394 | - var g = "", h = "", i = "", j = "", k = c(' class="%s"', f["class"]), | |
395 | - l = (b.options.sortOrder || f.order, "px"), m = f.width; | |
396 | - if (void 0 === f.width || b.options.cardView || "string" == typeof f.width && -1 !== f.width.indexOf("%") && (l = "%"), f.width && "string" == typeof f.width && (m = f.width.replace("%", "").replace("px", "")), h = c("text-align: %s; ", f.halign ? f.halign : f.align), i = c("text-align: %s; ", f.align), j = c("vertical-align: %s; ", f.valign), j += c("width: %s; ", !f.checkbox && !f.radio || m ? m ? m + l : void 0 : "36px"), "undefined" != typeof f.fieldIndex) { | |
397 | - if (b.header.fields[f.fieldIndex] = f.field, b.header.styles[f.fieldIndex] = i + j, b.header.classes[f.fieldIndex] = k, b.header.formatters[f.fieldIndex] = f.formatter, b.header.events[f.fieldIndex] = f.events, b.header.sorters[f.fieldIndex] = f.sorter, b.header.sortNames[f.fieldIndex] = f.sortName, b.header.cellStyles[f.fieldIndex] = f.cellStyle, b.header.searchables[f.fieldIndex] = f.searchable, !f.visible) return; | |
398 | - if (b.options.cardView && !f.cardVisible) return; | |
399 | - d[f.field] = f | |
400 | - } | |
401 | - e.push("<th" + c(' title="%s"', f.titleTooltip), f.checkbox || f.radio ? c(' class="bs-checkbox %s"', f["class"] || "") : k, c(' style="%s"', h + j), c(' rowspan="%s"', f.rowspan), c(' colspan="%s"', f.colspan), c(' data-field="%s"', f.field), "tabindex='0'", ">"), e.push(c('<div class="th-inner %s">', b.options.sortable && f.sortable ? "sortable both" : "")), g = f.title, f.checkbox && (!b.options.singleSelect && b.options.checkboxHeader && (g = '<input name="btSelectAll" type="checkbox" />'), b.header.stateField = f.field), f.radio && (g = "", b.header.stateField = f.field, b.options.singleSelect = !0), e.push(g), e.push("</div>"), e.push('<div class="fht-cell"></div>'), e.push("</div>"), e.push("</th>") | |
402 | - }), e.push("</tr>") | |
403 | - }), this.$header.html(e.join("")), this.$header.find("th[data-field]").each(function () { | |
404 | - a(this).data(d[a(this).data("field")]) | |
405 | - }), this.$container.off("click", ".th-inner").on("click", ".th-inner", function (c) { | |
406 | - var d = a(this); | |
407 | - return b.options.detailView && d.closest(".bootstrap-table")[0] !== b.$container[0] ? !1 : void(b.options.sortable && d.parent().data().sortable && b.onSort(c)) | |
408 | - }), this.$header.children().children().off("keypress").on("keypress", function (c) { | |
409 | - if (b.options.sortable && a(this).data().sortable) { | |
410 | - var d = c.keyCode || c.which; | |
411 | - 13 == d && b.onSort(c) | |
412 | - } | |
413 | - }), a(window).off("resize.bootstrap-table"), !this.options.showHeader || this.options.cardView ? (this.$header.hide(), this.$tableHeader.hide(), this.$tableLoading.css("top", 0)) : (this.$header.show(), this.$tableHeader.show(), this.$tableLoading.css("top", this.$header.outerHeight() + 1), this.getCaret(), a(window).on("resize.bootstrap-table", a.proxy(this.resetWidth, this))), this.$selectAll = this.$header.find('[name="btSelectAll"]'), this.$selectAll.off("click").on("click", function () { | |
414 | - var c = a(this).prop("checked"); | |
415 | - b[c ? "checkAll" : "uncheckAll"](), b.updateSelected() | |
416 | - }) | |
417 | - }, p.prototype.initFooter = function () { | |
418 | - !this.options.showFooter || this.options.cardView ? this.$tableFooter.hide() : this.$tableFooter.show() | |
419 | - }, p.prototype.initData = function (a, b) { | |
420 | - this.data = "append" === b ? this.data.concat(a) : "prepend" === b ? [].concat(a).concat(this.data) : a || this.options.data, this.options.data = "append" === b ? this.options.data.concat(a) : "prepend" === b ? [].concat(a).concat(this.options.data) : this.data, "server" !== this.options.sidePagination && this.initSort() | |
421 | - }, p.prototype.initSort = function () { | |
422 | - var b = this, c = this.options.sortName, d = "desc" === this.options.sortOrder ? -1 : 1, | |
423 | - e = a.inArray(this.options.sortName, this.header.fields); | |
424 | - return this.options.customSort !== a.noop ? void this.options.customSort.apply(this, [this.options.sortName, this.options.sortOrder]) : void(-1 !== e && (this.options.sortStable && a.each(this.data, function (a, b) { | |
425 | - b.hasOwnProperty("_position") || (b._position = a) | |
426 | - }), this.data.sort(function (f, g) { | |
427 | - b.header.sortNames[e] && (c = b.header.sortNames[e]); | |
428 | - var i = m(f, c, b.options.escape), j = m(g, c, b.options.escape), | |
429 | - k = h(b.header, b.header.sorters[e], [i, j]); | |
430 | - return void 0 !== k ? d * k : ((void 0 === i || null === i) && (i = ""), (void 0 === j || null === j) && (j = ""), b.options.sortStable && i === j && (i = f._position, j = g._position), a.isNumeric(i) && a.isNumeric(j) ? (i = parseFloat(i), j = parseFloat(j), j > i ? -1 * d : d) : i === j ? 0 : ("string" != typeof i && (i = i.toString()), -1 === i.localeCompare(j) ? -1 * d : d)) | |
431 | - }))) | |
432 | - }, p.prototype.onSort = function (b) { | |
433 | - var c = "keypress" === b.type ? a(b.currentTarget) : a(b.currentTarget).parent(), | |
434 | - d = this.$header.find("th").eq(c.index()); | |
435 | - return this.$header.add(this.$header_).find("span.order").remove(), this.options.sortName === c.data("field") ? this.options.sortOrder = "asc" === this.options.sortOrder ? "desc" : "asc" : (this.options.sortName = c.data("field"), this.options.sortOrder = "asc" === c.data("order") ? "desc" : "asc"), this.trigger("sort", this.options.sortName, this.options.sortOrder), c.add(d).data("order", this.options.sortOrder), this.getCaret(), "server" === this.options.sidePagination ? void this.initServer(this.options.silentSort) : (this.initSort(), void this.initBody()) | |
436 | - }, p.prototype.initToolbar = function () { | |
437 | - var b, d, e = this, f = [], g = 0, i = 0; | |
438 | - this.$toolbar.find(".bs-bars").children().length && a("body").append(a(this.options.toolbar)), this.$toolbar.html(""), ("string" == typeof this.options.toolbar || "object" == typeof this.options.toolbar) && a(c('<div class="bs-bars pull-%s"></div>', this.options.toolbarAlign)).appendTo(this.$toolbar).append(a(this.options.toolbar)), f = [c('<div class="columns columns-%s btn-group pull-%s">', this.options.buttonsAlign, this.options.buttonsAlign)], "string" == typeof this.options.icons && (this.options.icons = h(null, this.options.icons)), this.options.showPaginationSwitch && f.push(c('<button class="btn' + c(" btn-%s", this.options.buttonsClass) + c(" btn-%s", this.options.iconSize) + '" type="button" name="paginationSwitch" title="%s">', this.options.formatPaginationSwitch()), c('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.paginationSwitchDown), "</button>"), this.options.showRefresh && f.push(c('<button class="btn' + c(" btn-%s", this.options.buttonsClass) + c(" btn-%s", this.options.iconSize) + '" type="button" name="refresh" title="%s">', this.options.formatRefresh()), c('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.refresh), "</button>"), this.options.showToggle && f.push(c('<button class="btn' + c(" btn-%s", this.options.buttonsClass) + c(" btn-%s", this.options.iconSize) + '" type="button" name="toggle" title="%s">', this.options.formatToggle()), c('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.toggle), "</button>"), this.options.showColumns && (f.push(c('<div class="keep-open btn-group" title="%s">', this.options.formatColumns()), '<button type="button" class="btn' + c(" btn-%s", this.options.buttonsClass) + c(" btn-%s", this.options.iconSize) + ' dropdown-toggle" data-toggle="dropdown">', c('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.columns), ' <span class="caret"></span>', "</button>", '<ul class="dropdown-menu" role="menu">'), a.each(this.columns, function (a, b) { | |
439 | - if (!(b.radio || b.checkbox || e.options.cardView && !b.cardVisible)) { | |
440 | - var d = b.visible ? ' checked="checked"' : ""; | |
441 | - b.switchable && (f.push(c('<li><label><input type="checkbox" data-field="%s" value="%s"%s> %s</label></li>', b.field, a, d, b.title)), i++) | |
442 | - } | |
443 | - }), f.push("</ul>", "</div>")), f.push("</div>"), (this.showToolbar || f.length > 2) && this.$toolbar.append(f.join("")), this.options.showPaginationSwitch && this.$toolbar.find('button[name="paginationSwitch"]').off("click").on("click", a.proxy(this.togglePagination, this)), this.options.showRefresh && this.$toolbar.find('button[name="refresh"]').off("click").on("click", a.proxy(this.refresh, this)), this.options.showToggle && this.$toolbar.find('button[name="toggle"]').off("click").on("click", function () { | |
444 | - e.toggleView() | |
445 | - }), this.options.showColumns && (b = this.$toolbar.find(".keep-open"), i <= this.options.minimumCountColumns && b.find("input").prop("disabled", !0), b.find("li").off("click").on("click", function (a) { | |
446 | - a.stopImmediatePropagation() | |
447 | - }), b.find("input").off("click").on("click", function () { | |
448 | - var b = a(this); | |
449 | - e.toggleColumn(a(this).val(), b.prop("checked"), !1), e.trigger("column-switch", a(this).data("field"), b.prop("checked")) | |
450 | - })), this.options.search && (f = [], f.push('<div class="pull-' + this.options.searchAlign + ' search">', c('<input class="form-control' + c(" input-%s", this.options.iconSize) + '" type="text" placeholder="%s">', this.options.formatSearch()), "</div>"), this.$toolbar.append(f.join("")), d = this.$toolbar.find(".search input"), d.off("keyup drop").on("keyup drop", function (b) { | |
451 | - e.options.searchOnEnterKey && 13 !== b.keyCode || a.inArray(b.keyCode, [37, 38, 39, 40]) > -1 || (clearTimeout(g), g = setTimeout(function () { | |
452 | - e.onSearch(b) | |
453 | - }, e.options.searchTimeOut)) | |
454 | - }), n() && d.off("mouseup").on("mouseup", function (a) { | |
455 | - clearTimeout(g), g = setTimeout(function () { | |
456 | - e.onSearch(a) | |
457 | - }, e.options.searchTimeOut) | |
458 | - })) | |
459 | - }, p.prototype.onSearch = function (b) { | |
460 | - var c = a.trim(a(b.currentTarget).val()); | |
461 | - this.options.trimOnSearch && a(b.currentTarget).val() !== c && a(b.currentTarget).val(c), c !== this.searchText && (this.searchText = c, this.options.searchText = c, this.options.pageNumber = 1, this.initSearch(), this.updatePagination(), this.trigger("search", c)) | |
462 | - }, p.prototype.initSearch = function () { | |
463 | - var b = this; | |
464 | - if ("server" !== this.options.sidePagination) { | |
465 | - if (this.options.customSearch !== a.noop) return void this.options.customSearch.apply(this, [this.searchText]); | |
466 | - var c = this.searchText && (this.options.escape ? j(this.searchText) : this.searchText).toLowerCase(), | |
467 | - d = a.isEmptyObject(this.filterColumns) ? null : this.filterColumns; | |
468 | - this.data = d ? a.grep(this.options.data, function (b) { | |
469 | - for (var c in d) if (a.isArray(d[c]) && -1 === a.inArray(b[c], d[c]) || b[c] !== d[c]) return !1; | |
470 | - return !0 | |
471 | - }) : this.options.data, this.data = c ? a.grep(this.data, function (d, f) { | |
472 | - for (var g = 0; g < b.header.fields.length; g++) if (b.header.searchables[g]) { | |
473 | - var i, j = a.isNumeric(b.header.fields[g]) ? parseInt(b.header.fields[g], 10) : b.header.fields[g], | |
474 | - k = b.columns[e(b.columns, j)]; | |
475 | - if ("string" == typeof j) { | |
476 | - i = d; | |
477 | - for (var l = j.split("."), m = 0; m < l.length; m++) i = i[l[m]]; | |
478 | - k && k.searchFormatter && (i = h(k, b.header.formatters[g], [i, d, f], i)) | |
479 | - } else i = d[j]; | |
480 | - if ("string" == typeof i || "number" == typeof i) if (b.options.strictSearch) { | |
481 | - if ((i + "").toLowerCase() === c) return !0 | |
482 | - } else if (-1 !== (i + "").toLowerCase().indexOf(c)) return !0 | |
483 | - } | |
484 | - return !1 | |
485 | - }) : this.data | |
486 | - } | |
487 | - }, p.prototype.initPagination = function () { | |
488 | - if (!this.options.pagination) return void this.$pagination.hide(); | |
489 | - this.$pagination.show(); | |
490 | - var b, d, e, f, g, h, i, j, k, l = this, m = [], n = !1, o = this.getData(), p = this.options.pageList; | |
491 | - if ("server" !== this.options.sidePagination && (this.options.totalRows = o.length), this.totalPages = 0, this.options.totalRows) { | |
492 | - if (this.options.pageSize === this.options.formatAllRows()) this.options.pageSize = this.options.totalRows, n = !0; else if (this.options.pageSize === this.options.totalRows) { | |
493 | - var q = "string" == typeof this.options.pageList ? this.options.pageList.replace("[", "").replace("]", "").replace(/ /g, "").toLowerCase().split(",") : this.options.pageList; | |
494 | - a.inArray(this.options.formatAllRows().toLowerCase(), q) > -1 && (n = !0) | |
495 | - } | |
496 | - this.totalPages = ~~((this.options.totalRows - 1) / this.options.pageSize) + 1, this.options.totalPages = this.totalPages | |
497 | - } | |
498 | - if (this.totalPages > 0 && this.options.pageNumber > this.totalPages && (this.options.pageNumber = this.totalPages), this.pageFrom = (this.options.pageNumber - 1) * this.options.pageSize + 1, this.pageTo = this.options.pageNumber * this.options.pageSize, this.pageTo > this.options.totalRows && (this.pageTo = this.options.totalRows), m.push('<div class="pull-' + this.options.paginationDetailHAlign + ' pagination-detail">', '<span class="pagination-info">', this.options.onlyInfoPagination ? this.options.formatDetailPagination(this.options.totalRows) : this.options.formatShowingRows(this.pageFrom, this.pageTo, this.options.totalRows), "</span>"), !this.options.onlyInfoPagination) { | |
499 | - m.push('<span class="page-list">'); | |
500 | - var r = [c('<span class="btn-group %s">', "top" === this.options.paginationVAlign || "both" === this.options.paginationVAlign ? "dropdown" : "dropup"), '<button type="button" class="btn' + c(" btn-%s", this.options.buttonsClass) + c(" btn-%s", this.options.iconSize) + ' dropdown-toggle" data-toggle="dropdown">', '<span class="page-size">', n ? this.options.formatAllRows() : this.options.pageSize, "</span>", ' <span class="caret"></span>', "</button>", '<ul class="dropdown-menu" role="menu">']; | |
501 | - if ("string" == typeof this.options.pageList) { | |
502 | - var s = this.options.pageList.replace("[", "").replace("]", "").replace(/ /g, "").split(","); | |
503 | - p = [], a.each(s, function (a, b) { | |
504 | - p.push(b.toUpperCase() === l.options.formatAllRows().toUpperCase() ? l.options.formatAllRows() : +b) | |
505 | - }) | |
506 | - } | |
507 | - for (a.each(p, function (a, b) { | |
508 | - if (!l.options.smartDisplay || 0 === a || p[a - 1] <= l.options.totalRows) { | |
509 | - var d; | |
510 | - d = n ? b === l.options.formatAllRows() ? ' class="active"' : "" : b === l.options.pageSize ? ' class="active"' : "", r.push(c('<li%s><a href="javascript:void(0)">%s</a></li>', d, b)) | |
511 | - } | |
512 | - }), r.push("</ul></span>"), m.push(this.options.formatRecordsPerPage(r.join(""))), m.push("</span>"), m.push("</div>", '<div class="pull-' + this.options.paginationHAlign + ' pagination">', '<ul class="pagination' + c(" pagination-%s", this.options.iconSize) + '">', '<li class="page-pre"><a href="javascript:void(0)">' + this.options.paginationPreText + "</a></li>"), this.totalPages < 5 ? (d = 1, e = this.totalPages) : (d = this.options.pageNumber - 2, e = d + 4, 1 > d && (d = 1, e = 5), e > this.totalPages && (e = this.totalPages, d = e - 4)), this.totalPages >= 6 && (this.options.pageNumber >= 3 && (m.push('<li class="page-first' + (1 === this.options.pageNumber ? " active" : "") + '">', '<a href="javascript:void(0)">', 1, "</a>", "</li>"), d++), this.options.pageNumber >= 4 && (4 == this.options.pageNumber || 6 == this.totalPages || 7 == this.totalPages ? d-- : m.push('<li class="page-first-separator disabled">', '<a href="javascript:void(0)">...</a>', "</li>"), e--)), this.totalPages >= 7 && this.options.pageNumber >= this.totalPages - 2 && d--, 6 == this.totalPages ? this.options.pageNumber >= this.totalPages - 2 && e++ : this.totalPages >= 7 && (7 == this.totalPages || this.options.pageNumber >= this.totalPages - 3) && e++, b = d; e >= b; b++) m.push('<li class="page-number' + (b === this.options.pageNumber ? " active" : "") + '">', '<a href="javascript:void(0)">', b, "</a>", "</li>"); | |
513 | - this.totalPages >= 8 && this.options.pageNumber <= this.totalPages - 4 && m.push('<li class="page-last-separator disabled">', '<a href="javascript:void(0)">...</a>', "</li>"), this.totalPages >= 6 && this.options.pageNumber <= this.totalPages - 3 && m.push('<li class="page-last' + (this.totalPages === this.options.pageNumber ? " active" : "") + '">', '<a href="javascript:void(0)">', this.totalPages, "</a>", "</li>"), m.push('<li class="page-next"><a href="javascript:void(0)">' + this.options.paginationNextText + "</a></li>", "</ul>", "</div>") | |
514 | - } | |
515 | - this.$pagination.html(m.join("")), this.options.onlyInfoPagination || (f = this.$pagination.find(".page-list a"), g = this.$pagination.find(".page-first"), h = this.$pagination.find(".page-pre"), i = this.$pagination.find(".page-next"), j = this.$pagination.find(".page-last"), k = this.$pagination.find(".page-number"), this.options.smartDisplay && (this.totalPages <= 1 && this.$pagination.find("div.pagination").hide(), (p.length < 2 || this.options.totalRows <= p[0]) && this.$pagination.find("span.page-list").hide(), this.$pagination[this.getData().length ? "show" : "hide"]()), n && (this.options.pageSize = this.options.formatAllRows()), f.off("click").on("click", a.proxy(this.onPageListChange, this)), g.off("click").on("click", a.proxy(this.onPageFirst, this)), h.off("click").on("click", a.proxy(this.onPagePre, this)), i.off("click").on("click", a.proxy(this.onPageNext, this)), j.off("click").on("click", a.proxy(this.onPageLast, this)), k.off("click").on("click", a.proxy(this.onPageNumber, this))) | |
516 | - }, p.prototype.updatePagination = function (b) { | |
517 | - b && a(b.currentTarget).hasClass("disabled") || (this.options.maintainSelected || this.resetRows(), this.initPagination(), "server" === this.options.sidePagination ? this.initServer() : this.initBody(), this.trigger("page-change", this.options.pageNumber, this.options.pageSize)) | |
518 | - }, p.prototype.onPageListChange = function (b) { | |
519 | - var c = a(b.currentTarget); | |
520 | - c.parent().addClass("active").siblings().removeClass("active"), this.options.pageSize = c.text().toUpperCase() === this.options.formatAllRows().toUpperCase() ? this.options.formatAllRows() : +c.text(), this.$toolbar.find(".page-size").text(this.options.pageSize), this.updatePagination(b) | |
521 | - }, p.prototype.onPageFirst = function (a) { | |
522 | - this.options.pageNumber = 1, this.updatePagination(a) | |
523 | - }, p.prototype.onPagePre = function (a) { | |
524 | - this.options.pageNumber - 1 === 0 ? this.options.pageNumber = this.options.totalPages : this.options.pageNumber--, this.updatePagination(a) | |
525 | - }, p.prototype.onPageNext = function (a) { | |
526 | - this.options.pageNumber + 1 > this.options.totalPages ? this.options.pageNumber = 1 : this.options.pageNumber++, this.updatePagination(a) | |
527 | - }, p.prototype.onPageLast = function (a) { | |
528 | - this.options.pageNumber = this.totalPages, this.updatePagination(a) | |
529 | - }, p.prototype.onPageNumber = function (b) { | |
530 | - this.options.pageNumber !== +a(b.currentTarget).text() && (this.options.pageNumber = +a(b.currentTarget).text(), this.updatePagination(b)) | |
531 | - }, p.prototype.initBody = function (b) { | |
532 | - var f = this, g = [], i = this.getData(); | |
533 | - this.trigger("pre-body", i), this.$body = this.$el.find(">tbody"), this.$body.length || (this.$body = a("<tbody></tbody>").appendTo(this.$el)), this.options.pagination && "server" !== this.options.sidePagination || (this.pageFrom = 1, this.pageTo = i.length); | |
534 | - for (var k = this.pageFrom - 1; k < this.pageTo; k++) { | |
535 | - var l, n = i[k], o = {}, p = [], q = "", r = {}, s = []; | |
536 | - if (o = h(this.options, this.options.rowStyle, [n, k], o), o && o.css) for (l in o.css) p.push(l + ": " + o.css[l]); | |
537 | - if (r = h(this.options, this.options.rowAttributes, [n, k], r)) for (l in r) s.push(c('%s="%s"', l, j(r[l]))); | |
538 | - n._data && !a.isEmptyObject(n._data) && a.each(n._data, function (a, b) { | |
539 | - "index" !== a && (q += c(' data-%s="%s"', a, b)) | |
540 | - }), g.push("<tr", c(" %s", s.join(" ")), c(' id="%s"', a.isArray(n) ? void 0 : n._id), c(' class="%s"', o.classes || (a.isArray(n) ? void 0 : n._class)), c(' data-index="%s"', k), c(' data-uniqueid="%s"', n[this.options.uniqueId]), c("%s", q), ">"), this.options.cardView && g.push(c('<td colspan="%s"><div class="card-views">', this.header.fields.length)), !this.options.cardView && this.options.detailView && g.push("<td>", '<a class="detail-icon" href="javascript:">', c('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.detailOpen), "</a>", "</td>"), a.each(this.header.fields, function (b, e) { | |
541 | - var i = "", j = m(n, e, f.options.escape), l = "", q = {}, r = "", s = f.header.classes[b], t = "", | |
542 | - u = "", v = "", w = "", x = f.columns[b]; | |
543 | - if (!(f.fromHtml && "undefined" == typeof j || !x.visible || f.options.cardView && !x.cardVisible)) { | |
544 | - if (o = c('style="%s"', p.concat(f.header.styles[b]).join("; ")), n["_" + e + "_id"] && (r = c(' id="%s"', n["_" + e + "_id"])), n["_" + e + "_class"] && (s = c(' class="%s"', n["_" + e + "_class"])), n["_" + e + "_rowspan"] && (u = c(' rowspan="%s"', n["_" + e + "_rowspan"])), n["_" + e + "_colspan"] && (v = c(' colspan="%s"', n["_" + e + "_colspan"])), n["_" + e + "_title"] && (w = c(' title="%s"', n["_" + e + "_title"])), q = h(f.header, f.header.cellStyles[b], [j, n, k, e], q), q.classes && (s = c(' class="%s"', q.classes)), q.css) { | |
545 | - var y = []; | |
546 | - for (var z in q.css) y.push(z + ": " + q.css[z]); | |
547 | - o = c('style="%s"', y.concat(f.header.styles[b]).join("; ")) | |
548 | - } | |
549 | - j = h(x, f.header.formatters[b], [j, n, k], j), n["_" + e + "_data"] && !a.isEmptyObject(n["_" + e + "_data"]) && a.each(n["_" + e + "_data"], function (a, b) { | |
550 | - "index" !== a && (t += c(' data-%s="%s"', a, b)) | |
551 | - }), x.checkbox || x.radio ? (l = x.checkbox ? "checkbox" : l, l = x.radio ? "radio" : l, i = [c(f.options.cardView ? '<div class="card-view %s">' : '<td class="bs-checkbox %s">', x["class"] || ""), "<input" + c(' data-index="%s"', k) + c(' name="%s"', f.options.selectItemName) + c(' type="%s"', l) + c(' value="%s"', n[f.options.idField]) + c(' checked="%s"', j === !0 || j && j.checked ? "checked" : void 0) + c(' disabled="%s"', !x.checkboxEnabled || j && j.disabled ? "disabled" : void 0) + " />", f.header.formatters[b] && "string" == typeof j ? j : "", f.options.cardView ? "</div>" : "</td>"].join(""), n[f.header.stateField] = j === !0 || j && j.checked) : (j = "undefined" == typeof j || null === j ? f.options.undefinedText : j, i = f.options.cardView ? ['<div class="card-view">', f.options.showHeader ? c('<span class="title" %s>%s</span>', o, d(f.columns, "field", "title", e)) : "", c('<span class="value">%s</span>', j), "</div>"].join("") : [c("<td%s %s %s %s %s %s %s>", r, s, o, t, u, v, w), j, "</td>"].join(""), f.options.cardView && f.options.smartDisplay && "" === j && (i = '<div class="card-view"></div>')), g.push(i) | |
552 | - } | |
553 | - }), this.options.cardView && g.push("</div></td>"), g.push("</tr>") | |
554 | - } | |
555 | - g.length || g.push('<tr class="no-records-found">', c('<td colspan="%s">%s</td>', this.$header.find("th").length, this.options.formatNoMatches()), "</tr>"), this.$body.html(g.join("")), b || this.scrollTo(0), this.$body.find("> tr[data-index] > td").off("click dblclick").on("click dblclick", function (b) { | |
556 | - var d = a(this), g = d.parent(), h = f.data[g.data("index")], i = d[0].cellIndex, j = f.getVisibleFields(), | |
557 | - k = j[f.options.detailView && !f.options.cardView ? i - 1 : i], l = f.columns[e(f.columns, k)], | |
558 | - n = m(h, k, f.options.escape); | |
559 | - if (!d.find(".detail-icon").length && (f.trigger("click" === b.type ? "click-cell" : "dbl-click-cell", k, n, h, d), f.trigger("click" === b.type ? "click-row" : "dbl-click-row", h, g, k), | |
560 | - "click" === b.type && f.options.clickToSelect && l.clickToSelect)) { | |
561 | - var o = g.find(c('[name="%s"]', f.options.selectItemName)); | |
562 | - o.length && o[0].click() | |
563 | - } | |
564 | - }), this.$body.find("> tr[data-index] > td > .detail-icon").off("click").on("click", function () { | |
565 | - var b = a(this), d = b.parent().parent(), e = d.data("index"), g = i[e]; | |
566 | - if (d.next().is("tr.detail-view")) b.find("i").attr("class", c("%s %s", f.options.iconsPrefix, f.options.icons.detailOpen)), d.next().remove(), f.trigger("collapse-row", e, g); else { | |
567 | - b.find("i").attr("class", c("%s %s", f.options.iconsPrefix, f.options.icons.detailClose)), d.after(c('<tr class="detail-view"><td colspan="%s"></td></tr>', d.find("td").length)); | |
568 | - var j = d.next().find("td"), k = h(f.options, f.options.detailFormatter, [e, g, j], ""); | |
569 | - 1 === j.length && j.append(k), f.trigger("expand-row", e, g, j) | |
570 | - } | |
571 | - f.resetView() | |
572 | - }), this.$selectItem = this.$body.find(c('[name="%s"]', this.options.selectItemName)), this.$selectItem.off("click").on("click", function (b) { | |
573 | - b.stopImmediatePropagation(); | |
574 | - var c = a(this), d = c.prop("checked"), e = f.data[c.data("index")]; | |
575 | - f.options.maintainSelected && a(this).is(":radio") && a.each(f.options.data, function (a, b) { | |
576 | - b[f.header.stateField] = !1 | |
577 | - }), e[f.header.stateField] = d, f.options.singleSelect && (f.$selectItem.not(this).each(function () { | |
578 | - f.data[a(this).data("index")][f.header.stateField] = !1 | |
579 | - }), f.$selectItem.filter(":checked").not(this).prop("checked", !1)), f.updateSelected(), f.trigger(d ? "check" : "uncheck", e, c) | |
580 | - }), a.each(this.header.events, function (b, c) { | |
581 | - if (c) { | |
582 | - "string" == typeof c && (c = h(null, c)); | |
583 | - var d = f.header.fields[b], e = a.inArray(d, f.getVisibleFields()); | |
584 | - f.options.detailView && !f.options.cardView && (e += 1); | |
585 | - for (var g in c) f.$body.find(">tr:not(.no-records-found)").each(function () { | |
586 | - var b = a(this), h = b.find(f.options.cardView ? ".card-view" : "td").eq(e), i = g.indexOf(" "), | |
587 | - j = g.substring(0, i), k = g.substring(i + 1), l = c[g]; | |
588 | - h.find(k).off(j).on(j, function (a) { | |
589 | - var c = b.data("index"), e = f.data[c], g = e[d]; | |
590 | - l.apply(this, [a, g, e, c]) | |
591 | - }) | |
592 | - }) | |
593 | - } | |
594 | - }), this.updateSelected(), this.resetView(), this.trigger("post-body", i) | |
595 | - }, p.prototype.initServer = function (b, c, d) { | |
596 | - var e, f = this, g = {}, | |
597 | - i = {searchText: this.searchText, sortName: this.options.sortName, sortOrder: this.options.sortOrder}; | |
598 | - this.options.pagination && (i.pageSize = this.options.pageSize === this.options.formatAllRows() ? this.options.totalRows : this.options.pageSize, i.pageNumber = this.options.pageNumber), (d || this.options.url || this.options.ajax) && ("limit" === this.options.queryParamsType && (i = { | |
599 | - search: i.searchText, | |
600 | - sort: i.sortName, | |
601 | - order: i.sortOrder | |
602 | - }, this.options.pagination && (i.offset = this.options.pageSize === this.options.formatAllRows() ? 0 : this.options.pageSize * (this.options.pageNumber - 1), i.limit = this.options.pageSize === this.options.formatAllRows() ? this.options.totalRows : this.options.pageSize)), a.isEmptyObject(this.filterColumnsPartial) || (i.filter = JSON.stringify(this.filterColumnsPartial, null)), g = h(this.options, this.options.queryParams, [i], g), a.extend(g, c || {}), g !== !1 && (b || this.$tableLoading.show(), e = a.extend({}, h(null, this.options.ajaxOptions), { | |
603 | - type: this.options.method, | |
604 | - url: d || this.options.url, | |
605 | - data: "application/json" === this.options.contentType && "post" === this.options.method ? JSON.stringify(g) : g, | |
606 | - cache: this.options.cache, | |
607 | - contentType: this.options.contentType, | |
608 | - dataType: this.options.dataType, | |
609 | - success: function (a) { | |
610 | - a = h(f.options, f.options.responseHandler, [a], a), f.load(a), f.trigger("load-success", a), b || f.$tableLoading.hide() | |
611 | - }, | |
612 | - error: function (a) { | |
613 | - f.trigger("load-error", a.status, a), b || f.$tableLoading.hide() | |
614 | - } | |
615 | - }), this.options.ajax ? h(this, this.options.ajax, [e], null) : (this._xhr && 4 !== this._xhr.readyState && this._xhr.abort(), this._xhr = a.ajax(e)))) | |
616 | - }, p.prototype.initSearchText = function () { | |
617 | - if (this.options.search && "" !== this.options.searchText) { | |
618 | - var a = this.$toolbar.find(".search input"); | |
619 | - a.val(this.options.searchText), this.onSearch({currentTarget: a}) | |
620 | - } | |
621 | - }, p.prototype.getCaret = function () { | |
622 | - var b = this; | |
623 | - a.each(this.$header.find("th"), function (c, d) { | |
624 | - a(d).find(".sortable").removeClass("desc asc").addClass(a(d).data("field") === b.options.sortName ? b.options.sortOrder : "both") | |
625 | - }) | |
626 | - }, p.prototype.updateSelected = function () { | |
627 | - var b = this.$selectItem.filter(":enabled").length && this.$selectItem.filter(":enabled").length === this.$selectItem.filter(":enabled").filter(":checked").length; | |
628 | - this.$selectAll.add(this.$selectAll_).prop("checked", b), this.$selectItem.each(function () { | |
629 | - a(this).closest("tr")[a(this).prop("checked") ? "addClass" : "removeClass"]("selected") | |
630 | - }) | |
631 | - }, p.prototype.updateRows = function () { | |
632 | - var b = this; | |
633 | - this.$selectItem.each(function () { | |
634 | - b.data[a(this).data("index")][b.header.stateField] = a(this).prop("checked") | |
635 | - }) | |
636 | - }, p.prototype.resetRows = function () { | |
637 | - var b = this; | |
638 | - a.each(this.data, function (a, c) { | |
639 | - b.$selectAll.prop("checked", !1), b.$selectItem.prop("checked", !1), b.header.stateField && (c[b.header.stateField] = !1) | |
640 | - }) | |
641 | - }, p.prototype.trigger = function (b) { | |
642 | - var c = Array.prototype.slice.call(arguments, 1); | |
643 | - b += ".bs.table", this.options[p.EVENTS[b]].apply(this.options, c), this.$el.trigger(a.Event(b), c), this.options.onAll(b, c), this.$el.trigger(a.Event("all.bs.table"), [b, c]) | |
644 | - }, p.prototype.resetHeader = function () { | |
645 | - clearTimeout(this.timeoutId_), this.timeoutId_ = setTimeout(a.proxy(this.fitHeader, this), this.$el.is(":hidden") ? 100 : 0) | |
646 | - }, p.prototype.fitHeader = function () { | |
647 | - var b, d, e, f, h = this; | |
648 | - if (h.$el.is(":hidden")) return void(h.timeoutId_ = setTimeout(a.proxy(h.fitHeader, h), 100)); | |
649 | - if (b = this.$tableBody.get(0), d = b.scrollWidth > b.clientWidth && b.scrollHeight > b.clientHeight + this.$header.outerHeight() ? g() : 0, this.$el.css("margin-top", -this.$header.outerHeight()), e = a(":focus"), e.length > 0) { | |
650 | - var i = e.parents("th"); | |
651 | - if (i.length > 0) { | |
652 | - var j = i.attr("data-field"); | |
653 | - if (void 0 !== j) { | |
654 | - var k = this.$header.find("[data-field='" + j + "']"); | |
655 | - k.length > 0 && k.find(":input").addClass("focus-temp") | |
656 | - } | |
657 | - } | |
658 | - } | |
659 | - this.$header_ = this.$header.clone(!0, !0), this.$selectAll_ = this.$header_.find('[name="btSelectAll"]'), this.$tableHeader.css({"margin-right": d}).find("table").css("width", this.$el.outerWidth()).html("").attr("class", this.$el.attr("class")).append(this.$header_), f = a(".focus-temp:visible:eq(0)"), f.length > 0 && (f.focus(), this.$header.find(".focus-temp").removeClass("focus-temp")), this.$header.find("th[data-field]").each(function () { | |
660 | - h.$header_.find(c('th[data-field="%s"]', a(this).data("field"))).data(a(this).data()) | |
661 | - }); | |
662 | - var l = this.getVisibleFields(), m = this.$header_.find("th"); | |
663 | - this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function (b) { | |
664 | - var d = a(this), e = b; | |
665 | - h.options.detailView && !h.options.cardView && (0 === b && h.$header_.find("th.detail").find(".fht-cell").width(d.innerWidth()), e = b - 1); | |
666 | - var f = h.$header_.find(c('th[data-field="%s"]', l[e])); | |
667 | - f.length > 1 && (f = a(m[d[0].cellIndex])), f.find(".fht-cell").width(d.innerWidth()) | |
668 | - }), this.$tableBody.off("scroll").on("scroll", function () { | |
669 | - h.$tableHeader.scrollLeft(a(this).scrollLeft()), h.options.showFooter && !h.options.cardView && h.$tableFooter.scrollLeft(a(this).scrollLeft()) | |
670 | - }), h.trigger("post-header") | |
671 | - }, p.prototype.resetFooter = function () { | |
672 | - var b = this, d = b.getData(), e = []; | |
673 | - this.options.showFooter && !this.options.cardView && (!this.options.cardView && this.options.detailView && e.push('<td><div class="th-inner"> </div><div class="fht-cell"></div></td>'), a.each(this.columns, function (a, f) { | |
674 | - var g, i = "", j = "", k = [], l = {}, m = c(' class="%s"', f["class"]); | |
675 | - if (f.visible && (!b.options.cardView || f.cardVisible)) { | |
676 | - if (i = c("text-align: %s; ", f.falign ? f.falign : f.align), j = c("vertical-align: %s; ", f.valign), l = h(null, b.options.footerStyle), l && l.css) for (g in l.css) k.push(g + ": " + l.css[g]); | |
677 | - e.push("<td", m, c(' style="%s"', i + j + k.concat().join("; ")), ">"), e.push('<div class="th-inner">'), e.push(h(f, f.footerFormatter, [d], " ") || " "), e.push("</div>"), e.push('<div class="fht-cell"></div>'), e.push("</div>"), e.push("</td>") | |
678 | - } | |
679 | - }), this.$tableFooter.find("tr").html(e.join("")), this.$tableFooter.show(), clearTimeout(this.timeoutFooter_), this.timeoutFooter_ = setTimeout(a.proxy(this.fitFooter, this), this.$el.is(":hidden") ? 100 : 0)) | |
680 | - }, p.prototype.fitFooter = function () { | |
681 | - var b, c, d; | |
682 | - return clearTimeout(this.timeoutFooter_), this.$el.is(":hidden") ? void(this.timeoutFooter_ = setTimeout(a.proxy(this.fitFooter, this), 100)) : (c = this.$el.css("width"), d = c > this.$tableBody.width() ? g() : 0, this.$tableFooter.css({"margin-right": d}).find("table").css("width", c).attr("class", this.$el.attr("class")), b = this.$tableFooter.find("td"), void this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function (c) { | |
683 | - var d = a(this); | |
684 | - b.eq(c).find(".fht-cell").width(d.innerWidth()) | |
685 | - })) | |
686 | - }, p.prototype.toggleColumn = function (a, b, d) { | |
687 | - if (-1 !== a && (this.columns[a].visible = b, this.initHeader(), this.initSearch(), this.initPagination(), this.initBody(), this.options.showColumns)) { | |
688 | - var e = this.$toolbar.find(".keep-open input").prop("disabled", !1); | |
689 | - d && e.filter(c('[value="%s"]', a)).prop("checked", b), e.filter(":checked").length <= this.options.minimumCountColumns && e.filter(":checked").prop("disabled", !0) | |
690 | - } | |
691 | - }, p.prototype.toggleRow = function (a, b, d) { | |
692 | - -1 !== a && this.$body.find("undefined" != typeof a ? c('tr[data-index="%s"]', a) : c('tr[data-uniqueid="%s"]', b))[d ? "show" : "hide"]() | |
693 | - }, p.prototype.getVisibleFields = function () { | |
694 | - var b = this, c = []; | |
695 | - return a.each(this.header.fields, function (a, d) { | |
696 | - var f = b.columns[e(b.columns, d)]; | |
697 | - f.visible && c.push(d) | |
698 | - }), c | |
699 | - }, p.prototype.resetView = function (a) { | |
700 | - var b = 0; | |
701 | - if (a && a.height && (this.options.height = a.height), this.$selectAll.prop("checked", this.$selectItem.length > 0 && this.$selectItem.length === this.$selectItem.filter(":checked").length), this.options.height) { | |
702 | - var c = k(this.$toolbar), d = k(this.$pagination), e = this.options.height - c - d; | |
703 | - this.$tableContainer.css("height", e + "px") | |
704 | - } | |
705 | - return this.options.cardView ? (this.$el.css("margin-top", "0"), this.$tableContainer.css("padding-bottom", "0"), void this.$tableFooter.hide()) : (this.options.showHeader && this.options.height ? (this.$tableHeader.show(), this.resetHeader(), b += this.$header.outerHeight()) : (this.$tableHeader.hide(), this.trigger("post-header")), this.options.showFooter && (this.resetFooter(), this.options.height && (b += this.$tableFooter.outerHeight() + 1)), this.getCaret(), this.$tableContainer.css("padding-bottom", b + "px"), void this.trigger("reset-view")) | |
706 | - }, p.prototype.getData = function (b) { | |
707 | - return !this.searchText && a.isEmptyObject(this.filterColumns) && a.isEmptyObject(this.filterColumnsPartial) ? b ? this.options.data.slice(this.pageFrom - 1, this.pageTo) : this.options.data : b ? this.data.slice(this.pageFrom - 1, this.pageTo) : this.data | |
708 | - }, p.prototype.load = function (b) { | |
709 | - var c = !1; | |
710 | - "server" === this.options.sidePagination ? (this.options.totalRows = b.total, c = b.fixedScroll, b = b[this.options.dataField]) : a.isArray(b) || (c = b.fixedScroll, b = b.data), this.initData(b), this.initSearch(), this.initPagination(), this.initBody(c) | |
711 | - }, p.prototype.append = function (a) { | |
712 | - this.initData(a, "append"), this.initSearch(), this.initPagination(), this.initSort(), this.initBody(!0) | |
713 | - }, p.prototype.prepend = function (a) { | |
714 | - this.initData(a, "prepend"), this.initSearch(), this.initPagination(), this.initSort(), this.initBody(!0) | |
715 | - }, p.prototype.remove = function (b) { | |
716 | - var c, d, e = this.options.data.length; | |
717 | - if (b.hasOwnProperty("field") && b.hasOwnProperty("values")) { | |
718 | - for (c = e - 1; c >= 0; c--) d = this.options.data[c], d.hasOwnProperty(b.field) && -1 !== a.inArray(d[b.field], b.values) && this.options.data.splice(c, 1); | |
719 | - e !== this.options.data.length && (this.initSearch(), this.initPagination(), this.initSort(), this.initBody(!0)) | |
720 | - } | |
721 | - }, p.prototype.removeAll = function () { | |
722 | - this.options.data.length > 0 && (this.options.data.splice(0, this.options.data.length), this.initSearch(), this.initPagination(), this.initBody(!0)) | |
723 | - }, p.prototype.getRowByUniqueId = function (a) { | |
724 | - var b, c, d, e = this.options.uniqueId, f = this.options.data.length, g = null; | |
725 | - for (b = f - 1; b >= 0; b--) { | |
726 | - if (c = this.options.data[b], c.hasOwnProperty(e)) d = c[e]; else { | |
727 | - if (!c._data.hasOwnProperty(e)) continue; | |
728 | - d = c._data[e] | |
729 | - } | |
730 | - if ("string" == typeof d ? a = a.toString() : "number" == typeof d && (Number(d) === d && d % 1 === 0 ? a = parseInt(a) : d === Number(d) && 0 !== d && (a = parseFloat(a))), d === a) { | |
731 | - g = c; | |
732 | - break | |
733 | - } | |
734 | - } | |
735 | - return g | |
736 | - }, p.prototype.removeByUniqueId = function (a) { | |
737 | - var b = this.options.data.length, c = this.getRowByUniqueId(a); | |
738 | - c && this.options.data.splice(this.options.data.indexOf(c), 1), b !== this.options.data.length && (this.initSearch(), this.initPagination(), this.initBody(!0)) | |
739 | - }, p.prototype.updateByUniqueId = function (b) { | |
740 | - var c = this, d = a.isArray(b) ? b : [b]; | |
741 | - a.each(d, function (b, d) { | |
742 | - var e; | |
743 | - d.hasOwnProperty("id") && d.hasOwnProperty("row") && (e = a.inArray(c.getRowByUniqueId(d.id), c.options.data), -1 !== e && a.extend(c.options.data[e], d.row)) | |
744 | - }), this.initSearch(), this.initSort(), this.initBody(!0) | |
745 | - }, p.prototype.insertRow = function (a) { | |
746 | - a.hasOwnProperty("index") && a.hasOwnProperty("row") && (this.data.splice(a.index, 0, a.row), this.initSearch(), this.initPagination(), this.initSort(), this.initBody(!0)) | |
747 | - }, p.prototype.updateRow = function (b) { | |
748 | - var c = this, d = a.isArray(b) ? b : [b]; | |
749 | - a.each(d, function (b, d) { | |
750 | - d.hasOwnProperty("index") && d.hasOwnProperty("row") && a.extend(c.options.data[d.index], d.row) | |
751 | - }), this.initSearch(), this.initSort(), this.initBody(!0) | |
752 | - }, p.prototype.showRow = function (a) { | |
753 | - (a.hasOwnProperty("index") || a.hasOwnProperty("uniqueId")) && this.toggleRow(a.index, a.uniqueId, !0) | |
754 | - }, p.prototype.hideRow = function (a) { | |
755 | - (a.hasOwnProperty("index") || a.hasOwnProperty("uniqueId")) && this.toggleRow(a.index, a.uniqueId, !1) | |
756 | - }, p.prototype.getRowsHidden = function (b) { | |
757 | - var c = a(this.$body[0]).children().filter(":hidden"), d = 0; | |
758 | - if (b) for (; d < c.length; d++) a(c[d]).show(); | |
759 | - return c | |
760 | - }, p.prototype.mergeCells = function (b) { | |
761 | - var c, d, e, f = b.index, g = a.inArray(b.field, this.getVisibleFields()), h = b.rowspan || 1, | |
762 | - i = b.colspan || 1, j = this.$body.find(">tr"); | |
763 | - if (this.options.detailView && !this.options.cardView && (g += 1), e = j.eq(f).find(">td").eq(g), !(0 > f || 0 > g || f >= this.data.length)) { | |
764 | - for (c = f; f + h > c; c++) for (d = g; g + i > d; d++) j.eq(c).find(">td").eq(d).hide(); | |
765 | - e.attr("rowspan", h).attr("colspan", i).show() | |
766 | - } | |
767 | - }, p.prototype.updateCell = function (a) { | |
768 | - a.hasOwnProperty("index") && a.hasOwnProperty("field") && a.hasOwnProperty("value") && (this.data[a.index][a.field] = a.value, a.reinit !== !1 && (this.initSort(), this.initBody(!0))) | |
769 | - }, p.prototype.getOptions = function () { | |
770 | - return this.options | |
771 | - }, p.prototype.getSelections = function () { | |
772 | - var b = this; | |
773 | - return a.grep(this.options.data, function (a) { | |
774 | - return a[b.header.stateField] | |
775 | - }) | |
776 | - }, p.prototype.getAllSelections = function () { | |
777 | - var b = this; | |
778 | - return a.grep(this.options.data, function (a) { | |
779 | - return a[b.header.stateField] | |
780 | - }) | |
781 | - }, p.prototype.checkAll = function () { | |
782 | - this.checkAll_(!0) | |
783 | - }, p.prototype.uncheckAll = function () { | |
784 | - this.checkAll_(!1) | |
785 | - },p.prototype.getRowByIndex = function (index) { | |
786 | - if((index * 1+1)>this.options.data.length){ | |
787 | - throw new Error("Unknown method: 没有当前序号!"); | |
788 | - } | |
789 | - return this.options.data[index * 1]; | |
790 | - }, p.prototype.checkInvert = function () { | |
791 | - var b = this, c = b.$selectItem.filter(":enabled"), d = c.filter(":checked"); | |
792 | - c.each(function () { | |
793 | - a(this).prop("checked", !a(this).prop("checked")) | |
794 | - }), b.updateRows(), b.updateSelected(), b.trigger("uncheck-some", d), d = b.getSelections(), b.trigger("check-some", d) | |
795 | - }, p.prototype.checkAll_ = function (a) { | |
796 | - var b; | |
797 | - a || (b = this.getSelections()), this.$selectAll.add(this.$selectAll_).prop("checked", a), this.$selectItem.filter(":enabled").prop("checked", a), this.updateRows(), a && (b = this.getSelections()), this.trigger(a ? "check-all" : "uncheck-all", b) | |
798 | - }, p.prototype.check = function (a) { | |
799 | - this.check_(!0, a) | |
800 | - }, p.prototype.uncheck = function (a) { | |
801 | - this.check_(!1, a) | |
802 | - }, p.prototype.check_ = function (a, b) { | |
803 | - var d = this.$selectItem.filter(c('[data-index="%s"]', b)).prop("checked", a); | |
804 | - this.data[b][this.header.stateField] = a, this.updateSelected(), this.trigger(a ? "check" : "uncheck", this.data[b], d) | |
805 | - }, p.prototype.checkBy = function (a) { | |
806 | - this.checkBy_(!0, a) | |
807 | - }, p.prototype.uncheckBy = function (a) { | |
808 | - this.checkBy_(!1, a) | |
809 | - }, p.prototype.checkBy_ = function (b, d) { | |
810 | - if (d.hasOwnProperty("field") && d.hasOwnProperty("values")) { | |
811 | - var e = this, f = []; | |
812 | - a.each(this.options.data, function (g, h) { | |
813 | - if (!h.hasOwnProperty(d.field)) return !1; | |
814 | - if (-1 !== a.inArray(h[d.field], d.values)) { | |
815 | - var i = e.$selectItem.filter(":enabled").filter(c('[data-index="%s"]', g)).prop("checked", b); | |
816 | - h[e.header.stateField] = b, f.push(h), e.trigger(b ? "check" : "uncheck", h, i) | |
817 | - } | |
818 | - }), this.updateSelected(), this.trigger(b ? "check-some" : "uncheck-some", f) | |
819 | - } | |
820 | - }, p.prototype.destroy = function () { | |
821 | - this.$el.insertBefore(this.$container), a(this.options.toolbar).insertBefore(this.$el), this.$container.next().remove(), this.$container.remove(), this.$el.html(this.$el_.html()).css("margin-top", "0").attr("class", this.$el_.attr("class") || "") | |
822 | - }, p.prototype.showLoading = function () { | |
823 | - this.$tableLoading.show() | |
824 | - }, p.prototype.hideLoading = function () { | |
825 | - this.$tableLoading.hide() | |
826 | - }, p.prototype.togglePagination = function () { | |
827 | - this.options.pagination = !this.options.pagination; | |
828 | - var a = this.$toolbar.find('button[name="paginationSwitch"] i'); | |
829 | - this.options.pagination ? a.attr("class", this.options.iconsPrefix + " " + this.options.icons.paginationSwitchDown) : a.attr("class", this.options.iconsPrefix + " " + this.options.icons.paginationSwitchUp), this.updatePagination() | |
830 | - }, p.prototype.refresh = function (a) { | |
831 | - a && a.url && (this.options.pageNumber = 1), this.initServer(a && a.silent, a && a.query, a && a.url), this.trigger("refresh", a) | |
832 | - }, p.prototype.resetWidth = function () { | |
833 | - this.options.showHeader && this.options.height && this.fitHeader(), this.options.showFooter && this.fitFooter() | |
834 | - }, p.prototype.showColumn = function (a) { | |
835 | - this.toggleColumn(e(this.columns, a), !0, !0) | |
836 | - }, p.prototype.hideColumn = function (a) { | |
837 | - this.toggleColumn(e(this.columns, a), !1, !0) | |
838 | - }, p.prototype.getHiddenColumns = function () { | |
839 | - return a.grep(this.columns, function (a) { | |
840 | - return !a.visible | |
841 | - }) | |
842 | - }, p.prototype.getVisibleColumns = function () { | |
843 | - return a.grep(this.columns, function (a) { | |
844 | - return a.visible | |
845 | - }) | |
846 | - }, p.prototype.toggleAllColumns = function (b) { | |
847 | - if (a.each(this.columns, function (a) { | |
848 | - this.columns[a].visible = b | |
849 | - }), this.initHeader(), this.initSearch(), this.initPagination(), this.initBody(), this.options.showColumns) { | |
850 | - var c = this.$toolbar.find(".keep-open input").prop("disabled", !1); | |
851 | - c.filter(":checked").length <= this.options.minimumCountColumns && c.filter(":checked").prop("disabled", !0) | |
852 | - } | |
853 | - }, p.prototype.showAllColumns = function () { | |
854 | - this.toggleAllColumns(!0) | |
855 | - }, p.prototype.hideAllColumns = function () { | |
856 | - this.toggleAllColumns(!1) | |
857 | - }, p.prototype.filterBy = function (b) { | |
858 | - this.filterColumns = a.isEmptyObject(b) ? {} : b, this.options.pageNumber = 1, this.initSearch(), this.updatePagination() | |
859 | - }, p.prototype.scrollTo = function (a) { | |
860 | - return "string" == typeof a && (a = "bottom" === a ? this.$tableBody[0].scrollHeight : 0), "number" == typeof a && this.$tableBody.scrollTop(a), "undefined" == typeof a ? this.$tableBody.scrollTop() : void 0 | |
861 | - }, p.prototype.getScrollPosition = function () { | |
862 | - return this.scrollTo() | |
863 | - }, p.prototype.selectPage = function (a) { | |
864 | - a > 0 && a <= this.options.totalPages && (this.options.pageNumber = a, this.updatePagination()) | |
865 | - }, p.prototype.prevPage = function () { | |
866 | - this.options.pageNumber > 1 && (this.options.pageNumber--, this.updatePagination()) | |
867 | - }, p.prototype.nextPage = function () { | |
868 | - this.options.pageNumber < this.options.totalPages && (this.options.pageNumber++, this.updatePagination()) | |
869 | - }, p.prototype.toggleView = function () { | |
870 | - this.options.cardView = !this.options.cardView, this.initHeader(), this.initBody(), this.trigger("toggle", this.options.cardView) | |
871 | - }, p.prototype.refreshOptions = function (b) { | |
872 | - i(this.options, b, !0) || (this.options = a.extend(this.options, b), this.trigger("refresh-options", this.options), this.destroy(), this.init()) | |
873 | - }, p.prototype.resetSearch = function (a) { | |
874 | - var b = this.$toolbar.find(".search input"); | |
875 | - b.val(a || ""), this.onSearch({currentTarget: b}) | |
876 | - }, p.prototype.expandRow_ = function (a, b) { | |
877 | - var d = this.$body.find(c('> tr[data-index="%s"]', b)); | |
878 | - d.next().is("tr.detail-view") === (a ? !1 : !0) && d.find("> td > .detail-icon").click() | |
879 | - }, p.prototype.expandRow = function (a) { | |
880 | - this.expandRow_(!0, a) | |
881 | - }, p.prototype.collapseRow = function (a) { | |
882 | - this.expandRow_(!1, a) | |
883 | - }, p.prototype.expandAllRows = function (b) { | |
884 | - if (b) { | |
885 | - var d = this.$body.find(c('> tr[data-index="%s"]', 0)), e = this, f = null, g = !1, h = -1; | |
886 | - if (d.next().is("tr.detail-view") ? d.next().next().is("tr.detail-view") || (d.next().find(".detail-icon").click(), g = !0) : (d.find("> td > .detail-icon").click(), g = !0), g) try { | |
887 | - h = setInterval(function () { | |
888 | - f = e.$body.find("tr.detail-view").last().find(".detail-icon"), f.length > 0 ? f.click() : clearInterval(h) | |
889 | - }, 1) | |
890 | - } catch (i) { | |
891 | - clearInterval(h) | |
892 | - } | |
893 | - } else for (var j = this.$body.children(), k = 0; k < j.length; k++) this.expandRow_(!0, a(j[k]).data("index")) | |
894 | - }, p.prototype.collapseAllRows = function (b) { | |
895 | - if (b) this.expandRow_(!1, 0); else for (var c = this.$body.children(), d = 0; d < c.length; d++) this.expandRow_(!1, a(c[d]).data("index")) | |
896 | - }, p.prototype.updateFormatText = function (a, b) { | |
897 | - this.options[c("format%s", a)] && ("string" == typeof b ? this.options[c("format%s", a)] = function () { | |
898 | - return b | |
899 | - } : "function" == typeof b && (this.options[c("format%s", a)] = b)), this.initToolbar(), this.initPagination(), this.initBody() | |
900 | - }; | |
901 | - var q = ["getOptions", "getSelections", "getAllSelections", "getData", "load", "append", "prepend", "remove", "removeAll", "insertRow", "updateRow", "updateCell", "updateByUniqueId", "removeByUniqueId", "getRowByUniqueId", "showRow", "hideRow", "getRowsHidden", "mergeCells", "checkAll", "uncheckAll", "checkInvert", "check", "uncheck", "checkBy", "uncheckBy", "refresh", "resetView", "resetWidth", "destroy", "showLoading", "hideLoading", "showColumn", "hideColumn", "getHiddenColumns", "getVisibleColumns", "showAllColumns", "hideAllColumns", "filterBy", "scrollTo", "getScrollPosition", "selectPage", "prevPage", "nextPage", "togglePagination", "toggleView", "refreshOptions", "resetSearch", "expandRow", "collapseRow", "expandAllRows", "collapseAllRows", "updateFormatText","getRowByIndex"]; | |
902 | - a.fn.bootstrapTable = function (b) { | |
903 | - var c, d = Array.prototype.slice.call(arguments, 1); | |
904 | - return this.each(function () { | |
905 | - var e = a(this), f = e.data("bootstrap.table"), | |
906 | - g = a.extend({}, p.DEFAULTS, e.data(), "object" == typeof b && b); | |
907 | - if ("string" == typeof b) { | |
908 | - if (a.inArray(b, q) < 0) throw new Error("Unknown method: " + b); | |
909 | - if (!f) return; | |
910 | - c = f[b].apply(f, d), "destroy" === b && e.removeData("bootstrap.table") | |
911 | - } | |
912 | - f || e.data("bootstrap.table", f = new p(this, g)) | |
913 | - }), "undefined" == typeof c ? this : c | |
914 | - }, a.fn.bootstrapTable.Constructor = p, a.fn.bootstrapTable.defaults = p.DEFAULTS, a.fn.bootstrapTable.columnDefaults = p.COLUMN_DEFAULTS, a.fn.bootstrapTable.locales = p.LOCALES, a.fn.bootstrapTable.methods = q, a.fn.bootstrapTable.utils = { | |
915 | - sprintf: c, | |
916 | - getFieldIndex: e, | |
917 | - compareObjects: i, | |
918 | - calculateObjectValue: h, | |
919 | - getItemField: m, | |
920 | - objectKeys: o, | |
921 | - isIEBrowser: n | |
922 | - }, a(function () { | |
923 | - a('[data-toggle="table"]').bootstrapTable() | |
924 | - }) | |
925 | -}(jQuery); | |
926 | 1 | \ No newline at end of file |
2 | +/** | |
3 | + * @author zhixin wen <wenzhixin2010@gmail.com> | |
4 | + * version: 1.11.0 | |
5 | + * https://github.com/wenzhixin/bootstrap-table/ | |
6 | + */ | |
7 | +(function(j){var k=null;var m=function(u){var s=arguments,r=true,t=1;u=u.replace(/%s/g,function(){var v=s[t++];if(typeof v==="undefined"){r=false;return""}return v});return r?u:""};var c=function(t,v,u,s){var r="";j.each(t,function(w,x){if(x[v]===s){r=x[u];return false}return true});return r};var i=function(s,t){var r=-1;j.each(s,function(u,v){if(v.field===t){r=u;return false}return true});return r};var l=function(u){var y,x,w,A=0,B=[];for(y=0;y<u[0].length;y++){A+=u[0][y].colspan||1}for(y=0;y<u.length;y++){B[y]=[];for(x=0;x<A;x++){B[y][x]=false}}for(y=0;y<u.length;y++){for(x=0;x<u[y].length;x++){var s=u[y][x],v=s.rowspan||1,t=s.colspan||1,z=j.inArray(false,B[y]);if(t===1){s.fieldIndex=z;if(typeof s.field==="undefined"){s.field=z}}for(w=0;w<v;w++){B[y+w][z]=true}for(w=0;w<t;w++){B[y][z+w]=true}}}};var a=function(){if(k===null){var t=j("<p/>").addClass("fixed-table-scroll-inner"),u=j("<div/>").addClass("fixed-table-scroll-outer"),s,r;u.append(t);j("body").append(u);s=t[0].offsetWidth;u.css("overflow","scroll");r=t[0].offsetWidth;if(s===r){r=u[0].clientWidth}u.remove();k=s-r}return k};var q=function(s,u,t,r){var v=u;if(typeof u==="string"){var w=u.split(".");if(w.length>1){v=window;j.each(w,function(x,y){v=v[y]})}else{v=window[u]}}if(typeof v==="object"){return v}if(typeof v==="function"){return v.apply(s,t)}if(!v&&typeof u==="string"&&m.apply(this,[u].concat(t))){return m.apply(this,[u].concat(t))}return r};var f=function(s,r,w){var x=Object.getOwnPropertyNames(s),u=Object.getOwnPropertyNames(r),v="";if(w){if(x.length!==u.length){return false}}for(var t=0;t<x.length;t++){v=x[t];if(j.inArray(v,u)>-1){if(s[v]!==r[v]){return false}}}return true};var p=function(r){if(typeof r==="string"){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/`/g,"`")}return r};var d=function(s){var r=0;s.children().each(function(){if(r<j(this).outerHeight(true)){r=j(this).outerHeight(true)}});return r};var g=function(t){for(var r in t){var s=r.split(/(?=[A-Z])/).join("-").toLowerCase();if(s!==r){t[s]=t[r];delete t[r]}}return t};var o=function(t,w,s){var u=t;if(typeof w!=="string"||t.hasOwnProperty(w)){return s?p(t[w]):t[w]}var r=w.split(".");for(var v in r){u=u&&u[r[v]]}return s?p(u):u};var b=function(){return !!(navigator.userAgent.indexOf("MSIE ")>0||!!navigator.userAgent.match(/Trident.*rv\:11\./))};var h=function(){if(!Object.keys){Object.keys=(function(){var t=Object.prototype.hasOwnProperty,u=!({toString:null}).propertyIsEnumerable("toString"),s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],r=s.length;return function(x){if(typeof x!=="object"&&(typeof x!=="function"||x===null)){throw new TypeError("Object.keys called on non-object")}var v=[],y,w;for(y in x){if(t.call(x,y)){v.push(y)}}if(u){for(w=0;w<r;w++){if(t.call(x,s[w])){v.push(s[w])}}}return v}}())}};var e=function(s,r){this.options=r;this.$el=j(s);this.$el_=this.$el.clone();this.timeoutId_=0;this.timeoutFooter_=0;this.init()};e.DEFAULTS={id:undefined,classes:"table table-hover",locale:undefined,height:undefined,undefinedText:"-",sortName:undefined,sortOrder:"asc",sortStable:false,striped:false,columns:[[]],data:[],dataField:"rows",method:"get",url:undefined,ajax:undefined,cache:true,contentType:"application/json",dataType:"json",ajaxOptions:{},queryParams:function(r){return r},queryParamsType:"limit",responseHandler:function(r){return r},pagination:false,onlyInfoPagination:false,sidePagination:"client",totalRows:0,pageNumber:1,pageSize:10,pageList:[10,25,50,100],paginationHAlign:"right",paginationVAlign:"bottom",paginationDetailHAlign:"left",paginationPreText:"‹",paginationNextText:"›",search:false,searchOnEnterKey:false,strictSearch:false,searchAlign:"right",selectItemName:"btSelectItem",showHeader:true,showFooter:false,showColumns:false,showSearch:false,showPageGo:false,showPaginationSwitch:false,showRefresh:false,showToggle:false,buttonsAlign:"right",smartDisplay:true,escape:false,firstLoad:true,minimumCountColumns:1,idField:undefined,uniqueId:undefined,cardView:false,detailView:false,detailFormatter:function(r,s){return""},trimOnSearch:true,clickToSelect:false,singleSelect:false,toolbar:undefined,toolbarAlign:"left",checkboxHeader:true,sortable:true,silentSort:true,maintainSelected:false,searchTimeOut:500,searchText:"",iconSize:undefined,buttonsClass:"default",iconsPrefix:"glyphicon",icons:{search:"glyphicon-search",paginationSwitchDown:"glyphicon-collapse-down icon-chevron-down",paginationSwitchUp:"glyphicon-collapse-up icon-chevron-up",refresh:"glyphicon-refresh icon-refresh",toggle:"glyphicon-list-alt icon-list-alt",columns:"glyphicon-th icon-th",detailOpen:"glyphicon-plus icon-plus",detailClose:"glyphicon-minus icon-minus"},customSearch:j.noop,customSort:j.noop,rowStyle:function(s,r){return{}},rowAttributes:function(s,r){return{}},footerStyle:function(s,r){return{}},onAll:function(s,r){return false},onClickCell:function(t,s,u,r){return false},onDblClickCell:function(t,s,u,r){return false},onClickRow:function(s,r){return false},onDblClickRow:function(s,r){return false},onSort:function(s,r){return false},onCheck:function(r){return false},onUncheck:function(r){return false},onCheckAll:function(r){return false},onUncheckAll:function(r){return false},onCheckSome:function(r){return false},onUncheckSome:function(r){return false},onLoadSuccess:function(r){return false},onLoadError:function(r){return false},onColumnSwitch:function(s,r){return false},onPageChange:function(s,r){return false},onSearch:function(r){return false},onShowSearch:function(){return false},onToggle:function(r){return false},onPreBody:function(r){return false},onPostBody:function(){return false},onPostHeader:function(){return false},onExpandRow:function(r,t,s){return false},onCollapseRow:function(r,s){return false},onRefreshOptions:function(r){return false},onRefresh:function(r){return false},onResetView:function(){return false}};e.LOCALES={};e.LOCALES["en-US"]=e.LOCALES.en={formatLoadingMessage:function(){return"Loading, please wait..."},formatRecordsPerPage:function(r){return m("%s rows per page",r)},formatShowingRows:function(t,r,s){return m("Showing %s to %s of %s rows",t,r,s)},formatPageGo:function(){return"跳转"},formatDetailPagination:function(r){return m("Showing %s rows",r)},formatSearch:function(){return"Search"},formatNoMatches:function(){return"No matching records found"},formatPaginationSwitch:function(){return"Hide/Show pagination"},formatRefresh:function(){return"Refresh"},formatToggle:function(){return"Toggle"},formatColumns:function(){return"Columns"},formatAllRows:function(){return"All"}};j.extend(e.DEFAULTS,e.LOCALES["en-US"]);e.COLUMN_DEFAULTS={radio:false,checkbox:false,checkboxEnabled:true,field:undefined,title:undefined,titleTooltip:undefined,"class":undefined,align:undefined,halign:undefined,falign:undefined,valign:undefined,width:undefined,sortable:false,order:"asc",visible:true,switchable:true,clickToSelect:true,formatter:undefined,footerFormatter:undefined,events:undefined,sorter:undefined,sortName:undefined,cellStyle:undefined,searchable:true,searchFormatter:true,cardVisible:true};e.EVENTS={"all.bs.table":"onAll","click-cell.bs.table":"onClickCell","dbl-click-cell.bs.table":"onDblClickCell","click-row.bs.table":"onClickRow","dbl-click-row.bs.table":"onDblClickRow","sort.bs.table":"onSort","check.bs.table":"onCheck","uncheck.bs.table":"onUncheck","check-all.bs.table":"onCheckAll","uncheck-all.bs.table":"onUncheckAll","check-some.bs.table":"onCheckSome","uncheck-some.bs.table":"onUncheckSome","load-success.bs.table":"onLoadSuccess","load-error.bs.table":"onLoadError","column-switch.bs.table":"onColumnSwitch","page-change.bs.table":"onPageChange","search.bs.table":"onSearch","toggle.bs.table":"onToggle","show-search.bs.table":"onShowSearch","pre-body.bs.table":"onPreBody","post-body.bs.table":"onPostBody","post-header.bs.table":"onPostHeader","expand-row.bs.table":"onExpandRow","collapse-row.bs.table":"onCollapseRow","refresh-options.bs.table":"onRefreshOptions","reset-view.bs.table":"onResetView","refresh.bs.table":"onRefresh"};e.prototype.init=function(){this.initLocale();this.initContainer();this.initTable();this.initHeader();this.initData();this.initFooter();this.initToolbar();this.initPagination();this.initBody();this.initSearchText();this.initServer()};e.prototype.initLocale=function(){if(this.options.locale){var r=this.options.locale.split(/-|_/);r[0].toLowerCase();if(r[1]){r[1].toUpperCase()}if(j.fn.bootstrapTable.locales[this.options.locale]){j.extend(this.options,j.fn.bootstrapTable.locales[this.options.locale])}else{if(j.fn.bootstrapTable.locales[r.join("-")]){j.extend(this.options,j.fn.bootstrapTable.locales[r.join("-")])}else{if(j.fn.bootstrapTable.locales[r[0]]){j.extend(this.options,j.fn.bootstrapTable.locales[r[0]])}}}}};e.prototype.initContainer=function(){this.$container=j(['<div class="bootstrap-table">','<div class="fixed-table-toolbar"></div>',this.options.paginationVAlign==="top"||this.options.paginationVAlign==="both"?'<div class="fixed-table-pagination" style="clear: both;"></div>':"",'<div class="fixed-table-container">','<div class="fixed-table-header"><table></table></div>','<div class="fixed-table-body">','<div class="fixed-table-loading">',this.options.formatLoadingMessage(),"</div>","</div>",'<div class="fixed-table-footer"><table><tr></tr></table></div>',this.options.paginationVAlign==="bottom"||this.options.paginationVAlign==="both"?'<div class="fixed-table-pagination"></div>':"","</div>","</div>"].join(""));this.$container.insertAfter(this.$el);this.$tableContainer=this.$container.find(".fixed-table-container");this.$tableHeader=this.$container.find(".fixed-table-header");this.$tableBody=this.$container.find(".fixed-table-body");this.$tableLoading=this.$container.find(".fixed-table-loading");this.$tableFooter=this.$container.find(".fixed-table-footer");this.$toolbar=this.$container.find(".fixed-table-toolbar");this.$pagination=this.$container.find(".fixed-table-pagination");this.$tableBody.append(this.$el);this.$container.after('<div class="clearfix"></div>');this.$el.addClass(this.options.classes);if(this.options.striped){this.$el.addClass("table-striped")}if(j.inArray("table-no-bordered",this.options.classes.split(" "))!==-1){this.$tableContainer.addClass("table-no-bordered")}};e.prototype.initTable=function(){var t=this,s=[],u=[];this.$header=this.$el.find(">thead");if(!this.$header.length){this.$header=j("<thead></thead>").appendTo(this.$el)}this.$header.find("tr").each(function(){var v=[];j(this).find("th").each(function(){if(typeof j(this).data("field")!=="undefined"){j(this).data("field",j(this).data("field")+"")}v.push(j.extend({},{title:j(this).html(),"class":j(this).attr("class"),titleTooltip:j(this).attr("title"),rowspan:j(this).attr("rowspan")?+j(this).attr("rowspan"):undefined,colspan:j(this).attr("colspan")?+j(this).attr("colspan"):undefined},j(this).data()))});s.push(v)});if(!j.isArray(this.options.columns[0])){this.options.columns=[this.options.columns]}this.options.columns=j.extend(true,[],s,this.options.columns);this.columns=[];l(this.options.columns);j.each(this.options.columns,function(w,v){j.each(v,function(x,y){y=j.extend({},e.COLUMN_DEFAULTS,y);if(typeof y.fieldIndex!=="undefined"){t.columns[y.fieldIndex]=y}t.options.columns[w][x]=y})});if(this.options.data.length){return}var r=[];this.$el.find(">tbody>tr").each(function(w){var v={};v._id=j(this).attr("id");v._class=j(this).attr("class");v._data=g(j(this).data());j(this).find(">td").each(function(z){var E=j(this),B=+E.attr("colspan")||1,C=+E.attr("rowspan")||1,A,y;for(;r[w]&&r[w][z];z++){}for(A=z;A<z+B;A++){for(y=w;y<w+C;y++){if(!r[y]){r[y]=[]}r[y][A]=true}}var D=t.columns[z].field;v[D]=j(this).html();v["_"+D+"_id"]=j(this).attr("id");v["_"+D+"_class"]=j(this).attr("class");v["_"+D+"_rowspan"]=j(this).attr("rowspan");v["_"+D+"_colspan"]=j(this).attr("colspan");v["_"+D+"_title"]=j(this).attr("title");v["_"+D+"_data"]=g(j(this).data())});u.push(v)});this.options.data=u;if(u.length){this.fromHtml=true}};e.prototype.initHeader=function(){var t=this,r={},s=[];this.header={fields:[],styles:[],classes:[],formatters:[],events:[],sorters:[],sortNames:[],cellStyles:[],searchables:[]};j.each(this.options.columns,function(v,u){s.push("<tr>");if(v===0&&!t.options.cardView&&t.options.detailView){s.push(m('<th class="detail" rowspan="%s"><div class="fht-cell"></div></th>',t.options.columns.length))}j.each(u,function(B,A){var F="",C="",E="",w="",D=m(' class="%s"',A["class"]),z=t.options.sortOrder||A.order,y="px",x=A.width;if(A.width!==undefined&&(!t.options.cardView)){if(typeof A.width==="string"){if(A.width.indexOf("%")!==-1){y="%"}}}if(A.width&&typeof A.width==="string"){x=A.width.replace("%","").replace("px","")}C=m("text-align: %s; ",A.halign?A.halign:A.align);E=m("text-align: %s; ",A.align);w=m("vertical-align: %s; ",A.valign);w+=m("width: %s; ",(A.checkbox||A.radio)&&!x?"36px":(x?x+y:undefined));if(typeof A.fieldIndex!=="undefined"){t.header.fields[A.fieldIndex]=A.field;t.header.styles[A.fieldIndex]=E+w;t.header.classes[A.fieldIndex]=D;t.header.formatters[A.fieldIndex]=A.formatter;t.header.events[A.fieldIndex]=A.events;t.header.sorters[A.fieldIndex]=A.sorter;t.header.sortNames[A.fieldIndex]=A.sortName;t.header.cellStyles[A.fieldIndex]=A.cellStyle;t.header.searchables[A.fieldIndex]=A.searchable;if(!A.visible){return}if(t.options.cardView&&(!A.cardVisible)){return}r[A.field]=A}s.push("<th"+m(' title="%s"',A.titleTooltip),A.checkbox||A.radio?m(' class="bs-checkbox %s"',A["class"]||""):D,m(' style="%s"',C+w),m(' rowspan="%s"',A.rowspan),m(' colspan="%s"',A.colspan),m(' data-field="%s"',A.field),"tabindex='0'",">");s.push(m('<div class="th-inner %s">',t.options.sortable&&A.sortable?"sortable both":""));F=A.title;if(A.checkbox){if(!t.options.singleSelect&&t.options.checkboxHeader){F='<input name="btSelectAll" type="checkbox" />'}t.header.stateField=A.field}if(A.radio){F="";t.header.stateField=A.field;t.options.singleSelect=true}s.push(F);s.push("</div>");s.push('<div class="fht-cell"></div>');s.push("</div>");s.push("</th>")});s.push("</tr>")});this.$header.html(s.join(""));this.$header.find("th[data-field]").each(function(u){j(this).data(r[j(this).data("field")])});this.$container.off("click",".th-inner").on("click",".th-inner",function(u){var v=j(this);if(t.options.detailView){if(v.closest(".bootstrap-table")[0]!==t.$container[0]){return false}}if(t.options.sortable&&v.parent().data().sortable){t.onSort(u)}});this.$header.children().children().off("keypress").on("keypress",function(v){if(t.options.sortable&&j(this).data().sortable){var u=v.keyCode||v.which;if(u==13){t.onSort(v)}}});j(window).off("resize.bootstrap-table");if(!this.options.showHeader||this.options.cardView){this.$header.hide();this.$tableHeader.hide();this.$tableLoading.css("top",0)}else{this.$header.show();this.$tableHeader.show();this.$tableLoading.css("top",this.$header.outerHeight()+1);this.getCaret();j(window).on("resize.bootstrap-table",j.proxy(this.resetWidth,this))}this.$selectAll=this.$header.find('[name="btSelectAll"]');this.$selectAll.off("click").on("click",function(){var u=j(this).prop("checked");t[u?"checkAll":"uncheckAll"]();t.updateSelected()})};e.prototype.initFooter=function(){if(!this.options.showFooter||this.options.cardView){this.$tableFooter.hide()}else{this.$tableFooter.show()}};e.prototype.initData=function(s,r){if(r==="append"){this.data=this.data.concat(s)}else{if(r==="prepend"){this.data=[].concat(s).concat(this.data)}else{this.data=s||this.options.data}}if(r==="append"){this.options.data=this.options.data.concat(s)}else{if(r==="prepend"){this.options.data=[].concat(s).concat(this.options.data)}else{this.options.data=this.data}}if(this.options.sidePagination==="server"){return}this.initSort()};e.prototype.initSort=function(){var u=this,t=this.options.sortName,r=this.options.sortOrder==="desc"?-1:1,s=j.inArray(this.options.sortName,this.header.fields);if(this.options.customSort!==j.noop){this.options.customSort.apply(this,[this.options.sortName,this.options.sortOrder]);return}if(s!==-1){if(this.options.sortStable){j.each(this.data,function(v,w){if(!w.hasOwnProperty("_position")){w._position=v}})}this.data.sort(function(w,v){if(u.header.sortNames[s]){t=u.header.sortNames[s]}var y=o(w,t,u.options.escape),z=o(v,t,u.options.escape),x=q(u.header,u.header.sorters[s],[y,z]);if(x!==undefined){return r*x}if(y===undefined||y===null){y=""}if(z===undefined||z===null){z=""}if(u.options.sortStable&&y===z){y=w._position;z=v._position}if(j.isNumeric(y)&&j.isNumeric(z)){y=parseFloat(y);z=parseFloat(z);if(y<z){return r*-1}return r}if(y===z){return 0}if(typeof y!=="string"){y=y.toString()}if(y.localeCompare(z)===-1){return r*-1}return r})}};e.prototype.onSort=function(r){var t=r.type==="keypress"?j(r.currentTarget):j(r.currentTarget).parent(),s=this.$header.find("th").eq(t.index());this.$header.add(this.$header_).find("span.order").remove();if(this.options.sortName===t.data("field")){this.options.sortOrder=this.options.sortOrder==="asc"?"desc":"asc"}else{this.options.sortOrder=t.data("order")==="asc"?"desc":"asc"}this.options.sortName=t.data("sortName")?t.data("sortName"):t.data("field");this.trigger("sort",this.options.sortName,this.options.sortOrder);t.add(s).data("order",this.options.sortOrder);this.getCaret();if(this.options.sidePagination==="server"){this.initServer(this.options.silentSort);return}this.initSort();this.initBody()};e.prototype.initToolbar=function(){var u=this,t=[],w=0,s,v,r=0;if(this.$toolbar.find(".bs-bars").children().length){j("body").append(j(this.options.toolbar))}this.$toolbar.html("");if(typeof this.options.toolbar==="string"||typeof this.options.toolbar==="object"){j(m('<div class="bs-bars pull-%s"></div>',this.options.toolbarAlign)).appendTo(this.$toolbar).append(j(this.options.toolbar))}t=[m('<div class="columns columns-%s btn-group pull-%s">',this.options.buttonsAlign,this.options.buttonsAlign)];if(typeof this.options.icons==="string"){this.options.icons=q(null,this.options.icons)}if(this.options.showSearch){t.push(m('<button class="btn'+m(" btn-%s",this.options.buttonsClass)+m(" btn-%s",this.options.iconSize)+'" type="button" name="showSearch" title="%s">',this.options.formatSearch()),m('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.search),"</button>")}if(this.options.showPaginationSwitch){t.push(m('<button class="btn'+m(" btn-%s",this.options.buttonsClass)+m(" btn-%s",this.options.iconSize)+'" type="button" name="paginationSwitch" title="%s">',this.options.formatPaginationSwitch()),m('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.paginationSwitchDown),"</button>")}if(this.options.showRefresh){t.push(m('<button class="btn'+m(" btn-%s",this.options.buttonsClass)+m(" btn-%s",this.options.iconSize)+'" type="button" name="refresh" title="%s">',this.options.formatRefresh()),m('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.refresh),"</button>")}if(this.options.showToggle){t.push(m('<button class="btn'+m(" btn-%s",this.options.buttonsClass)+m(" btn-%s",this.options.iconSize)+'" type="button" name="toggle" title="%s">',this.options.formatToggle()),m('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.toggle),"</button>")}if(this.options.showColumns){t.push(m('<div class="keep-open btn-group" title="%s">',this.options.formatColumns()),'<button type="button" class="btn'+m(" btn-%s",this.options.buttonsClass)+m(" btn-%s",this.options.iconSize)+' dropdown-toggle" data-toggle="dropdown">',m('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.columns),' <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">');j.each(this.columns,function(x,y){if(y.radio||y.checkbox){return}if(u.options.cardView&&!y.cardVisible){return}var z=y.visible?' checked="checked"':"";if(y.switchable){t.push(m("<li>"+'<label><input type="checkbox" data-field="%s" value="%s"%s> %s</label>'+"</li>",y.field,x,z,y.title));r++}});t.push("</ul>","</div>")}t.push("</div>");if(this.showToolbar||t.length>2){this.$toolbar.append(t.join(""))}if(this.options.showPaginationSwitch){this.$toolbar.find('button[name="paginationSwitch"]').off("click").on("click",j.proxy(this.togglePagination,this))}if(this.options.showRefresh){this.$toolbar.find('button[name="refresh"]').off("click").on("click",j.proxy(this.refresh,this))}if(this.options.showToggle){this.$toolbar.find('button[name="toggle"]').off("click").on("click",function(){u.toggleView()})}if(this.options.showSearch){this.$toolbar.find('button[name="showSearch"]').off("click").on("click",function(){j(this).parents(".select-table").siblings().slideToggle()})}if(this.options.showColumns){s=this.$toolbar.find(".keep-open");if(r<=this.options.minimumCountColumns){s.find("input").prop("disabled",true)}s.find("li").off("click").on("click",function(x){x.stopImmediatePropagation()});s.find("input").off("click").on("click",function(){var x=j(this);u.toggleColumn(j(this).val(),x.prop("checked"),false);u.trigger("column-switch",j(this).data("field"),x.prop("checked"))})}if(this.options.search){t=[];t.push('<div class="pull-'+this.options.searchAlign+' search">',m('<input class="form-control'+m(" input-%s",this.options.iconSize)+'" type="text" placeholder="%s">',this.options.formatSearch()),"</div>");this.$toolbar.append(t.join(""));v=this.$toolbar.find(".search input");v.off("keyup drop").on("keyup drop",function(x){if(u.options.searchOnEnterKey&&x.keyCode!==13){return}if(j.inArray(x.keyCode,[37,38,39,40])>-1){return}clearTimeout(w);w=setTimeout(function(){u.onSearch(x)},u.options.searchTimeOut)});if(b()){v.off("mouseup").on("mouseup",function(x){clearTimeout(w);w=setTimeout(function(){u.onSearch(x)},u.options.searchTimeOut)})}}};e.prototype.onSearch=function(r){var s=j.trim(j(r.currentTarget).val());if(this.options.trimOnSearch&&j(r.currentTarget).val()!==s){j(r.currentTarget).val(s)}if(s===this.searchText){return}this.searchText=s;this.options.searchText=s;this.options.pageNumber=1;this.initSearch();this.updatePagination();this.trigger("search",s)};e.prototype.initSearch=function(){var t=this;if(this.options.sidePagination!=="server"){if(this.options.customSearch!==j.noop){this.options.customSearch.apply(this,[this.searchText]);return}var r=this.searchText&&(this.options.escape?p(this.searchText):this.searchText).toLowerCase();var u=j.isEmptyObject(this.filterColumns)?null:this.filterColumns;this.data=u?j.grep(this.options.data,function(w,v){for(var s in u){if(j.isArray(u[s])&&j.inArray(w[s],u[s])===-1||w[s]!==u[s]){return false}}return true}):this.options.data;this.data=r?j.grep(this.data,function(A,x){for(var v=0;v<t.header.fields.length;v++){if(!t.header.searchables[v]){continue}var w=j.isNumeric(t.header.fields[v])?parseInt(t.header.fields[v],10):t.header.fields[v];var z=t.columns[i(t.columns,w)];var B;if(typeof w==="string"){B=A;var y=w.split(".");for(var s=0;s<y.length;s++){B=B[y[s]]}if(z&&z.searchFormatter){B=q(z,t.header.formatters[v],[B,A,x],B)}}else{B=A[w]}if(typeof B==="string"||typeof B==="number"){if(t.options.strictSearch){if((B+"").toLowerCase()===r){return true}}else{if((B+"").toLowerCase().indexOf(r)!==-1){return true}}}}return false}):this.data}};e.prototype.initPagination=function(){if(!this.options.pagination){this.$pagination.hide();return}else{this.$pagination.show()}var v=this,x=[],r=false,A,z,s,w,G,I,E,y,u,J=this.getData(),t=this.options.pageList;if(this.options.sidePagination!=="server"){this.options.totalRows=J.length}this.totalPages=0;if(this.options.totalRows){if(this.options.pageSize===this.options.formatAllRows()){this.options.pageSize=this.options.totalRows;r=true}else{if(this.options.pageSize===this.options.totalRows){var H=typeof this.options.pageList==="string"?this.options.pageList.replace("[","").replace("]","").replace(/ /g,"").toLowerCase().split(","):this.options.pageList;if(j.inArray(this.options.formatAllRows().toLowerCase(),H)>-1){r=true}}}this.totalPages=~~((this.options.totalRows-1)/this.options.pageSize)+1;this.options.totalPages=this.totalPages}if(this.totalPages>0&&this.options.pageNumber>this.totalPages){this.options.pageNumber=this.totalPages}this.pageFrom=(this.options.pageNumber-1)*this.options.pageSize+1;this.pageTo=this.options.pageNumber*this.options.pageSize;if(this.pageTo>this.options.totalRows){this.pageTo=this.options.totalRows}x.push('<div class="pull-'+this.options.paginationDetailHAlign+' pagination-detail">','<span class="pagination-info">',this.options.onlyInfoPagination?this.options.formatDetailPagination(this.options.totalRows):this.options.formatShowingRows(this.pageFrom,this.pageTo,this.options.totalRows),"</span>");if(!this.options.onlyInfoPagination){x.push('<span class="page-list">');var F=[m('<span class="btn-group %s">',this.options.paginationVAlign==="top"||this.options.paginationVAlign==="both"?"dropdown":"dropup"),'<button type="button" class="btn'+m(" btn-%s",this.options.buttonsClass)+m(" btn-%s",this.options.iconSize)+' dropdown-toggle" data-toggle="dropdown">','<span class="page-size">',r?this.options.formatAllRows():this.options.pageSize,"</span>",' <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">'];if(typeof this.options.pageList==="string"){var D=this.options.pageList.replace("[","").replace("]","").replace(/ /g,"").split(",");t=[];j.each(D,function(K,L){t.push(L.toUpperCase()===v.options.formatAllRows().toUpperCase()?v.options.formatAllRows():+L)})}j.each(t,function(K,L){if(!v.options.smartDisplay||K===0||t[K-1]<=v.options.totalRows){var M;if(r){M=L===v.options.formatAllRows()?' class="active"':""}else{M=L===v.options.pageSize?' class="active"':""}F.push(m('<li%s><a href="javascript:void(0)">%s</a></li>',M,L))}});F.push("</ul></span>");x.push(this.options.formatRecordsPerPage(F.join("")));x.push("</span>");x.push("</div>",'<div class="pull-'+this.options.paginationHAlign+' pagination">','<ul class="pagination'+m(" pagination-%s",this.options.iconSize)+'">','<li class="page-pre"><a href="javascript:void(0)">'+this.options.paginationPreText+"</a></li>");if(this.totalPages<5){z=1;s=this.totalPages}else{z=this.options.pageNumber-2;s=z+4;if(z<1){z=1;s=5}if(s>this.totalPages){s=this.totalPages;z=s-4}}if(this.totalPages>=6){if(this.options.pageNumber>=3){x.push('<li class="page-first'+(1===this.options.pageNumber?" active":"")+'">','<a href="javascript:void(0)">',1,"</a>","</li>");z++}if(this.options.pageNumber>=4){if(this.options.pageNumber==4||this.totalPages==6||this.totalPages==7){z--}else{x.push('<li class="page-first-separator disabled">','<a href="javascript:void(0)">...</a>',"</li>")}s--}}if(this.totalPages>=7){if(this.options.pageNumber>=(this.totalPages-2)){z--}}if(this.totalPages==6){if(this.options.pageNumber>=(this.totalPages-2)){s++}}else{if(this.totalPages>=7){if(this.totalPages==7||this.options.pageNumber>=(this.totalPages-3)){s++}}}for(A=z;A<=s;A++){x.push('<li class="page-number'+(A===this.options.pageNumber?" active":"")+'">','<a href="javascript:void(0)">',A,"</a>","</li>")}if(this.totalPages>=8){if(this.options.pageNumber<=(this.totalPages-4)){x.push('<li class="page-last-separator disabled">','<a href="javascript:void(0)">...</a>',"</li>")}}if(this.totalPages>=6){if(this.options.pageNumber<=(this.totalPages-3)){x.push('<li class="page-last'+(this.totalPages===this.options.pageNumber?" active":"")+'">','<a href="javascript:void(0)">',this.totalPages,"</a>","</li>")}}x.push('<li class="page-next"><a href="javascript:void(0)">'+this.options.paginationNextText+"</a></li>","</ul>","</div>")}this.$pagination.html(x.join(""));if(!this.options.onlyInfoPagination){w=this.$pagination.find(".page-list a");G=this.$pagination.find(".page-first");I=this.$pagination.find(".page-pre");E=this.$pagination.find(".page-next");y=this.$pagination.find(".page-last");u=this.$pagination.find(".page-number");if(this.options.smartDisplay){if(this.totalPages<=1){this.$pagination.find("div.pagination").hide()}if(t.length<2||this.options.totalRows<=t[0]){this.$pagination.find("span.page-list").hide()}this.$pagination[this.getData().length?"show":"hide"]()}if(r){this.options.pageSize=this.options.formatAllRows()}w.off("click").on("click",j.proxy(this.onPageListChange,this));G.off("click").on("click",j.proxy(this.onPageFirst,this));I.off("click").on("click",j.proxy(this.onPagePre,this));E.off("click").on("click",j.proxy(this.onPageNext,this));y.off("click").on("click",j.proxy(this.onPageLast,this));u.off("click").on("click",j.proxy(this.onPageNumber,this))}if(this.options.showPageGo){var v=this,C=this.$pagination.find("ul.pagination"),B=C.find("li.pageGo");if(!B.length){B=j(['<li class="pageGo">',m('<input type="text" class="form-control" value="%s">',this.options.pageNumber),'<button class="btn'+m(" btn-%s",this.options.buttonsClass)+m(" btn-%s",this.options.iconSize)+'" title="'+this.options.formatPageGo()+'" '+' type="button">'+this.options.formatPageGo(),"</button>","</li>"].join("")).appendTo(C);B.find("button").click(function(){var K=parseInt(B.find("input").val())||1;if(K<1||K>v.options.totalPages){K=1}v.selectPage(K)})}}};e.prototype.updatePagination=function(r){if(r&&j(r.currentTarget).hasClass("disabled")){return}if(!this.options.maintainSelected){this.resetRows()}this.initPagination();if(this.options.sidePagination==="server"){this.initServer()}else{this.initBody()}this.trigger("page-change",this.options.pageNumber,this.options.pageSize)};e.prototype.onPageListChange=function(r){var s=j(r.currentTarget);s.parent().addClass("active").siblings().removeClass("active");this.options.pageSize=s.text().toUpperCase()===this.options.formatAllRows().toUpperCase()?this.options.formatAllRows():+s.text();this.$toolbar.find(".page-size").text(this.options.pageSize);this.updatePagination(r)};e.prototype.onPageFirst=function(r){this.options.pageNumber=1;this.updatePagination(r)};e.prototype.onPagePre=function(r){if((this.options.pageNumber-1)===0){this.options.pageNumber=this.options.totalPages}else{this.options.pageNumber--}this.updatePagination(r)};e.prototype.onPageNext=function(r){if((this.options.pageNumber+1)>this.options.totalPages){this.options.pageNumber=1}else{this.options.pageNumber++}this.updatePagination(r)};e.prototype.onPageLast=function(r){this.options.pageNumber=this.totalPages;this.updatePagination(r)};e.prototype.onPageNumber=function(r){if(this.options.pageNumber===+j(r.currentTarget).text()){return}this.options.pageNumber=+j(r.currentTarget).text();this.updatePagination(r)};e.prototype.initBody=function(x){var z=this,y=[],v=this.getData();this.trigger("pre-body",v);this.$body=this.$el.find(">tbody");if(!this.$body.length){this.$body=j("<tbody></tbody>").appendTo(this.$el)}if(!this.options.pagination||this.options.sidePagination==="server"){this.pageFrom=1;this.pageTo=v.length}for(var w=this.pageFrom-1;w<this.pageTo;w++){var B,C=v[w],r={},s=[],t="",u={},A=[];r=q(this.options,this.options.rowStyle,[C,w],r);if(r&&r.css){for(B in r.css){s.push(B+": "+r.css[B])}}u=q(this.options,this.options.rowAttributes,[C,w],u);if(u){for(B in u){A.push(m('%s="%s"',B,p(u[B])))}}if(C._data&&!j.isEmptyObject(C._data)){j.each(C._data,function(E,D){if(E==="index"){return}t+=m(' data-%s="%s"',E,D)})}y.push("<tr",m(" %s",A.join(" ")),m(' id="%s"',j.isArray(C)?undefined:C._id),m(' class="%s"',r.classes||(j.isArray(C)?undefined:C._class)),m(' data-index="%s"',w),m(' data-uniqueid="%s"',C[this.options.uniqueId]),m("%s",t),">");if(this.options.cardView){y.push(m('<td colspan="%s"><div class="card-views">',this.header.fields.length))}if(!this.options.cardView&&this.options.detailView){y.push("<td>",'<a class="detail-icon" href="javascript:">',m('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.detailOpen),"</a>","</td>")}j.each(this.header.fields,function(I,L){var P="",M=o(C,L,z.options.escape),K="",E={},Q="",J=z.header.classes[I],G="",O="",R="",H="",F=z.columns[I];if(z.fromHtml&&typeof M==="undefined"){return}if(!F.visible){return}if(z.options.cardView&&!F.cardVisible){return}r=m('style="%s"',s.concat(z.header.styles[I]).join("; "));if(C["_"+L+"_id"]){Q=m(' id="%s"',C["_"+L+"_id"])}if(C["_"+L+"_class"]){J=m(' class="%s"',C["_"+L+"_class"])}if(C["_"+L+"_rowspan"]){O=m(' rowspan="%s"',C["_"+L+"_rowspan"])}if(C["_"+L+"_colspan"]){R=m(' colspan="%s"',C["_"+L+"_colspan"])}if(C["_"+L+"_title"]){H=m(' title="%s"',C["_"+L+"_title"])}E=q(z.header,z.header.cellStyles[I],[M,C,w,L],E);if(E.classes){J=m(' class="%s"',E.classes)}if(E.css){var D=[];for(var N in E.css){D.push(N+": "+E.css[N])}r=m('style="%s"',D.concat(z.header.styles[I]).join("; "))}M=q(F,z.header.formatters[I],[M,C,w],M);if(C["_"+L+"_data"]&&!j.isEmptyObject(C["_"+L+"_data"])){j.each(C["_"+L+"_data"],function(T,S){if(T==="index"){return}G+=m(' data-%s="%s"',T,S)})}if(F.checkbox||F.radio){K=F.checkbox?"checkbox":K;K=F.radio?"radio":K;P=[m(z.options.cardView?'<div class="card-view %s">':'<td class="bs-checkbox %s">',F["class"]||""),"<input"+m(' data-index="%s"',w)+m(' name="%s"',z.options.selectItemName)+m(' type="%s"',K)+m(' value="%s"',C[z.options.idField])+m(' checked="%s"',M===true||(M&&M.checked)?"checked":undefined)+m(' disabled="%s"',!F.checkboxEnabled||(M&&M.disabled)?"disabled":undefined)+" />",z.header.formatters[I]&&typeof M==="string"?M:"",z.options.cardView?"</div>":"</td>"].join("");C[z.header.stateField]=M===true||(M&&M.checked)}else{M=typeof M==="undefined"||M===null?z.options.undefinedText:M;P=z.options.cardView?['<div class="card-view">',z.options.showHeader?m('<span class="title" %s>%s</span>',r,c(z.columns,"field","title",L)):"",m('<span class="value">%s</span>',M),"</div>"].join(""):[m("<td%s %s %s %s %s %s %s>",Q,J,r,G,O,R,H),M,"</td>"].join("");if(z.options.cardView&&z.options.smartDisplay&&M===""){P='<div class="card-view"></div>'}}y.push(P)});if(this.options.cardView){y.push("</div></td>")}y.push("</tr>")}if(!y.length){y.push('<tr class="no-records-found">',m('<td colspan="%s">%s</td>',this.$header.find("th").length,this.options.formatNoMatches()),"</tr>")}this.$body.html(y.join(""));if(!x){this.scrollTo(0)}this.$body.find("> tr[data-index] > td").off("click dblclick").on("click dblclick",function(J){var D=j(this),F=D.parent(),M=z.data[F.data("index")],H=D[0].cellIndex,G=z.getVisibleFields(),K=G[z.options.detailView&&!z.options.cardView?H-1:H],E=z.columns[i(z.columns,K)],L=o(M,K,z.options.escape);if(D.find(".detail-icon").length){return}z.trigger(J.type==="click"?"click-cell":"dbl-click-cell",K,L,M,D);z.trigger(J.type==="click"?"click-row":"dbl-click-row",M,F,K);if(J.type==="click"&&z.options.clickToSelect&&E.clickToSelect){var I=F.find(m('[name="%s"]',z.options.selectItemName));if(I.length){I[0].click()}}});this.$body.find("> tr[data-index] > td > .detail-icon").off("click").on("click",function(){var H=j(this),G=H.parent().parent(),E=G.data("index"),I=v[E];if(G.next().is("tr.detail-view")){H.find("i").attr("class",m("%s %s",z.options.iconsPrefix,z.options.icons.detailOpen));G.next().remove();z.trigger("collapse-row",E,I)}else{H.find("i").attr("class",m("%s %s",z.options.iconsPrefix,z.options.icons.detailClose));G.after(m('<tr class="detail-view"><td colspan="%s"></td></tr>',G.find("td").length));var D=G.next().find("td");var F=q(z.options,z.options.detailFormatter,[E,I,D],"");if(D.length===1){D.append(F)}z.trigger("expand-row",E,I,D)}z.resetView()});this.$selectItem=this.$body.find(m('[name="%s"]',this.options.selectItemName));this.$selectItem.off("click").on("click",function(E){E.stopImmediatePropagation();var F=j(this),D=F.prop("checked"),G=z.data[F.data("index")];if(z.options.maintainSelected&&j(this).is(":radio")){j.each(z.options.data,function(H,I){I[z.header.stateField]=false})}G[z.header.stateField]=D;if(z.options.singleSelect){z.$selectItem.not(this).each(function(){z.data[j(this).data("index")][z.header.stateField]=false});z.$selectItem.filter(":checked").not(this).prop("checked",false)}z.updateSelected();z.trigger(D?"check":"uncheck",G,F)});j.each(this.header.events,function(G,F){if(!F){return}if(typeof F==="string"){F=q(null,F)}var H=z.header.fields[G],D=j.inArray(H,z.getVisibleFields());if(z.options.detailView&&!z.options.cardView){D+=1}for(var E in F){z.$body.find(">tr:not(.no-records-found)").each(function(){var M=j(this),N=M.find(z.options.cardView?".card-view":"td").eq(D),J=E.indexOf(" "),I=E.substring(0,J),K=E.substring(J+1),L=F[E];N.find(K).off(I).on(I,function(Q){var O=M.data("index"),R=z.data[O],P=R[H];L.apply(this,[Q,P,R,O])})})}});this.updateSelected();this.resetView();this.trigger("post-body",v)};e.prototype.initServer=function(r,w,s){var u=this,v={},x={searchText:this.searchText,sortName:this.options.sortName,sortOrder:this.options.sortOrder},t;if(this.options.pagination){x.pageSize=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize;x.pageNumber=this.options.pageNumber}if(!this.options.firstLoad&&!firstLoadTable.includes(this.options.id)){firstLoadTable.push(this.options.id);return}if(!(s||this.options.url)&&!this.options.ajax){return}if(this.options.queryParamsType==="limit"){x={search:x.searchText,sort:x.sortName,order:x.sortOrder};if(this.options.pagination){x.offset=this.options.pageSize===this.options.formatAllRows()?0:this.options.pageSize*(this.options.pageNumber-1);x.limit=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize}}if(!(j.isEmptyObject(this.filterColumnsPartial))){x.filter=JSON.stringify(this.filterColumnsPartial,null)}v=q(this.options,this.options.queryParams,[x],v);j.extend(v,w||{});if(v===false){return}if(!r){this.$tableLoading.show()}t=j.extend({},q(null,this.options.ajaxOptions),{type:this.options.method,url:s||this.options.url,data:this.options.contentType==="application/json"&&this.options.method==="post"?JSON.stringify(v):v,cache:this.options.cache,contentType:this.options.contentType,dataType:this.options.dataType,success:function(y){y=q(u.options,u.options.responseHandler,[y],y);u.load(y);u.trigger("load-success",y);if(!r){u.$tableLoading.hide()}},error:function(y){u.trigger("load-error",y.status,y);if(!r){u.$tableLoading.hide()}}});if(this.options.ajax){q(this,this.options.ajax,[t],null)}else{if(this._xhr&&this._xhr.readyState!==4){this._xhr.abort()}this._xhr=j.ajax(t)}};e.prototype.initSearchText=function(){if(this.options.search){if(this.options.searchText!==""){var r=this.$toolbar.find(".search input");r.val(this.options.searchText);this.onSearch({currentTarget:r})}}};e.prototype.getCaret=function(){var r=this;j.each(this.$header.find("th"),function(s,t){j(t).find(".sortable").removeClass("desc asc").addClass((j(t).data("field")===r.options.sortName||j(t).data("sortName")===r.options.sortName)?r.options.sortOrder:"both")})};e.prototype.updateSelected=function(){var r=this.$selectItem.filter(":enabled").length&&this.$selectItem.filter(":enabled").length===this.$selectItem.filter(":enabled").filter(":checked").length;var s=j(".left-fixed-table-columns input[name=btSelectItem]");if(s.length>0){r=this.$selectItem.filter(":enabled").length&&this.$selectItem.filter(":enabled").length===s.filter(":enabled").filter(":checked").length}this.$selectAll.add(this.$selectAll_).prop("checked",r);this.$selectItem.each(function(){j(this).closest("tr")[j(this).prop("checked")?"addClass":"removeClass"]("selected")})};e.prototype.updateRows=function(){var r=this;this.$selectItem.each(function(){r.data[j(this).data("index")][r.header.stateField]=j(this).prop("checked")})};e.prototype.resetRows=function(){var r=this;j.each(this.data,function(s,t){r.$selectAll.prop("checked",false);r.$selectItem.prop("checked",false);if(r.header.stateField){t[r.header.stateField]=false}})};e.prototype.trigger=function(s){var r=Array.prototype.slice.call(arguments,1);s+=".bs.table";this.options[e.EVENTS[s]].apply(this.options,r);this.$el.trigger(j.Event(s),r);this.options.onAll(s,r);this.$el.trigger(j.Event("all.bs.table"),[s,r])};e.prototype.resetHeader=function(){clearTimeout(this.timeoutId_);this.timeoutId_=setTimeout(j.proxy(this.fitHeader,this),this.$el.is(":hidden")?100:0)};e.prototype.fitHeader=function(){var t=this,u,r,x,y;if(t.$el.is(":hidden")){t.timeoutId_=setTimeout(j.proxy(t.fitHeader,t),100);return}u=this.$tableBody.get(0);r=u.scrollWidth>u.clientWidth&&u.scrollHeight>u.clientHeight+this.$header.outerHeight()?a():0;this.$el.css("margin-top",-this.$header.outerHeight());x=j(":focus");if(x.length>0){var z=x.parents("th");if(z.length>0){var A=z.attr("data-field");if(A!==undefined){var s=this.$header.find("[data-field='"+A+"']");if(s.length>0){s.find(":input").addClass("focus-temp")}}}}this.$header_=this.$header.clone(true,true);this.$selectAll_=this.$header_.find('[name="btSelectAll"]');this.$tableHeader.css({"margin-right":r}).find("table").css("width",this.$el.outerWidth()).html("").attr("class",this.$el.attr("class")).append(this.$header_);y=j(".focus-temp:visible:eq(0)");if(y.length>0){y.focus();this.$header.find(".focus-temp").removeClass("focus-temp")}this.$header.find("th[data-field]").each(function(B){t.$header_.find(m('th[data-field="%s"]',j(this).data("field"))).data(j(this).data())});var w=this.getVisibleFields(),v=this.$header_.find("th");this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(C){var E=j(this),B=C;if(t.options.detailView&&!t.options.cardView){if(C===0){t.$header_.find("th.detail").find(".fht-cell").width(E.innerWidth())}B=C-1}var D=t.$header_.find(m('th[data-field="%s"]',w[B]));if(D.length>1){D=j(v[E[0].cellIndex])}D.find(".fht-cell").width(E.innerWidth())});this.$tableBody.off("scroll").on("scroll",function(){t.$tableHeader.scrollLeft(j(this).scrollLeft());if(t.options.showFooter&&!t.options.cardView){t.$tableFooter.scrollLeft(j(this).scrollLeft())}});t.trigger("post-header")};e.prototype.resetFooter=function(){var s=this,t=s.getData(),r=[];if(!this.options.showFooter||this.options.cardView){return}if(!this.options.cardView&&this.options.detailView){r.push('<td><div class="th-inner"> </div><div class="fht-cell"></div></td>')}j.each(this.columns,function(x,z){var w,B="",v="",A=[],y={},u=m(' class="%s"',z["class"]);if(!z.visible){return}if(s.options.cardView&&(!z.cardVisible)){return}B=m("text-align: %s; ",z.falign?z.falign:z.align);v=m("vertical-align: %s; ",z.valign);y=q(null,s.options.footerStyle);if(y&&y.css){for(w in y.css){A.push(w+": "+y.css[w])}}r.push("<td",u,m(' style="%s"',B+v+A.concat().join("; ")),">");r.push('<div class="th-inner">');r.push(q(z,z.footerFormatter,[t]," ")||" ");r.push("</div>");r.push('<div class="fht-cell"></div>');r.push("</div>");r.push("</td>")});this.$tableFooter.find("tr").html(r.join(""));this.$tableFooter.show();clearTimeout(this.timeoutFooter_);this.timeoutFooter_=setTimeout(j.proxy(this.fitFooter,this),this.$el.is(":hidden")?100:0)};e.prototype.fitFooter=function(){var u=this,r,t,s;clearTimeout(this.timeoutFooter_);if(this.$el.is(":hidden")){this.timeoutFooter_=setTimeout(j.proxy(this.fitFooter,this),100);return}t=this.$el.css("width");s=t>this.$tableBody.width()?a():0;this.$tableFooter.css({"margin-right":s}).find("table").css("width",t).attr("class",this.$el.attr("class"));r=this.$tableFooter.find("td");this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(v){var w=j(this);r.eq(v).find(".fht-cell").width(w.innerWidth()+1)})};e.prototype.toggleColumn=function(r,s,u){if(r===-1){return}this.columns[r].visible=s;this.initHeader();this.initSearch();this.initPagination();this.initBody();if(this.options.showColumns){var t=this.$toolbar.find(".keep-open input").prop("disabled",false);if(u){t.filter(m('[value="%s"]',r)).prop("checked",s)}if(t.filter(":checked").length<=this.options.minimumCountColumns){t.filter(":checked").prop("disabled",true)}}};e.prototype.toggleRow=function(r,t,s){if(r===-1){return}this.$body.find(typeof r!=="undefined"?m('tr[data-index="%s"]',r):m('tr[data-uniqueid="%s"]',t))[s?"show":"hide"]()};e.prototype.getVisibleFields=function(){var s=this,r=[];j.each(this.header.fields,function(t,v){var u=s.columns[i(s.columns,v)];if(!u.visible){return}r.push(v)});return r};e.prototype.resetView=function(u){var s=0;if(u&&u.height){this.options.height=u.height}this.$selectAll.prop("checked",this.$selectItem.length>0&&this.$selectItem.length===this.$selectItem.filter(":checked").length);if(this.options.height){var t=d(this.$toolbar),v=d(this.$pagination),r=this.options.height-t-v;this.$tableContainer.css("height",r+"px")}if(this.options.cardView){this.$el.css("margin-top","0");this.$tableContainer.css("padding-bottom","0");this.$tableFooter.hide();return}if(this.options.showHeader&&this.options.height){this.$tableHeader.show();this.resetHeader();s+=this.$header.outerHeight()}else{this.$tableHeader.hide();this.trigger("post-header")}if(this.options.showFooter){this.resetFooter();if(this.options.height){s+=this.$tableFooter.outerHeight()+1}}this.getCaret();this.$tableContainer.css("padding-bottom",s+"px");this.trigger("reset-view")};e.prototype.getData=function(r){return(this.searchText||!j.isEmptyObject(this.filterColumns)||!j.isEmptyObject(this.filterColumnsPartial))?(r?this.data.slice(this.pageFrom-1,this.pageTo):this.data):(r?this.options.data.slice(this.pageFrom-1,this.pageTo):this.options.data)};e.prototype.load=function(s){var r=false;if(this.options.sidePagination==="server"){this.options.totalRows=s.total;r=s.fixedScroll;s=s[this.options.dataField]}else{if(!j.isArray(s)){r=s.fixedScroll;s=s.data}}this.initData(s);this.initSearch();this.initPagination();this.initBody(r)};e.prototype.append=function(r){this.initData(r,"append");this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.prepend=function(r){this.initData(r,"prepend");this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.remove=function(u){var r=this.options.data.length,s,t;if(!u.hasOwnProperty("field")||!u.hasOwnProperty("values")){return}for(s=r-1;s>=0;s--){t=this.options.data[s];if(!t.hasOwnProperty(u.field)){continue}if(j.inArray(t[u.field],u.values)!==-1){this.options.data.splice(s,1)}}if(r===this.options.data.length){return}this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.removeAll=function(){if(this.options.data.length>0){this.options.data.splice(0,this.options.data.length);this.initSearch();this.initPagination();this.initBody(true)}};e.prototype.getRowByUniqueId=function(x){var w=this.options.uniqueId,r=this.options.data.length,s=null,t,v,u;for(t=r-1;t>=0;t--){v=this.options.data[t];if(v.hasOwnProperty(w)){u=v[w]}else{if(v._data.hasOwnProperty(w)){u=v._data[w]}else{continue}}if(typeof u==="string"){x=x.toString()}else{if(typeof u==="number"){if((Number(u)===u)&&(u%1===0)){x=parseInt(x)}else{if((u===Number(u))&&(u!==0)){x=parseFloat(x)}}}}if(u===x){s=v;break}}return s};e.prototype.removeByUniqueId=function(t){var r=this.options.data.length,s=this.getRowByUniqueId(t);if(s){this.options.data.splice(this.options.data.indexOf(s),1)}if(r===this.options.data.length){return}this.initSearch();this.initPagination();this.initBody(true)};e.prototype.updateByUniqueId=function(t){var r=this;var s=j.isArray(t)?t:[t];j.each(s,function(u,w){var v;if(!w.hasOwnProperty("id")||!w.hasOwnProperty("row")){return}v=j.inArray(r.getRowByUniqueId(w.id),r.options.data);if(v===-1){return}j.extend(r.options.data[v],w.row)});this.initSearch();this.initSort();this.initBody(true)};e.prototype.insertRow=function(r){if(!r.hasOwnProperty("index")||!r.hasOwnProperty("row")){return}this.data.splice(r.index,0,r.row);this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.updateRow=function(t){var r=this;var s=j.isArray(t)?t:[t];j.each(s,function(u,v){if(!v.hasOwnProperty("index")||!v.hasOwnProperty("row")){return}j.extend(r.options.data[v.index],v.row)});this.initSearch();this.initSort();this.initBody(true)};e.prototype.showRow=function(r){if(!r.hasOwnProperty("index")&&!r.hasOwnProperty("uniqueId")){return}this.toggleRow(r.index,r.uniqueId,true)};e.prototype.hideRow=function(r){if(!r.hasOwnProperty("index")&&!r.hasOwnProperty("uniqueId")){return}this.toggleRow(r.index,r.uniqueId,false)};e.prototype.getRowsHidden=function(r){var t=j(this.$body[0]).children().filter(":hidden"),s=0;if(r){for(;s<t.length;s++){j(t[s]).show()}}return t};e.prototype.mergeCells=function(z){var y=z.index,t=j.inArray(z.field,this.getVisibleFields()),u=z.rowspan||1,s=z.colspan||1,w,v,x=this.$body.find(">tr"),r;if(this.options.detailView&&!this.options.cardView){t+=1}r=x.eq(y).find(">td").eq(t);if(y<0||t<0||y>=this.data.length){return}for(w=y;w<y+u;w++){for(v=t;v<t+s;v++){x.eq(w).find(">td").eq(v).hide()}}r.attr("rowspan",u).attr("colspan",s).show()};e.prototype.updateCell=function(r){if(!r.hasOwnProperty("index")||!r.hasOwnProperty("field")||!r.hasOwnProperty("value")){return}this.data[r.index][r.field]=r.value;if(r.reinit===false){return}this.initSort();this.initBody(true)};e.prototype.getOptions=function(){return this.options};e.prototype.getSelections=function(){var r=this;return j.grep(this.options.data,function(s){return s[r.header.stateField]})};e.prototype.getAllSelections=function(){var r=this;return j.grep(this.options.data,function(s){return s[r.header.stateField]})};e.prototype.checkAll=function(){this.checkAll_(true)};e.prototype.uncheckAll=function(){this.checkAll_(false)};e.prototype.checkInvert=function(){var s=this;var t=s.$selectItem.filter(":enabled");var r=t.filter(":checked");t.each(function(){j(this).prop("checked",!j(this).prop("checked"))});s.updateRows();s.updateSelected();s.trigger("uncheck-some",r);r=s.getSelections();s.trigger("check-some",r)};e.prototype.checkAll_=function(r){var s;if(!r){s=this.getSelections()}this.$selectAll.add(this.$selectAll_).prop("checked",r);this.$selectItem.filter(":enabled").prop("checked",r);this.updateRows();if(r){s=this.getSelections()}this.trigger(r?"check-all":"uncheck-all",s)};e.prototype.check=function(r){this.check_(true,r) | |
8 | +};e.prototype.uncheck=function(r){this.check_(false,r)};e.prototype.check_=function(t,r){var s=this.$selectItem.filter(m('[data-index="%s"]',r)).prop("checked",t);this.data[r][this.header.stateField]=t;this.updateSelected();this.trigger(t?"check":"uncheck",this.data[r],s)};e.prototype.checkBy=function(r){this.checkBy_(true,r)};e.prototype.uncheckBy=function(r){this.checkBy_(false,r)};e.prototype.checkBy_=function(s,u){if(!u.hasOwnProperty("field")||!u.hasOwnProperty("values")){return}var r=this,t=[];j.each(this.options.data,function(v,x){if(!x.hasOwnProperty(u.field)){return false}if(j.inArray(x[u.field],u.values)!==-1){var w=r.$selectItem.filter(":enabled").filter(m('[data-index="%s"]',v)).prop("checked",s);x[r.header.stateField]=s;t.push(x);r.trigger(s?"check":"uncheck",x,w)}});this.updateSelected();this.trigger(s?"check-some":"uncheck-some",t)};e.prototype.destroy=function(){this.$el.insertBefore(this.$container);j(this.options.toolbar).insertBefore(this.$el);this.$container.next().remove();this.$container.remove();this.$el.html(this.$el_.html()).css("margin-top","0").attr("class",this.$el_.attr("class")||"")};e.prototype.showLoading=function(){this.$tableLoading.show()};e.prototype.hideLoading=function(){this.$tableLoading.hide()};e.prototype.togglePagination=function(){this.options.pagination=!this.options.pagination;var r=this.$toolbar.find('button[name="paginationSwitch"] i');if(this.options.pagination){r.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchDown)}else{r.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchUp)}this.updatePagination()};e.prototype.refresh=function(r){if(r&&r.url){this.options.pageNumber=1}table.rememberSelecteds={};table.rememberSelectedIds={};this.initServer(r&&r.silent,r&&r.query,r&&r.url);this.trigger("refresh",r)};e.prototype.resetWidth=function(){if(this.options.showHeader&&this.options.height){this.fitHeader()}if(this.options.showFooter){this.fitFooter()}};e.prototype.showColumn=function(r){this.toggleColumn(i(this.columns,r),true,true)};e.prototype.hideColumn=function(r){this.toggleColumn(i(this.columns,r),false,true)};e.prototype.getHiddenColumns=function(){return j.grep(this.columns,function(r){return !r.visible})};e.prototype.getVisibleColumns=function(){return j.grep(this.columns,function(r){return r.visible})};e.prototype.toggleAllColumns=function(r){j.each(this.columns,function(t,u){this.columns[t].visible=r});this.initHeader();this.initSearch();this.initPagination();this.initBody();if(this.options.showColumns){var s=this.$toolbar.find(".keep-open input").prop("disabled",false);if(s.filter(":checked").length<=this.options.minimumCountColumns){s.filter(":checked").prop("disabled",true)}}};e.prototype.showAllColumns=function(){this.toggleAllColumns(true)};e.prototype.hideAllColumns=function(){this.toggleAllColumns(false)};e.prototype.filterBy=function(r){this.filterColumns=j.isEmptyObject(r)?{}:r;this.options.pageNumber=1;this.initSearch();this.updatePagination()};e.prototype.scrollTo=function(r){if(typeof r==="string"){r=r==="bottom"?this.$tableBody[0].scrollHeight:0}if(typeof r==="number"){this.$tableBody.scrollTop(r)}if(typeof r==="undefined"){return this.$tableBody.scrollTop()}};e.prototype.getScrollPosition=function(){return this.scrollTo()};e.prototype.selectPage=function(r){if(r>0&&r<=this.options.totalPages){this.options.pageNumber=r;this.updatePagination()}};e.prototype.prevPage=function(){if(this.options.pageNumber>1){this.options.pageNumber--;this.updatePagination()}};e.prototype.nextPage=function(){if(this.options.pageNumber<this.options.totalPages){this.options.pageNumber++;this.updatePagination()}};e.prototype.toggleView=function(){this.options.cardView=!this.options.cardView;this.initHeader();this.initBody();this.trigger("toggle",this.options.cardView)};e.prototype.refreshOptions=function(r){if(f(this.options,r,true)){return}this.options=j.extend(this.options,r);this.trigger("refresh-options",this.options);this.destroy();this.init()};e.prototype.resetSearch=function(s){var r=this.$toolbar.find(".search input");r.val(s||"");this.onSearch({currentTarget:r})};e.prototype.expandRow_=function(s,r){var t=this.$body.find(m('> tr[data-index="%s"]',r));if(t.next().is("tr.detail-view")===(s?false:true)){t.find("> td > .detail-icon").click()}};e.prototype.expandRow=function(r){this.expandRow_(true,r)};e.prototype.collapseRow=function(r){this.expandRow_(false,r)};e.prototype.expandAllRows=function(r){if(r){var w=this.$body.find(m('> tr[data-index="%s"]',0)),x=this,u=null,v=false,s=-1;if(!w.next().is("tr.detail-view")){w.find("> td > .detail-icon").click();v=true}else{if(!w.next().next().is("tr.detail-view")){w.next().find(".detail-icon").click();v=true}}if(v){try{s=setInterval(function(){u=x.$body.find("tr.detail-view").last().find(".detail-icon");if(u.length>0){u.click()}else{clearInterval(s)}},1)}catch(z){clearInterval(s)}}}else{var y=this.$body.children();for(var t=0;t<y.length;t++){this.expandRow_(true,j(y[t]).data("index"))}}};e.prototype.collapseAllRows=function(s){if(s){this.expandRow_(false,0)}else{var r=this.$body.children();for(var t=0;t<r.length;t++){this.expandRow_(false,j(r[t]).data("index"))}}};e.prototype.updateFormatText=function(r,s){if(this.options[m("format%s",r)]){if(typeof s==="string"){this.options[m("format%s",r)]=function(){return s}}else{if(typeof s==="function"){this.options[m("format%s",r)]=s}}}this.initToolbar();this.initPagination();this.initBody()};var n=["getOptions","getSelections","getAllSelections","getData","load","append","prepend","remove","removeAll","insertRow","updateRow","updateCell","updateByUniqueId","removeByUniqueId","getRowByUniqueId","showRow","hideRow","getRowsHidden","mergeCells","checkAll","uncheckAll","checkInvert","check","uncheck","checkBy","uncheckBy","refresh","resetView","resetWidth","destroy","showLoading","hideLoading","showColumn","hideColumn","getHiddenColumns","getVisibleColumns","showAllColumns","hideAllColumns","filterBy","scrollTo","getScrollPosition","selectPage","prevPage","nextPage","togglePagination","toggleView","refreshOptions","resetSearch","expandRow","collapseRow","expandAllRows","collapseAllRows","updateFormatText"];j.fn.bootstrapTable=function(s){var t,r=Array.prototype.slice.call(arguments,1);this.each(function(){var w=j(this),v=w.data("bootstrap.table"),u=j.extend({},e.DEFAULTS,w.data(),typeof s==="object"&&s);if(typeof s==="string"){if(j.inArray(s,n)<0){throw new Error("Unknown method: "+s)}if(!v){return}t=v[s].apply(v,r);if(s==="destroy"){w.removeData("bootstrap.table")}}if(!v){w.data("bootstrap.table",(v=new e(this,u)))}});return typeof t==="undefined"?this:t};j.fn.bootstrapTable.Constructor=e;j.fn.bootstrapTable.defaults=e.DEFAULTS;j.fn.bootstrapTable.columnDefaults=e.COLUMN_DEFAULTS;j.fn.bootstrapTable.locales=e.LOCALES;j.fn.bootstrapTable.methods=n;j.fn.bootstrapTable.utils={sprintf:m,getFieldIndex:i,compareObjects:f,calculateObjectValue:q,getItemField:o,objectKeys:h,isIEBrowser:b};j(function(){j('[data-toggle="table"]').bootstrapTable()})})(jQuery);var TABLE_EVENTS="all.bs.table click-cell.bs.table dbl-click-cell.bs.table click-row.bs.table dbl-click-row.bs.table sort.bs.table check.bs.table uncheck.bs.table onUncheck check-all.bs.table uncheck-all.bs.table check-some.bs.table uncheck-some.bs.table load-success.bs.table load-error.bs.table column-switch.bs.table page-change.bs.table search.bs.table toggle.bs.table show-search.bs.table expand-row.bs.table collapse-row.bs.table refresh-options.bs.table reset-view.bs.table refresh.bs.table";var firstLoadTable=[];var union=function(b,a){if($.isArray(a)){$.each(a,function(c,d){if($.inArray(d,b)==-1){b[b.length]=d}})}else{if($.inArray(a,b)==-1){b[b.length]=a}}return b};var difference=function(c,b){if($.isArray(b)){$.each(b,function(e,f){var d=$.inArray(f,c);if(d!=-1){c.splice(d,1)}})}else{var a=$.inArray(b,c);if(a!=-1){c.splice(a,1)}}return c};var _={"union":union,"difference":difference}; | |
927 | 9 | \ No newline at end of file |
... | ... |
src/main/resources/static/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.js
0 → 100644
1 | +/** | |
2 | + * 基于bootstrap-table-fixed-columns修改 | |
3 | + * 支持左右列冻结、支持固定高度 | |
4 | + * Copyright (c) 2019 ruoyi | |
5 | + */ | |
6 | +(function ($) { | |
7 | + 'use strict'; | |
8 | + | |
9 | + $.extend($.fn.bootstrapTable.defaults, { | |
10 | + fixedColumns: false, | |
11 | + fixedNumber: 1, | |
12 | + rightFixedColumns: false, | |
13 | + rightFixedNumber: 1 | |
14 | + }); | |
15 | + | |
16 | + var BootstrapTable = $.fn.bootstrapTable.Constructor, | |
17 | + _initHeader = BootstrapTable.prototype.initHeader, | |
18 | + _initBody = BootstrapTable.prototype.initBody, | |
19 | + _resetView = BootstrapTable.prototype.resetView; | |
20 | + | |
21 | + BootstrapTable.prototype.initFixedColumns = function () { | |
22 | + this.timeoutHeaderColumns_ = 0; | |
23 | + this.timeoutBodyColumns_ = 0; | |
24 | + if (this.options.fixedColumns) { | |
25 | + this.$fixedHeader = $([ | |
26 | + '<div class="left-fixed-table-columns">', | |
27 | + '<table>', | |
28 | + '<thead></thead>', | |
29 | + '</table>', | |
30 | + '</div>'].join('')); | |
31 | + | |
32 | + this.$fixedHeader.find('table').attr('class', this.$el.attr('class')); | |
33 | + this.$fixedHeaderColumns = this.$fixedHeader.find('thead'); | |
34 | + this.$tableHeader.before(this.$fixedHeader); | |
35 | + | |
36 | + this.$fixedBody = $([ | |
37 | + '<div class="left-fixed-body-columns">', | |
38 | + '<table>', | |
39 | + '<tbody></tbody>', | |
40 | + '</table>', | |
41 | + '</div>'].join('')); | |
42 | + | |
43 | + this.$fixedBody.find('table').attr('class', this.$el.attr('class')); | |
44 | + this.$fixedBodyColumns = this.$fixedBody.find('tbody'); | |
45 | + this.$tableBody.before(this.$fixedBody); | |
46 | + } | |
47 | + if (this.options.rightFixedColumns) { | |
48 | + this.$rightfixedBody = $([ | |
49 | + '<div class="right-fixed-table-columns">', | |
50 | + '<table>', | |
51 | + '<thead></thead>', | |
52 | + '<tbody style="background-color: #fff;"></tbody>', | |
53 | + '</table>', | |
54 | + '</div>'].join('')); | |
55 | + this.$rightfixedBody.find('table').attr('class', this.$el.attr('class')); | |
56 | + this.$rightfixedHeaderColumns = this.$rightfixedBody.find('thead'); | |
57 | + this.$rightfixedBodyColumns = this.$rightfixedBody.find('tbody'); | |
58 | + this.$tableBody.before(this.$rightfixedBody); | |
59 | + if (this.options.fixedColumns) { | |
60 | + $('.right-fixed-table-columns').attr('style','right:0px'); | |
61 | + } | |
62 | + } | |
63 | + }; | |
64 | + | |
65 | + BootstrapTable.prototype.initHeader = function () { | |
66 | + _initHeader.apply(this, Array.prototype.slice.apply(arguments)); | |
67 | + | |
68 | + if (!this.options.fixedColumns && !this.options.rightFixedColumns){ | |
69 | + return; | |
70 | + } | |
71 | + this.initFixedColumns(); | |
72 | + | |
73 | + var $ltr = this.$header.find('tr:eq(0)').clone(true), | |
74 | + $rtr = this.$header.find('tr:eq(0)').clone(), | |
75 | + $lths = $ltr.clone(true).find('th'), | |
76 | + $rths = $rtr.clone().find('th'); | |
77 | + | |
78 | + $ltr.html(''); | |
79 | + $rtr.html(''); | |
80 | + //右边列冻结 | |
81 | + if (this.options.rightFixedColumns) { | |
82 | + for (var i = 0; i < this.options.rightFixedNumber; i++) { | |
83 | + $rtr.append($rths.eq($rths.length - this.options.rightFixedNumber + i).clone()); | |
84 | + } | |
85 | + this.$rightfixedHeaderColumns.html('').append($rtr); | |
86 | + } | |
87 | + | |
88 | + //左边列冻结 | |
89 | + if (this.options.fixedColumns) { | |
90 | + for (var i = 0; i < this.options.fixedNumber; i++) { | |
91 | + $ltr.append($lths.eq(i).clone(true)); | |
92 | + } | |
93 | + this.$fixedHeaderColumns.html('').append($ltr); | |
94 | + this.$selectAll = $ltr.find('[name="btSelectAll"]'); | |
95 | + this.$selectAll.on('click', function () { | |
96 | + var checked = $(this).prop('checked'); | |
97 | + $(".left-fixed-body-columns input[name=btSelectItem]").filter(':enabled').prop('checked', checked); | |
98 | + $('.fixed-table-body input[name=btSelectItem]').closest('tr').removeClass('selected'); | |
99 | + }); | |
100 | + } | |
101 | + }; | |
102 | + | |
103 | + BootstrapTable.prototype.initBody = function () { | |
104 | + _initBody.apply(this, Array.prototype.slice.apply(arguments)); | |
105 | + | |
106 | + if (!this.options.fixedColumns && !this.options.rightFixedColumns) { | |
107 | + return; | |
108 | + } | |
109 | + | |
110 | + var that = this; | |
111 | + if (this.options.fixedColumns) { | |
112 | + this.$fixedBodyColumns.html(''); | |
113 | + this.$body.find('> tr[data-index]').each(function () { | |
114 | + var $tr = $(this).clone(true), | |
115 | + $tds = $tr.clone(true).find('td'); | |
116 | + | |
117 | + $tr.html(''); | |
118 | + for (var i = 0; i < that.options.fixedNumber; i++) { | |
119 | + $tr.append($tds.eq(i).clone(true)); | |
120 | + } | |
121 | + that.$fixedBodyColumns.append($tr); | |
122 | + }); | |
123 | + } | |
124 | + if (this.options.rightFixedColumns) { | |
125 | + this.$rightfixedBodyColumns.html(''); | |
126 | + this.$body.find('> tr[data-index]').each(function () { | |
127 | + var $tr = $(this).clone(), | |
128 | + $tds = $tr.clone().find('td'); | |
129 | + | |
130 | + $tr.html(''); | |
131 | + for (var i = 0; i < that.options.rightFixedNumber; i++) { | |
132 | + var indexTd = $tds.length - that.options.rightFixedNumber + i; | |
133 | + var oldTd = $tds.eq(indexTd); | |
134 | + var fixTd = oldTd.clone(); | |
135 | + var buttons = fixTd.find('button'); | |
136 | + //事件转移:冻结列里面的事件转移到实际按钮的事件 | |
137 | + buttons.each(function (key, item) { | |
138 | + $(item).click(function () { | |
139 | + that.$body.find("tr[data-index=" + $tr.attr('data-index') + "] td:eq(" + indexTd + ") button:eq(" + key + ")").click(); | |
140 | + }); | |
141 | + }); | |
142 | + $tr.append(fixTd); | |
143 | + } | |
144 | + that.$rightfixedBodyColumns.append($tr); | |
145 | + }); | |
146 | + } | |
147 | + }; | |
148 | + | |
149 | + BootstrapTable.prototype.resetView = function () { | |
150 | + _resetView.apply(this, Array.prototype.slice.apply(arguments)); | |
151 | + | |
152 | + if (!this.options.fixedColumns && !this.options.rightFixedColumns) { | |
153 | + return; | |
154 | + } | |
155 | + | |
156 | + clearTimeout(this.timeoutHeaderColumns_); | |
157 | + this.timeoutHeaderColumns_ = setTimeout($.proxy(this.fitHeaderColumns, this), this.$el.is(':hidden') ? 100 : 0); | |
158 | + | |
159 | + clearTimeout(this.timeoutBodyColumns_); | |
160 | + this.timeoutBodyColumns_ = setTimeout($.proxy(this.fitBodyColumns, this), this.$el.is(':hidden') ? 100 : 0); | |
161 | + }; | |
162 | + | |
163 | + BootstrapTable.prototype.fitHeaderColumns = function () { | |
164 | + var that = this, | |
165 | + visibleFields = this.getVisibleFields(), | |
166 | + headerWidth = 0; | |
167 | + if (that.options.fixedColumns) { | |
168 | + this.$body.find('tr:first-child:not(.no-records-found) > *').each(function (i) { | |
169 | + var $this = $(this), | |
170 | + index = i; | |
171 | + | |
172 | + if (i >= that.options.fixedNumber) { | |
173 | + return false; | |
174 | + } | |
175 | + | |
176 | + if (that.options.detailView && !that.options.cardView) { | |
177 | + index = i - 1; | |
178 | + } | |
179 | + that.$fixedHeader.find('thead th[data-field="' + visibleFields[index] + '"]') | |
180 | + .find('.fht-cell').width($this.innerWidth()); | |
181 | + headerWidth += $this.outerWidth(); | |
182 | + }); | |
183 | + this.$fixedHeader.width(headerWidth + 2).show(); | |
184 | + } | |
185 | + if (that.options.rightFixedColumns) { | |
186 | + this.$body.find('tr:first-child:not(.no-records-found) > *').each(function (i) { | |
187 | + var $this = $(this), | |
188 | + index = i; | |
189 | + | |
190 | + if (i >= visibleFields.length - that.options.rightFixedNumber) { | |
191 | + return false; | |
192 | + | |
193 | + | |
194 | + if (that.options.detailView && !that.options.cardView) { | |
195 | + index = i - 1; | |
196 | + } | |
197 | + that.$rightfixedBody.find('thead th[data-field="' + visibleFields[index] + '"]') | |
198 | + .find('.fht-cell').width($this.innerWidth() - 1); | |
199 | + headerWidth += $this.outerWidth(); | |
200 | + } | |
201 | + }); | |
202 | + this.$rightfixedBody.width(headerWidth - 1).show(); | |
203 | + } | |
204 | + }; | |
205 | + | |
206 | + BootstrapTable.prototype.fitBodyColumns = function () { | |
207 | + var that = this, | |
208 | + top = -(parseInt(this.$el.css('margin-top'))), | |
209 | + height = this.$tableBody.height(); | |
210 | + | |
211 | + if (that.options.fixedColumns) { | |
212 | + if (!this.$body.find('> tr[data-index]').length) { | |
213 | + this.$fixedBody.hide(); | |
214 | + return; | |
215 | + } | |
216 | + | |
217 | + if (!this.options.height) { | |
218 | + top = this.$fixedHeader.height()- 1; | |
219 | + height = height - top; | |
220 | + } | |
221 | + | |
222 | + this.$fixedBody.css({ | |
223 | + width: this.$fixedHeader.width(), | |
224 | + height: height, | |
225 | + top: top + 1 | |
226 | + }).show(); | |
227 | + | |
228 | + this.$body.find('> tr').each(function (i) { | |
229 | + that.$fixedBody.find('tr:eq(' + i + ')').height($(this).height() - 0.5); | |
230 | + var thattds = this; | |
231 | + that.$fixedBody.find('tr:eq(' + i + ')').find('td').each(function (j) { | |
232 | + $(this).width($($(thattds).find('td')[j]).width() + 1); | |
233 | + }); | |
234 | + }); | |
235 | + | |
236 | + $("#" + table.options.id).on("check.bs.table uncheck.bs.table", function (e, rows, $element) { | |
237 | + var index= $element.data('index'); | |
238 | + $(this).find('.bs-checkbox').find('input[data-index="' + index + '"]').prop("checked", true); | |
239 | + var selectFixedItem = $('.left-fixed-body-columns input[name=btSelectItem]'); | |
240 | + var checkAll = selectFixedItem.filter(':enabled').length && | |
241 | + selectFixedItem.filter(':enabled').length === | |
242 | + selectFixedItem.filter(':enabled').filter(':checked').length; | |
243 | + $(".left-fixed-table-columns input[name=btSelectAll]").prop('checked', checkAll); | |
244 | + $('.fixed-table-body input[name=btSelectItem]').closest('tr').removeClass('selected'); | |
245 | + }); | |
246 | + | |
247 | + //// events | |
248 | + this.$tableBody.on('scroll', function () { | |
249 | + that.$fixedBody.find('table').css('top', -$(this).scrollTop()); | |
250 | + }); | |
251 | + this.$body.find('> tr[data-index]').off('hover').hover(function () { | |
252 | + var index = $(this).data('index'); | |
253 | + that.$fixedBody.find('tr[data-index="' + index + '"]').addClass('hover'); | |
254 | + }, function () { | |
255 | + var index = $(this).data('index'); | |
256 | + that.$fixedBody.find('tr[data-index="' + index + '"]').removeClass('hover'); | |
257 | + }); | |
258 | + this.$fixedBody.find('tr[data-index]').off('hover').hover(function () { | |
259 | + var index = $(this).data('index'); | |
260 | + that.$body.find('tr[data-index="' + index + '"]').addClass('hover'); | |
261 | + }, function () { | |
262 | + var index = $(this).data('index'); | |
263 | + that.$body.find('> tr[data-index="' + index + '"]').removeClass('hover'); | |
264 | + }); | |
265 | + } | |
266 | + if (that.options.rightFixedColumns) { | |
267 | + if (!this.$body.find('> tr[data-index]').length) { | |
268 | + this.$rightfixedBody.hide(); | |
269 | + return; | |
270 | + } | |
271 | + | |
272 | + this.$body.find('> tr').each(function (i) { | |
273 | + that.$rightfixedBody.find('tbody tr:eq(' + i + ')').height($(this).height()); | |
274 | + }); | |
275 | + | |
276 | + //// events | |
277 | + this.$tableBody.on('scroll', function () { | |
278 | + that.$rightfixedBody.find('table').css('top', -$(this).scrollTop()); | |
279 | + }); | |
280 | + this.$body.find('> tr[data-index]').off('hover').hover(function () { | |
281 | + var index = $(this).data('index'); | |
282 | + that.$rightfixedBody.find('tr[data-index="' + index + '"]').addClass('hover'); | |
283 | + }, function () { | |
284 | + var index = $(this).data('index'); | |
285 | + that.$rightfixedBody.find('tr[data-index="' + index + '"]').removeClass('hover'); | |
286 | + }); | |
287 | + this.$rightfixedBody.find('tr[data-index]').off('hover').hover(function () { | |
288 | + var index = $(this).data('index'); | |
289 | + that.$body.find('tr[data-index="' + index + '"]').addClass('hover'); | |
290 | + }, function () { | |
291 | + var index = $(this).data('index'); | |
292 | + that.$body.find('> tr[data-index="' + index + '"]').removeClass('hover'); | |
293 | + }); | |
294 | + } | |
295 | + }; | |
296 | + | |
297 | +})(jQuery); | |
0 | 298 | \ No newline at end of file |
... | ... |