<%@ 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" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/formSelects-v4.css" media="all">
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/lib/font/iconfont.css" />
    <style>
        .circle2{
            width: 80px;
            height: 80px;
            border-radius: 50%;
            line-height: 22px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        html{ background-color: #FFF}
        .content-box{border-radius: 5px; width: 1000px; margin: 0 auto; box-sizing: border-box; padding: 30px 20px; font-size: 14px; color: #333333; margin-top: 100px; line-height: 28px; display: flex; background: url("${ctxPlugin}/static/sxImg/sx_ed_backgroud.png") #f2f2f2 right bottom no-repeat}
        .c-title{ font-weight: 600}
        .content-box .c-left{ flex: 1}
        .content-box .c-right{ width: 200px; text-align: center}
        .m-num{font-size: 20px;}
        .opt-btn{background-color: #0a6597; font-size: 14px; color: #ffffff; padding: 5px 10px; display: inline-block; border-radius: 3px; margin-top: 10px; cursor: pointer}
        .hide{display: none}
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-form layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <sfTags:pagePermission authFlag="ZHGL_SXZH_SXZH_T" html='<a href="${ctx}/account/toSxAccount"><li class="layui-this">授信账户</li></a>'/>
                <sfTags:pagePermission authFlag="ZHGL_KPHZH_BDMX_T" html='<a href="${ctx}/account/toKphBdDetail"><li class="">变动明细</li></a>'/>
<%--                <button class="layui-btn f-r mt-10 mr-15 pl-10 pr-10 " type="reset"  onclick="reset()" >--%>
<%--                    <i class="layui-icon fs-12">&#xe9aa;</i>--%>
<%--                    重置--%>
<%--                </button>--%>
<%--                <button class="layui-btn f-r mt-10 mr-15 pl-10 pr-10" id="searchBtn" lay-submit lay-filter="LAY-user-back-search"><i class="layui-icon fs-12">&#xe615;</i>查询</button>--%>
            </ul>
        </div>
    </div>
    <div class="layui-card">
            <div class="layui-card-body display-flex">
                <input class="hide" value="${empty account.columns.ifOne?"1":account.columns.ifOne}" id="ifOne">
                <input class="hide" value="${traderId}" id="traderId">
                <div class="layui-col-lg4 layui-col-sm4" style="display: flex;justify-content: center; align-items: center;">
                    <span class="property-icon circle2"><img src="${ctxPlugin}/static/sxImg/sx_sj.png" /></span>
                    <div class="dp-inline" style="color: #333333; font-size: 16px">
                        <div><div>实缴保证金(元)：</div> <span class="font-bold" id="totalStock">${empty account.columns.bzjAmount? 0: bzjAmount}</span></div>
                    </div>
                </div>
                <div class="layui-col-lg4 layui-col-sm4 " style="display: flex;justify-content: center; align-items: center;">
                    <span class="property-icon circle2"><img src="${ctxPlugin}/static/sxImg/sx_bzj.png" /></span>
                    <div class="dp-inline" style="color: #333333; font-size: 16px">
                        <div><div>保证金额度(元)：</div> <span class="font-bold" id="zpTotalStock">${empty account.columns.bondAmountLimit? 0: bzjLimitAmount}</span></div>
                    </div>
                </div>
                <div class="layui-col-lg4 layui-col-sm4 " style="display: flex;justify-content: center; align-items: center;">
                    <span class="property-icon circle2"><img src="${ctxPlugin}/static/sxImg/sx_yfh.png" /></span>
                    <div class="dp-inline" style="color: #333333; font-size: 16px">
                        <div><div>累计已发货(元)：</div> <span class="font-bold" id="yjTotalStock">${empty account.columns.deliverTotalAmount? 0: account.columns.deliverTotalAmount+account.columns.yk_deliver_total_capacity}</span></div>
                    </div>
                </div>
                <div class="layui-col-lg4 layui-col-sm4 " style="display: flex;justify-content: center; align-items: center;">
                    <span class="property-icon circle2"><img src="${ctxPlugin}/static/sxImg/sx_yaz.png" /></span>
                    <div class="dp-inline" style="color: #333333; font-size: 16px">
                        <div><div>累计已安装量(元)：</div> <span class="font-bold" id="tkTotalStock">${empty account.columns.yazTotalCapacity? 0: account.columns.yazTotalCapacity+account.columns.yk_yaz_total_capacity}</span></div>
                    </div>
                </div>
                <div class="layui-col-lg4 layui-col-sm4 " style="display: flex;justify-content: center; align-items: center;">
                    <span class="property-icon circle2"><img src="${ctxPlugin}/static/sxImg/sx_ybw.png" /></span>
                    <div class="dp-inline" style="color: #333333; font-size: 16px">
                        <div><div>累计已并网量(元)：</div> <span class="font-bold">${empty account.columns.ybwTotalCapacity? 0: account.columns.ybwTotalCapacity+account.columns.yk_ybw_total_capacity}</span></div>
                    </div>
                </div>
            </div>
        </div>
    <div class="content-box sc">
        <div class="c-left ">
           <%-- <div class="c-title">您当前可申请赊销下单最大额度为：</div>--%>
            <div>首次发货额度：实缴保证金金额+min((通过踏勘审核的进件量*${edSetSc.columns.capacity_ratio})* ${edSetSc.columns.capacity_multiple}倍，保证金额度*${edSetSc.columns.amount}倍）</div>
            <div>发货额度：min(实缴保证金金额+保证金额度*${edSetHx.columns.amount}倍-累计未安装量，保证金额度*${edSetHx.columns.capacity_multiple}倍-累计未并网量）</div>
        </div>
        <div class="c-right">
           <%-- <div class="m-num">2,578,450.90 元</div>--%>
            <div class="opt-btn ssed" >授信额度试算 <img src="${ctxPlugin}/static/sxImg/sx_yjt.png" /></div>
          <%--  <div class="opt-btn"><img src="${ctxPlugin}/static/sxImg/sx_cxjs.png" /> 重新测算</div>--%>
        </div>
    </div>

</div>

<div class="content-box hide" style="padding: 10px;" id="ideaDiv">
    <div class="c-left">
        <div class="c-title">您当前可申请赊销下单最大额度为：<span class="dt"></span></div>
        <div class="js">首次发货额度：实缴保证金金额+min(通过踏勘审核的进件量*1.2倍，保证金额度*2倍）</div>
    </div>
    <div class="c-right">
        <div class="m-num"></div>
        <div class="opt-btn ssed"><img src="${ctxPlugin}/static/sxImg/sx_cxjs.png" /> 重新测算</div>
    </div>
</div>
<!-- toolbar -->
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <sfTags:pagePermission authFlag="ZHGL_KPHZH_BDMX_DC_B" html='<button class="layui-btn layui-btn-sm" id="exportBtn"><i class="layui-icon layui-icon-export"></i>导出</button>'/>
    </div>
</script>
<!--操作栏-->
<script type="text/html" id="optTpl">
    <a class="layui-table-opt-link" lay-event="viewDetail">查看</a>
</script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/lib/formSelects-v4.js"></script>
<script>
    var entrycount=0;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form', 'upload', 'laytpl'], function(){
        //layui.use(['table','layer','laypage','laydate','form'], function(){
        $ = layui.$;
        tableExt = layui.tableExt;
        layer = layui.layer;
        laypage = layui.laypage;
        laydate = layui.laydate;
        form = layui.form;
        laytpl = layui.laytpl;
        table = tableExt.getLayTable();

        table.on('tool(test)', function (obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）

        })

        $(".ssed").on("click",function(){
            $("#ideaDiv").removeClass("hide");
            $(".sc").addClass("hide");
            var ifOne=$("#ifOne").val();
            if(isBlank(ifOne)){
                ifOne="0";
            }
            if(ifOne=="0"){
                $(".js").html("首次发货额度：实缴保证金金额+min((通过踏勘审核的进件量*${edSetSc.columns.capacity_ratio})* ${edSetSc.columns.capacity_multiple}倍，保证金额度*${edSetSc.columns.amount}倍）");
            }else {
                $(".js").html("发货额度：min(实缴保证金金额+保证金额度*${edSetHx.columns.amount}倍-累计未安装量，保证金额度*${edSetHx.columns.capacity_multiple}倍-累计未并网量）");
            }
            var traderId=$("#traderId").val();
            $.ajax({
                type:"POST",
                url:"${ctx}/account/countLimit",
                data:{
                    traderId:traderId,
                    type:ifOne
                },
                success:function(result){
                    if(result.code =='200'){
                        let totalCapacity = result.data.totalCapacity;//通过踏勘审核的进件量
                        let bondAmountLimit = result.data.bondAmountLimit;//保证金额度
                        // let bzjAmount = result.data.bzjAmount;//实缴保证金金额
                        // let ykBzjAmount = result.data.ykBzjAmount;//友夸实缴保证金金额
                        let totalBzjAmount = result.data.totalBzjAmount;//总实缴保证金金额
                        let wazTotalCapacity = result.data.wazTotalCapacity;//累计未安装量
                        let wbwTotalCapacity = result.data.wbwTotalCapacity;//累计未并网量
                        var edSet=result.data.edSet;
                        var html = "";
                        if (ifOne==="0"){
                            html = totalBzjAmount +' + min ( ( '+totalCapacity+' x '+edSet.columns.capacity_ratio+' ) x '+edSet.columns.capacity_multiple+' , '+bondAmountLimit+' x '+edSet.columns.amount+' ) ';
                        }else {
                            html=' min ( '+totalBzjAmount+' + '+bondAmountLimit+' x '+edSet.columns.amount+' - '+wazTotalCapacity+' , '+bondAmountLimit+' x '+edSet.columns.capacity_multiple+' - '+wbwTotalCapacity+' ) ';
                        }
                        console.log(result.data.ed);
                         $(".m-num").html(result.data.ed+'元');
                        $(".dt").html(html);
                    }else{
                        layer.msg("查询失败！")
                    }

                }
            })
        })
    })

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

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


