<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>初始化库存</title>
  <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" type="text/css" href="${ctxPlugin}/static/css/reset.css" />
  <link rel="stylesheet" type="text/css" href="${ctxPlugin}/lib/font/iconfont.css" />
  <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/formSelects-v4.css" media="all">
  <style>
    html{
      background-color: #fff;
    }

    @font-face {
      font-family: 'iconfont';
      src: url('${ctxPlugin}/lib/font/iconfont.eot');
      src: url('${ctxPlugin}/lib/font/iconfont.eot?#iefix') format('embedded-opentype'),
      url('${ctxPlugin}/lib/font/iconfont.woff2') format('woff2'),
      url('${ctxPlugin}/lib/font/iconfont.woff') format('woff'),
      url('${ctxPlugin}/lib/font/iconfont.ttf') format('truetype'),
      url('${ctxPlugin}/lib/font/iconfont.svg#iconfont') format('svg');
    }

    .layui-tab-title li {
      background-color:#f2f2f2;
      line-height: 40px;
    }
    .layui-tab-title .layui-this {
      background-color: #fff;
    }
    .layui-table td, .layui-table th {
      text-align: center;
    }
    tr {
      overflow: hidden;
      white-space: nowrap; /* 避免换行 */
    }
    td {
      text-overflow: ellipsis; /* 超出部分用省略号表示 */
      width: 100px;
    }

  </style>
</head>
<body>
<script>

</script>
<div class="layui-form mb-0 pr-15" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin">
  <div class="layui-card">
    <div id="textDiv" class="layui-card-body">
      <div class="layui-col-xs6 mb-15 mt-20">
        <label class="layui-form-label w-130">代理商名称：</label>
        <div class="layui-input-block">
          <input type="text" name="name" id="daili" class="layui-input layui-bg-gray" value="${trader.name}" disabled>
        </div>
      </div>
      <div class="layui-col-xs12 mb-15 mt-20">
        <div>




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

    <input type="hidden" name="regionName" id="regionName">
  </div>


  <div class="layui-form">
 <div class="layui-col-lg4 layui-col-sm4">
    <label class="layui-form-label">仓库名称：</label>
    <div class="layui-input-block">
      <select class="layui-input-block pos-r"  name="projectList" id="projectId" lay-filter="projectId" lay-search>
        <option value="">请选择初始化仓库:</option>
        <c:forEach items="${areaList}" var="pro">
          <option value="${pro.getStr("id")}">${pro.getStr("name")}</option>
        </c:forEach>
      </select>
    </div>
  </div>
  </div>

 <%-- <div class="layui-form">
    <div id="textDiv2" class="layui-card-body">
      <label class="layui-form-label w-130">仓库名称：</label>
      <div class="layui-input-block ml-130">
        <div class="layui-col-xs5 pr-10">
          <select id="projectId" name="projectId" lay-search="" lay-filter="projectId" xm-select="projectId" xm-select-type="2" xm-select-height="25px" xm-select-show-count="4" >
            <option value="">请选择初始化仓库</option>
            <c:forEach items="${areaList}" var="pro">
              <option  value="${pro.getStr("pid")}">${pro.getStr("name")}</option>
            </c:forEach>
          </select>
        </div>
      </div>
    </div>
  </div>--%>
  <script>

  </script>

  <div class="layui-form-item text-c operate-footer" >
    <button class="layui-btn " lay-submit lay-filter="component-form-element" &lt;%&ndash; onclick="save()" &ndash;%&gt;>保存</button>
    <button class="layui-btn layui-btn-primary" onclick="cancel()">关闭</button>
  </div>
</div>

<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/lib/formSelects-v4.js"></script>
<script src="${ctxPlugin}/lib/font/iconfont.js"></script>

<script>


  base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
  layui.config({
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['form','jquery'], function () {
           $ = layui.$,
            form = layui.form

    $(".layui-tab-title li").click(function (data) {
      $('.layui-tab-item').eq($(this).index()).addClass('layui-show').siblings('.layui-tab-item').removeClass('layui-show');
      $(".layui-tab-title li").removeClass("layui-this");
      $(this).addClass("layui-this");
      $(".tableTitle").eq($(this).index()).removeClass("layui-hide").siblings('.tableTitle').addClass('layui-hide');
    })

    form.on('select(projectId)',function(data){
      $("#projectId").val(data.value);
      console.log(data.value);
    })



  });


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

  function cancel(){
    var index = parent.layer.getFrameIndex(window.name);
    parent.layer.close(index);
  }



  function save(){
    var pid=$("#projectId").val();
    var url = '${ctx}/inventory/initiMethod?warehouse_id='+pid+'&id='+'${id}';
    $.ajax({
      url: url,
        success: function(data) {
      type: 'get'
        if(data.code === "200"){
          var index = parent.layer.getFrameIndex(window.name);
          layer.msg('操作成功！', {icon:1,time:1000},function(){
              cancel();
          })
        }else if(data.code ==="501"){
          layer.msg(data.msg,{icon:5,anim:6});
        }else{
          layer.msg("添加失败！",{icon:5,anim:6});
        }
      },
      complete:function(){

      }
    });
  }
</script>
</body>
</html>