<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >

<head  >
    <th:block th:include="include :: header('企业基本信息')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<style>
    .form-control {
        border-top-right-radius: 10px;
        border-top-left-radius: 10px;
        border-bottom-right-radius: 10px;
        border-bottom-left-radius: 10px;
    }
</style>
<body class="white-bg" >
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-qymessage-edit" >
        <input readOnly="true" id="id" name="id" th:value="${info.id}" type="hidden" >
        <input readOnly="true" id="qylx"  th:value="${info.qylx}" type="hidden">
        <input readOnly="true" id="qyss"  th:value="${info.qyss}" type="hidden">
        <input readOnly="true" id="jycscq"  th:value="${info.jycscq}"type="hidden" >
        <input readOnly="true" id="jycsxz"  th:value="${info.jycsxz}" type="hidden">
        <input readOnly="true" id="qyjyqx1"  th:value="${info.qyjyqx}" type="hidden">

        <input readOnly="true" id="qyjyfw"  th:value="${info.qyjyfw}" type="hidden">
        <h4 class="form-header h4">企业信息</h4>
        <div class="form-group">
            <label class="col-sm-2 control-label">申请来源：</label>
            <div class="col-sm-4 ">
                <input name="laiyuan" class="form-control" type="text"  th:value="${info.laiyuan}" >
            </div>
            <label class="col-sm-2 control-label">企业名称：</label>
            <div class="col-sm-4">
                <input name="qyname" class="form-control" type="text"  th:value="${info.qyname}" >
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">预先核准书文号：</label>
            <div class="col-sm-4 ">
                <input name="qyhezhun" class="form-control" type="text" th:value="${info.qyhezhun}"  >
            </div>
            <label class="col-sm-2 control-label">企业类型：</label>
            <div class="col-sm-4">
                <input name="qylx" class="form-control" type="text"  th:value="${info.qylx}" >
                <!-- <select class="form-control" name="qylx" id="type">
                     <option th:value="1">请选择</option>
                     <option th:value="2">有限责任公司(自然人独资)</option>
                     <option th:value="3">有限责任公司(自然人独资或控股)</option>
                 </select>-->
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">城乡标记：</label>
            <div class="col-sm-4 ">
                <select class="form-control" name="qyss" id="c1">
                    <!--                    <option th:value="1">请选择</option>-->
                    <option th:value="1">城镇</option>
                    <option th:value="2">农村</option>
                </select>
            </div>


            <label class="col-sm-2 control-label">注册资金(万元)：</label>
            <div class="col-sm-4">
                <input name="qyzczj" class="form-control" type="text"  th:value="${info.qyzczj}" >
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">住所产权：</label>
            <div class="col-sm-4 ">
                <!--            <input name="tableName" class="form-control" type="text"  >-->
                <select class="form-control" name="jycscq" id="z1">
                    <!--                        <option th:value="1">请选择</option>-->
                    <option th:value="1">自有</option>
                    <option th:value="2">租赁</option>
                    <option th:value="3">无偿使用</option>
                    <option th:value="4">其他</option>
                </select>
            </div>

            <label class="col-sm-2 control-label">住所性质：</label>
            <div class="col-sm-4">
                <!--             <input name="tableName" class="form-control" type="text"  th:value="${info.qyzczj}" >-->
                <select class="form-control" name="jycsxz" id="s1">
                    <!--                    <option th:value="1">请选择</option>-->
                    <option th:value="1">住宅</option>
                    <option th:value="2">商用</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">从业人数：</label>
            <div class="col-sm-4 ">
                <input name="qycyrs" class="form-control" type="text" th:value="${info.qycyrs}" >
            </div>
            <label class="col-sm-2 control-label">是否军产：</label>
            <div class="col-sm-4">
                <input name="isjc" class="form-control" type="text"  th:value="${info.isjc}" >
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">正本打印：</label>
            <div class="col-sm-4 ">
                <select class="form-control" name="isprintZ"  >
                <option value="1"  th:selected="${info.isprintZ}==1">已打印</option>
                <option value="0"  th:selected="${info.isprintZ}==0">未打印</option>
            </select>
            </div>
            <label class="col-sm-2 control-label">副本打印：</label>
            <div class="col-sm-4 ">
                <select class="form-control" name="isprintF"  >
                    <option value="1"  th:selected="${info.isprintF}==1" >已打印</option>
                    <option value="0"  th:selected="${info.isprintF}==0">未打印</option>
                </select>
            </div>

        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">经营期限：</label>
            <div class="col-sm-4">
                <select class="form-control" name="qyjyqx" id="j1" >
                    <option th:value="1" >有效年</option>
                    <option th:value="2">有效期</option>
                    <option th:value="3">长期</option>
                </select>
            </div>
            <!--年-->
            <div id="nian" class="col-sm-1"style=" display: block;">
                <input  style="width: 75%;float: left;" id="qynx" name="qynx" class="form-control" type="text"
                        onkeyup="if(isNaN(value))execCommand('undo')" onafterpaste="if(isNaN(value))execCommand('undo')"
                        th:value="${info.qynx}==null?'':${info.qynx}">
                <span style="float: left;padding-top: 10px;padding-left: 3px;">年</span>

            </div>
            <!-- 开始时间-->
            <div id="kaishi" class="col-sm-2" style="    display: block; width: 25%; padding-right: 0;">
                <span style="float: left;padding: 9px 3px 0 0;">注册时间：</span>
                <input style="width: 60%; float: left;margin-left: 30px;" id="qyclrq"  name="qyclrq" type="text"
                       class="form-control required time-input" th:value="${info.qyclrq}==null?${date}:${Createdate}" onchange="onc(this)">
            </div>

            <div id="zhi" class="col-sm-2" style="display:none;display: block;padding-left: 0; padding-right: 0;">
                <span style="float: left;padding: 9px 9px 0 0;">至</span>
                <input  class="form-control required" style=" margin-right: 10px; width: 60%;float: left;" id="qyyyqz"  name="qyyyqz" type="text"
                       readonly="disabled "  >
            </div>


        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">住所：</label>
            <div class="col-sm-10">
                <input  name="qyjycs"  class="form-control" type="text" th:value="${info.qyjycs}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">行业分类：</label>
            <div class="col-sm-10">
                <div  onclick="selectTrade()">
                    <input class="form-control" name="hangye" autocomplete="off" id="treeName" type="text"  th:value="${info.hangye}">
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">经营范围<a onclick="AddJingYingFW()">补充</a>：</label>
            <div class="col-sm-10">
                <textarea class="form-control" id="jingyingfanwei" name="qyjyfw" rows="5"
                          style="resize:none" required th:text="${info.qyjyfw}"></textarea>
            </div>
        </div>
        <div th:if="${info.flg}==2" class="form-group">
            <label class="col-sm-2 control-label">统一社会信用代码：</label>
            <div class="col-sm-4">
                <input name="xinyongcode" class="form-control" type="text"  th:value="${info.xinyongcode}" >

            </div>
            <label class="col-sm-2 control-label">书文号：</label>
            <div class="col-sm-4">
                <input name="shuwenhao" class="form-control" type="text"  th:value="${info.shuwenhao}" >

            </div>
        </div>
        <div th:if="${info.flg}==2" class="form-group">
            <label class="col-sm-2 control-label">注册号：</label>
            <div class="col-sm-4">
                <input name="zhucehao" class="form-control" type="text"  th:value="${info.zhucehao}" >
            </div>
        </div>
        <div th:if="${info.flg}==3" class="form-group">
            <label class="col-sm-2 control-label">退回原因：</label>
            <div class="col-sm-10">
                <textarea class="form-control" id="return" name="return" rows="3"
                          style="resize:none" readonly >[[${info.shenhenote}]]</textarea>
            </div>
        </div>

    </form>


    <br><br>
    <div style="text-align:center">
        <button type="button"  th:onclick="submit()"class="btn btn-w-m btn-success">保存</button>
        <button type="button"  class="btn btn-w-m btn-primary"  th:if="${info.flg}==0" th:onclick="'javascript:setPass(\''+${info.id}+'\')'"> 审核通过</button>
        <button  type="button"  class="btn btn-w-m btn-primary" th:if="${info.flg}==1"th:onclick="'javascript:setPass(\''+${info.id}+'\')'" >审核通过</button>
        <button  type="button"  class="btn btn-w-m btn-success" th:if="${info.flg=='1'||info.flg=='0'}" th:onclick="'javascript:dataSync(\''+${info.id}+'\')'" >数据同步</button>
        <button type="button" class="btn btn-w-m btn-primary" th:if="${info.flg}==2" th:onclick="'kezhangsend(\''+${info.id}+'\')'">刻章推送</button>
        <button type="button" class="btn btn-w-m btn-danger" th:if="${info.flg}==1" th:onclick="'noaccept(\''+${info.id}+'\')'">不予受理</button>
        <button type="button" class="btn btn-w-m btn-danger" th:if="${info.flg}==0" th:onclick="'noaccept(\''+${info.id}+'\')'">不予受理</button>
    </div>
    <!-- <button  th:if="${info.flg}==0"class="btn btn-danger" th:onclick="'noaccept(\''+${info.id}+'\')'" style="width: 33%">  <i class="fa fa-edit"></i>不予受理</button>
     <button  th:if="${info.flg}==1"class="btn btn-danger" th:onclick="'noaccept(\''+${info.id}+'\')'" style="width: 33%">  <i class="fa fa-edit"></i>不予受理</button>-->

</div>
<div th:include="include :: footer"></div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:gtgsyw:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:gtgsyw:remove')}]];
    var auditFlag = [[${@permission.hasPermi('system:gtgsyw:audit')}]];
    var giveupFlag = [[${@permission.hasPermi('system:gtgsyw:giveup')}]];
    var prefx = ctx + "company/tenant";



</script>
<script type="text/javascript">
    var prefix = ctx + "company/tenant";

    //编辑保存
    function submit() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit",$('#form-qymessage-edit').serialize());
        }
    }
    // 不受理 退回
    function noaccept(id) {
        var url= prefix + "/sendback/"+id;
        $.modal.opentuihui("退回", url, '550', '500');

    }
    function kezhangsend(id) {
        //示范一个公告层
        layer.open({
            type: 1
            ,title: false //不显示标题栏
            ,closeBtn: false
            ,area: '650px;'
            ,shade: 0.8
            ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
            ,resize: false
            ,btn: ['确定', '取消']
            ,btnAlign: 'c'
            ,moveType: 0 //拖拽模式，0或者1
            ,content: ' <div class="form-group">\n' +
                '                            <label class="font-noraml">单选</label>\n' +
                '                            <select class="form-control" id="kezhang">\n' +
                '                            \t<option value="">--请选择刻章人员--</option>\n' +
                '                            \t<option value="kzsh01">kzsh01</option>\n' +
                '                            </select>\n' +
                '                        </div>'
            ,success: function(layero){

            },btn1:function () {
                var shenhename=$("#kezhang").val();
               var  formdata=new FormData();
                formdata.append("id",id);
                formdata.append("shenhename",shenhename)
                formdata.append("hangye",$("#treeName").val())
                $.ajax({
                    url: prefix + "/kezhang",
                    type: 'post',
                    data:formdata,
                    processData: false,        // 告诉jQuery不要去处理发送的数据
                    contentType: false,        // 告诉jQuery不要去设置Content-Type请求头
                    success: function (msg) {
                        $.modal.closeLoading();
                        if(msg.code==0){
                        $.modal.msgSuccess("推送成功!")
                        }
                    }
                })
            }
        });
    }
    function dataSync(id) {
        var url= prefix + "/qyDataSysc?id="+id;
        $.modal.confirm("确定将此数据同步到河北户籍系统？", function () {

            $.modal.loading("正在同步数据，请稍后...");
            $.ajax({
                url: url,
                post: 'get',
                success: function (msg) {
                    $.modal.closeLoading();
                    console.log(msg);
                    if(msg.code == 0){
                        $.modal.msgSuccess(msg.msg);
                    }else{
                        $.modal.msgError(msg.msg);
                    }

                },
                error: function (error) {
                    $.modal.closeLoading();
                    $.modal.msgError("数据同步失败");
                }
            });
        },200);
    }


    //通过
    function setPass(id) {
        auditpass(id);
	}
	function auditpass(id){
        var scope=$("#qyjyfw").val();
        if(!scope.endWith("（依法须经批准的项目，经相关部门批准后方可开展经营活动）")){
            alert("经营范围格式不对");
            return;
        }
        var url= prefix + "/pass/"+id;
        $.modal.opentongguo("通过", url, '550', '500');
    }

    $("#form-gtgsyw-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit",$('#form-gtgsyw-edit').serialize());
            $.modal.closeTab();
        }
    }
    String.prototype.endWith=function(endStr){
        var d=this.length-endStr.length;
        return (d>=0&&this.lastIndexOf(endStr)==d)
    };


    function selectTrade() {
        var url ="/system/gtgsyw/selectDept";
        var options = {
            title: '选择行业',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero) {
        var treeObj = layero.find("iframe")[0].contentWindow.$._tree,

            nodes = treeObj.getCheckedNodes(true),
            treeNames = [],
            treeIds = [];
        if(nodes.length==4){
            for (var i = 0; i < nodes.length; i++) {
                treeNames.push(nodes[i].name);
                treeIds.push(nodes[i].id);
            }
        }else{
            alert("选择行业格式不对");
            return;
        }


        $("#treeName").val(treeNames);
        layer.close(index);
    }

    function AddJingYingFW() {
        var jingying = $("#jingyingfanwei").val();
        $("#jingyingfanwei").val(jingying + "（依法须经批准的项目，经相关部门批准后方可开展经营活动）");
        $.operate.save(prefix + "/edit",$('#form-qymessage-edit').serialize());

    }


    onload = function() {
        /*企业类型*/
        /* var jycssy1=$("#qylx").val();
         document.getElementById("type").selectedIndex = jycssy1-1;*/
        /*城乡标记*/
        var jycssy2=$("#qyss").val();
        document.getElementById("c1").selectedIndex = jycssy2-1;
        /*住所产权*/
        var jycssy3=$("#jycscq").val();
        document.getElementById("z1").selectedIndex = jycssy3-1;
        /*住所性质*/
        var jycssy4=$("#jycsxz").val();
        document.getElementById("s1").selectedIndex = jycssy4-1;

        /*经营期限*/
        var jycssy5=$("#qyjyqx1").val();
        document.getElementById("j1").selectedIndex = jycssy5-1;
        //经营期限
        var j1=$("#j1").children('option:selected').val();
        if(j1==1){
            //显示
            $("#qyyyqz").addClass("time-input");
            $("#nian").css("display","block");
            $("#kaishi").css("display","block");
            $("#zhi").css("display","block");
            $("#qyyyqz").attr("readOnly",true);

        }else if(j1==2){
            $("#nian").css("display","none");
            $("#kaishi").css("display","block");
            $("#zhi").css("display","block");
            $("#qyyyqz").attr("readOnly",false);

        }else if(j1==3){
            $("#nian").css("display","none");
            $("#kaishi").css("display","none");
            $("#zhi").css("display","none");
        }


        var qynx = $("#qynx").val();
        var qyclrq = $("#qyclrq").val();
        var strs= [];
        strs=qyclrq.split("-");
        var year=Number(strs[0])+Number(qynx);
        var day=Number(strs[2])-Number(1);
        var cutOff="";
        if(day==0){
            var month=Number(strs[1])-Number(1);
            cutOff=year+"-"+month+"-"+30;
            document.getElementById('qyyyqz').value=cutOff
        }else{
            if(day<10){
                day="0"+day;
                cutOff=year+"-"+strs[1]+"-"+"0"+day;
                document.getElementById('qyyyqz').value=cutOff
            }
            cutOff=year+"-"+strs[1]+"-"+day;
            document.getElementById('qyyyqz').value=cutOff
        }
    };
    //经营期限change监听器
    $("#j1").change(function(){
        if($(this).children('option:selected').val()==1){
            //显示
            $("#qyyyqz").addClass("time-input");
            $("#nian").css("display","block");
            $("#kaishi").css("display","block");
            $("#zhi").css("display","block");

            $("#qyyyqz").attr("readOnly",true);

        }else if($(this).children('option:selected').val()==2){
            $("#qyyyqz").attr("class","form-control required time-input ");
            $("#nian").css("display","none");
            $("#kaishi").css("display","block");
            $("#zhi").css("display","block");
            $("#qyyyqz").attr("readOnly",false);

        }else if($(this).children('option:selected').val()==3){
            $("#nian").css("display","none");
            $("#kaishi").css("display","none");
            $("#zhi").css("display","none");
        }
    });

    //input年限 焦点事件
    $("#qynx").blur(function() {
        var qynx = $("#qynx").val();
        var qyclrq = $("#qyclrq").val();
        var strs= [];
        strs=qyclrq.split("-");
        var year=Number(strs[0])+Number(qynx);
        var day=Number(strs[2])-Number(1);
        var cutOff="";
        if(day==0){
            var month=Number(strs[1])-Number(1);
            cutOff=year+"-"+month+"-"+30;
            document.getElementById('qyyyqz').value=cutOff
        }else{
            if(day<10){
                day="0"+day;
                cutOff=year+"-"+strs[1]+"-"+"0"+day;
                document.getElementById('qyyyqz').value=cutOff
            }
            cutOff=year+"-"+strs[1]+"-"+day;
            document.getElementById('qyyyqz').value=cutOff
        }
    });


    //input注册时间 失去焦点事件
    //  $("#qyclq").change(function(){
    $("#qyclrq").blur(function() {

        var j1=$("#j1").children('option:selected').val();
        if(j1==1){
            var qynx = $("#qynx").val();
            if(qynx==""){
                alert("请填写年限");
                return;
            }
            var qyclrq = $("#qyclrq").val();
            var strs= [];
            strs=qyclrq.split("-");
            var year=Number(strs[0])+Number(qynx);
            var day=Number(strs[2])-Number(1);
            var cutOff="";
            if(day==0){
                var month=Number(strs[1])-Number(1);
                cutOff=year+"-"+month+"-"+30;
                document.getElementById('qyyyqz').value=cutOff
            }else{
                if(day<10){
                    day="0"+day;
                    cutOff=year+"-"+strs[1]+"-"+day;
                    document.getElementById('qyyyqz').value=cutOff
                }
                cutOff=year+"-"+strs[1]+"-"+day;
                document.getElementById('qyyyqz').value=cutOff
            }
        }

    });

    function onc(data){
        alert(data.value);
    }
</script>

</body>
</html>
