2023-03-22 13:35:41 +08:00

240 lines
8.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{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>
{notempty name="is_vote"}
<tr>
<td class="layui-td-gray">结束时间<font>*</font></td>
<td colspan="7"> <input type="text" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" id="test1" name="end_time">
<input type="hidden" name="is_vote" value="1">
</td>
</tr>
{/notempty}
<tr>
<td class="layui-td-gray" style="vertical-align:top;">摘要</td>
<td colspan="3">
<textarea name="describe" placeholder="请输入摘要不能超过200个字"
class="layui-textarea">{$detail.describe}</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-sm" id="upload_btn_thumb">
上传缩略图(尺寸:640x360)
</button>
<div class="layui-upload-list" id="upload_box_thumb"
style="width: 120px; height:66px; overflow: hidden;">
<img src="{$detail.image}"
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
style="max-width: 100%; height:66px;"/>
<input type="hidden" name="image" value="{$detail.image}">
</div>
</div>
</td>
</tr>
{if {:session('gougu_admin')['group_access']==1}
<tr>
<td class="layui-td-gray" style="vertical-align:top;">区县</td>
<td colspan="3">
<div class="layui-col-md6">
<div >
<select name="county" lay-filter="area_id">
{volist name='street' id='vo'}
<option value="{$vo.code}" {if $detail.county==$vo.code} selected {/if}>{$vo.name}</option>
{/volist}
</select>
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="vertical-align:top;">街道/镇</td>
<td colspan="3">
<div class="layui-col-md6">
<div >
<div id="demo1" ></div>
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="vertical-align:top;">村/社区</td>
<td colspan="3">
<div class="layui-col-md6">
<div >
<div id="demo2" ></div>
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">用户<font>*</font></td>
<td colspan="3">
<div class="layui-col-md6">
<select name="user_id" lay-verify="required" lay-search="">
<option value="" >请选择</option>
{volist name='users' id='vo'}
<option value="{$vo.user_id}" {if $detail.user_id==$vo.user_id} selected {/if}>{$vo.name}</option>
{/volist}
</select>
</div>
</td>
</tr>
{/if}
<tr>
<td colspan="6" class="layui-td-gray" style="text-align:left">文章内容</td>
</tr>
<tr>
<td colspan="6">
<textarea placeholder="请输入内容" class="layui-textarea"
id="container_content">{$detail.content}</textarea>
</td>
</tr>
</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 src="/static/assets/js/xm-select.js"></script>
<script>
const editorType = '{$editor}';
var moduleInit;
if (editorType == 1) {
moduleInit = ['tool', 'tagpicker', 'tinymce'];
} else {
moduleInit = ['tool', 'tagpicker', 'editormd'];
}
var group_access = "{:session('gougu_admin')['group_access']}";
var area_id = "{$detail.county}";
var street_id = "{$detail.township}";
function gouguInit() {
var form =layui.form, tool = layui.tool,tagspicker = layui.tagpicker,laydate=layui.laydate;
laydate.render({
elem: '#test1' //指定元素
});
//上传缩略图
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.filepath);
$('#upload_box_thumb img').attr('src', res.data.filepath);
}
});
if (area_id != 0) {
street(area_id)
}
if (street_id != 0) {
village(street_id)
}
form.on('select(area_id)', function (data) {
street(data.value)
});
function street (id) {
var demo1 = xmSelect.render({
name: 'township',
el: '#demo1',
initValue: ["{$detail.township}"],
prop: {
name: 'name',
value: 'code',
},
data: [],
radio: true,
disabled: group_access == 2 ||group_access == 4? true : false,
on: function (data) {
var arr = data.arr;
if(arr.length > 0){
village(arr[0]['code']);
}else{
village();
}
},
})
$.get('/api/geo/street?pcode=' + id, function (result) {
demo1.update({
data: result.data
})
});
}
function village (id) {
var demo2 = xmSelect.render({
name: 'village',
el: '#demo2',
initValue: ["{$detail.village}"],
prop: {
name: 'name',
value: 'id',
},
data: [],
radio: true,
disabled: group_access == 2 ? true : false,
})
$.get('/api/geo/village?pcode=' + id, function (result) {
demo2.update({
data: result.data
})
});
}
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("{$url[2]}", data.field, callback);
return false;
});
}
</script>
{/block}
<!-- /脚本 -->