<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <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" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/static/css/reset.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/dist/viewer.css" media="all">
    <style>
        html{background-color: #fff;padding-bottom: 50px;}
        .layui-form-select dl{
            max-height:200px;
            width: 80%;
        }
        .layui-text h3 {
            font-size: 14px !important;
        }
        .fontColor1{
            color: #409eff !important;
        }
        td, th {
            text-align: center !important;
        }
    </style>
</head>
<body>

<div class="layui-form" id="LAY_app">
    <div class="layui-card mt-10">

        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this">表单信息</li>
                <li>审批过程</li>
            </ul>

            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <input name="id" value="${apply.columns.id}" hidden>
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <div class="layui-row layui-col-space12 layui-form-item mt-5">
                                <%--<div class="layui-col-xs3">
                                    <label class="layui-form-label"><i class="red">*</i>备货类型：</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input layui-bg-gray" value="${'0' eq apply.columns.fitting_type?'其他':'组件'}" id="fittingType" disabled>
                                    </div>
                                </div>--%>
                                <div class="layui-col-xs3">
                                    <label class="layui-form-label"><i class="red">*</i>入库仓库：</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input layui-bg-gray" value="${apply.columns.inWarehouseName}" id="inWarehouseName" disabled>
                                    </div>
                                </div>
                                <div class="layui-col-xs3">
                                    <label class="layui-form-label">申请人：</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input layui-bg-gray" value="${apply.columns.create_name}" id="createName" disabled>
                                    </div>
                                </div>
                                <div class="layui-col-xs3">
                                    <label class="layui-form-label">申请时间：</label>
                                    <div class="layui-input-block">
                                        <input type="text" autocomplete="off" id="createTime" name="createTime" class="layui-input layui-bg-gray" value="${apply.columns.createTime}" readonly>
                                    </div>
                                </div>
                                <div class="layui-col-xs3">
                                    <label class="layui-form-label">申请编号：</label>
                                    <div class="layui-input-block">
                                        <input type="text" autocomplete="off"  name="createTime" class="layui-input layui-bg-gray" value="${apply.columns.number}" readonly>
                                    </div>
                                </div>
                                <div class="layui-inline layui-col-xs12">
                                    <label class="layui-form-label">备注：</label>
                                    <div class="layui-input-block ">
                                        <input type="text" name="remarks" autocomplete="off" placeholder="" class="layui-input layui-bg-gray" value="${apply.columns.remarks}" readonly>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-card">

                        <blockquote class="layui-elem-quote">物料清单</blockquote>
                        <div class="layui-card-body ">
                            <div class="layui-row layui-col-space12 layui-form-item">
                                <div class="layui-col-xs12 mb-10 pr-30 pl-30">

                                    <table class="layui-table">
                                        <thead>
                                        <tr>
                                            <th style="width: 5%">序号</th>
                                            <th style="width: 18%">物料类型</th>
                                            <th style="width: 20%">物料规格</th>
                                            <th style="width: 10%">备货数量</th>
                                            <c:if test="${'3' eq apply.columns.status || '4' eq apply.columns.status}">
                                                <th style="width: 10%">单位</th>
                                                <th style="width: 10%">物料代码</th>
                                                <th style="width: 10%">品牌</th>
                                            </c:if>
                                            <th style="width: 20%">备注</th>
                                        </tr>
                                        </thead>
                                        <tbody id="materialBody">
                                        <c:if test="${not empty details}">
                                            <c:forEach items="${details}" var="de" varStatus="vs">
                                                <tr class="materialtr">
                                                    <td>${vs.count}</td>
                                                    <td>${de.columns.material_type}</td>
                                                    <td>${de.columns.material_spec}<c:if test="${'组件' eq de.columns.material_type}">W</c:if></td>
                                                    <td>${de.columns.amount}</td>
                                                    <c:if test="${'3' eq apply.columns.status || '4' eq apply.columns.status}">
                                                       <td>${de.columns.unitName}</td>
                                                        <td>${de.columns.material_code}</td>
                                                        <td>${de.columns.material_brand}</td>
                                                    </c:if>
                                                    <td>${de.columns.remark}</td>
                                                </tr>
                                            </c:forEach>
                                        </c:if>
                                        <c:if test="${empty details}">
                                            <tr class="materialtr">
                                                <td>1</td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                            </tr>
                                        </c:if>

                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>

                    <c:if test="${from eq 'audit'}">
                        <div class="layui-col-xs12 mb-15 pr-30 mt-10">
                            <label class="layui-form-label w-130">审核备注：</label>
                            <div class="layui-input-block">
                                <input type="text" name="auditRemarks" id="auditRemarks" autocomplete="off" placeholder="" class="layui-input" value="">
                            </div>
                        </div>

                    </c:if>
                </div>


                <div class="layui-tab-item guocheng">
                    <ul class="layui-timeline">
                        <c:forEach items="${infos}" var="info">
                            <li class="layui-timeline-item">
                                <i class="layui-icon layui-timeline-axis"></i>
                                <div class="layui-timeline-content layui-text">
                                    <div class="layui-timeline-title"><fmt:formatDate value="${info.operateTime}" pattern="yyyy-MM-dd HH:mm:ss"/>&nbsp;&nbsp;&nbsp;${info.detail}</div>
                                </div>
                            </li>
                        </c:forEach>

                    </ul>
                </div>
            </div>

        </div>
        <div  class="openDivBottom">
            <div class="layui-col-xs4">
                提交人：${apply.columns.create_name}
            </div>
            <div class="layui-col-xs4">
                所属部门：${apply.columns.department_name}
            </div>
            <div class="layui-col-xs4">
                申请时间：${apply.columns.createTime}
            </div>
        </div>


        <input type="hidden" name="taskId" id="taskId" value="${apply.columns.task_id}">
        <input type="hidden" name="id" id="id" value="${apply.columns.id}">

        <input type="hidden" id="processInstanceId" value="${apply.columns.process_instance_id}">
        <input type="hidden" id="status" value="${apply.columns.status}">
        <div class="layui-col-xs12 mb-20 pr-30 mt-20">
        </div>
    </div>
    <div class="operate-footer">
        <c:if test="${from eq 'audit'}">
            <input type="button"  id="approve" class="layui-btn " value="同意">
            <input type="button"  id="back" class="layui-btn " value="驳回">
        </c:if>
        <input type="button"   value="取消" class="layui-btn layui-btn-primary " onclick="closeDiv();" >
    </div>
</div>

<div id="lookImg" class="hide pos-r">
    <div style="position:relative;width:90%;height:450px;">
        <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/layuiAdmin/dist/layuiadmin/dist/viewer.js"></script>
<script type="text/javascript">
    var viewer = new Viewer(document.getElementById('LAY_app'));
    //初始数据
    var $form;
    var form;
    var upload;
    var $;
    var myreg=/^[1][3,4,5,6,7,8,9][0-9]{9}$/;
    layui.use(['form', 'table', 'upload', 'jquery','element'], function () {
        $ = layui.jquery;
        form = layui.form;
        upload = layui.upload;
        $form = $('form');
        var element = layui.element;

        element.on('tab(docDemoTabBrief)', function (data) {
            $('.layui-tab-content').eq(data.index).removeClass('layui-hide').siblings('.layui-tab-content').addClass('layui-hide');
        });

        //通过
        $("#approve").click(function (){
            var id=$("#id").val();
            var taskId=$("#taskId").val();
            var content=$("#auditRemarks").val();
            $("#approve").attr("disabled","true");
            $.ajax({
                type:"POST",
                url:"${ctx}/fittingStockUp/examineFittingStockUpApplyApprove",
                data:{
                    id:id,
                    taskId:taskId,
                    content:content
                },
                success:function(res){
                    console.log(res+'----');
                    if(res.code=="200"){
                        parent.layer.msg("审核成功",{time:2000});
                        closeDiv();
                        parent.table.reload('test-table-reload');
                    } else{
                        layer.msg(res.errMsg,{time:2000});
                        $("#approve").removeAttr("disabled");
                    }
                },
                error:function (data) {
                }
            }) ;
        })

        //驳回
        $("#back").click(function (){
            var id=$("#id").val();
            var taskId=$("#taskId").val();
            var content=$("#auditRemarks").val();
            if(isBlank(content)){
                layer.msg("请输入备注！",{icon:"2"});
                return ;
            }
            $("#back").attr("disabled","true");
            $.ajax({
                type:"POST",
                url:"${ctx}/fittingStockUp/rejectFittingStockUpApplyTask",
                data:{
                    id:id,
                    taskId:taskId,
                    content:content
                },
                success:function(res){
                    console.log(res+'++++++');
                    if(res.code=="200"){
                        parent.layer.msg("驳回成功",{time:2000});
                        closeDiv();
                        parent.table.reload('test-table-reload');
                    } else{
                        layer.msg(res.errMsg,{time:2000});
                        $("#back").removeAttr("disabled");
                    }
                },
                error:function (data) {
                }
            }) ;
        })
    })

    function  closeDiv() {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index);
    }

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

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


