<!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-gtgsyw-edit" th:object="${gtgsyw}">
        <input readOnly="true" id="id" name="id" th:field="*{id}" type="hidden">
        <input readOnly="true" id="ztree" name="ztree" th:value="${ztree}" type="hidden">
        <input readOnly="true" id="jycssy"  th:value="${jycssy}" type="hidden" >



        <div class="form-group">
            <label class="col-sm-2 control-label">申请来源：</label>
            <div class="col-sm-4">
                <input name="shenqinglaiyuan" th:field="*{shenqinglaiyuan}" class="form-control" type="text">
            </div>
            <label class="col-sm-2 control-label">个体工商户名称：</label>
            <div class="col-sm-4">
                <input readOnly="true" id="personName" name="gtgsh" th:field=" *{codeName}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group personName">
            <label class="col-sm-2 control-label">行政区划-区：</label>
            <div class="col-sm-4">
                <input name="nsxzq" th:field="*{nsxzq}" class="form-control" type="text">
            </div>

            <label class="col-sm-2 control-label">字号：</label>
            <div class="radio-box" id="zwzh1">
                <input id="z1" type="radio" name="zwzh" th:value="*{zwzh1}" th:checked="*{zwzh1==zwzh}">
                <label value="2" th:for="zwzh" th:text="*{zwzh1}"></label>
            </div>
            <div class="radio-box"id="zwzh2">
                <input id="z2" type="radio" name="zwzh" th:value="*{zwzh2}" th:checked="*{zwzh2==zwzh}">
                <label value="2" th:for="zwzh" th:text="*{zwzh2}"></label>
            </div>
            <div class="radio-box"id="zwzh3">
                <input id="z3" type="radio" name="zwzh" th:value="*{zwzh3}" th:checked="*{zwzh3==zwzh}">
                <label value="3" th:for="zwzh" th:text="*{zwzh3}"></label>
            </div>
            <div class="radio-box">
                <input id="orther" type="text" th:value="*{zwzh}" style="border:none;border-bottom: #1a2226 1px;border-bottom-style: double;width: 60px"/>
                <input style="display: none" id="z4" type="radio" name="zwzh" th:value="*{zwzh}" th:checked="*{!((zwzh1 == zwzh)||(zwzh2 == zwzh)||(zwzh3 == zwzh))}"/>
                <label value="4" th:for="zwzh" ></label>
            </div>
        </div>


        <div class="form-group personName">
            <label class="col-sm-2 control-label">名称行业：</label>
            <div class="col-sm-4">
                <input name="mingchenghangye" th:field="*{mingchenghangye}" class="form-control" type="text">
            </div>

            <label class="col-sm-2 control-label">组织形式：</label>
            <div class="col-sm-4">
                <input name="zuzhixingshi" th:field="*{zuzhixingshi}" class="form-control" type="text">
            </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:field="*{hangye}">
                </div>
            </div>
        </div>

        <!--    <div class="form-group">
                <label class="col-sm-3 control-label">行业：</label>
                <div class="col-sm-8">
                    <input  name="hangye" th:field="*{hangye}" class="form-control" type="text">
                    <input  name="hangye1" th:field="*{hangye1}" class="form-control" type="text">
                    <input  name="hangye2" th:field="*{hangye2}" class="form-control" type="text">
                    <input  name="hangye3" th:field="*{hangye3}" class="form-control" type="text">
                </div>
            </div>-->

        <div class="form-group">
            <label class="col-sm-2 control-label">照片采集：</label>
            <div class="col-sm-4">
                <img  style=" height: 168px;width:164px; "  th:src="${gtgsyw.paizhao}" class="form-control" width="40px" height="50px">
            </div>
            <label th:if="${gtgsyw.shenqinglaiyuan}ne'微信小程序'" class="col-sm-2 control-label">身份证头像：</label>
            <div th:if="${gtgsyw.shenqinglaiyuan}ne'微信小程序'" class="col-sm-4">
                <img style=" height: 168px;width:164px; " th:src=" ${gtgsyw.jingyingcardtouxiang}" class="form-control" >
            </div>

        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">经营人身份证正面：</label>
            <div class="col-sm-4">
                <img  style=" height: 195px;width:315px; "  th:src="${gtgsyw.statusFront}" class="form-control" width="40px" height="50px">
            </div>
            <label class="col-sm-2 control-label">经营人身份证反面：</label>
            <div class="col-sm-4">
                <img  style=" height: 195px;width:315px; "  th:src="${gtgsyw.statusFan}" class="form-control" width="40px" height="50px">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">签名：</label>
            <div class="col-sm-4">
                <img  style=" height: 195px;width:315px; "  name="qianming" th:src="${gtgsyw.qianming}" class="form-control" width="40px" height="50px">
            </div>
            <label class="col-sm-2 control-label" th:if="${gtgsyw.type=='网店'}">网店证明：</label>
            <div class="col-sm-4"  th:if="${gtgsyw.type=='网店'}">
                <img  style=" height: 195px;width:315px; "  th:src="${typeSrc}" class="form-control" width="40px" height="50px">
            </div>
        </div>


        <div class="form-group" th:if="${gtgsyw.rzduibishenhe}==1 ">
            <label class="col-sm-2 control-label">营业执照领取人照片：</label>
            <div class="col-sm-4">
                <img  style=" height: 185px;width:255px; "  th:src="${gtgsyw.lqrpaizhao}" class="form-control" width="40px" height="50px">
            </div>
            <div th:if="${gtgsyw.rzduibishenhe}==1">
                <label class="col-sm-2 control-label">营业执照领取人签名：</label>
                <div class="col-sm-4">
                    <img  style=" height: 185px;width:255px; "  th:src="${gtgsyw.lqrqianming}" class="form-control" width="40px" height="50px">
                </div>
            </div>
        </div>




        <div class="form-group">
            <label class="col-sm-2 control-label">经营人：</label>
            <div class="col-sm-4">
                <input name="jingyingren" th:field="*{jingyingren}" class="form-control" type="text">
            </div>
            <label class="col-sm-2 control-label">身份证号：</label>
            <div class="col-sm-4">
                <input  id="JingYingCard" name="jingyingcard" th:field="*{jingyingcard}" class="form-control" type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">性别：</label>
            <div class="col-sm-4">
                <div class="radio-box">
                    <input type="radio" name="xingbie" value="1" th:checked="*{xingbie}==男">
                    <label  th:for="sex1" th:text="男"></label>
                </div>
                <div class="radio-box">
                    <input type="radio" name="xingbie" value="2" th:checked="*{xingbie}==女">
                    <label th:for="sex2" th:text="女"></label>
                </div>
            </div>

            <label class="col-sm-2 control-label">民族：</label>
            <div class="col-sm-4">
                <input name="minzhu" th:field="*{minzhu}" class="form-control" type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">家庭住址：</label>
            <div class="col-sm-4">
                <input  name="jiatingzhuzhi" th:field="*{jiatingzhuzhi}" class="form-control" type="text">
            </div>

            <label class="col-sm-2 control-label">政治面貌：</label>
            <div class="col-sm-4">
                <input  name="zzmm" th:field="*{zzmm}" class="form-control" type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">文化程度：</label>
            <div class="col-sm-4">
                <input  name="whcd" th:field="*{whcd}" class="form-control" type="text">
            </div>
            <label class="col-sm-2 control-label">职业状况：</label>
            <div class="col-sm-4">
                <input  name="zyzk" th:field="*{zyzk}" class="form-control" type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">是否军产：</label>
            <div class="col-sm-4">
                <input  name="isjc" th:field="*{junchan}" class="form-control" type="text">
            </div>

            <label class="col-sm-2 control-label">电话：</label>
            <div class="col-sm-4">
                <input  name="jingyingrenphone" th:field="*{jingyingrenphone}" class="form-control" type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">类 型：</label>
            <div class="col-sm-4">
                <input  name="congyerenshu" th:field="*{sczttype}" class="form-control" type="text">
            </div>

            <label class="col-sm-2 control-label">经营场所：</label>
            <div class="col-sm-4">
                <input  name="jingyingchangsuo" th:field="*{jingyingchangsuo}" class="form-control" type="text">
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-2 control-label">经营场所属于：</label>
            <div class="col-sm-4">
                <select class="form-control" name="jycssy" id="s1">
                    <option th:value="1">非住宅</option>
                    <option th:value="2">住宅</option>
                    <option th:value="3">军用</option>
                </select>
            </div>

            <label class="col-sm-2 control-label">组成形式：</label>
            <div class="col-sm-4">
                <input  name="zuchengxingshi" th:field="*{zuchengxingshi}" class="form-control" type="text">
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-2 control-label">注册资金(万元)：</label>
            <div class="col-sm-4">
                <input  name="zijinshue" th:field="*{zijinshue}" class="form-control" type="text">
            </div>

            <label class="col-sm-2 control-label">经营范围<a onclick="AddJingYingFW()">补充</a>：</label>
            <div class="col-sm-4">
                <textarea class="form-control" id="jingyingfanwei" name="jingyingfanwei" rows="3"
                          style="resize:none" required >[[*{jingyingfanwei}]]</textarea>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">正本打印：</label>
            <div class="col-sm-4 ">
                <select class="form-control" name="isprint"  >
                    <option value="1"  th:selected="*{isprint}==1">已打印</option>
                    <option value="0"  th:selected="*{isprint}==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="*{isprintF}==1">已打印</option>
                    <option value="0"  th:selected="*{isprintF}==0">未打印</option>
                </select>
            </div>

        </div>
        <div class="form-group"th:if="*{flg}==1"  >
            <label class="col-sm-2 control-label">统一社会信用代码：</label>
            <div class="col-sm-4 ">
                <input name="xinyongcode" th:field="*{xinyongcode}" class="form-control" type="text">
            </div><label class="col-sm-2 control-label">书文号：</label>
            <div class="col-sm-4 ">
                <input name="zhucehao1" th:field="*{zhucehao1}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group"th:if="*{flg}==1"  >
            <label  class="col-sm-2 control-label">注册号：</label>
            <div class="col-sm-4 ">
                <input name="zhucehao" th:field="*{zhucehao}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">从业人数：</label>
            <div class="col-sm-4">
                <input name="congyerenshu" th:field="*{congyerenshu}" class="form-control" type="text">
            </div>

            <label class="col-sm-2 control-label">申请时间：</label>
            <div class="col-sm-4">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input readOnly="true" name="shenqingdate" th:value="${#dates.format(gtgsyw.shenqingdate, 'yyyy-MM-dd HH:mm:ss')}" class="form-control" placeholder="yyyy-MM-dd HH:mm:ss" type="text" >
                </div>
            </div>
        </div>

        <div th:if="${gtgsyw.flg}==2" 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 >[[${gtgsyw.shenhenote}]]</textarea>
            </div>
        </div>

    </form>
    <br><br>
    <div style="text-align:center">
        <button type="button"  th:onclick="submitHandler()"class="btn btn-w-m btn-success">保存</button>
        <button th:if="${gtgsyw.flg}==0" id="btn-pass" class="btn btn-w-m btn-primary" th:onclick="'javascript:setPass(\''+${gtgsyw.id}+'\')'" >  审核通过</button>
        <button th:if="${gtgsyw.flg}==3" id="btn-pass" class="btn btn-w-m btn-primary" th:onclick="'javascript:setPass(\''+${gtgsyw.id}+'\')'" >  审核通过</button>
       <!-- <button th:if="${gtgsyw.flg!=1&&gtgsyw.flg!=2}" id="btn-pass" class="btn btn-w-m btn-success " th:onclick="writeFile()" >  </i>数据同步</button>-->
        <button th:if="${gtgsyw.flg!=1&&gtgsyw.flg!=2}"  id="btn-gtsysc" class="btn btn-w-m btn-success " th:onclick="gtDateSysc()" >  </i>数据同步</button>
        <button th:if="${gtgsyw.flg}==0" id="btn-pass" class="btn btn-w-m btn-danger" th:onclick="'enable(\''+${gtgsyw.id}+'\')'" >  不予受理</button>
        <button th:if="${gtgsyw.flg}==3" id="btn-pass" class="btn btn-w-m btn-danger" th:onclick="'enable(\''+${gtgsyw.id}+'\')'" >  不予受理</button>
    </div>
</div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script type="text/javascript">

	var prefix = ctx + "system/gtgsyw";
	$("#form-gtgsyw-edit").validate({
		focusCleanup: true
	});

	function submitHandler() {
		if ($.validate.form()) {
			$.operate.post(prefix + "/edit",$('#form-gtgsyw-edit').serialize());
		}
	}


	onload = function() {
		var jycssy=$("#jycssy").val();
		document.getElementById("s1").selectedIndex = jycssy-1;
		var a= $("#dqflg").val();
		if( $("#dqflg").val()==0){
			if($("#shenheid").val !=$("#shenheren").val){
				alert("已有人审核");
				$.modal.close();
			}
		}

	}

</script>
<script type="text/javascript">
	var prefix = ctx + "system/gtgsyw";


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

	String.prototype.endWith=function(endStr){
		var d=this.length-endStr.length;
		return (d>=0&&this.lastIndexOf(endStr)==d)
	};


	function enable(id) {
		sendback(id);
	}
	function sendback(id) {
		var url= prefix + "/sendback/"+id;
		$.modal.opentuihui("退回", url, '550', '500');
		/*   $.modal.openTab("退回", url)*/
	}
	var tree="";
	function selectTraed() {
		var list=$("#ztree").val();
		tree =listToTree(list,0);//调用函数，传入要转换的list数组，和树中顶级元素的pid
		alert("tree:"+tree);
	}

	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();
		if('[[${gtgsyw.type}]]'=="网店"){
         $("#jingyingfanwei").val(jingying + "（仅限于通过互联网从事经营活动）");
        }else {
		$("#jingyingfanwei").val(jingying + "（依法须经批准的项目，经相关部门批准后方可开展经营活动）");
        }
		$.operate.post(prefix + "/edit",$('#form-gtgsyw-edit').serialize(),$.modal.loading());
	}

    function gtDateSysc() {
        $.modal.confirm("确定将此数据同步到河北户籍系统？", function () {

        $.modal.loading("正在同步数据，请稍后...");
        $.ajax({
            url: "/system/gtgsyw/gtDateSysc",
            data: {
                id: [[${gtgsyw.id}]]
            },
            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 writeFile() {
		$.modal.confirm("确定将此数据同步到河北户籍系统？", function () {
			$.modal.loading("正在同步数据，请稍后...");
			$.ajax({
				url: "/system/gtgsyw/filetxt",
				data: {
					id:[[${gtgsyw.id}]]
				},
				success:function (msg) {
					$.modal.closeLoading();
					var result = msg;
					var fso;
					try {
						fso=new ActiveXObject("Scripting.FileSystemObject");
					} catch (e) {
						alert("当前浏览器不支持");
						return;
					}
					deleteFile(result.filename);//删除文件
					console.log(result);
					var fso, f, s;
					fso = new ActiveXObject("Scripting.FileSystemObject");
					f = fso.createtextfile(result.filename, 8, true);

					f.WriteLine(result.msg);
					f.Close();
				},
				error: function (error) {
					alert("数据同步失败");
				}
			})

			// $.operate.save("/system/gtgsyw/filetxt",  $('#form-gtgsyw-edit').serialize());
			// var fso;
			// try {
			// 	fso=new ActiveXObject("Scripting.FileSystemObject");
			// } catch (e) {
			// 	alert("当前浏览器不支持");
			// 	return;
			// }
			// var f1 = fso.createtextfile("C:\\1.txt",true);
			// f1.WriteLine("这是内容");
			// f1.close();
			//
			// console.log("aaaa");
			// window.location.href = "/system/gtgsyw/filetxt?id=" + [[${gtgsyw.id}]];
		}, 200);
	}

	function deleteFile(name) {
		var fso = new ActiveXObject("Scripting.FileSystemObject");
		if (fso.FileExists(name))
			fso.DeleteFile(name);
		else
			return false;
	}
	$("#orther").change(function () {
		$("#z4").val($(this).val());
		pName =  $(this).val();
	});

	$(document).on("click",".personName",function () {
		changePName();
	});


	$(document).on("click",function () {
		console.log(111);
		changePName();
	});
	$(".personName").change(function () {
		changePName();
	});


	function changePName() {
		console.log();
		var pN = $("[name = nsxzq]").val() + $('input[name="zwzh"]:checked').val() + $("[name=mingchenghangye]").val() + $("[name=zuzhixingshi]").val();
		$("#personName").val(pN);
	}
function nameDisp() {
    if('[[${gtgsyw.zwzh1}]]' == "" ||'[[${gtgsyw.zwzh1}]]' == null){
    	$('#zwzh1').hide()
    }

	if('[[${gtgsyw.zwzh2}]]' == "" ||'[[${gtgsyw.zwzh2}]]' == null){
		$('#zwzh2').hide()
	}

	if('[[${gtgsyw.zwzh3}]]' == "" ||'[[${gtgsyw.zwzh3}]]' == null){
		$('#zwzh3').hide()
	}

}
	nameDisp();
</script>




</body>
</html>
