<?php
	include_once("../config.php");
	$sql = "select id,name,pp,gg from haocai where num>0 order by id desc";
	$requ=mysqli_query($con,$sql);
	$sql = "select id,name from danwei where status=1";
	$requs=mysqli_query($con,$sql);
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>耗材出库</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
	<style type="text/css">
		#delimg{color:#f00;width:20px;height:20px;font-size:20px;border:1px solid #f00;border-radius:10px;}
	</style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
	<form class="layui-form" action="" id="addxzxform" lay-filter="example">
			<div class="layui-form-item">
				<label for="username" class="layui-form-label">
					<span class="x-red"></span>模糊查询</label>
				<div class="layui-input-inline">
					<input type="text" id="sear" name="sear" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="username" class="layui-form-label">
					<span class="x-red">*</span>选择耗材</label>
				<div class="layui-input-block">
					<select name="hc" id="hc">
						<option value="0" selected="">选择耗材</option>
						<?php
						while($rs=mysqli_fetch_array($requ)){
							echo '<option value="'.$rs['id'].'">'.$rs['name'].'('.$rs['pp'].' '.$rs['gg'].')</option>';
						}
						?>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label for="username" class="layui-form-label">
					<span class="x-red">*</span>选择单位</label>
				<div class="layui-input-block">
					<select name="dw" id="dw">
						<option value="0" selected="">选择单位</option>
						<?php
						while($rss=mysqli_fetch_array($requs)){
							echo '<option value="'.$rss['name'].'">'.$rss['name'].'</option>';
						}
						?>
					</select>
				</div>
			</div>
	
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label"><span class="x-red">*</span>领用人</label>
				<div class="layui-input-inline">
					<input type="text" name="lyr" lay-verify="required" autocomplete="off" class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">领用数量</label>
				<div class="layui-input-inline">
					<input type="text" name="num" value="1" lay-verify="number" autocomplete="off" class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
    </div>
</div>

<script src="../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form'], function () {
        var form = layui.form
            , layer = layui.layer
			, $ = layui.$;

	$("#sear").keyup(function (e) {
		var s=$("#sear").val();
		if(s==''){
			return false;
		}else{
			s = s.replace(/[\'\"\\\/\b\f\n\r\t]/g, '');
			s = s.replace(/[\@\#\$\%\^\&\*\(\)\{\}\:\"\L\<\>\?\[\]]/, '');
			$.post("../action.php",{mode:'mhsearchhaocai',s:s},function(res){
				console.log(res);
				$("#hc").val(res);
				layui.form.render('select');
			})
		}

	});

        form.on('submit(demo1)', function (data) {
			var d = JSON.stringify(data.field);
			d=d.replace(/\'/g,"’");
			$.post("../action.php?mode=haocaichuku",{data:d},function(result){
				console.log(result);
				var r = JSON.parse(result);
				if(r.status==1){
					var index = layer.alert('出库成功',function () {
						$("#addxzxform")[0].reset();
                        layui.form.render();
						layer.close(index);
					});
				}else{
					layer.alert(r.msg);
				}
			});
            return false;
        });
		
	  form.on('select(changeleibie)', function(data){
		console.log(data);
	  });
    });
</script>

</body>
</html>