<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="导入表结构" bodyClass="gray-bg" libs=["table"]/>
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<@f.form id="gen-form" class="form-inline">
					<@f.hidden name="dbName" value="${dbName}" refresh=false />
					<div class="select-list">
						<ul>
							<li>
								表名称：
								<@f.select name="tableName" items=dbTables itemLabel="tableName" itemValue="tableName" blankValue="" blankLabel="所有"/>
							</li>
							<li>
								表描述：
								<@f.select name="tableComment" items=dbTables itemLabel="tableComment" itemValue="tableComment" blankValue="" blankLabel="所有"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
			</@f.form>
		</div>
		<@table id="bootstrap-table"/>
	</div>
</div>
<@footer>
<script type="text/javascript">
	var prefix = baseURL + "tool/gen";

	function queryParams(params) {
		var search = $.table.queryParams(params);
		search.dbName = $("#dbName").val();
		return search;
	}

	$(function() {
		var options = {
			url: prefix + "/db/list",
			sortName: "createTime",
			uniqueId: "tableName",
			sortOrder: "desc",
			showSearch: false,
			showRefresh: false,
			showToggle: false,
			showColumns: false,
			queryParams: this.queryParams, /*初始化请求参数*/
			pageSize: 10,
			pageList: [10, 30, 50],
			columns: [
			{checkbox: true},
			{
				title: $.i18n.prop("序号"),
				formatter: function (value, row, index) {
					return $.table.serialNumber(index);
				}
			},
			{
				field: 'tableName',
				title: '表名称',
				width: '20%',
				sortable: true
			},
			{
				field: 'tableComment',
				title: '表描述',
				width: '20%',
				sortable: true
			},
			{
				field: 'createTime',
				title: $.i18n.prop("创建时间"),
				width: '20%',
				sortable: true
			},
			{
				field: 'updateTime',
				title: '更新时间',
				width: '20%',
				sortable: true
			}]
		};
		$.table.init(options);
	});

	/* 导入表结构-选择表结构-提交 */
	function submitHandler() {
		var rows = $.table.selectColumns("tableName");
		if (rows.length == 0) {
			opt.modal.alertWarning("请至少选择一条记录");
			return;
		}
		var data = {"tables": rows.join(),"dbName": $("#dbName").val()};
		opt.operate.save(prefix + "/importTable", data);
	}
</script>
</@footer>
</@pageTheme>