cargo.jsp 13.9 KB
<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2019/3/15
  Time: 9:33
  To change this template use File | Settings | File Templates.
--%>
<%@ 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="wbm.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="loginname"><spring:message code="manifest.loginaccount"/></th>
                <th field="codes"><spring:message code="manifest.agentCode"/></th>
                <th field="contacts">联系人</th>
                <th field="phone">电话</th>
                <th field="tstype" formatter="tstype">货主类型</th>
                <th field="fullname">货主名称</th>
                <th field="forshort">货主简称</th>
                <th field="waybill" sortable="true"><spring:message code="manifest.bill.number"/></th>
                <th field="customsstatus"><spring:message code="manifest.customs"/></th>
                <th field="flightno"><spring:message code="manifest.flight.number"/></th>
                <th field="flightdate" formatter="formatFlightDate"><spring:message code="manifest.flight.date"/></th>
                <th field="orig"><spring:message code="manifest.starting.point"/></th>
                <th field="dest"><spring:message code="manifest.destination"/></th>
                <th id="tpie" field="piece"><spring:message code="manifest.number.of.fittings"/></th>
                <th id="twei" field="weight"><spring:message code="manifest.pre.weight"/></th>
                <th field="retext" formatter="checkResponseText" width="200"><spring:message code="manifest.response_text" /></th>
                <%--<th field=".." formatter="operatorFormat"><spring:message code="opt.operator" /></th>--%>
            </tr>
            </thead>
        </table>
        <div id="tb" style="padding:0 30px;"><input type="hidden" id="idcc">
            <form id="searchForm">
                <table class="search_form_table">
                    <select name="search_LIKE_tstype" id="tstype" style="width:166px;height:35px;line-height:35px;">
                        <option value="">请选择</option>
                        <option value="A">发货人</option>
                        <option value="B">订舱代理</option>
                        <option value="C">操作代理</option>
                    </select>

                    货主名称: <input class="easyui-textbox" type="text" name="search_LIKE_fullname" style="width:166px;height:35px;line-height:35px;">

                    航班开始日期:<input type="text" class=" bill"  name="search_GTES_flightdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width:166px;height:35px;line-height:35px;">

                    航班结束日期:<input type="text" class=" bill"  name="search_LTES_flightdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width:166px;height:35px;line-height:35px;">
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="javascript:doSearch()" class="easyui-linkbutton" iconCls="icon-search" data-options="selected:true"><spring:message code="opt.search" /></a>
                </table>
            </form>

            总件数:<span id = "totalpiec"></span>
            总重量:<span id = "totalweight"></span>
        </div>
    </div>

</div>
<script type="text/javascript" src="<%=basePath%>resource/My97DatePicker/WdatePicker.js?version=${version}"></script>
<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 formatFlightDate(value, row, index){
        return row.flightdate.split(" ")[0];
    }

    // function appendCarrier(value, row, index) {
    //     return row.carrier+row.flightno;
    // }

    function tstype(value, row, index) {
        console.log(row);
        if ("111" == row.tstype){
            return "发货人"
        }
        if ("222" == row.tstype){
            return"订舱代理"
        }
        if("333"== row.tstype){
            return "操作代理"
        }
    }

    function checkResponseText(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_ = value.indexOf("分单");
                var start_exception_ = value.indexOf("主单");
                if(start_exception_>-1||start_exception_>-1){
                    //没有回执
                    res = '<span style="color:black;">'+value+'</span>';
                }else{
                    res = '<span style="color:red;">'+value+'</span>';
                }
            }
        }

        return res;
    }

    var totalpiece = 0;
    var totalweight = 0;

    $(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 %>cargo/grid.json',
            //queryParams:$("#searchForm").serializeJson(),
            pageNumber:getPageNumber(),
            view: detailview,
            detailFormatter:function(index,row){
                $("#totalpiec").html('');
                $("#totalweight").html('');
                totalpiece += parseInt(row.piece);
                totalweight += parseInt(row.weight);


                $("#totalpiec").html(totalpiece);
                $("#totalweight").html(totalweight);

                return '<div id="ddv-' + index + '""></div>';
            },
        });
    });




    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="userUpdate('+row.id+')"><i class="iconfont">&#xe65a;</i></a>'
        html += '<a href="javascript:void(0)" style="text-decoration:none;margin-left:20px;color:blue;" </a>';
        return html;
    }

    //分单撤销
    function preoperatorFormat(val, row, index){
        var html =  "<a href='javascript:void(0)' onclick='prebackout("+row.id+")' style='text-decoration:none;color:blue;'><spring:message code='opt.delete'/></a>";
        // html+="<a href='javascript:void(0)' style='text-decoration:none;color:blue;margin-left:20px;'></a>";
        return html;
    }

    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){
        var html = "<a href='javascript:void(0)' onclick='backout("+row.id+")' style='text-decoration:none;color:blue;'><spring:message code='opt.backout'/></a>";
        html+="<a href='javascript:void(0)' onclick='openReceipt(\""+row.waybillnomaster+"\")' style='text-decoration:none;color:blue;margin-left:20px;'><spring:message code='opt.open.receipt'/></a>";
        return html;
    }
    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 openSubReceipt(waybill_no,subno){
        if(typeof(waybill_no) == "undefined")
            return;
        if(typeof(subno) == "undefined")
            return;
        seeReceipt(waybill_no,subno,false);
    }

    //查看主单回执
    function openReceipt(waybill_no){
        if(typeof(waybill_no) == "undefined")
            return;
        seeReceipt(waybill_no,"",true);
    }

    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 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;color:blue;" onclick="editHbillRow('+row.id+')"><i class="iconfont">&#xe65a;</i></a>';
	      var  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 userUpdate(id) {
        // iframe层
        layer.open({
            type : 2,
            title : '修改主单号用户',
            maxmin : true,
            shadeClose : false, // 点击遮罩关闭层
            area : [ '450px', '300px' ],
            content : '<%=basePath %>wbm/edit?id='+id
        });
    }

    function doSearch(){
        totalpiece = 0;
        totalweight = 0;
        $('#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()+"-")
        }
    })
</script>
</body>
</html>