MrDoc/template/app_doc/create_doctemp.html

87 lines
3.4 KiB
HTML

{% extends 'app_doc/create_base_2.html' %}
{% load staticfiles %}
{% block title %}新建文档模板{% endblock %}
{% block editor_type %}新建模板{% endblock %}
{% block head_toolbar %}
<a class="btn pull-left" aria-label="" href="{% url 'create_doc' %}?pid={{project.id}}" target="_blank">
<i class="fa fa-plus-square"></i> <span class="layui-hide-xs">新建模板</span>
</a>
<a class="btn pull-left" aria-label="" href="{% url 'manage_doctemp' %}?pid={{project.id}}" target="_blank">
<i class="fa fa-cubes"></i> <span class="layui-hide-xs">管理模板</span>
</a>
<a class="btn pull-left" aria-label="" href="{% url 'manage_project' %}" target="_blank">
<i class="fa fa-cubes"></i> <span class="layui-hide-xs">管理文集</span>
</a>
{% endblock %}
{% block left_opera %}
<div class="layui-form" style="padding: 10px;">
<div class="layui-row">
<div class="layui-col-md12" style="margin-bottom: 10px;">
<label class="doc-form-label">
<button class="layui-btn layui-btn-normal layui-btn-fluid" onclick="createDocTemp()">
<i class="fa fa-save"></i> 保存模板
</button>
</label>
</div>
</div>
<!-- 已有模板 -->
<div class="layui-row">
<div class="layui-card">
<div class="layui-card-header">现有模板</div>
<div class="layui-card-body">
{% for temp in doctemps %}
<li><a href="{% url 'modify_doctemp' temp.id %}" target="_blank" title="点击查看修改《{{temp.name}}》的内容"><i class="fa fa-file"></i> {{temp.name}}</a></li>
{% endfor %}
</div>
</div>
</div>
</div>
{% endblock %}
{% block content %}
<div class="create-doc-form">
<div class="layui-form" style="padding-bottom:10px;">
<div class="layui-input-block" style="margin-left:0px;">
<input type="text" name="doc-name" id="doctemp-name" required lay-verify="required" placeholder="请输入模板标题" autocomplete="off" class="layui-input">
</div>
</div>
</div>
<div id="editor-md">
<textarea style="display:none;"></textarea>
<textarea class="editormd-html-textarea" name="$id-html-code"></textarea>
</div>
{% endblock %}
{% block custom_script %}
<script>
//保存文档模板
createDocTemp = function(){
$('button.layui-btn').attr("disabled",true);
$('button.layui-btn').addClass('layui-btn-disabled');
layer.load();
var data = {
'name':$("#doctemp-name").val(),
'content':editor.getMarkdown(),
}
$.post("{% url 'create_doctemp' %}",data,function(r){
if(r.status){
//创建成功
layer.closeAll("loading");
layer.msg('保存成功',function(){
md_changed = false;
window.location.href = "{% url 'manage_doctemp' %}";
});
}else{
//创建失败
layer.closeAll("loading");
layer.msg('保存失败');
$('button.layui-btn').attr("disabled",false);
$('button.layui-btn').removeClass('layui-btn-disabled');
}
});
};
</script>
{% endblock %}