<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>项目安装方式</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="decorator" content="base"/>
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/css/reset.css" />
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/lib/font/iconfont.css" />
    <style>
        html{
            background-color: #fff;
        }
        .layui-form-select dl {
            max-height: 200px;
        }
    </style>
</head>
<body>
<div class="layui-form mb-0 pr-30" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin">
    <input type="hidden" name="id" value="${setRecord.columns.id}">
    <input type="hidden" name="traderId" value="${setRecord.columns.traderId}">
    <div id="textDiv" class="layui-card-body">
        <div class="layui-col-xs6 mb-10">
            <label class="layui-form-label"><i class="mark">*</i>验收类型：</label>
            <div class="layui-input-block">
                <input type="text" value="质量验收" class="layui-input layui-bg-gray" readonly>
            </div>
        </div>

        <div class="layui-col-xs6 mb-10">
            <label class="layui-form-label"><i class="mark">*</i>代理商名称：</label>
            <div class="layui-input-block">
                <input type="text" value="${setRecord.columns.traderName}" class="layui-input layui-bg-gray" readonly>
            </div>
        </div>

        <div class="layui-col-xs6 mb-10">
            <label class="layui-form-label"><i class="mark">*</i>抽成比例：</label>
            <div class="layui-input-block">
                <input type="text" name="ratio" value="${setRecord.columns.ratio}" lay-verify="required" class="layui-input" oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1');">
                <span class="pos-a h-32 lh-32 layui-span-unit">%</span>
            </div>
        </div>

    </div>
    <div class="layui-form-item text-c operate-footer" >
        <button class="layui-btn " lay-submit lay-filter="component-form-element">保存</button>
        <button class="layui-btn layui-btn-primary" onclick="cancel()">取消</button>
    </div>
</div>

<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/font/iconfont.js"></script>
<script>
    layui.use(['form','jquery','layedit'], function () {
        $ = layui.$,
            form = layui.form,
            layer = layui.layer;

        var fg=false;
        form.on('submit(component-form-element)',function(data){
            if(fg){
                return;
            }
            var field = data.field; //获取提交的字段
            /*if(isNaN(field.ratio)){
                layer.msg("抽成比例格式不正确!", {time: 3000});
                return;
            }*/
            if(field.ratio<=0 || field.ratio>100){
                layer.msg("抽成比例只允许输入0.01-100的数字!", {time: 3000});
                return;
            }
            fg=true;
            $.ajax({
                url: '${ctx}/qualityRatioSet/editQualityRatioSet',
                type: 'post',
                data: {
                    id: field.id,
                    traderId: field.traderId,
                    ratio:field.ratio
                },
                success: function(data) {
                    if(data.code === "200"){
                        layer.msg('操作成功！', {icon:1,time:2000},function(){
                            parent.window.reload(); //刷新父页面
                        })
                    }else{
                        layer.msg("修改失败！"+data.errMsg,{icon:5,anim:6});
                    }
                },
                complete:function(){
                    fg=false;
                }
            });

        })

    });

    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }
    function cancel(){
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }
</script>
</body>
</html>

