You've already forked qlg.tsgz.moe
							
							
		
			
				
	
	
		
			119 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			119 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| var mmg,combo;
 | |
| function initGrid(){
 | |
|     var h = WST.pageHeight();
 | |
|     var cols = [
 | |
|             {title:'文章ID', name:'id' ,width:30,sortable:true},
 | |
|             {title:'标题', name:'title' ,width:200,sortable:true},
 | |
|             {title:'是否显示', name:'isShow' ,width:50,sortable:true, renderer: function(val,item,rowIndex){
 | |
|                 return '<form autocomplete="off" class="layui-form" lay-filter="gridForm"><input type="checkbox" id="isShow" name="isShow" '+((item['isShow']==1)?"checked":"")+' lay-skin="switch" value="1" lay-filter="isShow" lay-text="显示|隐藏" data="'+item['articleId']+'"></form>';
 | |
|             }},
 | |
|             {title:'创建时间', name:'create_time' ,width:120,sortable:true},
 | |
|             {title:'操作', name:'' ,width:100, align:'center', renderer: function(val,item,rowIndex){
 | |
|                 var h = "";
 | |
|                 h += "<a  class='btn btn-blue' onclick='javascript:toEdit("+item['id']+")'><i class='fa fa-pencil'></i>修改</a> ";
 | |
|                 h += "<a  class='btn btn-red' onclick='javascript:toDel(" + item['id'] + ")'><i class='fa fa-trash-o'></i>删除</a> ";
 | |
|                 return h;
 | |
|             }}
 | |
|             ];
 | |
|  
 | |
|     mmg = $('.mmg').mmGrid({height: h-85,indexCol: true, cols: cols,method:'POST',checkCol:true,multiSelect:true,
 | |
|         url: WST.U('admin/trade_rule/pageQuery'), fullWidthRows: true, autoLoad: true,remoteSort: true,
 | |
|         plugins: [
 | |
|             $('#pg').mmPaginator({})
 | |
|         ]
 | |
|     });   
 | |
|     mmg.on('loadSuccess',function(){
 | |
|     	layui.form.render('','gridForm');
 | |
|         layui.form.on('switch(isShow)', function(data){
 | |
|             var id = $(this).attr("data");
 | |
|             if(this.checked){
 | |
|                 toggleIsShow(1,id);
 | |
|             }else{
 | |
|                 toggleIsShow(0,id);
 | |
|             }
 | |
|         });
 | |
|     })
 | |
| }
 | |
| 
 | |
| function loadGrid(){
 | |
| 	mmg.load({page:1});
 | |
| }
 | |
| 
 | |
| function toggleIsShow(t,v){
 | |
|     var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
 | |
|     	$.post(WST.U('admin/trade_rule/editiIsShow'),{id:v,isShow:t},function(data,textStatus){
 | |
| 			  layer.close(loading);
 | |
| 			  var json = WST.toAdminJson(data);
 | |
| 			  if(json.status=='1'){
 | |
| 			    	WST.msg(json.msg,{icon:1});
 | |
| 		            loadGrid();
 | |
| 			  }else{
 | |
| 			    	WST.msg(json.msg,{icon:2});
 | |
| 			  }
 | |
| 		});
 | |
| }
 | |
| 
 | |
| function toEdit(id){
 | |
| 	location.href=WST.U('admin/trade_rule/toEdit','id='+id);
 | |
| }
 | |
| 
 | |
| function toEdits(id){
 | |
|     var params = WST.getParams('.ipt');
 | |
|     params.id = id;
 | |
|     var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
 | |
| 	$.post(WST.U('admin/trade_rule/'+((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});
 | |
| 		        setTimeout(function(){ 
 | |
| 			    	location.href=WST.U('admin/trade_rule/index');
 | |
| 		        },1000);
 | |
| 		  }else{
 | |
| 		        WST.msg(json.msg,{icon:2});
 | |
| 		  }
 | |
| 	});
 | |
| }
 | |
| 
 | |
| function toDel(id){
 | |
| 	var box = WST.confirm({content:"您确定要删除该条规则吗?",yes:function(){
 | |
| 	           var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
 | |
| 	           	$.post(WST.U('admin/trade_rule/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);
 | |
| 	           		            loadGrid();
 | |
| 	           			  }else{
 | |
| 	           			    	WST.msg(json.msg,{icon:2});
 | |
| 	           			  }
 | |
| 	           		});
 | |
| 	            }});
 | |
| }
 | |
| 
 | |
| function toBatchDel(){
 | |
| 	var rows = mmg.selectedRows();
 | |
| 	if(rows.length==0){
 | |
| 		WST.msg('请选择要删除的文章',{icon:2});
 | |
| 		return;
 | |
| 	}
 | |
| 	var ids = [];
 | |
| 	for(var i=0;i<rows.length;i++){
 | |
|        ids.push(rows[i]['articleId']); 
 | |
| 	}
 | |
| 	var box = WST.confirm({content:"您确定要删除这些规则吗?",yes:function(){
 | |
| 	           var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
 | |
| 	           	$.post(WST.U('admin/trade_rule/delByBatch'),{ids:ids.join(',')},function(data,textStatus){
 | |
| 	           			  layer.close(loading);
 | |
| 	           			  var json = WST.toAdminJson(data);
 | |
| 	           			  if(json.status=='1'){
 | |
| 	           			    	WST.msg(json.msg,{icon:1});
 | |
| 	           			    	layer.close(box);
 | |
| 	           		            loadGrid();
 | |
| 	           			  }else{
 | |
| 	           			    	WST.msg(json.msg,{icon:2});
 | |
| 	           			  }
 | |
| 	           		});
 | |
| 	            }});
 | |
| } |