108 lines
3.2 KiB
HTML

{extend name="common/base" /}
<!-- 主体 -->
{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>
<select name="pid" lay-filter="storeBrandCategory" lay-search>
<option value="0" selected>顶级分类</option>
{volist name=":set_product_recursion(get_product_calss())" id="v"}
<option value="{$v.store_category_id}">{$v.cate_name} </option>
{/volist}
</select>
</td>
</tr>
<tr>
<td class="layui-td-gray">分类名称<font>*</font>
</td>
<td>
<input type="text" name="cate_name" lay-verify="required" autocomplete="off" placeholder="请输入分类名称"
lay-reqText="请输入分类名称" class="layui-input">
</td>
</tr>
<tr>
<td class="layui-td-gray">分类图片</td>
<td>
<div class="layui-upload">
<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb">上传缩略图(尺寸:110*110px)</button>
<div class="layui-upload-list" id="upload_box_thumb" style="width: 120px; height:66px; overflow: hidden;">
<img src="" onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;" width="100" style="max-width: 100%; height:66px;"/>
<input type="hidden" name="pic" value="">
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">排序</td>
<td>
<input type="text" name="sort" value="0" placeholder="请输入数字,越小越靠前" autocomplete="off"
class="layui-input">
</td>
<td>
<div class="layui-form-item">
<label class="layui-form-label">是否显示</label>
<div class="layui-input-block">
<input type="checkbox" name="is_show" lay-skin="switch">
</div>
</div>
</td>
</tr>
</table>
<div style="padding: 10px 0">
<input type="hidden" name="id" value="{$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>
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
function gouguInit() {
var form = layui.form,tool=layui.tool;
//上传缩略图
var upload_thumb = layui.upload.render({
elem: '#upload_btn_thumb',
url: '/admin/api/upload',
done: function (res) {
//如果上传失败
if (res.code == 1) {
return layer.msg('上传失败');
}
//上传成功
$('#upload_box_thumb input').attr('value', res.data.filepath);
$('#upload_box_thumb img').attr('src', res.data.filepath);
}
});
//监听提交
form.on('submit(webform)', function (data) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
setTimeout(function () {
parent.location.reload();
}, 1000);
}
}
tool.post("/admin/product.classify/add", data.field, callback);
return false;
});
}
</script>
{/block}
<!-- /脚本 -->