nk-lihaink-cn/app/admin/view/slide/slide_info_add.html
2021-01-30 20:59:12 +08:00

121 lines
4.1 KiB
HTML

{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<form class="layui-form body-content">
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray2">标题<font>*</font>
</td>
<td>
<input type="hidden" name="id" value="{$id}" />
<input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="请输入标题" class="layui-input"
{notempty name="$slide_info.title" }value="{$slide_info.title}" {/notempty}>
</td>
<td class="layui-td-gray2">排序</td>
<td><input type="text" name="sort" placeholder="请输入排序,数字" autocomplete="off" class="layui-input" {notempty
name="$slide_info.sort" }value="{$slide_info.sort}" {/notempty}></td>
</tr>
<tr>
<td class="layui-td-gray2">链接<font>*</font>
</td>
<td>
<input type="text" name="src" autocomplete="off" placeholder="请输入链接" class="layui-input" {notempty
name="$slide_info.src" }value="{$slide_info.src}" {/notempty}>
</td>
<td class="layui-td-gray2" rowspan="2">图片</td>
<td rowspan="2">
<div class="layui-upload">
<button type="button" class="layui-btn layui-btn-normal" id="test1">上传图片</button>
<div class="layui-upload-list" id="demo1">
<img {notempty name="$slide_info.img" }src="{:get_file($slide_info.img)}" {/notempty}
style="max-height: 120px;" />
<input type="hidden" name="img" {notempty name="$slide_info.img" }value="{$slide_info.img}" {/notempty}>
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray2">状态<font>*</font>
</td>
<td>
{if condition="$id eq 0"}
<input type="radio" name="status" value="1" title="正常" checked>
<input type="radio" name="status" value="-1" title="禁用">
{else/}
<input type="radio" name="status" value="1" title="正常" {eq name="$slide_info.status" value="1" }checked{/eq}>
<input type="radio" name="status" value="-1" title="禁用" {eq name="$slide_info.status" value="-1" }checked{/eq}>
{/if}
</td>
</tr>
<tr>
<td class="layui-td-gray2">备注<font>*</font>
</td>
<td colspan="3">
<textarea name="desc" placeholder="请输入备注"
class="layui-textarea">{notempty name="$slide_info.desc" }{$slide_info.desc}{/notempty}</textarea>
</td>
</tr>
</table>
<div style="padding: 10px 0">
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
<button lay-event="back" class="layui-btn layui-btn-primary">返回</button>
</div>
</form>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
function init(layui) {
var form = layui.form
, layer = layui.layer
, upload = layui.upload;
//头像上传
var uploadInst = upload.render({
elem: '#test1'
, url: '/admin/api/upload'
, done: function (res) {
//如果上传失败
if (res.code == 0) {
return layer.msg('上传失败');
}
//上传成功
$('#demo1 input').attr('value', res.data.id);
$('#demo1 img').attr('src', res.data.filepath);
}
});
//监听提交
form.on('submit(webform)', function (data) {
$.ajax({
url: "/admin/slide/slide_info_submit",
type: 'post',
data: data.field,
success: function (e) {
if (e.code == 1) {
layer.confirm('保存成功,返回列表页吗?', { icon: 3, title: '提示' }, function (index) {
history.back(-1);
layer.close(index);
});
} else {
layer.msg(e.msg);
}
}
})
return false;
});
//监听返回
$('.body-content').on('click', '[lay-event="back"]', function () {
history.back(-1);
return false;
});
}
</script>
{include file="common/layui" base='base' extend="[]" use="['upload','form']" callback="init" /}
{/block}
<!-- /脚本 -->