TaoLer/app/admin/view/content/cate/edit.html

183 lines
7.2 KiB
HTML
Raw Normal View History

2023-03-16 22:40:15 +08:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>修改页面</title>
<link rel="stylesheet" href="/static/component/pear/css/pear.css" />
</head>
<body>
<form class="layui-form" action="">
<div class="mainBox">
<div class="main-container">
<div class="layui-form-item">
<label class="layui-form-label">上级分类</label>
<div class="layui-input-block">
<div id="menuSelectBox" class="ew-xmselect-tree"></div>
</div>
</div>
<label class="layui-form-label">所属应用</label>
<div class="layui-input-block">
<select name="appname" lay-filter="appname" lay-verify="required">
{volist name="appname" id="vo"}
<option value="{$vo}" {if($vo == $cate.appname)} selected {/if}>{$vo}</option>
{/volist}
</select>
</div>
<div class="layui-form-item">
<label class="layui-form-label">分类名</label>
<div class="layui-input-block">
<input type="text" name="catename" lay-verify="required" value="{$cate.catename}" placeholder="分类名*" autocomplete="off" class="layui-input">
</div>
<label class="layui-form-label">EN别名</label>
<div class="layui-input-block">
<input type="text" name="ename" lay-verify="required" value="{$cate.ename}" placeholder="英文名*" autocomplete="off" class="layui-input">
</div>
<label class="layui-form-label">图标</label>
<div class="layui-input-block">
<input type="text" name="icon" placeholder="图标*" value="{$cate.icon}" id="iconPicker" lay-filter="iconPicker" style="display:none;" class="layui-input">
</div>
<label class="layui-form-label">详情页模板</label>
<div class="layui-input-block">
<select name="detpl" id="tpl" lay-verify="required">
{volist name="template" id="vo"}
<option value="{$vo}" {if($vo == $cate.detpl)} selected {/if} >{$vo}</option>
{/volist}
</select>
</div>
<label class="layui-form-label">描述</label>
<div class="layui-input-block">
<input type="text" name="desc" lay-verify="required" value="{$cate.desc}" placeholder="描述*" autocomplete="off" class="layui-input">
</div>
<label class="layui-form-label">排序</label>
<div class="layui-input-block">
<input type="text" name="sort" lay-verify="number|required" value="{$cate.sort}" placeholder="请填数字" autocomplete="off" class="layui-input">
</div>
<div class="layui-input-block layui-hide">
<input type="text" name="id" lay-verify="number|required" value="{$cate.id}" placeholder="请填数字" autocomplete="off" class="layui-input">
</div>
</div>
</div>
</div>
<div class="bottom">
<div class="button-container">
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="cate-save">
<i class="layui-icon layui-icon-ok"></i>
提交
</button>
<button type="reset" class="pear-btn pear-btn-sm">
<i class="layui-icon layui-icon-refresh"></i>
重置
</button>
</div>
</div>
</form>
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<script>
layui.use(['form', 'iconPicker', 'xmSelect',], function(){
var $ = layui.jquery
,form = layui.form ;
var iconPicker = layui.iconPicker;
var xmSelect = layui.xmSelect;
var initPid = "{$cate.pid}";
//初始化图标选择
iconPicker.render({
elem: '#iconPicker',
type: 'fontClass',
search: false,
page: true,
limit: 12,
click: function (data) {
//console.log(data);
}
});
form.on('submit(cate-save)', function(data) {
$.ajax({
url: "{:url('content.cate/edit')}",
data: JSON.stringify(data.field),
dataType: 'json',
contentType: 'application/json',
type: 'post',
success: function(result) {
if (result.code === 0) {
layer.msg(result.msg, {
icon: 1,
time: 1000
}, function() {
parent.layer.close(parent.layer.getFrameIndex(window
.name)); //关闭当前页
parent.layui.table.reload("cate-table");
});
} else {
layer.msg(result.msg, {
icon: 2,
time: 1000
});
}
}
})
return false;
});
// 根据应用名动态选择应用下模板
form.on('select(appname)', function(data){
var appName = data.value;
$("#tpl").children('option').remove();
$.post("{:url('content.cate/getAppNameView')}", {appname:appName},function (res){
var str = '<option value="" >请选择</option>';
for(var i=0; i < res.data.length; i++ ) {
str += '<option value="'+ res.data[i] +'" >' + res.data[i] + '</option>';
// $("select[name='detpl']").append('<option value="'+ arr[i] +'" >' + arr[i] + '</option>');
}
$("#tpl").append(str);
// 动态select重新渲染
form.render('select');
})
});
(function (){
//分类菜单结构
$.ajax({
type: "get",
url: "{:url('content.forum/getCateTree')}",
success: function(res){
var data = res.data;
// 渲染下拉树
xmSelect.render({
el: '#menuSelectBox',
name: 'pid',
height: '250px',
layVerify: 'required',
layVerType: 'tips',
data: data,
initValue: [initPid],
model: {label: {type: 'text'}},
prop: {
name: 'catename',
value: 'id'
},
radio: true,
clickClose: true,
tree: {
show: true,
indent: 15,
strict: false,
expandedKeys: true
},
tips: '请选择上级菜单'
});
}
});
})()
})
</script>
</body>
</html>