forked from mirror/MrDoc
83 lines
3.4 KiB
HTML
83 lines
3.4 KiB
HTML
{% extends 'app_doc/create_base.html' %}
|
|
{% load staticfiles %}
|
|
{% block title %}修改文档{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="create-doc-form">
|
|
<div class="layui-form">
|
|
<label class="layui-form-label">文档标题</label>
|
|
<div class="layui-input-inline">
|
|
<input type="text" name="doc-name" id="doc-name" required lay-verify="required" placeholder="请输入文档标题" value="{{ doc.name }}" class="layui-input" >
|
|
</div>
|
|
<label class="doc-form-label">所属文集</label>
|
|
<div class="layui-input-inline">
|
|
<select name="pro_id" lay-verify="required" lay-filter="project" id="project" disabled>
|
|
<option value="{{ project.id }}">{{ project.name }}</option>
|
|
</select>
|
|
</div>
|
|
<label class="doc-form-label">上级文档</label>
|
|
<div class="layui-input-inline">
|
|
<select name="parent_id" lay-verify="required" id="parent-doc">
|
|
<option value="0"></option>
|
|
</select>
|
|
</div>
|
|
<label class="doc-form-label">
|
|
<button class="layui-btn layui-btn-primary">插入模板</button>
|
|
</label>
|
|
<label class="doc-form-label">
|
|
<button class="layui-btn layui-btn-normal" onclick="createDoc()">保存</button>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div id="editor-md">
|
|
<textarea style="display:none;">{{ doc.pre_content }}</textarea>
|
|
<textarea class="editormd-html-textarea" name="$id-html-code"></textarea>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block custom_script %}
|
|
<script>
|
|
//获取上级文档信息
|
|
$(function(){
|
|
var doc_parent_id = {{ doc.parent_doc }};
|
|
$.post('{% url 'get_pro_doc' %}',{'pro_id':$("#project").val()},function(r){
|
|
if(r.status){
|
|
//解析文集的下级文档
|
|
for(let i in r.data) {
|
|
console.log(doc_parent_id,r.data[i][2])
|
|
if(r.data[i][0] == doc_parent_id){
|
|
$("#parent-doc").append("<option value='"+r.data[i][0]+"' selected>"+r.data[i][3]+r.data[i][1]+"</option>")
|
|
}else{
|
|
$("#parent-doc").append("<option value='"+r.data[i][0]+"'>"+r.data[i][3]+r.data[i][1]+"</option>")
|
|
}
|
|
};
|
|
form.render();
|
|
}else{
|
|
layer.msg("获取下级文档失败!")
|
|
}
|
|
});
|
|
});
|
|
//保存文档
|
|
createDoc = function(){
|
|
var data = {
|
|
'doc_id':{{ doc.id }},
|
|
'project':$("#project").val(),
|
|
'parent_doc':$("#parent-doc").val(),
|
|
'doc_name':$("#doc-name").val(),
|
|
'content':editor.getHTML(),
|
|
'pre_content':editor.getMarkdown(),
|
|
}
|
|
$.post("{% url 'modify_doc' doc_id=doc.id %}",data,function(r){
|
|
if(r.status){
|
|
//创建成功
|
|
layer.msg('保存成功,即将跳转',function(){
|
|
window.location.href = "{% url 'doc' pro_id=doc.top_doc doc_id=doc.id %}";
|
|
});
|
|
}else{
|
|
//创建失败
|
|
layer.msg('保存失败');
|
|
}
|
|
});
|
|
};
|
|
</script>
|
|
{% endblock %} |