Commit fb7fe564db51c4918005d96d80dd011ed4fa39f2
1 parent
cd8a2f34
线路分配
Showing
8 changed files
with
797 additions
and
0 deletions
src/main/java/com/bsth/controller/sys/UserLineController.java
0 → 100644
| 1 | +package com.bsth.controller.sys; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | +import java.util.Map; | |
| 5 | + | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 8 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 9 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 10 | +import org.springframework.web.bind.annotation.RestController; | |
| 11 | + | |
| 12 | +import com.bsth.controller.BaseController; | |
| 13 | +import com.bsth.entity.sys.UserLine; | |
| 14 | +import com.bsth.service.sys.UserLineService; | |
| 15 | + | |
| 16 | +@RestController | |
| 17 | +@RequestMapping("userline") | |
| 18 | +public class UserLineController extends BaseController<UserLine, Integer> { | |
| 19 | + | |
| 20 | + | |
| 21 | + @Autowired | |
| 22 | + private UserLineService service; | |
| 23 | + | |
| 24 | + @RequestMapping(value = "/userRoleTree", method = RequestMethod.GET) | |
| 25 | + public List<Map<String, Object>> userRoleTree(@RequestParam Map<String, Object> map){ | |
| 26 | + | |
| 27 | + return service.userRoleTree(map); | |
| 28 | + | |
| 29 | + } | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * | |
| 33 | + * @Title: setLineCasts | |
| 34 | + * | |
| 35 | + * @Description: TODO(为角色设置模块,全量覆盖) | |
| 36 | + * | |
| 37 | + * @param @param userId 用户ID | |
| 38 | + * | |
| 39 | + * @param @param mIds 线路ID字符串(1,2,3,4) | |
| 40 | + * | |
| 41 | + * @throws | |
| 42 | + */ | |
| 43 | + @RequestMapping(value = "/setLineCasts", method = RequestMethod.POST) | |
| 44 | + public Map<String, Object> setLineCasts(@RequestParam Integer userId,@RequestParam String mIds){ | |
| 45 | + return service.setLineCasts(userId, mIds); | |
| 46 | + } | |
| 47 | +} | ... | ... |
src/main/java/com/bsth/entity/sys/UserLine.java
0 → 100644
| 1 | +package com.bsth.entity.sys; | |
| 2 | + | |
| 3 | +import javax.persistence.Entity; | |
| 4 | +import javax.persistence.GeneratedValue; | |
| 5 | +import javax.persistence.GenerationType; | |
| 6 | +import javax.persistence.Id; | |
| 7 | +import javax.persistence.ManyToOne; | |
| 8 | +import javax.persistence.Table; | |
| 9 | + | |
| 10 | +import com.bsth.entity.Line; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * | |
| 14 | + * @ClassName: Line(用户线路分配实体类) | |
| 15 | + * | |
| 16 | + * @Description: TODO(用户线路分配实体类) | |
| 17 | + * | |
| 18 | + * @Author bsth@lq | |
| 19 | + * | |
| 20 | + * @Date 2016年8月26日 09:03:33 | |
| 21 | + * | |
| 22 | + * @Version 公交调度系统BS版 0.1 | |
| 23 | + * | |
| 24 | + */ | |
| 25 | + | |
| 26 | +@Entity | |
| 27 | +@Table(name = "bsth_c_user_line") | |
| 28 | +public class UserLine { | |
| 29 | + | |
| 30 | + @Id | |
| 31 | + @GeneratedValue(strategy = GenerationType.IDENTITY) | |
| 32 | + private Integer id; | |
| 33 | + | |
| 34 | + @ManyToOne | |
| 35 | + private Line line; | |
| 36 | + | |
| 37 | + @ManyToOne | |
| 38 | + private SysUser user; | |
| 39 | + | |
| 40 | + public Line getLine() { | |
| 41 | + return line; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public Integer getId() { | |
| 45 | + return id; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public void setId(Integer id) { | |
| 49 | + this.id = id; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public void setLine(Line line) { | |
| 53 | + this.line = line; | |
| 54 | + } | |
| 55 | + | |
| 56 | + public SysUser getUser() { | |
| 57 | + return user; | |
| 58 | + } | |
| 59 | + | |
| 60 | + public void setUser(SysUser user) { | |
| 61 | + this.user = user; | |
| 62 | + } | |
| 63 | +} | ... | ... |
src/main/java/com/bsth/repository/sys/UserLineRepository.java
0 → 100644
| 1 | +package com.bsth.repository.sys; | |
| 2 | + | |
| 3 | +import org.springframework.data.jpa.repository.Modifying; | |
| 4 | +import org.springframework.data.jpa.repository.Query; | |
| 5 | +import org.springframework.stereotype.Repository; | |
| 6 | +import org.springframework.transaction.annotation.Transactional; | |
| 7 | + | |
| 8 | +import com.bsth.entity.sys.UserLine; | |
| 9 | +import com.bsth.repository.BaseRepository; | |
| 10 | + | |
| 11 | + | |
| 12 | +@Repository | |
| 13 | +public interface UserLineRepository extends BaseRepository<UserLine, Integer>{ | |
| 14 | + | |
| 15 | + @Modifying | |
| 16 | + @Query(value="DELETE FROM bsth_c_user_line WHERE user = ?1", nativeQuery=true) | |
| 17 | + public void del(int userId); | |
| 18 | + | |
| 19 | +} | ... | ... |
src/main/java/com/bsth/service/sys/UserLineService.java
0 → 100644
| 1 | +package com.bsth.service.sys; | |
| 2 | +import java.util.List; | |
| 3 | +import java.util.Map; | |
| 4 | + | |
| 5 | +import com.bsth.entity.sys.UserLine; | |
| 6 | +import com.bsth.service.BaseService; | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * | |
| 12 | + * @Interface: LineService(线路service业务层实现接口) | |
| 13 | + * | |
| 14 | + * @extends : BaseService | |
| 15 | + * | |
| 16 | + * @Description: TODO(线路service业务层实现接口) | |
| 17 | + * | |
| 18 | + * @Author bsth@lq | |
| 19 | + * | |
| 20 | + * @Date 2016年4月28日 上午9:21:17 | |
| 21 | + * | |
| 22 | + * @Version 公交调度系统BS版 0.1 | |
| 23 | + * | |
| 24 | + */ | |
| 25 | +public interface UserLineService extends BaseService<UserLine, Integer> { | |
| 26 | + | |
| 27 | + List<Map<String, Object>> userRoleTree(Map<String, Object> map); | |
| 28 | + | |
| 29 | + Map<String, Object> setLineCasts(Integer userId, String mIds); | |
| 30 | + | |
| 31 | +} | ... | ... |
src/main/java/com/bsth/service/sys/impl/UserLineServiceImpl.java
0 → 100644
| 1 | +package com.bsth.service.sys.impl; | |
| 2 | + | |
| 3 | +import java.util.ArrayList; | |
| 4 | +import java.util.HashMap; | |
| 5 | +import java.util.HashSet; | |
| 6 | +import java.util.Iterator; | |
| 7 | +import java.util.List; | |
| 8 | +import java.util.Map; | |
| 9 | +import java.util.Set; | |
| 10 | + | |
| 11 | +import org.apache.catalina.User; | |
| 12 | +import org.slf4j.Logger; | |
| 13 | +import org.slf4j.LoggerFactory; | |
| 14 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 15 | +import org.springframework.stereotype.Service; | |
| 16 | +import org.springframework.transaction.annotation.Transactional; | |
| 17 | + | |
| 18 | +import com.bsth.common.ResponseCode; | |
| 19 | +import com.bsth.entity.Line; | |
| 20 | +import com.bsth.entity.search.CustomerSpecs; | |
| 21 | +import com.bsth.entity.sys.Role; | |
| 22 | +import com.bsth.entity.sys.SysUser; | |
| 23 | +import com.bsth.entity.sys.UserLine; | |
| 24 | +import com.bsth.repository.LineRepository; | |
| 25 | +import com.bsth.repository.sys.RoleRepository; | |
| 26 | +import com.bsth.repository.sys.SysUserRepository; | |
| 27 | +import com.bsth.repository.sys.UserLineRepository; | |
| 28 | +import com.bsth.service.impl.BaseServiceImpl; | |
| 29 | +import com.bsth.service.sys.UserLineService; | |
| 30 | + | |
| 31 | + | |
| 32 | +/** | |
| 33 | + * Created by xu on 16/5/31. | |
| 34 | + */ | |
| 35 | +@Service | |
| 36 | +public class UserLineServiceImpl extends BaseServiceImpl<UserLine, Integer> implements UserLineService { | |
| 37 | + | |
| 38 | + @Autowired | |
| 39 | + private UserLineRepository repository; | |
| 40 | + | |
| 41 | + @Autowired | |
| 42 | + private SysUserRepository userRepository; | |
| 43 | + | |
| 44 | + @Autowired | |
| 45 | + private RoleRepository roleRepository; | |
| 46 | + | |
| 47 | + @Autowired | |
| 48 | + private LineRepository lineRepository; | |
| 49 | + | |
| 50 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 51 | + | |
| 52 | + @Override | |
| 53 | + public List<Map<String, Object>> userRoleTree(Map<String, Object> map) { | |
| 54 | + | |
| 55 | + CustomerSpecs spec = new CustomerSpecs<Role>(map); | |
| 56 | + | |
| 57 | + List<Role> roleLine = roleRepository.findAll(spec); | |
| 58 | + | |
| 59 | + int size = roleLine.size(); | |
| 60 | + | |
| 61 | + List<Map<String, Object>> list = new ArrayList<>(); | |
| 62 | + | |
| 63 | + if(size>0){ | |
| 64 | + | |
| 65 | + for(int i = 0; i <size;i++) { | |
| 66 | + | |
| 67 | + Map<String, Object> tempM = new HashMap<String, Object>(); | |
| 68 | + int roleId = roleLine.get(i).getId(); | |
| 69 | + String roleName = roleLine.get(i).getRoleName(); | |
| 70 | + tempM.put("name", roleName); | |
| 71 | + tempM.put("text", roleName); | |
| 72 | + tempM.put("icon", "fa fa-database"); | |
| 73 | + tempM.put("pId",null); | |
| 74 | + tempM.put("id", 100+roleId); | |
| 75 | + tempM.put("groupType", "1"); | |
| 76 | + tempM.put("enable", true); | |
| 77 | + Set<SysUser> user = roleLine.get(i).getUsers(); | |
| 78 | + Iterator<SysUser> it = user.iterator(); | |
| 79 | + List<Map<String, Object>> roleChildren = new ArrayList<>(); | |
| 80 | + while(it.hasNext()) { | |
| 81 | + Map<String, Object> userMap = new HashMap<String, Object>(); | |
| 82 | + SysUser tempU = it.next(); | |
| 83 | + String userName = tempU.getUserName(); | |
| 84 | + int userId = tempU.getId(); | |
| 85 | + userMap.put("name", userName); | |
| 86 | + userMap.put("text", userName); | |
| 87 | + userMap.put("icon", "fa fa-user"); | |
| 88 | + userMap.put("pId",100+roleId); | |
| 89 | + userMap.put("id", 1000+userId); | |
| 90 | + userMap.put("userId", userId); | |
| 91 | + userMap.put("groupType", "2"); | |
| 92 | + userMap.put("enable", true); | |
| 93 | + roleChildren.add(userMap); | |
| 94 | + | |
| 95 | + } | |
| 96 | + tempM.put("children", roleChildren); | |
| 97 | + list.add(tempM); | |
| 98 | + } | |
| 99 | + | |
| 100 | + } | |
| 101 | + | |
| 102 | + return list; | |
| 103 | + } | |
| 104 | + | |
| 105 | + @Override | |
| 106 | + @Transactional | |
| 107 | + public Map<String, Object> setLineCasts(Integer userId, String mIds) { | |
| 108 | + Map<String, Object> map = new HashMap<>(); | |
| 109 | + | |
| 110 | + try { | |
| 111 | + | |
| 112 | + repository.del(userId); | |
| 113 | + | |
| 114 | + SysUser user = userRepository.findOne(userId); | |
| 115 | + | |
| 116 | + List<Integer> idList = new ArrayList<>(); | |
| 117 | + String[] array = mIds.split(","); | |
| 118 | + for (String id : array) { | |
| 119 | + if (null == id || id.trim().equals("")) | |
| 120 | + continue; | |
| 121 | + idList.add(Integer.parseInt(id)); | |
| 122 | + } | |
| 123 | + | |
| 124 | + int size = idList.size(); | |
| 125 | + | |
| 126 | + if(size>0) { | |
| 127 | + | |
| 128 | + for(int i = 0 ; i<size;i++) { | |
| 129 | + | |
| 130 | + UserLine entity = new UserLine(); | |
| 131 | + | |
| 132 | + int lineId = idList.get(i); | |
| 133 | + | |
| 134 | + Line line = lineRepository.findOne(lineId); | |
| 135 | + | |
| 136 | + entity.setUser(user); | |
| 137 | + | |
| 138 | + entity.setLine(line); | |
| 139 | + | |
| 140 | + repository.save(entity); | |
| 141 | + } | |
| 142 | + | |
| 143 | + } | |
| 144 | + | |
| 145 | + map.put("status", ResponseCode.SUCCESS); | |
| 146 | + | |
| 147 | + } catch (Exception e) { | |
| 148 | + | |
| 149 | + logger.error("", e); | |
| 150 | + map.put("status", ResponseCode.ERROR); | |
| 151 | + } | |
| 152 | + | |
| 153 | + return map; | |
| 154 | + } | |
| 155 | +} | ... | ... |
src/main/resources/static/pages/base/linecast/cast.html
0 → 100644
| 1 | +<link href="/pages/base/linecast/css/cast.css" rel="stylesheet" type="text/css" /> | |
| 2 | + | |
| 3 | +<script type="text/javascript" src="/pages/base/linecast/js/jquery.quicksearch.js"></script> | |
| 4 | + | |
| 5 | +<div class="page-head"> | |
| 6 | + <div class="page-title"> | |
| 7 | + <h1>线路分配</h1> | |
| 8 | + </div> | |
| 9 | +</div> | |
| 10 | +<ul class="page-breadcrumb breadcrumb"> | |
| 11 | + <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li> | |
| 12 | + <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li> | |
| 13 | + <li><span class="active">线路分配</span></li> | |
| 14 | +</ul> | |
| 15 | + | |
| 16 | +<div class="row"> | |
| 17 | + <div class="col-md-4" style="padding-right: 0px;"> | |
| 18 | + <div class="portlet light bordered" style="min-height: 520px;"> | |
| 19 | + <div class="portlet-title"> | |
| 20 | + <div class="caption"> | |
| 21 | + <i class="fa fa-users font-dark"></i> | |
| 22 | + <span class="caption-subject font-dark sbold uppercase">用户菜单</span> | |
| 23 | + </div> | |
| 24 | + </div> | |
| 25 | + <div class="portlet-body"> | |
| 26 | + <div id="modules_tree" ></div> | |
| 27 | + </div> | |
| 28 | + </div> | |
| 29 | + </div> | |
| 30 | + <div class="col-md-6" style="padding-left: 0px;"> | |
| 31 | + <div class="portlet light bordered" style="height: 520px;"> | |
| 32 | + <div class="portlet-body" style="min-height: 200px;" id="init-text"> | |
| 33 | + <div class="text-info" style="text-align: center;line-height: 200px;"> | |
| 34 | + <i class="fa fa-info"></i> 单击节点查看详细 | |
| 35 | + </div> | |
| 36 | + </div> | |
| 37 | + | |
| 38 | + <div style="display:none" id="line-cast"> | |
| 39 | + <!-- BEGIN PORTLET--> | |
| 40 | + <div class="portlet light bordered"> | |
| 41 | + <div class="portlet-title"> | |
| 42 | + <div class="caption"> | |
| 43 | + <i class="icon-bar-chart font-green"></i> | |
| 44 | + <span class="caption-subject font-green bold uppercase">线路配置</span> | |
| 45 | + </div> | |
| 46 | + <div class="actions"> | |
| 47 | + <button class="btn green btn-circle btn-sm" disabled="disabled" id="saveModuleSett"><i class="fa fa-check"></i> 保存修改</button> | |
| 48 | + </div> | |
| 49 | + </div> | |
| 50 | + <div class="portlet-body"> | |
| 51 | + <div class="form-group last" > | |
| 52 | + <div> | |
| 53 | + <select multiple="multiple" class="multi-select" id="moduleSettSelect" ></select> | |
| 54 | + </div> | |
| 55 | + </div> | |
| 56 | + </div> | |
| 57 | + </div> | |
| 58 | + </div> | |
| 59 | + </div> | |
| 60 | + </div> | |
| 61 | +</div> | |
| 62 | + | |
| 63 | +<script type="text/html" id="left_line_cast"> | |
| 64 | + | |
| 65 | +</script> | |
| 66 | + | |
| 67 | +<script> | |
| 68 | + | |
| 69 | +$(function(){ | |
| 70 | + | |
| 71 | + getTreeData(function(treeData){ | |
| 72 | + | |
| 73 | + //初始化树 | |
| 74 | + $('#modules_tree').on('loaded.jstree', function(e, data){close_all();}).jstree({ | |
| 75 | + 'core' : { | |
| 76 | + 'themes' : { | |
| 77 | + 'responsive': false | |
| 78 | + }, | |
| 79 | + 'data': treeData, | |
| 80 | + 'multiple':false | |
| 81 | + }, | |
| 82 | + 'types' : { | |
| 83 | + "default" : { | |
| 84 | + "icon" : false | |
| 85 | + }, | |
| 86 | + 'enable_true' : { | |
| 87 | + "icon" : 'fa fa-check icon-lg' | |
| 88 | + }, | |
| 89 | + 'enable_false' : { | |
| 90 | + 'icon' : 'fa fa-close icon-lg' | |
| 91 | + }, | |
| 92 | + 'group':{ | |
| 93 | + 'icon' : 'fa fa-object-group icon-lg' | |
| 94 | + } | |
| 95 | + }, | |
| 96 | + 'plugins': ['types'] | |
| 97 | + }).on('select_node.jstree', jstreeClick); | |
| 98 | + }); | |
| 99 | + | |
| 100 | + $('.tooltips').tooltip(); | |
| 101 | + | |
| 102 | +}); | |
| 103 | + | |
| 104 | +function jstreeClick(){ | |
| 105 | + | |
| 106 | + var selected = getCurrSelNode(); | |
| 107 | + | |
| 108 | + var obj = selected[0].original; | |
| 109 | + | |
| 110 | + $('#saveModuleSett').attr('disabled', 'disabled'); | |
| 111 | + | |
| 112 | + if(obj.pId==null) { | |
| 113 | + | |
| 114 | + $('#line-cast').hide(); | |
| 115 | + | |
| 116 | + $('#init-text').show(); | |
| 117 | + }else { | |
| 118 | + | |
| 119 | + $('#line-cast').show(); | |
| 120 | + | |
| 121 | + $('#init-text').hide(); | |
| 122 | + | |
| 123 | + var userId = obj.userId; | |
| 124 | + | |
| 125 | + getModuleTreeData(userId); | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | +} | |
| 130 | + | |
| 131 | +function getCurrSelNode(){ | |
| 132 | + | |
| 133 | + var array = []; | |
| 134 | + | |
| 135 | + try { | |
| 136 | + | |
| 137 | + array = $.jstree.reference("#modules_tree").get_selected(true); | |
| 138 | + | |
| 139 | + } catch (e) { | |
| 140 | + | |
| 141 | + console.log(e); | |
| 142 | + | |
| 143 | + } | |
| 144 | + | |
| 145 | + return array; | |
| 146 | +} | |
| 147 | + | |
| 148 | +function close_all(){ | |
| 149 | + | |
| 150 | + $.jstree.reference("#modules_tree").close_all(); | |
| 151 | + | |
| 152 | +} | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | +function getTreeData(cb){ | |
| 157 | + | |
| 158 | + var treeData = []; | |
| 159 | + | |
| 160 | + $get('/userline/userRoleTree',null, function(arr){ | |
| 161 | + | |
| 162 | + //转换为jsTree想要的数据格式 | |
| 163 | + treeData = createTreeData(arr); | |
| 164 | + | |
| 165 | + cb && cb(treeData) | |
| 166 | + }); | |
| 167 | +} | |
| 168 | + | |
| 169 | +function getModuleTreeData(userId){ | |
| 170 | + | |
| 171 | + | |
| 172 | + $get('/line/all',null, function(linedata){ | |
| 173 | + | |
| 174 | + $get('/userline/all',{'user.id_eq':userId}, function(userlinedata){ | |
| 175 | + | |
| 176 | + var options = ''; | |
| 177 | + | |
| 178 | + var len = userlinedata.length; | |
| 179 | + | |
| 180 | + $.each(linedata, function(i, g){ | |
| 181 | + | |
| 182 | + //是否被当前用户持有 | |
| 183 | + var selected = ''; | |
| 184 | + | |
| 185 | + if(len>0) { | |
| 186 | + | |
| 187 | + for(var j = 0;j<userlinedata.length;j++ ) { | |
| 188 | + | |
| 189 | + if(userlinedata[j].line.id==g.id){ | |
| 190 | + | |
| 191 | + selected = 'selected'; | |
| 192 | + | |
| 193 | + break; | |
| 194 | + | |
| 195 | + } | |
| 196 | + | |
| 197 | + } | |
| 198 | + | |
| 199 | + } | |
| 200 | + | |
| 201 | + options += '<option value="'+g.id+'" ' + selected +'>'+g.name+'</option>' | |
| 202 | + | |
| 203 | + }); | |
| 204 | + | |
| 205 | + //初始化multiSelect | |
| 206 | + $('#moduleSettSelect').html(options).multiSelect({ | |
| 207 | + selectableOptgroup: true, | |
| 208 | + | |
| 209 | + selectableFooter: "<div class='multi-custom-header-left'>未分配</div>", | |
| 210 | + selectionFooter: "<div class='multi-custom-header-right'>已分配</div>", | |
| 211 | + | |
| 212 | + selectableHeader: "<input type='text' class='search-input' style='width: 221px;' autocomplete='off' placeholder='搜索线路'>", | |
| 213 | + selectionHeader: "<input type='text' class='search-input' style='width: 221px;' autocomplete='off' placeholder='搜索线路'>", | |
| 214 | + afterInit: function(ms){ | |
| 215 | + var that = this, | |
| 216 | + $selectableSearch = that.$selectableUl.prev(), | |
| 217 | + $selectionSearch = that.$selectionUl.prev(), | |
| 218 | + selectableSearchString = '#'+that.$container.attr('id')+' .ms-elem-selectable:not(.ms-selected)', | |
| 219 | + selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected'; | |
| 220 | + | |
| 221 | + that.qs1 = $selectableSearch.quicksearch(selectableSearchString) | |
| 222 | + .on('keydown', function(e){ | |
| 223 | + if (e.which === 40){ | |
| 224 | + that.$selectableUl.focus(); | |
| 225 | + return false; | |
| 226 | + } | |
| 227 | + }); | |
| 228 | + | |
| 229 | + that.qs2 = $selectionSearch.quicksearch(selectionSearchString) | |
| 230 | + .on('keydown', function(e){ | |
| 231 | + if (e.which == 40){ | |
| 232 | + that.$selectionUl.focus(); | |
| 233 | + return false; | |
| 234 | + } | |
| 235 | + }); | |
| 236 | + }, | |
| 237 | + afterSelect: function(){ | |
| 238 | + this.qs1.cache(); | |
| 239 | + this.qs2.cache(); | |
| 240 | + }, | |
| 241 | + afterDeselect: function(){ | |
| 242 | + this.qs1.cache(); | |
| 243 | + this.qs2.cache(); | |
| 244 | + } | |
| 245 | + }).on('change',function(){ | |
| 246 | + | |
| 247 | + if( $(this).val() ==null || $(this).val().length > 0) | |
| 248 | + $('#saveModuleSett').removeAttr('disabled'); | |
| 249 | + else | |
| 250 | + $('#saveModuleSett').attr('disabled', 'disabled'); | |
| 251 | + }); | |
| 252 | + | |
| 253 | + $('#moduleSettSelect').multiSelect('refresh'); | |
| 254 | + | |
| 255 | + }); | |
| 256 | + | |
| 257 | + }); | |
| 258 | +} | |
| 259 | + | |
| 260 | + | |
| 261 | +$('#saveModuleSett').on('click', function(){ | |
| 262 | + if($(this).attr('disabled')) | |
| 263 | + return; | |
| 264 | + | |
| 265 | + var ids = ''; | |
| 266 | + | |
| 267 | + if($('#moduleSettSelect').val() !=null) { | |
| 268 | + | |
| 269 | + $.each($('#moduleSettSelect').val(), function(i, mId){ | |
| 270 | + ids += mId + ','; | |
| 271 | + }); | |
| 272 | + | |
| 273 | + } | |
| 274 | + | |
| 275 | + var selected = getCurrSelNode(); | |
| 276 | + | |
| 277 | + var obj = selected[0].original; | |
| 278 | + | |
| 279 | + if(obj) { | |
| 280 | + | |
| 281 | + $post('/userline/setLineCasts', {'userId': obj.userId,mIds: ids}, function(){ | |
| 282 | + $('#saveModuleSett').attr('disabled', 'disabled'); | |
| 283 | + layer.msg('修改成功!'); | |
| 284 | + }); | |
| 285 | + | |
| 286 | + } | |
| 287 | + | |
| 288 | +}); | |
| 289 | +</script> | |
| 0 | 290 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/base/linecast/css/cast.css
0 → 100644
| 1 | +.jstree-default .jstree-hovered{ | |
| 2 | + background-color: rgba(101, 155, 224, 0.19); | |
| 3 | +} | |
| 4 | + | |
| 5 | +.jstree-default .jstree-clicked { | |
| 6 | + background-color: #659BE0; | |
| 7 | + color: white; | |
| 8 | +} | |
| 9 | +.layui-layer-cfm-delete .layui-layer-btn0{ | |
| 10 | + background-color: #e73d4a; | |
| 11 | + border-color: #CE3643; | |
| 12 | +} | |
| 0 | 13 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/base/linecast/js/jquery.quicksearch.js
0 → 100644
| 1 | +(function($, window, document, undefined) { | |
| 2 | + $.fn.quicksearch = function (target, opt) { | |
| 3 | + | |
| 4 | + var timeout, cache, rowcache, jq_results, val = '', e = this, options = $.extend({ | |
| 5 | + delay: 100, | |
| 6 | + selector: null, | |
| 7 | + stripeRows: null, | |
| 8 | + loader: null, | |
| 9 | + noResults: '', | |
| 10 | + matchedResultsCount: 0, | |
| 11 | + bind: 'keyup', | |
| 12 | + onBefore: function () { | |
| 13 | + return; | |
| 14 | + }, | |
| 15 | + onAfter: function () { | |
| 16 | + return; | |
| 17 | + }, | |
| 18 | + show: function () { | |
| 19 | + this.style.display = ""; | |
| 20 | + }, | |
| 21 | + hide: function () { | |
| 22 | + this.style.display = "none"; | |
| 23 | + }, | |
| 24 | + prepareQuery: function (val) { | |
| 25 | + return val.toLowerCase().split(' '); | |
| 26 | + }, | |
| 27 | + testQuery: function (query, txt, _row) { | |
| 28 | + for (var i = 0; i < query.length; i += 1) { | |
| 29 | + if (txt.indexOf(query[i]) === -1) { | |
| 30 | + return false; | |
| 31 | + } | |
| 32 | + } | |
| 33 | + return true; | |
| 34 | + } | |
| 35 | + }, opt); | |
| 36 | + | |
| 37 | + this.go = function () { | |
| 38 | + | |
| 39 | + var i = 0, | |
| 40 | + numMatchedRows = 0, | |
| 41 | + noresults = true, | |
| 42 | + query = options.prepareQuery(val), | |
| 43 | + val_empty = (val.replace(' ', '').length === 0); | |
| 44 | + | |
| 45 | + for (var i = 0, len = rowcache.length; i < len; i++) { | |
| 46 | + if (val_empty || options.testQuery(query, cache[i], rowcache[i])) { | |
| 47 | + options.show.apply(rowcache[i]); | |
| 48 | + noresults = false; | |
| 49 | + numMatchedRows++; | |
| 50 | + } else { | |
| 51 | + options.hide.apply(rowcache[i]); | |
| 52 | + } | |
| 53 | + } | |
| 54 | + | |
| 55 | + if (noresults) { | |
| 56 | + this.results(false); | |
| 57 | + } else { | |
| 58 | + this.results(true); | |
| 59 | + this.stripe(); | |
| 60 | + } | |
| 61 | + | |
| 62 | + this.matchedResultsCount = numMatchedRows; | |
| 63 | + this.loader(false); | |
| 64 | + options.onAfter(); | |
| 65 | + | |
| 66 | + return this; | |
| 67 | + }; | |
| 68 | + | |
| 69 | + /* | |
| 70 | + * External API so that users can perform search programatically. | |
| 71 | + * */ | |
| 72 | + this.search = function (submittedVal) { | |
| 73 | + val = submittedVal; | |
| 74 | + e.trigger(); | |
| 75 | + }; | |
| 76 | + | |
| 77 | + /* | |
| 78 | + * External API to get the number of matched results as seen in | |
| 79 | + * https://github.com/ruiz107/quicksearch/commit/f78dc440b42d95ce9caed1d087174dd4359982d6 | |
| 80 | + * */ | |
| 81 | + this.currentMatchedResults = function() { | |
| 82 | + return this.matchedResultsCount; | |
| 83 | + }; | |
| 84 | + | |
| 85 | + this.stripe = function () { | |
| 86 | + | |
| 87 | + if (typeof options.stripeRows === "object" && options.stripeRows !== null) | |
| 88 | + { | |
| 89 | + var joined = options.stripeRows.join(' '); | |
| 90 | + var stripeRows_length = options.stripeRows.length; | |
| 91 | + | |
| 92 | + jq_results.not(':hidden').each(function (i) { | |
| 93 | + $(this).removeClass(joined).addClass(options.stripeRows[i % stripeRows_length]); | |
| 94 | + }); | |
| 95 | + } | |
| 96 | + | |
| 97 | + return this; | |
| 98 | + }; | |
| 99 | + | |
| 100 | + this.strip_html = function (input) { | |
| 101 | + var output = input.replace(new RegExp('<[^<]+\>', 'g'), ""); | |
| 102 | + output = $.trim(output.toLowerCase()); | |
| 103 | + return output; | |
| 104 | + }; | |
| 105 | + | |
| 106 | + this.results = function (bool) { | |
| 107 | + if (typeof options.noResults === "string" && options.noResults !== "") { | |
| 108 | + if (bool) { | |
| 109 | + $(options.noResults).hide(); | |
| 110 | + } else { | |
| 111 | + $(options.noResults).show(); | |
| 112 | + } | |
| 113 | + } | |
| 114 | + return this; | |
| 115 | + }; | |
| 116 | + | |
| 117 | + this.loader = function (bool) { | |
| 118 | + if (typeof options.loader === "string" && options.loader !== "") { | |
| 119 | + (bool) ? $(options.loader).show() : $(options.loader).hide(); | |
| 120 | + } | |
| 121 | + return this; | |
| 122 | + }; | |
| 123 | + | |
| 124 | + this.cache = function () { | |
| 125 | + | |
| 126 | + jq_results = $(target); | |
| 127 | + | |
| 128 | + if (typeof options.noResults === "string" && options.noResults !== "") { | |
| 129 | + jq_results = jq_results.not(options.noResults); | |
| 130 | + } | |
| 131 | + | |
| 132 | + var t = (typeof options.selector === "string") ? jq_results.find(options.selector) : $(target).not(options.noResults); | |
| 133 | + cache = t.map(function () { | |
| 134 | + return e.strip_html(this.innerHTML); | |
| 135 | + }); | |
| 136 | + | |
| 137 | + rowcache = jq_results.map(function () { | |
| 138 | + return this; | |
| 139 | + }); | |
| 140 | + | |
| 141 | + /* | |
| 142 | + * Modified fix for sync-ing "val". | |
| 143 | + * Original fix https://github.com/michaellwest/quicksearch/commit/4ace4008d079298a01f97f885ba8fa956a9703d1 | |
| 144 | + * */ | |
| 145 | + val = val || this.val() || ""; | |
| 146 | + | |
| 147 | + return this.go(); | |
| 148 | + }; | |
| 149 | + | |
| 150 | + this.trigger = function () { | |
| 151 | + this.loader(true); | |
| 152 | + options.onBefore(); | |
| 153 | + | |
| 154 | + window.clearTimeout(timeout); | |
| 155 | + timeout = window.setTimeout(function () { | |
| 156 | + e.go(); | |
| 157 | + }, options.delay); | |
| 158 | + | |
| 159 | + return this; | |
| 160 | + }; | |
| 161 | + | |
| 162 | + this.cache(); | |
| 163 | + this.results(true); | |
| 164 | + this.stripe(); | |
| 165 | + this.loader(false); | |
| 166 | + | |
| 167 | + return this.each(function () { | |
| 168 | + | |
| 169 | + /* | |
| 170 | + * Changed from .bind to .on. | |
| 171 | + * */ | |
| 172 | + $(this).on(options.bind, function () { | |
| 173 | + | |
| 174 | + val = $(this).val(); | |
| 175 | + e.trigger(); | |
| 176 | + }); | |
| 177 | + }); | |
| 178 | + | |
| 179 | + }; | |
| 180 | + | |
| 181 | +}(jQuery, this, document)); | |
| 0 | 182 | \ No newline at end of file | ... | ... |