页面
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/d151af84a55e4fab859ee4dcddb8340a.png#pic_center)
页面代码
<% layout('/layouts/default.html', {title: '健康知识管理', libs: ['dataGrid']}){ %>
<div class="main-content">
<div class="box box-main">
<div class="box-header">
<div class="box-title">
<i class="fa icon-notebook"></i> ${text('健康知识管理')}
</div>
<div class="box-tools pull-right">
<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
<% if(hasPermi('health:health:edit')){ %>
<a href="${ctx}/health/health/form" class="btn btn-default btnTool" title="${text('新增健康知识')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
<% } %>
<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
</div>
</div>
<div class="box-body">
<#form:form id="searchForm" model="${health}" action="${ctx}/health/health/listData" method="post" class="form-inline hide"
data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
<div class="form-group">
<label class="control-label">${text('健康知识')}:</label>
<div class="control-inline">
<#form:input path="healthKnowleage" class="form-control width-120"/>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-sm"><i class="glyphicon glyphicon-search"></i> ${text('查询')}</button>
<button type="reset" class="btn btn-default btn-sm isQuick"><i class="glyphicon glyphicon-repeat"></i> ${text('重置')}</button>
</div>
</#form:form>
<table id="dataGrid"></table>
<div id="dataGridPage"></div>
</div>
</div>
</div>
<% } %>
<script>
$('#dataGrid').dataGrid({
searchForm: $('#searchForm'),
columnModel: [
{header:'${text("健康知识")}', name:'healthKnowleage', index:'a.health_knowleage', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
return '<a href="${ctx}/health/health/form?healthCode='+row.healthCode+'" class="btnList" data-title="${text("编辑健康知识")}">'+(val||row.id)+'</a>';
}},
{header:'${text("操作")}', name:'actions', width:120, formatter: function(val, obj, row, act){
var actions = [];
actions.push('<a href="${ctx}/health/health/form?healthCode='+row.healthCode+'" class="btnList" title="${text("编辑健康知识")}"><i class="fa fa-pencil"></i></a> ');
actions.push('<a href="${ctx}/health/health/delete?healthCode='+row.healthCode+'" class="btnList" title="${text("删除健康知识")}" data-confirm="${text("确认要删除该健康知识吗?")}"><i class="fa fa-trash-o"></i></a> ');
return actions.join('');
}}
],
ajaxSuccess: function(data){
}
});
</script>
数据库表
CREATE TABLE `health` (
`health_code` varchar(100) NOT NULL COMMENT '编号',
`health_knowleage` text COMMENT '健康知识',
PRIMARY KEY (`health_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='健康知识';
INSERT INTO `jeesite`.`health` (`health_code`, `health_knowleage`) VALUES ('1', '如果牛奶不喝,就喝酸奶;酸奶不喝,就喝豆浆;如果牛奶、酸奶、豆浆都不喝,那就等死了。');
INSERT INTO `jeesite`.`health` (`health_code`, `health_knowleage`) VALUES ('2', '鹿群没有了敌人,越来越胖,是狼救了它们。');
INSERT INTO `jeesite`.`health` (`health_code`, `health_knowleage`) VALUES ('3', '每日250克碳水就能调控体重。');
INSERT INTO `jeesite`.`health` (`health_code`, `health_knowleage`) VALUES ('4', '为什么广东人瘦,饭前喝汤。饭后喝汤,越喝越胖。');
INSERT INTO `jeesite`.`health` (`health_code`, `health_knowleage`) VALUES ('5', '获得“健康食品”的殊荣,世界上仅有两种:黄豆和燕麦。');
INSERT INTO `jeesite`.`health` (`health_code`, `health_knowleage`) VALUES ('6', '每顿不能吃太饱。');
INSERT INTO `jeesite`.`health` (`health_code`, `health_knowleage`) VALUES ('7', '水果、蔬菜,预防癌症最好。');
INSERT INTO `jeesite`.`health` (`health_code`, `health_knowleage`) VALUES ('8', '红黄色蔬菜-维生素A之最。');
INSERT INTO `jeesite`.`health` (`health_code`, `health_knowleage`) VALUES ('9', '饮料里茶最好,茶叶当中绿茶最好。');
INSERT INTO `jeesite`.`health` (`health_code`, `health_knowleage`) VALUES ('10', '吃了一个半月黑木耳,3个血管都通了。');
INSERT INTO `jeesite`.`health` (`health_code`, `health_knowleage`) VALUES ('11', '少纤维,少运动,能不便秘?广播操,多按摩,保你健康。');