<!--{include file="<!--{$oetplpath}-->block_head.tpl"}-->

<!--{if $a == "add2"}-->
<div class="layui-fluid oe_fluid" style="padding-top:10px;">

  <div class="layui-card">
    <div class="layui-card-header">编辑[<!--{$username}-->]会员等级</div>
    <div class="layui-card-body">
      <table class="oe_tbl_form layui-form">
        <tr style="display:none;">
          <th><font color="red"></font>用户UID：</th>
          <td>
            <input type="hidden" name="id" id="id" class="layui-input input-200" value="<!--{$id}-->" />
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font> 会员等级：</th>
          <td>
            <div class="tbl_input input-200">
              <!--{assign var="grouplist" value=vo_list("mod={group} where={v.flag='1'} orderby={v.orders ASC}")}-->
              <select name="groupid" id="groupid">
                <option value="">请选择</option>
                <!--{foreach $grouplist as $volist}-->
                <option value="<!--{$volist.groupid}-->"><!--{$volist.groupname}--></option>
                <!--{/foreach}-->
              </select>
            </div>
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font> 到期时间：</th>
          <td>
            <div class="tbl_input input-200">
              <input type="text" name="vipetime" id="vipetime" class="layui-input" value="" placeholder="请设置到期时间" />
            </div>
            <script type="text/javascript">
            layui.use('laydate', function(){
                $laydate = layui.laydate;
                $laydate.render({
                    elem: '#vipetime',
                    type: 'datetime'
                });
            });
            </script>
          </td>
        </tr>
        <tr>
          <th>其他：</th>
          <td>
            <input type="hidden" name="transpower" id="transpower" value="1" />
            <input type="checkbox" lay-skin="primary" name="checktrans" id="checktrans" value="1" lay-filter="checktrans" checked title="同步组权限" />
            <br />
            <span class="text_tip_inline">(同步组权限，将该会员所属当前选定组的全部权限打开)</span>
          </td>
        </tr>
      </table>
    </div>
  </div>

  
  <div class="oe_tbl_form_btn">
    <button class="layui-btn" id="but_submit_post" lay-submit lay-filter="submitform">
      完成
      <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
    </button>
  </div>
  
</div>

<script type="text/javascript">
$(function(){
    layui.use('form', function(){
        $form = layui.form;
        
        //选择
        $form.on('checkbox(checktrans)', function (e) {
            if (e.elem.checked) {
                $("#transpower").val('1');
            }
            else {
              $("#transpower").val('0');
            }
        
        });

        //保存...
        $form.on('submit(submitform)', function(data){
            $obj_id = data.elem.getAttribute("id");
            if (!$("#"+$obj_id).hasClass("forbid_submit")) {
            
            
                $id = $("#id").val();
                if ($id.length == 0) {
                    layer.msg("请输入用户UID");
                    return false;
                }
                $groupid = $("#groupid").val();
                if ($groupid.length == 0) {
                    layer.msg("请选择会员等级");
                    return false;
                }
                $vipetime = $("#vipetime").val();
                if ($vipetime.length == 0) {
                    layer.msg("请设置到期时间");
                    return false;
                }
                
                $transpower = $("#transpower").val();
                
                $("#"+$obj_id).addClass("forbid_submit");
                if ($("#"+$obj_id).find("span").length > 0) {
                    $("#"+$obj_id).find("span").show();
                }
                $.ajax({
                    type: "POST",
                    url: "<!--{$oefile}-->&c=<!--{$c}-->",
                    cache: false,
                    data: {
                        a:"saveedit2", id:$id, groupid:$groupid, vipetime:$vipetime, 
                        transpower:$transpower, datatype:"ajax", r:get_rndnum(8)
                    },
                    dataType: "json",
                    success: function(data) {
                        $json = eval(data);
                        $response = $json.response;
                        $result = $json.result;
                        if ($response == '1') {
                            layer.msg("操作成功");
                            setTimeout(function(){
                                window.parent.location.reload();
                            }, 800);
                        }
                        else {
                            if ($result.length > 0) {
                                layer.msg($result);
                            }
                            else {
                                layer.msg("操作失败");
                            }
                            $("#"+$obj_id).removeClass("forbid_submit");
                            if ($("#"+$obj_id).find("span").length > 0) {
                                $("#"+$obj_id).find("span").hide();
                            }
                        }
                        
                    },
                    error: function() {
                        layer.msg("系统繁忙，请稍后再试！");
                        $("#"+$obj_id).removeClass("forbid_submit");
                        if ($("#"+$obj_id).find("span").length > 0) {
                            $("#"+$obj_id).find("span").hide();
                        }
                    }
                });
                
                
            }
        });   
        
        
    });
    
});
</script>
<!--{/if}-->
</body>
</html>