<?
$row = $duoduo->select(MOD, "*", "id=" . $_GET['id']);
// $role=new role($ddadmin,$duoduo);
// $roles=$role->get_roles();
?>
<br>
<div class="layui-form layuimini-main">

	<div class="layui-form-item">
		<label class="layui-form-label required">权限组</label>
		<div class="layui-input-block">
			<?
			$field = "role";
			$values = $role_arr;
			$select_values = $role_select_arr ? $role_select_arr : array(1);
			include(ADMINROOT . '/template/tpl/checkbox.tpl.php'); //
			?>

		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label required">名称</label>
		<div class="layui-input-block">
			<input type="text" name="title" lay-verify="required" lay-reqtext="" placeholder="请输入菜单名称" value="<?= $row['title'] ?>" class="layui-input">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">图标</label>
		<div class="layui-input-block">
			<input type="text" id="iconPicker" lay-filter="iconPicker" name="icon" lay-reqtext="" placeholder="" value="<?= $row['icon'] ?>" class="layui-input">
		</div>
		<script>
			layui.use(['iconPicker'], () => {
				var iconPicker = layui.iconPicker;
				iconPicker.render({
					// 选择器，推荐使用input
					elem: '#iconPicker',
					// 数据类型：fontClass/unicode，推荐使用fontClass
					type: 'fontClass',
					// 是否开启搜索：true/false
					search: true,
					// 点击回调
					click: (data) => {
						if(data.icon == undefined) {
							document.querySelector('#iconPicker').value = ''
						}
					}
				});
				/**
				 * 选中图标 （常用于更新时默认选中图标）
				 * @param filter lay-filter
				 * @param iconName 图标名称，自动识别fontClass/unicode
				 */
				iconPicker.checkIcon('iconPicker', '<?= $row['icon'] ?>');
			});
		</script>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label required">节点</label>
		<div class="layui-input-inline">
			<input type="text" name="node" id="nodevalue" lay-verify="required" lay-reqtext="" placeholder="请输入节点" value="<?= $row['node'] ?>" class="layui-input">
		</div>
		<div class="layui-input-inline">
			<?= select2($node_arr, $row['node'], 'node_id') ?>
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label required">模块</label>
		<div class="layui-input-block">
			<input type="text" name="mod" lay-reqtext="" placeholder="请输入模块名称" value="<?= $row['mod'] ?>" class="layui-input">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label required">行为</label>
		<div class="layui-input-block">
			<input type="text" name="act" lay-reqtext="" placeholder="请输入行为名称" value="<?= $row['act'] ?>" class="layui-input">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label required">url</label>
		<div class="layui-input-block">
			<input type="text" name="url" lay-reqtext="" placeholder="请输入url" value="<?= $row['url'] ?>" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">隐藏</label>
		<div class="layui-input-block">
			<input type="checkbox" name="hide" <?= ($row['hide'] == 1) ? "checked" : "" ?> lay-skin="switch" lay-text="ON|OFF">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label required">排序</label>
		<div class="layui-input-block">
			<input type="text" name="sort" lay-verify="required|number" lay-reqtext="" placeholder="" value="<?= $row['sort'] ? $row['sort'] : 0 ?>" class="layui-input">
		</div>
	</div>

	<div class="layui-form-item">
		<div class="layui-input-block">
			<input type="hidden" value="<?= $row['id'] ?>" name="id">
			<button class="layui-btn" lay-submit lay-filter="saveBtn">确认保存</button>
		</div>
	</div>

</div>
<script>
	layui.use(['form', 'table', 'miniAdmin'], function() {
		var form = layui.form,
			layer = layui.layer,
			miniAdmin = layui.miniAdmin,
			table = layui.table,
			$ = layui.jquery;
		/**
		 * 初始化表单，要加上，不然刷新部分组件可能会不加载
		 */
		form.render();

		form.on('select(node_id)', function(data) {

			$('#nodevalue').val(data.value);
		})

	});
</script>