<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="en">
<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.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="decorator" content="base" />
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/css/reset.css" />
    <style>
        html{
            background-color: #fff;
        }
    </style>
</head>
<body>
<div class="layui-form" lay-filter="layuiadmin-form-admin">
    <div class="layui-card md-0">
        <div class="layui-card-body">
            <div class="layui-form-item layui-col-xs12 ">
                <div class="layui-col-xs6 mb-5">
                    <label class="layui-form-label">物料号：</label>
                    <div class="layui-input-block">
                        <input type="text" id="fittingCode" name="code" class="layui-input layui-bg-gray"
                               value="${fitt.code}" disabled>
                    </div>
                </div>
                <div class="layui-col-xs6 mb-5">
                    <label class="layui-form-label">备件名称：</label>
                    <div class="layui-input-block">
                        <input type="text" id="name" name="name" class="layui-input layui-bg-gray" value="${fitt.name}"
                               disabled>
                    </div>
                </div>

                <div class="layui-col-xs6 mb-5">
                    <label class="layui-form-label">备件型号：</label>
                    <div class="layui-input-block">
                        <input type="text" id="version" name="version" class="layui-input layui-bg-gray"
                               value="${fitt.version}" disabled>
                    </div>
                </div>

                <div class="layui-col-xs6 mb-5">
                    <label class="layui-form-label">适用机型：</label>
                    <div class="layui-input-block">
                        <input type="text" name="suitPrinter" id="suitPrinter" class="layui-input layui-bg-gray"
                               value="${fitt.suitPrinter}" disabled>
                    </div>
                </div>
                <div class="layui-col-xs6 mb-5">
                    <label class="layui-form-label">操作人：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input layui-bg-gray" value="${name}" disabled>
                    </div>
                </div>
                <div class="layui-col-xs6 mb-5">
                    <label class="layui-form-label">操作时间：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input layui-bg-gray" value="${time}" disabled>
                    </div>
                </div>
                <div class="layui-col-xs6 mb-5">
                    <label class="layui-form-label">当前库存：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input layui-bg-gray" value="${fitt.warning}" disabled>
                    </div>
                </div>

                <div class="layui-col-xs4 mb-5">
                    <label class="layui-form-label"><i class="mark ">*</i>调整后库存：</label>
                    <div class="layui-input-block">
                        <input type="text" name="newWaring" id="newWaring" class="layui-input" lay-verify="required"
                               value="">
                    </div>
                </div>

                <div class="layui-col-xs12 mb-5">
                    <label class="layui-form-label"><i class="mark ">*</i>调整原因：</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入调整原因" class="layui-textarea" id="remarks" name="remarks"
                                  lay-verify="required"></textarea>
                    </div>
                </div>
                <input type="hidden" name="id" value="${fitt.id}">
            </div>
        </div>
    </div>
    <div class="operate-footer">
        <button class="layui-btn" lay-submit="" lay-filter="component-form-demo1" id="tijiaoBtn">保存</button>
        <button type="button" class="layui-btn layui-btn-primary" onclick="cancels()">取消</button>
    </div>
</div>


<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script>
    layui.use(['form', 'jquery','laydate','upload'], function () {
        $ = layui.$
            , element = layui.element
            , form = layui.form
            , laydate = layui.laydate;

        var ckeckFi = false;
        form.on('submit(component-form-demo1)', function (data) {
            $("#tijiaoBtn").attr("disabled", "true"); //改变提交按钮上的文字并将按钮设置为不可点击
            if(ckeckFi){
                return
            }
            ckeckFi = true;
            var articleFrom = data.field;
            $.ajax({
                type:"POST",
                url:"${ctx}/platform/fiting/InventoryFitting",
                data:articleFrom,
                success:function(data){
                    console.log(data)
                    ckeckFi = false;
                    $("#tijiao").removeAttr("disabled");
                    if(data.code=='200'){
                        layer.msg('提交成功！', {icon:1,time:1000},function(){
                            parent.layer.closeAll();
                       parent.searchOrder()
                        // parent.window.location.reload();
                        });
                    }else if(data.code == '203'){
                         layer.msg(data.errMsg, {icon: 2});
                    }else{
                        layer.msg("保存失败", {icon: 2});
                    }
                }
            });

        })
    });
    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }

    function cancels(){
        parent.layer.closeAll();
    }


</script>
</body>
</html>