<%@ 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-card md-0">
    <div class="layui-card-body">
        <form class="layui-form" lay-filter="layuiadmin-form-admin" >
            <input type="hidden" name="id" id="id" value="${apply.columns.id}" >
            <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" lay-verify="required" value="${apply.columns.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" lay-verify="required" value="${apply.columns.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" lay-verify="required" value="${apply.columns.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="${apply.columns.suit_printer}" 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="unit" name="unit" class="layui-input layui-bg-gray" lay-verify="required" value="${apply.columns.unit}" 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="storehouse" name="storehouse" class="layui-input layui-bg-gray" lay-verify="required" value="${apply.columns.storehouse}" disabled>
                    </div>
                </div>
              <%--  <div class="layui-col-xs6 mb-5">
                    <label class="layui-form-label">返回旧件：</label>
                    <div class="layui-input-block">
                        <select  name="refundOldFlag" id="refundOldFlag"  class="layui-bg-gray"  disabled>
                            <option value="">请选择</option>
                            <option value="1" <c:if test="${apply.columns.refund_old_flag eq '0'}"> selected</c:if> >无需返还</option>
                            <option value="2" <c:if test="${apply.columns.refund_old_flag eq '1'}"> selected</c:if>>需要返还</option>
                        </select>
                    </div>
                </div>--%>
                <div class="layui-col-xs12 mb-5">
                    <label class="layui-form-label">备件描述：</label>
                    <div class="layui-input-block">
                        <input type="text"  id="remarks" name="remarks" class="layui-input layui-bg-gray"  value="${apply.columns.remarks}" disabled>
                    </div>
                </div>
                <div class="layui-col-xs12 layui-form-item">
                    <label class="layui-form-label">备件图片：</label>
                    <div class="layui-input-block">
                        <div id="imgsDiv">
                            <c:forEach items="${imgs}" var="img">
                                <div class="bj-img imgSpan mt-10">
                                    <img src="${commonStaticImgPath}${img}" data-img="${commonStaticImgPath}${img}" height="900" width="1300"/>
                                </div>
                            </c:forEach>
                        </div>
                    </div>
                </div>
                <%--<div class="layui-col-xs12 layui-form-item">
                    <label class="layui-form-label">二维码：</label>
                    <div class="layui-input-block mt-10">
                        <div id="codeDiv">
                           &lt;%&ndash; <div class="bj-img imgSpan">
                            </div>&ndash;%&gt;
                        </div>
                    </div>
                </div>--%>

            </div>
        </form>
    </div>
    <div class="operate-footer">
        <button type="button" class="layui-btn layui-btn-primary" onclick="cancels()">取消</button>
    </div>
</div>

<div id="lookImg" class="hide pos-r">
    <div style="position:relative;width:100%;height:500px;">
        <div class="w-500 h-450 lookImg">
            <img src="" width="80%" id="image" >
        </div>
    </div>
</div>


<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/ueditor/1.4.3/third-party/jquery-1.10.2.min.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/modules/qrcode.min.js"></script>
<script>
    var imgsCount;
    var fitId = '${apply.columns.fittingId}';
    layui.use(['form', 'jquery','laydate'], function () {
        $ = layui.$
            , element = layui.element
            , form = layui.form
            , laydate = layui.laydate;

        //$("#codeDiv").empty().qrcode({width : 120, height : 120,text:fitId});

        $(".imgSpan img").click(function(){
            var img = $(this).attr("data-img");
            $("#lookImg img").attr('src',img);
            layer.open({
                type:1,
                title:'查看图片',
                area:['500px','530px'],
                content:$("#lookImg")
            })
        })
    });




    //通过申请
    var noRepeatSub = false;
    function addFitting(){
        if(noRepeatSub){
            return;
        }
        var warning = $("#warning").val();  //审核数量
        var sitePrice = $("#sitePrice").val();  //返还旧件

        var checkTe = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
        if(isBlank(warning)){
            layer.msg("备件数量不可为空", {icon: 5, anim: 6});
            return;
        }else if (!checkTe.test(warning)) {
            layer.msg("备件数量格式不正确", {icon: 5, anim: 6});
            return;
        }else if(isBlank(sitePrice)){
            layer.msg("价格不可为空", {icon: 5, anim: 6});
            return;
        }else if (!checkTe.test(sitePrice)) {
            layer.msg("价格格式不正确", {icon: 5, anim: 6});
            return;
        }else{
            $.ajax({
                url: '${ctx}/platform/fitting/adoptApply',
                type: 'post',
                data: {
                    id: id,
                    fittingSuditNum: fittingSuditNum,
                    oldFittingFlag: oldFittingFlag,
                    factoryMarks: factoryMarks
                },
                success: function(data) {
                    if(data.code=="200"){
                        layer.msg("保存成功！",{time:1000},function(){
                            layer.closeAll()
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layerIFrameReload(index); //再执行关闭
                        });
                    }else if(data.code="401"){
                        layer.msg("该申请已经审核，请刷新页面",{icon:2})
                    }else{
                        layer.msg("保存失败！");
                    }
                },
                complete:function(){

                }
            });
        }
    }

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

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


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