easyui datagrid 增删改查示例

 查询JSP页面

  1 <!doctype html>
  2 <%@include file="/internet/common.jsp"%>
  3 <!-- 新样式右侧菜单共用CSS和部分JS:在页面最前 -->
  4 <%@include file="/ChangeFbrole/pageMain/Common_RightMenu.jsp"%>
  5 <html>
  6 <head>
  7     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8     <title>告警接单人查询</title>
  9     <script src="/ChangeFbrole/pgYunWei/scripts/QueryStaff.js" type="text/javascript"></script>
 10     
 11     <script language="javascript">
 12         var userID = '<bean:write property="SessionEntity/userID"/>';
 13         var RegionID = '<bean:write property="SessionEntity/RegionID"/>';
 14         // 查询条件
 15         var search_input = '<bean:write property="search_input"/>';
 16         // 工单调度条件
 17         var dispatch = '';
 18     </script>
 19 </head>
 20 <body scroll="no">
 21 <!-- 告警方式-->
 22 <html:hidden property="currentstate" value="1" />
 23 <!--查询SQL-->
 24 <html:hidden property="sToSelectSql" value="" />
 25 <!--过长的查询SQL-->
 26 <html:hidden property="sToSelectSql2" value="" />
 27 <!--查询条件-->
 28 <html:hidden property="queryCond/Entity" value="" />
 29 <div class="autoheight">
 30 
 31     <h2><b>告警接单人查询</b> <span> </span></h2>
 32     
 33     <div class="boxEdit" id='toolbar' style="padding-top: 10px;">
 34         <div class="boxEditItem">
 35             <p class="th_title">ITSM工号:</p>
 36             <div class="textInputWrap w480"><input id='itsmno' class="textInput" type="text" value="请输入ITSM工号" onfocus="if(value=='请输入ITSM工号'){value=''}" onblur="if(value==''){value='请输入ITSM工号'}" /></div>
 37             <div class="btnWrap"><a class="btn btnNormal" href="###" onclick="query()"><span></span><i>搜索</i></a></div>
 38             <div class="btnWrap"><span class="tr_h">精简筛选条件</span></div>
 39         </div>
 40         
 41         <div class="boxEditItem">
 42             <p class="th_title">姓名:</p>
 43             <div class="textInputWrap w190"><input id="staffname" class="textInput" type="text" value="请输入姓名" onfocus="if(value=='请输入姓名'){value=''}" onblur="if(value==''){value='请输入姓名'}" /></div>
 44             <p class="th_title" id="bsn">BSN工号:</p>
 45             <div class="textInputWrap w190" id="bsndiv"><input id="bsnid" class="textInput" type="text" value="请输入BSN工号" onfocus="if(value=='请输入BSN工号'){value=''}" onblur="if(value==''){value='请输入BSN工号'}" /></div>
 46         </div>
 47         
 48         
 49         <div class="boxEditItem">
 50             <p class="th_title">告警:</p>
 51             <div>
 52                 <a class="tags active" href="####" onclick="stateClick('1',this)">BSN告警</a>
 53                 <a class="tags" href="####" onclick="stateClick('2',this)">IT基础设施告警</a>
 54             </div>
 55         </div>
 56         
 57         <div class="fn-clear"></div>
 58         
 59     </div>
 60     <div id="datadiv1">
 61         <table id='table1' style="width:799px; "></table>
 62     </div>
 63     <table id="ordertable" style="width:799px;" >
 64     </table>
 65     
 66     <!-- BSN接单人增加窗口start -->
 67          <div id="WinViewAdd" class="easyui-window" title="新增BSN接单人" data-options="iconCls:'icon-save',closed:true,minimizable:false,top:'0',right:'100'" style="width:500px;height:330px;padding:10px;">
 68              <form id="viewaddform" name="viewaddform" style="padding:10px 20px 10px 40px;">
 69                  <div class="boxEditItem">
 70                      <p class="th_title"><span>*</span>BSN工号:</p>
 71                      <div class="textInputWrap w190"><input name="ITSM_BSN_STAFF/STAFF_ID" class="textInput" type="text"/></div>
 72                     <div class="edit_red" style="display: none;"><em class="col_red"> BSN工号不能为空</em></div>
 73                  </div>
 74                  
 75                  <div class="boxEditItem">
 76                      <p class="th_title"><span>*</span>姓名:</p>
 77                      <div class="textInputWrap w190"><input name="ITSM_BSN_STAFF/STAFF_NAME" class="textInput" type="text"/></div>
 78                     <div class="edit_red" style="display: none;"><em class="col_red"> 姓名不能为空</em></div>
 79                  </div>
 80                  
 81                  <div class="boxEditItem">
 82                      <p class="th_title"><span>*</span>联系电话:</p>
 83                      <div class="textInputWrap w190"><input name="ITSM_BSN_STAFF/STAFF_PHONE" class="textInput" type="text"/></div>
 84                      <div class="edit_red" style="display: none;"><em class="col_red"> 联系电话不能为空</em></div>
 85                  </div>
 86                  
 87                  <div class="boxEditItem">
 88                      <p class="th_title"><span>*</span>综服工号:</p>
 89                      <div class="textInputWrap w190"><input name="ITSM_BSN_STAFF/ITSM_STAFF_ID" class="textInput" type="text"/></div>
 90                      <div class="edit_red" style="display: none;"><em class="col_red"> 综服工号不能为空</em></div>
 91                  </div>
 92                  
 93                  <div class="boxEditItem">
 94                      <p class="th_title"><span>*</span>ITSM工号:</p>
 95                      <div class="textInputWrap w190"><input name="ITSM_BSN_STAFF/NEW_ITSM_STAFF_ID" class="textInput" type="text"/></div>
 96                      <div class="edit_red" style="display: none;"><em class="col_red"> ITSM工号不能为空</em></div>
 97                  </div>
 98                  
 99                  <div class="fn-clear h10"></div>
100                  <div class="boxEditItem">
101                     <p class="th_title">&nbsp;</p>
102                     <div>
103                         <a class="btnLarge" href="####" onclick="addBsnStaffView()"><i>保 存</i></a>  
104                         <a class="btnLarge btnGray" href="####" onclick="$('#viewaddform')[0].reset()"><i>重 置</i></a>
105                     </div>
106                 </div>
107              </form>
108          </div>
109      <!-- BSN接单人增加窗口end -->
110      
111      <!-- BSN接单人修改窗口start -->
112         <div id="WinViewEdit" class="easyui-window" title="修改BSN接单人信息" data-options="iconCls:'icon-save',closed:true,minimizable:false,top:'0',right:'120'" style="width:500px;height:400px;padding:10px;">
113             <form id="vieweditform" name="vieweditform" style="padding:10px 20px 10px 40px;">
114                 <input type="hidden" name="ITSM_BSN_STAFF/ID" />
115                 <input type="hidden" name="updateChk" >
116                 <div class="fn-clear h10"></div>
117                 <div class="boxEdit">
118                 <div class="boxEditItem">
119                      <p class="th_title"><span>*</span>BSN工号:</p>
120                      <div class="textInputWrap w190"><input name="ITSM_BSN_STAFF/STAFF_ID" class="textInput" type="text"/></div>
121                     <div class="edit_red" style="display: none;"><em class="col_red"> BSN工号不能为空</em></div>
122                  </div>
123                 <div class="boxEditItem">
124                      <p class="th_title"><span>*</span>姓名:</p>
125                      <div class="textInputWrap w190"><input name="ITSM_BSN_STAFF/STAFF_NAME" class="textInput" type="text"/></div>
126                     <div class="edit_red" style="display: none;"><em class="col_red"> 姓名不能为空</em></div>
127                  </div>
128                 <div class="boxEditItem">
129                      <p class="th_title"><span>*</span>联系电话:</p>
130                      <div class="textInputWrap w190"><input name="ITSM_BSN_STAFF/STAFF_PHONE" class="textInput" type="text"/></div>
131                     <div class="edit_red" style="display: none;"><em class="col_red"> 联系电话不能为空</em></div>
132                  </div>
133                 <div class="boxEditItem">
134                      <p class="th_title"><span>*</span>综服工号:</p>
135                      <div class="textInputWrap w190"><input name="ITSM_BSN_STAFF/ITSM_STAFF_ID" class="textInput" type="text"/></div>
136                     <div class="edit_red" style="display: none;"><em class="col_red"> 综服工号不能为空</em></div>
137                  </div>
138                 <div class="boxEditItem">
139                      <p class="th_title"><span>*</span>ITSM工号:</p>
140                      <div class="textInputWrap w190"><input name="ITSM_BSN_STAFF/NEW_ITSM_STAFF_ID" class="textInput" type="text"/></div>
141                     <div class="edit_red" style="display: none;"><em class="col_red"> ITSM工号不能为空</em></div>
142                  </div>
143                  
144                  <div class="fn-clear h10"></div>
145                  
146                 <div class="boxEditItem">
147                     <p class="th_title">&nbsp;</p>
148                     <div>
149                         <a class="btnLarge" href="####" onclick="UpdateBsnView()"><i>保 存</i></a>  
150                     </div>
151                 </div>
152                 </div>
153                 <div class="fn-clear h5"></div>
154             </form>
155         </div>
156     <!-- BSN接单人修改窗口end -->
157     
158     <!-- IT基础设施告警接单人增加窗口start -->
159          <div id="WinViewAddIt" class="easyui-window" title="新增IT基础设施告警接单人" data-options="iconCls:'icon-save',closed:true,minimizable:false,top:'0',right:'100'" style="width:500px;height:330px;padding:10px;">
160              <form id="viewItaddform" name="viewItaddform" style="padding:10px 20px 10px 40px;">
161                  <div class="boxEditItem">
162                      <p class="th_title"><span>*</span>ITSM工号:</p>
163                      <div class="textInputWrap w190"><input name="ITSM_C_ITJJSS_STAFF/STAFF_ID" class="textInput" type="text"/></div>
164                     <div class="edit_red" style="display: none;"><em class="col_red"> ITSM工号不能为空</em></div>
165                  </div>
166                  
167                  <div class="boxEditItem">
168                      <p class="th_title"><span>*</span>姓名:</p>
169                      <div class="textInputWrap w190"><input name="ITSM_C_ITJJSS_STAFF/STAFF_NAME" class="textInput" type="text"/></div>
170                     <div class="edit_red" style="display: none;"><em class="col_red"> 姓名不能为空</em></div>
171                  </div>
172                  
173                  <div class="boxEditItem">
174                      <p class="th_title"><span>*</span>联系电话:</p>
175                      <div class="textInputWrap w190"><input name="ITSM_C_ITJJSS_STAFF/STAFF_PHONE" class="textInput" type="text"/></div>
176                      <div class="edit_red" style="display: none;"><em class="col_red"> 联系电话不能为空</em></div>
177                  </div>
178                  
179                  <div class="fn-clear h10"></div>
180                  <div class="boxEditItem">
181                     <p class="th_title">&nbsp;</p>
182                     <div>
183                         <a class="btnLarge" href="####" onclick="addItStaffView()"><i>保 存</i></a>  
184                         <a class="btnLarge btnGray" href="####" onclick="$('#viewItaddform')[0].reset()"><i>重 置</i></a>
185                     </div>
186                 </div>
187              </form>
188          </div>
189      <!-- IT基础设施告警接单人增加窗口end -->
190      
191      <!-- IT基础设施告警接单人修改窗口start -->
192         <div id="WinViewEditIt" class="easyui-window" title="修改IT基础设施告警接单人信息" data-options="iconCls:'icon-save',closed:true,minimizable:false,top:'0',right:'120'" style="width:500px;height:400px;padding:10px;">
193             <form id="vieweditItform" name="vieweditItform" style="padding:10px 20px 10px 40px;">
194                 <input type="hidden" name="ITSM_C_ITJJSS_STAFF/ID" />
195                 <input type="hidden" name="updateChk" >
196                 <div class="fn-clear h10"></div>
197                 <div class="boxEdit">
198                 <div class="boxEditItem">
199                      <p class="th_title"><span>*</span>ITSM工号:</p>
200                      <div class="textInputWrap w190"><input name="ITSM_C_ITJJSS_STAFF/STAFF_ID" class="textInput" type="text"/></div>
201                     <div class="edit_red" style="display: none;"><em class="col_red"> ITSM工号不能为空</em></div>
202                  </div>
203                 <div class="boxEditItem">
204                      <p class="th_title"><span>*</span>姓名:</p>
205                      <div class="textInputWrap w190"><input name="ITSM_C_ITJJSS_STAFF/STAFF_NAME" class="textInput" type="text"/></div>
206                     <div class="edit_red" style="display: none;"><em class="col_red"> 姓名不能为空</em></div>
207                  </div>
208                 <div class="boxEditItem">
209                      <p class="th_title"><span>*</span>联系电话:</p>
210                      <div class="textInputWrap w190"><input name="ITSM_C_ITJJSS_STAFF/STAFF_PHONE" class="textInput" type="text"/></div>
211                     <div class="edit_red" style="display: none;"><em class="col_red"> 联系电话不能为空</em></div>
212                  </div>
213                  
214                  <div class="fn-clear h10"></div>
215                  
216                 <div class="boxEditItem">
217                     <p class="th_title">&nbsp;</p>
218                     <div>
219                         <a class="btnLarge" href="####" onclick="UpdateItView()"><i>保 存</i></a>  
220                     </div>
221                 </div>
222                 </div>
223                 <div class="fn-clear h5"></div>
224             </form>
225         </div>
226     <!-- IT基础设施告警接单人修改窗口end -->
227     
228     <!-- 页面底部留白 -->
229     <div class="clearfix h10"></div>
230 </div>
231 </body>
232 </html>
query.jsp

增删改查js

// 获取查询列表json数据的链接
var queryUrl = "";
// 第一次加载标志位。
var loadState = 0;
$(document).ready(function(){
    SERVICEDATAGRID = $('#ordertable');
    CreateParam();
    // 设置查询链接
    joinUrl();
    loadgrid();
    
});
/**
* 接单人查询
*/
function query(){
    // 查询时设置按钮不可用,防止重复查询
    // 创建查询语句和查询条件
    CreateParam();
    // 设置查询链接
    joinUrl();
    $("#ordertable").datagrid('options').url = queryUrl;
    $("#ordertable").datagrid('load');
    //alert($("input[name='currentstate']").val());
    //当查询IT基础设施的时候隐藏BSN工号、综服工号列
    if($("input[name='currentstate']").val()==2){
        $('#ordertable').datagrid('hideColumn','STAFF_ID');
        $('#ordertable').datagrid('hideColumn','ITSM_STAFF_ID');
        document.getElementById("bsn").style.display="none";
        document.getElementById("bsnid").style.display="none";
        document.getElementById("bsndiv").style.display="none";
        //$('#bsnid').hide();
    }else{
        $('#ordertable').datagrid('showColumn','STAFF_ID');
        $('#ordertable').datagrid('showColumn','ITSM_STAFF_ID');
        document.getElementById("bsn").style.display="";
        document.getElementById("bsnid").style.display="";
        document.getElementById("bsndiv").style.display="";
    }
    // 清空选中行
    SERVICEDATAGRID.datagrid('clearSelections');
}
// 选择告警
function stateClick(status,Obj){
    $(Obj).parent().find('a').removeClass().addClass("tags");
    $(Obj).removeClass().addClass("tags active");
    $("input[name='currentstate']").val(status);
    query();
}

/**
* 创建查询语句
*/
function CreateParam(){
    // ITSM工号
    var itsmBaseID = $('#itsmno').val();
    if(itsmBaseID == '请输入ITSM工号'){
        itsmBaseID = "";
    }
    // 工单类型
    var StaffName = $('#staffname').val();
    if(StaffName == '请输入姓名'){
        StaffName = "";
    }
    // BSN工号
    var BsnId = $('#bsnid').val();
    if(BsnId == '请输入BSN工号'){
        BsnId = "";
    }
    // 告警
    var CURRENTSTATE= $("input[name='currentstate']").val();
    
    // 忽略空格
    itsmBaseID = itsmBaseID.replace(/\s/g,'');
    StaffName = StaffName.replace(/\s/g,'');
    BsnId = BsnId.replace(/\s/g,'');
      
    var i=0;
    var dt=[];
    var Sql="";      
    if(CURRENTSTATE==1){
        Sql = "SELECT a.ID,a.STAFF_ID,a.STAFF_NAME,a.STAFF_PHONE,a.ITSM_STAFF_ID,a.NEW_ITSM_STAFF_ID,a.UPDATE_TIME FROM itsm.ITSM_BSN_STAFF a where 1=1 ";
    }else{
        Sql = "select a.ID,'' as STAFF_ID,a.STAFF_NAME,a.STAFF_PHONE,'' as ITSM_STAFF_ID,a.STAFF_ID as NEW_ITSM_STAFF_ID,a.UPDATE_TIME from itsm.ITSM_C_ITJJSS_STAFF a where 1=1 ";
    }
    var whereSql = "";
    if(BsnId!=""){
        if(CURRENTSTATE==1){
            whereSql = whereSql +" and a.STAFF_ID like {eos_string}" ;
            dt.push({name:'FormEntity/A'+i++,value: '¥'+BsnId+'¥'});
        }
    }
    if(StaffName!=""){
        whereSql = whereSql +" and a.STAFF_NAME like {eos_string}" ;
        dt.push({name:'FormEntity/A'+i++,value: '¥'+StaffName+'¥'});
    }
    if(itsmBaseID!=""){
        if(CURRENTSTATE==1){
            whereSql = whereSql +" and a.NEW_ITSM_STAFF_ID like {eos_string}" ;
            dt.push({name:'FormEntity/A'+i++,value: '¥'+itsmBaseID+'¥'});
        }else{
            whereSql = whereSql +" and a.STAFF_ID like {eos_string}" ;
            dt.push({name:'FormEntity/A'+i++,value: '¥'+itsmBaseID+'¥'});
        }
    }
    var Sql = Sql+whereSql;
    var order = " order by a.ID desc";
    var xmlSql="<FormEntity>";
    for(var k=0;k<dt.length;k++){
        var tempNode=dt[k].name;
        xmlSql+="<"+tempNode.substring(tempNode.indexOf("/")+1)+">"+dt[k].value+"</"+tempNode.substring(tempNode.indexOf("/")+1)+">";
    }
    xmlSql+="</FormEntity>";
    // 由于url字符串长度限制,所以当长度大于1800时则自动截取,sToSelectSql2中不能有中文!
    if(Sql.length > 1800){
        $("input[name='sToSelectSql']").val(Sql.substr(0,1500));
        $("input[name='sToSelectSql2']").val(Sql.substr(1500));
    }else{
        $("input[name='sToSelectSql']").val(Sql);
        $("input[name='sToSelectSql2']").val("");
    }
    $("input[name='queryCond/Entity']").val(xmlSql);
}
// 查询url
function joinUrl(){
    queryUrl = 'ChangeFbrole.prYunWei.prStaffQueryAll.do?sToSelectSql='+$('input[name="sToSelectSql"]').val()+"&queryCond/Entity="+$('input[name="queryCond/Entity"]').val();
}
/*
* 创建列表
*/
function loadgrid(){

    $('#ordertable').datagrid({
        // 设置宽高
        width:'799',
        // 可折叠
        collapsible:true,
        // 查询条件
        toolbar: toolbar,
        // 标题
        title:'告警接单人查询列表',
        // 表格自适应当前页面大小
        fit:false,
        // 长度超出列宽时自动截取
        nowrap: false,
        // 列自适应表格大小          
        fitColumns:true,
        // 是否只能选中一行              
        singleSelect:false,
        // 选中一行时则选中当前行的复选框             
        selectOnCheck:true,
        // 查询逻辑逻辑
        url:queryUrl,
        // 排序字段,传入后台
        sortName: 'STAFF_ID',
        // 排序方式,传入后台
        sortOrder: 'desc',
        // 返回行样式
        rowStyler:function(index,row){
               if(row.PROCESSTIMEOUT == "Y"){
                   if(row.ACTIVITYTIMEOUT == "N"){
                       return "background-color: orange;color:#fff;";
                   }else{
                       return "background-color: red;color:#fff;";
                   }
               }
        },
// 查询参数
        queryParams:{
                 /* 查询条件
                 * 拼接查询字段传入后台。
                 * 注意:查询条件的中文会出现乱码,所以存在中文的条件放在url?之后。
                 * 必须使用存在中文的查询参数时,需要进行编码之后传入后台进行解码
                 */
                 'SortOrder/order':function(){
                                 
                                 var ordersql = "";
                                 
                                 sortName = $('#ordertable').datagrid('options').sortName;
                                 
                                 sortOrder = $('#ordertable').datagrid('options').sortOrder;
                                 
                                 ordersql = " order by " + sortName + " " + sortOrder;
                                 
                                 return ordersql;
                             },
             
                 'PageCond/begin':function (){
                                     var begin = 0;
                                     // 每页记录数
                                     var size = $('#ordertable').datagrid('getPager').pagination('options').pageSize;
                                     // 页码
                                     var page = $('#ordertable').datagrid('getPager').pagination('options').pageNumber;
                                     if(page > 1){
                                         begin = size * (page - 1);
                                     }
                                     return begin;
                                 },
                 
                 'PageCond/length':function (){return $('#ordertable').datagrid('getPager').pagination('options').pageSize;},
                 
                 'fresh':false,
                 
                 'dispatch':'',
                 
                 'ReplaceType':1,
                 
                 'sToSelectSql2':function (){return $('input[name="sToSelectSql2"]').val();}
                 
        },
// 是否从服务器获取数据进行排序
        remoteSort: true,
// id字段
        idField:'ID',
// 设置标题和对应列数据的id
        columns:[[
              
                 /* 
                 *field:必须。对应查询结果的字段名称。
                 *titile:必须。对应列显示标题。
                 *width:必须。按照比例显示列宽。
                 *sortable:可选。是否可以排序。
                 *formatter:可选。格式化。
                 *hidden:可选。是否隐藏列。
                 */
            {field:'ck',checkbox:true},
             
              {field:'ID',title:'id',hidden:true},
              
              {field:'STAFF_ID',title:'BSN工号',width:2.5*80,align:'center',sortable:true},
              
            {field:'STAFF_NAME',title:'姓名',width:2*80,align:'center',sortable:true},
              
            {field:'STAFF_PHONE',title:'联系电话',width:2*80,align:'center',sortable:true},
              
            {field:'ITSM_STAFF_ID',title:'综服工号',width:2*80,align:'center',sortable:true,hidden:true},
            
            {field:'NEW_ITSM_STAFF_ID',title:'ITSM工号',width:2*80,align:'center',sortable:true},
            
            {field:'UPDATE_TIME',title:'更新时间',width:2*80,align:'center',sortable:true,formatter:formatUpdateTime},

        ]],
// 是否可以分页
        pagination:true,
// 从第几页开始显示
        pageNumber:1,
// 每页显示记录数
        pageSize:10,
// 可供选择的每页记录数
        pageList:[10],           
// 是否显示行数:这里的行是显示所有记录的行,总数太多时不建议使用,因为默认的行列无法自适应,总数超过4位数时就无法全部显示。
        rownumbers:false,
// 在请求载入数据之前触发,如果返回false将取消载入。             
        onBeforeLoad:function(){
        },
// 当数据载入成功时触发:列表查询完成时使查询按钮可用              
        onLoadSuccess:function(){
        },
// 当载入远程数据发生错误时触发。
        onLoadError:function(){
               $.messager.alert("提示信息","数据载入失败!","error");
        }
    });
}

// 表格按钮
var toolbar = [{  
    text:'增加',  
    iconCls:'icon-add',  
    handler:function(){
        //alert($("input[name='currentstate']").val());
        if($("input[name='currentstate']").val()==1){
            $('#viewaddform')[0].reset();    // 重置表单元素
            $('#WinViewAdd').window('open');    // 打开服务增加窗口
        }else{
            $('#viewItaddform')[0].reset();    // 重置表单元素
            $('#WinViewAddIt').window('open');    // 打开服务增加窗口
        }
    }  
},{  
    text:'删除',  
    iconCls:'icon-remove',  
    handler:function(){
        var row = SERVICEDATAGRID.datagrid('getSelections'); 
        if(row.length == 0){
            $.messager.alert('提示信息','请先选中一行!','warning');
        }else{
             $.messager.confirm('提示信息', '是否确认删除选中接单人?', function(r){
                if (r){
                    if($("input[name='currentstate']").val()==1){
                        delBsnStaffViews();
                    }else{
                        delItStaffViews();
                    }
                }
            });
        }
    }  
},{  
    text:'修改',  
    iconCls:'icon-edit',  
    handler:function(){
        var row = SERVICEDATAGRID.datagrid('getSelections'); 
        if(row.length == 0){
            $.messager.alert('提示信息','请先选中一行!','warning');
        }else if(row.length > 1){
            $.messager.alert('提示信息','修改时只能选中一行!','warning');
        }else{
            if($("input[name='currentstate']").val()==1){
                // 打开修改界面
                $('#WinViewEdit').window('open');
                // 赋值
                var editObj = $('#vieweditform');
                editObj.find("input[name='ITSM_BSN_STAFF/STAFF_ID']").val(row[0]['STAFF_ID']);
                editObj.find("input[name='ITSM_BSN_STAFF/STAFF_NAME']").val(row[0]['STAFF_NAME']);
                editObj.find("input[name='ITSM_BSN_STAFF/STAFF_PHONE']").val(row[0]['STAFF_PHONE']);
                editObj.find("input[name='ITSM_BSN_STAFF/ITSM_STAFF_ID']").val(row[0]['ITSM_STAFF_ID']);
                editObj.find("input[name='ITSM_BSN_STAFF/NEW_ITSM_STAFF_ID']").val(row[0]['NEW_ITSM_STAFF_ID']);
                editObj.find("input[name='ITSM_BSN_STAFF/ID']").val(row[0]['ID']);
            }else{
                // 打开修改界面
                $('#WinViewEditIt').window('open');
                // 赋值
                var editObj = $('#vieweditItform');
                editObj.find("input[name='ITSM_C_ITJJSS_STAFF/STAFF_ID']").val(row[0]['NEW_ITSM_STAFF_ID']);
                editObj.find("input[name='ITSM_C_ITJJSS_STAFF/STAFF_NAME']").val(row[0]['STAFF_NAME']);
                editObj.find("input[name='ITSM_C_ITJJSS_STAFF/STAFF_PHONE']").val(row[0]['STAFF_PHONE']);
                editObj.find("input[name='ITSM_C_ITJJSS_STAFF/ID']").val(row[0]['ID']);
            }
        }
    }  
}]; 
/**
保存新增BSN接单人
*/
function addBsnStaffView(){
    // 定义所属form
    var formobj = $('#viewaddform');
    var staffId = formobj.find("input[name='ITSM_BSN_STAFF/STAFF_ID']").val();
    var staffName = formobj.find("input[name='ITSM_BSN_STAFF/STAFF_NAME']").val();
    var staffPhone = formobj.find("input[name='ITSM_BSN_STAFF/STAFF_PHONE']").val();
    var issId = formobj.find("input[name='ITSM_BSN_STAFF/ITSM_STAFF_ID']").val();
    var itsmId = formobj.find("input[name='ITSM_BSN_STAFF/NEW_ITSM_STAFF_ID']").val();
    
    if(staffId == ""){
        $.messager.alert('提示信息','BSN工号不能为空!','warning');
        formobj.find("input[name='ITSM_BSN_STAFF/STAFF_ID']").parent().parent().find('.edit_red').show();    // 显示红字提示信息
        return;
    }else if(staffName == ""){
        $.messager.alert('提示信息','姓名不能为空!','warning');
        formobj.find("input[name='ITSM_BSN_STAFF/STAFF_NAME']").parent().parent().find('.edit_red').show();
        return;
    }else if(staffPhone == ""){
        $.messager.alert('提示信息','联系电话不能为空!','warning');
        formobj.find("input[name='ITSM_BSN_STAFF/STAFF_PHONE']").parent().parent().find('.edit_red').show();
        return;
    }else if(issId == ""){
        $.messager.alert('提示信息','综服工号不能为空!','warning');
        formobj.find("input[name='ITSM_BSN_STAFF/ITSM_STAFF_ID']").parent().parent().find('.edit_red').show();
        return;
    }else if(itsmId == ""){
        $.messager.alert('提示信息','综服工号不能为空!','warning');
        formobj.find("input[name='ITSM_BSN_STAFF/NEW_ITSM_STAFF_ID']").parent().parent().find('.edit_red').show();
        return;
    }

    var sub = new HiddenSubmit("ChangeFbrole.bizYunWei.bizSaveBsnStaff");
    if(sub.submitForm(document.forms.viewaddform)){
        // 保存成功提示信息,显示1秒
        $.messager.show({
            title:'提示信息',
            msg:'增加成功.',
            timeout:1000,
            style:{
                right:'',
                top:'150'
            }
        });
        //关闭增加窗口
        $('#WinViewAdd').window('close');
        //刷新表格
        SERVICEDATAGRID.datagrid('load');
    }else{
        $.messager.alert('提示信息','保存失败!','error');
    }
}
//删除BSN接单人
function delBsnStaffViews(){
    var selects = SERVICEDATAGRID.datagrid('getSelections');
    var sub = new HiddenSubmit('ChangeFbrole.bizYunWei.bizDelBsnStaffViews');
    var xmlstr = ''
    for(var i=0;i<selects.length;i++){
        xmlstr = xmlstr + '<ITSM_BSN_STAFF><ID>' + selects[i]['ID'] + '</ID></ITSM_BSN_STAFF>'
    }
    sub.add('xmlstr',xmlstr);
    if(sub.submit()){
        // 删除成功提示信息,显示1秒
        $.messager.show({
            title:'提示信息',
            msg:'删除成功.',
            timeout:1000,
            style:{
                   right:'',
                   top:'150'
               }
        });
        //刷新表格
        SERVICEDATAGRID.datagrid('load');
        // 清空选中行
        SERVICEDATAGRID.datagrid('clearSelections');
    }else{
        $.messager.alert('提示信息','删除失败!','error');
    };
}
//修改Bsn接单人信息
function UpdateBsnView(){
    // 定义所属form
    var formobj = $('#vieweditform');
    var staffId = formobj.find("input[name='ITSM_BSN_STAFF/STAFF_ID']").val();
    var staffName = formobj.find("input[name='ITSM_BSN_STAFF/STAFF_NAME']").val();
    var staffPhone = formobj.find("input[name='ITSM_BSN_STAFF/STAFF_PHONE']").val();
    var issId=formobj.find("input[name='ITSM_BSN_STAFF/ITSM_STAFF_ID']").val();
    var itsmId=formobj.find("input[name='ITSM_BSN_STAFF/NEW_ITSM_STAFF_ID']").val();
    var sc_id=formobj.find("input[name='ITSM_BSN_STAFF/ID']").val();

    if(staffId == ""){
        $.messager.alert('提示信息','BSN工号不能为空!','warning');
        formobj.find("input[name='ITSM_BSN_STAFF/STAFF_ID']").parent().parent().find('.edit_red').show();
        return;    
    }else if(staffName == ""){
        $.messager.alert('提示信息','姓名不能为空!','warning');
        formobj.find("input[name='ITSM_BSN_STAFF/STAFF_NAME']").parent().parent().find('.edit_red').show();
        return;
    }else if(staffPhone == ""){
        $.messager.alert('提示信息','联系电话不能为空!','warning');
        formobj.find("input[name='ITSM_BSN_STAFF/STAFF_PHONE']").parent().parent().find('.edit_red').show();
        return;
    }else if(itsmId == ""){
        $.messager.alert('提示信息','ITSM工号不能为空!','warning');
        formobj.find("input[name='ITSM_BSN_STAFF/NEW_ITSM_STAFF_ID']").parent().parent().find('.edit_red').show();
        return;
    }
    
    var sub = new HiddenSubmit("ChangeFbrole.bizYunWei.bizUpdateBsnView");
    if(sub.submitForm(document.forms.vieweditform)){
    sub.add('ITSM_BSN_STAFF/ID',sc_id);
        // 保存成功提示信息,显示1秒
        $.messager.show({
            title:'提示信息',
            msg:'修改成功.',
            timeout:1000,
            style:{
                right:'',
                top:'150'
            }
        });
        //关闭增加窗口
        $('#WinViewEdit').window('close');
        //刷新当前页
        SERVICEDATAGRID.datagrid('reload');
    }else{
        $.messager.alert('提示信息','保存失败!','error');
    };
}

/**
保存新增IT基础设施接单人
*/
function addItStaffView(){
    // 定义所属form
    var formobj = $('#viewItaddform');
    var staffId = formobj.find("input[name='ITSM_C_ITJJSS_STAFF/STAFF_ID']").val();
    var staffName = formobj.find("input[name='ITSM_C_ITJJSS_STAFF/STAFF_NAME']").val();
    var staffPhone = formobj.find("input[name='ITSM_C_ITJJSS_STAFF/STAFF_PHONE']").val();
    
    if(staffId == ""){
        $.messager.alert('提示信息','ITSM工号不能为空!','warning');
        formobj.find("input[name='ITSM_C_ITJJSS_STAFF/STAFF_ID']").parent().parent().find('.edit_red').show();    // 显示红字提示信息
        return;
    }else if(staffName == ""){
        $.messager.alert('提示信息','姓名不能为空!','warning');
        formobj.find("input[name='ITSM_C_ITJJSS_STAFF/STAFF_NAME']").parent().parent().find('.edit_red').show();
        return;
    }else if(staffPhone == ""){
        $.messager.alert('提示信息','联系电话不能为空!','warning');
        formobj.find("input[name='ITSM_C_ITJJSS_STAFF/STAFF_PHONE']").parent().parent().find('.edit_red').show();
        return;
    }
    //$("input[name='currentstate']").val()
    var sub = new HiddenSubmit("ChangeFbrole.bizYunWei.bizSaveItStaff");
    if(sub.submitForm(document.forms.viewItaddform)){
        // 保存成功提示信息,显示1秒
        $.messager.show({
            title:'提示信息',
            msg:'增加成功.',
            timeout:1000,
            style:{
                right:'',
                top:'150'
            }
        });
        //关闭增加窗口
        $('#WinViewAddIt').window('close');
        //刷新表格
        SERVICEDATAGRID.datagrid('load');
    }else{
        $.messager.alert('提示信息','保存失败!','error');
    }
}

//删除IT基础设施告警接单人
function delItStaffViews(){
    var selects = SERVICEDATAGRID.datagrid('getSelections');
    var sub = new HiddenSubmit('ChangeFbrole.bizYunWei.bizDelItStaffViews');
    var xmlstr = ''
    for(var i=0;i<selects.length;i++){
        xmlstr = xmlstr + '<ITSM_C_ITJJSS_STAFF><ID>' + selects[i]['ID'] + '</ID></ITSM_C_ITJJSS_STAFF>'
    }
    sub.add('xmlstr',xmlstr);
    if(sub.submit()){
        // 删除成功提示信息,显示1秒
        $.messager.show({
            title:'提示信息',
            msg:'删除成功.',
            timeout:1000,
            style:{
                   right:'',
                   top:'150'
               }
        });
        //刷新表格
        SERVICEDATAGRID.datagrid('load');
        // 清空选中行
        SERVICEDATAGRID.datagrid('clearSelections');
    }else{
        $.messager.alert('提示信息','删除失败!','error');
    };
}

//修改IT基础设施告警接单人信息
function UpdateItView(){
    // 定义所属form
    var formobj = $('#vieweditItform');
    var staffId = formobj.find("input[name='ITSM_C_ITJJSS_STAFF/STAFF_ID']").val();
    var staffName = formobj.find("input[name='ITSM_C_ITJJSS_STAFF/STAFF_NAME']").val();
    var staffPhone = formobj.find("input[name='ITSM_C_ITJJSS_STAFF/STAFF_PHONE']").val();
    var sc_id=formobj.find("input[name='ITSM_C_ITJJSS_STAFF/ID']").val();

    if(staffId == ""){
        $.messager.alert('提示信息','ITSM工号不能为空!','warning');
        formobj.find("input[name='ITSM_C_ITJJSS_STAFF/STAFF_ID']").parent().parent().find('.edit_red').show();
        return;    
    }else if(staffName == ""){
        $.messager.alert('提示信息','姓名不能为空!','warning');
        formobj.find("input[name='ITSM_C_ITJJSS_STAFF/STAFF_NAME']").parent().parent().find('.edit_red').show();
        return;
    }else if(staffPhone == ""){
        $.messager.alert('提示信息','联系电话不能为空!','warning');
        formobj.find("input[name='ITSM_C_ITJJSS_STAFF/STAFF_PHONE']").parent().parent().find('.edit_red').show();
        return;
    }
    
    var sub = new HiddenSubmit("ChangeFbrole.bizYunWei.bizUpdateItView");
    if(sub.submitForm(document.forms.vieweditItform)){
    sub.add('ITSM_C_ITJJSS_STAFF/ID',sc_id);
        // 保存成功提示信息,显示1秒
        $.messager.show({
            title:'提示信息',
            msg:'修改成功.',
            timeout:1000,
            style:{
                right:'',
                top:'150'
            }
        });
        //关闭增加窗口
        $('#WinViewEditIt').window('close');
        //刷新当前页
        SERVICEDATAGRID.datagrid('reload');
    }else{
        $.messager.alert('提示信息','保存失败!','error');
    };
}

// 格式化时间
function formatUpdateTime(val,row){
    var str
    if(val != ""){
        str= val.substr(0,4) + "-" + val.substr(4,2) + "-" + val.substr(6,2) + " " + val.substr(8,2) + ":" + val.substr(10,2) + ":" + val.substr(12,2);
    }
    return str
}
QueryStaff.js

 

posted @ 2015-07-07 17:43  Yes,I do  阅读(563)  评论(0编辑  收藏  举报