Init Repo

This commit is contained in:
root
2019-09-06 23:53:10 +08:00
commit f0ef89dfbb
7905 changed files with 914138 additions and 0 deletions

View File

@ -0,0 +1,234 @@
var grid;
$(function(){
$('#headTip').WSTTips({width:90,height:35,callback:function(v){
var diff = v?113:53;
}});
grid = $("#maingrid").WSTGridTree({
url:WST.U('admin/homemenus/pageQuery'),
pageSize:10000,
pageSizeOptions:10000,
height:'99%',
width:'100%',
minColToggle:6,
delayLoad :true,
rownumbers:true,
columns: [
{ display: '菜单名称', name: 'menuName', id:"menuId", isSort: false},
{ display: '菜单Url', name: 'menuUrl', isSort: false},
{ display: '菜单类型', name: 'menuType', width:80,isSort: false,render:function(rowdata, rowindex, value){
return (rowdata['menuType']==0)?'用户菜单':'商家菜单';
}},
{ display: '是否显示', name: 'isShow', width:80,isSort: false,render :function(item, rowindex, value){
return '<input type="checkbox" '+((item.isShow==1)?"checked":"")+' class="ipt" lay-skin="switch" lay-filter="isShow" data="'+item.menuId+'" lay-text="显示|隐藏">';
}},
{ display: '排序号', name: 'menuSort', width:60,isSort: false,render:function(rowdata,rowindex,value){
return '<span class="classSort" style="cursor:pointer;color:blue;" ondblclick="changeSort(this,'+rowdata["menuId"]+');">'+rowdata['menuSort']+'</span>';
}},
{ display: '操作', name: 'op',width:230,isSort: false,render: function (rowdata, rowindex, value){
var h = "";
if(WST.GRANT.QTCD_01)h += "<a class='btn btn-blue' href='javascript:toEdit(0," + rowdata['menuId'] + ","+rowdata['menuType']+")'><i class='fa fa-plus'></i>添加子菜单</a> ";
if(WST.GRANT.QTCD_02)h += "<a class='btn btn-blue' href='javascript:getForEdit("+rowdata["parentId"]+"," + rowdata['menuId'] + ")' href='"+WST.U('admin/homemenus/toEdit','menuId='+rowdata['menuId'])+"'><i class='fa fa-pencil'></i>修改</a> ";
if(WST.GRANT.QTCD_03)h += "<a class='btn btn-red' href='javascript:toDel("+rowdata["parentId"]+"," + rowdata['menuId'] + ")'><i class='fa fa-trash-o'></i>删除</a> ";
return h;
}}
],
callback:function(){
$('.classSort').poshytip({content:'双击修改排序号',showTimeout:0,hideTimeout:1,alignX: 'center',
offsetY: 10,timeOnScreen:1000,allowTipHover: false});
layui.form.render();
}
});
layui.form.on('switch(isShow)', function(data){
var id = $(this).attr("data");
if(this.checked){
toggleIsShow(id, 1);
}else{
toggleIsShow(id, 0);
}
});
})
var oldSort;
function changeSort(t,id){
if(!WST.GRANT.QTCD_02)return;
$(t).attr('ondblclick'," ");
var html = "<input type='text' id='sort-"+id+"' style='width:30px;padding:2px' onblur='doneChange(this,"+id+")' value='"+$(t).html()+"' />";
$(t).html(html);
$('#sort-'+id).focus();
$('#sort-'+id).select();
}
function doneChange(t,id){
var sort = ($(t).val()=='')?0:$(t).val();
if(sort==oldSort){
$(t).parent().attr('ondblclick','changeSort(this,'+id+')');
$(t).parent().html(parseInt(sort));
return;
}
$.post(WST.U('admin/homemenus/changeSort'),{id:id,menuSort:sort},function(data){
var json = WST.toAdminJson(data);
if(json.status==1){
$(t).parent().attr('ondblclick','changeSort(this,'+id+')');
$(t).parent().html(parseInt(sort));
}
});
}
function toDel(pid,menuId){
var box = WST.confirm({content:"删除该菜单会将下边的子菜单也一并删除,您确定要删除吗?",yes:function(){
var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
$.post(WST.U('admin/homemenus/del'),{menuId:menuId},function(data,textStatus){
layer.close(loading);
var json = WST.toAdminJson(data);
if(json.status=='1'){
WST.msg("操作成功",{icon:1});
layer.close(box);
grid.reload(pid);
}else{
WST.msg(json.msg,{icon:2});
}
});
}});
}
function edit(pid,menuId){
//获取所有参数
var params = WST.getParams('.ipt');
params.menuId = menuId;
var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
$.post(WST.U('admin/homemenus/'+((menuId==0)?"add":"edit")),params,function(data,textStatus){
layer.close(loading);
var json = WST.toAdminJson(data);
if(json.status=='1'){
WST.msg("操作成功",{icon:1});
loadGrid();
}else{
WST.msg(json.msg,{icon:2});
}
});
}
function toggleIsShow(menuId, isShow){
if(!WST.GRANT.QTCD_02)return;
$.post(WST.U('admin/homemenus/setToggle'), {'menuId':menuId, 'isShow':isShow}, function(data, textStatus){
var json = WST.toAdminJson(data);
if(json.status=='1'){
WST.msg("操作成功",{icon:1});
grid.reload(menuId);
}else{
WST.msg(json.msg,{icon:2});
}
})
}
function getForEdit(pid,menuId){
$('#menuForm')[0].reset();
var loading = WST.msg('正在获取数据,请稍后...', {icon: 16,time:60000});
$.post(WST.U('admin/homemenus/get'),{menuId:menuId},function(data,textStatus){
layer.close(loading);
var json = WST.toAdminJson(data);
if(json.menuId){
WST.setValues(json);
toEdit(json.menuId,pid);
}else{
WST.msg(json.msg,{icon:2});
}
});
}
function toEdit(menuId,parentId,tId){
var title = "编辑";
if(menuId==0){
$('#menuForm')[0].reset();
title = "新增";
WST.setValue('isShow',1);
}
if(parentId>0){
$('#menuTypes').hide();
}else{
$('#menuTypes').show();
}
if(tId==1){$('#menuType').val(1);}
layui.form.render();
var box = WST.open({title:title,type:1,content:$('#menuBox'),area: ['550px', '420px'],btn:['确定','取消'],
end:function(){$('#menuBox').hide();},yes:function(){
$('#menuForm').submit();
}});
$('#menuForm').validator({
fields: {
'menuName': {rule:"required;",msg:{required:'请输入菜单名称'}},
'menuUrl': {rule:"required;",msg:{required:'请输入菜单Url'}},
'menuSort': {rule:"required;integer",msg:{required:'请输入排序号',number:"请输入数字"}}
},
valid: function(form){
var params = WST.getParams('.ipt');
params.menuId = menuId;
params.parentId = parentId;
params.isShow = params.isShow?params.isShow:0;
var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
$.post(WST.U('admin/homemenus/'+((menuId==0)?"add":"edit")),params,function(data,textStatus){
layer.close(loading);
var json = WST.toAdminJson(data);
if(json.status=='1'){
WST.msg("操作成功",{icon:1});
$('#menuBox').hide();
$('#menuForm')[0].reset();
layer.close(box);
grid.reload(params.parentId);
}else{
WST.msg(json.msg,{icon:2});
}
});
}
});
}
function loadGrid(){
$("#maingrid").WSTGridTree({
url:WST.U('admin/homemenus/pageQuery',{menuType:$('#s_menuType').val()}),
pageSize:10000,
pageSizeOptions:10000,
height:'99%',
width:'100%',
minColToggle:6,
delayLoad :true,
rownumbers:true,
columns: [
{ display: '菜单名称', name: 'menuName', id:"menuId", isSort: false},
{ display: '菜单Url', name: 'menuUrl', isSort: false},
{ display: '菜单类型', name: 'menuType', width:80,isSort: false,render:function(rowdata, rowindex, value){
return (rowdata['menuType']==0)?'用户菜单':'商家菜单';
}},
{ display: '是否显示', name: 'isShow', width:80,isSort: false,render :function(item, rowindex, value){
return '<input type="checkbox" '+((item.isShow==1)?"checked":"")+' class="ipt" lay-skin="switch" lay-filter="isShow" data="'+item.menuId+'" lay-text="显示|隐藏">';
}},
{ display: '排序号', name: 'menuSort', width:60,isSort: false,render:function(rowdata,rowindex,value){
return '<span style="cursor:pointer;color:blue;" ondblclick="changeSort(this,'+rowdata["menuId"]+');">'+rowdata['menuSort']+'</span>';
}},
{ display: '操作', name: 'op',width:230,isSort: false,render: function (rowdata, rowindex, value){
var h = "";
if(WST.GRANT.QTCD_01)h += "<a class='btn btn-blue' href='javascript:toEdit(0," + rowdata['menuId'] + ","+rowdata['menuType']+")'><i class='fa fa-plus'></i>添加子菜单</a> ";
if(WST.GRANT.QTCD_02)h += "<a class='btn btn-blue' href='javascript:getForEdit("+rowdata["parentId"]+"," + rowdata['menuId'] + ")' href='"+WST.U('admin/homemenus/toEdit','menuId='+rowdata['menuId'])+"'><i class='fa fa-pencil'></i>修改</a> ";
if(WST.GRANT.QTCD_03)h += "<a class='btn btn-red' href='javascript:toDel("+rowdata["parentId"]+"," + rowdata['menuId'] + ")'><i class='fa fa-trash-o'></i>删除</a> ";
return h;
}}
],
callback:function(){
layui.form.render();
}
});
layui.form.on('switch(isShow)', function(data){
var id = $(this).attr("data");
if(this.checked){
toggleIsShow(id, 1);
}else{
toggleIsShow(id, 0);
}
});
}

View File

@ -0,0 +1,78 @@
{extend name="base" /}
{block name="css"}
<link rel="stylesheet" type="text/css" href="__ADMIN__/js/mmgrid/mmGrid.css?v={$v}" />
{/block}
{block name="js"}
<script src="__ADMIN__/js/wstgridtree.js?v={$v}" type="text/javascript"></script>
<script src="__ADMIN__/homemenus/homemenus.js?v={$v}" type="text/javascript"></script>
{/block}
{block name="main"}
<style>.mmGrid{border-bottom:0px;}</style>
<div id='alertTips' class='alert alert-success alert-tips fade in'>
<div id='headTip' class='head'><i class='fa fa-lightbulb-o'></i>操作说明</div>
<ul class='body'>
<li>本功能为开发者功能,主要用于设置电脑版买家和买家菜单,普通使用者请勿随意修改,以免影响系统使用。</li>
</ul>
</div>
<div class="wst-toolbar">
<select id='s_menuType' onchange='loadGrid()'>
<option value='-1'>菜单类型</option>
<option value='0'>用户菜单</option>
<option value='1'>商家菜单</option>
</select>
{if WSTGrant('QTCD_01')}
<button class="btn btn-success f-right" onclick="javascript:toEdit(0)"><i class='fa fa-plus'></i>新增</button>
{/if}
<div style="clear:both"></div>
</div>
<div class='wst-grid'>
<div class='mmGrid layui-form' id="maingrid"></div>
</div>
<div id='menuBox' style='display:none'>
<form id='menuForm'>
<table class='wst-form wst-box-top'>
<tr>
<th>菜单名称<font color='red'>*</font></th>
<td>
<input type="text" id="menuName" name="menuName" class="ipt" maxLength='20' />
</td>
</tr>
<tr>
<th>菜单Url<font color='red'>*</font></th>
<td>
<input type="text" id="menuUrl" name="menuUrl" class="ipt" maxLength='200' style='width:300px'/>
</td>
</tr>
<tr>
<th>附加资源:</th>
<td>
<textarea id="menuOtherUrl" name="menuOtherUrl" class="ipt" style='width:80%'></textarea>
</td>
</tr>
<tr id="menuTypes">
<th>菜单类型<font color='red'>*</font></th>
<td>
<select id="menuType" class="ipt">
<option value="0">用户菜单</option>
<option value="1">商家菜单</option>
</select>
</td>
</tr>
<tr>
<th>菜单排序<font color='red'>*</font></th>
<td>
<input type="text" id="menuSort" name="menuSort" class="ipt" maxLength='20' />
</td>
</tr>
<tr>
<th>是否显示<font color='red'> </font></th>
<td class="layui-form">
<input type="checkbox" id="isShow" name="isShow" value="1" class="ipt" lay-skin="switch" lay-filter="isShow1" lay-text="显示|隐藏">
</td>
</tr>
</table>
</form>
</div>
{/block}