script
$(function () {
$("#xcpxList").datagrid({
title:"用户信息列表",
url:"/xcpx/getAll",
method:"POST",
pagination:true,
pageSize:10,
pageList:[10,20,30],
rownumbers:true,
singleSelect:true,
fit:true,
striped : true,
border:false,
idField:"id",
toolbar:"#toolbar",
fitColumns:true, //去除滚动条
columns:[[
{field:'id',title:'序号',width:40,hidden:false,align:'center'},
{field:'tbdwDm',title:'单位',width:100,align:'center'},
{field:'xcrq',title:'日期',width:100,align:'center'},
{field:'ztqd',title:'发布载体或渠道',width:80,align:'center'},
{field:'xcnr',title:'宣传内容或标题',width:100,align:'center'},
{field:'llrcXx',title:'浏览(涉及)人次-线下',width:100,align:'center'},
{field:'llrcXs',title:'浏览(涉及)人次-线上',width:100,align:'center'},
{field:'fbsl',title:'发布(张贴)数量',width:100,align:'center'},
{field:'xcxsXl',title:'宣传形式小类',width:100,align:'center'},
{field:'xcxsZl',title:'宣传形式中类',width:100,align:'center'},
{field:'xcxsDl',title:'宣传形式大类',width:100,align:'center'},
{field:'bz',title:'备注',width:100,align:'center'},
{field:'lrrDm',title:'录入人',width:85,align:'center'},
{field:'lrrq',title:'录入日期',width:90,align:'center'},
{field:'handle',title:'操作',width:150,align:'center',formatter:function (value,row,index) {
var str = '修改 删除';
return str;
}}
]]
})
});
修改
//修改
function edit(index){
$("#xcpxList").datagrid('selectRow',index);
var rowid = $("#xcpxList").datagrid("getSelected");
if(rowid){
$("#dd").dialog('open').dialog('setTitle','编辑个人所得税改革宣传培训情况明细表');
$('input[name="id"]').attr('readonly',true);
$("#ff").form("load",rowid);
}
}
删除
//逻辑删除
function del(index) {
$("#xcpxList").datagrid('selectRow',index);
var row = $("#xcpxList").datagrid("getSelected");
if(row){
$.messager.confirm('系统提示','你确定要删除选中的数据吗?',function (r) {
if (r){
$.post('/xcpx/updateDelflagById',{id:row.id},function (result) {
if (result.success){
$("#xcpxList").datagrid('reload');
}else {
$.messager.show({
title:'系统提示',
msg:result.errorMsg
});
}
},'json');
}
});
}
}
controller
//新增及修改功能
@ResponseBody
@RequestMapping("/save")
public Map save (GshsXcpxtzPxmx gshsXcpxtzPxmx,HttpServletResponse response){
Map resultMap = new HashMap();
if(null == gshsXcpxtzPxmx.getId()||gshsXcpxtzPxmx.getId().equals("")){ //如果是新增操作
gshsXcpxtzPxmx.setCreateDate(new Date());
gshsXcpxtzPxmx.setDelFlag("0");
gshsXcpxtzPxmx.setLrrq(new Date());
}else { //修改操作
gshsXcpxtzPxmx.setUpdateDate(new Date());
}
gshsXcpxtzPxmxService.save(gshsXcpxtzPxmx);
resultMap.put("success",true);
return resultMap;
}
//逻辑删除
@ResponseBody
@RequestMapping("/updateDelflagById")
public Map updateDelflagById (String id){
Map resultMap = new HashMap();
gshsXcpxtzPxmxService.updateDelflagById(id);
resultMap.put("success",true);
return resultMap;
}
dao
@Transactional
@Modifying
@Query(name = "edit",nativeQuery = true,value =
"UPDATE t91_gshs_xcpxtz_pxmx SET #{#gshsXcpxtzPxmx}")
void edit(GshsXcpxtzPxmx gshsXcpxtzPxmx);
@Transactional
@Modifying
@Query(name = "updateDelflagById",nativeQuery = true,value =
"UPDATE t91_gshs_xcpxtz_pxmx a SET a.del_flag = 1 WHERE a.id =:id")
void updateDelflagById(@Param("id") String id);