list.jsp 13.8 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">
	
	<link rel="stylesheet" href="<%=basePath%>resource/layui/css/layui.css" media="all">
	<script type="text/javascript" src="<%=basePath%>resource/easyui/jquery.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>resource/layer-v3.0.3/layer/layer.js"></script>
	<script type="text/javascript" src="<%=basePath%>resource/layui/layui.js"></script>
	
</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="."  formatter="editFormat"><spring:message code="opt.edit" /></th>
                            <th field="sd_waybill">运单号</th>
                            <%--货代信息--%>
                            <th field="sd_cargo_shipper_name">航空货运托运人名称</th>
                            <th field="sd_cargo_agent_name">航空货运销售代理人名称</th>
                            <th field="sd_iata_number">航协编号</th>
                            <th field="sd_transport_certificate" formatter="certificate">运输条件鉴定书</th>
                            <th field="sd_transportation_prove" formatter="prove">航空公司同意运输证明</th>
                            <th field="operation">发布时间</th>
                            <th field="customs">海关关区</th>
                            <th field="sd_static"formatter="sdStatic" width="80">状态</th>
                            <th field=".." formatter="operatorFormat" width="60">操作</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_waybill" style="width:166px;height:35px;line-height:35px;">
                     海关关区:<input id="manifnum" type="text" name="search_EQ_customs" 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:doSaves()" class="easyui-linkbutton" style="background:#18A197;color:#FFF;border: 1px solid #18A197;" iconCls="icon-add">添加</a>

                     <%--<a href="javascript:printAll()" class="easyui-linkbutton" style="background:red;color:#FFF;border: 1px solid red">批量打印</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?version=${version}"></script>
<!--弹出层引入的JS-->
<script type="text/javascript" src="<%=basePath %>resource/layer-v3.0.3/layer/layer.js"></script>
    <script type="text/javascript">

    function editFormat(val,row,index){

        var html='<a href="javascript:void(0)" style="padding-left:10px;text-decoration:none;color:blue;padding-right:20px;" onclick="editRow('+row.id+')"><i class="iconfont">&#xe65a;</i></a>'
        return html;
    }

    //判断是否为空
    function certificate(val, row, index) {
        if (row.sd_transport_certificate == null){
            return "无";
        }else {
            return row.sd_transport_certificate;
        }
    }

    function prove(val, row, index) {
        if (row.sd_transportation_prove == null){
            return "无";
        }else {
            return row.sd_transportation_prove;
        }
    }



    function sdStatic(value, row, index) {
        var res = '';
        res = '<span style="color:red;">'+value+'</span>';
        return res;
    }

    function operatorFormat(val, row, index) {
        var html = "<a href='javascript:void(0)' onclick='print("+row.id+")' style='text-decoration:none;color:blue;'>打印</a>" +
            "&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:void(0)' onclick='findOne("+row.id+")' style='text-decoration:none;color:blue;'>查看</a>"+
            "&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:void(0)' onclick='doDelete("+row.id+")' style='text-decoration:none;color:blue;'>删除</a>";

        return html;
    }

    $(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 %>declaration/grid.json',
         	//queryParams:$("#searchForm").serializeJson(),
			pageNumber:getPageNumber(),
            view: detailview,
            detailFormatter:function(index,row){
                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',
                    autoRowHeight:"true",
                    columns:[[
                        {field:'.',title:'<spring:message code="opt.name"/>',formatter:editHbillFormat},
                        {field:'waybillnosecondary',title:'<spring:message code="manifest.odd.number"/>'},
                        {field:'originatingstation',title:'<spring:message code="manifest.starting.point"/>'},
                        {field:'destinationstation',title:'<spring:message code="manifest.destination"/>'},
                        {field:'preparepiece',title:'<spring:message code="manifest.number.of.fittings"/>'},
                        {field:'prepareweight',title:'<spring:message code="manifest.pre.weight"/>'},
                        {field:'response_text',width:160,title:'<spring:message code="manifest.response_text"/>',
	                        	formatter:function(value, row, index){
	                        		var res = '';
	                                if(value){
	                             	   	var start_yupei = value.indexOf("41301");
	                             	   	var start_yundi = value.indexOf("45201");
	                         	        if(start_yupei>-1||start_yundi>-1){
	                         	            	// 成功
	                         	            	res = '<span style="color:green;">'+value+'</span>';
	                                    }else{
	                                       	// 未通过或者未回执
	                                       	var start_exception_1 = value.indexOf("分单");
	                                       	var start_exception_2 = value.indexOf("主单");
	                                       	if(start_exception_1>-1||start_exception_2>-1){
	                                       		//没有回执
	                                       		res = '<span style="color:black;">'+value+'</span>';
	                                       	}else{
	                                       		res = '<span style="color:red;">'+value+'</span>';
	                                       	}
	                                    }
	                                }

	                                return res;
	                        }
                        },
                        {field:'..', title:'<spring:message code="opt.operator" />', formatter:preoperatorFormat, width:40}
                    ]],
                    onResize:function(){
                        $('#dg').datagrid('fixDetailRowHeight',index);
                    },
                    onLoadSuccess:function(){
                        $('#dg').datagrid('resize');   
                    }
                });
                
                $('#dg').datagrid('fixDetailRowHeight',index);
            }
        });
    });
		function seeReceipt(waybill_no,sub_waybill_no,isMain){
			layui.use('layer', function(){
				  var layer = layui.layer;
				  var api="<%=basePath%>receipt/seeReceipt";
				  var params = "waybill_no="+waybill_no;
				  if(!isMain){
					  params+="&sub_waybill_no="+sub_waybill_no;
				  }
				  var viewUrl = api+"?"+params;
				  
				  parent.layer.open({
			            type: 2,
			            title: "<spring:message code='opt.open.receipt'/>",
			            shadeClose: true,
			            shade: 0.8,
			            area: ['80%', '60%'],
			            content: viewUrl
			        }); 
			});  
		}


        function doDelete(id) {
            $.post("<%=basePath %>declaration/doDelete",{id:id},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 %>declaration/list";
                    })
                }else{
                    layer.open({content:"请联系管理员删除"});
                }
            },"json");
        }
		
		function editRow(id){
            layer.open({
                type : 2,
                title : '修改',
                maxmin : true,
                shadeClose : false, // 点击遮罩关闭层
                area : [ '80%', '65%' ],
                content : '<%=basePath %>declaration/edit?id='+id
            });
	    }

	    function findOne(id) {
            layer.open({
                type : 2,
                title : '修改',
                maxmin : true,
                shadeClose : false, // 点击遮罩关闭层
                area : [ '80%', '65%' ],
                content : '<%=basePath %>declaration/findone?id='+id
            });
        }

        function doSaves() {
            layer.open({
                type : 2,
                title : '添加',
                maxmin : true,
                shadeClose : false, // 点击遮罩关闭层
                area : [ '80%', '65%' ],
                content : '<%=basePath %>declaration/inlandSaveView'
            });
        }
	    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;
        }
        
        $("#manifnum").keyup(function(){
        	var leng =  $("#manifnum").val().length;
            if (leng == 3)
            {
            	 $("#manifnum").val( $("#manifnum").val()+"-")
            }
        })
    function print(id) {
        layer.open({
            type : 2,
            title : '打印',
            maxmin : true,
            shadeClose : false, // 点击遮罩关闭层
            area : [ '80%', '65%' ],
            content : '<%=basePath %>declaration/print?id='+id
        });
    }

    //批量打印
    function printAll(){
        var rows = $("#dg").datagrid('getChecked');
        if(rows.length==0){
            layer.open({content:"请选择一项"});
            return false;
        }
        alert(getIds().join(","));
        <%--$.post("<%=basePath %>wbm/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 %>wbm/list";--%>
                <%--})--%>
            <%--}else{--%>
                <%--layer.open({content:"<spring:message code="opt.delfailed" />!"});--%>
            <%--}--%>
        <%--},"json");--%>
    }



</script>
</body>
</html>