You've already forked qlg.tsgz.moe
							
							Init Repo
This commit is contained in:
		
							
								
								
									
										149
									
								
								hyhproject/admin/view/areas/areas.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										149
									
								
								hyhproject/admin/view/areas/areas.js
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,149 @@
 | 
			
		||||
var mmg;
 | 
			
		||||
function initGrid(){
 | 
			
		||||
    var parentId=$('#h_areaId').val();
 | 
			
		||||
    var h = WST.pageHeight();
 | 
			
		||||
    var cols = [
 | 
			
		||||
            {title:'地区名称', name:'areaName', width: 300},
 | 
			
		||||
            {title:'是否显示', name:'isShow', width: 30,renderer: function(val,item,rowIndex){
 | 
			
		||||
            	return '<input type="checkbox" '+((item['isShow']==1)?"checked":"")+' name="isShow2" lay-skin="switch" lay-filter="isShow2" data="'+item['areaId']+'" lay-text="显示|隐藏">';
 | 
			
		||||
 | 
			
		||||
            }},
 | 
			
		||||
            {title:'排序字母', name:'areaKey', width: 30},
 | 
			
		||||
            {title:'排序号', name:'areaSort', width: 30},
 | 
			
		||||
            {title:'操作', name:'' ,width:140, align:'center', renderer: function(val,item,rowIndex){
 | 
			
		||||
                var h = "";
 | 
			
		||||
                h += "<a  class='btn btn-blue' onclick='javascript:toView("+item['areaId']+")'><i class='fa fa-search'></i>查看</a> ";
 | 
			
		||||
                if(WST.GRANT.DQGL_02)h += "<a  class='btn btn-blue' onclick='javascript:toEdit("+item['areaId']+","+item["parentId"]+")'><i class='fa fa-pencil'></i>修改</a>";
 | 
			
		||||
                if(WST.GRANT.DQGL_03)h += "<a  class='btn btn-red' onclick='javascript:toDel(" + item['areaId'] + ")'><i class='fa fa-trash-o'></i>删除</a>";
 | 
			
		||||
                return h;
 | 
			
		||||
            }}
 | 
			
		||||
            ];
 | 
			
		||||
 
 | 
			
		||||
    mmg = $('.mmg').mmGrid({height: h-80,indexCol: true, cols: cols,method:'POST',
 | 
			
		||||
        url: WST.U('admin/areas/pageQuery','parentId='+parentId), fullWidthRows: true, autoLoad: true,
 | 
			
		||||
        plugins: [
 | 
			
		||||
            $('#pg').mmPaginator({})
 | 
			
		||||
        ]
 | 
			
		||||
    }); 
 | 
			
		||||
    mmg.on('loadSuccess',function(){
 | 
			
		||||
    	layui.form.render('','gridForm');
 | 
			
		||||
        layui.form.on('switch(isShow2)', function(data){
 | 
			
		||||
            var id = $(this).attr("data");
 | 
			
		||||
            if(this.checked){
 | 
			
		||||
  				toggleIsShow(0,id);
 | 
			
		||||
  			}else{
 | 
			
		||||
  				toggleIsShow(1,id);
 | 
			
		||||
  			}
 | 
			
		||||
        });
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function toggleIsShow(t,v){
 | 
			
		||||
	if(!WST.GRANT.DQGL_02)return;
 | 
			
		||||
    var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
    	$.post(WST.U('admin/areas/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});
 | 
			
		||||
		            mmg.load();
 | 
			
		||||
			  }else{
 | 
			
		||||
			    	WST.msg(json.msg,{icon:2});
 | 
			
		||||
			  }
 | 
			
		||||
		});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function toReturn(){
 | 
			
		||||
	location.href=WST.U('admin/areas/index','parentId='+$('#h_parentId').val());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function letterOnblur(obj){
 | 
			
		||||
	if($.trim(obj.value)=='')return;
 | 
			
		||||
	if($('#areaKey').val()!=='')return;
 | 
			
		||||
	var loading = WST.msg('正在生成排序字母,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
	$.post(WST.U('admin/areas/letterObtain'),{code:obj.value},function(data,textStatus){
 | 
			
		||||
		layer.close(loading);
 | 
			
		||||
		var json = WST.toAdminJson(data);
 | 
			
		||||
		if(json.status == 1){
 | 
			
		||||
			$('#areaKey').val(json.msg);
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function toEdit(id,pid){
 | 
			
		||||
	$('#areaForm')[0].reset();
 | 
			
		||||
	if(id>0){
 | 
			
		||||
		var loading = WST.msg('正在获取数据,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
		$.post(WST.U('admin/areas/get'),{id:id},function(data,textStatus){
 | 
			
		||||
			layer.close(loading);
 | 
			
		||||
			var json = WST.toAdminJson(data);
 | 
			
		||||
			if(json){
 | 
			
		||||
				WST.setValues(json);
 | 
			
		||||
				layui.form.render();
 | 
			
		||||
				editsBox(id);
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	}else{
 | 
			
		||||
		WST.setValues({parentId:pid,areaId:0});
 | 
			
		||||
		layui.form.render();
 | 
			
		||||
		editsBox(id);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
function toView(id){
 | 
			
		||||
	location.href = WST.U('admin/areas/index','parentId='+id);
 | 
			
		||||
}
 | 
			
		||||
function editsBox(id){
 | 
			
		||||
	var box = WST.open({title:(id>0)?'修改地区':"新增地区",type:1,content:$('#areasBox'),area: ['460px', '260px'],btn:['确定','取消'],
 | 
			
		||||
		end:function(){$('#areasBox').hide();},yes:function(){
 | 
			
		||||
		$('#areaForm').submit();
 | 
			
		||||
	          }});
 | 
			
		||||
	$('#areaForm').validator({
 | 
			
		||||
	    fields: {
 | 
			
		||||
	    	areaName: {
 | 
			
		||||
	    		tip: "请输入地区名称",
 | 
			
		||||
	    		rule: '地区名称:required;length[~10];'
 | 
			
		||||
	    	},
 | 
			
		||||
		    areaKey: {
 | 
			
		||||
	    		tip: "请输入排序字母",
 | 
			
		||||
	    		rule: '排序字母:required;length[~1];'
 | 
			
		||||
	    	},
 | 
			
		||||
	    	areaSort: {
 | 
			
		||||
            	tip: "请输入排序号",
 | 
			
		||||
            	rule: '排序号:required;length[~8];'
 | 
			
		||||
            }
 | 
			
		||||
	    },
 | 
			
		||||
	    valid: function(form){
 | 
			
		||||
	        var params = WST.getParams('.ipt');
 | 
			
		||||
	        var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
 | 
			
		||||
	    		$.post(WST.U('admin/areas/'+((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});
 | 
			
		||||
	    			    	$('#areasBox').hide();
 | 
			
		||||
	    			    	layer.close(box);
 | 
			
		||||
	    		            mmg.load();
 | 
			
		||||
	    			  }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/areas/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);
 | 
			
		||||
	           		            mmg.load();
 | 
			
		||||
	           			  }else{
 | 
			
		||||
	           			    	WST.msg(json.msg,{icon:2});
 | 
			
		||||
	           			  }
 | 
			
		||||
	           		});
 | 
			
		||||
	            }});
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										55
									
								
								hyhproject/admin/view/areas/list.html
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										55
									
								
								hyhproject/admin/view/areas/list.html
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,55 @@
 | 
			
		||||
{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__/areas/areas.js?v={$v}" type="text/javascript"></script>
 | 
			
		||||
<script>
 | 
			
		||||
$(function(){initGrid();})
 | 
			
		||||
</script>
 | 
			
		||||
{/block}
 | 
			
		||||
{block name="main"}
 | 
			
		||||
<input type='hidden' id='h_areaId' value='{$pArea["areaId"]}'/>
 | 
			
		||||
<input type='hidden' id='h_parentId' value='{$pArea["parentId"]}'/>
 | 
			
		||||
<div class="wst-toolbar">
 | 
			
		||||
  {if condition="($pArea['areaId'] != 0)"}
 | 
			
		||||
      上级地区:{$pArea['areaName']}
 | 
			
		||||
  <button class="btn f-right" onclick='javascript:toReturn(0)'><i class="fa fa-angle-double-left"></i>返回</button>
 | 
			
		||||
  {/if}
 | 
			
		||||
  {if WSTGrant('DQGL_01')}
 | 
			
		||||
  <button class="btn btn-success f-right btn-mright" onclick='javascript:toEdit(0,{$pArea["areaId"]})'><i class='fa fa-plus'></i>新增</button>
 | 
			
		||||
  {/if}
 | 
			
		||||
  <div style='clear:both'></div>
 | 
			
		||||
</div>
 | 
			
		||||
<form lay-filter='gridForm' class='layui-form wst-grid'>
 | 
			
		||||
<div id="mmg" class="mmg"></div>
 | 
			
		||||
</form>
 | 
			
		||||
<div id="pg" style="text-align: right;"></div>
 | 
			
		||||
<div id='areasBox' style='display:none'>
 | 
			
		||||
  <form id='areaForm' autocomplete="off" class='layui-form'>
 | 
			
		||||
  <input type='hidden' class='ipt' id='areaId' />
 | 
			
		||||
  <input type='hidden' class='ipt' id='parentId' />
 | 
			
		||||
  <table class='wst-form wst-box-top'>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th width='100'>地区名称<font color='red'>*</font>:</th>
 | 
			
		||||
        <td><input type='text' id='areaName' name="areaName" class='ipt' maxLength='20' style='width:200px;' onblur='javascript:letterOnblur(this)'/></td>
 | 
			
		||||
     </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th width='100'>是否显示<font color='red'>*</font>:</th>
 | 
			
		||||
        <td height='24'>
 | 
			
		||||
           <input type="checkbox" id='isShow' name='isShow' value="1" lay-skin="switch" lay-filter="switchTest" class="ipt" lay-text="显示|隐藏">
 | 
			
		||||
        </td>
 | 
			
		||||
     </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th width='100'>排序字母<font color='red'>*</font>:</th>
 | 
			
		||||
        <td><input type='text' id='areaKey' name='areaKey' class='ipt' style='width:60px;'  maxLength='1'/></td>
 | 
			
		||||
     </tr>
 | 
			
		||||
     <tr>
 | 
			
		||||
        <th width='100'>排序号<font color='red'>*</font>:</th>
 | 
			
		||||
        <td><input type='text' id='areaSort' name='areaSort' 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