<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('证照打印')" />
    <th:block th:include="include :: datetimepicker-css" />
    <style>
        #img img{
            width: 150px;
            height: 150px;
        }
        .form-control {
            border-top-right-radius: 10px;
            border-top-left-radius: 10px;
            border-bottom-right-radius: 10px;
            border-bottom-left-radius: 10px;
        }
        .form-group:after {
            content: '';
            height: 0;
            display: block;
            clear: both;
        }
        .form-group:before {
            content: '';
            height: 0;
            display: block;
            clear: both;
        }
    </style>
</head>
<body class="white-bg">

<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form id="info">
        <input type="hidden" name="bsid"/>
        <input type="hidden" name="appno"/>
        <div class="col-md-12">
            <div class="form-group ">
                <label class="col-sm-3 control-label">经营者：</label>
                <div class="col-sm-9">
                    <input type="text" name="jingyingren" class="form-control" placeholder="请输入文本" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">身份证号：</label>
                <div class="col-sm-9">
                    <input type="text" name="jingyingcard" class="form-control" placeholder="请输入文本" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">名 称：</label>
                <div class="col-sm-9">
                    <input type="text" name="zwzh" class="form-control" placeholder="请输入文本" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">统一社会信用代码：</label>
                <div class="col-sm-9">
                    <input type="text" name="xinyongcode" id="xinyongcode" class="form-control" placeholder="请输入文本" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3  font-noraml">注册日期</label>
                <div class="input-group date col-sm-8">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input type="text"  name="zhucetime"  class="form-control" id="laydate-demo-2" placeholder="yyyy-MM-dd" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3  font-noraml">审核日期</label>
                <div class="input-group date col-sm-8">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input type="text"  name="shenhedate"  class="form-control" id="laydate-demo-3" placeholder="yyyy-MM-dd" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">组成形式：</label>
                <div class="col-sm-9">
                    <input type="text" name="zuchengxingshi" class="form-control" placeholder="请输入文本" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">经营场所：</label>
                <div class="col-sm-9">
                    <input type="text" name="jingyingchangsuo" class="form-control" placeholder="请输入文本" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">经营范围：</label>
                <div class="col-sm-9">
                    <input type="text" name="jingyingfanwei" class="form-control" placeholder="请输入文本" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">正本打印情况：</label>
                <div class="col-sm-9">
                    <select class="form-control" name="isprint">
                        <option value="0">未打印</option>
                        <option value="1">已打印</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">副本打印情况：</label>
                <div class="col-sm-9">
                    <select class="form-control" name="isprintF">
                        <option value="0">未打印</option>
                        <option value="1">已打印</option>
                    </select>
                </div>
            </div>
            <input hidden="hidden" name="erweimabase64" id="erweimabase64" value="">
            <div class="form-group" id="img" style="text-align: center">
            </div>
            <div class="form-group" style="text-align: center">

                <button type=button class="btn btn-info" id="updataBtn">保存</button>
            </div>

        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">

    var prefix = ctx + "system/cprint";

    var uuid = [[${bsid}]];
    var url=window.location.href.split("/");

    $("#form-pritn-add").validate({
        focusCleanup: true
    });
    <!-- laydate示例 -->
    layui.use('laydate', function() {
        var laydate = layui.laydate;

        laydate.render({
            elem: '#laydate-demo-2',
            type: 'date'
        });
        laydate.render({
            elem: '#laydate-demo-3',
            type: 'date'
        });
    });
    function getMyDate(str){
        var oDate = new Date(str),
            oYear = oDate.getFullYear(),
            oMonth = oDate.getMonth()+1,
            oDay = oDate.getDate(),
            oHour = oDate.getHours(),
            oMin = oDate.getMinutes(),
            oSen = oDate.getSeconds(),
            oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay)  //最后拼接时间
        return oTime;
    };
    //补0操作
    function getzf(num){
        if(parseInt(num) < 10){
            num = '0'+num;
        }
        return num;
    }
    if(url[url.length-1]!="addinfo"){
        $.modal.loading("正在加载数据，请稍后...");
        $.ajax(
            {
                url:prefix+"/requestInfo",
                data: {uuid:uuid},
                type:"post",
                dataType: "json",
                success:function(msg){
                    var data = JSON.parse(msg.msg);
                    console.log(data);
                    var date = new Date(data.zhucetime);
                    var year = date.getFullYear();//年
                    var month = (date.getMonth()+1);//月
                    var day = date.getDate();//日
                    $("[name=jingyingren]").val(data.jingyingren);
                    $("[name=xinyongcode]").val(data.xinyongcode);
                    $("[name=zwzh]").val(data.zwzh);
                    $("[name=zhucetime]").val(year+"-"+month+"-"+day);
                    $("[name=zuchengxingshi]").val(data.zuchengxingshi);
                    $("[name=jingyingchangsuo]").val(data.jingyingchangsuo);
                    $("[name=jingyingfanwei]").val(data.jingyingfanwei);
                    $("[name=bsid]").val(data.bsid);
                    $("[name=appno]").val(data.appno);
                    $("[name=jingyingcard]").val(data.jingyingcard);
                    $("[name=erweimabase64]").val(data.erweimabase64);
                    var img = new Image();
                    img.src = "data:image/png;base64,"+data.erweimabase64;
                    $("#img").append(img);
                    if(data.isprint == 0){
                        $('[name=isprint]').children().removeAttr("selected").eq(0).attr("selected","selected");
                    }else{
                        $('[name=isprint]').children().removeAttr("selected").eq(1).attr("selected","selected");
                    }
                    if(data.isprintF == 0){
                        $('[name=isprintF]').children().removeAttr("selected").eq(0).attr("selected","selected");
                    }else{
                        $('[name=isprintF]').children().removeAttr("selected").eq(1).attr("selected","selected");
                    }
                    $("[name=shenhedate]").val(getMyDate(data.shenhedate))
                    $.modal.closeLoading();
                },
                error: function (msg) {
                    $.modal.closeLoading();
                }
            }
        )
    }
    $("#xinyongcode").change(function () {
        $.get(prefix + "/getEwmImg", {"xinyongcode":$("#xinyongcode").val()}, function (msg) {

            if($.common.isEmpty(msg)||msg==undefined){
                return false;
            }else {
            $("#img").html("");
            var img = new Image();
            img.src = "data:image/png;base64,"+msg;
            $("#img").append(img);
            $("#erweimabase64").val(msg)
            }
        })
    })
    if(url[url.length-1]!="addinfo") {
        $("#updataBtn").click(function () {
            if($.validate.form()){
                $.operate.post(prefix + "/updata", $("#info").serialize(), function (msg) {
                    console.log(msg);
                })
            }

        })
    }else {
        $("#updataBtn").click(function () {
            if($.validate.form()){
                $.operate.post(prefix + "/saveinfo", $("#info").serialize(), function (msg) {
                    console.log(msg);
                })
            }
        })
    }






</script>



</body>
</html>
