jquery之营销系统(会员促销)

var appPath = getAppPath();
var cnt = 0;
var loadCnt = 0;
$(function() {
    $("#opreateHtml").window("close");
    $("#opreateHtmlGoods").window("close");
    $("#opreateHtmlCategory").window("close");
    $("#myOrderDlg").window("close");
    $("#addDlg2").window("close");
    $("#customAreaTree").window("close");
    $("#addFQ").window("close");
    $("#addFQList").window("close");
    $("#opreateHtmlConflict").window("close");
    $("#opreateHtmlmemberRankFreedom").window("close");
    $("#fanxie").hide();
    getAllMemberRank("memberRank1");
    getAllMemberRank("memberRank2");
    getAllMemberRank("memberRank3");
    $("#deliveryGrid")
            .datagrid(
                    {
                        url : appPath
                                + "/page/ecPromoteRuleGoodsGNewAct/getPage",
                        height : "full",
                        idField : 'PROMOTE_RULE_ID',// 唯一行
                        striped : true,
                        height : 600,
                        remoteSort : false,
                        pagination : true,
                        rownumbers : true,
                        singleSelect : false,
                        queryParams : getQueryParam(),
                        frozenColumns : [ [
                                {
                                    field : "ck",
                                    checkbox : true
                                },
                                {
                                    field : "opt",
                                    title : "操作",
                                    width : 100,
                                    align : "center",
                                    formatter : function(value, rowData,
                                            rowIndex) {
                                        var dataStr = JSON.stringify(rowData);
                                        if (rowData.IS_ENABLE == "N") {
                                            var html = "<img class='op-enable' src='"
                                                    + appPath
                                                    + "/js/lib/jquery-easyui/themes/icons/pencil.png' onClick='showWin("
                                                    + rowData.PROMOTE_RULE_ID
                                                    + ","
                                                    + 1
                                                    + ")' title='编辑'/>";
                                            html += "&nbsp;<img class='op-enable' src='"
                                                    + appPath
                                                    + "/js/lib/jquery-easyui/themes/icons/cancel.png' onClick='deleteRule("
                                                    + rowData.PROMOTE_RULE_ID
                                                    + ")' title='删除'/>";
                                            html += "&nbsp;<img class='op-enable' src='"
                                                    + appPath
                                                    + "/js/lib/jquery-easyui/themes/icons/ok.png' onClick='doOk("
                                                    + dataStr
                                                    + ","
                                                    + 1
                                                    + ")' title='启用'/>";
                                            html += "&nbsp;<img class='op-enable' src='"
                                                    + appPath
                                                    + "/js/lib/jquery-easyui/themes/icons/search.png' onClick='showWin("
                                                    + rowData.PROMOTE_RULE_ID
                                                    + ","
                                                    + 0
                                                    + ")' title='查看'/>";
                                            return html;
                                        } else {
                                            var html = "&nbsp;<img class='op-enable' src='"
                                                    + appPath
                                                    + "/js/lib/jquery-easyui/themes/icons/no.png' onClick='doOk("
                                                    + dataStr
                                                    + ","
                                                    + 2
                                                    + ")' title='禁用'/>";
                                            html += "&nbsp;<img class='op-enable' src='"
                                                    + appPath
                                                    + "/js/lib/jquery-easyui/themes/icons/search.png' onClick='showWin("
                                                    + rowData.PROMOTE_RULE_ID
                                                    + ","
                                                    + 0
                                                    + ")' title='查看'/>";
                                            return html;
                                        }
                                    }
                                } ] ],
                        columns : [ [ {
                            field : 'RULE_NO',
                            title : '促销编码',
                            width : 120,
                            align : 'center',
                            sortable : true
                        }, {
                            field : 'RULE_NAME',
                            title : '促销名称',
                            width : 100,
                            align : 'center',
                            sortable : true
                        }, {
                            field : 'DISCOUNT_PLAN',
                            title : '促销分类',
                            width : 120,
                            align : 'center',
                            sortable : true,
                            formatter : function(value, rowData, rowIndex) {
                                if (value == '6') {
                                    return '会员邮费促销';
                                } else {
                                    return value;
                                }
                            }
                        }, {
                            field : 'DISCOUNT_TYPE',
                            title : '促销方式',
                            width : 120,
                            align : 'center',
                            sortable : true,
                            formatter : function(value) {
                                if (value == 1) {
                                    return "商品";
                                } else if (value == 2) {
                                    return "满元";
                                } else if (value == 3) {
                                    return "满件";
                                } else {
                                    return value;
                                }
                            }
                        }, {
                            field : 'BEGIN_TIME',
                            title : '开始时间',
                            width : 120,
                            align : 'center',
                            sortable : true
                        }, {
                            field : 'END_TIME',
                            title : '结束时间',
                            width : 130,
                            align : 'center',
                            sortable : true
                        }, {
                            field : 'IS_ENABLE',
                            title : '促销状态',
                            width : 100,
                            align : 'center',
                            sortable : true,
                            formatter : function(value) {
                                if (value == 'Y') {
                                    return "<font color='green'>启用</font>";
                                } else {
                                    return "禁用";
                                }
                            }
                        }, {
                            field : 'COUNT_ORDER',
                            title : '订单统计',
                            width : 130,
                            align : 'center',
                            sortable : true
                        }, {
                            field : 'USER_NAME',
                            title : '操作人员',
                            width : 120,
                            align : 'center',
                            sortable : true
                        }, {
                            field : 'SUM_ORDER',
                            title : '促销销量统计',
                            width : 120,
                            align : 'center',
                            sortable : true
                        } ] ],
                        toolbar : [ {
                            id : 'btnadd',
                            text : '新增',
                            iconCls : 'icon-add',
                            handler : function() {
                                showWin(null, 2);
                            }
                        } ]

                    });

    $("a.deleteArea").live("click", function() {
        $(this).parent().parent().remove();
    });
});

/**
 * 删除商品规则
 */
function deleteRule(id) {
    if(!checkUserButtonRight('editSales')){
        return ;
    }

    var obj = new Object();
    obj.promoteRuleId = id;
    // 验证
    $.messager.confirm('提示信息', "您确定保存操作?", function(r) {
        if (r) {
            doAjax({
                url : appPath + '/page/ecPromoteRuleNewAct/deleteIdsLogic',
                type : 'post',
                data : obj,
                success : function(data) {
                    if (data == 1) {
                        doQuery();
                        $.messager.alert('提示信息', '操作成功', 'info');
                    } else {
                        $.messager.alert('提示信息', '网络异常请重试', 'info');
                    }
                }
            });
        }
    });

}

function getQueryParam() {
    var obj = new Object();
    if ($("#promoteRuleId").val() != 'null') {
        obj.promoteRuleId = $("#promoteRuleId").val();
    }
    if ($("#wapType").val() != 'null') {
        obj.promoteClient = $("#wapType").val();
    } else {
        obj.promoteClient = 'web';
    }
    obj.discountPlan = '6'; // 邮费促销
    obj.ruleNo = $.trim($("#ruleno").val());
    obj.ruleName = $.trim($("#rulename").val());
    obj.discountType = $.trim($("#discounttype").combobox('getValue'));
    obj.isEnable = $.trim($("#type").combobox('getValue'));
    obj.promoteStates = $.trim($("#promoteStates").combobox('getValue'));
    obj.beginTime = $.trim($("#begintime").datebox('getValue'));
    obj.endTime = $.trim($("#endtime").datebox('getValue'));
    obj.goodsNo = $.trim($("#goodsno").val());
    obj.goodsName = $.trim($("#goodsname").val());
    return obj;
}

function doQuery() {
    $("#promoteRuleId").val(""); // 本列表中不能要主表ID
    $("#deliveryGrid").datagrid('load', getQueryParam());
}

/**
 * 获取所有的会员等级id add by lk 2014-7-9
 *
 * @returns {___obj1}
 */
function getAllMemberRank(name) {
    doAjax({
        url : appPath + '/page/memberRankCommon/memberRankListForSelect',
        type : 'post',
        success : function(list) {
            if (list.length > 0) {
                for (var int = 0; int < list.length; int++) {
                    $("#" + name).append(
                            $(
                                    "<option value='"
                                            + list[int].MEMBER_RANK_ID + "'>")
                                    .html(list[int].RANK_NAME));
                }
            }
        }
    });
}

function showWin(id, look) {
    //编辑
    if(look==1){
        if(!checkUserButtonRight('editSales')){
            return ;
        }
    }
    //新增
    if(look==2){
        if(!checkUserButtonRight('addSales')){
            return ;
        }
    }

    // 清除数据
    $("#addpromoteRuleId").val("");
    $("#addruleNo").val("");
    $("#addruleName").val("");
    $("#addbeginTime").datebox("setValue", "");
    $("#addendTime").datebox("setValue", "");
    $("#adddiscountType").val("商品");
    $("input[id=all]").attr("checked", true); // 默认按全部
    $("#memberRank1").val("");// 默认为玄铁会员
    $('input:radio[name="sales"]').attr("disabled", false);
    var pro = new Object();
    GoodOrCategoryBJ(pro); // 初始化按商品和按类目
    $("#yuan").val("");
    $("#jian").val("");

    $("#ss1").hide();
    $("#ss2").hide();
    $("#one").show();
    $("#two").hide();
    $("#three").hide();

    $("#shangpinItemId").val("");
    $("#manyuanItemId").val("");
    $("#manjianItemId").val("");
    $("input[id=ALL1]").attr("checked", true); // 默认选中的是全部
    $("input[id=ALL2]").attr("checked", true);
    $("input[id=ALL3]").attr("checked", true);
    clearTable();
    // 阶梯的添加和删除按钮的显示(查看的时候,要隐藏掉)
    $(".look").show();
    // 附加优惠条件(初始化)
    inputFuJia();
    // 清空附加信息
    $.each($("input[id^='fujia']"), function(i, input) {
        if ($(input).attr("type") == "text") {
            $(input).val("");
        } else {
            $(input).removeAttr("checked");
        }
    });
    $.each($("input[id$='_value']"), function(i, input) {
        if ($(input).attr("type") == "text") {
            $(input).val("");
        } else {
            $(input).removeAttr("checked");
        }
    });
    $("#ZXL_day").val("");

    // 判断一个页面几处用了添加行,删除行的操作(控制样式)
    var divLast1 = ".conditionDiv1 div:last";
    var row1 = $(divLast1);// 获得最后一行 -- 设置jquery对象(待克隆的div)
    idNum1 = Number(row1.attr('id').substring(row1.attr('id').length - 1)) + 1;
    for (var int = 1; int < idNum1; int++) {
        $("#warnConditionsa" + int).remove();
    }
    var divLast2 = ".conditionDiv2 div:last";
    var row2 = $(divLast2);// 获得最后一行 -- 设置jquery对象(待克隆的div)
    idNum2 = Number(row2.attr('id').substring(row2.attr('id').length - 1)) + 1;
    for (var int = 1; int < idNum2; int++) {
        $("#warnConditions2" + int).remove();
    }

    var iconStr = "icon-add";
    var title = "新增促销规则";
    if (id != null) {
        iconStr = "icon-edit";
        title = "编辑促销规则";
        $
                .post(
                        appPath + "/page/ecPromoteRuleNewAct/getBean/" + id,
                        {},
                        function(data) {
                            // 第一步:加载基本促销信息
                            $("#addpromoteRuleId").val(data.promoteRuleId);
                            $("#addruleNo").val(data.ruleNo);
                            $("#addruleName").val(data.ruleName);
                            $("#addbeginTime").datebox("setValue",
                                    data.beginTime);
                            $("#addendTime").datebox("setValue", data.endTime);
                            $("#adddiscountType").val(data.discountType);
                            var o = new Object();
                            o.value = data.discountType;
                            // 绑定下拉框
                            couxiaoSelect(o);
                            // 判断是全场还是按商品或是类目
                            var pro = new Object();
                            pro.checked = true;
                            pro.id = data.promoteRange;
                            GoodOrCategoryBJ(pro);
                            if (data.promoteRange == 'all') {
                                $('#' + data.promoteRange + 's').attr(
                                        "checked", true);
                            } else {
                                $('#' + data.promoteRange)
                                        .attr("checked", true);
                            }

                            // 第二步:查出促销详情
                            var EcPromoteRuleItem = new Object();
                            EcPromoteRuleItem.promoteRuleId = data.promoteRuleId;
                            doAjax({
                                url : appPath
                                        + '/page/ecPromoteRuleItemAct/list',
                                type : 'post',
                                data : EcPromoteRuleItem,
                                success : function(list) {
                                    if (list.length != 0) {
                                        // 第三步:判断是不是换购
                                        // 判断是换购还是其他三个
                                        if (o.value == '1') {
                                            $("#shangpinItemId").val(
                                                    list[0].ruleItemId);
                                            var v1 = list[0].discountValue1
                                                    + o.value;
                                            $("input[id=" + v1 + "]").attr(
                                                    "checked", true);
                                            var vRank = 'memberRank' + o.value;
                                            $("#" + vRank).val(
                                                    list[0].discountValue4);
                                        } else if (o.value != '1') {
                                            // 促销详情
                                            for (var int2 = 0; int2 < list.length; int2++) {
                                                var vId = '';
                                                var v2 = '';
                                                var vRank = '';
                                                if (o.value == '2') {
                                                    vId = 'manyuanItemId';
                                                    v2 = 'yuan';
                                                    vRank = 'memberRank'
                                                            + o.value;
                                                } else if (o.value == '3') {
                                                    vId = 'manjianItemId';
                                                    v2 = 'jian';
                                                    vRank = 'memberRank'
                                                            + o.value;
                                                }
                                                var v1 = list[int2].discountValue1
                                                        + o.value;
                                                if (int2 != 0) {
                                                    // 创建一行(克隆)
                                                    if (o.value == '2') {
                                                        addRow('ss1');
                                                    } else if (o.value == '3') {
                                                        addRow('ss2');
                                                    }
                                                    vId += int2;
                                                    v1 += int2;
                                                    v2 += int2;
                                                    vRank += int2;
                                                }

                                                $("input[id=" + vId + "]").val(
                                                        list[int2].ruleItemId);
                                                if (list[int2].discountValue1 != null
                                                        || list[int2].discountValue1 != ''
                                                        || list[int2].discountValue4 != null
                                                        || list[int2].discountValue4 != '') {
                                                    $("input[id=" + v1 + "]")
                                                            .attr("checked",
                                                                    true);
                                                    $("#" + v2)
                                                            .val(
                                                                    list[int2].discountValueFee1);
                                                    $("#" + vRank)
                                                            .val(
                                                                    list[int2].discountValue4);
                                                }
                                            }
                                        }

                                    }
                                }
                            });
                            // 附加优惠
                            setFuJiaValues(data.promoteRuleId);

                        }, "json");
    } else {
        // 当弹出添加框的时候,先添加一个促销规则,返回促销Id
        var ecPromoteRuleNew = new Object();
        ecPromoteRuleNew.discountPlan = '2'; // 邮费促销
        ecPromoteRuleNew.promoteClient = $("#wapType").val();
        doAjax({
            url : appPath + '/page/ecPromoteRuleNewAct/saveOrUpdate',
            type : 'post',
            data : ecPromoteRuleNew,
            success : function(data) {
                if (data != null) {
                    $("#addpromoteRuleId").val(data);
                }
            }
        });
    }

    $('#opreateHtml').window({
        title : title,
        iconCls : iconStr,
        width : 720,
        height : 400,
        left : 200,
        modal : true,
        shadow : true,
        collapsible : false,
        minimizable : false,
        maximizable : false
    });
    $('#opreateHtml').window('move', {
        top : 100
    });
    $('#opreateHtml').window('open');
    // 查看促销规则 ====禁用掉所有的按钮
    if (look == 0) {
        // 查看
        // $("#addruleNo").attr("readonly",true);
        // $("#addruleName").attr("readonly",true);
        // $('#addbeginTime').combobox('disable');
        // $('#addendTime').combobox('disable');
        $("#adddiscountType").attr("disabled", true);
        $('input:radio[name="sales"]').attr("disabled", true);
        // $('input:radio[value="ALL"]').attr("disabled",true);
        // $('input:radio[value="KDFH"]').attr("disabled",true);
        // $('input:radio[value="HDFK"]').attr("disabled",true);
        // $('input:text[name="Fee1"]').attr("readonly",true);
        // 阶梯中的添加和删除按钮隐藏掉
        $(".look").hide();
        $("#mutexTQ").hide();
    } else {
        $("#mutexTQ").show();
        $("#addruleNo").attr("readonly", false);
        $("#addruleName").attr("readonly", false);
        $('#addbeginTime').combobox('enable');
        $('#addendTime').combobox('enable');
        $('input:radio[value="ALL"]').attr("disabled", false);
        $('input:radio[value="KDFH"]').attr("disabled", false);
        $('input:radio[value="HDFK"]').attr("disabled", false);
        $('input:text[name="Fee1"]').attr("readonly", false);
        if (look == 1) {
            // 编辑(禁用按商品,按类目)
            $('input:radio[name="sales"]').attr("disabled", false);
            $("#adddiscountType").attr("disabled", true);
        } else if (look == 2) {
            // 添加(启用按商品,按类目)
            $('input:radio[name="sales"]').attr("disabled", false);
            $('input:radio[name="sales"]').attr("checked", false);
            $("#adddiscountType").attr("disabled", false);
        }
    }
}

// 选择商品
function chooseGoodsSales() {
    if ($("input[id='goods']").prop("checked") == false) {
        $.messager.alert('提示信息', '请选择按商品促销', 'info');
        return;
    }
    // 运营分类
    $("#ywCatalogSel").combobox({
        url : appPath + "/page/systemRoleSelect/getSystemRoleSelect",
        valueField : "key",
        textField : "value",
        panelHeight : "auto",
        editable : false
    });
    $("#deliveryGridGoods").datagrid({
        url : appPath + '/page/promoteRule/goodsList',
        height : 250,
        idField : 'goodsId',// 唯一行
        striped : true,
        remoteSort : false,
        pagination : true,
        rownumbers : true,
        singleSelect : false,
        frozenColumns : [ [ {
            field : 'ck',
            checkbox : true
        } ] ],
        columns : [ [ {
            field : 'goodsNo',
            title : '商品编码',
            width : 80,
            align : 'center',
            sortable : true
        }, {
            field : 'goodsName',
            title : '商品名称',
            width : 140,
            align : 'center',
            sortable : true
        }, {
            field : 'unitName',
            title : '商品单位',
            width : 55,
            align : 'center',
            sortable : true
        }, {
            field : 'marketPrice',
            title : '市场价',
            width : 55,
            align : 'center',
            sortable : true,
            formatter : function(value) {
                if (!isNaN(Number(value))) {
                    return Number(value).toFixed(2);
                }
            }
        }, {
            field : 'ecPrice',
            title : '售价',
            width : 55,
            align : 'center',
            sortable : true,
            formatter : function(value) {
                if (!isNaN(Number(value))) {
                    return Number(value).toFixed(2);
                }
            }
        }, {
            field : 'availableStock',
            title : '库存',
            width : 55,
            align : 'center',
            sortable : true
        } ] ]
    });
    $('#opreateHtmlGoods').window({
        title : '查看商品',
        width : 600,
        height : 400,
        left : 200,
        modal : true,
        shadow : true,
        collapsible : false,
        minimizable : false,
        maximizable : false
    });
    $('#opreateHtmlGoods').window('move', {
        top : 100
    });
    $('#opreateHtmlGoods').window('open');
}

// 商品的查询

function doQueryBrand() {
    var param = new Object();
    param.nos = $.trim($('#goodsNo').val());
    param.goodsName = $.trim($('#goodsName').val());
    if ($('#ywCatalogSel').combobox("getValue") != null
            && $('#ywCatalogSel').combobox("getValue") != '') {
        param.proYwCatalogStr = $('#ywCatalogSel').combobox("getValue");
    }
    $("#deliveryGridGoods").datagrid('unselectAll');
    $("#deliveryGridGoods").datagrid('load', param);
}

function getPromoteRuleIdParam() {
    var obj = new Object();
    obj.promoteRuleId = $("#addpromoteRuleId").val();
    return obj;
}

// 商品促销列表
function goods() {
    $("#deliveryGridSalesOrGoods")
            .datagrid(
                    {
                        url : appPath
                                + '/page/ecPromoteRuleGoodsNewAct/getPage?str=cx',
                        height : 250,
                        idField : 'promoteConditionGoodsId',// 唯一行
                        striped : true,
                        remoteSort : false,
                        pagination : true,
                        rownumbers : true,
                        singleSelect : false,
                        queryParams : getPromoteRuleIdParam(),
                        frozenColumns : [ [
                                {
                                    field : "ck",
                                    checkbox : true
                                },
                                {
                                    field : "opt",
                                    title : "操作",
                                    width : 40,
                                    align : "center",
                                    formatter : function(value, rowData,
                                            rowIndex) {
                                        var html = "<img class='op-enable' src='"
                                                + appPath
                                                + "/js/lib/jquery-easyui/themes/icons/cancel.png' onClick='showWinSalesGoods("
                                                + rowData.promoteConditionGoodsId
                                                + ")' title='删除'/>";
                                        return html;
                                    }
                                } ] ],
                        columns : [ [ {
                            field : 'goodsNo',
                            title : '商品编码',
                            width : 80,
                            align : 'center',
                            sortable : true
                        }, {
                            field : 'goodsName',
                            title : '商品名称',
                            width : 140,
                            align : 'center',
                            sortable : true
                        }, {
                            field : 'unitName',
                            title : '商品单位',
                            width : 55,
                            align : 'center',
                            sortable : true
                        }, {
                            field : 'marketPrice',
                            title : '市场价',
                            width : 55,
                            align : 'center',
                            sortable : true,
                            formatter : function(value) {
                                if (!isNaN(Number(value))) {
                                    return Number(value).toFixed(2);
                                }
                            }
                        }, {
                            field : 'ecPrice',
                            title : '售价',
                            width : 55,
                            align : 'center',
                            sortable : true,
                            formatter : function(value) {
                                if (!isNaN(Number(value))) {
                                    return Number(value).toFixed(2);
                                }
                            }
                        }, {
                            field : 'availableStock',
                            title : '库存',
                            width : 55,
                            align : 'center',
                            sortable : true
                        } ] ]
                    });
    $('#opreateHtml').window({
        width : 700,
        height : 650,
        left : 200,
        modal : true,
        shadow : true,
        collapsible : false,
        minimizable : false,
        maximizable : false
    });
    $('#opreateHtml').window('move', {
        top : 100
    });
    $('#opreateHtml').window('open');
}

// 保存促销商品
function sureBrand() {
    var promoteRuleId = $("#addpromoteRuleId").val();
    var selections = $("#deliveryGridGoods").datagrid('getSelections');
    if (selections == null || selections == '') {
        $.messager.alert('提示信息', '请选择商品', 'info');
        return;
    } else {
        $.messager.confirm('提示信息', '您确定要选择这些商品?', function(r) {
            if (r) {
                // 添加完促销商品详情,然后再添加给促销Goods表中添加促销商品
                // 商品ID
                var goodsIds = '';
                // 原价==售价
                var ecPrices = '';
                for (var i = 0; i < selections.length; i++) {
                    goodsIds += selections[i].goodsId + ",";
                    ecPrices += selections[i].ecPrice + ",";
                }
                doAjax({
                    url : appPath
                            + '/page/ecPromoteRuleGoodsNewAct/save?str=cx',
                    type : 'post',
                    data : {
                        promoteRuleId : promoteRuleId,
                        discountType : $("#adddiscountType").val(),
                        discountPlan : "6",
                        goodsIds : goodsIds,
                        ecPrices : ecPrices,
                    },
                    success : function(data) {
                        if (data == 'OK') {
                            $('#salesOrGoods').css('display', 'block');
                            goods();
                            $.messager.alert('提示信息', '批量添加成功', 'info');
                            cancelBrand();
                        } else if (data == 'repeat') {
                            $.messager
                                    .alert('提示信息', '已经存在你选择的数据,请重新选择', 'info');
                            return;
                        }
                    },
                });
            }
        });
    }
}

function cancelBrand() {
    $('#deliveryGridGoods').datagrid('unselectAll');
    $('#opreateHtmlGoods').window('close');
}

// 删除促销商品
function showWinSalesGoods(id) {
    var obj = new Object();
    obj.promoteConditionGoodsId = id;
    var str = '';
    var str1 = '';
    // 验证
    $.messager.confirm('提示信息', "您确定保存操作?", function(r) {
        if (r) {
            doAjax({
                url : appPath
                        + "/page/ecPromoteRuleGoodsNewAct/deleteIdsLogic?str="
                        + str + '&str1=' + str1,
                type : 'post',
                data : obj,
                success : function(data) {
                    if (data == 'OK') {
                        goods();
                        $.messager.alert('提示信息', '操作成功', 'info');
                    } else {
                        $.messager.alert('提示信息', '网络异常请重试', 'info');
                    }

                }
            });
        }
    });
}

// 类目查询
function chooseGoodsCategory() {
    if ($("input[id='catalog']").prop("checked") == false) {
        $.messager.alert('提示信息', '请选择按类目促销', 'info');
        return;
    }
    $("#chooseGoodsCategory").datagrid({
        url : appPath + '/page/promoteRule/addYwCatalogList',
        height : 250,
        width : 'auto',
        striped : true,
        remoteSort : false,
        pagination : true,
        rownumbers : true,
        singleSelect : false,
        idField : 'ywCatalogId',
        frozenColumns : [ [ {
            field : 'ck',
            checkbox : true
        } ] ],
        columns : [ [ {
            field : 'ywCatalogId',
            title : '类目编码',
            width : 100,
            align : 'center',
            sortable : true
        }, {
            field : 'ywCatalogName',
            title : '类目名称',
            width : 143,
            align : 'center',
            sortable : true
        } ] ]
    });
    $('#opreateHtmlCategory').window({
        width : 700,
        height : 350,
        left : 200,
        modal : true,
        shadow : true,
        collapsible : false,
        minimizable : false,
        maximizable : false
    });
    $('#opreateHtmlCategory').window('move', {
        top : 100
    });
    $('#opreateHtmlCategory').window('open');
}

// 类目的查询
function doQueryLeiBrand() {
    var param = new Object();
    param.ywCatalogId = $.trim($('#ywCatalogId').val());
    param.ywCatalogName = $.trim($('#ywCatalogName').val());
    $("#chooseGoodsCategory").datagrid('unselectAll');
    $("#chooseGoodsCategory").datagrid('load', param);
}

/**
 * 按类目促销(保存)
 *
 */
function sureBrandSales() {
    var promoteRuleId = $("#addpromoteRuleId").val();
    var selections = $("#chooseGoodsCategory").datagrid('getSelections');
    if (selections == null || selections == '') {
        $.messager.alert('提示信息', '请选择类目', 'info');
        return;
    } else {
        $.messager.confirm('提示信息', "您确定保存操作?", function(r) {
            if (r) {
                var ids = '';
                for (var i = 0; i < selections.length; i++) {
                    ids += selections[i].ywCatalogId + ",";
                }
                // 验证
                doAjax({
                    url : appPath
                            + '/page/ecPromoteRuleCategoryNewAct/saveList',
                    type : 'post',
                    data : {
                        promoteRuleId : promoteRuleId,
                        ids : ids,
                    },
                    success : function(data) {
                        if (data == 'OK') {
                            $('#SalesOrCategory').css('display', 'block');
                            category();
                            $.messager.alert('提示信息', '批量添加成功', 'info');
                            cancelBrandSales();
                        } else if (data == 'repeat') {
                            $.messager
                                    .alert('提示信息', '已经存在你选择的数据,请重新选择', 'info');
                            return;
                        }
                    }
                });
            }
        });
    }
}

function cancelBrandSales() {
    $('#opreateHtmlCategory').window('close');
}

// 类目促销列表
function category() {
    $("#deliveryGridSalesOrCategory")
            .datagrid(
                    {
                        url : appPath
                                + "/page/ecPromoteRuleCategoryNewAct/getPage",
                        height : 250,
                        idField : 'promoteCategoryConditionId',
                        width : 'auto',
                        striped : true,
                        remoteSort : false,
                        pagination : true,
                        rownumbers : true,
                        singleSelect : false,
                        queryParams : getPromoteRuleIdParam(),
                        frozenColumns : [ [ {
                            field : "opt",
                            title : "操作",
                            width : 40,
                            align : "center",
                            formatter : function(value, rowData, rowIndex) {
                                var html = "<img class='op-enable' src='"
                                        + appPath
                                        + "/js/lib/jquery-easyui/themes/icons/cancel.png' onClick='deleteYwCatelog("
                                        + rowData.PROMOTE_CATEGORY_CONDITION_ID
                                        + ")' title='删除'/>";
                                return html;
                            }
                        } ] ],
                        columns : [ [ {
                            field : 'YW_CATALOG_ID',
                            title : '类目编码',
                            width : 100,
                            align : 'center',
                            sortable : true
                        }, {
                            field : 'YW_CATALOG_NAME',
                            title : '类目名称',
                            width : 100,
                            align : 'center',
                            sortable : true
                        } ] ]
                    });
    $('#opreateHtml').window({
        width : 700,
        height : 650,
        left : 200,
        modal : true,
        shadow : true,
        collapsible : false,
        minimizable : false,
        maximizable : false
    });
    $('#opreateHtml').window('move', {
        top : 100
    });
    $('#opreateHtml').window('open');
}

/**
 * 删除目录分类
 */
function deleteYwCatelog(id) {
    var obj = new Object();
    obj.promoteCategoryConditionId = id;
    // 验证
    $.messager.confirm('提示信息', "您确定保存操作?", function(r) {
        if (r) {
            doAjax({
                url : appPath + '/page/ecPromoteRuleCategoryNewAct/delete',
                type : 'post',
                data : obj,
                success : function(data) {
                    if (data == 1) {
                        category();
                        $.messager.alert('提示信息', '操作成功', 'info');
                    } else {
                        $.messager.alert('提示信息', '网络异常请重试', 'info');
                    }

                }
            });
        }
    });
}

function closeWin() {
    var ecPromoteRuleNew = new Object();
    ecPromoteRuleNew.promoteRuleId = $("#addpromoteRuleId").val();
    // 物理删除促销信息
    $.messager.confirm('提示信息', "您确定退出?", function(r) {
        if (r) {
            doAjax({
                url : appPath + '/page/ecPromoteRuleNewAct/deleteIdsPhysics',
                type : 'post',
                data : ecPromoteRuleNew,
                success : function(data) {
                    $('#opreateHtml').window('close');
                }
            });
        }
    });

}

/**
 * 每选择一个添加一行
 */
function showParentSelect(o) {
    $.messager.confirm('提示信息', "切换促销类型未保存的数据将被清空!", function(r) {
        if (r) {
            $('input:radio[name="sales"]').attr("checked", false);
            $("#addruleItemId").val("");
            qiehuan();
            couxiaoSelect(o);
        }
    });
}

function qiehuan() {
    var ecPromoteRuleNew = new Object();
    ecPromoteRuleNew.promoteRuleId = $("#addpromoteRuleId").val();
    // 物理删除促销信息
    doAjax({
        url : appPath + '/page/ecPromoteRuleNewAct/deleteIdsSwitch',
        type : 'post',
        data : ecPromoteRuleNew,
        success : function(data) {
            // 商品促销列表
            $('#salesOrGoods').css('display', 'none');
            // 类目促销列表
            $('#SalesOrCategory').css('display', 'none');
            removes();
        }
    });
}

function removes() {
    $("input[id=manyuanItemId]").val("");
    $("input[id=yuan]").val("");
    // $("input[id=memberRank2]").val("");
    // 创建行的时候,满件的初始化
    $("input[id=manjianItemId]").val("");
    $("input[id=jian]").val("");
    // $("input[id=memberRank3]").val("");
    $("input[id=ALL2]").attr("checked", true);
    $("input[id=ALL3]").attr("checked", true);
    // 判断一个页面几处用了添加行,删除行的操作(控制样式)
    var divLast1 = ".conditionDiv1 div:last";
    var row1 = $(divLast1);// 获得最后一行 -- 设置jquery对象(待克隆的div)
    idNum1 = Number(row1.attr('id').substring(row1.attr('id').length - 1)) + 1;
    for (var int = 1; int < idNum1; int++) {
        $("#warnConditionsa" + int).remove();
    }
    var divLast2 = ".conditionDiv2 div:last";
    var row2 = $(divLast2);// 获得最后一行 -- 设置jquery对象(待克隆的div)
    idNum2 = Number(row2.attr('id').substring(row2.attr('id').length - 1)) + 1;
    for (var int = 1; int < idNum2; int++) {
        $("#warnConditions2" + int).remove();
    }
}

// 促销下拉框(添加和编辑都要用)
function couxiaoSelect(o) {
    $("#one").hide();
    $("#two").hide();
    $("#three").hide();
    // 下拉对应项显示
    if (o.value == '1') {
        $("#one").show();
    } else if (o.value == '2') {
        $("#two").show();
    } else if (o.value == '3') {
        $("#three").show();
    }
}

// 动态添加行
function addRow(str) {
    var idNum;
    var row1;
    var row;
    $("#" + str).show();
    // 这个div中的第一行(用来克隆)
    var divfirst = "";
    // 这个div中的最后一行;(用来让新增的ID加1,不重复)
    var divLast = "";
    // 克隆的id样式,以及判断删除的标志
    var bigDiv = "";
    // 判断一个页面几处用了添加行,删除行的操作(控制样式)
    // if(str=="ss"){
    // divfirst=".conditionDiv div:first";
    // divLast=".conditionDiv div:last";
    // bigDiv="warnConditions";
    // }
    if (str == "ss1") {
        divfirst = ".conditionDiv1 div:first";
        divLast = ".conditionDiv1 div:last";
        bigDiv = "warnConditionsa";
    }
    if (str == "ss2") {
        divfirst = ".conditionDiv2 div:first";
        divLast = ".conditionDiv2 div:last";
        bigDiv = "warnConditions2";
    }

    row = $(divfirst);// 获得第一行 -- 设置jquery对象(待克隆的div)
    row1 = $(divLast);// 获得最后一行 -- 设置jquery对象(待克隆的div)
    // 如果row1为空
    if (row1.length == 0) {
        idNum = 1;
        row1 = $(bigDiv + (idNum - 1));
    } else {
        idNum = Number(row1.attr('id').substring(row1.attr('id').length - 1)) + 1;
    }
    var newRow = row.clone(true);// 创建第一行的一个副本(克隆第一行)
    // newRow.insertBefore(row1);//在最后一行前插入
    var rndID = bigDiv + idNum;
    newRow.attr("id", rndID);// 设置行ID 每次都不一样
    newRow.find("a[id=" + str + "]").attr("id", rndID);
    var num = $("#adddiscountType").val(); // 判断是商品还是满元,满件
    if (num == '1') {
        newRow.find("input[id=shangpinItemId]").attr("id",
                "shangpinItemId" + idNum);
        newRow.find("select[id=memberRank1]").attr("id", "memberRank1" + idNum);// 动态添加会员等级
        $("#memberRank1" + idNum).find("option[value='1']").attr("selected",
                true);
    } else if (num == '2') {
        newRow.find("input[id=manyuanItemId]").attr("id",
                "manyuanItemId" + idNum);
        newRow.find("input[id=yuan]").attr("id", "yuan" + idNum);
        newRow.find("a[id=manyuan]").attr("id", "manyuan" + idNum);
        newRow.find("select[id=memberRank2]").attr("id", "memberRank2" + idNum);// 动态添加会员等级
        $("#memberRank2" + idNum).find("option[value='1']").attr("selected",
                true);
    } else if (num == '3') {
        newRow.find("input[id=manjianItemId]").attr("id",
                "manjianItemId" + idNum);
        newRow.find("input[id=jian]").attr("id", "jian" + idNum);
        newRow.find("a[id=manjian]").attr("id", "manjian" + idNum);
        newRow.find("select[id=memberRank3]").attr("id", "memberRank3" + idNum);// 动态添加会员等级
        $("#memberRank3" + idNum).find("option[value='1']").attr("selected",
                true);
    }
    newRow.find("input[name=mylxRadio" + num + "]").attr("name",
            "mylxRadio" + num + "" + idNum);
    newRow.find("input[id=ALL" + num + "]")
            .attr("id", "ALL" + num + "" + idNum);
    newRow.find("input[id=KDFH" + num + "]").attr("id",
            "KDFH" + num + "" + idNum);
    newRow.find("input[id=HDFK" + num + "]").attr("id",
            "HDFK" + num + "" + idNum);

    newRow.insertAfter(row1);// 在最后一行后插入

    // 创建行的时候,满元的初始化
    $("input[id=manyuanItemId" + idNum + "]").val("");
    $("input[id=yuan" + idNum + "]").val("");

    // 创建行的时候,满件的初始化
    $("input[id=manjianItemId" + idNum + "]").val("");
    $("input[id=jian" + idNum + "]").val("");

    // 显示克隆出的新行数据
    newRow.show();

    // 第一个删除符号不用,所以隐藏
    $("#" + str).hide();

}

// 动态删除行
function delRow(who) {
    // 除了第一行其余的都可以删除
    $.messager.confirm('提示信息', "确定删除此行促销?", function(r) {
        if (r) {
            var num = $("#adddiscountType").val();
            var addruleItemId = '';
            if (num == '2') {
                var str = who.id.substring("warnConditionsa".length);
                addruleItemId = $("#manyuanItemId" + str).val();
            } else if (num == '3') {
                var str = who.id.substring("warnConditions2".length);
                addruleItemId = $("#manjianItemId" + str).val();
            }
            doAjax({
                url : appPath + '/page/ecPromoteRuleItemAct/delRow',
                type : 'post',
                data : {
                    ruleItemId : addruleItemId
                },
                success : function(list) {
                    if (list == 'OK') {
                        $("#" + who.id).remove();
                    } else {
                        $.messager.alert('提示信息', '删除行失败', 'info');
                        return;
                    }
                }
            });
        }
    });
};

// 单选框的触发事件(全场促销,商品促销,类目促销)
function showGoodOrCategory(o) {
    $('#salesOrGoods').css('display', 'none');
    $('#SalesOrCategory').css('display', 'none');
    // goods();
    // category();
    if (o.checked) {
        if (o.id == "goods") {
            var selections = $("#deliveryGridSalesOrCategory").datagrid(
                    'getRows');
            if (selections != '') {
                $('input:radio[id="catalog"]').attr("checked", true);
                $('#SalesOrCategory').css('display', 'block');
                category();
                $.messager.alert('提示信息', '已经选择按类目促销,请先删除类目列表', 'info');
                return;
            }
            $('#salesOrGoods').css('display', 'block');
            goods();
        }
        if (o.id == "catalog") {
            var selections = $("#deliveryGridSalesOrGoods").datagrid('getRows');
            if (selections != '') {
                $('input:radio[id="goods"]').attr("checked", true);
                $('#salesOrGoods').css('display', 'block');
                goods();
                $.messager.alert('提示信息', '已经选择按商品促销,请先删除促销商品列表', 'info');
                return;
            }
            $('#SalesOrCategory').css('display', 'block');
            category();
        }
        if (o.id == "alls") {
            var selections = $("#deliveryGridSalesOrGoods").datagrid('getRows');
            if (selections != '') {
                $('input:radio[id="goods"]').attr("checked", true);
                $('#salesOrGoods').css('display', 'block');
                goods();
                $.messager.alert('提示信息', '已经选择按商品促销,请先删除促销商品列表', 'info');
                return;
            }
            var selections = $("#deliveryGridSalesOrCategory").datagrid(
                    'getRows');
            if (selections != '') {
                $('input:radio[id="catalog"]').attr("checked", true);
                $('#SalesOrCategory').css('display', 'block');
                category();
                $.messager.alert('提示信息', '已经选择按类目促销,请先删除类目列表', 'info');
                return;
            }
            $('#salesOrGoods').css('display', 'none');
            $('#SalesOrCategory').css('display', 'none');
        }
    }
}

function GoodOrCategoryBJ(o) {
    $('#salesOrGoods').css('display', 'none');
    $('#SalesOrCategory').css('display', 'none');
    goods();
    category();
    if (o.checked) {
        if (o.id == "goods") {
            $('#salesOrGoods').css('display', 'block');
            goods();
        }
        if (o.id == "catalog") {
            $('#SalesOrCategory').css('display', 'block');
            category();
        }
        if (o.id == "all") {
            $('#salesOrGoods').css('display', 'none');
            $('#SalesOrCategory').css('display', 'none');
        }
    }
}

function showGoodOrPostage(obj) {
    if (obj.id == "all") {
        var selections = $("#areaPromoteGrid").datagrid('getRows');
        if (selections != '') {
            $('input:radio[id=' + $("#postage").val() + ']').attr("checked",
                    true);
            $.messager.alert('提示信息', '已经添加区域,请先删除所有的区域', 'info');
            return;
        }
    }
    $("#postage").val(obj.value);
}

function myOrderDlg(o, saveOrUpdate) {
    var name = o.id;
    $("#yuanjianRuleId").val(o.id);
    var num = $("#adddiscountType").val();
    var addruleItemId = '';
    if (num == '1') {
        addruleItemId = $("#shangpinItemId").val();
    } else if (num == '2') {
        var str = name.substring("manyuan".length);
        addruleItemId = $("#manyuanItemId" + str).val();
    } else if (num == '3') {
        var str = name.substring("manjian".length);
        addruleItemId = $("#manjianItemId" + str).val();
    }
    doAjax({
        url : appPath + '/page/ecPromoteRuleItemAct/list',
        type : 'post',
        data : {
            promoteRuleId : $('#addpromoteRuleId').val(),
            ruleItemId : addruleItemId
        },
        success : function(list) {
            if (list.length != 0) {
                // 设置免邮区域时,默认详情中的免邮区域
                $('input:radio[id=' + list[0].discountValue2 + ']').attr(
                        "checked", true);
                $("#postage").val(list[0].discountValue2);
            }
            if (saveOrUpdate == 'save') {
                OrderDlg(addruleItemId);
            }
        }
    });
}

// 设置免邮区域
function OrderDlg(addruleItemId) {
    $('#areaPromoteGrid')
            .datagrid(
                    {
                        url : appPath + '/page/ecPromoteRuleAreaNewAct/getPage',
                        method : 'post',
                        queryParams : {
                            promoteRuleId : $('#addpromoteRuleId').val(),
                            ruleItemId : addruleItemId
                        },
                        height : 310,
                        width : 445,
                        striped : true,
                        remoteSort : false,
                        checkbox : false,
                        idField : 'ruleConditionAreaId',
                        frozenColumns : [ [ {
                            field : 'ck',
                            checkbox : true
                        } ] ],
                        columns : [ [ {
                            field : 'ruleConditionAreaId',
                            hidden : true
                        }, {
                            field : 'areaNameP',
                            title : '省',
                            width : 100,
                            align : 'center',
                            sortable : true
                        }, {
                            field : 'areaNameC',
                            title : '市',
                            width : 100,
                            align : 'center',
                            sortable : true
                        }, {
                            field : 'areaNameA',
                            title : '区/县',
                            width : 100,
                            align : 'center',
                            sortable : true
                        } ] ],
                        pagination : true,
                        rownumbers : true,
                        toolbar : [
                                {
                                    id : 'btnadd',
                                    text : '添加区域',
                                    iconCls : 'icon-add',
                                    handler : function() {
                                        var discountValue2 = $(
                                                'input:radio[name="discountFeeMy"]:checked')
                                                .val();
                                        if (discountValue2 == 'all') {
                                            $.messager.alert('提示信息',
                                                    '全国免邮不需要选择区域', 'info');
                                            return;
                                        }
                                        showAdd();
                                    }
                                }, '-', {
                                    id : 'btnadd',
                                    text : '删除区域',
                                    iconCls : 'icon-cancel',
                                    handler : function() {
                                        areaDelete();
                                    }
                                } ]
                    });
    $('#myOrderDlg').window({
        title : "设置免邮区域",
        iconCls : 'icon-add',
        width : 500,
        height : 400,
        left : 100,
        modal : true,
        shadow : true,
        collapsible : false,
        minimizable : false,
        maximizable : false
    });
    $('#myOrderDlg').window('move', {
        top : 150
    });
    $('#myOrderDlg').window('move', {
        left : 500
    });
    $('#myOrderDlg').window('open');

    $('#moduleTree').tree({
        height : 200,
        width : 150,
        striped : true,
        remoteSort : false,
        checkbox : true
    });
}

// 删除邮费区域
function areaDelete() {
    var selections = $("#areaPromoteGrid").datagrid('getSelections');
    if (selections == null || selections == '') {
        $.messager.alert('提示信息', '请选择要删除的数据', 'info');
        return;
    } else {
        $.messager.confirm('提示信息', '您确定要删除这些记录?', function(r) {
            if (r) {
                var ruleConditionAreaId = '';
                for (var i = 0; i < selections.length; i++) {
                    ruleConditionAreaId += selections[i].ruleConditionAreaId
                            + ',';
                }
                ruleConditionAreaId = ruleConditionAreaId.substring(0,
                        ruleConditionAreaId.lastIndexOf(','));
                doAjax({
                    url : appPath + '/page/ecPromoteRuleAreaNewAct/delArea',
                    data : {
                        ids : ruleConditionAreaId
                    },
                    type : 'post',
                    success : function(data) {
                        if (data == 'ok') {
                            $.messager.alert('提示信息', '删除成功', 'info');
                        }
                        doAreaReload();
                    },
                    error : function(XMLHttpRequest, textStatus, errorThrown) {
                        $.messager.alert('提示信息', '抱歉,删除未能完成,' + textStatus,
                                'error');
                        doAreaReload();
                    }
                });
            }
        });
    }
}

function doAreaReload() {
    $('#areaPromoteGrid').datagrid('unselectAll');
    $('#areaPromoteGrid').datagrid('reload');
}

function showAdd() {
    $('#addDlg2').window({
        title : '指定地区',
        iconCls : 'icon-add',
        width : 300,
        height : 430,
        modal : true,
        shadow : true,
        collapsible : false,
        minimizable : false,
        maximizable : false
    });
    if (cnt == 0) {
        $("#msg").attr("innerHTML", "数据读取中,请稍候。。。。。。");
        initTree();
        cnt = cnt + 1;
    } else {
        $("#euTree").tree("collapseAll");
        $("#euTree").tree("expand", $("#euTree").tree("getRoot").target);
        $("#euTree").tree("uncheck", $("#euTree").tree("getRoot").target);
    }

    $('#addDlg2').window('move', {
        top : 10,
        left : 10
    });
    $('#addDlg2').window('open');
}

function initTree() {
    var treeOps = {};
    treeOps.checkbox = true;
    treeOps.url = appPath + "/page/promoteRule/-1/subEcAreaList";
    treeOps.onLoadSuccess = function(node, param) {
        if (loadCnt == 0) {
            loadCnt = loadCnt + 1;
        } else {
            $("#msg").attr("innerHTML", "");
            $("#euTreeTwo").tree("collapseAll");
            $("#euTreeTwo").tree("expand", $("#euTree").tree("getRoot").target);
        }
    };
    $("#euTreeTwo").tree(treeOps);
}

function saveDeliveryHome(strs) {
    // 先保存促销详情
    // 判断选择的下拉是那个
    var ecPromoteRuleItem = new Object();
    ecPromoteRuleItem.promoteRuleId = $("#addpromoteRuleId").val();
    var num = $("#adddiscountType").val();
    var discountValue2 = $('input:radio[name="discountFeeMy"]:checked').val();
    ecPromoteRuleItem.discountValue2 = discountValue2;
    var name = $("#yuanjianRuleId").val();
    if (num == '1') {
        // var rank = "memberRank"+num;
        ecPromoteRuleItem.ruleItemId = $("#shangpinItemId").val();
        ecPromoteRuleItem.discountValue1 = $(
                'input:radio[name=mylxRadio' + num + ']:checked').val();
        // ecPromoteRuleItem.discountValue4=$('#'+rank+']').val();
    }
    if (num == '2') {
        // var rank = "memberRank"+num;
        var str = name.substring("manyuan".length);
        ecPromoteRuleItem.ruleItemId = $("#manyuanItemId" + str).val();
        ecPromoteRuleItem.discountValue1 = $(
                'input:radio[name=mylxRadio' + num + str + ']:checked').val();
        ecPromoteRuleItem.discountValueFee1 = $("#yuan" + str).val();
        // ecPromoteRuleItem.discountValue4=$('#'+rank+str+']').val();
    }
    if (num == '3') {
        // var rank = "memberRank"+num;
        var str = name.substring("manjian".length);
        ecPromoteRuleItem.ruleItemId = $("#manjianItemId" + str).val();
        ecPromoteRuleItem.discountValue1 = $(
                'input:radio[name=mylxRadio' + num + str + ']:checked').val();
        ecPromoteRuleItem.discountValueFee1 = $("#jian" + str).val();
        // ecPromoteRuleItem.discountValue4=$('#'+rank+str+']').val();
    }
    doAjax({
        url : appPath + '/page/ecPromoteRuleItemAct/saveOrUpdate',
        type : 'post',
        data : ecPromoteRuleItem,
        success : function(data) {
            // 促销详情的id = data
            // 给地区的层上赋上ruleItemId
            if (num == '1') {
                $("#shangpinItemId").val(data);
            } else if (num == '2') {
                var str = name.substring("manyuan".length);
                $("#manyuanItemId" + str).val(data);
            } else if (num == '3') {
                var str = name.substring("manjian".length);
                $("#manjianItemId" + str).val(data);
            }
            areaPostage(strs, data, discountValue2);
        }
    });
}

function areaPostage(str, ruleItemId, discountValue2) {
    var checkedNodes = $("#euTreeTwo").tree("getChecked");
    var mIds = "";
    var fullIndex = "";
    for (var i = 0; i < checkedNodes.length; i++) {
        var node = checkedNodes[i];
        var level = node.attributes["areaLevel"];
        if (level == 3) {
            mIds += node.fullIndex + ",";
            fullIndex += node.attributes["fullIndex"] + ",";
        }
    }
    if (mIds.lastIndexOf(",") > 0) {
        mIds = mIds.substring(0, mIds.lastIndexOf(","));
    }
    if (fullIndex.lastIndexOf(",") > 0) {
        fullIndex = fullIndex.substring(0, fullIndex.lastIndexOf(","));
    }
    var isFree = '';
    if (discountValue2 == 'all') {
        isFree = 'Y';
    } else if (discountValue2 == 'little') {
        isFree = 'Y';
    } else if (discountValue2 == 'lots') {
        isFree = 'N';
    }
    if (str == 'save') {
        doAjax({
            url : appPath + '/page/ecPromoteRuleAreaNewAct/saveEcAreaRelation',
            type : 'post',
            data : {
                promoteRuleId : $('#addpromoteRuleId').val(),
                ruleItemId : ruleItemId,
                ids : fullIndex,
                isFree : isFree,
                isDelete : 'N'
            },
            success : function(data) {
                if (data != 'ok') {
                    $.messager
                            .alert('提示信息', '抱歉,保存未能完成,' + textStatus, 'error');
                    return;
                }
                var o = new Object();
                o.id = $("#yuanjianRuleId").val();
                myOrderDlg(o, 'save');
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
                $.messager.alert('提示信息', '抱歉,保存未能完成,' + textStatus, 'error');
            }
        });
        $('#addDlg2').window('close');
    }
    if (str == 'update') {
        doAjax({
            url : appPath
                    + '/page/ecPromoteRuleAreaNewAct/updateEcAreaRelation',
            type : 'post',
            data : {
                promoteRuleId : $('#addpromoteRuleId').val(),
                ruleItemId : ruleItemId,
                isFree : isFree,
                isDelete : 'N'
            },
            success : function(data) {
                if (data == 'OK') {
                    var o = new Object();
                    o.id = $("#yuanjianRuleId").val();
                    myOrderDlg(o, 'update');
                    $.messager.alert('提示信息', '保存成功', 'info');
                    $('#myOrderDlg').window('close');
                } else {
                    $.messager.alert('提示信息', '抱歉,保存未能完成', 'info');
                }
            }
        });
    }

}
// //////////////////////////优惠券开始////////////////////////////
// 给附加条件选择框添加事件
function inputFuJia() {
    hideLable();
    $.each($("input[id^='fujia_']"), function(i, lable) {
        $(lable).click(function() {
            if (this.name == 'mian') {
                $("#fujialab_FF").hide();
                $("#fujialab_FQ").hide();
            }
            if (this.checked == true) {
                $("#fujialab_" + this.value).show();
            } else {
                $("#fujialab_" + this.value).hide();
            }
        });
    });
}

// 隐藏所有的设值
function hideLable() {
    $.each($("label[id^='fujialab_']"), function(i, lable) {
        $(lable).hide();
    });
}

// 优惠券弹出层
function addFQ() {
    // 查询已经添加的优惠劵
    var obj = new Object();
    obj.additionalValues = $("#fujialab_FQ_value").val();
    obj.additionalCounts = $("#fujialab_FQ_count").val();
    if (obj.additionalValues != '' && obj.additionalCounts != '') {
        clearTable();
        doAjax({
            url : appPath
                    + '/page/ecPromoteRuleGoodsGNewAct/getCouponTypeListByIds',
            type : 'post',
            data : obj,
            success : function(data) {
                if (data != null) {
                    var html = "";
                    $
                            .each(
                                    data,
                                    function(i, coup) {
                                        html += "<tr class=\"selectedArea\">"
                                                + "<td><a class=\"easyui-linkbutton deleteArea\" href=\"javascript:void(0)\" iconCls=\"icon-cancel\" >删除</a></td>"
                                                + "<td>"
                                                + coup.COUPON_TYPE_NO
                                                + " <input type= \"hidden\" name=\"FQ_couponTypeId\" value=\""
                                                + coup.COUPON_TYPE_ID
                                                + "\"> </td>"
                                                + "<td>"
                                                + coup.COUPON_TYPE_NAME
                                                + "</td>"
                                                + "<td>"
                                                + coup.COUPON_FEE
                                                + "<input type = \"hidden\" name = \"FQ_couponFee\"  value = \""
                                                + coup.COUPON_FEE
                                                + "\"></td>"
                                                + "<td><input type=\"text\"  maxlength = \"4\"  name=\"FQ_amount\" value=\""
                                                + coup.NUMBER
                                                + "\" style=\"width:50px;\" /></td>"
                                                + "</tr>";
                                    });
                    $("#selectConputTbl").append(html);
                }
            }
        });
    }

    $('#addFQ').window({
        title : "返优惠券",
        iconCls : 'icon-add',
        width : 500,
        height : 350,
        left : 100,
        modal : true,
        shadow : true,
        collapsible : false,
        minimizable : false,
        maximizable : false
    });
    $('#addFQ').window('move', {
        top : 150
    });
    $('#addFQ').window('open');
}

function clearTable() {

    $("#selectConputTbl").html("");
    $("#selectConputTbl").append(getHTML());
}

/**
 * 附加优惠 添加 优惠券
 */
function addFQList() {
    conponList("FQListGridsList", "addFQList");
}
/**
 * 附加条件促销 end
 */

function conponList(gridid, winid) {

    $("#" + gridid).datagrid({
        url : appPath + "/page/promoteGoods/conponList",
        height : 200,
        idField : 'couponTypeId',// 唯一行
        striped : true,
        remoteSort : false,
        pagination : true,
        rownumbers : true,
        singleSelect : false,
        pageList : [ 5, 10, 15, 20, 30, 50 ], // 分页记录数数组
        frozenColumns : [ [ {
            field : "ck",
            checkbox : true
        } ] ],
        columns : [ [ {
            field : 'couponTypeNo',
            title : '优惠券类型',
            width : 100,
            align : 'center',
            sortable : true
        }, {
            field : 'couponTypeName',
            title : '优惠券名称',
            width : 100,
            align : 'center',
            sortable : true
        }, {
            field : 'couponFee',
            title : '优惠券面额',
            width : 100,
            align : 'center',
            sortable : true
        } ] ]
    });
    $('#' + winid).window({
        title : '优惠券',
        width : 700,
        height : 350,
        left : 200,
        modal : true,
        shadow : true,
        collapsible : false,
        minimizable : false,
        maximizable : false
    });
    $('#' + winid).window('move', {
        top : 100
    });
    $('#' + winid).window('open');
}
// 查询优惠券
function doQueryFQ() {
    var obj = new Object();
    obj.couponTypeNo = $.trim($("#fqtype").val());
    obj.couponTypeName = $.trim($("#fqname").val());
    $("#FQListGridsList").datagrid('load', obj);
}

/**
 * 保存优惠券 添加赠品(关闭赠品查询公共窗口后回调方法)
 *
 * @param {}
 *            giftDatas
 */
function saveFQ() {
    var giftDatas = $("#FQListGridsList").datagrid('getSelections');
    if (!giftDatas) {
        $.messager.alert('提示信息', '请选择优惠卷', 'info');
        return;
    }
    var ids = '';
    var add = true;
    for (var i = 0; i < giftDatas.length; i++) {
        var gift = giftDatas[i];
        $.each($("input[name='FQ_couponTypeId']"),
                function(j, input) {
                    if (gift.couponTypeId == $(input).val()) {
                        $.messager.alert('提示信息', gift.couponTypeNo + '优惠卷添加重复',
                                'info');
                        add = false;
                        return false;
                    }
                });
        if (add) {
            ids += gift.couponTypeId + ',';
            var html = "<tr class=\"selectedArea\">"
                    + "<td><a class=\"easyui-linkbutton deleteArea\" href=\"javascript:void(0)\" iconCls=\"icon-cancel\" >删除</a></td>"
                    + "<td>"
                    + gift.couponTypeNo
                    + " <input type= \"hidden\" name=\"FQ_couponTypeId\" value=\""
                    + gift.couponTypeId
                    + "\"> </td>"
                    + "<td>"
                    + gift.couponTypeName
                    + "</td>"
                    + "<td>"
                    + gift.couponFee
                    + "<input type = \"hidden\" name = \"FQ_couponFee\"  value = \""
                    + gift.couponFee
                    + "\"></td>"
                    + "<td><input type=\"text\"  maxlength = \"4\"  name=\"FQ_amount\" value=\"1\" style=\"width:50px;\" /></td>"
                    + "</tr>";
            $("#selectConputTbl").append(html);
        }
    }
    if (add) {
        ids = ids.substring(0, ids.lastIndexOf(','));
        if ($('#fqCouponId').val() != "") {
            $('#fqCouponId').attr('value', $('#fqCouponId').val() + "," + ids);
        } else {
            $('#fqCouponId').attr('value', ids);
        }
        closeAddFQList();
    }
}

function closeAddFQList() {
    $('#addFQList').window('close');
}

function closeAddFQ() {
    $.messager.confirm('提示信息', "您确定保存操作?", function(r) {
        if (r) {
            $.messager.alert('提示信息', '保存成功', 'info');
            $('#addFQ').window('close');
        }
    });
}

/**
 * 附加条件促销保存 start
 */
function saveAll() {
    var obj = new Object();
    // 如果选择的是 全场促销 则一次性保存
    if ($("#sales_all").prop("checked")) {
        obj = getRuleInfo();
    }
    var additionalTypes = "";
    var additionalValues = "";
    var additionalCounts = "";
    var promoteRuleId = $("#addpromoteRuleId").val();
    // 获取附加优惠值
    $.each($("input[id^='fujia']"), function(i, input) {

        if ($(input).prop("checked")) {
            var additionalType = $(input).val();
            additionalTypes += additionalType;

            // 送优惠券
            if (additionalType == 'FQ') {
                var adva = "";
                var adco = "";
                $.each($("input[name^='FQ_']"), function(i, input) {
                    var name = $(input).attr("name");
                    if (name == 'FQ_couponTypeId') {
                        adva += $(input).val() + "-";
                    } else if (name == 'FQ_amount') {
                        adco += $(input).val() + "-";
                    }
                });
                additionalValues += adva;
                additionalCounts += adco;
            } else if (additionalType == 'FKFS') {
                var value = $(
                        "input[name=" + additionalType + "_value]:checked")
                        .val();
                additionalValues += value;
                additionalCounts += "";

            } else if (additionalType == 'ZXL') {
                var value1 = $("#" + additionalType + "_value").val();
                var value2 = $("#" + additionalType + "_day").val();

                additionalValues += value1;
                additionalCounts += value2;

                // 选择手机验证
            } else if (additionalType == 'SYZ') {
                additionalValues += 'SYZ';
            } else {
                var value = $("#" + additionalType + "_value").val();
                additionalValues += value;
                additionalCounts += "";
            }
            if (i != $("input[id^='fujia']").length - 1) {
                additionalTypes += ",";
                additionalValues += ",";
                additionalCounts += ",";
            }
        }
    });
    obj.promoteRuleId = promoteRuleId;
    obj.additionalTypes = additionalTypes;
    obj.additionalValues = additionalValues;
    obj.additionalCounts = additionalCounts;
    doAjax({
        url : appPath + '/page/ecPromoteRuleGoodsGNewAct/addAdditionSave',
        type : 'post',
        data : obj,
        success : function(data) {
            if (data == 1) {
                $.messager.alert('提示信息', '操作成功', 'info');
                doQuery();
                $('#opreateHtml').window('close');
                // 刷新列表
            } else {
                $.messager.alert('提示信息', '网络异常请重试', 'info');
            }
        }
    });
}

// 设置附加信息
function setFuJiaValues(promoteRuleId) {
    // 清空附加信息
    $.each($("input[id^='fujia']"), function(i, input) {
        if ($(input).attr("type") == "text") {
            $(input).val("");
        } else if ($(input).attr("type") == "hidden") {
            $(input).val("");
        } else {
            $(input).removeAttr("checked");
        }
    });
    $.each($("input[id$='_value']"), function(i, input) {
        if ($(input).attr("type") == "text") {
            $(input).val("");
        } else {
            $(input).removeAttr("checked");
        }
    });
    $("#ZXL_day").val("");
    hideLable();

    var object = new Object();
    object.promoteRuleId = promoteRuleId;
    doAjax({
        url : appPath + '/page/ecPromoteRuleGoodsGNewAct/getAdditionList',
        type : 'post',
        data : object,
        success : function(data) {
            if (data != null) {
                $.each(data, function(i, obj) {

                    additionalType = obj.additionalType;
                    // 送优惠券
                    if (additionalType == 'FQ') {
                        $("#fujia_3").attr("checked", "checked");
                        $("#fujialab_FQ_count").val(obj.additionalCount);
                        $("#fujialab_FQ_value").val(obj.additionalValue);
                        $("#fujialab_FQ").show();

                        // 付款方式
                    } else if (additionalType == 'XL') {
                        $("#XL_value").val(obj.additionalValue);
                        $("#fujia_4").attr("checked", "checked");
                        $("#fujialab_XL").show();

                    } else if (additionalType == 'DHXL') {
                        $("#DHXL_value").val(obj.additionalValue);
                        $("#fujia_5").attr("checked", "checked");
                        $("#fujialab_DHXL").show();

                    } else if (additionalType == 'FKFS') {
                        $("#fujia_6").attr("checked", "checked");
                        $.each($("input[name='FKFS_value']"),
                                function(i, FKFS) {
                                    if ($(FKFS).val() == obj.additionalValue) {
                                        $(FKFS).attr("checked", "checked");
                                    }
                                });
                        $("#fujialab_FKFS").show();

                    } else if (additionalType == 'ZXL') {
                        $("#fujia_8").attr("checked", "checked");
                        $("#" + additionalType + "_value").val(
                                obj.additionalValue);
                        $("#" + additionalType + "_day").val(
                                obj.additionalCount);
                        $("#fujialab_ZXL").show();
                        // 选择手机验证
                    } else if (additionalType == 'SYZ') {
                        $("#fujia_7").attr("checked", "checked");

                    } else if (additionalType == 'FF') {
                        $("#fujia_2").attr("checked", "checked");
                        $("#" + additionalType + "_value").val(
                                obj.additionalValue);
                        $("#fujialab_FF").show();
                    } else if (additionalType == 'MY') {
                        $("#fujia_1").attr("checked", "checked");
                    } else {
                        $("#" + additionalType + "_value").val(
                                obj.additionalValue);
                    }
                });
            }
        }
    });
}

// //////////////////////////优惠券结束////////////////////////////

function save() {
    BigSave(); // 先保存优惠券
}
// 保存促销规则
function BigSave() {
    if ($("#addruleNo").val() == null || $("#addruleNo").val() == '') {
        $.messager.alert('提示信息', '请填写促销编码', 'info');
        return;
    }
    if ($("#addruleName").val() == null || $("#addruleName").val() == '') {
        $.messager.alert('提示信息', '请填写促销标题', 'info');
        return;
    }
    if ($("#addbeginTime").datebox("getValue") == null
            || $("#addbeginTime").datebox("getValue") == '') {
        $.messager.alert('提示信息', '请填写促销开始时间', 'info');
        return;
    }
    if ($("#addendTime").datebox("getValue") == null
            || $("#addendTime").datebox("getValue") == '') {
        $.messager.alert('提示信息', '请填写促销结束时间', 'info');
        return;
    }
    if ($("#addbeginTime").datebox("getValue") > $("#addendTime").datebox(
            "getValue")) {
        $.messager.alert('提示信息', '促销开始时间不能大于结束时间', 'info');
        return;
    }
    var ecPromoteRuleNew = new Object();
    var val = $('input:radio[name="sales"]:checked').val();
    ecPromoteRuleNew.promoteRange = val;
    ecPromoteRuleNew.discountPlan = 6;
    ecPromoteRuleNew.promoteRuleId = $("#addpromoteRuleId").val();
    ecPromoteRuleNew.ruleNo = $("#addruleNo").val();
    ecPromoteRuleNew.ruleName = $("#addruleName").val();
    ecPromoteRuleNew.beginTime = $("#addbeginTime").datebox("getValue");
    ecPromoteRuleNew.endTime = $("#addendTime").datebox("getValue");
    ecPromoteRuleNew.discountType = $("#adddiscountType").val();
    ecPromoteRuleNew.discountType1 = $("#adddiscountType1").val();
    var num = $("#adddiscountType").val();
    var ruleItemId = '';
    var discountValue1 = "mylxRadio" + num;
    var discountValueFee1 = '';
    var discountValue4 = 'memberRank' + num;// 存放会员id
    var dataJson = '';
    var retus = true;
    if (num == '1') {
        var ruleItemIdVal = $("#shangpinItemId").val();
        discountValue4 = 'memberRank' + num;
        if ($("#shangpinItemId").val() == null
                || $("#shangpinItemId").val() == '') {
            $.messager.alert('提示信息', '请设置免邮区域', 'info');
            return;
        }
        // 判斷是否選擇会员等级
        if ($("#" + discountValue4).val() == null
                || $("#" + discountValue4).val() == '') {
            $.messager.alert('提示信息', '请设置会员级别', 'info');
            return;
        }
        var discountValue1Val = $(
                'input:radio[name=' + discountValue1 + ']:checked').val();
        var discountValue4Val = $('select[id=' + discountValue4 + ']').val();
        dataJson = "{'ruleItemId':'" + ruleItemIdVal + "'"
                + ",'discountValue1':'" + discountValue1Val
                + "','discountValueFee1':'" + discountValueFee1
                + "','discountValue4':'" + discountValue4Val + "'},";
        dataJson = dataJson.substring(0, dataJson.lastIndexOf(","));
    } else if (num != '1') {
        var divs = "";
        if (num == '2') {
            divs = "divName1";
        } else if (num == '3') {
            divs = "divName2";
        }
        $
                .each(
                        $("div[name=" + divs + "]"),
                        function(i, input) {
                            var nn = $(input).attr("id");
                            discountValue1 = "mylxRadio" + num;
                            discountValue4 = 'memberRank' + num;
                            var str = "";
                            if (num == '2') {
                                ruleItemId = 'manyuanItemId';
                                discountValueFee1 = 'yuan';
                                discountValue4 = 'memberRank' + num;
                                str = nn.substring("warnConditionsa".length);
                            } else if (num == '3') {
                                ruleItemId = 'manjianItemId';
                                discountValueFee1 = 'jian';
                                discountValue4 = 'memberRank' + num;
                                str = nn.substring("warnConditions2".length);
                            }
                            if (str != 0) {
                                ruleItemId += Number(str);
                                discountValue1 += Number(str);
                                discountValueFee1 += Number(str);
                                discountValue4 += Number(str);
                            }
                            if (num == '2') {
                                if ($("#" + ruleItemId).val() == null
                                        || $("#" + ruleItemId).val() == '') {
                                    $.messager.alert('提示信息', '请设置第' + (i + 1)
                                            + '行的免邮区域', 'info');
                                    retus = false;
                                    return false;
                                }
                                if ($("#" + discountValueFee1).val() == null
                                        || $("#" + discountValueFee1).val() == '') {
                                    $.messager.alert('提示信息', '请填写第' + (i + 1)
                                            + '行的满多少元', 'info');
                                    retus = false;
                                    return false;
                                }
                                // 判断输入的是否是数字
                                if (checkIntegerOrDecimal($(
                                        "#" + discountValueFee1).val()) == false) {
                                    $.messager.alert('提示信息', '第' + (i + 1)
                                            + '行的满多少元,请填写数字', 'info');
                                    retus = false;
                                    return false;
                                }
                                if ($("#" + discountValue4).val() == null
                                        || $("#" + discountValue4).val() == '') {
                                    $.messager.alert('提示信息', '请设置第' + (i + 1)
                                            + '行的会员级别', 'info');
                                    retus = false;
                                    return false;
                                }
                            } else if (num == '3') {
                                if ($("#" + ruleItemId).val() == null
                                        || $("#" + ruleItemId).val() == '') {
                                    $.messager.alert('提示信息', '请设置第' + (i + 1)
                                            + '行的免邮区域', 'info');
                                    retus = false;
                                    return false;
                                }
                                if ($("#" + discountValueFee1).val() == null
                                        || $("#" + discountValueFee1).val() == '') {
                                    $.messager.alert('提示信息', '请填写第' + (i + 1)
                                            + '行的满多少件', 'info');
                                    retus = false;
                                    return false;
                                }
                                // 判断输入的是否是数字
                                if (checkNumber($("#" + discountValueFee1)
                                        .val()) == false) {
                                    $.messager.alert('提示信息', '第' + (i + 1)
                                            + '行的满多少件,请填写整数', 'info');
                                    retus = false;
                                    return false;
                                }
                                if ($("#" + discountValue4).val() == null
                                        || $("#" + discountValue4).val() == '') {
                                    $.messager.alert('提示信息', '请设置第' + (i + 1)
                                            + '行的会员级别', 'info');
                                    retus = false;
                                    return false;
                                }
                            }
                            var ruleItemIdVal = $("#" + ruleItemId).val();
                            var discountValue1Val = $(
                                    'input:radio[name=' + discountValue1
                                            + ']:checked').val();
                            var discountValueFee1Val = $(
                                    "#" + discountValueFee1).val();
                            var discountValue4Val = $(
                                    'select[id=' + discountValue4 + ']').val();
                            dataJson += "{'ruleItemId':'" + ruleItemIdVal + "'"
                                    + ",'discountValue1':'" + discountValue1Val
                                    + "','discountValueFee1':'"
                                    + discountValueFee1Val
                                    + "','discountValue4':'"
                                    + discountValue4Val + "'},";
                        });
        dataJson = dataJson.substring(0, dataJson.lastIndexOf(","));
    }
    if (retus) {
        doAjax({
            url : appPath
                    + '/page/ecPromoteRuleNewAct/saveOrUpdate?dataJsons=Postage&postageRuleList='
                    + dataJson,
            type : 'post',
            data : ecPromoteRuleNew,
            success : function(data) {
                saveAll();
            }
        });
    }
}

function baoCunMyDlg() {
    // 更新一下促销详情表
    saveDeliveryHome('update');
}
function closeMyDlg() {
    // 删除这个促销之下的促销详情和免邮区域(物理删除)

    // 清除这个下拉框对应免邮区域的促销详情的Id
    $('#myOrderDlg').window('close');
}

// 启用
function doOk(rowData, str) {
    if(!checkUserButtonRight('editSales')){
        return ;
    }

    var ecPromoteRuleNew = new Object();
    ecPromoteRuleNew.promoteRuleId = rowData.PROMOTE_RULE_ID;
    ecPromoteRuleNew.promoteRuleIdNo = rowData.PROMOTE_RULE_ID;
    ecPromoteRuleNew.promoteClient = rowData.PROMOTE_CLIENT;
    ecPromoteRuleNew.discountPlan = '2,6';
    ecPromoteRuleNew.promoteRange = rowData.PROMOTE_RANGE; // 分别是全场还是按商品还是按类目
    // 物理删除促销信息
    $.messager.confirm('提示信息', "您确定保存操作?", function(r) {
        if (r) {
            doAjax({
                url : appPath + '/page/ecPromoteRuleNewAct/doOkshow',
                type : 'post',
                data : ecPromoteRuleNew,
                success : function(data) {
                    if (str == 1) {
                        if (data.length != 0) {
                            if (rowData.PROMOTE_RANGE == "all") {
                                // 此促销已经有启用的促销,提示
                                if (data[0].prompt != null
                                        && data[0].prompt != "") {
                                    $.messager.alert('提示信息', data[0].prompt,
                                            'info');
                                } else {
                                    enableShow(rowData, null);
                                }
                                // 提示已经启用其他的促销,无法启用全场促销
                            } else if (rowData.PROMOTE_RANGE == "goods") {
                                if (data[0].prompt != null
                                        && data[0].prompt != "") {
                                    $.messager.alert('提示信息', data[0].prompt,
                                            'info');
                                } else {
                                    ConflictListGoods(rowData); // 促销商品冲突列表
                                }
                            } else if (rowData.PROMOTE_RANGE == "catalog") {
                                if (data[0].prompt != null
                                        && data[0].prompt != "") {
                                    $.messager.alert('提示信息', data[0].prompt,
                                            'info');
                                } else {
                                    ConflictListCatalog(rowData); // 促销类目冲突列表
                                }
                            }
                        } else {
                            enableShow(rowData, null);
                        }
                    } else if (str == 2) {
                        enableShow(rowData, 'disable');
                    }
                }
            });
        }
    });
}

function enableShow(rowData, str) {
    var ecPromoteRuleNew = new Object();
    ecPromoteRuleNew.promoteRuleId = rowData.PROMOTE_RULE_ID;
    ecPromoteRuleNew.promoteClient = rowData.PROMOTE_CLIENT;
    ecPromoteRuleNew.promoteRange = rowData.PROMOTE_RANGE; // 分别是全场还是按商品还是按类目
    doAjax({
        url : appPath + '/page/ecPromoteRuleNewAct/enableShow?str=' + str,
        type : 'post',
        data : ecPromoteRuleNew,
        success : function(data) {
            $.messager.alert('提示信息', '操作成功', 'info');
            doQuery();
        }
    });
}
// 冲突列表
function ConflictListGoods(rowData) {
    var ecPromoteRuleNew = new Object();
    ecPromoteRuleNew.promoteRuleId = rowData.PROMOTE_RULE_ID;
    ecPromoteRuleNew.promoteRuleIdNo = rowData.PROMOTE_RULE_ID;
    ecPromoteRuleNew.promoteClient = rowData.PROMOTE_CLIENT;
    ecPromoteRuleNew.discountPlan = '2,6';
    ecPromoteRuleNew.promoteRange = rowData.PROMOTE_RANGE; // 分别是全场还是按商品还是按类目
    $("#conflictListPromoteRuleId").val(rowData.PROMOTE_RULE_ID);
    $("#conflictListPromoteRange").val(rowData.PROMOTE_RANGE);
    $("#deliveryGridDoOkshow").datagrid({
        url : appPath + "/page/ecPromoteRuleNewAct/doOkshow",
        idField : 'promoteConditionGoodsId',// 唯一行
        striped : true,
        remoteSort : false,
        pagination : true,
        rownumbers : true,
        singleSelect : false,
        queryParams : ecPromoteRuleNew,
        columns : [ [ {
            field : 'ruleNo',
            title : '促销编码',
            width : 100,
            align : 'center',
            sortable : true
        }, {
            field : 'ruleName',
            title : '促销名称',
            width : 100,
            align : 'center',
            sortable : true
        }, {
            field : 'goodsNo',
            title : '促销商品编码',
            width : 120,
            align : 'center',
            sortable : true
        }, {
            field : 'goodsName',
            title : '促销商品名称',
            width : 120,
            align : 'center',
            sortable : true
        }, {
            field : 'discountPlan',
            title : '促销分类',
            width : 100,
            align : 'center',
            sortable : true,
            formatter : function(value) {
                if (value == 1) {
                    return "单品促销";
                } else if (value == 2) {
                    return "邮费促销";
                } else if (value == 3) {
                    return "赠品促销";
                } else if (value == 4) {
                    return "XY促销";
                } else if (value == 5) {
                    return "会员单品促销";
                } else if (value == 6) {
                    return "会员邮费促销";
                } else if (value == 7) {
                    return "会员赠品促销";
                } else if (value == 8) {
                    return "会员XY促销";
                } else {
                    return value;
                }
            }
        }, {
            field : 'beginTime',
            title : '开始时间',
            width : 120,
            align : 'center',
            sortable : true
        }, {
            field : 'endTime',
            title : '结束时间',
            width : 120,
            align : 'center',
            sortable : true
        } ] ]
    });
    $('#opreateHtmlConflict').window({
        title : '促销冲突列表',
        width : 800,
        height : 400,
        left : 200,
        modal : true,
        shadow : true,
        collapsible : false,
        minimizable : false,
        maximizable : false
    });
    $('#opreateHtmlConflict').window('move', {
        top : 100
    });
    $('#opreateHtmlConflict').window('open');
}

function cancelBrandConflict() {
    $('#opreateHtmlConflict').window('close');
}

// 冲突列表(类目的冲突列表)
function ConflictListCatalog(rowData) {
    var ecPromoteRuleNew = new Object();
    ecPromoteRuleNew.promoteRuleId = rowData.PROMOTE_RULE_ID;
    ecPromoteRuleNew.promoteRuleIdNo = rowData.PROMOTE_RULE_ID;
    ecPromoteRuleNew.promoteClient = rowData.PROMOTE_CLIENT;
    ecPromoteRuleNew.discountPlan = '2,6';
    ecPromoteRuleNew.promoteRange = rowData.PROMOTE_RANGE; // 分别是全场还是按商品还是按类目
    $("#conflictListPromoteRuleId").val(rowData.PROMOTE_RULE_ID);
    $("#conflictListPromoteRange").val(rowData.PROMOTE_RANGE);
    $("#deliveryGridDoOkshow").datagrid({
        url : appPath + "/page/ecPromoteRuleNewAct/doOkshow",
        idField : 'promoteCategoryConditionId',// 唯一行
        striped : true,
        height : "250",
        remoteSort : false,
        pagination : true,
        rownumbers : true,
        singleSelect : false,
        queryParams : ecPromoteRuleNew,
        columns : [ [ {
            field : 'ruleNo',
            title : '促销编码',
            width : 100,
            align : 'center',
            sortable : true
        }, {
            field : 'ruleName',
            title : '促销名称',
            width : 100,
            align : 'center',
            sortable : true
        }, {
            field : 'ywCatalogId',
            title : '类目编码',
            width : 50,
            align : 'center',
            sortable : true
        }, {
            field : 'ywCatalogName',
            title : '类目名称',
            width : 100,
            align : 'center',
            sortable : true
        }, {
            field : 'discountPlan',
            title : '促销分类',
            width : 100,
            align : 'center',
            sortable : true,
            formatter : function(value) {
                if (value == 1) {
                    return "单品促销";
                } else if (value == 2) {
                    return "邮费促销";
                } else if (value == 3) {
                    return "赠品促销";
                } else if (value == 4) {
                    return "XY促销";
                } else if (value == 5) {
                    return "会员单品促销";
                } else if (value == 6) {
                    return "会员邮费促销";
                } else if (value == 7) {
                    return "会员赠品促销";
                } else if (value == 8) {
                    return "会员XY促销";
                } else {
                    return value;
                }
            }
        }, {
            field : 'beginTime',
            title : '开始时间',
            width : 120,
            align : 'center',
            sortable : true
        }, {
            field : 'endTime',
            title : '结束时间',
            width : 120,
            align : 'center',
            sortable : true
        } ] ]
    });
    $('#opreateHtmlConflict').window({
        title : '促销冲突列表',
        width : 800,
        height : 400,
        left : 200,
        modal : true,
        shadow : true,
        collapsible : false,
        minimizable : false,
        maximizable : false
    });
    $('#opreateHtmlConflict').window('move', {
        top : 100
    });
    $('#opreateHtmlConflict').window('open');
}

// 解决冲突
function sureBrandConflict() {
    var ecPromoteRuleNew = new Object();
    var str = $('input:radio[name="Conflict"]:checked').val();
    ecPromoteRuleNew.promoteRuleId = $("#conflictListPromoteRuleId").val();
    ecPromoteRuleNew.promoteRuleIdNo = $("#conflictListPromoteRuleId").val();
    ecPromoteRuleNew.promoteRange = $("#conflictListPromoteRange").val();
    if ($("#wapType").val() != 'null') {
        ecPromoteRuleNew.promoteClient = $("#wapType").val();
    } else {
        ecPromoteRuleNew.promoteClient = 'web';
    }
    ecPromoteRuleNew.discountPlan = '2,6';
    doAjax({
        url : appPath + '/page/ecPromoteRuleNewAct/doOkshow?jiejue=' + str,
        type : 'post',
        data : ecPromoteRuleNew,
        success : function(data) {
            if (data.length == 0) {
                $.messager.alert('提示信息', '冲突已经成功解决', 'info');
                $('#opreateHtmlConflict').window('close');
                doQuery();
            }
        }
    });
}

function getHTML() {
    return "<tr ><td class=\"queryTitle\" width=\"8%\">操作</td>"
            + "<td class=\"queryTitle\" width=\"15%\">优惠券类型</td>"
            + "<td class=\"queryTitle\" width=\"25%\">优惠券名称</td>"
            + "<td class=\"queryTitle\" width=\"15%\">优惠券面额</td>"
            + "<td class=\"queryTitle\" width=\"25%\">赠送数量</td>" + "</tr>";
}

// ////////////////设置互斥特权开始/////////////////////

// 设置互斥特权
function salesMutexTQ() {
    var iconStr = "icon-add";
    $('#opreateHtmlmemberRankFreedom').window({
        title : '设置互斥特权',
        iconCls : iconStr,
        width : 570,
        height : 400,
        left : 200,
        modal : true,
        shadow : true,
        collapsible : false,
        minimizable : false,
        maximizable : false
    });
    $('#opreateHtmlmemberRankFreedom').window('move', {
        top : 100
    });
    $('#opreateHtmlmemberRankFreedom').window('open');
    // 加载互斥列表
    freedomRepListShow();

}

function freedomRepListShow() {
    doAjax({
        url : appPath + '/page/memberFreedomRepModel/requestfreedom',
        cache : false,
        success : function(data) {
            var freedomArr = []; // 放特权类型;
freedomArr=data;
freedomRepList(freedomArr);
}
});
}

// 列表
function freedomRepList(freedomArr){
$("#rankFreedomGrid").datagrid({
                                        url : appPath + "/page/memberFreedomRepModel/getPage",
                        height : '270',
                        width : '560',
                        striped : true,
                        remoteSort : false,
                        rownumbers : true,
                        singleSelect : false,
                        idField : 'id',
                        queryParams : rankFreedomSelect(),
                        frozenColumns : [ [ {
                            field : "ck",
                            checkbox : true
                        } ] ],
                        columns : [ [
                                {
                                    field : 'freedomName',
                                    title : '特权名称',
                                    width : 150,
                                    align : 'center',
                                    sortable : true
                                },
                                {
                                    field : 'freedomDes',
                                    title : '特权标语',
                                    width : 150,
                                    align : 'center',
                                    sortable : true
                                },
                                {
                                    field : 'freedomType',
                                    title : '特权类型',
                                    width : 100,
                                    align : 'center',
                                    sortable : true,
                                    formatter : function(value, rowData,
                                            rowIndex) {
                                        var num = 0;
                                        for (var int = 0; int < freedomArr.length; int++) {
                                            if (value == freedomArr[int].id) {
                                                num = 1;
                                                return freedomArr[int].name;
                                            }
                                        }
                                        if (num == 0) {
                                            return value;
                                        }
                                    }
                                }, {
                                    field : 'level',
                                    title : '优先级',
                                    width : 55,
                                    align : 'center',
                                    sortable : true
                                } ] ],
                        onLoadSuccess : function(data) {
                            $("#rankFreedomGrid").datagrid('unselectAll');
                            if (data.total > 0) {
                                var promoteRuleId = $("#addpromoteRuleId")
                                        .val();
                                if (promoteRuleId != '') {
                                    var discountExclude = new Object();
                                    discountExclude.excludeMainId = promoteRuleId;
                                    doAjax({
                                        url : appPath
                                                + '/page/memberFreedomRepModel/getPageDisCount',
                                        type : 'post',
                                        data : discountExclude,
                                        success : function(dataCount) {
                                            if (data.total != 0) {
                                                for (var int = 0; int < dataCount.length; int++) {
                                                    for (var int2 = 0; int2 < data.total; int2++) {
                                                        if (dataCount[int].excludeMinorId == data.rows[int2].id) {
                                                            $(
                                                                    '#rankFreedomGrid')
                                                                    .datagrid(
                                                                            'selectRow',
                                                                            int2);
                                                            break;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    });
                                }
                            }
                        },
                        pagination : false,// pagination:false不能写在上面,否则不走onLoadSuccess方法,为true可以走
                    });
}

// 查询
function rankFreedomSelect() {
    var memberFreedomRepModel = new Object();
    // 特权类型
    memberFreedomRepModel.freedomType = $.trim($("#freedomType").combobox(
            "getValue"));
    return memberFreedomRepModel;
}

function doQueryRankFreedom() {
    $("#rankFreedomGrid").datagrid('load', rankFreedomSelect());
}

function saveTQ() {
    var promoteRuleId = $("#addpromoteRuleId").val();
    if (promoteRuleId == '') {
        $.messager.alert('提示信息', '请先填写完促销主信息', 'info');
        return;
    }

    var discountExclude = new Object();
    discountExclude.excludeMainId = promoteRuleId;
    // 获取特权ID和促销ID添加数据,刷新互斥列表
    var selections = $("#rankFreedomGrid").datagrid('getSelections');
    var ids = '';
    if (selections != null && selections != '') {
        for (var i = 0; i < selections.length; i++) {
            ids += selections[i].id + ',';
        }
    }
    doAjax({
        url : appPath + '/page/memberFreedomRepModel/saveOrUpdate?ids=' + ids,
        type : 'post',
        data : discountExclude,
        success : function(data) {
            $.messager.alert('提示信息', '保存成功', 'info');
            $("#rankFreedomGrid").datagrid('unselectAll');
            $('#opreateHtmlmemberRankFreedom').window('close');
        }
    });
}

function closeWinTQ(id) {
    $("#" + id).window("close");
}
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<jsp:include page="/jsp/common/header.jsp"></jsp:include>
<script src="${ctx }/js/memberSales/salesPostage.js"></script>
<input type="hidden" id="promoteRuleId" name="promoteRuleId" value="<%=request.getParameter("promoteRuleId")%>">
<input type="hidden" id="wapType" name="wapType" value="<%=request.getParameter("wapType")%>">
<table class="queryTable">
    <tr>
        <td class="queryTitle" width="80px">促销名称</td>
        <td class="queryContent"><input class="inputText" type="text" id="rulename"/></td>
        <td class="queryTitle" width="80px">促销编码</td>
        <td class="queryContent"><input class="inputText" type="text" id="ruleno"/></td>
        <td class="queryTitle" width="80px">促销方式</td>
        <td class="queryContent">
        <select id="discounttype" class="easyui-combobox" style="width: 100px" panelHeight="auto">
                <option value>请选择</option>
                <option value="1">商品</option>
                <option value="2">满元</option>
                <option value="3">满件</option>
        </select>
        </td>
        <td class="queryTitle" width="80px">规则状态</td>
        <td class="queryContent">
        <select id="type" class="easyui-combobox" style="width: 100px" panelHeight="auto">
                <option value>请选择</option>
                <option value="Y">启用</option>
                <option value="N">禁用</option>
        </select></td>
        <td class="queryBtnTd" rowspan="2"><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="doQuery()">查&nbsp;&nbsp;询</a></td>
    </tr>
    <tr>

        <td class="queryTitle" width="80px">商品编码</td>
        <td class="queryContent"><input class="inputText" type="text" id="goodsno"/></td>
        <td class="queryTitle" width="80px">商品名称</td>
        <td class="queryContent"><input class="inputText" type="text" id="goodsname"/></td>
        <td class="queryTitle" width="80px">促销状态</td>
        <td class="queryContent">
        <select id="promoteStates" class="easyui-combobox" style="width: 100px" panelHeight="auto">
                <option value>请选择</option>
                <option value="1">未开始</option>
                <option value="2">进行中</option>
                <option value="3">已结束</option>
        </select></td>
        <td class="queryTitle" width="80px">促销时间</td>
        <td class="queryContent"><input class="inputText easyui-datebox" type="text" id="begintime" style="width: 100px" editable="false" />&nbsp;到 <input class="inputText easyui-datebox" type="text" id="endtime" style="width: 100px" editable="false" /></td>
    </tr>
</table>

<table id="deliveryGrid"></table>

<!-- 邮费促销 -->
<div id="opreateHtml" class="easyui-window" title="" iconCls="icon-edit" style="width:700px; height:400px; text-align: center; background: #fafafa;">
    <div class="easyui-layout" fit="true">
        <div region="center" border="false" style="background: #fff; border: 1px solid #ccc;">
            <form action="" method="post">
                <table border="0" class="queryTable" width="690px" style="margin:auto;">
                    <tr><td class="queryContent" colspan="4" style="text-align: center;">新增邮费促销</td></tr>
                    <tr>
                        <input type="hidden" id="addpromoteRuleId"/>
                        <td class="queryTitle" width="70px">促销编码</td>
                        <td class="queryContent"><input class="inputText" type="text" maxlength="15" id="addruleNo" /></td>
                        <td class="queryTitle" width="70px">促销标题</td>
                        <td class="queryContent"><input class="inputText" type="text" id="addruleName" /></td>
                    </tr>
                    <tr>
                        <td class="queryTitle" width="70px">促销时间</td>
                        <td class="queryContent" colspan="3"><input class="inputText easyui-datetimebox" type="text" id="addbeginTime" style="width: 125px" editable="false" />&nbsp;
                                                 到 <input  class="inputText easyui-datetimebox" type="text" id="addendTime" style="width: 125px" editable="false" /></td>
                    </tr>
                    <tr>
                        <td class="queryTitle" width="70px">促销类型</td>
                        <td class="queryContent">
                            <select id="adddiscountType" onchange="showParentSelect(this)" style="width: 100px" panelHeight="auto">
                                <option value="1">商品</option>
                                <option value="2">满元</option>
                                <option value="3">满件</option>
                            </select>
                         </td>
                         <td colspan="2" style="text-align: center;">
                             <a class="easyui-linkbutton" href="javascript:void(0);"  onclick="salesMutexTQ()">设置互斥特权</a>&nbsp;
                          </td>
                      </tr>
                      <tr>
                         <td colspan="4">&nbsp;
                            <input type="radio" id="alls" value="all" name="sales" onchange="showGoodOrCategory(this)">全场促销&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" id="goods"  value="goods" name="sales" onchange="showGoodOrCategory(this)">按商品促销
                            <label class="look"><a class="easyui-linkbutton" href="javascript:void(0);" onclick="chooseGoodsSales()">添加促销商品</a>&nbsp;&nbsp;&nbsp;&nbsp;</label>
                            <input type="radio" id="catalog" value="catalog" name="sales" onchange="showGoodOrCategory(this)">按类目促销
                            <label class="look"><a class="easyui-linkbutton" href="javascript:void(0);" onclick="chooseGoodsCategory()">添加促销类目</a></label>
                        </td>
                    </tr>
                    <tr id="one">
                     <td colspan="4">
                        <div class="conditionDiv">
                            <div id="warnConditions0" name="divName" >&nbsp;
                                    <input type="hidden" id="shangpinItemId" style="width:80px;"/>
                                      <input type="radio" id="ALL1" name="mylxRadio1" value="ALL"/>全部
                                    <input type="radio" id="KDFH1" name="mylxRadio1" value="KDFH"  />款到发货
                                    <input type="radio" id="HDFK1" name="mylxRadio1" value="HDFK"  />货到付款&nbsp;
                                    <select id="memberRank1" style="width: 80px" panelHeight="auto"></select>
                                    <a class="easyui-linkbutton" id="shangpin" iconCls="icon-add" href="javascript:void(0)" onclick="myOrderDlg(this,'save')">设置免邮区域</a>
                            </div>
                        </div>
                      </td>
                    </tr>
                    <tr id="two">
                       <td colspan="4">
                            <div class="conditionDiv1">
                                <div id="warnConditionsa0" name="divName1" >&nbsp;
                                        <input type="hidden" id="manyuanItemId" style="width:80px;"/>
                                        <input type="radio" id="ALL2" name="mylxRadio2" value="ALL" />全部
                                        <input type="radio" id="KDFH2" name="mylxRadio2" value="KDFH"  />款到发货
                                        <input type="radio" id="HDFK2" name="mylxRadio2" value="HDFK"  />货到付款
                                          满&nbsp;<input id="yuan" name="Fee1" style="width:80px;"/>元&nbsp;
                                          <select id="memberRank2" style="width: 80px" panelHeight="auto"></select>
                                         <a class="easyui-linkbutton" id="manyuan" iconCls="icon-add" href="javascript:void(0)" onclick="myOrderDlg(this,'save')">设置免邮区域</a>
                                       <label class="look"><a class="easyui-linkbutton" iconCls="icon-add"  href="javascript:void(0);" onclick="return addRow('ss1')"></a>&nbsp;</label>
                                       <label class="look"><a class="easyui-linkbutton" iconCls="icon-cancel" id="ss1" href="javascript:void(0);" onclick="return delRow(this)"></a></label>
                                </div>
                            </div>
                       </td>
                    </tr>
                    <tr id="three">
                      <td colspan="4">
                            <div class="conditionDiv2">
                                <div id="warnConditions20" name="divName2" >&nbsp;
                                        <input type="hidden" id="manjianItemId" style="width:80px;"/>
                                        <input type="radio" id="ALL3" name="mylxRadio3" value="ALL" />全部
                                        <input type="radio" id="KDFH3" name="mylxRadio3" value="KDFH"  />款到发货
                                        <input type="radio" id="HDFK3" name="mylxRadio3" value="HDFK"  />货到付款
                                          满&nbsp;<input id="jian" name="Fee1" style="width:80px;"/>件&nbsp;
                                          <select id="memberRank3" style="width: 80px" panelHeight="auto"></select>
                                         <a class="easyui-linkbutton" id="manjian" iconCls="icon-add" href="javascript:void(0)" onclick="myOrderDlg(this,'save')">设置免邮区域</a>
                                       <label class="look"><a class="easyui-linkbutton" iconCls="icon-add" href="javascript:void(0);" onclick="return addRow('ss2')"></a>&nbsp;</label>
                                       <label class="look"><a class="easyui-linkbutton" iconCls="icon-cancel" id="ss2" href="javascript:void(0);" onclick="return delRow(this)"></a></label>
                                </div>
                            </div>
                       </td>
                    </tr>
                </table>
                <br/>
                <span id="salesOrGoods" style="display: none;">
                    <table id="deliveryGridSalesOrGoods" style="width:690px;height:250px"></table>
                </span>
                <label id="SalesOrCategory" style="display: none;">
                  <table id="deliveryGridSalesOrCategory" style="width:690px;height:250px"></table>
                </label>
                <br/>
                <!--促销附加条件 -->
                <table border="0" class="queryTable" width="690px" style="margin: auto;">
                    <tr>
                        <td class="queryTitle" width="70px" rowspan="4">附加条件</td>
                    </tr>
                    <tr>
                      <td class="queryContent">
                         <input type="radio" id="fujia_1" name="mian" value="MY" />免邮费
                         <input type="radio"  id="fujia_2" name="mian" value="FF" />送积分
                            <label id="fujialab_FF"><input type="text" id="FF_value" style="width: 100px;" value="">分 </label>
                         <input type="radio"  id="fujia_3" name="mian" value="FQ" />送优惠券
                           <label id="fujialab_FQ"><input type="hidden" id="fujialab_FQ_count">
                              <input type="hidden" id="fujialab_FQ_value">
                               <a class="easyui-linkbutton l-btn" iconcls="icon-add" href="javascript:void(0)" onclick="addFQ()">设置优惠劵</a>
                           </label>
                       </td>
                     </tr>
                     <tr  id="fanxie">
                       <td class="queryContent">
                       <input type="checkbox" id="fujia_4" name="dan" value="XL" />单品限购<label id="fujialab_XL">&nbsp;&nbsp;单次限购:<input type="text" id="XL_value" class="inputText" style="width: 100px;" value=""></label>
                       <input type="checkbox" id="fujia_5" name="dan" value="DHXL" />单品会员限购<label id="fujialab_DHXL">&nbsp;&nbsp;限购:<input type="text" id="DHXL_value" class="inputText" style="width: 100px;" value="">件</label>
                       <input type="checkbox" id="fujia_6" name="dan" value="FKFS"/>付款方式<label id="fujialab_FKFS">&nbsp;&nbsp;<input type="radio" id="FKFS_value" name="FKFS_value"  value="KDFH">款到发货&nbsp;<input type="radio" id="FKFS_value" name="FKFS_value"  value="HDFK">货到付款</label></td>
                     </tr>
                    <tr>
                       <td class="queryContent"><!--#7138隐藏<input type="checkbox" id="fujia_7" name="danzhen" value="SYZ"/>手机验证--><input type="checkbox"  id="fujia_8"name="danzhen" value="ZXL" />整单限购<label id="fujialab_ZXL">&nbsp;&nbsp;限购:<input type="text" id="ZXL_day" class="inputText" style="width: 100px;" value="">天内,限购:<input type="text" id="ZXL_value" class="inputText" style="width: 100px;" value="">件</label></td>
                    </tr>
                </table>
                <!--促销附加条件 -->
            </form>
        </div>
   <div region="south" border="false" style="text-align:center;height:30px;line-height:30px;">
      <label class="look"><a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0);" onclick="save();">保存</a>&nbsp;&nbsp;</label>
     <a class="easyui-linkbutton" iconCls="icon-cancel" href="javascript:void(0);" onclick="closeWin();">退出</a>
  </div>
    </div>
</div>
<!-- 选择优惠券 -->
<div id="addFQList" class="easyui-window" title="" iconCls="icon-edit" style="width:600px; height:350px; text-align: center; background: #fafafa;">
  <div class="easyui-layout" fit="true">
    <div region="center" border="false" style="background: #fff; border: 1px solid #ccc;">
           <table class="queryTable">
        <tr>
            <td class="queryTitle" width="80px">优惠券类型</td>
            <td class="queryContent"><input type="text" class="inputText" id="fqtype" /></td>
            <td class="queryTitle" width="80px">优惠券名称</td>
            <td class="queryContent"><input type="text" class="inputText" id="fqname" /></td>
            <td class="queryBtnTd" colspan="2"><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="doQueryFQ()">查&nbsp;&nbsp;询</a></td>
        </tr>
        </table>
        <table id="FQListGridsList"></table>
     </div>
     <br/>
      <div region="south" border="false" style="text-align: center; height: 30px; line-height: 30px;">
        <a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0);" onclick="saveFQ();">完成</a>&nbsp;
        <a class="easyui-linkbutton" iconCls="icon-cancel" href="javascript:void(0);" onclick="closeAddFQList();">取消</a>
    </div>
 </div>
</div>
<!-- 返优惠券 -->
<div id="addFQ" class="easyui-window" title="" iconCls="icon-edit" style="width:600px; height:200px;text-align:center; background: #fafafa;">
    <div class="easyui-layout" fit="true">
        <div region="center" border="false" style="background:#fff;border:1px solid #ccc;">
            <table class="queryTable" width="95%">
                <tr></tr>
                <tr>
                    <td class="queryTitle" style="text-align: left;">&nbsp;&nbsp;赠送优惠券</td>
                </tr>
                <tr>
                    <td class="queryContent">
                         <label class="look"><a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0)" onclick="addFQList()">添加优惠券</a></label>
                    </td>
                </tr>
            </table>
            <table border="0" class="queryTable" width="95%" id ="selectConputTbl">
                <tr>
                    <td class="queryTitle" width="8%">操作</td>
                    <td class="queryTitle" width="15%">优惠券类型</td>
                    <td class="queryTitle" width="25%">优惠券名称</td>
                    <td class="queryTitle" width="15%">优惠券面额</td>
                    <td class="queryTitle" width="25%">赠送数量</td>
                </tr>
            </table>
            <input type="hidden" id="fqCouponId">
        </div>
        <div region="south" border="false" style="text-align:center;height:30px;line-height:30px;">
            <a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0)" onclick="closeAddFQ()">确定</a>&nbsp;&nbsp;
            <a class="easyui-linkbutton" iconCls="icon-back" href="javascript:void(0)" onclick="closeAddFQ()">取消</a>
        </div>
    </div>
</div>

<!--促销类目列表 窗口 -->
<div id="opreateHtmlCategory" class="easyui-window" title="" iconCls="icon-edit" style="width:600px; height:400px; text-align: center; background: #fafafa;">
   <div class="easyui-layout" fit="true">
    <div region="center" border="false" style="background: #fff; border: 1px solid #ccc;">
        <table class="queryTable">
        <tr>
            <td class="queryTitle" width="80px">目录编码</td>
            <td class="queryContent"><input type="text" class="inputText" id="ywCatalogId" /></td>
            <td class="queryTitle" width="80px">目录名称</td>
            <td class="queryContent"><input type="text" class="inputText" id="ywCatalogName" /></td>
            <td class="queryBtnTd" colspan="2"><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="doQueryLeiBrand()">查&nbsp;&nbsp;询</a></td>
        </tr>
       </table>
        <table id="chooseGoodsCategory"></table>
     </div>
      <br/>
    <div region="south" border="false" style="text-align: center; height: 30px; line-height: 30px;">
        <a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0);" onclick="sureBrandSales();">完成</a>&nbsp; <a class="easyui-linkbutton" iconCls="icon-cancel" href="javascript:void(0);" onclick="cancelBrandSales();">取消</a>
    </div>
  </div>
</div>

<!--商品列表 窗口 -->
<div id="opreateHtmlGoods" class="easyui-window" title="" iconCls="icon-edit" style="width:600px; height:300px; text-align: center; background: #fafafa;">
   <div class="easyui-layout" fit="true">
    <div region="center" border="false" style="background: #fff; border: 1px solid #ccc;">
        <table class="queryTable">
            <tr>
                <td class="queryTitle" width="80px">运营分类</td>
                <td class="queryContent">
                     <input  id="ywCatalogSel" />
                </td>
                <td class="queryTitle" width="80px">商品编号</td>
                <td class="queryContent"><input type="text" class="inputText" id="goodsNo" /></td>
            </tr>
            <tr>
                <td class="queryTitle" width="80px">商品名称</td>
                <td class="queryContent"><input type="text" class="inputText" id="goodsName" /></td>
                <td class="queryBtnTd" colspan="2"><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="doQueryBrand()">查&nbsp;&nbsp;询</a></td>
            </tr>
        </table>
        <table id="deliveryGridGoods"></table>
    </div>
    <div region="south" border="false" style="text-align: center; height: 30px; line-height: 30px;">
        <a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0);" onclick="sureBrand();">完成</a>&nbsp; <a class="easyui-linkbutton" iconCls="icon-cancel" href="javascript:void(0);" onclick="cancelBrand();">取消</a>
    </div>
   </div>
</div>

<!-- 免邮费 -->
<div id="myOrderDlg" class="easyui-window" title="" iconCls="icon-edit" style="width:600px; height:200px;text-align:center; background: #fafafa;">
    <div class="easyui-layout" fit="true">
        <div region="center" border="false" style="background:#fff;border:1px solid #ccc;">
            <table class="queryTable" width="95%">
                <tr></tr>
                <tr>
                    <input type="hidden" id="yuanjianRuleId"/>
                    <input type="hidden" id="postage"/>
                    <td class="queryTitle" style="text-align: left;">&nbsp;&nbsp;免邮范围</td>
                </tr>
                <tr>
                    <td class="queryContent">
                        <input type="radio" id="all" name="discountFeeMy" checked="checked" value="all" onclick="showGoodOrPostage(this)"/> 全国免邮
                        <input type="radio" id="little" name="discountFeeMy" value="little" onclick="showGoodOrPostage(this)"/> 如下区域免邮
                        <input type="radio" id="lots" name="discountFeeMy" value="lots" onclick="showGoodOrPostage(this)"/> 如下区域不免邮,其余地区免邮
                    </td>
                </tr>
            </table>
            <table id="areaPromoteGrid" ></table>
        </div>
        <div region="south" border="false" style="text-align:center;height:30px;line-height:30px;">
            <label class="look"><a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0)" onclick="baoCunMyDlg()">确定</a>&nbsp;&nbsp;</label>
            <a class="easyui-linkbutton" iconCls="icon-cancel" href="javascript:void(0)" onclick="closeMyDlg()">取消</a>
        </div>
    </div>
</div>

<div  region="west"  split="true"  style="width:200px;padding:10px;">
    <ul id="euTree"></ul>
</div>
<div id="addDlg2" class="easyui-window" title=""  iconCls="icon-save" style="width:600px; height:500px;text-align:left; background: #fafafa;">
    <div class="easyui-layout" fit="true">
        <div region="center" border="false" style="background:#fff;border:1px solid #ccc;padding-left: 30px;">
            <form id="addForm2">
            <div id="msg"></div>
            <div  region="west"  split="true"  style="width:200px;padding:10px;">
                <ul id="euTreeTwo"></ul>
            </div>
            </form>
        </div>
        <div region="south" border="false" style="text-align:center;height:30px;line-height:30px;">
            <a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0)" onclick="saveDeliveryHome('save')">确定</a>
        </div>
    </div>
</div>
<!-- 自定义区域 -->
<div id="customAreaTree" class="easyui-window" title=""  iconCls="icon-save" style="width:600px; height:500px;text-align:left; background: #fafafa;">
    <div class="easyui-layout" fit="true">
        <div region="center" border="false" style="background:#fff;border:1px solid #ccc;padding-left: 30px;">
            <form id="addForm1">
            <div id="msg1"></div>
            <div  region="west"  split="true"  style="width:200px;padding:10px;">
                <ul id="euTreeOne"></ul>
            </div>
            </form>
        </div>
        <div region="south" border="false" style="text-align:center;height:30px;line-height:30px;">
            <a class="easyui-linkbutton"  href="javascript:void(0)" onclick="selectCustomArea()">确定</a>
        </div>
    </div>
</div>

<!-- 冲突列表 -->
<div id="opreateHtmlConflict" class="easyui-window" title="" iconCls="icon-edit" style="width:700px; height:350px; text-align: center; background: #fafafa;">
  <div class="easyui-layout" fit="true">
    <div region="center" border="false" style="background: #fff; border: 1px solid #ccc;">
           <input type="hidden" id="conflictListPromoteRuleId">
           <input type="hidden" id="conflictListPromoteRange">
           <table id="deliveryGridDoOkshow"></table>
           <br/>
           <input type="radio" name="Conflict" value="Enable" checked="checked"/>启用本促销禁用其他促销&nbsp;&nbsp;
           <input type="radio" name="Conflict" value="Yes" />删除本促销冲突商品&nbsp;&nbsp;
           <input type="radio" name="Conflict" value="No" />删除其他促销冲突商品
           <br/>
           <br/>
    </div>
    <div region="south" border="false" style="text-align: center; height: 30px; line-height: 30px;">
        <a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0);" onclick="sureBrandConflict();">解决冲突</a>&nbsp; <a class="easyui-linkbutton" iconCls="icon-cancel" href="javascript:void(0);" onclick="cancelBrandConflict();">取消</a>
    </div>
   </div>
</div>

<div id="opreateHtmlmemberRankFreedom" class="easyui-window" title="" iconCls="icon-edit" style="width:600px; height:200px;text-align:center; background: #fafafa;">
  <div class="easyui-layout" fit="true">
    <div region="center" border="false" style="background:#fff;border:1px solid #ccc;">
       <form>
             <table class="queryTable" width="550px">
               <tr>
                   <td class="queryTitle" width="120px">特权类型</td>
                   <td class="queryContent" >
                        <select id="freedomType" class="easyui-combobox" style="width: 100px" panelHeight="auto">
                             <option value="6">会员特价</option>
                        </select>
                   </td>
                   <td class="queryBtnTd" style="text-align:right;" colspan="2">
                        <a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0);" onclick="doQueryRankFreedom();">查&nbsp;询</a>
                   </td>
             </tr>
             </table>
             <table id="rankFreedomGrid"></table>
       </form>
    </div>
    <div region="south" border="false" style="text-align:center;height:30px;line-height:30px;">
         <label id="mutexTQ">
           <a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0);" onclick="saveTQ();">选择</a>&nbsp;&nbsp;
         </label>
         <a class="easyui-linkbutton" iconCls="icon-cancel" href="javascript:void(0);" onclick="closeWinTQ('opreateHtmlmemberRankFreedom');">取消</a>
    </div>
  </div>
</div>


上一篇:Dubbo下载-从missing artifactId说起


下一篇:Xcode插件失效解决办法