brandRebateEdit.html 3.91 KB
<!DOCTYPE html>
<div id="brandRebateEditDiv" >
    <form id="brandRebateEditForm" name="brandRebateEditForm" method="post">
        <table cellspacing="0" border="0" align="center" style="width:90%;margin-top:0px;line-height:10px;height:200px;" id="sknRebateEditTable">
            <tr>
                <td width="30%"  align="left">品牌:</span></td>
                <td width="70%"  align="left" colspan="3" id="brandIdTR">
                    <input class="easyui-combobox" id="brand" style="width: 200px;">
                </td>
                <td width="70%"  align="left" colspan="3" id="brandNameTR" hidden>
                    <span id="brandName" hidden></span>
                </td>
            </tr>
            <tr>
                <td width="30%"  align="left">返佣比例:</td>
                <td width="30%"  align="left" colspan="2">
                    <input type="radio" value="1"  name="type" style="width:20px" checked >默认</input>&nbsp;&nbsp;
                    <input type="radio" value="2"  name="type" style="width:20px">自定义</input>
                </td>
                <td width="40%" align="left">
                    <input type='text' class="easyui-textbox" style="width: 100px" id="rebateStr" name="rebateStr" data-options="prompt:'0.0 ~ 25.0'"/>
                    <span style="margin-left:-15px">%</span>
                </td>
            </tr>
            <tr>
                <td width="30%"  align="left" >返佣状态:</td>
                <td width="70%"  align="left" colspan="3">
                    <input type="radio" value="1"  name="state" style="width:20px" checked >开启</input>&nbsp;&nbsp;
                    <input type="radio" value="2"  name="state" style="width:20px">关闭</input>
                </td>
            </tr>
        </table>
    </form>
</div>
<script>

    $(function(){

        var rebatTextBox = $("#rebateStr");
        rebatTextBox.textbox('textbox').bind('keyup', function() {
            var tempValue = $(this).val();
            var value = tempValue.replace(/[^\d.]/g,"")
                                 .replace(/^(\-)*(\d+)\.(\d).*$/,'$1$2.$3');
            rebatTextBox.textbox('setValue',value);
        });

        var brandCombobox = $("#brandRebateEditDiv #brand");
        brandCombobox.myCombobox({
            editable: false,
            valueField : "value",
            textField : "text",
            required:false,
            prompt: "选择品牌",
            url : contextPath + "/UnionRebateRest/queryAllBrandList",
            panelHeight:200,
            loadFilter: function (data) {
                return data;
            }
        });

        rebatTextBox.textbox('readonly',true);
        $('input[type=radio][name=type]').change(function() {
            if (this.value == '1') {
                rebatTextBox.textbox("setValue", "");
                rebatTextBox.textbox('readonly',true);
            } else {
                rebatTextBox.textbox('readonly',false);
            }
        });

        var data = window.self.paramObject.brandRebateData;
        if (data){
            brandCombobox.myCombobox("setValue", data.brand);
            $("#brandIdTR").hide();
            var brandNameSpan = $("#brandNameTR");
            brandNameSpan.show();
            brandNameSpan.html(data.name);
            if(data.type == 1){
                $(":radio[name='type'][value='1']").prop("checked",true);
            }else if(data.type == 2){
                rebatTextBox.textbox('readonly',false);
                $(":radio[name='type'][value='2']").prop("checked",true);
            }
            if(data.state == 1){
                $(":radio[name='state'][value='1']").prop("checked",true);
            }else if(data.state == 2){
                $(":radio[name='state'][value='2']").prop("checked",true);
            }
            if(data.rebate != 0) {
                rebatTextBox.textbox("setValue", data.rebate / 100);
            }
        }
    })
</script>