list.jsp 14.5 KB
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link href="<%=basePath %>resource/css/base.css" rel="stylesheet">
	<link rel="stylesheet" href="<%=basePath %>resource/easyui/uimaker/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=basePath %>resource/easyui/uimaker/icon.css">
	<link rel="stylesheet" href="<%=basePath %>resource/css/providers.css">
</head>
<body>
    <div class="container">
    <div data-options="closable:true">
       	 <table id="dg" style="width:100%;" title="<spring:message code="manifest.list"/>" 
       	 		data-options="
                rownumbers:true,
                singleSelect:false,
                autoRowHeight:false,
                pagination:true,
                fitColumns:true,
                striped:true,
                collapsible:true,
                toolbar:'#tb',
                pageSize:10">
                <thead>
                        <tr>
                            <!-- <th field="id" checkbox="true"></th> -->
                            <th field="."  formatter="editFormat" width="40"><spring:message code="opt.edit" /></th>
                            <th field="waybillnomaster" sortable="true" width="30"><spring:message code="manifest.bill.number"/></th>
                            <th field="customscode" width="15"><spring:message code="manifest.customs"/></th>
                            <th field="flightno" width="20"><spring:message code="manifest.flight.number"/></th>
                            <th field="originatingstation" width="20"><spring:message code="manifest.starting.point"/></th>
                            <th field="destinationstation" width="20"><spring:message code="manifest.destination"/></th>
                            <%-- <th field="totalpiece" width="50"><spring:message code="manifest.number.of.consignment.note"/></th>--%>
                            <th field="preparetotalweight" width="20"><spring:message code="manifest.pre.weight"/></th>
                            <th field="preparetotalpiece"  width="20"><spring:message code="manifest.number.of.fittings"/></th>
                            <th field="response_text" widht="260"><spring:message code="manifest.response_text" /></th>
                            <th field=".." width="20" formatter="operatorFormat"><spring:message code="opt.operator" /></th>
<%--                        <th field="flightdate" width="130"><spring:message code="manifest.flight.date"/></th> --%>
                        </tr>
                </thead>
           </table>
           <div id="tb" style="padding:0 30px;"><input type="hidden" id="idcc">
	           <form id="searchForm">
		           <table class="search_form_table">	
		                     <spring:message code="manifest.bill.number"/>:<input id="manifnum" type="text" name="search_LIKE_waybillnomaster" style="width:166px;height:35px;line-height:35px;">
		                     <spring:message code="manifest.flight.number"/>:<input class="easyui-textbox" type="text" name="search_LIKE_flightno" style="width:166px;height:35px;line-height:35px;">
		                     <a href="javascript:doSearch()" class="easyui-linkbutton" iconCls="icon-search" data-options="selected:true"><spring:message code="opt.search" /></a>
		                     <a href="javascript:editRow()" class="easyui-linkbutton" style="background:#18A197;color:#FFF;border: 1px solid #18A197;" iconCls="icon-add"><spring:message code="opt.add" /></a>
							 <%--<a href="javascript:doDelete()" class="easyui-linkbutton" style="background:red;color:#FFF;border: 1px solid red" iconCls="icon-no"><spring:message code="opt.delete" /></a> --%>
		          	</table>
	          	</form>
           </div>
    </div>
    
</div>    
<script type="text/javascript" src="<%=basePath %>resource/easyui/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath %>resource/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=basePath %>resource/easyui/easyui-lang-${pageContext.response.locale}.js"></script>
<script type="text/javascript" src="<%=basePath %>resource/easyui/datagrid-detailview.js"></script>
<script type="text/javascript" src="<%=basePath %>resource/js/tools.js"></script>
<!--弹出层引入的JS-->
<script type="text/javascript" src="<%=basePath %>resource/layer-v3.0.3/layer/layer.js"></script>
    <script type="text/javascript">

    $(function(){
        function getPageNumber(){
           	var pageNumber = window.localStorage.getItem("pageNumber");
           	if(typeof(pageNumber) != "undefined")
           	{
           		try{
           			var pattern = /^\d+$/g;		//判断是否是数字
           			
           			//console.log(pageNumber.search(pattern));
           			
           			if(pageNumber.search(pattern) >= 0)
           			{
	           			var num = parseInt(pageNumber);
	           			return num;
           			}
           			return 1;
           		}
           		catch(e){
           			return 1;
           		}
           	}
           	return 1;
        }
        
        //console.log(getPageNumber());
        
        $('#dg').datagrid({
            url:'<%=basePath %>manifest/grid.json',
         	//queryParams:$("#searchForm").serializeJson(),
			pageNumber:getPageNumber(),
            view: detailview,
            detailFormatter:function(index,row){
            	console.log("index:"+index);
                return '<div id="ddv-' + index + '"style="padding:5px 0"></div>';
            },
            onExpandRow: function(index,row){
            	console.log("expand row index:"+index);
                $('#ddv-'+index).datagrid({
                    url:'<%=basePath %>manifest/sub/grid.json?mawbId='+row.id,
                    fitColumns:true,
                    singleSelect:true,
                    loadMsg:'正在加载中……',
                    height:'auto',
                    columns:[[
                    	{field:'.',title:'<spring:message code="opt.name"/>',formatter:editHbillFormat,width:30},
                        {field:'waybillnosecondary',title:'<spring:message code="manifest.odd.number"/>',width:40},
                        {field:'originatingstation',title:'<spring:message code="manifest.starting.point"/>',width:40},
                        {field:'destinationstation',title:'<spring:message code="manifest.destination"/>',width:40},
                        /* {field:'totalpiece',title:'<spring:message code="manifest.number.of.consignment.note"/>',width:60},
                        {field:'totalweight',title:'<spring:message code="manifest.waybill.weight"/>',width:60}, */
                        {field:'prepareweight',title:'<spring:message code="manifest.pre.weight"/>',width:30},
                        {field:'preparepiece',title:'<spring:message code="manifest.number.of.fittings"/>',width:30},
                        {field:'response_text',title:'<spring:message code="manifest.response_text"/>', width:160},
                        {field:'..', title:'<spring:message code="opt.operator" />', formatter:preoperatorFormat, width:40}
                    ]],
                    onResize:function(){
                        $('#dg').datagrid('fixDetailRowHeight',index);
                    },
                    onLoadSuccess:function(){
                        setTimeout(function(){
                            $('#dg').datagrid('fixDetailRowHeight',index);
                        },0);
                        
                        
                        
                    }
                });
                $('#dg').datagrid('fixDetailRowHeight',index);
            }
        });
    });
		
		function editFormat(val,row,index){
	    	var html='<a href="javascript:void(0)" style="padding-left:10px;text-decoration:none;padding-right:20px;" onclick="editRow('+row.id+')"><i class="iconfont">&#xe65a;</i></a>'
	    	  html += '<a href="javascript:void(0)" style="text-decoration:none;margin-left:20px;" onclick="makeHawb('+row.id+')"><i class="iconfont">&#xe663;</i><spring:message code="manifest.new.sheet"/></a>';
	    	return html;
	    }
		//分单撤销按钮
		function preoperatorFormat(val, row, index){
			return "<a href='javascript:void(0)' onclick='prebackout("+row.id+")' style='text-decoration:none;'><spring:message code='opt.backout' /></a>";
		}
		function prebackout(id){
			if(typeof(id) == "undefined")
				return;
			layer.confirm("确定要撤销吗?", function(flag){
				layer.close(flag);
				$.ajax({
					url:"<%=basePath %>/manifest/prebackout",
					data:{
						id:id
					},
					success:function(data){
						if(data.status == 200)
							layer.alert("撤销请求已发送!");
						else
							layer.alert("撤销请求发送失败!");
					}
				});
			});
		}
		//主单撤销按钮
		function operatorFormat(val, row, index){
			return "<a href='javascript:void(0)' onclick='backout("+row.id+")' style='text-decoration:none;'><spring:message code='opt.backout'/></a>";
		}
		function backout(id){
			if(typeof(id) == "undefined")
				return;
			layer.confirm("确定要撤销吗?", function(flag){
				layer.close(flag);
				//提交到后台,发送一个撤销报文
				$.ajax({
					url:"<%=basePath %>/manifest/backout",
					data:{
						id:id
					},
					success:function(data){
						if(data.status == 200)
							layer.alert("撤销请求已发送!");
						else
							layer.alert("撤销请求发送失败!");
					}
				});
			});
		}
		 //制分单
	    function makeHawb(id){
	        window.location.href="<%=basePath %>manifest/subedit?mawbId="+id;
	    }
		 
	    //分单编辑
	    function editHbillRow(id){
	        window.location.href="<%=basePath %>manifest/subedit?id="+id;
	    }
		 
	    function editHbillFormat(val,row,index){
	        var html='<a href="javascript:void(0)" style="text-decoration:none;margin-left:20px;" onclick="editHbillRow('+row.id+')"><i class="iconfont">&#xe65a;</i></a>';
// 	        html += '<a href="javascript:void(0)" style="text-decoration:none;margin-left:20px;color:red;" onclick="delHbillRow('+row.id+','+row.mawbId+','+index+')"><i class="iconfont">&#xe661;</i></a>';
	        return html;
	    }

		
		function editRow(id){
			var page = $("#dg").datagrid("getPager").data("pagination").options;
			window.localStorage.setItem("pageNumber", page.pageNumber);
	        if(id==undefined){
	            window.location.href='<%=basePath %>manifest/edit?id=';
	        }else{
	            window.location.href='<%=basePath %>manifest/edit?id='+id;
	        }
	    }
	    
	    function doSearch(){
	    	$('#dg').datagrid("options").queryParams=$("#searchForm").serializeJson();
	    	$('#dg').datagrid("reload");
	    }

        function getIds() {
            var ids = [];
            var rows = $("#dg").datagrid('getChecked');
            $.each(rows,function(key,v){
                ids.push(v.id);
            });
            return ids;
        }
        
      	//分单删除
        function delHbillRow(id,mawbId,index){
            $.post("<%=basePath %>manifest/subdelete",{id:id},function(data){
                if(data.status == 200) {
                        $('#ddv-'+index).datagrid({
                            url:'<%=basePath %>manifest/sub/grid.json?mawbId='+id,
                            queryParams:$("#searchForm").serializeJson(),
                            fitColumns:true,
                            singleSelect:true,
                            loadMsg:'',
                            height:'auto',
                            columns:[[
                                {field:'.',title:'<spring:message code="opt.name"/>',formatter:editHbillFormat,width:80},
                                {field:'hawbNo',title:'<spring:message code="bill.hawbNo"/>',width:100},
                                {field:'totalPieces',title:'<spring:message code="bill.pieces"/>',width:100},
                                {field:'grossWeight',title:'<spring:message code="bill.weightcharge"/>',width:100},
                                {field:'goodsName',title:'<spring:message code="bill.productname"/>',width:100},
                                {field:'departureStation',title:'<spring:message code="bill.orilocation"/>',width:100},
                                {field:'destinationStation',title:'<spring:message code="bill.destination"/>',width:100},
                            ]],
                            onResize:function(){
                                $('#dg').datagrid('fixDetailRowHeight',index);
                            },
                            onLoadSuccess:function(){
                                setTimeout(function(){
                                    $('#dg').datagrid('fixDetailRowHeight',index);
                                },0);
                            }
                            //onClickRow: editHbillRow

                    })
                    layer.open({content:"<spring:message code="opt.success"/>"});
                }else{
                    layer.open({content:"<spring:message code="opt.delfailed"/>!"});
                }
            },"json");
        }
        
        
        function doDelete(){
            var rows = $("#dg").datagrid('getChecked');
            if(rows.length==0){
                layer.open({content:"<spring:message code="opt.selectone" />"});
                return false;
            }
            layer.confirm("<spring:message code="opt.confirmdel" />?", {btn:['<spring:message code="opt.confirm" />','<spring:message code="opt.cancel" />']},function () {
                $.post("<%=basePath %>manifest/delete",{ids:getIds().join(",")},function(data){
                    if(data.status == 200) {
                        layer.confirm("<spring:message code="opt.delsuccess" />!",{btn:['<spring:message code="opt.confirm" />','<spring:message code="opt.cancel" />']},function(){
                            window.location.href="<%=basePath %>manifest/list";
                        })
                    }else{
                        layer.open({content:"<spring:message code="opt.delfailed" />!"});
                    }
                },"json");

            });
        }
        
        $("#manifnum").keyup(function(){
        	var leng =  $("#manifnum").val().length;
            if (leng == 3)
            {
            	 $("#manifnum").val( $("#manifnum").val()+"-")
            }
        })
</script>
</body> 
</html>