<%@ 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" 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">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/dist/viewer.css" media="all">
    <style>
        .layui-form-select dl{
            /* max-height:200px;*/
            width: 80%;
        }
        html{ background: #FFF}

        .layui-input-block {
            margin-left: 132px;
        }

        .layui-form-label {
            width: 132px;
        }
        .title1 {
            border-left: 4px solid #1b6073;
            padding-left: 20px;
            font-size: 14px;
            margin: 10px auto;
            font-weight: 600;
            height: 34px;
            line-height: 34px;
            background-color: #f4f6f9;
            color: #666666;
        }
        .clearfix{*zoom:1;}
        .clearfix:before,.clearfix:after{display:table; line-height:0; content:"";}
        .clearfix:after{clear:both;}

        .operate-footer{
            z-index: 1;
        }
    </style>
</head>
<body>
<div class="aaa">
    <div class="layui-form " id="detailSet">
        <div class="layui-card-body  pt-20 h-350" action="" id="LAY_app">

             <form class="clearfix" id="form4">
                 <h1 class="title1">设备清单</h1>

                 <div class="layui-col-xs12 mb-5 pr-30">
                     <div class="layui-inline layui-col-xs4">
                         <label class="layui-form-label"><i class="red">*</i>资产识别号：</label>
                         <div class="layui-input-block">
                             <input type="text"  name="equipNum"  lay-verify="required"  class="layui-input layui-bg-gray" readonly value="${equipInfoNormal.equipNum}">
                         </div>
                     </div>


                         <div class="layui-inline layui-col-xs4">
                             <label class="layui-form-label"><i class="red">*</i>确定的租赁物价值：</label>
                             <div class="layui-input-block">
                                 <input type="text"  name="confirmValue" id="confirmValue"    lay-verify="required"  class="layui-input"
                                        value="${equipInfoNormal.confirmValue}" onkeyup="this.value=this.value.replace(/\D/g,'')">
                                 <span class="pos-a h-32 lh-32 layui-span-unit">元</span>
                             </div>
                         </div>
                     <div class="layui-inline layui-col-xs4">
                         <label class="layui-form-label"><i class="red">*</i>确认折旧：</label>
                         <div class="layui-input-block">
                             <input type="text"  name="accumulatedDepreciation"  lay-verify="required"  class="layui-input layui-bg-gray" readonly value="${equipInfoNormal.accumulatedDepreciation}" onkeyup="!/^(\d+\.?)?\d{0,2}$/.test(this.value)?(this.value=this.value.substring(0, this.value.length-1)): ''">
                             <span class="pos-a h-32 lh-32 layui-span-unit">元</span>
                         </div>
                     </div>
                 </div>
                 <div class="layui-col-xs12 mb-5 pr-30 jingyingzulin">
                     <div class="layui-inline layui-col-xs4 ">
                         <label class="layui-form-label"><i class="red">*</i>租赁物原值：</label>
                         <div class="layui-input-block">
                             <input type="text"  name="originalAssetValue" id="originalAssetValue"   lay-verify="required"  class="layui-input" value="${equipInfoNormal.originalAssetValue}" onkeyup="!/^(\d+\.?)?\d{0,2}$/.test(this.value)?(this.value=this.value.substring(0, this.value.length-1)): ''">
                             <span class="pos-a h-32 lh-32 layui-span-unit">元</span>
                         </div>
                     </div>
                     <div class="layui-inline layui-col-xs4">
                         <label class="layui-form-label"><i class="red">*</i>不含税原值：</label>
                         <div class="layui-input-block">
                             <input type="text"  name="netOriginalAssetValue" id="netOriginalAssetValue"  lay-verify="required"   class="layui-input " value="${equipInfoNormal.netOriginalAssetValue}" onkeyup="!/^(\d+\.?)?\d{0,2}$/.test(this.value)?(this.value=this.value.substring(0, this.value.length-1)): ''">
                             <span class="pos-a h-32 lh-32 layui-span-unit">元</span>
                         </div>
                     </div>
                     <div class="layui-inline layui-col-xs4">
                         <label class="layui-form-label"><i class="red">*</i>初始确认物净值：</label>
                         <div class="layui-input-block">
                             <input type="text"  name="netAssetValue" id="netAssetValue"  lay-verify="required"  class="layui-input "  value="${equipInfoNormal.netAssetValue}" onkeyup="!/^(\d+\.?)?\d{0,2}$/.test(this.value)?(this.value=this.value.substring(0, this.value.length-1)): ''">
                             <span class="pos-a h-32 lh-32 layui-span-unit">元</span>
                         </div>
                     </div>

                 </div>


                 <div class="layui-col-xs12 mb-5 pr-30">


                     <div class="layui-inline layui-col-xs4">
                         <label class="layui-form-label"><i class="red">*</i>发票号：</label>
                         <div class="layui-input-block">
                             <input type="text"  name="invoiceNum"  class="layui-input layui-bg-gray" readonly value="${equipInfoNormal.invoiceNum}">
                         </div>
                     </div>
                     <div class="layui-inline layui-col-xs4">
                         <label class="layui-form-label"><i class="red">*</i>通信模块S/N编码：</label>
                         <div class="layui-input-block">
                             <input type="text"  name="communicationCode"  lay-verify="required"  class="layui-input layui-bg-gray" readonly value="${equipInfoNormal.communicationCode}">
                         </div>
                     </div>
                     <div class="layui-inline layui-col-xs4">
                         <label class="layui-form-label"><i class="red">*</i>确认净值日期：</label>
                         <div class="layui-input-block">
                             <input   name="confirmNetValueDate" id="confirmNetValueDate" lay-verify="required" disabled class="layui-input layui-bg-gray" placeholder="年-月-日" value="${equipInfoNormal.confirmNetValueDate}">
                         </div>
                     </div>

                 </div>

                 <div class="layui-col-xs12 mb-5 pr-30">

                     <div class="layui-inline layui-col-xs4">
                         <label class="layui-form-label"><i class="red">*</i>建造完工日期：</label>
                         <div class="layui-input-block" >
                             <input   name="purchasedate" id="purchasedate" lay-verify="required"  class="layui-input layui-bg-gray" disabled placeholder="年-月-日" value="${equipInfoNormal.purchasedate}">
                         </div>
                     </div>
                     <div class="layui-inline layui-col-xs4">
                         <label class="layui-form-label"><i class="red">*</i>入账日期：</label>
                         <div class="layui-input-block" >
                             <input   name="entryDate"  id="entryDate" lay-verify="required"  class="layui-input layui-bg-gray" disabled placeholder="年-月-日" value="${equipInfoNormal.entryDate}">
                         </div>
                     </div>
                     <div class="layui-inline layui-col-xs4">
                         <label class="layui-form-label"><i class="red">*</i>发电户号：</label>
                         <div class="layui-input-block">
                             <input type="text"  name="generatorNo"  lay-verify="required"  class="layui-input layui-bg-gray"readonly value="${equipInfoNormal.generatorNo}">
                         </div>
                     </div>
                 </div>

                 <div class="layui-col-xs12 mb-5 pr-30">
                     <div class="layui-inline layui-col-xs3">
                         <label class="layui-form-label"><i class="red">*</i>租赁物保险单：</label>
                         <div class="layui-input-block" style="display:flex;">
                             <div id="imgsDiv1">
                                 <c:if test="${not empty equipInfoNormal.policyImg}">
                                     <div class="bj-img imgSpan">
                                         <img src="${commonStaticImgPath}${equipInfoNormal.policyImg}" height="700" width="1200"/>
                                         <input type="hidden" class="roof_photo_one" name="policyImg" value="${equipInfoNormal.policyImg}"/>
                                     </div>
                                 </c:if>
                             </div>

                         </div>
                     </div>
                     <div class="layui-inline layui-col-xs4">
                         <label class="layui-form-label" style="width: 148px"><i class="red">*</i>全额增值税专用发票：</label>
                         <div class="layui-input-block" style="display:flex; width: 148px">
                             <div id="imgsDiv2">
                                 <c:if test="${not empty equipInfoNormal.invoiceImg}">
                                     <div class="bj-img imgSpan">
                                         <img src="${commonStaticImgPath}${equipInfoNormal.invoiceImg}" height="700" width="1200"/>
                                         <input type="hidden" class="roof_photo_one" name="invoiceImg" value="${equipInfoNormal.invoiceImg}"/>
                                     </div>
                                 </c:if>
                             </div>


                         </div>
                     </div>
                     <div class="layui-inline layui-col-xs5">
                         <label class="layui-form-label"><i class="red">*</i>购售电合同：</label>
                         <div class="layui-input-block">

                             <a style="display: block ;color:#D9B589;cursor:pointer;" id="contractImgPath" target="_blank"
                                         href="${commonStaticImgPath}${equipInfoNormal.contractImg}" >
                                 <c:if test="${not empty equipInfoNormal.contractImg}">
                                     ${fn:substring(equipInfoNormal.contractImg,equipInfoNormal.contractImg.lastIndexOf("/")+1,-1)}
                                 </c:if>

                             </a>
                                <input type="hidden" id="contractImg" name="contractImg" value="${equipInfoNormal.contractImg}"/>
                         </div>
                     </div>

                 </div>

             </form>
        </div>
        <div style="height: 70px;"></div>
        <div class="layui-form-item operate-footer" style="text-align: center;">
            <input type="button" lay-submit lay-filter="confirm" id="confirm" class="layui-btn " value="同意">
            <input type="button" lay-filter="temp" id="temp" class="layui-btn" value="驳回">
            <input type="button"   value="取消" class="layui-btn layui-btn-primary " lay onclick="closeDiv();" >
        </div>
    </div>
</div>
<div class="hide pd-10" id="ideaDiv">
    <p class="f-l"><span class="red">*</span>驳回意见：</p>
    <textarea id="idea" class="idea-text f-l" style="width: 320px; height: 90px;"></textarea>
</div>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/dist/viewer.js"></script>
<script>
    var entryId='${entryId}';
    var viewer = new Viewer(document.getElementById('LAY_app'));
    var idCordReq = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
    //初始数据
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['form', 'table', 'upload', 'jquery','laydate','upload'], function () {
        $ = layui.$
            ,form = layui.form
            ,laydate = layui.laydate;
        var  upload = layui.upload;



          laydate.render({
              elem: '#confirmNetValueDate'
              ,trigger: 'click'
              ,format:"yyyy-MM-dd"
          });

         laydate.render({
             elem: '#purchasedate'
             ,trigger: 'click'
             ,format:"yyyy-MM-dd"
         });
          laydate.render({
              elem: '#entryDate'
              ,trigger: 'click'
              ,format:"yyyy-MM-dd"
          });

        form.verify({

            telephone:function(value,item){
                if(!$.trim(value)){
                    return "手机号码不能为空,请输入手机号码后保存！";
                }
                if(!myreg.test($.trim(value))){
                    return "请输入正确的手机号码后保存！";
                }
            },

            idCord:function(value,item){
                if(!isBlank(value) &&　! idCordReq.test($.trim(value))){
                    return "身份证号码格式不正确";
                }
            }

        });
        $("#temp").click(function(){

            layer.open({
                type:1,
                title:'驳回原因',
                area:['450px','200px'],
                content:$("#ideaDiv"),
                btn: ['确认', '取消'],
                btnAlign: 'c',
                yes: function(){
                    var idea = $('#idea').val();
                    if(isBlank(idea)){
                        layer.msg('请输入驳回意见', {icon: 2});
                        return;
                    }
                    $.ajax({
                        type: 'post',
                        url: '${ctx}/customerEntryExtra/examineNotApplication',
                        dataType: 'json',
                        data: {
                            entryId:'${entryId}'
                            ,result:2
                            ,failReason:idea
                        },
                        success:function(res){
                            console.log(res);
                            if(res.code=="200"){
                                parent.layer.msg("操作成功",{time:1000});
                                closeDiv();
                                parent.table.reload('test');
                            }else{
                                layer.msg(res.errMsg,{time:1000},function(){

                                });
                            }
                        }
                    });
                }
            })

        })

        var saveFlag=false;
        form.on('submit(confirm)', function(data){
            if(saveFlag){
                return false;
            }
            var netOriginalAssetValue =$("#netOriginalAssetValue").val();
            var netAssetValue =$("#netAssetValue").val();
            var originalAssetValue =$("#originalAssetValue").val();
            saveFlag=true;
            $.ajax({
                url:'${ctx}/customerEntryExtra/examineNotApplication',
                method:'get',
                data:{
                    entryId:'${entryId}'
                    ,result:1,
                    netOriginalAssetValue:netOriginalAssetValue,
                    netAssetValue:netAssetValue,
                    originalAssetValue:originalAssetValue
                },
                success:function(res){
                    console.log(res);
                    if(res.code=="200"){
                        parent.layer.msg("操作成功",{time:1000});
                        closeDiv();
                        parent.table.reload('test');
                    }else{
                        layer.msg(res.errMsg,{time:1000},function(){
                            saveFlag=false;
                        });
                    }
                }
            }) ;
        });

    })

    function updateFileEntry(id) {
        $.ajax({
            type: 'post',
            url: '${ctx}/customerEntry/uploadTwoAttachment',
            data: {
                id: id,
                type:'2'
            },
            success: function(data){
                console.log(data)
            }
        });
    }

    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 delImg(that,id){
        $("#"+id).show();
        $(that).parent().remove();
    }


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

