知识库系统源代码——news.jsp

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tangruyi1992/article/details/55049250

此页面为信息管理首页面


代码如下:

<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<link rel="stylesheet" type="text/css" href="../jslib/jquery-easyui-1.3.3/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../jslib/jquery-easyui-1.3.3/themes/icon.css">
<script type="text/javascript" src="../jslib/jquery-easyui-1.3.3/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="../jslib/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../jslib/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
<!-- xhEditor插件库 -->
<script type="text/javascript" src="../jslib/xheditor-1.1.14/xheditor-1.1.14-zh-cn.min.js" charset="utf-8"></script>
<!-- 自己定义的样式和JS扩展 -->
<link rel="stylesheet" href="../style/syCss.css" type="text/css"></link>
<script type="text/javascript" src="../jslib/syUtil.js" charset="utf-8"></script>
<script type="text/javascript">
	 $(function() {
		$('#admin_news_datagrid').datagrid({
			url : '${pageContext.request.contextPath}/News?action=list',
			fit : true,
			fitColumns : true,
			border : false,
			pagination : true,
			idField : 'id',
			pageSize : 20,
			pageList : [ 10, 20, 30, 40, 50 ],
			sortName : 'createtime',
			sortOrder : 'desc',
			//checkOnSelect : false,
			//selectOnCheck : false,
			nowrap : false,
			columns : [ [ {
				title : '编号',
				field : 'id',
				width : 150,
				checkbox : true
			}, {
				title : '信息标题',
				field : 'name',
				width : 150
			}, {
				title : '发布时间',
				field : 'createtime',
				width : 150
			}, {
				title : '详细信息',
				field : 'text',
				width : 150,
				formatter : function(value, row, index) {
					return formatString('<span class="icon-search" style="display:inline-block;vertical-align:middle;width:16px;height:16px;"></span><a href="javascript:void(0);" onclick="admin_news_showNoteFun(\'{0}\');">详细内容</a>', index);
				}
			}, {
				field : 'action',
				title : '编辑',
				width : 100,
				formatter : function(value, row, index) {
					return formatString('<img onclick="admin_news_editFun(\'{0}\');" src="{1}"/> ', row.id, '${pageContext.request.contextPath}/style/images/extjs_icons/pencil.png');
				}
			} ] ],
			toolbar : '#admin_news_toolbar'
		});
	});

	function admin_news_showNoteFun(index) {
		var rows = $('#admin_news_datagrid').datagrid('getRows');
		var row = rows[index];
		$('<div/>').dialog({
			title : '信息名称[' + row.name + ']',
			modal : true,
			maximizable : true,
			width : 1000,
			height : 400,
			content : '<iframe src="${pageContext.request.contextPath}/News?action=showNote&id=' + row.id + '" frameborder="0" style="border:0;width:100%;height:99%;"></iframe>',
			onClose : function() {
				$(this).dialog('destroy');
			}
		});

		$('#admin_news_datagrid').datagrid('uncheckAll').datagrid('unselectAll').datagrid('clearSelections');
	}

	function admin_news_editFun(id) {
		$('#admin_news_datagrid').datagrid('uncheckAll').datagrid('unselectAll').datagrid('clearSelections');
		$('<div/>').dialog({
			href : '${pageContext.request.contextPath}/News?action=editNew&id=' + id,
			width : 1000,
			height : 400,
			modal : true,
			title : '编辑信息',
			buttons : [ {
				text : '编辑',
				iconCls : 'icon-edit',
				handler : function() {
					var d = $(this).closest('.window-body');
					$('#admin_newsEdit_editForm').form({
						url : '${pageContext.request.contextPath}/News?action=savaEdit',
								
						success:function(result){
							d.dialog('destroy');
							var result=eval('('+result+')');
							if(result.errorMsg){
								$.messager.alert('系统提示',"<font color=red>"+result.errorMsg+"</font>");
								return;
							}else{
								$('#admin_news_datagrid').datagrid("load");
								$.messager.show({
									title : '提示',
									msg : '编辑成功!'});
							}
						}
					});
					
					$('#admin_newsEdit_editForm').submit();
				}
			} ],
			onClose : function() {
				$(this).dialog('destroy');
			},
			onLoad : function() {
			}
		});
	}
	function admin_news_appendFun() {
		$('#admin_news_datagrid').datagrid('uncheckAll').datagrid('unselectAll').datagrid('clearSelections');
		$('<div/>').dialog({
			href : '${pageContext.request.contextPath}/admin/newsAdd.jsp',
			width : 1000,
			height : 400,
			modal : true,
			title : '添加信息',
			buttons : [ {
				text : '增加',
				iconCls : 'icon-add',
				handler : function() {
					var d = $(this).closest('.window-body');
					$('#admin_newsAdd_addForm').form({
						url : '${pageContext.request.contextPath}/News?action=saveNew',
								
						success:function(result){
							d.dialog('destroy');
							var result=eval('('+result+')');
							if(result.errorMsg){
								$.messager.alert('系统提示',"<font color=red>"+result.errorMsg+"</font>");
								return;
							}else{
								$('#admin_news_datagrid').datagrid("load");
								$.messager.show({
									title : '提示',
									msg : '保存成功!'});
							}
						}
					});
					$('#admin_newsAdd_addForm').submit();
				}
			} ],
			onClose : function() {
				$(this).dialog('destroy');
			}
		});
	}
	function admin_news_removeFun() {
		var selectedRows=$("#admin_news_datagrid").datagrid('getChecked');
		if(selectedRows.length==0){
			$.messager.alert('系统提示','请选择要删除的数据!');
			return;
		}
		var strIds=[];
		for(var i=0;i<selectedRows.length;i++){
			strIds.push(selectedRows[i].id);
		}
		var ids=strIds.join(",");
		$.messager.confirm("系统提示","您确认要删除这<font color=red>"+selectedRows.length+"</font>条数据吗?",function(r){
			if(r){
				$.post("${pageContext.request.contextPath}/News?action=deleteNew",{delIds:ids},function(result){
					if(result.success){
						$.messager.alert('系统提示',"您已成功删除<font color=red>"+result.delNums+"</font>条数据!");
						$("#admin_news_datagrid").datagrid("load");
						$('#admin_news_datagrid').datagrid('uncheckAll').datagrid('unselectAll').datagrid('clearSelections');
					}else{
						$.messager.alert('系统提示',result.errorMsg);
					}
				},"json");
			}
		});
	}
	function admin_news_deleteFun(id) {
		$('#admin_news_datagrid').datagrid('uncheckAll').datagrid('unselectAll').datagrid('clearSelections');
		$('#admin_news_datagrid').datagrid('checkRow', $('#admin_news_datagrid').datagrid('getRowIndex', id));
		admin_news_removeFun();
	} 
</script>
<table id="admin_news_datagrid"></table>
<div id="admin_news_toolbar" style="display: none;">
	<a href="javascript:void(0);" onclick="admin_news_appendFun();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" style="float: left;">增加</a>
	<div class="datagrid-btn-separator"></div>
	<a href="javascript:void(0);" onclick="admin_news_removeFun();" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" style="float: left;">删除</a>
	<div class="datagrid-btn-separator"></div>
	<input id="admin_news_searchbox" class="easyui-searchbox" style="width:150px;" data-options="searcher:function(value,name){$('#admin_news_datagrid').datagrid('load',{name:value});},prompt:'可模糊查询标题'"></input> <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true" onclick="$('#admin_news_datagrid').datagrid('load',{});$('#admin_news_searchbox').searchbox('setValue','');">清空条件</a>
</div>


阅读更多

没有更多推荐了,返回首页