223 lines
7.5 KiB
HTML
223 lines
7.5 KiB
HTML
{extend name="common/base"/}
|
||
{block name="style"}
|
||
<style type="text/css">
|
||
.editormd-code-toolbar select {display: inline-block}
|
||
.editormd li {list-style: inherit;}
|
||
</style>
|
||
{/block}
|
||
<!-- 主体 -->
|
||
{block name="body"}
|
||
<form class="layui-form p-4">
|
||
<h3 class="pb-3">编辑文章表</h3>
|
||
<table class="layui-table layui-table-form">
|
||
<tr>
|
||
<td class="layui-td-gray">文章标题<font>*</font></td>
|
||
<td colspan="7"> <input type="text" name="title" lay-verify="required" lay-reqText="请输入文章标题"
|
||
autocomplete="off" placeholder="请输入文章标题" class="layui-input" value="{$detail.title}"></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="layui-td-gray">文章分类<font>*</font></td>
|
||
<td>
|
||
<select name="cate_id" lay-verify="required" lay-reqText="请选择分类">
|
||
<option value="">请选择分类</option>
|
||
{volist name=":set_recursion(get_article_cate())" id="v"}
|
||
<option value="{$v.id}" {eq name="$detail.cate_id" value="$v.id" }selected{/eq}>{$v.title}
|
||
</option>
|
||
{/volist}
|
||
</select>
|
||
</td>
|
||
<td class="layui-td-gray">关键字<font>*</font></td>
|
||
<td>
|
||
<input type="text" id="keyword_name" name="keyword_names" autocomplete="off" lay-verify="required"
|
||
lay-reqText="请选择关键字" placeholder="请选择关键字" class="layui-input" value="{$detail.keyword_names}"
|
||
readonly>
|
||
<input type="hidden" id="keyword_id" name="keywords_id" autocomplete="off"
|
||
value="{$detail.keyword_ids}">
|
||
</td>
|
||
<td class="layui-td-gray">状态<font>*</font></td>
|
||
<td>
|
||
<input type="radio" name="status" value="1" title="正常" {eq name="$detail.status" value="1"
|
||
}checked{/eq}>
|
||
<input type="radio" name="status" value="0" title="下架" {eq name="$detail.status" value="0"
|
||
}checked{/eq}>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="layui-td-gray">排序</td>
|
||
<td>
|
||
<input type="text" name="sort" placeholder="请输入排序,数字" autocomplete="off" class="layui-input"
|
||
value="{$detail.sort}">
|
||
</td>
|
||
<td class="layui-td-gray">首页显示</td>
|
||
<td>
|
||
<input type="radio" name="is_home" value="1" title="是" {eq name="$detail.is_home" value="1"
|
||
}checked{/eq}>
|
||
<input type="radio" name="is_home" value="0" title="否" {eq name="$detail.is_home" value="0"
|
||
}checked{/eq}>
|
||
</td>
|
||
<td class="layui-td-gray">属性</td>
|
||
<td>
|
||
<select name="type">
|
||
<option value="">请选择属性</option>
|
||
<option value="1" {eq name="$detail.type" value="1" }selected{/eq}>精华</option>
|
||
<option value="2" {eq name="$detail.type" value="2" }selected{/eq}>热门</option>
|
||
<option value="3" {eq name="$detail.type" value="3" }selected{/eq}>推荐</option>
|
||
</select>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="layui-td-gray">是否原创</td>
|
||
<td>
|
||
<input type="radio" name="original" value="1" title="是" {eq name="$detail.original" value="1"
|
||
}checked{/eq}>
|
||
<input type="radio" name="original" value="0" title="否" {eq name="$detail.original" value="0"
|
||
}checked{/eq}>
|
||
</td>
|
||
<td class="layui-td-gray">作者/来源</td>
|
||
<td>
|
||
<input type="text" name="origin" class="layui-input" autocomplete="off" placeholder="请输入文章来源"
|
||
value="{$detail.origin}">
|
||
</td>
|
||
<td class="layui-td-gray">来源链接</td>
|
||
<td>
|
||
<input type="text" name="origin_url" class="layui-input" autocomplete="off" placeholder="请输入来源链接"
|
||
value="{$detail.origin_url}">
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="layui-td-gray" style="vertical-align:top;">摘要</td>
|
||
<td colspan="3">
|
||
<textarea name="desc" placeholder="请输入摘要,不能超过200个字" class="layui-textarea">{$detail.desc}</textarea>
|
||
</td>
|
||
<td class="layui-td-gray" style="vertical-align:top;">缩略图</td>
|
||
<td>
|
||
<div class="layui-upload">
|
||
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm"
|
||
id="uploadBtn">上传缩略图(尺寸:480x272)</button>
|
||
<div class="layui-upload-list" id="demo1" style="width: 120px; height:66px; overflow: hidden;">
|
||
<img src="{:get_file($detail.thumb)}" onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;" style="max-width: 100%; height:66px;" />
|
||
<input type="hidden" name="thumb" value="{$detail.thumb}">
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
{eq name="$editor" value="1"}
|
||
<tr>
|
||
<td colspan="6" class="layui-td-gray" style="text-align:left">文章内容<font>*</font><span class="ml-4 red">当前为TinyMCE富文本编辑器,可在【系统管理->系统配置->其他配置】中切换为mardown编辑器</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td colspan="6">
|
||
<textarea placeholder="请输入内容" class="layui-textarea" id="container_content">{$detail.content}</textarea>
|
||
</td>
|
||
</tr>
|
||
{else/}
|
||
<tr>
|
||
<td colspan="6" class="layui-td-gray" style="text-align:left">文章内容<font>*</font><span class="ml-4 red">当前为mardown编辑器,可在【系统管理->系统配置->其他配置】中切换为TinyMCE富文本编辑器</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td colspan="6">
|
||
<div style="margin-top:-2px; margin-right:2px">
|
||
<textarea id="mdContent" style="display:none;">{$detail.md_content|raw}</textarea>
|
||
<div id="docContent"></div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
{/eq}
|
||
</table>
|
||
<div class="pt-3">
|
||
<input type="hidden" name="id" value="{$detail.id}"/>
|
||
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
|
||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||
</div>
|
||
</form>
|
||
{/block}
|
||
<!-- /主体 -->
|
||
|
||
<!-- 脚本 -->
|
||
{block name="script"}
|
||
<script>
|
||
const editorType = '{$editor}';
|
||
var moduleInit;
|
||
if (editorType == 1) {
|
||
moduleInit = ['tool', 'tagpicker', 'tinymce'];
|
||
}
|
||
else {
|
||
moduleInit = ['tool', 'tagpicker', 'editormd'];
|
||
}
|
||
|
||
function gouguInit() {
|
||
var form = layui.form, tool = layui.tool,tagpicker = layui.tagpicker;
|
||
|
||
var tags = new tagpicker({
|
||
'url': '/admin/api/get_keyword_cate',
|
||
'target': 'keyword_name',
|
||
'tag_ids': 'keyword_id',
|
||
'tag_tags': 'keyword_name',
|
||
'height': 500,
|
||
'isDiy': 1
|
||
});
|
||
|
||
//上传缩略图
|
||
var upload_thumb = layui.upload.render({
|
||
elem: '#upload_btn_thumb',
|
||
url: '/admin/api/upload',
|
||
done: function (res) {
|
||
//如果上传失败
|
||
if (res.code == 1) {
|
||
layer.msg('上传失败');
|
||
return false;
|
||
}
|
||
//上传成功
|
||
$('#upload_box_thumb input').attr('value', res.data.id);
|
||
$('#upload_box_thumb img').attr('src', res.data.filepath);
|
||
}
|
||
});
|
||
|
||
if (editorType == 1) {
|
||
var editor = layui.tinymce;
|
||
var edit = editor.render({
|
||
selector: "#container_content",
|
||
height: 500
|
||
});
|
||
//监听提交
|
||
form.on('submit(webform)', function (data) {
|
||
data.field.content = tinyMCE.editors['container_content'].getContent();
|
||
if (data.field.content == '') {
|
||
layer.msg('请先完善文章内容');
|
||
return false;
|
||
}
|
||
let callback = function (e) {
|
||
layer.msg(e.msg);
|
||
if (e.code == 0) {
|
||
tool.sideClose(1000);
|
||
}
|
||
}
|
||
tool.post("/admin/article/edit", data.field, callback);
|
||
return false;
|
||
});
|
||
}
|
||
else {
|
||
var editor = layui.editormd;
|
||
var edit = editor.render('docContent', {
|
||
markdown: document.getElementById('mdContent').value
|
||
});
|
||
//监听提交
|
||
form.on('submit(webform)', function (data) {
|
||
if (data.field.mdContent == '') {
|
||
layer.msg('请先完善文章内容');
|
||
return false;
|
||
}
|
||
let callback = function (e) {
|
||
layer.msg(e.msg);
|
||
if (e.code == 0) {
|
||
tool.sideClose(1000);
|
||
}
|
||
}
|
||
tool.post("/admin/article/edit", data.field, callback);
|
||
return false;
|
||
});
|
||
}
|
||
}
|
||
</script>
|
||
{/block}
|
||
<!-- /脚本 --> |