<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>账户设置</title>
    <meta charset="utf-8">
    <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" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/static/css/reset.css" media="all">
    <style>
        .ce{
            text-align: center;
        }
        .layui-table th{
            text-align: center;
        }
       /* .layui-table tr{
            height: 150px;
        }*/
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card layui-form">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <sfTags:pagePermission authFlag="XTSZ_XTSZ_ZHSZ_T" html='<li class="layui-this"><a href="${ctx}/accountSet/accountSetPage">账户设置</a></li>'/>
            </ul>
        </div>

        <div class="layui-card-body layuiadmin-card-header-auto" >
        </div>

        <div class="layui-card-body">
            <table class="layui-table ce" lay-size="lg" lay-filter="test">
                <colgroup>
                    <col width="10">
                    <col width="140">
                    <col width="140">
                    <col width="600">
                    <col width="100">
                </colgroup>
                <thead>
                <tr>
                    <th>序号</th>
                    <th>账户名称</th>
                    <th>设置类目</th>
                    <th>设置内容</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>1</td>
                    <td>首次发货授信方案</td>
                    <td>首次发货授信方案</td>
                    <td>
                        <c:if test="${not empty type1.columns.content}">
                              <c:forEach items="${fn:split(type1.columns.content,'。')}" var="co">
                                  <p>${co}</p>
                              </c:forEach>
                        </c:if>

                    </td>
                    <td><a class="layui-table-opt-link" href="javascript:setAccounts('1');">设置</a></td>
                </tr>
                <tr>
                    <td>2</td>
                    <td>标准发货授信方案</td>
                    <td>标准发货授信方案</td>
                    <td>
                        <c:if test="${not empty type2.columns.content}">
                            <c:forEach items="${fn:split(type2.columns.content,'。')}" var="co">
                                <p>${co}</p>
                            </c:forEach>
                        </c:if>
                    </td>
                    <td><a class="layui-table-opt-link" href="javascript:setAccounts('2');">设置</a></td>
                </tr>
                <tr>
                    <td>3</td>
                    <td>结算款账户方案</td>
                    <td>待结算账户</td>
                    <td id="account3">
                        <c:if test="${not empty type3.columns.content}">
                            <c:forEach items="${fn:split(type3.columns.content,'。')}" var="co">
                                <p>${co}</p>
                            </c:forEach>
                        </c:if>
                    </td>
                    <td><a class="layui-table-opt-link" href="javascript:setAccounts3('3');">设置</a></td>
                </tr>
                <tr>
                    <td>4</td>
                    <td>质保金账户方案</td>
                    <td>质保金账户</td>
                    <td id="account4" data-value="${type4.columns.proportion}">

                    <c:choose>
                        <c:when test="${type4.columns.way eq '1'}">${type4.columns.proportion} 元/瓦</c:when>
                        <c:when test="${type4.columns.way eq '2'}">${type4.columns.proportion} 元/块</c:when>
                        <c:otherwise>
                        结算费 * ${type4.columns.proportion}%
                        </c:otherwise>
                    </c:choose>
                    </td>
                    <td><a class="layui-table-opt-link" href="javascript:setAccounts2('4');">设置</a></td>
                </tr>
                </tbody>
            </table>
        </div>

    </div>
</div>
</div>
<script type="text/html" id="table-toolbar">
    <sfTags:pagePermission authFlag="XTSZ_JSJSZ_JSJSZ_LOOK_B" html='<a class="layui-table-opt-link" lay-event="look">查看</a>'/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <sfTags:pagePermission authFlag="XTSZ_JSJSZ_JSJSZ_DELETE_B" html='<a class="layui-table-opt-link" lay-event="delete">作废</a>'/>
</script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/data.js"></script>
<script type="text/javascript">
    var saveMark = false;
    //初始数据
    var $form;
    var form;
    var upload;
    var $;
    var table;
    var myreg=/^\d+(\.\d{1,2})?$/;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form','excel'], function(){
        $ = layui.$
            ,form = layui.form
            ,tableExt = layui.tableExt;
        laydate = layui.laydate;
        table = layui.table;

        //开始日期
        var disStartTime = laydate.render({
            elem: '#createTimeSta'
            ,done: function(value, date){
                //更新结束日期的最小日期
                disEndTime.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                disEndTime.config.elem[0].focus();
            }
        });
        //结束日期
        var disEndTime = laydate.render({
            elem: '#createTimeEnd'
            ,done: function(value, date){
                //更新开始日期的最大日期
                disStartTime.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });


        table.on('tool(test)',function(obj) {
            var data = obj.data;
            var id = data.id;
            var applyId=data.apply_id;
            if (obj.event === 'setAccount') {
                layer.open({
                    title:'查看',
                    type: 2,
                    area: ["60%", "70%"],
                    content: '${ctx}/apply/standardPrice/standardPriceApplyDetailPage?id='+applyId+'&detailId='+id
                })
            }
        });

        //监听搜索
        form.on('submit(LAY-user-back-search)', function(data){
            var field = data.field;
            //执行重载
            table.reload('test', {
                where: field,
                page:{
                    curr:1
                }
            });
        });

        function isBlank(val) {
            if (val == null || val == '' || val == undefined) {
                return true;
            }
            return false;
        }
    });

    ///  首次发货授信方案  /  标准发货授信方案
    function setAccounts(type){
        layer.open({
            title:'设置',
            type: 2,
            area: ["60%", "80%"],
            content: '${ctx}/accountSet/addSetAccountPage?type='+type
        })
    }

    // 结算款账户方案
    function setAccounts3(type){
        layer.open({
            title:'设置',
            type: 2,
            area: ["60%", "80%"],
            content: '${ctx}/accountSet/setYjsAccountPage?type='+type
        })
    }

    //质保金账户方案
    function setAccounts2(type){


        layer.open({
            title:'设置',
            type: 2,
            area: ["45%", "60%"],
            content: '${ctx}/accountSet/setBzjdjSet?type='+type
        })

      /*  var amount;
        var str="";
        if('3'==type){
          amount=$("#account3").attr("data-value");
          str="预结算比例";

        }else if('4'==type){
            amount=$("#account4").attr("data-value");
            str="质保金单价设置"
        }
        if(isBlank(amount)){
            amount="";
        }

        var htm='<div class="layui-form-item mt-30" style="width: 90%">' +
            ' <label class="layui-form-label w-120"><i class="red">*</i>'+str+'：</label>' +
            '<div class="layui-input-block ml-120">' +
            ' <input type="text" name="setAmount" class="layui-input"  id="setAmount"  value="'+amount+'">' ;
              if('3' == type){
                  htm+=' <span class="pos-a h-32 lh-32 layui-span-unit" >%</span> ';
              }else if('4' == type){
                  htm+=' <span class="pos-a h-32 lh-32 layui-span-unit" >元/瓦</span>';
              }

        htm+=' </div>' +
                '</div>';
      var mid= layer.open({
            type: 1,
            title:'设置',
            area: ['450px', '300px'],
            content: htm,
            btn: ['保存', '取消'],
            yes: function(index, layero){
               var setAmount=$("#setAmount").val();
                if (!myreg.test(setAmount)) {
                    layer.msg("请输入正确的格式!",{time:2000});
                    return false;
                }
                $.ajax({
                    type: "POST",
                    url: "${ctx}/accountSet/saveOtherAccountSet",
                    data: {
                        type: type,
                        amount:setAmount
                    },
                    success: function (result) {
                        if(result.code=="200"){
                            layer.msg("保存成功",{time:2000},function (){
                                if("3"==type){
                                    $("#account3").text(setAmount+'%');
                                    $("#account3").attr("data-value",setAmount);
                                }else if("4"== type){
                                    $("#account4").text(setAmount+'元/瓦');
                                    $("#account4").attr("data-value",setAmount);
                                }
                                layer.close(mid);
                            });

                        } else{
                            layer.msg("保存失败!",{time:2000});
                        }
                    },
                });
        }
        });*/
    }
    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }


</script>
</body>
</html>





