<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE HTML>
<html>
<head>
  <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">
  <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/dist/viewer.css" media="all">
  <style>
    html {background-color: #fff;padding-bottom: 50px;}td, th {text-align: center !important;}
    .layui-btn-danger {
      background-color: #0a6597;
    }
    .layui-tab{position: relative}
    a.gl-btn{position: absolute; top: 10px; right: 20px; background: #0a6597; padding: 0 10px; color: #FFF;}
    .layui-card{margin-bottom: 0px}
    .layui-form-select dl{max-height: 230px}
  </style>
</head>

<body>
<div class="layui-form">
  <div class="layui-card-body layui-col-xs12" id="LAY_app">
    <blockquote class="layui-elem-quote">发票信息</blockquote>
    <div class="layui-card">
      <div class="layui-card-body">
        <div class="layui-row layui-col-space12 layui-form-item">
          <input type="hidden" id="releCode" class="layui-input" value="${releCode}">
          <input type="hidden" id="id" class="layui-input" value="${id}">
          <div class="layui-inline layui-col-md3 layui-col-sm3">
            <label class="layui-form-label w-130">发票代码：</label>
            <div class="layui-input-block">
              <input type="text" autocomplete="off" id="invoiceCode" class="layui-input" value="${invoice.invoiceCode}" readonly>
            </div>
          </div>
          <div class="layui-inline layui-col-md3 layui-col-sm3">
            <label class="layui-form-label w-130">发票号码：</label>
            <div class="layui-input-block">
              <input type="text" autocomplete="off" id="invoiceNumber" class="layui-input" value="${invoice.invoiceNumber}" readonly>
            </div>
          </div>
          <div class="layui-inline layui-col-md3 layui-col-sm3">
            <label class="layui-form-label w-130">发票名称：</label>
            <div class="layui-input-block">
              <input id="invoiceName" value="${invoice.invoiceName}"  class="layui-input" readonly>
            </div>
          </div>
          <div class="layui-inline layui-col-md3 layui-col-sm3">
            <label class="layui-form-label w-130">开票时间：</label>
            <div class="layui-input-block">
              <input id="invoiceDate" value="${invoice.invoiceDate}"  class="layui-input" readonly >
            </div>
          </div>
          <div class="layui-inline layui-col-md3 layui-col-sm3">
            <label class="layui-form-label w-130">发票金额：</label>
            <div class="layui-input-block">
              <input id="invoiceAmount" value="${invoice.invoiceAmount}"  class="layui-input" readonly>
            </div>
          </div>
          <div class="layui-inline layui-col-md3 layui-col-sm3">
            <label class="layui-form-label w-130">开票税率：</label>
            <div class="layui-input-block">
              <input id="invoiceTax" value="${invoice.invoiceTax}"  class="layui-input" readonly>
            </div>
          </div>
          <div class="layui-col-xs12 mb-10 pr-30">
            <div class="layui-form-item">
              <label class="layui-form-label w-130">订单备注：</label>
              <div class="layui-input-block ">
                <textarea name="remark" class="layui-textarea" style="min-height: 60px" readonly>${invoice.remark}</textarea>
              </div>
            </div>
          </div>
          <div class="layui-row">
            <div class="layui-inline layui-col-xs12">
              <label class="layui-form-label"><i class="mark">*</i>文件：</label>
              <div class="layui-input-block img-box ml-120">
                <div style="display: flex">
                  <div id="insuranceFilesDiv">
                    <c:forEach items="${fn:split(invoice.invoiceFile,',')}" var="img">
                      <div style="margin-top: 5px">
                        <a style="color:#2890ac;" target="_blank" onclick="previewUrl('${img}')" class="download-link">${fn:substring(img,img.lastIndexOf("/")+1 ,img.length() )}</a>
                        <input type="hidden" class="insuranceFiles" value="${img}">
                      </div>
                    </c:forEach>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="layui-form-item operate-footer" style="text-align: center;">
      <input type="button"  class="layui-btn layui-btn-primary" value="返回" onclick="closeDiv();">
    </div>
  </div>
</div>

<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/xm-select.js"></script>
<script src="${ctxPlugin}/lib/base64.js"></script>
<script type="text/javascript">
  //初始数据
  var $form;
  var form;
  var $;
  var imgs = '';
  var myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
  var matypeList ;
  layui.config({
    base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['form', 'layedit', 'laydate', 'jquery', 'upload','layer'], function () {
    $ = layui.jquery;
    form = layui.form;
    $form = $('form');
    var upload = layui.upload;
    laydate = layui.laydate;

  })



  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;
  }
  function delImg(that, id) {
    $("#" + id).show();
    $(that).parent().remove();
  }

  function previewUrl(_url) {
    if (!checkUrl(_url)) {
      return false;
    }
    var base = new Base64();
    var b64Encoded = base.encode(_url);
    if(_url.endsWith('pdf')){
      window.open('http://47.98.203.224:8012/onlinePreview?url=' + encodeURIComponent(b64Encoded)+'&officePreviewType=pdf');
    }else{
      window.open('http://47.98.203.224:8012/onlinePreview?url=' + encodeURIComponent(b64Encoded));
    }
  }

  function checkUrl(url) {
    //url= 协议://(ftp的登录信息)[IP|域名](:端口号)(/或?请求参数)
    var strRegex = '^((https|http|ftp)://)'//(https或http或ftp)
            + '(([\\w_!~*\'()\\.&=+$%-]+: )?[\\w_!~*\'()\\.&=+$%-]+@)?' //ftp的user@  可有可无
            + '(([0-9]{1,3}\\.){3}[0-9]{1,3}' // IP形式的URL- 3位数字.3位数字.3位数字.3位数字
            + '|' // 允许IP和DOMAIN（域名）
            + '(localhost)|'	//匹配localhost
            + '([\\w_!~*\'()-]+\\.)*' // 域名- 至少一个[英文或数字_!~*\'()-]加上.
            + '\\w+\\.' // 一级域名 -英文或数字  加上.
            + '[a-zA-Z]{1,6})' // 顶级域名- 1-6位英文
            + '(:[0-9]{1,5})?' // 端口- :80 ,1-5位数字
            + '((/?)|' // url无参数结尾 - 斜杆或这没有
            + '(/[\\w_!~*\'()\\.;?:@&=+$,%#-]+)+/?)$';//请求参数结尾- 英文或数字和[]内的各种字符
    var re = new RegExp(strRegex, 'i');//i不区分大小写
    //将url做uri转码后再匹配，解除请求参数中的中文和空字符影响
    if (re.test(encodeURI(url))) {
      return (true);
    } else {
      return (false);
    }
  }
</script>
</body>
</html>
