<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<meta charset="UTF-8">
	<meta name="format-detection" content="telephone=no">
	<th:block th:include="include :: header('绑定患者')" />
	<th:block th:include="include :: layout-latest-css" />
	<th:block th:include="include :: ztree-css" />
</head>

<body class="gray-bg">
<div class="ui-layout-center">
<input type="hidden" id="rowIds">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="tag-form" class="customize-search-form">
				<div class="customize-form-group-container">
					<div class="customize-form-group">
						<label>患者名/手机号:</label>
						<input type="text" class="styled-input" placeholder="请输入患者姓名/手机号" name="query" style="width: 300px;"/>
						<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()">搜索</a>
						<a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()">重置</a>
					</div>
				</div>

			</form>
		</div>

	</div>
	<div class="row">
		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table"></table>
		</div>
	</div>
	<div class="row">
	<div class="customize-form-group" style="justify-content: center;">
		<button type="button"  onclick="addHuanZhe()" class="btn-primary">新建患者</button>
	</div>
	</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: layout-latest-js" />
<th:block th:include="include :: bootstrap-table-fixed-columns-js" />
<th:block th:include="include :: ztree-js" />
<script th:inline="javascript">
	var viewFlag = [[${@permission.hasPermi('dtp:pmService:archivesList')}]];
	var prefix = ctx + "dtp/pmService";
	$(function() {
		var panehHidden = false;
		if ($(this).width() < 1590) {
			panehHidden = true;
		}
		$('body').layout({ initClosed: panehHidden, west__size: 185, resizeWithWindow: false });
		// 回到顶部绑定
		if ($.fn.toTop !== undefined) {
			var opt = {
				win:$('.ui-layout-center'),
				doc:$('.ui-layout-center')
			};
			$('#scroll-up').toTop(opt);
		}
		queryUserList();
	});

	function queryUserList() {
		var options = {
			url: prefix + "/slectPatientByNameOrPhone",
			viewUrl: prefix + "/view/{id}",
			modalName: "患者信息",
			showFooter:true,  //是否显示表格底部区域。
			clickToSelect: true, //是否启用点击行时选中整行的功能。
			singleSelect: true, //是否仅允许选择一行
			fixedColumns: true,
			//fixedNumber: 3,
			//fixedRightNumber: 1,
			columns: [
				{checkbox: true},
				{field: "id",title: "id",visible: true,},
				{field: 'name', title: '姓名', align: 'center'},
				{field: 'gender', title: '性别', align: 'center'},
				{field: 'age', title: '年龄', align: 'center'},
				{field: 'phoneNumber', title: '手机号', align: 'center'},
				{field: 'documentNumber', title: '证件号码', align: 'center'},
				{field: 'storeName', title: '门店', align: 'center'},
				]
		};
		$.table.init(options);
	}

	/* 自定义重置-表单重置/隐藏框/树节点选择色/搜索 */
	function resetPre() {
		resetDate();
		$("#tag-form")[0].reset();
		$("#deptId").val("");
		$("#parentId").val("");
		$(".curSelectedNode").removeClass("curSelectedNode");
		$.table.search();
	}
	/* 添加用户-选择用户-提交(子页面调用父页面形式) */
	function submitHandler(index, layero) {
		debugger
		var rows = $.table.selectFirstColumns();

		if (rows.length == 0) {
			$.modal.alertWarning("请至少选择一条记录");
			return;
		}
		$.modal.close(index);
		// 父页面的方法
		// activeWindow().selectUsers();
		// 父页面的变量
		activeWindow().$('#userids').html('我是通过方式一来的：' + rows.join());

	}

	/* 添加用户-选择用户-提交(回调形式-父页面调用子页面) */
	function getSelections() {
		return $.table.selectFirstColumns();
	}
	// 获取 URL 中的查询参数
	// var urlParams = new URLSearchParams(window.location.search);
	// var returnedData = JSON.parse(decodeURIComponent(urlParams.get('data')));
	// console.log("returnedData"+returnedData)
	function selectTableObject() {
		var id = $.table.selectColumns('id');
		var name = $.table.selectColumns('name');
		var phoneNumber = $.table.selectColumns('phoneNumber');
		var documentNumber = $.table.selectColumns('documentNumber');
		var gender = $.table.selectColumns('gender');
		var age = $.table.selectColumns('age');
		var column = [{id:id,name:name,phoneNumber:phoneNumber,documentNumber:documentNumber,gender:gender,age:age}];
		return column;
	}
	$("#bootstrap-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", function (e, rowsAfter, rowsBefore) {
		var rows = $.common.equals("uncheck-all", e.type) ? rowsBefore : rowsAfter;
		var rowIds = $.table.affectedRowIds(rows);
		$("#rowIds").val(rowIds);
	});

	function addHuanZhe(){
		addNewHuanZhe();
	}
	function addNewHuanZhe(data){
		var options = {
			title: '新建患者',
			url: prefix + "/archivesAdd",
			width:1000,
			//callBack: submitHandler
		};
		$.modal.openOptions(options);
	}

</script>
</body>

</html>
