227 lines
8.7 KiB
HTML
227 lines
8.7 KiB
HTML
|
<!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" 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" placeholder="英文名*" autocomplete="off" class="layui-input">
|
||
|
</div>
|
||
|
<label class="layui-form-label">图标</label>
|
||
|
<div class="layui-input-block">
|
||
|
<input type="text" name="icon" placeholder="图标*" 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" 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" 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/add')}",
|
||
|
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: '请选择上级菜单'
|
||
|
});
|
||
|
|
||
|
|
||
|
// var demo4 = xmSelect.render({
|
||
|
// el: '#menuSelectBox',
|
||
|
// model: { label: { type: 'text' } },
|
||
|
// tree: {
|
||
|
// show: true,
|
||
|
// strict: false,
|
||
|
// expandedKeys: [ -1 ],
|
||
|
// },
|
||
|
// on: function(data){
|
||
|
// if(data.isAdd){
|
||
|
// return data.change.slice(0, 1)
|
||
|
// }
|
||
|
// },
|
||
|
// height: 'auto',
|
||
|
// })
|
||
|
|
||
|
// //这里模拟ajax
|
||
|
// setTimeout(function(){
|
||
|
// demo4.update({
|
||
|
// data: [
|
||
|
// {name: '销售员', value: -1, children: [
|
||
|
// {name: '张三', value: 100, children: []},
|
||
|
// {name: '李四1', value: 2},
|
||
|
// {name: '王五1', value: 3, disabled: true},
|
||
|
// ]},
|
||
|
// {name: '奖品', value: -2, children: [
|
||
|
// {name: '奖品3', value: -3, children: [
|
||
|
// {name: '苹果3', value: 14},
|
||
|
// {name: '香蕉3', value: 15},
|
||
|
// {name: '葡萄3', value: 16},
|
||
|
// ]},
|
||
|
// {name: '苹果2', value: 4, disabled: true},
|
||
|
// {name: '香蕉2', value: 5},
|
||
|
// {name: '葡萄2', value: 6},
|
||
|
// ]},
|
||
|
// ]
|
||
|
// })
|
||
|
|
||
|
// //设置默认值
|
||
|
// demo4.setValue([
|
||
|
// {name: '李四1', value: 2},
|
||
|
// {name: '苹果3', value: 14},
|
||
|
// ], null, true)
|
||
|
|
||
|
// }, 300)
|
||
|
|
||
|
}
|
||
|
|
||
|
});
|
||
|
})()
|
||
|
|
||
|
|
||
|
})
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|