| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- var team_id;
- var dept_id = 1;
- var idUpdate;
- function queryTable(){
- var data = {
- "dept_id":dept_id
- }
- var name = $("#select_name").val();
- if(name!=''){
- data.name = name ;
- }
- var cols = [
- {width: 30, text: '序号', flex: false, colClass: 'text-center',field:'num'},
- {width: 160, text: '班组名称', flex: false,colClass: '',field:'name'},
- {width: 80, text: '所属人员分类', flex: false, colClass: '',field:'type'},
- {width: 80, text: '班长', type: 'date', flex: false, sort: 'down',field:'monitor'},
- {width: 80, text: '副班长', type: 'string', flex: false, colClass: '',field:'sub_monitor'},
- {width: 80, text: '人员', flex: false, colClass: '',field:'user_ids'},
- {width: 50, text: '操作', flex: false, colClass: '',field:'task_id',oper:[
- {func:'updateCheckTeam',text:'修改',col_class:'icon-edit'},{func:'deleteCheckTeam',text:'删除',col_class:'icon-remove-circle'}
- ]},
- ] ;
-
- $('.datatable').mytable({'cols':cols,
- 'url':"team/getTeamByName",
- 'param':data}
- );
- }
- function deleteCheckTeam(id){
- deleteItem4Common(id,"team/delete",queryTable);
- }
- $(document).ready(function() {
- queryTable();
- })
- function updateCheckTeam(id){
- team_id = id;
- data = {
- "id":id
- }
- post_common_service("team/getTeamById", data, function(data){
- $("#monitor").empty();
- $("#second-monitor").empty();
- $("#member").empty();
- $("#team_name").val(data.name);
- users = data.user_ids.split(",");
- for(i=0;i<users.length;i++){
- $("#monitor").append('<option value="'+users[i]+'">'+users[i]+'</option>');
- $("#second-monitor").append('<option value="'+users[i]+'">'+users[i]+'</option>');
- $("#member").append('<div style="width:83px;float:left;">\
- <input type="checkbox" value="'+users[i]+'"><span>'+users[i]+'</span>\
- </div>');
- }
- idUpdate = true;
- layerUpdateTeam('form-div','班组修改','550px');
- }, function(){
- });
-
- }
- function layerUpdateTeam(domId,title,area){
- layer.open({
- type: 1,
- title: false,
- closeBtn: 1,
- title:title,
- shadeClose: true,
- skin: 'yourclass',
- area:area,
- content: $("#"+domId)
- });
- }
- //关闭弹窗
- $("#close-layer").click(function(){
- layer.closeAll();
- })
- //保存修改或添加
- $("#save-team").click(function(){
- var user_ids = "";
- $.each($('input:checkbox'),function(){
- if(this.checked){
- user_ids = user_ids + $(this).val() + ",";
- }
- });
- if(user_ids != ""){
- user_ids = user_ids.substring(0,user_ids.length-1);
- }else{
- layer.msg('请选择人员');
- return;
- }
- data = {
- "id":team_id,
- "dept_id":dept_id,
- "name":$("#team_name").val(),
- "user_ids":user_ids,
- "type":2,
- "monitor":$("#monitor").val(),
- "sub_monitor":$("#second-monitor").val()
- }
- if(idUpdate){
- post_common_service("team/update", data, function(data){
- layer.closeAll();
- queryTable();
- }, function(){
- });
- }else{
- post_common_service("team/add", data, function(data){
- layer.closeAll();
- queryTable();
- }, function(){
- });
- }
- })
- //条件查询
- $("#conditional_query").click(function(){
- queryTable();
- })
- //添加班组
- $("#addTeam").click(function(){
- idUpdate = false;
- layerUpdateTeam('form-div','班组新增','550px');
- })
|