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,134 @@
var mmg;
$(function(){
var h = WST.pageHeight();
var cols = [
{title:'属性名称', name:'attrName', width: 10},
{title:'所属商品分类', name:'goodsCatNames', width: 160},
{title:'属性类型', name:'attrType', width: 5,renderer: function(val,item,rowIndex){
return (val==1)?'多选项':(val==2?'下拉框':'输入框');
}},
{title:'属性选项', name:'attrVal', width: 260},
{title:'是否显示', name:'attrVal', width: 20,renderer: function(val,item,rowIndex){
return '<input type="checkbox" '+((item['isShow']==1)?"checked":"")+' id="isShow1" name="isShow1" value="1" class="ipt" lay-skin="switch" lay-filter="isShow1" data="'+item['attrId']+'" lay-text="显示|隐藏">'
}},
{title:'排序号', name:'attrSort', width: 5},
{title:'操作', name:'' ,width:80, align:'center', renderer: function(val,item,rowIndex){
var h = "";
if(WST.GRANT.SPSX_02)h += "<a class='btn btn-blue' href='javascript:toEdit("+ item['attrId']+")'><i class='fa fa-pencil'></i>修改</a> ";
if(WST.GRANT.SPSX_03)h += "<a class='btn btn-red' href='javascript:toDel(" + item['attrId'] + ")'><i class='fa fa-trash-o'></i>删除</a> ";
return h;
}}
];
mmg = $('.mmg').mmGrid({height: h-85,indexCol: true, cols: cols,method:'POST',
url: WST.U('admin/attributes/pageQuery'), fullWidthRows: true, autoLoad: true,
plugins: [
$('#pg').mmPaginator({})
]
});
mmg.on('loadSuccess',function(data){
layui.form.render();
layui.form.on('switch(isShow1)', function(data){
var id = $(this).attr("data");
if(this.checked){
toggleIsShow(id, 1);
}else{
toggleIsShow(id, 0);
}
});
})
});
//------------------属性类型---------------//
function toEdit(attrId){
$("select[id^='bcat_0_']").remove();
$('#attrForm').get(0).reset();
$.post(WST.U('admin/attributes/get'),{attrId:attrId},function(data,textStatus){
var json = WST.toAdminJson(data);
WST.setValues(json);
layui.form.render();
if(json.goodsCatId>0){
var goodsCatPath = json.goodsCatPath.split("_");
$('#bcat_0').val(goodsCatPath[0]);
var opts = {id:'bcat_0',val:goodsCatPath[0],childIds:goodsCatPath,className:'goodsCats'}
WST.ITSetGoodsCats(opts);
}
var title =(attrId==0)?"新增":"编辑";
var box = WST.open({title:title,type:1,content:$('#attrBox'),area: ['750px', '320px'],btn:['确定','取消'],
end:function(){$('#attrBox').hide();},yes:function(){
$('#attrForm').submit();
}});
$('#attrForm').validator({
rules: {
attrType: function() {
return ($('#attrType').val()!='0');
}
},
fields: {
'attrName': {rule:"required",msg:{required:'请输入属性名称'}},
'attrVal': 'required(attrType)'
},
valid: function(form){
var params = WST.getParams('.ipt');
var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
params.goodsCatId = WST.ITGetGoodsCatVal('goodsCats');
$.post(WST.U('admin/attributes/'+((params.attrId==0)?"add":"edit")),params,function(data,textStatus){
layer.close(loading);
var json = WST.toAdminJson(data);
if(json.status=='1'){
WST.msg("操作成功",{icon:1});
layer.close(box);
$('#attrBox').hide();
loadGrid();
layer.close(box);
}else{
WST.msg(json.msg,{icon:2});
}
});
}
});
});
}
function loadGrid(){
var keyName = $("#keyName").val();
var goodsCatPath = WST.ITGetAllGoodsCatVals('cat_0','pgoodsCats');
mmg.load({"page":1,"keyName":keyName,"goodsCatPath":goodsCatPath.join('_')});
}
function toDel(attrId){
var box = WST.confirm({content:"您确定要删除该属性吗?",yes:function(){
var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
$.post(WST.U('admin/attributes/del'),{attrId:attrId},function(data,textStatus){
layer.close(loading);
var json = WST.toAdminJson(data);
if(json.status=='1'){
WST.msg("操作成功",{icon:1});
layer.close(box);
loadGrid();
}else{
WST.msg(json.msg,{icon:2});
}
});
}});
}
function toggleIsShow( attrId, isShow){
$.post(WST.U('admin/attributes/setToggle'), {'attrId':attrId, 'isShow':isShow}, function(data, textStatus){
var json = WST.toAdminJson(data);
if(json.status=='1'){
WST.msg("操作成功",{icon:1});
loadGrid();
}else{
WST.msg(json.msg,{icon:2});
}
})
}
function changeArrType(v){
if(v>0){
$('#attrValTr').show();
}else{
$('#attrValTr').hide();
}
}

View File

@ -0,0 +1,87 @@
{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/mmgrid/mmGrid.js?v={$v}" type="text/javascript"></script>
<script src="__ADMIN__/attributes/attributes.js?v={$v}" type="text/javascript"></script>
{/block}
{block name="main"}
<div class="wst-toolbar">
<div class="f-left">
<div id="pcat_0_box" class="f-left">
<select id="cat_0" class='ipt pgoodsCats' level="0" onchange="WST.ITGoodsCats({id:'cat_0',val:this.value,isRequire:false,className:'pgoodsCats'});">
<option value="">-所属分类-</option>
{volist name=":WSTGoodsCats(0)" id="vo"}
<option value="{$vo['catId']}">{$vo['catName']}</option>
{/volist}
</select>
</div>
<input type="text" id="keyName" placeholder="请输入属性名称"/>
<button class="btn btn-primary" onclick="loadGrid(0)"><i class='fa fa-search'></i>查询</button>
</div>
{if WSTGrant('SPSX_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 id="mmg" class="mmg layui-form"></div>
<div id="pg" style="text-align: right;"></div>
</div>
<div id='attrBox' style='display:none'>
<form id="attrForm">
<table class='wst-form wst-box-top'>
<tr>
<th width='150'>
<input type="hidden" id="attrId" value="" class="ipt" />
所属商品分类<font color='red'>*</font></th>
<td id="bcat_0_box">
<select id="bcat_0" class='ipt goodsCats' level="0" onchange="WST.ITGoodsCats({id:'bcat_0',val:this.value,isRequire:false,className:'goodsCats'});" data-rule='所属商品分类:required;' data-target="#msg_bcat_0">
<option value="">-请选择-</option>
{volist name=":WSTGoodsCats(0)" id="vo"}
<option value="{$vo['catId']}">{$vo['catName']}</option>
{/volist}
</select>
<span class='msg-box' id='msg_bcat_0' style='color:red;'>(至少选择一个商品分类)</span>
</td>
</tr>
<tr>
<th>属性名称<font color='red'>*</font></th>
<td>
<input type="text" id="attrName" name="attrName" class="ipt" maxLength='20'/>
</td>
</tr>
<tr>
<th>属性类型<font color='red'>*</font></th>
<td>
<select id='attrType' class='ipt' onchange='changeArrType(this.value)'>
<option value='0'>输入框</option>
<option value='1'>多选项</option>
<option value='2'>下拉项</option>
</select>
</td>
</tr>
<tr id='attrValTr' style='display:none'>
<th>属性选项<font color='red'>*</font></th>
<td>
<input type="text" id="attrVal" name="attrVal" class="ipt" style='width:70%' placeholder="每个属性选项以,号分隔" data-msg='请输入属性选项'/>
</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="isShow" lay-text="显示|隐藏">
</td>
</tr>
<tr>
<th>排序号<font color='red'>*</font></th>
<td>
<input type="text" id="attrSort" name="attrSort" class="ipt" maxLength='20'/>
</td>
</tr>
</table>
</form>
</div>
{/block}