shareUserOrders.html 9.43 KB
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Yoho!Buy运营平台</title>
    <script src="/union/js/include.js"></script>
    <script src="/union/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="padding-bottom: 35px; height: auto;">
    <script>
        document.write(addHead('市场报表管理', 'CPS订单管理'));
    </script>
    <form id="searchForm" method="post" accept-charset="utf-8">
        <div style="margin-left: 10px;margin-top: 10px">

            <label>开始时间:</label>
            <input class="easyui-datetimebox" id="beginTime" name="beginTime">
            </input>

            <label>结束时间:</label>
            <input class="easyui-datetimebox" id="endTime" name="endTime">
            </input>

            <label>订单号:</label>
            <input class="easyui-textbox" id="orderCode" name="orderCode">
            </input>

            <label>联盟渠道号:</label>
            <input class="easyui-textbox" id="unionId" name="unionId">
            </input>

            <label>渠道:</label>
            <input class="easyui-textbox" id="unionType" name="unionType">
            </input>


            <a id="searchBtn" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">查询</a>
            <a id="exportButton" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">导出</a>
            <a id="exportAllButton" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">全部导出</a>
        </div>
    </form>
</div>
<div region="center">
    <div style="margin-left: 30px;margin-top: 20px; height: 500px;">
        <table id="userOrdersTable"></table>
    </div>
</div>
<script type="text/javascript">
    var checkedItems = [];
    $(function () {
        $("#userOrdersTable").myDatagrid({
            fit: true,
            fitColumns: true,
            <!-- idField: "id",-->
            view: fileview,
            nowrap: false,
            onCheckAll: addcheckItem,
            onCheck: addcheckItem,
            onUncheckAll: removeAllItem,
            onUncheck: removeSingleItem,
            url: contextPath + "/UnionShareRest/queryUnionShareOrders",
            method: 'POST',
            loadFilter: function (data) {
                var temp = defaultLoadFilter(data);
                temp.rows = temp.list;
                return temp;
            },
            columns: [[{
                title: "ID",
                field: "id",
                idField:"id",
                width: 200,
                align: "center",
                checkbox: true
            }, {
                title: "联盟渠道号",
                field: "unionId",
                width: 200,
                align: "center"
            }, {
                title: "下单时间",
                field: "orderTime",
                width: 200,
                align: "center"
            }, {
                title: "订单号",
                field: "orderCode",
                width: 200,
                align: "center"
            }, {
                title: "分享用户ID",
                field: "uid",
                width: 200,
                align: "center"
            }, {
                title: "订单金额",
                field: "orderAmount",
                width: 200,
                align: "center"
            }, {
                title: "订单状态",
                field: "orderStatus",
                width: 200,
                align: "center"
            }, {
                title: "渠道名称",
                field: "unionType",
                width: 200,
                align: "center"
            }, {
                title: "渠道号类型",
                field: "channelType",
                width: 200,
                align: "center"
            }, {
                title: "是否新客",
                field: "isNew",
                width: 200,
                align: "center"
            }
            ]],
            cache: false,
            pagination: true,
            pageSize: 10,
            pageList: [10],
            idField: "id",
            singleSelect: false,
            checkOnSelect: false,
            onLoadSuccess: function (data) {
                    resetSelectedCheckBox(data);
            }
        });

        function resetSelectedCheckBox(data){
            $("input[type='checkbox'][name='id']").each(function () {
                var cb=$(this);
                $.each(checkedItems,function(index,value){
                    if(value==cb.val()){
                        cb.attr("checked",true);
                        return false;
                    }
                });
            });
        }
        function getParam(table) {
            var paramsArray = $("#"+table+"").serializeArray();
            var params = {};
            for (var i = 0; i < paramsArray.length; i++) {
                params[paramsArray[i].name] = paramsArray[i].value;
            }
            return params;
        }

        $("#searchBtn").linkbutton({
            iconCls : "icon-search",
            onClick : function() {
                checkedItems=[];
                var param = {};
                if ($("#beginTime").datetimebox('getValue')!='')
                {
                    param.beginTime = parseInt(new Date($("#beginTime").datetimebox('getValue')).getTime() / 1000)
                }
                if ($("#endTime").datetimebox('getValue') != ''){
                    param.endTime = parseInt(new Date($("#endTime").datetimebox('getValue')).getTime() / 1000)
                }

                param.orderCode = $("#orderCode").val(),
                        param.unionId = $("#unionId").val(),
                        param.unionType=$("#unionType").val(),
                        $("#userOrdersTable").myDatagrid("load", param);
            }
        });

        function addcheckItem() {
            $("input[type='checkbox'][name='id']:checked").each(function () {
                var k = findCheckedItem($(this).val());
                if (k == -1) {
                    checkedItems.push($(this).val());
                }
            });
        }

        var fileview = $.extend({}, $.fn.datagrid.defaults.view, { onAfterRender: function (target) { isCheckItem(); } });

        function isCheckItem() {
            for (var i = 0; i < checkedItems.length; i++) {
                $("input[type='checkbox'][name='id'][value='"+checkedItems[i]+"']").attr("checked", "checked");
            }
        }

        function findCheckedItem(ID) {
            for (var i = 0; i < checkedItems.length; i++) {
                if (checkedItems[i] == ID) return i;
            }
            return -1;
        }

        function findCheckedItem(ID) {
            for (var i = 0; i < checkedItems.length; i++) {
                if (checkedItems[i] == ID) return i;
            }
            return -1;
        }

        function removeAllItem(rows) {
            $("input[type='checkbox'][name='id']").each(function () {
                if (!this.checked) {
                    var k = findCheckedItem($(this).val());
                    if (k != -1) {
                        checkedItems.splice(k, 1);
                    }
                }
            });
        }

        function removeSingleItem(rowIndex, rowData) {
            var k = findCheckedItem(rowData.id);
            if (k != -1) {
                checkedItems.splice(k, 1);
            }
        }

        $("#exportButton").linkbutton({
            onClick : function() {
                if (checkedItems.length == 0) {
                    $.messager.alert('提示','请选择要导出的数据');
                    return;
                }
                var params = {"ids": checkedItems.toString() };
                window.open(contextPath + "/batch/export.do?type=unionShareServiceImpl&queryConf=" + JSON.stringify(params));
            }
        });

        $("#exportAllButton").linkbutton({
            onClick : function() {
                window.open(contextPath + "/batch/export.do?type=unionShareServiceImpl&queryConf=" + JSON.stringify(getParams()));
            }
        });

        function getParams() {
            var paramsArray = $("#searchForm").serializeArray();
            var params = {};
            var orderCode = "";
            var beginTime="";
            var endTime="";
            for (var i = 0; i < paramsArray.length; i++ ) {
                if (paramsArray[i].name == "orderCode") {
                    orderCode += paramsArray[i].value + ",";
                }else if(paramsArray[i].name=="beginTime"){
                    beginTime += paramsArray[i].value + ",";
                }else if(paramsArray[i].name=="endTime"){
                    endTime +=paramsArray[i].value+",";
                } else {
                    params[paramsArray[i].name] = paramsArray[i].value;
                }
            }
            if (orderCode.length != 0) {
                params["orderCode"] = orderCode.substring(0, orderCode.length -1);
            }
            if(beginTime.length !=0){
                params["beginTime"]= parseInt(new Date($("#beginTime").datetimebox('getValue')).getTime() / 1000)
            }
            if(endTime.length !=0){
                params["endTime"]= parseInt(new Date($("#endTime").datetimebox('getValue')).getTime() / 1000)
            }

            return params;
        }

    });
</script>
</body>
</html>