You've already forked qlg.tsgz.moe
							
							Init Repo
This commit is contained in:
		
							
								
								
									
										276
									
								
								hyhproject/admin/view/goodscats/goodscats.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										276
									
								
								hyhproject/admin/view/goodscats/goodscats.js
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,276 @@
 | 
			
		||||
var grid,oldData = {},oldorderData = {};
 | 
			
		||||
function initGrid(){	
 | 
			
		||||
	grid = $('#maingrid').WSTGridTree({
 | 
			
		||||
		url:WST.U('admin/goodscats/pageQuery'),
 | 
			
		||||
		pageSize:10000,
 | 
			
		||||
		pageSizeOptions:[10000],
 | 
			
		||||
		height:'99%',
 | 
			
		||||
        width:'100%',
 | 
			
		||||
        minColToggle:6,
 | 
			
		||||
        delayLoad :true,
 | 
			
		||||
        rownumbers:true,
 | 
			
		||||
        columns: [
 | 
			
		||||
	        { display: '分类名称', width: 350,name: 'catName', id:'catId', align: 'left',isSort: false,render: function (item)
 | 
			
		||||
                {
 | 
			
		||||
                	oldData[item.catId] = item.catName;
 | 
			
		||||
                    return '<input type="text" size="40" value="'+item.catName+'" onblur="javascript:editName('+item.catId+',this)"/>';
 | 
			
		||||
            }},
 | 
			
		||||
			{ display: '自营是否显示', width: 70, name: 'isSelfShow',isSort: false,
 | 
			
		||||
				render: function (item)
 | 
			
		||||
				{
 | 
			
		||||
					return '<input type="checkbox" '+((item.isSelfShow==1)?"checked":"")+' class="ipt" lay-skin="switch" lay-filter="isSelfShow" data="'+item.catId+'" lay-text="显示|隐藏">';
 | 
			
		||||
				}
 | 
			
		||||
			},
 | 
			
		||||
            { display: '推荐楼层', width: 70, name: 'isFloor',isSort: false,
 | 
			
		||||
                render: function (itemf)
 | 
			
		||||
                {
 | 
			
		||||
                    return '<input type="checkbox" '+((itemf.isFloor==1)?"checked":"" )+'  class="ipt" lay-skin="switch" lay-filter="isFloor" data="'+itemf.catId+'" lay-text="是|否">';
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
			{ display: '是否显示', width: 70, name: 'isShow',isSort: false,
 | 
			
		||||
				render: function (item)
 | 
			
		||||
				{
 | 
			
		||||
					return '<input type="checkbox" '+((item.isShow==1)?"checked":"")+' class="ipt" lay-skin="switch" lay-filter="isShow" data="'+item.catId+'" lay-text="显示|隐藏">';
 | 
			
		||||
				}
 | 
			
		||||
			},
 | 
			
		||||
            { display: '排序号', name: 'catSort',width: 50,isSort: false,render: function (item)
 | 
			
		||||
                {
 | 
			
		||||
                	oldorderData[item.catId] = item.catSort;
 | 
			
		||||
                    return '<input type="text" style="width:50px" value="'+item.catSort+'" onblur="javascript:editOrder('+item.catId+',this)"/>';
 | 
			
		||||
            }},
 | 
			
		||||
            { display: '佣金', width: 50, name: 'commissionRate',isSort: false,
 | 
			
		||||
                render: function (item)
 | 
			
		||||
                {
 | 
			
		||||
                    return item["commissionRate"]+'%';
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            { display: '质保金', width: 50, name: 'payDeposit',isSort: false,
 | 
			
		||||
                render: function (item)
 | 
			
		||||
                {
 | 
			
		||||
                    return item["payDeposit"];
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
	        { display: '操作', name: 'op',width: 170,isSort: false,
 | 
			
		||||
	        	render: function (rowdata){
 | 
			
		||||
		            var h = "";
 | 
			
		||||
			        if(WST.GRANT.SPFL_01)h += "<a class='btn btn-blue' href='javascript:toEdit("+rowdata["catId"]+",0)'><i class='fa fa-plus'></i>新增子分类</a> ";
 | 
			
		||||
		            if(WST.GRANT.SPFL_02)h += "<a class='btn btn-blue' href='javascript:toEdit("+rowdata["parentId"]+","+rowdata["catId"]+")'><i class='fa fa-pencil'></i>修改</a> ";
 | 
			
		||||
		            if(WST.GRANT.SPFL_03)h += "<a class='btn btn-red' href='javascript:toDel("+rowdata["parentId"]+","+rowdata["catId"]+")'><i class='fa fa-trash-o'></i>删除</a> "; 
 | 
			
		||||
		            return h;
 | 
			
		||||
	        	}}
 | 
			
		||||
        ],
 | 
			
		||||
        callback:function(){
 | 
			
		||||
		    layui.form.render();
 | 
			
		||||
	    }
 | 
			
		||||
    });
 | 
			
		||||
	layui.form.on('switch(isSelfShow)', function(data){
 | 
			
		||||
		var id = $(this).attr("data");
 | 
			
		||||
		if(this.checked){
 | 
			
		||||
			toggleIsSelfShow(id, 1);
 | 
			
		||||
		}else{
 | 
			
		||||
			toggleIsSelfShow(id, 0);
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
    layui.form.on('switch(isShow)', function(data){
 | 
			
		||||
        var id = $(this).attr("data");
 | 
			
		||||
        if(this.checked){
 | 
			
		||||
            toggleIsShow(id, 1);
 | 
			
		||||
        }else{
 | 
			
		||||
            toggleIsShow(id, 0);
 | 
			
		||||
        }
 | 
			
		||||
   });
 | 
			
		||||
   layui.form.on('switch(isFloor)', function(data){
 | 
			
		||||
        var id = $(this).attr("data");
 | 
			
		||||
        if(this.checked){
 | 
			
		||||
            toggleIsFloor(id, 1);
 | 
			
		||||
        }else{
 | 
			
		||||
            toggleIsFloor(id, 0);
 | 
			
		||||
        }
 | 
			
		||||
   });
 | 
			
		||||
}
 | 
			
		||||
function toggleIsSelfShow(id,isSelfShow){
 | 
			
		||||
	if(!WST.GRANT.SPFL_02)return;
 | 
			
		||||
	var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
	$.post(WST.U('admin/goodscats/editiIsSelfShow'),{id:id,isSelfShow:isSelfShow},function(data,textStatus){
 | 
			
		||||
		layer.close(loading);
 | 
			
		||||
		var json = WST.toAdminJson(data);
 | 
			
		||||
		if(json.status=='1'){
 | 
			
		||||
			WST.msg(json.msg,{icon:1});
 | 
			
		||||
			grid.reload(id);
 | 
			
		||||
		}else{
 | 
			
		||||
			WST.msg(json.msg,{icon:2});
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
function toggleIsFloor(id,isFloor){
 | 
			
		||||
	if(!WST.GRANT.SPFL_02)return;
 | 
			
		||||
    var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
	$.post(WST.U('admin/goodscats/editiIsFloor'),{id:id,isFloor:isFloor},function(data,textStatus){
 | 
			
		||||
		  layer.close(loading);
 | 
			
		||||
		  var json = WST.toAdminJson(data);
 | 
			
		||||
		  if(json.status=='1'){
 | 
			
		||||
		    	WST.msg(json.msg,{icon:1});
 | 
			
		||||
				grid.reload(id);
 | 
			
		||||
		  }else{
 | 
			
		||||
		    	WST.msg(json.msg,{icon:2});
 | 
			
		||||
		  }
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function toggleIsShow(id,isShow){
 | 
			
		||||
	if(!WST.GRANT.SPFL_02)return;
 | 
			
		||||
    var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
    $.post(WST.U('admin/goodscats/editiIsShow'),{id:id,isShow:isShow},function(data,textStatus){
 | 
			
		||||
		layer.close(loading);
 | 
			
		||||
		var json = WST.toAdminJson(data);
 | 
			
		||||
		if(json.status=='1'){
 | 
			
		||||
			 WST.msg(json.msg,{icon:1});
 | 
			
		||||
			 grid.reload(id);
 | 
			
		||||
		}else{
 | 
			
		||||
			 WST.msg(json.msg,{icon:2});
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function toEdit(pid,id){
 | 
			
		||||
	$('#goodscatsForm')[0].reset();
 | 
			
		||||
	if(id>0){
 | 
			
		||||
		$.post(WST.U('admin/goodscats/get'),{id:id},function(data,textStatus){
 | 
			
		||||
			var json = WST.toAdminJson(data);
 | 
			
		||||
			if(json){
 | 
			
		||||
				WST.setValues(json);
 | 
			
		||||
				layui.form.render();
 | 
			
		||||
				if(json.catImg){
 | 
			
		||||
					$('#preview').html('<img src="'+WST.conf.IMGURL+'/'+json.catImg+'" height="70px" />');
 | 
			
		||||
				}else{
 | 
			
		||||
					$('#preview').html('');
 | 
			
		||||
				}
 | 
			
		||||
				editsBox(id);
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	}else{
 | 
			
		||||
		WST.setValues({parentId:pid,catName:'',isShow:1,isFloor:0,catSort:0,catImg:''});
 | 
			
		||||
		$('#preview').html('');
 | 
			
		||||
		layui.form.render();
 | 
			
		||||
		editsBox(id);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
var isInitUpload = false;
 | 
			
		||||
function editsBox(id,v){
 | 
			
		||||
	if(!isInitUpload)initUpload();
 | 
			
		||||
	var title =(id>0)?"修改商品分类":"新增商品分类";
 | 
			
		||||
	var box = WST.open({title:title,type:1,content:$('#goodscatsBox'),area: ['465px', '400px'],btn:['确定','取消'],
 | 
			
		||||
		 end:function(){$('#goodscatsBox').hide();},yes:function(){
 | 
			
		||||
		$('#goodscatsForm').submit();
 | 
			
		||||
	          }});
 | 
			
		||||
	$('#goodscatsForm').validator({
 | 
			
		||||
	    fields: {
 | 
			
		||||
	    	catName: {
 | 
			
		||||
	    		tip: "请输入商品分类名称",
 | 
			
		||||
	    		rule: '商品分类名称:required;length[~20];'
 | 
			
		||||
	    	},
 | 
			
		||||
	    	commissionRate: {
 | 
			
		||||
	    		tip: "请输入分类的佣金",
 | 
			
		||||
	    		rule: '分类的佣金:required;'
 | 
			
		||||
	    	},
 | 
			
		||||
	    	catSort: {
 | 
			
		||||
            	tip: "请输入排序号",
 | 
			
		||||
            	rule: '排序号:required;length[~8];'
 | 
			
		||||
            },
 | 
			
		||||
            payDeposit: {
 | 
			
		||||
            	tip: "请输入质保金",
 | 
			
		||||
            	rule: '分类的质保金:required;length[~20];'
 | 
			
		||||
            },
 | 
			
		||||
	    },
 | 
			
		||||
	    valid: function(form){
 | 
			
		||||
	        var params = WST.getParams('.ipt');
 | 
			
		||||
	        params.id = id;
 | 
			
		||||
	        var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
    		$.post(WST.U('admin/goodscats/'+((id>0)?"edit":"add")),params,function(data,textStatus){
 | 
			
		||||
    			  layer.close(loading);
 | 
			
		||||
    			  var json = WST.toAdminJson(data);
 | 
			
		||||
    			  if(json.status=='1'){
 | 
			
		||||
    			    	WST.msg(json.msg,{icon:1});
 | 
			
		||||
    			    	$('#goodscatsBox').hide();
 | 
			
		||||
    			    	layer.close(box);
 | 
			
		||||
    			    	grid.reload(params.parentId);
 | 
			
		||||
    			  }else{
 | 
			
		||||
    			        WST.msg(json.msg,{icon:2});
 | 
			
		||||
    			  }
 | 
			
		||||
    		});
 | 
			
		||||
	    }
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function toDel(pid,id){
 | 
			
		||||
	var box = WST.confirm({content:"您确定要删除该商品分类并下架该分类下的所有商品吗?",yes:function(){
 | 
			
		||||
	           var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
	           	$.post(WST.U('admin/goodscats/del'),{id:id},function(data,textStatus){
 | 
			
		||||
	           			  layer.close(loading);
 | 
			
		||||
	           			  var json = WST.toAdminJson(data);
 | 
			
		||||
	           			  if(json.status=='1'){
 | 
			
		||||
	           			       WST.msg(json.msg,{icon:1});
 | 
			
		||||
	           			       layer.close(box);
 | 
			
		||||
	           		           grid.reload(pid);
 | 
			
		||||
	           			  }else{
 | 
			
		||||
	           			       WST.msg(json.msg,{icon:2});
 | 
			
		||||
	           			  }
 | 
			
		||||
	           		});
 | 
			
		||||
	            }});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function initUpload(){
 | 
			
		||||
	isInitUpload = true;
 | 
			
		||||
	//文件上传
 | 
			
		||||
	WST.upload({
 | 
			
		||||
	    pick:'#catFilePicker',
 | 
			
		||||
	    formData: {dir:'goodscats'},
 | 
			
		||||
	    accept: {extensions: 'gif,jpg,jpeg,png',mimeTypes: 'image/jpg,image/jpeg,image/png,image/gif'},
 | 
			
		||||
	    callback:function(f){
 | 
			
		||||
	      var json = WST.toAdminJson(f);
 | 
			
		||||
	      if(json.status==1){
 | 
			
		||||
	        $('#uploadMsg').empty().hide();
 | 
			
		||||
	        //将上传的图片路径赋给全局变量
 | 
			
		||||
		    $('#catImg').val(json.savePath+json.name);
 | 
			
		||||
		    $('#preview').html('<img src="'+WST.conf.IMGURL+'/'+json.savePath+json.thumb+'" height="75" />');
 | 
			
		||||
	      }else{
 | 
			
		||||
	      	WST.msg(json.msg,{icon:2});
 | 
			
		||||
	      }
 | 
			
		||||
	  },
 | 
			
		||||
	  progress:function(rate){
 | 
			
		||||
	      $('#uploadMsg').show().html('已上传'+rate+"%");
 | 
			
		||||
	  }
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function editName(id,obj){
 | 
			
		||||
	if($.trim(obj.value)=='' || $.trim(obj.value)==oldData[id]){
 | 
			
		||||
		obj.value = oldData[id];
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	$.post(WST.U('admin/goodscats/editName'),{id:id,catName:obj.value},function(data,textStatus){
 | 
			
		||||
	    var json = WST.toAdminJson(data);
 | 
			
		||||
	    if(json.status=='1'){
 | 
			
		||||
	    	oldData[id] = $.trim(obj.value);
 | 
			
		||||
	        WST.msg(json.msg,{icon:1});
 | 
			
		||||
	    }else{
 | 
			
		||||
	        WST.msg(json.msg,{icon:2});
 | 
			
		||||
	    }
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
function editOrder(id,obj){
 | 
			
		||||
	if($.trim(obj.value)=='' || $.trim(obj.value)==editOrder[id]){
 | 
			
		||||
		obj.value = editOrder[id];
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	$.post(WST.U('admin/goodscats/editOrder'),{id:id,catSort:obj.value},function(data,textStatus){
 | 
			
		||||
	    var json = WST.toAdminJson(data);
 | 
			
		||||
	    if(json.status=='1'){
 | 
			
		||||
	    	editOrder[id] = $.trim(obj.value);
 | 
			
		||||
	        WST.msg(json.msg,{icon:1});
 | 
			
		||||
	    }else{
 | 
			
		||||
	        WST.msg(json.msg,{icon:2});
 | 
			
		||||
	    }
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										80
									
								
								hyhproject/admin/view/goodscats/list.html
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										80
									
								
								hyhproject/admin/view/goodscats/list.html
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,80 @@
 | 
			
		||||
{extend name="base" /}
 | 
			
		||||
{block name="css"}
 | 
			
		||||
<link rel="stylesheet" type="text/css" href="__ADMIN__/js/mmgrid/mmGrid.css?v={$v}" />
 | 
			
		||||
<link rel="stylesheet" type="text/css" href="__STATIC__/plugins/webuploader/webuploader.css?v={$v}" />
 | 
			
		||||
{/block}
 | 
			
		||||
{block name="js"}
 | 
			
		||||
<script src="__ADMIN__/js/wstgridtree.js?v={$v}" type="text/javascript"></script>
 | 
			
		||||
<script src="__ADMIN__/goodscats/goodscats.js?v={$v}" type="text/javascript"></script>
 | 
			
		||||
<script type='text/javascript' src='__STATIC__/plugins/webuploader/webuploader.js?v={$v}'></script>
 | 
			
		||||
<script>
 | 
			
		||||
$(function(){initGrid();})
 | 
			
		||||
</script>
 | 
			
		||||
{/block}
 | 
			
		||||
{block name="main"}
 | 
			
		||||
<style>.mmGrid{border-bottom:0px;}</style>
 | 
			
		||||
{if WSTGrant('SPFL_01')}
 | 
			
		||||
<div class="wst-toolbar">
 | 
			
		||||
   <button class="btn btn-success f-right" onclick='javascript:toEdit(0)'><i class='fa fa-plus'></i>新增</button>
 | 
			
		||||
   <div style='clear:both'></div>
 | 
			
		||||
</div>
 | 
			
		||||
{/if}
 | 
			
		||||
<div class='wst-grid'>
 | 
			
		||||
 <div class='mmGrid layui-form' id="maingrid"></div>
 | 
			
		||||
</div>
 | 
			
		||||
<div id='goodscatsBox' style='display:none' class='layui-form'>
 | 
			
		||||
  <form id='goodscatsForm' autocomplete="off">
 | 
			
		||||
  <input type='hidden' id='parentId' name="parentId" class='ipt'/>
 | 
			
		||||
  <table class='wst-form wst-box-top'>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th width='100'>商品分类名称<font color='red'>*</font>:</th>
 | 
			
		||||
        <td><input type='text' id='catName' name="catName" class='ipt' maxLength='20' style='width:200px;'/></td>
 | 
			
		||||
     </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
          <th>图标:</th>
 | 
			
		||||
          <td>
 | 
			
		||||
            <div id='catFilePicker'>上传图标</div><span id='uploadMsg'></span>
 | 
			
		||||
            <input type='hidden' id='catImg' name="catImg" class="ipt" />
 | 
			
		||||
            
 | 
			
		||||
          </td>
 | 
			
		||||
       </tr>
 | 
			
		||||
       <tr>
 | 
			
		||||
          <th>预览图:</th>
 | 
			
		||||
          <td><div style="min-height:70px;" id="preview"></div></td>
 | 
			
		||||
       </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th width='100'>佣金<font color='red'>*</font>:</th>
 | 
			
		||||
        <td height='24'>
 | 
			
		||||
            <input type="text" id="commissionRate" name="commissionRate" class="ipt" value="-1" data-target="#msg_commissionRate" size='7' class='ipt'>%<span id='msg_commissionRate'>(-1代表继承上级佣金)</span>
 | 
			
		||||
        </td>
 | 
			
		||||
     </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th width='100'>应交质保金<font color='red'>*</font>:</th>
 | 
			
		||||
        <td height='50'>
 | 
			
		||||
            <input type="text" id="payDeposit" name="payDeposit" class="ipt" value="-1" data-target="#payDeposit" size='7' class='ipt'><span id='payDeposit'>(-1代表继承上级质保金)</span>
 | 
			
		||||
        </td>
 | 
			
		||||
     </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th width='100'>是否显示<font color='red'>*</font>:</th>
 | 
			
		||||
        <td height='24'>
 | 
			
		||||
           <input type="checkbox" id="isShow" name="isShow" value="1" class="ipt" lay-skin="switch" lay-filter="isShow1" lay-text="显示|隐藏">
 | 
			
		||||
        </td>
 | 
			
		||||
     </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th width='100'>是否首页楼层<font color='red'>*</font>:</th>
 | 
			
		||||
        <td height='24'>
 | 
			
		||||
           <input type="checkbox" id="isFloor" name="isFloor" value="1" class="ipt" lay-skin="switch" lay-filter="isFloor1" lay-text="是|否">
 | 
			
		||||
        </td>
 | 
			
		||||
     </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th width='100'>楼层副标题<font color='red'> </font>:</th>
 | 
			
		||||
        <td><input type='text' id='subTitle' name='subTitle' class='ipt' style='width:200px;' /></td>
 | 
			
		||||
     </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th width='100'>排序号<font color='red'>*</font>:</th>
 | 
			
		||||
        <td><input type='text' id='catSort' name='catSort' class='ipt' style='width:60px;' onkeypress='return WST.isNumberKey(event);' onkeyup="javascript:WST.isChinese(this,1)" maxLength='10' value='0'/></td>
 | 
			
		||||
     </tr>
 | 
			
		||||
  </table>
 | 
			
		||||
  </form>
 | 
			
		||||
</div>
 | 
			
		||||
{/block}
 | 
			
		||||
		Reference in New Issue
	
	Block a user