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

<!--{if $a == "run"}-->
<div class="layui-fluid oe_fluid">

  <div class="oe_breadcrumb_box clearfix">
    <div class="layui-breadcrumb fl" lay-filter="breadcrumb" style="visibility: visible;">
      <a href="javascript:;">获客推广</a><span lay-separator="">/</span>
      <a href="javascript:;">营销管理</a><span lay-separator="">/</span>
      <a><cite>邮件模板</cite></a>
    </div>

  </div>
  <!--//Top End -->

  <div class="oe_table_wrap layui-form">
  
    <table class="layui-table">
      <thead>
        <tr>
          <th width="8%">ID</th>
          <th width="13%">类型</th>
          <th width="25%">标题</th>
          <th>内容</th>
          <th width="8%">操作</th>
        </tr> 
      </thead>
      
      <!--{if empty($mailtpl)}-->
      <tr>
        <td colspan="5" class="text_center">没有符合条件的信息</td>
      </tr>
      <!--{else}-->
      <!--{foreach $mailtpl as $volist}-->
      <tr>
        <td class="text_center"><!--{$volist.tplid}--></td>
        <td class="text_center"><!--{$volist.type}--></td>
        <td><!--{$volist.title}--></td>
        <td><!--{$volist.content|filterhtml:100}--></td>
        <td class="text_center">
          <div class="btn_box">
            <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=edit&id=<!--{$volist.tplid}-->&<!--{$comeurl}-->" class="layui-btn layui-btn-xs layui-btn-normal">编辑</a>
          </div>
        </td>
      </tr>
      <!--{/foreach}-->
      <!--{/if}-->
    </table>
    
    <div class="oe_page_box"><!--{$showpage}--></div>
    
  </div>
</div>
<!--{/if}-->

<!--{if $a == "edit"}-->
<div class="layui-fluid oe_fluid">

  <div class="oe_breadcrumb_box clearfix">
    <div class="layui-breadcrumb fl" lay-filter="breadcrumb" style="visibility: visible;">
      <a href="javascript:;">获客管理</a><span lay-separator="">/</span>
      <a href="javascript:;">营销管理</a><span lay-separator="">/</span>
      <a><cite>邮件模板</cite></a>
    </div>
    <div class="oe_tool_bar ft">
      <button class="layui-btn layui-btn-sm layui-btn-radius" id="but_submit_post2" lay-submit lay-filter="editform">
        编辑保存
        <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
      </button>
      <span class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius"><a href="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->">返回列表</a></span>
    </div>
  </div>
  
  <form class="layui-form" id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->" method="post">
  <input type="hidden" name="a" id="a" value="saveedit" />
	<input type="hidden" name="id" id="id" value="<!--{$id}-->" />
  <div class="layui-card">
    <div class="layui-card-header">编辑模板</div>
    <div class="layui-card-body">
      <table class="oe_tbl_form layui-form">
        <tr>
          <th width="15%">模板类型：</th>
          <td width="85%">
            <!--{$mailtpl.type}-->
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>邮件标题：</th>
          <td><input type="text" name="title" id="title" class="layui-input input-300" value="<!--{$mailtpl.title}-->" /></td>
        </tr>
        <tr>
          <th><font color="red">*</font>模板内容：</th>
          <td>
            <textarea name="content" id="content" class="layui-textarea" style="width:80%;height:300px;"><!--{$mailtpl.content}--></textarea>
            <span class="text_tip_inline">
              全局标签可用：{sitename}-网站名称，{siteurl}-网站URL
            </span>
          </td>
        </tr>
      </table>
      <!--{include file="<!--{$oetplpath}-->widget_editor.tpl"}-->
    </div>
  </div>
  </form>
  
  <div class="oe_tbl_form_btn">
    <button class="layui-btn" id="but_submit_post" lay-submit lay-filter="editform">
      编辑保存
      <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('submit(editform)', function(data){
            $obj_id = data.elem.getAttribute("id");
            if (!$("#"+$obj_id).hasClass("forbid_submit")) {
            
                if ($("#title").val().length  == 0) {
                    layer.msg("请填写标题");
                    return false;
                }
                if (OEeditor.html().length == 0) {
                  layer.msg("请填写内容");
                    return false;
                }
                
                $("#"+$obj_id).addClass("forbid_submit");
                if ($("#"+$obj_id).find("span").length > 0) {
                    $("#"+$obj_id).find("span").show();
                }
                $("#content").text(OEeditor.html());
                
                $("#myform").submit();
            }
        });   
    });
    
});
</script>
<!--{/if}-->

</body>
</html>