首页 技术 正文
技术 2022年11月15日
0 收藏 583 点赞 2,902 浏览 21197 个字

增加页面:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>表单录入</title>
</head>
<body>
<script src="<%=request.getContextPath()%>/uiPage/ods/meal/meal.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/js/ajaxfileupload.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/kindeditor-4.1.10/kindeditor.js"></script>
<script src="<%=request.getContextPath()%>/kindeditor-4.1.10/kindeditor-all.js"></script>
<script src="<%=request.getContextPath()%>/kindeditor-4.1.10/kindeditor-all-min.js"></script>
<script src="<%=request.getContextPath()%>/kindeditor-4.1.10/kindeditor-min.js"></script>
<script src="<%=request.getContextPath()%>/kindeditor-4.1.10/lang/zh_CN.js"></script>
<script type="text/javascript">
function upload(){
$.ajaxFileUpload({
url : './meal/upload.action',//用于文件上传的服务器端请求地址
secureuri : false,
fileElementId:'file',//必须和<input type="file" name="file" id="file">中的id属性的值一致,后台才能获取到文件的名称
type:'post',
dataType : 'text', //返回值类型 一般设置为json
success : function(data) {
$('#picPath').val(data);
//alert(data);
//alert(data.substring(data.lastIndexOf("\\")+1));
data1 = data.substring(data.lastIndexOf("\\")+1);
//alert(data.substring(0,data.lastIndexOf("\\")));
data = data.substring(0,data.lastIndexOf("\\"));
//alert(data.substring(data.lastIndexOf("\\")+1));
data2 = data.substring(data.lastIndexOf("\\")+1);
/* alert("/"+data1); */
$("img[id='imgId']").attr("src","/"+data2+"/"+data1);
}
})
}
(function ($, K) {
if (!K)
throw "KindEditor未定义!";
function create(target) {
var opts = $.data(target, 'kindeditor').options;
var editor = K.create(target, opts);
$.data(target, 'kindeditor').options.editor = editor;
} $.fn.kindeditor = function (options, param) {
if (typeof options == 'string') {
var method = $.fn.kindeditor.methods[options];
if (method) {
return method(this, param);
}
}
options = options || {};
return this.each(function () {
var state = $.data(this, 'kindeditor');
if (state) {
$.extend(state.options, options);
} else {
state = $.data(this, 'kindeditor', {
options : $.extend({}, $.fn.kindeditor.defaults, $.fn.kindeditor.parseOptions(this), options)
});
}
create(this);
});
}
$.fn.kindeditor.parseOptions = function (target) {
return $.extend({}, $.parser.parseOptions(target, []));
};
$.fn.kindeditor.methods = {
editor : function (jq) {
return $.data(jq[0], 'kindeditor').options.editor;
}
};
$.fn.kindeditor.defaults = {
resizeType : 1,
allowPreviewEmoticons : false,
allowImageUpload : false,
items : [
'fontname', 'fontsize', 'code','|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
'insertunorderedlist', '|', 'emoticons', 'image', 'link'],
afterChange:function(){
this.sync();//这个是必须的,如果你要覆盖afterChange事件的话,请记得最好把这句加上.
}
};
$.parser.plugins.push("kindeditor");
})(jQuery, KindEditor);
</script>
<div data-options="iconCls:'icon-costom',title:'组织机构信息'" style="padding:10px;" >
<form method="post" name="addMealForm" id="addMealForm">
<h1 style="font-weight:bold">基本信息</h1>
<div style="width:650px;height:5px;border-top:1px dashed #cccccc; margin-left:3px"></div>
<table id="layoutCentTab" align="center" class="w600">
<tr class="lh50">
<td class="stdfrm-b1">菜品名称:</td>
<td><input class="easyui-validatebox stdfrm-b2" type="text" name="meal.mealName" data-options="required:true"></input><span class="redstart">&nbsp;&nbsp;&nbsp;</span></td>
<td class="stdfrm-b3">菜品分类:</td>
<td>
<input id="type" name="meal.type" type="text" class="easyui-combobox"
data-options="value:'请选择',
width:'207',height:'24',
valueField:'code',
textField:'name',
panelHeight:'auto',
url:'./meal/queryMealType.action'"/><span class="redstart">&nbsp;&nbsp;&nbsp;</span>
</td>
</tr>
<tr class="lh50">
<td class="stdfrm-b1">单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;价:</td>
<td><input class="easyui-validatebox stdfrm-b4" type="text" name="meal.unitPrice" data-options="required:true"></input><span class="redstart">&nbsp;&nbsp;&nbsp;</span></td>
<td class="stdfrm-b3">菜品图片:</td>
<td>
<input type="file" name="file" id="file"/>
<input type="button" value="上传" onclick="upload()"></input>
</td>
</tr>
<tr class="lh50">
<!-- <td class="stdfrm-b1">菜品简介:</td>
<td><input class="easyui-validatebox stdfrm-b2" type="text" name="meal.briefIntro" data-options="required:true"></input><span class="redstart">&nbsp;&nbsp;&nbsp;</span></td> -->
<td class="stdfrm-b1">图片路径:</td>
<td><input id="picPath" readonly="readonly" class="easyui-validatebox stdfrm-b2" type="text" name="picPath" />
</tr>
<tr>
<td class="stdfrm-b1">菜品图片:&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>
<img id="imgId" height="120" width="200" src="${path }"/>
</td>
</tr>
<tr class="lh50">
<td class="stdfrm-b1">菜品简介:&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td colspan="3" ><textarea class="easyui-kindeditor" style=" width:98%;height:200px; margin-top:10px;" name="meal.briefIntro"></textarea></td>
</tr>
<tr class="lh50">
<td class="stdfrm-b1">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:</td>
<td colspan="3" ><textarea class="easyui-kindeditor" style=" width:98%;height:200px; margin-top:10px;" name="meal.comment"></textarea></td>
</tr>
</table>
</form>
</div>
</body>
</html>

查询页面:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>查看</title>
</head>
<body class="easyui-layout" data-options="fit:true">
<script src="<%=request.getContextPath()%>/uiPage/ods/meal/meal.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("#mealName").bind('blur', function(){
$(this).validatebox('enableValidation').validatebox('validate');
});
})
</script>
<div class="easyui-layout" style="width: 100%; height: 100%;" data-options="fit:true">
<div id="northLayout" data-options="region:'north',maxHeight:500,border:false" style="height: 50px;">
<table id="layoutCentTab" class="mt10 " style="float: left;">
<tr class="lh30">
<td class="w40 tl pl10">菜品名称:</td>
<td >
<input class="easyui-validatebox stdfrm-b2" type="text" style="width: 150px;" name="meal.mealName" id="mealName" data-options="validType:'minLength[4]',novalidate:true"/>
</td>
<td class="w40 tl pl10">菜品分类:</td>
<td>
<input id="type" name="meal.type" id="type" type="text" class="easyui-combobox"
data-options="mode:'remote',
valueField:'code',
textField:'name',
panelHeight:'auto',
url:'./meal/queryMealType.action',
delay:1000"/>
</td>
</tr>
</table>
<span style="float:left;margin-left:80px;margin-top:12px;"><a href="javascript:void(0)" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="easyui-linkbutton" data-options="iconCls:'icon-fi-search'" style="width:80px" onclick="doQuery();">查询</a></span>
</div>
<div data-options="region:'center'">
<table id="dg_meal"></table>
<div id="toolbar_meal">
<a href="javascript:void(0)" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="easyui-linkbutton" iconCls="icon-fi-add" plain="true" onclick="doAdd()">新增</a>
<a href="javascript:void(0)" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="easyui-linkbutton" iconCls="icon-fi-del" plain="true" onclick="deleteMeal()">刪除</a>
</div>
<div id="dd_meal"></div>
</div>
</div>
</body>
</html>

更新或修改页面:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>更新</title>
</head>
<body>
<script src="<%=request.getContextPath()%>/uiPage/ods/meal/meal.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/js/ajaxfileupload.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/kindeditor-4.1.10/kindeditor.js"></script>
<script src="<%=request.getContextPath()%>/kindeditor-4.1.10/kindeditor-all.js"></script>
<script src="<%=request.getContextPath()%>/kindeditor-4.1.10/kindeditor-all-min.js"></script>
<script src="<%=request.getContextPath()%>/kindeditor-4.1.10/kindeditor-min.js"></script>
<script src="<%=request.getContextPath()%>/kindeditor-4.1.10/lang/zh_CN.js"></script>
<script type="text/javascript">
function upload(){
$.ajaxFileUpload({
url : './meal/upload.action',//用于文件上传的服务器端请求地址
secureuri : false,
fileElementId:'file',//必须和<input type="file" name="file" id="file">中的id属性的值一致,后台才能获取到文件的名称
type:'post',
dataType : 'text', //返回值类型 一般设置为json
success : function(data) {
$('#picPath').val(data);
//alert(data);
//alert(data.substring(data.lastIndexOf("\\")+1));
data1 = data.substring(data.lastIndexOf("\\")+1);
//alert(data.substring(0,data.lastIndexOf("\\")));
data = data.substring(0,data.lastIndexOf("\\"));
//alert(data.substring(data.lastIndexOf("\\")+1));
data2 = data.substring(data.lastIndexOf("\\")+1);
//alert("/"+data2+"/"+data1);
$("img[id='imgId']").attr("src","/"+data2+"/"+data1);
}
})
}
(function ($, K) {
if (!K)
throw "KindEditor未定义!"; function create(target) {
var opts = $.data(target, 'kindeditor').options;
var editor = K.create(target, opts);
$.data(target, 'kindeditor').options.editor = editor;
} $.fn.kindeditor = function (options, param) {
if (typeof options == 'string') {
var method = $.fn.kindeditor.methods[options];
if (method) {
return method(this, param);
}
}
options = options || {};
return this.each(function () {
var state = $.data(this, 'kindeditor');
if (state) {
$.extend(state.options, options);
} else {
state = $.data(this, 'kindeditor', {
options : $.extend({}, $.fn.kindeditor.defaults, $.fn.kindeditor.parseOptions(this), options)
});
}
create(this);
});
} $.fn.kindeditor.parseOptions = function (target) {
return $.extend({}, $.parser.parseOptions(target, []));
}; $.fn.kindeditor.methods = {
editor : function (jq) {
return $.data(jq[0], 'kindeditor').options.editor;
}
}; $.fn.kindeditor.defaults = {
resizeType : 1,
allowPreviewEmoticons : false,
allowImageUpload : false,
items : [
'fontname', 'fontsize', 'code','|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
'insertunorderedlist', '|', 'emoticons', 'image', 'link'],
afterChange:function(){
this.sync();//这个是必须的,如果你要覆盖afterChange事件的话,请记得最好把这句加上.
}
};
$.parser.plugins.push("kindeditor");
})(jQuery, KindEditor);
</script>
<!--begin TabsBox-->
<div data-options="iconCls:'icon-costom',title:'组织机构信息'" style="padding:10px;" >
<form method="post" name="editMealForm" id="editMealForm">
<input type="hidden" name="meal.id" value="${meal.id }"/>
<h1 style="font-weight:bold">基本信息</h1>
<div style="width:650px;height:5px;border-top:1px dashed #cccccc; margin-left:3px"></div>
<table id="layoutCentTab" align="center">
<tr class="lh50">
<td class="stdfrm-b1">菜单名称:</td>
<td><input class="easyui-validatebox stdfrm-b2" type="text" name="meal.mealName" data-options="required:true" value="${meal.mealName}"><span class="redstart">&nbsp;&nbsp;&nbsp;</span></td>
<td class="stdfrm-b3">菜单分类:</td>
<td>
<input type="text" id="type" class="easyui-combobox" name="meal.type" value="${meal.type}"
data-options="required:true,
width:'207',height:'24',
url:'./meal/queryMealType.action',
valueField:'code',
textField:'name',
panelHeight:'auto',
"><span class="redstart">&nbsp;&nbsp;&nbsp;</span></input>
</td>
<tr class="lh50">
<td class="stdfrm-b1">单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;价:</td>
<td><input class="easyui-validatebox stdfrm-b2" type="text" name="meal.unitPrice" data-options="required:true" value="${meal.unitPrice}"><span class="redstart">&nbsp;&nbsp;&nbsp;</span></td>
<td class="stdfrm-b3">菜单图片:</td>
<td>
<input type="file" id="file" name="file"/>
<input type="button" value="上传" onclick="upload()"/>
</td>
</tr>
<tr class="lh50">
<%-- <td class="stdfrm-b1">菜单简介:</td>
<td><input class="easyui-validatebox stdfrm-b2" type="text" name="meal.briefIntro" value="${meal.briefIntro}"></input></td> --%>
<td class="stdfrm-b1">图片路径:</td>
<td><input id="picPath" readonly="readonly" class="easyui-validatebox stdfrm-b2" type="text" name="picPath" value="${meal.picPath }"/>
</tr>
<tr>
<td class="stdfrm-b1">菜品图片:&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>
<img id="imgId" height="120" width="207" src="${path }"/>
</td>
</tr>
<tr class="lh50">
<td class="stdfrm-b1">菜品简介:</td>
<td colspan="3"><textarea class="easyui-kindeditor" style=" width:98%;height:200px; margin-top:10px;" name="meal.briefIntro">${meal.briefIntro}</textarea></td>
</tr>
<tr class="lh50">
<td class="stdfrm-b1">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:</td>
<td colspan="3"><textarea class="easyui-kindeditor" style=" width:98%;height:200px; margin-top:10px;" name="meal.comment">${meal.comment}</textarea></td>
</tr>
</table>
</form>
</div>
<!--end TabsBox-->
</body>
</html>

查看页面:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>查看</title>
</head>
<body>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/cascadeEasyUICombox.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/initCascadeEasyUICombox.js"></script>
<script src="<%=request.getContextPath()%>/kindeditor-4.1.10/kindeditor.js"></script>
<script src="<%=request.getContextPath()%>/kindeditor-4.1.10/kindeditor-all.js"></script>
<script src="<%=request.getContextPath()%>/kindeditor-4.1.10/kindeditor-all-min.js"></script>
<script src="<%=request.getContextPath()%>/kindeditor-4.1.10/kindeditor-min.js"></script>
<script src="<%=request.getContextPath()%>/kindeditor-4.1.10/lang/zh_CN.js"></script>
<script language="javascript">
(function ($, K) {
if (!K)
throw "KindEditor未定义!"; function create(target) {
var opts = $.data(target, 'kindeditor').options;
var editor = K.create(target, opts);
$.data(target, 'kindeditor').options.editor = editor;
} $.fn.kindeditor = function (options, param) {
if (typeof options == 'string') {
var method = $.fn.kindeditor.methods[options];
if (method) {
return method(this, param);
}
}
options = options || {};
return this.each(function () {
var state = $.data(this, 'kindeditor');
if (state) {
$.extend(state.options, options);
} else {
state = $.data(this, 'kindeditor', {
options : $.extend({}, $.fn.kindeditor.defaults, $.fn.kindeditor.parseOptions(this), options)
});
}
create(this);
});
} $.fn.kindeditor.parseOptions = function (target) {
return $.extend({}, $.parser.parseOptions(target, []));
}; $.fn.kindeditor.methods = {
editor : function (jq) {
return $.data(jq[0], 'kindeditor').options.editor;
}
}; $.fn.kindeditor.defaults = {
resizeType : 1,
allowPreviewEmoticons : false,
allowImageUpload : false,
readonlyMode : true,
items : [
'fontname', 'fontsize', 'code','|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
'insertunorderedlist', '|', 'emoticons', 'image', 'link'],
afterChange:function(){
this.sync();//这个是必须的,如果你要覆盖afterChange事件的话,请记得最好把这句加上.
}
};
$.parser.plugins.push("kindeditor");
})(jQuery, KindEditor);
</script>
<!--begin TabsBox-->
<div data-options="iconCls:'icon-costom',title:'组织机构信息'" style="padding:10px;" >
<form method="post" name="editMealForm" id="editMealForm">
<h1 style="font-weight:bold">基本信息</h1>
<div style="width:650px;height:5px;border-top:1px dashed #cccccc; margin-left:3px"></div>
<table id="layoutCentTab" align="center">
<tr class="lh50">
<td class="stdfrm-b1">菜单名称:</td>
<td><input class="easyui-validatebox stdfrm-b2 bgf1" disabled="disabled" type="text" name="meal.mealName" data-options="required:true" value="${meal.mealName}"></input></td>
<td class="stdfrm-b3">菜品分类:</td>
<td><input class="easyui-validatebox stdfrm-b4 bgf1" disabled="disabled" type="text" name="meal.type" data-options="required:true" value="${meal.type}"></input></td>
</tr>
<tr class="lh50">
<td class="stdfrm-b1">单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;价:</td>
<td><input class="easyui-validatebox stdfrm-b2 bgf1" disabled="disabled" type="text" name="meal.unitPrice" value="${meal.unitPrice}"></input></td>
<%-- <td class="stdfrm-b3">菜品简介:</td>
<td><input class="easyui-validatebox stdfrm-b4 bgf1" disabled="disabled" type="text" name="meal.briefIntro" data-options="required:true" value="${meal.briefIntro}"></input></td> --%>
</tr>
<tr class="lh50">
<td class="stdfrm-b1">菜品图片:</td>
<td>
<img id="imgId" height="120" width="207" src="${path }"/>
</td>
</tr>
<tr class="lh50">
<td class="stdfrm-b1">菜品简介:</td>
<td colspan="3"><textarea name="meal.briefIntro" class="bgf1 easyui-kindeditor" rows="8" style="width:98%;height:250px;">${meal.briefIntro}</textarea>
</tr>
<tr class="lh50">
<td class="stdfrm-b1">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:</td>
<td colspan="3"><textarea name="meal.comment" class="bgf1 easyui-kindeditor" rows="8" style="width:98%;height:250px;">${meal.comment}</textarea>
</tr>
</table>
</form>
</div>
<!--end TabsBox-->
</body>
</html>

js:

$(function(){
//列表显示
$("#dg_meal").datagrid({
toolbar:'#toolbar_meal',
url:'./meal/queryMeal.action',
fit:true,
striped:true,
singleSelect:false,
fitColumns:true,
nowrap:false,
pagination:true,
pageSize:20,
columns:[[
{field:'id',checkbox:true},
{field:'mealName',width:5,title:'菜品名称',align:'left'},
{field:'unitPrice',width:5,title:'单价(元)',align:'left'},
{field:'type',width:5,title:'菜品分类',align:'left'},
{field:'briefIntro',width:20,title:'菜品简介',align:'left'},
{field:'_id_',title:'操作',width:5,align:'center',formatter:function(val,row,index){
return '<div class="opreation"><a href="javascript:$(\'#dg_meal\').treegrid(\'select\',\''+row.id+'\');doView(\''+row.id+'\');" rel="external nofollow" ><img src="./img/details.gif" style="vertical-align:middle;"/> 查看</a> <a href="javascript:$(\'#dg_meal\').treegrid(\'select\',\''+row.id+'\');doEdit(\''+row.id+'\');" rel="external nofollow" ><img src="./img/edit.gif" style="vertical-align:middle;"/> 修改</a> <a href="javascript:$(\'#dg_meal\').treegrid(\'select\',\''+row.id+'\');doDelete(\''+row.id+'\');" rel="external nofollow" ><img src="./img/del.gif" style="vertical-align:middle;"/> 删除</a></div>';
}}
]],
onBeforeLoad:function(){
flushCache();
},
onDblClickRow:function(rowIndex,row){
doView(row.id);
}
});
}); /**
* 分页
*/
var p = $('#dg_meal').datagrid('getPager');
$(p).pagination({
pageSize: 20,//每页显示的记录条数,默认为20
pageList: [10,20,50,100],//可以设置每页记录条数的列表
beforePageText: '第',//页数文本框前显示的汉字
afterPageText: '页 共 {pages} 页',
displayMsg: '当前显示 {from} - {to} 条记录 共 {total} 条记录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
}); /**
* 添加
*/
function doAdd(){
$('#dd_meal').dialog({
title: '新增食谱',
width: 850,
height: 550,
closed: false,
inline: false,
cache: false,
href: '/wcs/meal/toAddMeal.action',
modal: true,
buttons: [{
text:'&nbsp;&nbsp;&nbsp;&nbsp;保&nbsp;&nbsp;存&nbsp;&nbsp;&nbsp;',
iconCls:'icon-fi-save',
handler:function(){
if($('#addMealForm').validateForm()){
jQuery.ajax({
url : "./meal/addMeal.action?seq="+new Date(),
dataType : "json",
data : $("#addMealForm").serialize(),
cache : false,
type : 'POST', // 设置请求类型为 ‘POST’,默认为 ‘GET’
error : function(XMLHttpRequest, textStatus,
errorThrown) {
$.messager.alert('信息','录入失败,请检查数据!');
},
success : function(data) {
if (data.result == "success") {
$(".panel-tool-close").click();
$.messager.alert('信息','新增成功!');
$('#dg_meal').datagrid('reload');
} else if(data.result == "repeat"){
$.messager.alert('信息','录入重复:'+data.message);
} else {
$.messager.alert('信息','录入失败:'+data.message);
}
}
});
}
}
},
{
text:'&nbsp;&nbsp;&nbsp;&nbsp;取&nbsp;&nbsp;消&nbsp;&nbsp;&nbsp;',
iconCls:'icon-fi-cancel',
handler:function(){
$(".panel-tool-close").click();
}
}]
})
}/**
* 查看
*/
function doView(id){
$('#dd_meal').dialog({
title: '查看食谱',
width: 700,
height: 550,
closed: false,
inline: false,
cache: false,
href: '/wcs/meal/toViewMeal.action?id='+id,
modal: true,
buttons: [{
text:'&nbsp;&nbsp;&nbsp;&nbsp;取&nbsp;&nbsp;消&nbsp;&nbsp;&nbsp;',
iconCls:'icon-fi-cancel',
handler:function(){
$(".panel-tool-close").click();
}
}]
});
}/**
* 修改
*/
function doEdit(id){
$('#dd_meal').dialog({
title: '修改食谱',
width: 850,
height: 550,
closed: false,
inline: false,
cache: false,
href: '/wcs/meal/toUpdateMeal.action?id='+id,
modal: true,
buttons: [{
text:'&nbsp;&nbsp;&nbsp;&nbsp;保&nbsp;&nbsp;存&nbsp;&nbsp;&nbsp;',
iconCls:'icon-fi-save',
handler:function(){
jQuery.ajax({
url : "./meal/updateMeal.action?id="+id+"&seq="+new Date()+"&dictType=MEAL_KIND",
dataType : "json",
data : $("#editMealForm").serialize(),
cache : false,
type : 'POST', // 设置请求类型为 ‘POST’,默认为 ‘GET’
error : function(XMLHttpRequest, textStatus,
errorThrown) {
$.messager.alert('信息','更新失败,请检查数据!');
},
success : function(data) {
if (data.result == "success") {
$(".panel-tool-close").click();
$.messager.alert('信息','修改成功!');
$('#dg_meal').datagrid('reload');
} else {
$.messager.alert('信息','更新失败:'+data.message);
}
}
});
}
},
{
text:'&nbsp;&nbsp;&nbsp;&nbsp;取&nbsp;&nbsp;消&nbsp;&nbsp;&nbsp;',
iconCls:'icon-fi-cancel',
handler:function(){
$(".panel-tool-close").click();
}
}]
})
}/**
* 删除
*/
function doDelete(id){
var rows = $('#dg_meal').datagrid('getChecked');
var allRows = $('#dg_meal').datagrid('getSelections');
for(var i in allRows){
if(allRows[i].id == id){
rows = new Array();
rows.push(allRows[i]);
}
}
for(var i=0; i<rows.length; i++){
if(id == rows[i].id){
if(rows[i].children != undefined && rows[i].children.length > 0){
$.messager.alert('信息','不能直接删除有子节点的对象。','warning');
return;
}
}
}
if(rows.length == 0){
$.messager.alert('信息','请先选择操作对象。','info');
return;
}
var str_confirm = '即将删除批量数据,删除后将无法恢复,确实要这样做吗?';
if(rows.length <= 1){
str_confirm = '确实要删除吗?</font>';
}
$.messager.confirm('删除确认',str_confirm,function(r) {
if (r) {
jQuery.ajax({
url : "./meal/deleteMeal.action?ids="+id,
dataType : "json",
cache : false,
type : 'POST', // 设置请求类型为 ‘POST’,默认为 ‘GET’
error : function(XMLHttpRequest, textStatus, errorThrown) {
$.messager.alert('信息','删除失败。<br>错误信息:网络异常或表单数据错误。','error');
},
success : function(data) {
if(data.result == "success"){
$.messager.alert('信息','删除成功。','info');
$('#dg_meal').datagrid('reload');
}else{
if(data.message == 'false'){
$.messager.alert('信息','删除失败。错误信息:不能进行删除。','error');
}else{
$.messager.alert('信息','删除失败。错误信息1:'+data.message,'error');
}
}
}
});
}
});
}
function deleteMeal() {
var rows = $('#dg_meal').datagrid('getSelections');
var parm = '';
for(var i=0; i<rows.length; i++){
if(rows[i].children != undefined && rows[i].children.length > 0){
$.messager.alert('信息','不能直接删除有子节点的记录!','warning');
return;
}
var row = rows[i];
if(i == 0){
parm += row.id;
}else{
parm += '&ids='+row.id;
}
}
doDelete(parm);
}/**
* 查询
*/
function doQuery(){
$('#dg_meal').datagrid('reload',{
'mealName': $('#mealName').val(),
'code': $('#type').combobox('getValue')
});
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,110
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,584
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,431
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,202
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,837
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,920