<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" 
      xmlns:sec="http://www.pollix.at/thymeleaf/shiro">
<head th:replace="admin/common/html/head :: head_Normal(~{::title},~{::link},~{::style})">

<title th:text=${title}></title>
<!-- 这儿引用单独的css link -->
<!-- Ladda for Bootstrap 3按钮加载进度插件 -->
<link rel="stylesheet" th:href="@{/static/admin/assets/js/button/ladda/ladda.min.css}">
<!-- bootstrap-table表单样式 -->
<link th:href="@{/static/admin/assets/js/bootstrap/css/bootstrap-table/bootstrap-table.min.css}" rel="stylesheet"/>


<!-- jquery向导插件introjs -->
<link th:href="@{/static/admin/assets/js/intro/introjs.css}" rel="stylesheet"/>



<style type="text/css">
/**
*这里写单独的css样式
*/

</style>

</head>

<body id="listbody">




<!-- ###############################代码编写处############################### -->

<!-- 右边内容 -->
<div class="wrap-fluid">
    <div class="container-fluid paper-wrap bevel tlbr">
        <!-- 内容 -->
        <!--标题 通用-->
        <div th:replace="admin/common/html/title :: title(${title},${parenttitle},${isMsg},${msgHTML})">
        </div>
        <!-- 结束标题 通用-->
        <div class="content-wrap">
            <!-- 结束内容 -->
            <div class="row">
                <div class="row">
                	
                	<!-- 自动代码生成填写 -->
                	<div class="col-sm-6">
                		
                		<div class="nest">
						    <div class="nest" id="basicClose">
						        <div class="title-alt">
						            <h6>单表生成Ⅰ</h6>
						            <div class="titleClose">
						                <a class="gone" href="#basicClose">
						                    <span class="entypo-cancel"></span>
						                </a>
						            </div>
						            <div class="titleToggle">
						                <a class="nav-toggle-alt" href="#basic">
						                    <span class="entypo-up-open"></span>
						                </a>
						            </div>
						
						        </div>
						
						        <div class="body-nest" id="basic">
									<form class="form-horizontal bucket-form">
	                                    <div class="form-group" data-step="1" data-intro="选择表!">
	                                        <label class="col-sm-2 control-label">选择表</label>
	                                        <div class="col-sm-4">
	                                            <select  id="typeId" class="form-control" name="typeId">
													 <option value="-1">请选择</option>
												     <option  th:each="table : ${tables}" th:text="${table.tableName}" th:value="${table.tableName}"></option>
												</select>
	                                        </div>
	                                    </div>
	                                    <div class="form-group">
	                                        <label class="col-sm-2 control-label">表注释</label>
	                                        <div class="col-sm-4">
	                                            <input  class="form-control" id="tableComment" value="">
	                                        </div>
		                               </div>
		                               <div class="form-group">
	                                        <label class="col-sm-2 control-label">表model名称</label>
	                                        <div class="col-sm-4">
	                                            <input  class="form-control" id="tableModel" value="">
	                                        </div>
		                               </div>
		                               
	                                </form>
	                             
						        </div>
						    </div>
						</div>
                		
                		
                	</div>
                	<div  class="col-sm-6">
                		<div class="nest" id="basicClose2">
						        <div class="title-alt">
						            <h6>单表生成Ⅱ</h6>
						            <div class="titleClose">
						                <a class="gone" href="#basicClose2">
						                    <span class="entypo-cancel"></span>
						                </a>
						            </div>
						            <div class="titleToggle">
						                <a class="nav-toggle-alt" href="#basic2">
						                    <span class="entypo-up-open"></span>
						                </a>
						            </div>
						
						        </div>
						
						        <div class="body-nest" id="basic2">
									<form method="post" class="form-horizontal bucket-form">
	                                   
		                               <div class="form-group" data-step="2" data-intro="选择条件查询字段!">
	                                        <label class="col-sm-2 control-label">条件查询字段</label>
	                                        <div class="col-sm-8">
		                                        <div class="row">
		                                        	<div class="col-sm-6">
			                                        	 <select  id="conditionQueryField" class="form-control" name="conditionQueryField">
													     	<option value=""></option>
														 </select>
		                                        	</div>
		                                        	<div class="col-sm-6">
		                                        		<div class="alert-warning form-control">
						                                	<button data-dismiss="alert" class="close" type="button">×</button>
						                                    <span class="fa fa-hand-o-left"></span>
						                                  		html页面查询字段
						                                </div>
		                                        	</div>
		                                        </div>
	                                           
	                                        </div>
		                               </div>
		                               <div class="form-group" data-step="2" data-intro="选择两个圆圈的父标签，其他圈不支持，只准2个!">
	                                        <label class="col-sm-2 control-label">父菜单</label>
	                                        <div class="col-sm-8">
	                                        	<div class="row">
	                                        		<div class="col-sm-6">
	                                        			<select  id="menuid" class="form-control" name="menuid">
			                                             	<option></option>
														</select>
	                                        		</div>
	                                        		
	                                        		<div class="col-sm-6">
	                                        			<div class="alert-warning form-control">
						                                	<button data-dismiss="alert" class="close" type="button">×</button>
						                                    <span class="fa fa-hand-o-left"></span>
						                                  		选择⚪⚪的父菜单
						                                </div>
	                                        		</div>
	                                        	</div>
	                                        </div>
		                               </div>
		                               <div class="form-group" data-step="3" data-intro="选择是否把权限sql录入数据库!">
	                                        <label class="col-sm-2 control-label">sql自动录入</label>
	                                        <div class="col-sm-8">
	                                        	<div class="row">
	                                        		<div class="col-sm-4">
		                                        	  	<select  id="sql" class="form-control" name="sql">
													    	<option value="-1">不录入</option>
													    	<option value="1">录入</option>
														</select>
		                                        	</div>
		                                        	<div class="col-sm-8">
		                                        		<div class="alert-warning form-control">
						                                    <button data-dismiss="alert" class="close" type="button">×</button>
						                                    <span class="fa fa-hand-o-left"></span>
						                                  		第一次选择录入，第二次不录入防止冲突
						                                </div>
		                                        	</div>
	                                        	</div>
	                                        </div>
		                               </div>
	                                </form>
	                             
						        </div>
						    </div>
						</div>
                		<!-- 选择生成的东西 -->
                		<div  class="col-sm-12">
                			<div class="nest" id="basicClose3">
						        <div class="title-alt">
						            <h6>单表生成Ⅲ</h6>
						            <div class="titleClose">
						                <a class="gone" href="#basicClose2">
						                    <span class="entypo-cancel"></span>
						                </a>
						            </div>
						            <div class="titleToggle">
						                <a class="nav-toggle-alt" href="#basic2">
						                    <span class="entypo-up-open"></span>
						                </a>
						            </div>
						
						        </div>
						
						        <div class="body-nest" id="basic3">
									<form method="post" class="form-horizontal bucket-form">
		                               <div class="form-group"  data-step="4" data-intro="自行选择需要生成的页面!第一次要全部生成!">
	                                        
	                                        <div class="col-sm-12">
		                                        <div class="row">
		                                        	<div class="col-sm-3">
			                                        	<label class="checkbox checkbox-primary">
											                <input id="vhtml" class="styled" type="checkbox" checked="">
											                <label for="vhtml">生成html</label>
											            </label>
											            
		                                        	</div>
		                                        	<div class="col-sm-3">
		                                        		<label class="checkbox checkbox-primary">
											                <input id="vController" class="styled" type="checkbox" checked="">
											                <label for="vController">生成Controller</label>
											            </label>
		                                        	</div>
		                                        	<div class="col-sm-3">
		                                        		<label class="checkbox checkbox-primary">
											                <input id="vService" class="styled" type="checkbox" checked="">
											                <label for="vService">生成Service</label>
											            </label>
		                                        	</div>
		                                        	
		                                        	<div class="col-sm-3">
		                                        		<label class="checkbox checkbox-primary">
											                <input id="vMapperORdao" class="styled" type="checkbox" checked="checked">
											                <label for="vMapperORdao">生成model与mapper</label>
											            </label>
		                                        	</div>
		                                        </div>
	                                        </div>
		                               </div>
	                                </form>
	                             
						        </div>
						    </div>
                		
                		</div>
                		
                		
                		
                	</div>
					
                
                
               	 
                	<!-- END自动代码生成填写 -->
                	
                	
                    <!-- 空白页开始-->
                    <div class="nest" id="Blank_PageClose">
                        <div class="title-alt">
                            <h6>表单</h6>
                            <div class="titleClose">
                                <a class="gone" href="#Blank_PageClose">
                                    <span class="entypo-cancel"></span>
                                </a>
                            </div>
                            <div class="titleToggle">
                                <a class="nav-toggle-alt" href="#Blank_Page_Content">
                                    <span class="entypo-up-open"></span>
                                </a>
                            </div>
                        </div>
                        
                        <div class="body-nest" id="Blank_Page_Content">
                            <!-- 工具条 -->
                            <div class="btn-group hidden-xs" id="exampleTableEventsToolbar" role="group" data-step="5" data-intro="点击生成!会自动生成到全局里面的文件夹地址！然后刷新项目，重启即可" data-position='right'>
                               <button  onclick="divonclick();" type="button" class="btn btn-primary"   >
                                    <span class="entypo-plus-squared"></span>&nbsp;&nbsp;生成
                                </button>
                               
                           </div>
                            <!-- 工具条 end-->
                           <table id="dataTable" class="table-striped footable-res footable metro-blue" data-page-size="6">
                                   
                                    
                           </table>
                           
                           
                        </div>
                    </div>
                </div>
                <!-- 空白页结束 -->
            </div>
            <!-- 结束内容 -->
        </div>
    </div>
</div>
<!-- 结束右边内容 -->
<!-- ###############################代码编写处end############################### -->







<!-- 右侧隐藏滑块内容 -->
<div th:include="admin/common/html/rightHide :: rightHide">
    
</div>
   <!-- END 右侧隐藏滑块内容-->

<!-- 通用js -->
<div th:include="admin/common/html/js :: onload_js">
   
</div>
<!-- bootstarp 表格 -->
<script th:src="@{/static/admin/assets/js/bootstrap/js/bootstrap-table/bootstrap-table.min.js}" type="text/javascript"></script>
<script th:src="@{/static/admin/assets/js/bootstrap/js/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}" type="text/javascript"></script>
<script th:src="@{/static/admin/assets/js/bootstrap/js/base_list.js}" type="text/javascript"></script>
<!-- 导出 -->
<script th:src="@{/static/admin/assets/js/bootstrap/extensions/export/bootstrap-table-export.js}" type="text/javascript"></script>
<script th:src="@{/static/admin/assets/js/bootstrap/extensions/export/tableExport.js}" type="text/javascript"></script>

<!-- 弹窗 -->
<script th:src="@{/static/admin/assets/js/layer/layer.js}" type="text/javascript"></script>
<!-- 遮罩层 -->
<script th:src="@{/static/admin/assets/js/blockUI/jquery.blockUI.js}" type="text/javascript"></script>
<!-- jquery向导插件introjs -->
<script type="text/javascript" th:src="@{/static/admin/assets/js/intro/intro.js}"></script>
<!-- 提示插件  -->
<script type="text/javascript" th:src="@{/static/admin/assets/js/tip/jquery.tooltipster.js}"></script>
<script type="text/javascript">

var dataUrl11=window.rootPath+"/autoCodeController/queryTableInfo";
var removeUrl=window.rootPath+"/generatorController/remove";
var createUrl=window.rootPath+"/generatorController/add";
var updateUrl=window.rootPath+"/generatorController/edit/{id}";
var exportUrl=window.rootPath+"/generatorController/export";
var createUrl=window.rootPath+"/generatorController/code";

	var $dataTableHot = $("#dataTable").bootstrapTable({
            search: false,
            pagination: true,
            toolbar: '#exampleTableEventsToolbar',     
            pageSize: 15,
            pageList: [5, 10, 15, 20],
            showColumns: true,
            showRefresh: false,
            locale: "zh-CN",
            striped: true,
            toggle:true,
            columns:[
    			{
    			    checkbox: true
    			},                   
    			{
    				title: '字段名',
    				field: 'column_name'
    			},
    			{
    				title: '实体名称(可修改)',
    				field: 'beanName'
    			},
    			{
    				title: '数据库类型',
    				field: 'data_type'
    			},
    			{
    				title: '实体名称',
    				field: 'beanType'
    			},
    			{
    				title: '长度',
    				field: 'character_maximum_length'
    			},
    			{
    				title: '主键',
    				field: 'column_key',
    				formatter: function (value, row, index) {
    			        var id = row.column_key;
    			       if("PRI"==id){
    			    	   return "YES";
    			       }
    			       
    			       return "NO";
    				}
    			},
    			{
    				title: '是否自增',
    				field: 'extra',
    				formatter: function (value, row, index) {
    			        var id = row.extra;
    			       if(id.indexOf("auto_increment")!=-1){
    			    	   return "YES";
    			       }
    			       return "NO";
    			    }
    			},
    			{
    				title: '是否可为空',
    				field: 'is_nullable',
    				formatter: function (value, row, index) {
    			        var id = row.is_nullable;
    			       return id;
    			    }
    			},
    			{
    				title: '默认值',
    				field: 'column_default'
    			},
    			{
    				title: '备注(可修改)',
    				field: 'column_comment'
    			}],
    			 onDblClickCell : function(field,value,row,$element){
    				 $element.attr('contenteditable', true);
    		            $element.blur(function() {
    		                let index = $element.parent().data('index');
    		                let tdValue = $element.html();

    		                $dataTableHot.bootstrapTable('updateCell', {
    		                    index: index,       //行索引
    		                    field: field,       //列名
    		                    value: tdValue        //cell值
    		                })
    		            })
    			 }
        });
	
  
  
//列表
/* var oTab=$.table.oTableInit(options);
oTab.Init(); */
$(function(){
	
	$("#typeId").change(function() {
		var selectval= $(this).val();
		//表注释、表model名称
		$.ajax({
	  		type : "POST",
	  		url : rootPath + "/autoCodeController/queryTable",
	  		data :"tableName="+selectval,
	  		async : false,
			success:function(data){
				if(data.code==200){
					$("#tableComment").val(data.data[0].tableComment);
					$("#tableModel").val(data.data[0].tableModel);
				}
				
			}
		})
		
		//重新加载表格
			 $.ajax({
	            url:dataUrl11,
	            type:"post",
	            data:{"tableName":selectval},
	            dataType:"json",
	            success:function(data){
	            	if(data!=""){
	            		var selecthtml="";
	            		for ( var i in data.data) {
	            			if(data.data[i].column_key!="PRI"){
	            				selecthtml+="<option value=\""+data.data[i].funName+"\">"+data.data[i].column_name+" ("+data.data[i].column_comment+")</option>";
	            			}
	            			
						}
	            		$("#conditionQueryField").html(selecthtml);	
	            	}
	                $('#dataTable').bootstrapTable('load', data.data);
	            },
	            error:function(error){
	                console.log(error);
	            }
	        });
	});
	
	
	$.ajax({
  		type : "POST",
  		url : rootPath + "/PermissionController/list2",
  		async : false,
		success:function(data){
			if(data!=""&&data.length>0){
				var selecthtml="";
				var html=selecton(data,"0","");
				$("#menuid").html(html);
			}
			
		}
	})
	
})

function selecton(data,pid,pidstr){
	var selecthtml="";
	for ( var i in data) {
		var menuid = data[i].id;//获取菜单的id
		var parentid = data[i].pid;//获取菜单的父id
		if(parentid!=null){
			if(parentid==pid){
    			var htmla="<span class=\"label label-important\">"+pidstr+data[i].name+"</span>";
				selecthtml+="<option value=\""+data[i].id+"\">"+htmla+"</option>";
				selecthtml+=selecton(data,menuid,pidstr+" ⚪ ");
			}
		}
	}
	
	return selecthtml;
}

function divonclick(){

	    
	    
		var tableName=$("#typeId").val();
	    if(tableName=="-1"){
	    	return $.modal.alertWarning("选择表");
	    }
	    var conditionQueryField=$("#conditionQueryField").val();
		var allColumnss=JSON.stringify($dataTableHot.bootstrapTable('getSelections'));
		var pid=$("#menuid").val();
		var sql=$("#sql").val();
		var vMapperORdao="";
		
		
		if(sql=="1"){
			var sqlflag=true;
			 $.ajax({
					type : "POST",
			  		url : rootPath + "/autoCodeController/queryLikePerms",
			  		data :{"tableName":tableName},
			  		async : false,
					success:function(data){
						if(data.code==500){
							$.modal.alertWarning(data.msg);
							
						}else{
							sqlflag=false;
						}
						
					}
			 });
			 
			 if(sqlflag){
				 return;
			 }
		}
		
		$.ajax({
			type : "POST",
	  		url : rootPath + "/autoCodeController/saveOne",
	  		data :{"tableName":tableName,"conditionQueryField":conditionQueryField,"pid":pid,"sqlcheck":sql,
	  			"vhtml":$("#vhtml").is(':checked'),
	  			"vController":$("#vController").is(':checked'),
	  			"vService":$("#vService").is(':checked'),
	  			"vMapperORdao":$("#vMapperORdao").is(':checked'),
	  			"allColumnss":allColumnss
	  		},
	  		async : false,
			success:function(data){
				$.operate.saveSuccess(data,false);
			}
		});
		
	}

</script>


<script type="text/javascript">
this._options = {
	  /* 下一步按钮的显示名称 */
	  nextLabel: 'Next →',
	  /* 上一步按钮的显示名称 */
	  prevLabel: '← Back',
	  /* 跳过按钮的显示名称 */
	  skipLabel: 'Skip',
	  /* 结束按钮的显示名称 */
	  doneLabel: 'Done',
	  /* 引导说明框相对高亮说明区域的位置 */
	  tooltipPosition: 'right',
	  /* 引导说明文本框的样式 */
	  tooltipClass: '',
	  /* 说明高亮区域的样式 */
	  highlightClass: '',
	  /* 是否使用键盘Esc退出 */
	  exitOnEsc: true,
	  /* 是否允许点击空白处退出 */
	  exitOnOverlayClick: true,
	  /* 是否显示说明的数据步骤*/
	  showStepNumbers: true,
	  /* 是否允许键盘来操作 */
	  keyboardNavigation: false,
	  /* 是否按键来操作 */
	  showButtons: true,
	  /* 是否使用点点点显示进度 */
	  showBullets: true,
	  /* 是否显示进度条 */
	  showProgress: true,
	  /* 是否滑动到高亮的区域 */
	  scrollToElement: true,
	  /* 遮罩层的透明度 */
	  overlayOpacity: 0.8,
	  /* 当位置选择自动的时候，位置排列的优先级 */
	  positionPrecedence: ["bottom", "top", "right", "left"],
	  /* 是否禁止与元素的相互关联 */
	  disableInteraction: false,
	  /* 默认提示位置 */
	  hintPosition: 'bottom-middle',
	  /* 默认提示内容 */
	  hintButtonLabel: 'Got it'
};

//访问引导页
function guide() {
    introJs().setOptions({
        prevLabel: "上一步",
        nextLabel: "下一步",
        skipLabel: "跳过",
        doneLabel: "结束"
    }).oncomplete(function () {
        //点击跳过按钮后执行的事件
    }).onexit(function () {
        //点击结束按钮后， 执行的事件
    }).start();
}

guide();
</script>


</body>


</html>
