<%@ page language="C#" autoeventwireup="true" inherits="SB_admin_N47_Project, App_Web_wkioulim" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>操作</title>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/SB/control/easy_ui/jquery.min.js?v=1")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/SB/control/easy_ui/jquery.easyui.min.js?v=1")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/SB/control/easy_ui/locale/easyui-lang-zh_CN.js?v=1")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/SB/control/easy_ui/jquery.load.js?v=1")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/SB/control/easy_ui/jquery.json.js?v=1")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/SB/control/easy_ui/jquery.easyui.validtor.js?v=1")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/SB/control/js/PageDialog.js?v=1")%>"></script>
    <link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~/SB/control/easy_ui/themes/bootstrap/easyui.css?v=1")%>" />
    <link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~/SB/control/easy_ui/themes/icon.css?v=1")%>" />
    <link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~/SB/control/easy_ui/load.css?v=1")%>" />
    <link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~/SB/control/css/main.css?v=1")%>" />
    <script language="javascript" type="text/javascript">
       var currentMenuKey = null;
       function query(){
	        $("#dataview").datagrid("load",{
			p_name: $("#qp_name").val(),
			c_name: $("#qp_customer").val(),
			p_notPlan: $("#qp_notPlan").get(0).checked,
			p_march: $("#qp_march").get(0).checked,
			p_complete: $("#qp_complete").get(0).checked,
			p_user:$("#txtUser").size()!=0?$('#txtUser').combobox('getValue'):''
			
			});
   	   }
   	   
   	   $(function(){
   	        $("body").css("visibility","visible"); 
   	        if(!<%=isadd %>)
   	        $("#addbtn").linkbutton('disable');
   	        if(!<%=isdelete %>)
   	        $("#deletebtn").remove();
   	   });
   	   function showMenu(obj,id,edit,dlt){
   	        var e = $(obj).offset();
            openMenu(e.left,e.top+10,id,edit,dlt);
   	   }
   	   
   	   function openMenu(left,top,id,isEdit,isDelete){
          $('#OperMenu').menu('show',{  
                    left:left,  
                    top: top 
            });
            currentMenuKey = id;
   
            var menus = $('#OperMenu');
            if( isEdit){
                menus.menu('enableItem', menus.menu('getItem', $("#m1")[0]).target);
                if($("#m6").size()!=0){
                menus.menu('enableItem',menus.menu('getItem', $("#m6")[0]).target);
                menus.menu('enableItem',menus.menu('getItem', $("#m7")[0]).target);
                }
            }else{
                menus.menu('disableItem', menus.menu('getItem', $("#m1")[0]).target);
                if($("#m6").size()!=0){
                menus.menu('disableItem',menus.menu('getItem', $("#m6")[0]).target);
                menus.menu('disableItem',menus.menu('getItem', $("#m7")[0]).target);
                }
            }
            if( isDelete){
                 menus.menu('enableItem',menus.menu('getItem', $("#m2")[0]).target);
            }else{
                 menus.menu('disableItem',menus.menu('getItem', $("#m2")[0]).target);
            }
            
   	   }
   	   function linkUrl(url,b){
            if(b){
                ShowDialog("show"+currentMenuKey,url+"?pid="+currentMenuKey,1024,768,0,0);
            }
            else{
                location.href=url+"?pid="+currentMenuKey;
            }
   	   }
   	   function userFormat(row){
            var s = '<span >' + row.u_name + '('+row.u_pys+')</span><br/>' +  
                    '<span style="color:#888">(' +row.u_isLogin+')'+ row.u_note + '</span>';  
            return s;  
        }
   </script>
   
   
</head>
<body class="easyui-layout" style="visibility:hidden">
    <div region="center" border="false">
        <table id="dataview">
            <thead>
                <tr>  
					<th field="ck" checkbox="true"></th>
						<th field="id" width="60" formatter='OperFormat'>操作</th>
						<th field="p_index" width="70" >项目编号</th>
						<th field="p_name" width="150" formatter='nameFormat'>项目名称</th>
						<th field="p_customer" width="150" >客户</th>
						<th field="p_notPlan" width="50" formatter='p_notPlanFormat'>未安排</th>
						<th field="p_march" width="50" formatter='p_marchFormat'>进行中</th>
						<th field="p_complete" width="50" formatter='p_completeFormat'>已完成</th>
						<th field="p_depart" width="150" >部门(客户)</th>
						<th field="p_linkman" width="150" >联系人</th>
						<th field="p_tel" width="150" >联系电话</th>
						<th field="p_qq" width="150" >QQ</th>
						<th field="p_contact" width="150" >其他联系方式</th>
						<th field="p_address" width="150" >地址</th>
						
						<th field="p_program" width="150" >设计稿</th>
						<th field="p_production" width="150" >制作稿</th>
						<th field="p_materiel" width="150" >物料完成</th>
						<th field="p_dispatch" width="150" >配送完成</th>
						
			            <th field="p_spe" width="150" >规格</th>
			            <th field="p_quantity" width="150" >数量</th>
			            
			            <%if(isShowPrice){ %>
			            <th field="p_unitPrice" width="150" >单价</th>
			            <th field="p_sumPrice" width="150" >总价格</th>
			            <%} %>
			            
			            <th field="p_unit" width="100" >单位</th>
			         
			            <th field="p_material" width="150" >材料</th>
						<th field="p_internalMaterial" width="150" >内页用纸</th>
						<th field="p_outMaterial" width="150" >外部用纸</th>
						<th field="p_technology" width="150" >其他工艺</th>
						<th field="p_binding" width="150" >拆装工艺</th>
						<th field="p_orderTakers" width="150" >接单人员</th>
						<th field="p_uid" width="150" >项目创建人员</th>
						 <th field="p_note" width="150" >备注</th>
						<th field="p_cdate" width="150" >创建日期</th>
						
                       
				</tr>
            </thead>
        </table>
    </div>
    <div id="toolbar"   style="height:55px"   >
        <a id="addbtn" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="Add()">添 加</a>
        <a id="deletebtn" class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="deleteList()">删除</a>
      
        <br />
        &nbsp;
        <asp:Panel ID="UserQueryPanel" runat="server" style="display:inline">
                人员：
                <input id="txtUser" type="text" class="easyui-combobox" Style="width: 150px"
                data-options="  
                        panelWidth: 150,  
                        valueField: 'id',  
                        textField: 'u_name',  
                        url: 'N47_User/N47_User_ComboData.aspx',
                        formatter: userFormat 
                 "/>
         </asp:Panel>                        
                                 
        		项目名称 ：<input id="qp_name" name="name" type="text" maxlength="255" onkeydown= "if(event.keyCode==13)query()" style="width:100px"/>
				客户 ：<input id="qp_customer" name="name" type="text" maxlength="255" onkeydown= "if(event.keyCode==13)query()" style="width:100px"/>
				
				
				<input id="qp_notPlan" type="checkbox" onclick='$("#qp_march").attr("checked",false);$("#qp_complete").attr("checked",false);' /> <label for="qp_notPlan">未安排</label>  
				<input id="qp_march" type="checkbox" onclick='$("#qp_notPlan").attr("checked",false);$("#qp_complete").attr("checked",false);'/><label for="qp_march">进行中</label>  
				<input id="qp_complete" type="checkbox" onclick='$("#qp_notPlan").attr("checked",false);$("#qp_march").attr("checked",false);'/><label for="qp_complete">已完成</label>  
				
        <a class="easyui-linkbutton" iconcls="icon-search" plain="true" onclick="query()">查询 </a>
        <a class="easyui-linkbutton" iconcls="icon-book" plain="true" onclick="$('#dataview').datagrid('load',{})">全部显示</a>
    </div>
    
    <div id="OperMenu" class="easyui-menu" style="width:120px;">    
            <div id="m1" onclick="editItem()" data-options="iconCls:'icon-edit'">项目编辑</div>  
            <div id="m2" onclick="deleteItem()" data-options="iconCls:'icon-cancel'">项目删除</div>  
            <div id="m3" onclick="linkUrl('N47_Project_WordEmployee.aspx',true)" data-options="iconCls:'icon-user'">人员工作</div>  
            <div id="m4" onclick="linkUrl('N47_WorkSchedule.aspx',true)" data-options="iconCls:'icon-comment'">项目进度</div> 
      
            
        <asp:Panel ID="m5" runat="server" onclick="linkUrl('N47_Project/N47_Project_Print.aspx',true)"  data-options="iconCls:'icon-print'">项目打印</asp:Panel>
            
        <asp:Panel ID="m6" runat="server" onclick="linkUrl('N47_PrintForm.aspx',true)"  data-options="iconCls:'icon-message'">项目制作单</asp:Panel>
       <asp:Panel ID="m7" runat="server" onclick="linkUrl('N47_DeliveryNote.aspx',true)" data-options="iconCls:'icon-subject'">项目送货单</asp:Panel>
       
      
             
            
            
    </div>
    
</body>

<script language="javascript" type="text/javascript">

$(function(){
    
    $("#dataview").datagrid({
        toolbar:"#toolbar",
        fit:true,
        idfield:"id",
        border:false,
        pageSize:30,
        resizable:true,
        pagination:true,
        rownumbers:true,
        url:"N47_Project/N47_Project_Dataview.aspx",
        onLoadSuccess:function(){ $('#dataview').datagrid("unselectAll"); },
        queryParams:{
            p_id:'<%=pid %>'
        },
        onRowContextMenu:function(e,rowindex,row){
            e.preventDefault();
            openMenu(e.pageX,e.pageY,row.id,row.isEdit,row.isDelete);
            $('#dataview').datagrid("unselectAll").datagrid("selectRow",rowindex);
            
    
      }
    });
});

function nameFormat(value,row,index){
    if(row.isCreate){
        return "<IMG SRC='N47_Project/edit.png' />"+value;
    }
    return value;
}
function OperFormat(value,row,index){
      return "<a href='javascript:void(0)' onclick='showMenu(this,\""+value+"\","+row.isEdit+","+row.isDelete+")' >操作菜单</a>";
}

function p_notPlanFormat(value,row,index){
return "<input type='checkbox'  "+ (value?"checked='checked'":"")+" onclick=\"return false;\"  />";
}function p_marchFormat(value,row,index){
return "<input type='checkbox'  "+ (value?"checked='checked'":"")+" onclick=\"return false;\"  />";
}function p_completeFormat(value,row,index){
return "<input type='checkbox'  "+ (value?"checked='checked'":"")+" onclick=\"return false;\"  />";
}

function ToggleShow(key,obj,column){
 	     var check = $(obj);
      
         $.ajax({
            type: "POST",
            url:"N47_Project/N47_Project_SetShow.aspx",
            data: {"id":key,"show":check.get(0).checked,"column":column},
            success: function(data){
                 var result = $.parseJSON(data);
                 if(result.state==1){
                 }else{
                    check.get(0).checked = false;
                    $.messager.show({title: '错误',msg: result.data});
                 }
            }
         }); 
         event.stopPropagation();
   }
function deleteItem(){
     $.messager.confirm('确认','确定要删除选中吗?',function(r){
     if(!r){ return }load("删除中...");
             $.ajax({
                type: "POST",
                url:"N47_Project/N47_Project_Delete.aspx",
                dataType:"json",
                data: {"deleteKey": currentMenuKey},
                success: function(data){
                  unload();
                  if(data.state==1){
                      $.messager.show({title: '提示', msg: data.data});
                      $('#dataview').datagrid('reload').datagrid("unselectAll");
                  }
                  else{
                     $.messager.alert('错误',data.data,'message');
                  }
               }
            });
     });
}
function deleteList(){
     var row = $('#dataview').datagrid('getSelections');
     if(row.length==0){$.messager.alert('提示',"请选择删除项！",'message'); return;}
     $.messager.confirm('确认','确定要删除选中吗?',function(r){
     if(r){
                 load("删除中...");
                 var list = new Array();
                 for(var index =0; index<row.length;index++){ list.push(row[index].id);  }
                 $.ajax({
                    type: "POST",
                    url:"N47_Project/N47_Project_Delete.aspx",
                    dataType:"json",
                    data: {"deleteList": list.join(",")}, 
                    success: function(data){
                      unload();
                      if(data.state==1){
                          $.messager.show({ title: '提示', msg: "总共删除"+data.data+"条信息" });
                          $('#dataview').datagrid('reload').datagrid("unselectAll");
                      }else{
                         $.messager.alert('错误',data.data,'message');
                      }
                   }
                });
     }
     });
}

function editItem(){
    ShowDialog("edit","N47_Project/N47_Project_Edit.aspx?id="+currentMenuKey,920,760,0,100);
}
function Add(){
 	ShowDialog("add","N47_Project/N47_Project_Insert.aspx",1024,768,0,0);
}
function reload(param){
    if(param=='last'){
        var grid = $('#dataview'); 
        var gridOptions = grid.datagrid("options"); 
        var options = grid.datagrid('getPager').data("pagination").options;  
        var pagenumber = options.total==0?1:Math.ceil( options.total/options.pageSize);
        gridOptions.pageNumber = pagenumber 
        options.pageNumber = pagenumber;
        $('#dataview').datagrid('reload');
    }
    $('#dataview').datagrid('reload');
}
</script>

</html>
