list.jsp 11.4 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:99%" title="<spring:message code="bill.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="120"><spring:message code="opt.name"></spring:message></th>
                <th field="mawbNo" width="100"><spring:message code="bill.mawbNo"/></th>
                <th field="deliveryStation" sortable="true" width="200"><spring:message code="bill.unit"/></th>
                <th field="agent" width="110"><spring:message code="delivery.agent"/></th>
                <th field="departureStation" width="170"><spring:message code="bill.orilocation"/></th>
                <th field="destinationStation" width="170"><spring:message code="bill.destination"/></th>
                <th field="goodsName" width="170"><spring:message code="bill.productname"/></th>
            </tr>
            </thead>
        </table>
        <div id="tb" style="padding:0 30px;">
            <form id="searchForm"><input type="hidden" id="type" name="search_LIKE_billType" value="${type}">
                <table class="search_form_table">
                   		<tr>
                   			<td class="klabel"><spring:message code="bill.mawbNo"/></td>
                   			<td class="kcontent"><input id="mawbNo" type="text" name="search_LIKE_mawbNo"></td>
                   			<td class="klabel"><spring:message code="bill.unit"/></td>
                   			<td class="kcontent"><input type="text" name="search_LIKE_deliveryStation"></td>
                   			<td class="klabel"><spring:message code="delivery.agent"/></td>
                   			<td class="kcontent"><input type="text" name="search_LIKE_agent"></td>
                   			<td class="klabel"><spring:message code="bill.orilocation"/></td>
                   			<td class="kcontent"><input type="text" name="search_LIKE_departureStation"></td>
                   		</tr>
                   		<tr>
                   			<td class="klabel"><spring:message code="bill.destination"/></td>
                   			<td class="kcontent"><input type="text" name="search_LIKE_destinationStation"></td>
                   			<td class="klabel"><spring:message code="bill.productname"/></td>
                   			<td class="kbutton"><input type="text" name="search_LIKE_goodsName"></td>
                   			
                   			<td class="kbutton" colspan="4">
                       				<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>
                       		</td>
                   		</tr>
                </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">
    var billType = $("#type").val();
    $(function(){
        $('#dg').datagrid({
            url:'<%=basePath %>bill/grid.json?type='+billType,
//             queryParams:$("#searchForm").serializeJson(),
            view: detailview,
            detailFormatter:function(index,row){
                return '<div id="ddv-' + index + '"style="padding:5px 0"></div>';
            },
            onExpandRow: function(index,row){
                $('#ddv-'+index).datagrid({
                    url:'<%=basePath %>bill/sub/grid.json?mawbId='+row.id,
//                     queryParams:$("#searchForm").serializeJson(),
                    fitColumns:true,
                    singleSelect:true,
                    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:'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);
                    }
                });
                $('#dg').datagrid('fixDetailRowHeight',index);
            }
        });
    });

    function editFormat(val,row,index){
        var html='<a href="javascript:void(0)" style="text-decoration:none;" 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>制分单</a>';
        return html;
    }
    
    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){
        if(id==undefined){
            window.location.href='<%=basePath %>bill/edit?id='+'&type='+billType;
        }else{
            window.location.href='<%=basePath %>bill/edit?id='+id+'&type='+billType;
        }
    }

    //制分单
    function makeHawb(id){
        window.location.href="<%=basePath %>bill/sub/edit?mawbId="+id+'&type='+billType;
    }

    //分单编辑
    function editHbillRow(id){
        window.location.href='<%=basePath %>bill/sub/edit?id='+id+'&type='+billType;
    }

    //分单删除
    function delHbillRow(id,mawbId,index){
    	alert(id+"****"+mawbId+"****"+index );
        $.post("<%=basePath %>bill/sub/delete",{id:id},function(data){
            if(data.status == 200) {

                    $('#ddv-'+index).datagrid({
                        url:'<%=basePath %>bill/sub/grid.json?mawbId='+mawbId,
                        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

                })
            }else{
                layer.open({content:"<spring:message code="opt.delfailed"/>!"});
            }
        },"json");
    }


    function doSearch(){
        $('#dg').datagrid("options").queryParams=$("#searchForm").serializeJson();
        $('#dg').datagrid("reload");
    }

    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 %>bill/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%>bill/list?type="+billType;
                    })
                }else{
                    layer.open({content:"<spring:message code="opt.delfailed"/>!"});
                }
            },"json");

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