<%@ 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: #cd2323;
    }
    .bj-img{
      width: 50px;height: 50px;
    }
  </style>
</head>

<body>
<div class="layui-form">
  <div class="layui-card-body layui-col-xs12" id="LAY_app">
    <div class="layui-card-body">
      <input value="${detailRecord.columns.id}" hidden  id="id">
      <div class="layui-row layui-col-space12 layui-form-item mt-5">
        <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="${detailRecord.columns.trader_name}" 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="${detailRecord.columns.region_province}${detailRecord.columns.region_city}${detailRecord.columns.region_area}" disabled>
          </div>
        </div>
        <div class="layui-col-xs3">
          <label class="layui-form-label">质检单号：</label>
          <div class="layui-input-block">
            <input type="text" autocomplete="off"  class="layui-input layui-bg-gray" readonly  value="${detailRecord.columns.number}">
          </div>
        </div>
        <div class="layui-col-xs3">
          <label class="layui-form-label">质检人员：</label>
          <div class="layui-input-block">
            <input type="text" autocomplete="off"  class="layui-input layui-bg-gray" readonly  value="${detailRecord.columns.quality_emp_name}">
          </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="${detailRecord.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="<fmt:formatDate value="${acceptanceDetail.acceptTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" readonly>
          </div>
        </div>

        <hr class="layui-bg-gray" style="padding: 0px">
        <div class="layui-col-xs12">
          <label class="layui-form-label">验收结果：</label>
          <div class="layui-input-block" style="padding: 9px 0px;line-height: 17px">
            合格（<span style="color: red">${count.columns.rightCount}</span>）  整改（<span style="color: #0a84ff;">${count.columns.wrongCount}</span>）
          </div>
        </div>
      </div>
    </div>


    <div class="layui-card">
      <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title" lay-filter="changeTab" id="changeTabId">
          <li class="layui-this">整改项</li>
          <li>合格项</li>
        </ul>
        <div class="layui-card-body zgx">
          <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>检查类目</th>
                  <th>检查项目</th>
                  <th>结果</th>
                  <th>验收图片</th>
                  <th>验收说明</th>
                  <th>整改图片</th>
                  <th>整改说明</th>
                </tr>
                </thead>
                <tbody id="entryListBody">
                <c:if test="${not empty resultWrong}">
                  <c:forEach items="${resultWrong}" var="itemWrong">
                    <c:forEach var="item" items="${itemWrong.items}" varStatus="inx">
                      <tr>
                        <c:if test="${inx.count==1}">
                          <td rowspan="${fn:length(itemWrong.items)}">${itemWrong.groupName}</td>
                        </c:if>
                        <td>${item.columns.item_name}</td>
                        <td>${item.columns.result_desc}</td>
                        <td>
                          <c:if test="${not empty item.columns.img_path}">
                            <c:forEach items="${item.columns.img_path.split(',')}" var="img">
                              <div class="bj-img imgSpan">
                                <img src="${commonStaticImgPath}${img}" height="700" width="1200">
                              </div>
                            </c:forEach>
                          </c:if>
                        </td>
                        <td>${item.columns.test_remarks}</td>

                        <td>
                          <c:if test="${not empty item.columns.change_img}">
                            <c:forEach items="${item.columns.change_img.split(',')}" var="img">
                              <div class="bj-img imgSpan">
                                <img src="${commonStaticImgPath}${img}" height="700" width="1200">
                              </div>
                            </c:forEach>
                          </c:if>
                        </td>
                        <td><textarea class="layui-textarea">${item.columns.change_desc}</textarea></td>
                      </tr>
                    </c:forEach>
                  </c:forEach>
                </c:if>
                </tbody>
              </table>
            </div>
          </div>
        </div>
        <div class="layui-card-body hgx hide">
          <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>检查类目</th>
                  <th>检查项目</th>
                  <th>结果</th>
                  <th>验收图片</th>
                  <th>验收说明</th>
                </tr>
                </thead>
                <tbody>
                <c:if test="${not empty resultRight}">
                  <c:forEach items="${resultRight}" var="rightRes">
                    <c:forEach var="item" items="${rightRes.items}" varStatus="inx">
                      <tr>
                        <c:if test="${inx.count==1}">
                          <td rowspan="${fn:length(rightRes.items)}">${rightRes.groupName}</td>
                        </c:if>
                        <td>${item.columns.item_name}</td>
                        <td>${item.columns.result_desc}</td>
                        <td>
                          <c:if test="${not empty item.columns.img_path}">
                            <c:forEach items="${item.columns.img_path.split(',')}" var="img">
                              <div class="bj-img imgSpan">
                                <img src="${commonStaticImgPath}${img}" height="700" width="1200">
                              </div>
                            </c:forEach>
                          </c:if>

                        </td>
                        <td>${item.columns.test_remarks}</td>
                      </tr>
                    </c:forEach>
                  </c:forEach>
                </c:if>
                </tbody>
              </table>
            </div>
          </div>
        </div>
        <div class="layui-inline layui-col-xs12">
          <label class="layui-form-label w-130">验收意见：</label>
          <div class="layui-input-block ">
            <input type="text" id="changeAcceptRemarks" name="changeAcceptRemarks" class="layui-input" value="">
          </div>
        </div>
      </div>
    </div>
    <div class="layui-form-item operate-footer" style="text-align: center;">
      <button class="layui-btn pass">通过</button>
      <button class="layui-btn reject">驳回</button>
      <input type="button"   value="取消" class="layui-btn layui-btn-primary " onclick="closeDiv();" >
    </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 $;
  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', 'layer','element'], function () {
    $ = layui.jquery;
    form = layui.form;
    $form = $('form');
    var element = layui.element;


    $("#changeTabId li").on("click",function(){
      $("#changeTabId li").removeClass("layui-this");
      $(this).addClass("layui-this");
      if($(this).index() ==0 ) {
        $(".zgx").removeClass("hide");
        $(".hgx").addClass("hide");
      }else{
        $(".hgx").removeClass("hide");
        $(".zgx").addClass("hide");
      }
    })

    $('.pass').click(function(){
      var changeAcceptRemarks = $("#changeAcceptRemarks").val();
      var id = '${id}';
      $.ajax({
        type: 'post',
        url: '${ctx}/entryQuality/qualityRectification/saveAcceptQuality',
        data: {
          changeAcceptRemarks:changeAcceptRemarks,
          id:id,
          changeStatus:'5'
        },
        success: function (result) {
          console.log(result)
          if (result.code === '200') {
            layer.msg('操作成功！', {icon: 1, time: 2000}, function () {
              closeDiv();
              parent.reload();
            });
          } else {
            layer.msg('验收失败！' + result.errMsg);
          }
        }
      })
    });

    $('.reject').click(function(){
      var changeAcceptRemarks = $("#changeAcceptRemarks").val();
      if(isBlank(changeAcceptRemarks)){
        layer.msg("验收意见不可为空！",{icon:2});
        return;
      }
      var id = '${id}';
      $.ajax({
        type: 'post',
        url: '${ctx}/entryQuality/qualityRectification/saveAcceptQuality',
        data: {
          changeAcceptRemarks:changeAcceptRemarks,
          id:id,
          changeStatus: '4'
        },
        success: function (result) {
          if (result.code === '200') {
            layer.msg('操作成功！', {icon: 1, time: 2000}, function () {
              closeDiv();
              parent.reload();
            });
          } else {
            layer.msg('验收失败！' + result.errMsg);
          }
        }
      })
    });
  })

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

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

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


