<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <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}/lib/layuiAdmin/dist/layuiadmin/dist/viewer.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/static/css/reset.css" media="all">
    <style>
        html{background-color: #fff;padding-bottom: 50px;}
        .layui-form-select dl{
            max-height:200px;
            width: 80%;
        }
        .layui-text h3 {
            font-size: 14px !important;
        }
        .fontColor1{
            color: #409eff !important;
        }
    </style>
</head>
<body>

<div class="layui-form" id="LAY_app">
    <div class="layui-card mt-10">

        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this">表单信息</li>
                <c:if test="${7 != userType && 6!= userType}">
                   <%-- <li>流程路径</li>--%>
                    <li>审批过程</li>
                </c:if>
            </ul>

            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-col-xs12 mb-15 pr-30">
                        <input name="id" value="${apply.columns.id}" hidden>
                        <label class="layui-form-label w-130"><i class="red">*</i>代理商名称：</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input layui-bg-gray" value="${apply.columns.traderName}" id="traderName" disabled>
                        </div>
                    </div>

                    <div class="layui-col-xs12 mb-10 pr-30">
                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130">请款金额：</label>
                            <div class="layui-input-block ">
                                <input type="text" class="layui-input layui-bg-gray" value="${apply.columns.out_cash}"  disabled>
                                <span class="pos-a h-32 lh-32 layui-span-unit">元</span>
                            </div>
                        </div>
                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130">请款账户：</label>
                            <div class="layui-input-block w-200" >
                                <input type="text" class="layui-input layui-bg-gray" value="${apply.columns.obj_type eq '0'?'待结算账户':'质保金账户'}" id="mobile" disabled>
                            </div>
                        </div>
                    </div>

                    <c:if test="${apply.columns.obj_type eq '0'}">
                        <div class="layui-col-xs12 mb-10 pr-30">
                            <div class="layui-inline layui-col-xs6">
                                <label class="layui-form-label w-130">保证金扣除：</label>
                                <div class="layui-input-block ">
                                    <input type="text" class="layui-input layui-bg-gray" name="offsetBondAmount" value="${apply.columns.offset_bond_amount}"  disabled>
                                    <span class="pos-a h-32 lh-32 layui-span-unit">元</span>
                                </div>
                            </div>
                            <div class="layui-inline layui-col-xs6">
                                <label class="layui-form-label w-130">实付金额：</label>
                                <div class="layui-input-block w-200" >
                                    <input type="text" class="layui-input" name="outCash layui-bg-gray"  name="payAmount" disabled  readonly value="${apply.columns.pay_amount}">
                                    <span class="pos-a h-32 lh-32 layui-span-unit">元</span>
                                </div>
                            </div>
                        </div>
                    </c:if>

                    <div class="layui-col-xs12 mb-10 pr-30">
                        <label class="layui-form-label w-130">公司名称：</label>
                        <div class="layui-input-block">
                            <input type="text"  class="layui-input layui-bg-gray" value="${apply.columns.company_name}" disabled>
                        </div>
                    </div>
                    <div class="layui-col-xs12 mb-10 pr-30">
                        <label class="layui-form-label w-130">开户银行：</label>
                        <div class="layui-input-block">
                            <input type="text"  class="layui-input layui-bg-gray" value="${apply.columns.bank}" disabled>
                        </div>
                    </div>

                    <div class="layui-col-xs12 mb-10 pr-30">
                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130">银行账号：</label>
                            <div class="layui-input-block ">
                                <input type="text"  class="layui-input layui-bg-gray" value="${apply.columns.bank_code}" disabled>
                            </div>
                        </div>
                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130">申请时间：</label>
                            <div class="layui-input-block w-200" >
                                <input type="text" class="layui-input layui-bg-gray"  disabled lay-verify="required" value="${apply.columns.createTime}">
                            </div>
                        </div>
                    </div>
                    <%--<div class="layui-col-xs12 mb-15 pr-30 mt-10">
                        <label class="layui-form-label w-130">备注说明：</label>
                        <div class="layui-input-block">
                            <textarea name="remarks" id="remarks" class="layui-textarea" lay-verify="required">${apply.columns.remarks}</textarea>
                        </div>
                    </div>
--%>
                    <div class="layui-col-xs12 layui-form-item">
                        <label class="layui-form-label"> <%--<c:if test="${from eq 'audit'}"><i class="red">*</i></c:if>--%>发票：</label>
                        <div class="layui-input-block">
                            <div id="imgsDiv">
                                <c:forEach items="${imglist}" var="img">
                                    <div class="bj-img imgSpan">
                                       <%-- <c:if test="${from eq 'audit'}"><span class="layui-icon-close layui-icon" onclick="delImg(this)"></span></c:if>--%>
                                        <img src="${commonStaticImgPath.concat(img)}" data-img="${commonStaticImgPath.concat(img)}"  height="700" width="1200"/>
                                        <input type="hidden" class="imgPicker" value="${img}"/>
                                    </div>
                                </c:forEach>
                            </div>
                         <%--   <c:if test="${from eq 'audit'}">
                                <div class="upload-container" id="uploader">
                                    <img src="" alt="img placeholder" id="imgsAdd">
                                </div>
                            </c:if>--%>
                        </div>
                    </div>
                 <%--   <c:if test="${from eq 'audit'}">
                        &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;(最多上传3张图片)
                    </c:if>--%>


                    <%--<div class="layui-col-xs12 mb-15 pr-30 mt-10">
                        <label class="layui-form-label w-130">备注：</label>
                        <div class="layui-input-block">
                            <c:choose>
                                <c:when test="${from eq 'audit'}">
                                    <input type="text" name="auditRemarks" id="auditRemarks" autocomplete="off" placeholder="" class="layui-input" value="">
                                </c:when>
                                <c:otherwise>
                                    <input type="text" autocomplete="off" placeholder="" class="layui-input layui-bg-gray" disabled value="${apply.columns.examine_opinion}">
                                </c:otherwise>
                            </c:choose>
                        </div>
                    </div>--%>
                    <c:if test="${from eq 'audit'}">
                        <div class="layui-col-xs12 mb-15 pr-30 mt-10">
                            <label class="layui-form-label w-130">备注：</label>
                            <div class="layui-input-block">
                                <input type="text" name="auditRemarks" id="auditRemarks" autocomplete="off" placeholder="" class="layui-input" value="">
                            </div>
                        </div>

                    </c:if>


                <div class="layui-col-xs12 mb-20 pr-30 pl-30">
                    <div style="max-width: 100%;overflow: auto;">
                        <table class="layui-table" style="width: 2000px">
                            <thead>
                            <tr>
                                <th style="width: 50px">序号</th>
                                <th style="width: 120px">电站编码</th>
                                <th style="width: 150px">代理商名称</th>
                                <th style="width: 200px">项目名称</th>
                                <th style="width: 120px">所属省区</th>
                                <th style="width: 120px">开发经理</th>
                                <th style="width: 150px">结算类型</th>
                                <th style="width: 150px">结算单价</th>
                                <th style="width: 120px">安装容量(W)</th>
                                <th style="width: 105px">结算金额</th>
                                <th style="width: 120px">屋顶类型</th>
                                <th style="width: 120px">设计方案</th>
                                <th style="width: 150px">方案名称</th>
                                <th style="width: 120px">业主姓名</th>
                                <th style="width: 120px">联系方式</th>
                                <th style="width: 120px">产品编码</th>
                                <th style="width: 130px">产品名称</th>
                                <th style="width: 120px">组件块数</th>
                                <th style="width: 220px">生成时间</th>
                                <th style="width: 120px">备注</th>
                            </tr>
                            </thead>
                            <tbody id="materialTable">
                            <c:forEach items="${settleDetails}" varStatus="vs" var="detail">
                                <tr data-id="${detail.columns.id}" class="entryTr" >
                                    <td>${vs.count}</td>
                                    <td>${detail.columns.power_station_code}</td>
                                    <td>${detail.columns.trader_name}</td>
                                    <td>
                                            ${detail.columns.province}${detail.columns.city}${detail.columns.entryName}<fmt:formatNumber type="number" value="${detail.columns.actual_capacity/1000}" maxFractionDigits="2"/>KW光伏电站
                                    </td>
                                    <td>${detail.columns.department_name}</td>
                                    <td>${detail.columns.creator}</td>
                                    <td>

                                        <c:if test="${detail.columns.settleType eq '0'}">预结算</c:if>
                                        <c:if test="${detail.columns.settleType eq '1'}">分包并网结算</c:if>
                                        <c:if test="${detail.columns.settleType eq '2'}">电站整改(减)</c:if>
                                        <c:if test="${detail.columns.settleType eq '3'}">质保金</c:if>

                                    </td>
                                    <td>${detail.columns.unit_price}</td>
                                    <td>${detail.columns.actual_capacity}</td>
                                    <td>${detail.columns.amount}</td>
                                    <td>${detail.columns.roof_type}</td>
                                    <td>${detail.columns.scheme_type eq '1' ? '标准方案' : '组合方案'}</td>
                                    <td>${detail.columns.scheme_name}</td>
                                    <td>${detail.columns.tenant_name}</td>
                                    <td>${detail.columns.mobile}</td>
                                    <td>${detail.columns.project_code}</td>
                                    <td>${detail.columns.project_name}</td>
                                    <td>${detail.columns.component_num}</td>
                                    <td>${detail.columns.createTime}</td>
                                    <td><div class="remarks fl" style="width: 120px" title="${detail.columns.remarks}">${detail.columns.remarks}</div></td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                    </div>
                </div>
                </div>
                <%--<div class="layui-tab-item licheng">
                    <ul class="layui-timeline" id="licheng">

                    </ul>
                </div>--%>

                <div class="layui-tab-item guocheng">
                    <ul class="layui-timeline">
                        <c:forEach items="${infos}" var="info">
                            <li class="layui-timeline-item">
                                <i class="layui-icon layui-timeline-axis"></i>
                                <div class="layui-timeline-content layui-text">
                                    <div class="layui-timeline-title"><fmt:formatDate value="${info.operateTime}" pattern="yyyy-MM-dd HH:mm:ss"/>&nbsp;&nbsp;&nbsp;${info.detail}</div>
                                </div>
                            </li>
                        </c:forEach>

                    </ul>
                </div>
            </div>

        </div>

        <%--<div  class="openDivBottom">
            <div class="layui-col-xs4">
                提交人：${apply.columns.create_name}
            </div>
            <div class="layui-col-xs4">
                所属部门：${apply.columns.department_name}
            </div>
            <div class="layui-col-xs4">
                申请时间：${apply.columns.createTime}
            </div>
        </div>--%>

        <input type="hidden" name="taskId" id="taskId" value="${apply.columns.task_id}">
        <input type="hidden" name="id" id="id" value="${apply.columns.id}">

        <input type="hidden" id="processInstanceId" value="${apply.columns.process_instance_id}">
        <input type="hidden" id="status" value="${apply.columns.status}">
        <div class="layui-col-xs12 mb-20 pr-30 mt-20">
        </div>
    </div>
    <input hidden id="imgs" value="${apply.columns.voucher}">
    <div class="operate-footer">
        <c:if test="${from eq 'audit'}">
            <input type="button"  id="approve" class="layui-btn " value="同意">
            <input type="button"  id="back" class="layui-btn " value="驳回">
        </c:if>
        <input type="button"   value="取消" class="layui-btn layui-btn-primary " onclick="closeDiv();" >
    </div>
</div>


<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/dist/viewer.js"></script>
<script type="text/javascript">
    //图片查看效果
    var viewer = new Viewer(document.getElementById('LAY_app'));
    //初始数据
    var $form;
    var form;
    var upload;
    var $;
    var myreg=/^[1][3,4,5,6,7,8,9][0-9]{9}$/;
    var imgsCount=${imgsCount};
    layui.use(['form', 'table', 'upload', 'jquery','element'], function () {
        $ = layui.jquery;
        form = layui.form;
        upload = layui.upload;
        $form = $('form');
        var element = layui.element;

        /*if (imgsCount>=3) {
            $("#uploader").hide();
        }*/

        element.on('tab(docDemoTabBrief)', function (data) {
            console.log(data);
            $('.layui-tab-content').eq(data.index).removeClass('layui-hide').siblings('.layui-tab-content').addClass('layui-hide');
          /*  if(data.index==1){
                var len=$("#licheng li").length;
                console.log("leng"+len);
                if(len==0){
                    var processInstanceId=$("#processInstanceId").val();
                    var status=$("#status").val();
                    $.ajax({
                        type:"POST",
                        url:"${ctx}/set/process/getBpmnModel",
                        data:{
                            processInstanceId:processInstanceId,
                            status:status,
                        },
                        success:function(res){
                            if(res.code=="200"){
                                var str=res.data;
                                var ht='';
                                for(var i=0;i<str.length;i++){
                                    var taski = str[i];
                                    console.log(taski);
                                    ht+='<li class="layui-timeline-item">';
                                    ht+='<i class="layui-icon layui-timeline-axis">&#xe63f;</i>';
                                    ht+='<div class="layui-timeline-content layui-text">';
                                    if(taski.status=='3'){
                                        ht+='<h3 class="layui-timeline-title fontColor1">'+taski.taskName+'</h3>'
                                        ht+='<p class="fontColor1">'+taski.approveUserName+'</p>';
                                    }else{
                                        ht+='<h3 class="layui-timeline-title">'+taski.taskName+'</h3>'
                                        ht+='<p>'+taski.approveUserName+'</p>';
                                    }
                                    ht+='</div>'
                                    ht+='</li>';
                                }

                                $("#licheng").html(ht);
                            }
                        },
                    }) ;
                }
            }*/

        });

        //通过
        var fg=false;
        $("#approve").click(function (){
            if(fg){
                return ;
            }
            var index= layer.load(2, {shade: [0.5,'#fff'], content:''});

            $("#approve").attr("disabled","true");
            var id=$("#id").val();
            var taskId=$("#taskId").val();
            var content=$("#auditRemarks").val();
            var voucher=$("#imgs").val();
           /* if(isBlank(voucher)){
                layer.msg("支付凭证不能为空！",{icon:"2"});
                return ;
            }*/
            fg=true;

            $.ajax({
                type:"POST",
                url:"${ctx}/apply/outCash/examineCashOutApplyApprove",
                data:{
                    id:id,
                    taskId:taskId,
                    content:content,
                    voucher:voucher
                },
                success:function(res){
                    console.log(res+'----');
                    if(res.code=="200"){
                        parent.layer.msg("审核成功",{time:2000});
                        closeDiv();
                        parent.table.reload('test');
                    } else{
                        layer.msg(res.errMsg,{time:2000});
                        $("#approve").removeAttr("disabled");
                        fg=false;
                    }
                },
                complete: function () {
                    layer.close(index);
                },
                error:function (data) {
                }
            }) ;
        })

        //驳回
        $("#back").click(function (){
            var id=$("#id").val();
            var taskId=$("#taskId").val();
            var content=$("#auditRemarks").val();
            if(isBlank(content)){
                layer.msg("请输入备注！",{icon:"2"});
                return ;
            }
            $("#back").attr("disabled","true");
            $.ajax({
                type:"POST",
                url:"${ctx}/apply/outCash/rejectCashOutApplyTask",
                data:{
                    id:id,
                    taskId:taskId,
                    content:content
                },
                success:function(res){
                    console.log(res+'++++++');
                    if(res.code=="200"){
                        parent.layer.msg("驳回成功",{time:2000});
                        closeDiv();
                        parent.table.reload('test');
                    } else{
                        layer.msg(res.errMsg,{time:2000});
                        $("#back").removeAttr("disabled");
                    }
                },
                error:function (data) {
                }
            }) ;
        })

        var uploadInst = upload.render({
            elem: '#uploader' //绑定元素
            , url: '${ctx}/common/uploadFile' //上传接口
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {

                });
            }
            , done: function (res) {
                /* imgs+=res.path+',';
                 $("#imgs").val(imgs);*/
                //上传完毕回调
                addImg(res.path);
            }
            , error: function () {
                //请求异常回调
            }
        });


    })

    function  closeDiv() {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index);
    }

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

    function addImg(data){
        imgs = '';
        imgsCount++;
        if (imgsCount >= 3) {
            $("#uploader").hide();
        }else{
            $("#uploader").show();
        }
        var html = '<div class="bj-img imgSpan"><span class="layui-icon-close layui-icon" onclick="delImg(this)"></span>';
        html += '<img src="${commonStaticImgPath}'+data+'" height="700" width="1200"/>';
        html += '<input type="hidden" class="imgPicker" value="'+data+'"/> </div>';
        $("#imgsDiv").append(html);
        var imgSelector = $(".imgPicker");
        imgSelector.each(function (index) {
            var img = $(this).val();
            if (!isBlank(img)) {
                imgs += img + ",";
            }
        });
        console.log(imgs);
        $("#imgs").val(imgs);
    }

    function delImg(that){
        imgsCount--;
        if (imgsCount < 3) {
            $("#uploader").show();
        }
        $(that).parent().remove();
        var imgSelector = $(".imgPicker");
        imgSelector.each(function (index) {
            var img = $(this).val();
            if (!isBlank(img)) {
                imgs += img + ",";
            }
        });
        $("#imgs").val(imgs);
    }

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




