<%@ 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;
    }
  </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>--%>
    <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-xs4">
          <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-xs4">
          <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-xs4">
          <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-xs4">
          <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>
    </div>
    <div class="layui-card">
      <div class="layui-card-body hasMsg">
        <table class="layui-hide" lay-skin="row" id="test" lay-filter="test"></table>
      </div>
    </div>
  </div>
</div>
<div class="operate-footer">
  <button class="layui-btn sureAdd">确认</button>
  <button class="layui-btn layui-btn-primary" onclick="cancel();">取消</button>
</div>
<script type="text/html" id="choose">
  <input type="radio" lay-skin="primary" name="choose" value="{{d.id}}" data-name="{{d.name}}"/>
</script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
      base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
      index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer', 'form'], function () {
      $ = layui.$;
      tableExt = layui.tableExt;
      layer = layui.layer;
      form = layui.form;
      table = tableExt.getLayTable();


      var traderId = '${traderId}';
      tableExt.render({
        elem: '#test'
        , height: 'full-160'
        , page : false //开启分页
        , url: '${ctx}/entryQuality/qualityRectification/getDispatchEmpList?traderId='+traderId
        , cols: [[
          {title: '序号', type: 'numbers'}
          , {field: 'name', title: '姓名', align: 'center', minWidth: 120}
          , {field: 'mobile', title: '联系电话', align: 'center', minWidth: 120}
          , {field: 'waitCount', title: '待整改电站', align: 'center', minWidth: 120}
          , {field: 'id', title: '选择', align: 'center', templet: '#choose', minWidth: 80, fixed: 'right'}
        ]],
        done: function(res){
        }
      });

      $('.sureAdd').click(function(){
        var empId = $('input[name = choose]:checked').val();
        var empName = $('input[name = choose]:checked').attr("data-name");
        var id = '${id}';
        if(isBlank(empId)){
          layer.msg('请选择质检员！');
          return;
        }
        var data = {};
        data.id = id;
        data.empId = empId;
        data.empName = empName;
        $.ajax({
          type: 'post',
          url: '${ctx}/entryQuality/qualityRectification/saveDispatchEmp',
          contentType: 'application/json',
          data: JSON.stringify(data),
          success: function (result) {
            if (result.code === '200') {
              layer.msg('操作成功！', {icon: 1, time: 2000}, function () {
                cancel();
                parent.reload();
              });
            } else {
              layer.msg('派工失败！' + result.errMsg);
            }
          }
        })
      });

    });


    function cancel() {
      var index = parent.layer.getFrameIndex(window.name);
      parent.layer.close(index);//关闭当前页
    }

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

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


