article_list.html 8.55 KB
<% 
	var headContent = {
	include("/pages/template/head.html"){}
%>

<% include("/pages/includes/ztree.html"){} %>

<script type="text/javascript">
var oper;
jQuery(function($) {
	// 页面方法
	oper = {
		width : 750,
		height : 500,
		form : document.form1,
		list : function() {
			var url = 'admin/article/list';
			this.form.action = url;
			this.form.submit();
		},
		view : function(id) {
			var url = 'admin/article/view/'+id;
			var title = '查看文章';
			Iframe(url, this.width, this.height, title, false, false, false, EmptyFunc);
		},
		add : function() {
			var url = 'admin/article/add?model.folder_id='+$('[name="attr.folder_id"]').val();
			var title = '添加文章';
			Iframe(url, this.width, this.height, title);
		},
		edit : function(id) {
			var url = 'admin/article/edit/'+id;
			var title = '修改文章';
			Iframe(url, this.width, this.height, title);
		},
		copy : function(id) {
			var url = 'admin/article/tocopy/'+id;
			var title = '复制文章';
			Iframe(url, 450, this.height, title);
		},
		edit_content : function (pid){
			var url = 'admin/article/edit_content/'+pid;
			Iframe(url,900,580,'文章内容',false,false,true);
		},
		edit_content_textarea : function (pid){
			var url = 'admin/article/edit_content_textarea/'+pid;
			Iframe(url,900,580,'文章内容',false,false,true);
		},
		edit_content_ue : function (pid){
			var url = 'admin/article/edit_content_ue/'+pid;
			Iframe(url,900,600,'文章内容',false,false,true);
		},
		del : function(id) {
			var url = 'admin/article/delete/'+id;
			var title = '确认要删除该文章信息?';
			Confirm(title, function() {
				form1.action = url;
				form1.submit();
			});
		}
	};
	//显示Menu索引
	showMenu('page_article');
});

//分页
var paginator = function(page) {
	oper.list();
};

var zTree;
var demoIframe;

var setting = {
    check: {
        enable: false
    },
    view: {
        dblClickExpand: false,
        showLine: true,
        selectedMulti: false
    },
    data: {
        simpleData: {
            enable:true,
            idKey: "id",
            pIdKey: "pId",
            rootPId: ""
        }
    },
    callback: {
        beforeClick: function(treeId, treeNode) {
        	$("[name='attr.folder_id']").val(treeNode.id);
        	oper.list();
        	return true;
        	/**
            var zTree = $.fn.zTree.getZTreeObj("tree");
            if (treeNode.isParent) {
                zTree.expandNode(treeNode);
                return false;
            } else {
                demoIframe.attr("src",treeNode.file + ".html");
                return true;
            }
            **/
        }
    }
};

var zNodes =[
     <% for(item in folders){ %>
     	{id:${item.id}, pId:${item.parent_id}, name:"${item.name}"} ${itemLP.index==folders.~size?"":","}
     <% } %>
];

$(document).ready(function(){
	var t = $("#tree");
	t = $.fn.zTree.init(t, setting, zNodes);
	demoIframe = $("#testIframe");
	demoIframe.bind("load", loadReady);
	zTree = $.fn.zTree.getZTreeObj("tree");
	// zTree.selectNode(zTree.getNodeByParam("id", 101));
	var openTree = $('[name="attr.folder_id"]').val();
	if(openTree>0) zTree.selectNode(zTree.getNodeByParam("id", openTree));
});

function loadReady() {
    var bodyH = demoIframe.contents().find("body").get(0).scrollHeight,
            htmlH = demoIframe.contents().find("html").get(0).scrollHeight,
            maxH = Math.max(bodyH, htmlH), minH = Math.min(bodyH, htmlH),
            h = demoIframe.height() >= maxH ? minH:maxH ;
    if (h < 530) h = 530;
}
</script>

<%
};

var bodyContent = {
%>

<div class="row" style="margin-right: 0px; margin-left: 0px; ">
<div class="col-md-2">
<ul id="tree" class="ztree" style="overflow:auto;"></ul>
</div>
<div class="col-md-10">


	<form name="form1" action="" method="post"  class="form-inline" role="form">
		<!-- 菜单 -->
		<% include("/pages/template/menu.html"){} %>

		<div class="tableSearch">
			<%  //查询列表 %>
			<div class="form-group">
				<select name="attr.folder_id" class="form-control" >
				<option value="-1">--请选择--</option>
				${selectFolder }
				</select>
			</div>
			<div class="form-group">
					<input class="form-control" type="text" name="attr.title" value="${attr.title!''}" 
						placeholder="请输入名称" required='required' />
			</div>
	 		<div class="form-group">
					<select name="attr.status" class="form-control" >
						<option value="-1">--请选择--</option>
						<option value="1" ${attr.status=='1'?'selected':''}>显示</option>
						<option value="2" ${attr.status=='2'?'selected':''}>隐藏</option>
					</select>
			</div>
			
			<button type="button" class="btn btn-default" onclick="oper.list();" name="search">
			 		<span class="glyphicon glyphicon-search"></span> 查 询
			</button>
			<button type="button" class="btn btn-default" onclick="resetForm();">
			 		<span class="glyphicon glyphicon-refresh"></span> 重 置
			</button>
			<button type="button" class="btn btn-default" onclick="oper.add();">
			 		<span class="glyphicon glyphicon-plus"></span> 新 增
			</button>
		</div>
		
		<!-- 数据列表 -->
		<table class="table table-striped table-bordered table-hover">
			<thead>
				<tr>
					<th>序号</th>
					<%  // 列表头部 %>
					
					<th name="folder_id" class="sorting">栏目</th> 
					<th name="title" class="sorting">名称</th> 
					<th name="sort" class="sorting">排序</th> 
					<th name="status" class="sorting">状态</th> 
					<th>置顶</th>
					<th name="is_recommend" class="sorting">推荐</th> 
					<th name="approve_status" class="sorting">审核状态</th> 
					<th name="publish_time" class="sorting">发布时间</th> 
					<th name="publish_user" class="sorting">发布者</th> 
					<!-- 
					<th>开始时间</th> 
					<th>结束时间</th>
					 -->
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
			<% for(item in page.list){ %>
				<tr>
					<td>${itemLP.index }</td>
					<%  // 列表内容 %>
					<td>${item.folderName  }</td>
					<td title="${item.title}">
					<a href="front/article/${item.id}.html" class="btn btn-link"  target="_blank">
					<% if (strutil.length(item.title) > 12) { %>
						${strutil.subStringTo(item.title, 0, 12)}...
					<% 	} else { %>
						${item.title}
					<%  } %>
					</a>
					</td> 
					<td>${item.sort}</td>
					<td>
					<% if(item.status=='2') { %>
					隐藏
					<%	} %>
					<% if(item.status=='1') { %>
					显示
					<%	} %>
					</td> 
					<td>${item.sort<10?'是':'否'  }</td>
					<td>
					<% if(item.is_recommend==2) { %>
					否
					<%	} %>
					<% if(item.is_recommend==1) { %>
					是
					<%	} %>
					</td> 
					<td style='background-color:${(item.approve_status==1 || item.approve_status==2)?"#ECC2C2":""} '>
					<% if(item.approve_status==1 || item.approve_status==2) { %>
					待审核
					<%	} %>
					<% if(item.approve_status==9) { %>
					未通过
					<%	} %>
					<% if(item.approve_status==10) { %>
					通过
					<%	} %>
					</td>
	 				<td>${item.publish_time}</td>
					<td>${item.publish_user}</td> 
					<!-- 
					<td>${item.start_time}</td>
					<td>${item.end_time}</td>
					 -->
					<td>
					
					<!-- Split button -->
					<div class="btn-group">
					  <button type="button" class="btn btn-sm btn-info"  onclick="oper.edit_content_ue(${item.id});">编辑内容</button>
					  <button type="button" class="btn btn-sm btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
					    <span class="caret"></span>
					    <span class="sr-only">下拉</span>
					  </button>
					  <ul class="dropdown-menu">
					  	<!-- 
					    <li><a href="admin/article/edit_content_ue/${item.id}" target="_blank">修改内容</a></li>
					    <li><a href="javascript:void(0);"  onclick="oper.edit_content(${item.id});">修改内容(UM)</a></li>
					    <li><a href="javascript:void(0);"  onclick="oper.edit_content_textarea(${item.id});">修改内容(textarea)</a></li>
					    <li role="separator" class="divider"></li>
					     -->
					    <li><a href="javascript:void(0);" onclick="oper.copy(${item.id});">复制文章</a></li>
						<li><a href="javascript:void(0);" onclick="oper.view(${item.id});">查看内容</a></li>
					  </ul>
					</div>
					
					<a href="javascript:void(0);" class="btn btn-sm btn-primary" onclick="oper.edit(${item.id});">修改</a> 
					<% if(item.id>1){ %>
					<a href="javascript:void(0);" class="btn btn-sm btn-danger" onclick="oper.del(${item.id});">删除</a>
					<% } %>
					
					</td>
				</tr>
			<% } %>
			</tbody>
		</table>
		<%include("/pages/includes/paginator.html"){} %>
	</form>

</div>
</div>
<%}; %>


<% layout("/pages/template/_layout.html",{head:headContent,body:bodyContent}){ %>
<%} %>