<%@ 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>
        .layui-form-select dl{
            max-height:200px;
            width: 80%;
        }
        .w-130{width: 130px}
        .ml120 .layui-input-block{margin-left: 130px}
        .ml-130{margin-left:  130px}
        .border-grey{border: 1px solid #DDD; border-radius: 10px;}
        .table-input{width: 30px; border: none; text-align: center; height: 30px; line-height: 30px}
        .layui-elem-field legend{font-size: 16px}
        .img-80{display: flex; justify-content: center;}
        .img-80 .bj-img{margin-right: 0}
    </style>
</head>
<body>
<div class="layui-form">
    <div class="layui-card" id="LAY_app">

        <div class="layui-tab layui-tab-brief over pt-20 pb-40 h-350" lay-filter="docDemoTabBrief" id="detailSet">
            <ul class="layui-tab-title">
                <li class="layui-this">表单信息</li>
              <%--  <li>流程路径</li>--%>
                <li>审批过程</li>
            </ul>
            <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">

            <div class="layui-row ml120 mt-20">
                <div class="layui-col-xs9">
                    <div class="layui-col-xs12 mb-15 pr-30">
                        <label class="layui-form-label w-130"><i class="red">*</i>供应商名称：</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" lay-verify="traderName" autocomplete="off"  class="layui-input" readonly value="${apply.name}">
                        </div>
                    </div>
                    <div class="layui-col-xs12 mb-10 pr-30">
                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130"><i class="red">*</i>登录账号：</label>
                            <div class="layui-input-block ">
                                <input type="text"  name="loginName" lay-verify="loginName" autocomplete="off" placeholder="请输入登录账号" class="layui-input" value="${apply.loginName}">
                            </div>
                        </div>
                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130"><i class="red">*</i>登录密码：</label>
                            <div class="layui-input-block w-200" >
                                <input type="password" name="password" lay-verify="password" autocomplete="new-password" placeholder="请输入登录密码" class="layui-input" <c:if test="${apply.password eq null}">value=""</c:if>value="default">
                            </div>
                        </div>
                    </div>
                    <%--<div class="layui-col-xs12 mb-10 pr-30">
                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130"><i class="red">*</i>法定代表人：</label>
                            <div class="layui-input-block ">
                                <input type="text" name="contacts" lay-verify="required" autocomplete="off" placeholder="请输入法定代表人" class="layui-input" value="${apply.contacts}">
                            </div>
                        </div>
                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130"><i class="red">*</i>联系电话：</label>
                            <div class="layui-input-block w-200" >
                                <input type="text" name="mobile" lay-verify="telephone" autocomplete="off" placeholder="请填写业务联系人" class="layui-input" value="${apply.mobile}">
                            </div>
                        </div>
                    </div>--%>
                    <div class="layui-col-xs12 mb-10 pr-30">
                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130"><i class="red">*</i>企业负责人：</label>
                            <div class="layui-input-block ">
                                <input type="text" name="actualContacts" lay-verify="required" autocomplete="off" placeholder="请输入企业负责人" class="layui-input" value="${apply.actualContacts}">
                            </div>
                        </div>
                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130"><i class="red">*</i>联系电话：</label>
                            <div class="layui-input-block w-200" >
                                <input type="text" name="telephone" lay-verify="telephone" autocomplete="off" placeholder="请填写企业负责人电话" class="layui-input" value="${apply.telephone}">
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs12 mb-10 pr-30">

                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130"><i class="red">*</i>身份证号：</label>
                            <div class="layui-input-block w-200" >
                                <input type="text" name="actualIdCode" lay-verify="idcode" autocomplete="off" placeholder="请填写身份证号" class="layui-input" value="${apply.actualIdCode}">
                            </div>
                        </div>

                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130"><i class="red">*</i>统一信用代码：</label>
                            <div class="layui-input-block w-200" >
                                <input type="text" name="taxNumber" lay-verify="required" autocomplete="off" placeholder="请填写统一信用代码" class="layui-input" value="${apply.taxNumber}">
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs12 mb-10 pr-30">
                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130"><i class="red">*</i>开户银行：</label>
                            <div class="layui-input-block ">
                                <input type="text" name="bankName" lay-verify="required" autocomplete="off" placeholder="请输入开户银行" class="layui-input" value="${apply.bankName}">
                            </div>
                        </div>
                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130"><i class="red">*</i>银行账号：</label>
                            <div class="layui-input-block w-200" >
                                <input type="text" name="bankCode" lay-verify="required" autocomplete="off" placeholder="请填写银行账号" class="layui-input" value="${apply.bankCode}">
                            </div>
                        </div>
                    </div>

                    <div class="layui-col-xs12 mb-10 pr-30">

                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130"><i class="red">*</i>关联品牌：</label>
                            <div class="layui-input-block w-200">
                                <select name="materialBrandId" id="materialBrandId" lay-verify="required" >
                                    <option value="">请选择</option>
                                    <c:forEach items="${brands}" var="brand">
                                        <option value="${brand.columns.id}" <c:if test="${apply.materialBrandId eq brand.columns.id}"> selected</c:if> >${brand.columns.name}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline layui-col-xs6">
                            <label class="layui-form-label w-130"><i class="red">*</i>关联物料类型：</label>
                            <div class="layui-input-block w-200" >
                                <div id="materialTypeId"></div>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="layui-col-xs3">
                    <div class="layui-input-block" style="margin-left: 50px">
                        <div id="imgsDiv" class="img-80">
                            <div class="bj-img imgSpan"><span class="layui-icon-close layui-icon" ></span>
                               <img src="${commonStaticImgPath}${apply.certificationImg}" height="700" width="1200"/>
                               <input type="hidden" class="imgPicker" value="${apply.certificationImg}"/> </div>
                        </div>
                        <div class="upload-container hide" id="uploader" style="margin: 0 auto;">
                            <img src="" alt="img placeholder" id="imgsAdd">
                        </div>
                         <div style="width: 100%; text-align: center; color: #144856"><i class="mark">*</i>营业执照</div>
                    </div>
                    <%--<div class="layui-input-block" style="margin-left: 50px">
                        <div id="IdFrontimgsDiv" class="img-80">
                            <div class="bj-img imgSpan"><span class="layui-icon-close layui-icon" ></span>
                                <c:if test="${not empty apply.idFrontImg}">
                                    <img src="${commonStaticImgPath}${apply.idFrontImg}" height="700" width="1200"/>
                                </c:if>
                                <input type="hidden" class="imgPicker" value="${apply.idFrontImg}"/> </div>
                        </div>
                        <div class="upload-container hide" id="IdFrontimgsuploader" style="margin: 0 auto;">
                            <img src="" alt="img placeholder" id="IdFrontimgsAdd">
                        </div>
                        <div style="width: 100%; text-align: center; color: #144856">法定代表人身份证正反面<p>复印件(加盖公章)</p></div>
                    </div>--%>
                    <div class="layui-input-block" style="margin-left: 50px">
                        <div id="idOppositeImgDiv" class="img-80">
                            <div class="bj-img imgSpan"><span class="layui-icon-close layui-icon" ></span>
                                <c:if test="${not empty apply.idOppositeImg}">
                                    <img src="${commonStaticImgPath}${apply.idOppositeImg}" height="700" width="1200"/>
                                </c:if>

                                <input type="hidden" class="imgPicker" value="${apply.idOppositeImg}"/> </div>
                        </div>
                        <div class="upload-container hide" id="idOppositeImguploader" style="margin: 0 auto;">
                            <img src="" alt="img placeholder" id="idOppositeImgAdd">
                        </div>
                        <div style="width: 100%; text-align: center; color: #144856">企业负责人身份证正反面<p>复印件(加盖公章)</p></div>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 mb-10 pr-30">
                <label class="layui-form-label w-130"><i class="red">*</i>供应商地址：</label>
                <div class="layui-input-block ml-130">
                    <div class="layui-col-xs4 pr-20">
                        <select class="province" id="province" name="province" lay-verify="province" lay-filter="province" lay-search>
                            <option value="">请选择省</option>
                            <c:forEach items="${province}" var="pro">
                                <option value="${pro.columns.ProvinceName}" title="${pro.columns.ProvinceID}" <c:if test="${apply.province == pro.columns.ProvinceName}">selected</c:if>>${pro.columns.ProvinceName}</option>
                            </c:forEach>
                        </select>
                    </div>
                    <div class="layui-col-xs4 pr-20">
                        <select class="city" name="city" id="city" lay-verify="city" lay-filter="city" lay-search>
                            <option value="">请选择市</option>
                            <c:forEach items="${city}" var="cityList">
                                <option value="${cityList.columns.CityName}" title="${cityList.columns.CityID}" <c:if test="${apply.city==cityList.columns.CityName}">selected</c:if>>${cityList.columns.CityName}</option>
                            </c:forEach>
                        </select>
                    </div>
                    <div class="layui-col-xs4">
                        <select class="area" name="area" id="area" lay-verify="area" lay-filter="area" lay-search>
                            <option value="">请选择县/区</option>
                            <c:forEach items="${area}" var="areaList">
                                <option value="${areaList.columns.DistrictName}" <c:if test="${apply.area==areaList.columns.DistrictName}">selected</c:if>>${areaList.columns.DistrictName}</option>
                            </c:forEach>
                        </select>
                    </div>
                    <div class="layui-col-xs12 mt-20">
                        <input type="text" id="address" name="address" lay-verify="address" class="layui-input layui-col-lg2"
                               value="${apply.address}">
                    </div>

                </div>
            </div>
                <div class="layui-col-xs12 mb-15 pr-30">
                    <label class="layui-form-label w-130">相关资质：</label>
                    <div class="layui-input-block ml-130">
                        <div id="licenseImgDiv">
                            <c:if test="${not empty apply.licenseImg}">
                                <c:forEach var="item" items="${fn:split(apply.licenseImg, ',')}">
                                    <div class="bj-img imgSpan">
                                        <img src="${commonStaticImgPath}${item}" height="700" width="1200"/>
                                        <input type="hidden" class="imgPicker" value="${item}"/> </div>
                                </c:forEach>
                            </c:if>
                        </div>
                    </div>
                </div>
           <%-- <div class="layui-col-xs12 mb-15 pr-30">
                <label class="layui-form-label w-130">备注：</label>
                <div class="layui-input-block ml-130">
                    <input type="text" name="remarks" autocomplete="off" placeholder="" class="layui-input" value="${apply.remarks}">
                </div>
            </div>--%>
            <%--<div class="layui-col-xs12 mb-15 pr-30 ">
                <label class="layui-form-label w-100">备注：</label>
                <div class="layui-input-block">
                    <c:choose>
                        <c:when test="${from eq 'audit'}">
                            <input type="text" name="content" id="auditRemarks" autocomplete="off" placeholder="" class="layui-input" value="">
                        </c:when>
                        <c:otherwise>
                            <input type="text" autocomplete="off" placeholder="" class="layui-input layui-bg-gray" disabled value="${apply.content}">
                        </c:otherwise>
                    </c:choose>

                </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 ml-130">
                            <input type="text" name="content" id="auditRemarks" autocomplete="off" placeholder="" class="layui-input" value="">
                        </div>
                    </div>

                </c:if>

            </div>
           <%-- <div class="layui-tab-item licheng">
                <ul class="layui-timeline" id="licheng">
                </ul>
            </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.creator}
                </div>
                <div class="layui-col-xs4">
                    所属部门：${apply.departmentName}
                </div>
                <div class="layui-col-xs4">
                    申请时间：<fmt:formatDate value="${apply.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
                </div>
            </div>
            <div style="height: 20px"></div>


            <input type="hidden" name="id" id="id" value="${apply.id}">
            <input type="hidden" name="certificationImg" id="certificationImg" value="${apply.certificationImg}">
            <input type="hidden" name="licenseImg" id="licenseImg" value="${apply.licenseImg}">
            <input type="hidden" name="idFrontImg" id="idFrontImg" value="${apply.idFrontImg}">
            <input type="hidden" name="idOppositeImg" id="idOppositeImg" value="${apply.idOppositeImg}">
            <input type="hidden" name="taskId" id="taskId" value="${apply.taskId}">
            <input type="hidden" id="processInstanceId" value="${apply.processInstanceId}">
            <input type="hidden" id="status" value="${apply.status}">
        <div class="layui-col-xs12 mb-20 pr-30 mt-20">
        </div>

        <div class="layui-form-item operate-footer" style="text-align: center;">
            <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>
<%--<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/layui/data.js"></script>
<script src="${ctxPlugin}/lib/xm-select.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 imgs='';
    var myreg=/^[1][3,4,5,6,7,8,9][0-9]{9}$/;
    var reg = /^(\d{2})(\d{4})(\d{4})(\d{2})(\d{2})\d{2}(\d)(\d|X)$/;
    var shuzi = /^\d+(\.\d+)?$/;
    layui.use(['form', 'table', 'upload', 'jquery','element'], function () {
        $ = layui.jquery;
        form = layui.form;
        upload = layui.upload;
        $form = $('form');
        var table = layui.table;
        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');
           /* if(data.index==1){
                var htsks = $("#licheng").html();
             /!*   if(!isBlank(htsks)){
                    return ;
                }*!/
                var len=$("#licheng li").length;
                console.log("leng"+len);
                if(len==0){
                    var processInstanceId=$("#processInstanceId").val();
                    var status=$("#status").val();
                    $.ajax({
                        type:"POST",
                        url:"${ctx}/set/process/getBpmnModel",
                        data:{
                            processInstanceId:processInstanceId,
                            status:status,
                        },
                        success:function(res){
                            if(res.code=="200"){
                                var str=res.data;
                                var ht='';
                                for(var i=0;i<str.length;i++){
                                    var taski = str[i];
                                    ht+='<li class="layui-timeline-item">';
                                    ht+='<i class="layui-icon layui-timeline-axis">&#xe63f;</i>';
                                    ht+='<div class="layui-timeline-content layui-text">';
                                    if(taski.status=='3'){
                                        ht+='<h3 class="layui-timeline-title fontColor1">'+taski.taskName+'</h3>'
                                        ht+='<p class="fontColor1">'+taski.approveUserName+'</p>';
                                    }else{
                                        ht+='<h3 class="layui-timeline-title">'+taski.taskName+'</h3>'
                                        ht+='<p>'+taski.approveUserName+'</p>';
                                    }
                                    ht+='</div>'
                                    ht+='</li>';
                                }

                                $("#licheng").html(ht);
                            }
                        },
                    }) ;
                }
            }*/

        });

        table.init('parse-table-demo',{
            height: 75
        })

        // from=audit是审核，否则是查看
        if ('${from}' !== 'audit') {
            $('select').prop('disabled', true);
            form.render('select');
            $('.layui-input').addClass('layui-bg-gray').prop('readonly', true);
            $('.layui-icon-close').remove();
        }

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

        //通过
        $("#approve").click(function (){
            var index= layer.load(2, {shade: [0.5,'#fff'], content:''});
            var id=$("#id").val();
            var taskId=$("#taskId").val();
            var content=$("#auditRemarks").val();
           /* if(isBlank(content)){
                layer.msg("请输入审核备注",{icon:2});
                return false
            }*/
            $("#approve").attr("disabled","true");
            $.ajax({
                type:"POST",
                url:"${ctx}/flowpath/supplySupplierApply/examineTraderApply",
                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');
                    } else{
                        layer.msg(res.errMsg,{time:2000});
                        $("#approve").removeAttr("disabled");
                    }
                },complete: function () {
                    layer.close(index);
                },
                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}/flowpath/supplySupplierApply/rejectTask",
                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');
                    } else{
                        layer.msg(res.errMsg,{time:2000});
                        $("#back").removeAttr("disabled");
                    }
                },
                error:function (data) {
                }
            }) ;
        })

        materialTypeIdSelect = xmSelect.render({
            el: '#materialTypeId',
            name: 'materialTypeId',
            filterable: true,
            size: 'mini',
            model: {
                label: {
                    type: 'block',
                    block: {
                        //最大显示数量, 0:不限制
                        showCount: 2,
                        //是否显示删除图标
                        showIcon: true,
                    }
                }
            },
            toolbar: {
                show: true
            },
            height: '300px',
            data: [
                <c:forEach items="${materielTypeList}" var="trader" varStatus="vs">
                <c:if test="${vs.count > 1}">, </c:if>
                {name: '${trader.columns.name}', value: '${trader.columns.id}'}
                </c:forEach>
            ]
            , on: function (data) {
                var array = data.arr;
                var materialTypeId = [];
                for (var i = 0; i < array.length; i ++) {
                    materialTypeId.push(array[i].value);
                }
                $('input[name=materialTypeId]').val(materialTypeId.join(','));
            }
            <c:if test="${from ne 'audit'}">
            , disabled: true
            </c:if>
        });
        materialTypeIdSelect.setValue('${apply.materialTypeId}'.split(","));

    })





    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>
